@@ -2,8 +2,10 @@ package apigateway
22
33import (
44 "context"
5+ "fmt"
56
67 "github.com/aws/aws-sdk-go-v2/aws"
8+ "github.com/aws/aws-sdk-go-v2/aws/arn"
79 "github.com/aws/aws-sdk-go-v2/service/apigateway"
810 "github.com/aws/aws-sdk-go-v2/service/apigateway/types"
911 "github.com/cloudquery/cloudquery/plugins/source/aws/client"
@@ -26,8 +28,13 @@ func fetchApigatewayRestApis(ctx context.Context, meta schema.ClientMeta, parent
2628func resolveApigatewayRestAPIArn (ctx context.Context , meta schema.ClientMeta , resource * schema.Resource , c schema.Column ) error {
2729 cl := meta .(* client.Client )
2830 rapi := resource .Item .(types.RestApi )
29- arn := cl .RegionGlobalARN (client .ApigatewayService , restApiIDPart , * rapi .Id )
30- return resource .Set (c .Name , arn )
31+ return resource .Set (c .Name , arn.ARN {
32+ Partition : cl .Partition ,
33+ Service : string (client .ApigatewayService ),
34+ Region : cl .Region ,
35+ AccountID : "" ,
36+ Resource : fmt .Sprintf ("/restapis/%s" , aws .ToString (rapi .Id )),
37+ }.String ())
3138}
3239func fetchApigatewayRestApiAuthorizers (ctx context.Context , meta schema.ClientMeta , parent * schema.Resource , res chan <- interface {}) error {
3340 r := parent .Item .(types.RestApi )
@@ -54,8 +61,13 @@ func resolveApigatewayRestAPIAuthorizerArn(ctx context.Context, meta schema.Clie
5461 cl := meta .(* client.Client )
5562 auth := resource .Item .(types.Authorizer )
5663 rapi := resource .Parent .Item .(types.RestApi )
57- arn := cl .RegionGlobalARN (client .ApigatewayService , restApiIDPart , * rapi .Id , "authorizers" , * auth .Id )
58- return resource .Set (c .Name , arn )
64+ return resource .Set (c .Name , arn.ARN {
65+ Partition : cl .Partition ,
66+ Service : string (client .ApigatewayService ),
67+ Region : cl .Region ,
68+ AccountID : "" ,
69+ Resource : fmt .Sprintf ("/restapis/%s/authorizers/%s" , aws .ToString (rapi .Id ), aws .ToString (auth .Id )),
70+ }.String ())
5971}
6072func fetchApigatewayRestApiDeployments (ctx context.Context , meta schema.ClientMeta , parent * schema.Resource , res chan <- interface {}) error {
6173 r := parent .Item .(types.RestApi )
@@ -78,8 +90,13 @@ func resolveApigatewayRestAPIDeploymentArn(ctx context.Context, meta schema.Clie
7890 cl := meta .(* client.Client )
7991 d := resource .Item .(types.Deployment )
8092 rapi := resource .Parent .Item .(types.RestApi )
81- arn := cl .RegionGlobalARN (client .ApigatewayService , restApiIDPart , * rapi .Id , "deployments" , * d .Id )
82- return resource .Set (c .Name , arn )
93+ return resource .Set (c .Name , arn.ARN {
94+ Partition : cl .Partition ,
95+ Service : string (client .ApigatewayService ),
96+ Region : cl .Region ,
97+ AccountID : "" ,
98+ Resource : fmt .Sprintf ("/restapis/%s/deployments/%s" , aws .ToString (rapi .Id ), aws .ToString (d .Id )),
99+ }.String ())
83100}
84101func fetchApigatewayRestApiDocumentationParts (ctx context.Context , meta schema.ClientMeta , parent * schema.Resource , res chan <- interface {}) error {
85102 r := parent .Item .(types.RestApi )
@@ -106,8 +123,13 @@ func resolveApigatewayRestAPIDocumentationPartArn(ctx context.Context, meta sche
106123 cl := meta .(* client.Client )
107124 d := resource .Item .(types.DocumentationPart )
108125 rapi := resource .Parent .Item .(types.RestApi )
109- arn := cl .RegionGlobalARN (client .ApigatewayService , restApiIDPart , * rapi .Id , "documentation/parts" , * d .Id )
110- return resource .Set (c .Name , arn )
126+ return resource .Set (c .Name , arn.ARN {
127+ Partition : cl .Partition ,
128+ Service : string (client .ApigatewayService ),
129+ Region : cl .Region ,
130+ AccountID : "" ,
131+ Resource : fmt .Sprintf ("/restapis/%s/documentation/parts/%s" , aws .ToString (rapi .Id ), aws .ToString (d .Id )),
132+ }.String ())
111133}
112134func fetchApigatewayRestApiDocumentationVersions (ctx context.Context , meta schema.ClientMeta , parent * schema.Resource , res chan <- interface {}) error {
113135 r := parent .Item .(types.RestApi )
@@ -134,8 +156,13 @@ func resolveApigatewayRestAPIDocumentationVersionArn(ctx context.Context, meta s
134156 cl := meta .(* client.Client )
135157 v := resource .Item .(types.DocumentationVersion )
136158 rapi := resource .Parent .Item .(types.RestApi )
137- arn := cl .RegionGlobalARN (client .ApigatewayService , restApiIDPart , * rapi .Id , "documentation/versions" , * v .Version )
138- return resource .Set (c .Name , arn )
159+ return resource .Set (c .Name , arn.ARN {
160+ Partition : cl .Partition ,
161+ Service : string (client .ApigatewayService ),
162+ Region : cl .Region ,
163+ AccountID : "" ,
164+ Resource : fmt .Sprintf ("/restapis/%s/documentation/versions/%s" , aws .ToString (rapi .Id ), aws .ToString (v .Version )),
165+ }.String ())
139166}
140167func fetchApigatewayRestApiGatewayResponses (ctx context.Context , meta schema.ClientMeta , parent * schema.Resource , res chan <- interface {}) error {
141168 r := parent .Item .(types.RestApi )
@@ -162,8 +189,13 @@ func resolveApigatewayRestAPIGatewayResponseArn(ctx context.Context, meta schema
162189 cl := meta .(* client.Client )
163190 r := resource .Item .(types.GatewayResponse )
164191 rapi := resource .Parent .Item .(types.RestApi )
165- arn := cl .RegionGlobalARN (client .ApigatewayService , restApiIDPart , * rapi .Id , "gatewayresponses" , string (r .ResponseType ))
166- return resource .Set (c .Name , arn )
192+ return resource .Set (c .Name , arn.ARN {
193+ Partition : cl .Partition ,
194+ Service : string (client .ApigatewayService ),
195+ Region : cl .Region ,
196+ AccountID : "" ,
197+ Resource : fmt .Sprintf ("/restapis/%s/gatewayresponses/%s" , aws .ToString (rapi .Id ), string (r .ResponseType )),
198+ }.String ())
167199}
168200func fetchApigatewayRestApiModels (ctx context.Context , meta schema.ClientMeta , parent * schema.Resource , res chan <- interface {}) error {
169201 r := parent .Item .(types.RestApi )
@@ -186,8 +218,13 @@ func resolveApigatewayRestAPIModelArn(ctx context.Context, meta schema.ClientMet
186218 cl := meta .(* client.Client )
187219 m := resource .Item .(types.Model )
188220 rapi := resource .Parent .Item .(types.RestApi )
189- arn := cl .RegionGlobalARN (client .ApigatewayService , restApiIDPart , * rapi .Id , "models" , * m .Name )
190- return resource .Set (c .Name , arn )
221+ return resource .Set (c .Name , arn.ARN {
222+ Partition : cl .Partition ,
223+ Service : string (client .ApigatewayService ),
224+ Region : cl .Region ,
225+ AccountID : "" ,
226+ Resource : fmt .Sprintf ("/restapis/%s/models/%s" , aws .ToString (rapi .Id ), aws .ToString (m .Name )),
227+ }.String ())
191228}
192229func resolveApigatewayRestAPIModelModelTemplate (ctx context.Context , meta schema.ClientMeta , resource * schema.Resource , c schema.Column ) error {
193230 r := resource .Item .(types.Model )
@@ -245,8 +282,13 @@ func resolveApigatewayRestAPIRequestValidatorArn(ctx context.Context, meta schem
245282 cl := meta .(* client.Client )
246283 r := resource .Item .(types.RequestValidator )
247284 rapi := resource .Parent .Item .(types.RestApi )
248- arn := cl .RegionGlobalARN (client .ApigatewayService , restApiIDPart , * rapi .Id , "requestvalidators" , * r .Id )
249- return resource .Set (c .Name , arn )
285+ return resource .Set (c .Name , arn.ARN {
286+ Partition : cl .Partition ,
287+ Service : string (client .ApigatewayService ),
288+ Region : cl .Region ,
289+ AccountID : "" ,
290+ Resource : fmt .Sprintf ("/restapis/%s/requestvalidators/%s" , aws .ToString (rapi .Id ), aws .ToString (r .Id )),
291+ }.String ())
250292}
251293func fetchApigatewayRestApiResources (ctx context.Context , meta schema.ClientMeta , parent * schema.Resource , res chan <- interface {}) error {
252294 r := parent .Item .(types.RestApi )
@@ -269,8 +311,13 @@ func resolveApigatewayRestAPIResourceArn(ctx context.Context, meta schema.Client
269311 cl := meta .(* client.Client )
270312 r := resource .Item .(types.Resource )
271313 rapi := resource .Parent .Item .(types.RestApi )
272- arn := cl .RegionGlobalARN (client .ApigatewayService , restApiIDPart , * rapi .Id , "resources" , * r .Id )
273- return resource .Set (c .Name , arn )
314+ return resource .Set (c .Name , arn.ARN {
315+ Partition : cl .Partition ,
316+ Service : string (client .ApigatewayService ),
317+ Region : cl .Region ,
318+ AccountID : "" ,
319+ Resource : fmt .Sprintf ("/restapis/%s/resources/%s" , aws .ToString (rapi .Id ), aws .ToString (r .Id )),
320+ }.String ())
274321}
275322func fetchApigatewayRestApiStages (ctx context.Context , meta schema.ClientMeta , parent * schema.Resource , res chan <- interface {}) error {
276323 r := parent .Item .(types.RestApi )
@@ -293,6 +340,11 @@ func resolveApigatewayRestAPIStageArn(ctx context.Context, meta schema.ClientMet
293340 cl := meta .(* client.Client )
294341 s := resource .Item .(types.Stage )
295342 rapi := resource .Parent .Item .(types.RestApi )
296- arn := cl .RegionGlobalARN (client .ApigatewayService , restApiIDPart , * rapi .Id , "stages" , * s .StageName )
297- return resource .Set (c .Name , arn )
343+ return resource .Set (c .Name , arn.ARN {
344+ Partition : cl .Partition ,
345+ Service : string (client .ApigatewayService ),
346+ Region : cl .Region ,
347+ AccountID : "" ,
348+ Resource : fmt .Sprintf ("/restapis/%s/stages/%s" , aws .ToString (rapi .Id ), aws .ToString (s .StageName )),
349+ }.String ())
298350}
0 commit comments