forked from gruntwork-io/cloud-nuke
/
apigatewayv2_types.go
58 lines (45 loc) · 1.3 KB
/
apigatewayv2_types.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
52
53
54
55
56
57
58
package resources
import (
"context"
"github.com/andrewderr/cloud-nuke-a1/config"
awsgo "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/apigatewayv2"
"github.com/aws/aws-sdk-go/service/apigatewayv2/apigatewayv2iface"
"github.com/gruntwork-io/go-commons/errors"
)
type ApiGatewayV2 struct {
Client apigatewayv2iface.ApiGatewayV2API
Region string
Ids []string
}
func (gw *ApiGatewayV2) Init(session *session.Session) {
gw.Client = apigatewayv2.New(session)
}
func (gw *ApiGatewayV2) ResourceName() string {
return "apigatewayv2"
}
func (gw *ApiGatewayV2) ResourceIdentifiers() []string {
return gw.Ids
}
func (gw *ApiGatewayV2) MaxBatchSize() int {
return 10
}
func (gw *ApiGatewayV2) GetAndSetIdentifiers(c context.Context, configObj config.Config) ([]string, error) {
identifiers, err := gw.getAll(c, configObj)
if err != nil {
return nil, err
}
gw.Ids = awsgo.StringValueSlice(identifiers)
return gw.Ids, nil
}
func (gw *ApiGatewayV2) Nuke(identifiers []string) error {
if err := gw.nukeAll(awsgo.StringSlice(identifiers)); err != nil {
return errors.WithStackTrace(err)
}
return nil
}
type TooManyApiGatewayV2Err struct{}
func (err TooManyApiGatewayV2Err) Error() string {
return "Too many Api Gateways requested at once."
}