-
Notifications
You must be signed in to change notification settings - Fork 0
/
reserved_cache_nodes_offerings_fetch.go
37 lines (33 loc) · 1.18 KB
/
reserved_cache_nodes_offerings_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
package elasticache
import (
"context"
"github.com/OpsHelmInc/cloudquery/client"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws/arn"
"github.com/aws/aws-sdk-go-v2/service/elasticache"
"github.com/aws/aws-sdk-go-v2/service/elasticache/types"
"github.com/cloudquery/plugin-sdk/schema"
)
func fetchElasticacheReservedCacheNodesOfferings(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
paginator := elasticache.NewDescribeReservedCacheNodesOfferingsPaginator(meta.(*client.Client).Services().Elasticache, nil)
for paginator.HasMorePages() {
v, err := paginator.NextPage(ctx)
if err != nil {
return err
}
res <- v.ReservedCacheNodesOfferings
}
return nil
}
func resolveCacheNodesOfferingArn(_ context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
cl := meta.(*client.Client)
item := resource.Item.(types.ReservedCacheNodesOffering)
a := arn.ARN{
Partition: cl.Partition,
Service: "elasticache",
Region: cl.Region,
AccountID: cl.AccountID,
Resource: "elasticache/" + aws.ToString(item.ReservedCacheNodesOfferingId),
}
return resource.Set(c.Name, a.String())
}