/
portfolios_fetch.go
51 lines (42 loc) · 1.33 KB
/
portfolios_fetch.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package servicecatalog
import (
"context"
"github.com/OpsHelmInc/cloudquery/client"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/servicecatalog"
"github.com/aws/aws-sdk-go-v2/service/servicecatalog/types"
"github.com/aws/aws-sdk-go-v2/service/servicecatalogappregistry"
"github.com/cloudquery/plugin-sdk/schema"
)
func fetchServicecatalogPortfolios(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
c := meta.(*client.Client)
svc := c.Services().Servicecatalog
listInput := new(servicecatalog.ListPortfoliosInput)
for {
output, err := svc.ListPortfolios(ctx, listInput)
if err != nil {
return err
}
res <- output.PortfolioDetails
if aws.ToString(output.NextPageToken) == "" {
break
}
listInput.PageToken = output.NextPageToken
}
return nil
}
func resolvePortfolioTags(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
port := resource.Item.(types.PortfolioDetail)
cl := meta.(*client.Client)
svc := cl.Services().Servicecatalogappregistry
response, err := svc.ListTagsForResource(ctx, &servicecatalogappregistry.ListTagsForResourceInput{
ResourceArn: port.ARN,
})
if err != nil {
if cl.IsNotFoundError(err) {
return nil
}
return err
}
return resource.Set(c.Name, response.Tags)
}