1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package ec2
4
5import (
6	"context"
7	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
8	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
9	"github.com/aws/aws-sdk-go-v2/service/ec2/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Exports routes from the specified transit gateway route table to the specified
15// S3 bucket. By default, all routes are exported. Alternatively, you can filter by
16// CIDR range. The routes are saved to the specified bucket in a JSON file. For
17// more information, see Export Route Tables to Amazon S3
18// (https://docs.aws.amazon.com/vpc/latest/tgw/tgw-route-tables.html#tgw-export-route-tables)
19// in Transit Gateways.
20func (c *Client) ExportTransitGatewayRoutes(ctx context.Context, params *ExportTransitGatewayRoutesInput, optFns ...func(*Options)) (*ExportTransitGatewayRoutesOutput, error) {
21	if params == nil {
22		params = &ExportTransitGatewayRoutesInput{}
23	}
24
25	result, metadata, err := c.invokeOperation(ctx, "ExportTransitGatewayRoutes", params, optFns, addOperationExportTransitGatewayRoutesMiddlewares)
26	if err != nil {
27		return nil, err
28	}
29
30	out := result.(*ExportTransitGatewayRoutesOutput)
31	out.ResultMetadata = metadata
32	return out, nil
33}
34
35type ExportTransitGatewayRoutesInput struct {
36
37	// The name of the S3 bucket.
38	//
39	// This member is required.
40	S3Bucket *string
41
42	// The ID of the route table.
43	//
44	// This member is required.
45	TransitGatewayRouteTableId *string
46
47	// Checks whether you have the required permissions for the action, without
48	// actually making the request, and provides an error response. If you have the
49	// required permissions, the error response is DryRunOperation. Otherwise, it is
50	// UnauthorizedOperation.
51	DryRun bool
52
53	// One or more filters. The possible values are:
54	//
55	// *
56	// attachment.transit-gateway-attachment-id - The id of the transit gateway
57	// attachment.
58	//
59	// * attachment.resource-id - The resource id of the transit gateway
60	// attachment.
61	//
62	// * route-search.exact-match - The exact match of the specified
63	// filter.
64	//
65	// * route-search.longest-prefix-match - The longest prefix that matches
66	// the route.
67	//
68	// * route-search.subnet-of-match - The routes with a subnet that match
69	// the specified CIDR filter.
70	//
71	// * route-search.supernet-of-match - The routes with a
72	// CIDR that encompass the CIDR filter. For example, if you have 10.0.1.0/29 and
73	// 10.0.1.0/31 routes in your route table and you specify supernet-of-match as
74	// 10.0.1.0/30, then the result returns 10.0.1.0/29.
75	//
76	// * state - The state of the
77	// route (active | blackhole).
78	//
79	// * transit-gateway-route-destination-cidr-block -
80	// The CIDR range.
81	//
82	// * type - The type of route (propagated | static).
83	Filters []types.Filter
84}
85
86type ExportTransitGatewayRoutesOutput struct {
87
88	// The URL of the exported file in Amazon S3. For example,
89	// s3://bucket_name/VPCTransitGateway/TransitGatewayRouteTables/file_name.
90	S3Location *string
91
92	// Metadata pertaining to the operation's result.
93	ResultMetadata middleware.Metadata
94}
95
96func addOperationExportTransitGatewayRoutesMiddlewares(stack *middleware.Stack, options Options) (err error) {
97	err = stack.Serialize.Add(&awsEc2query_serializeOpExportTransitGatewayRoutes{}, middleware.After)
98	if err != nil {
99		return err
100	}
101	err = stack.Deserialize.Add(&awsEc2query_deserializeOpExportTransitGatewayRoutes{}, middleware.After)
102	if err != nil {
103		return err
104	}
105	if err = addSetLoggerMiddleware(stack, options); err != nil {
106		return err
107	}
108	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
109		return err
110	}
111	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
112		return err
113	}
114	if err = addResolveEndpointMiddleware(stack, options); err != nil {
115		return err
116	}
117	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
118		return err
119	}
120	if err = addRetryMiddlewares(stack, options); err != nil {
121		return err
122	}
123	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
124		return err
125	}
126	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
127		return err
128	}
129	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
130		return err
131	}
132	if err = addClientUserAgent(stack); err != nil {
133		return err
134	}
135	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
136		return err
137	}
138	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
139		return err
140	}
141	if err = addOpExportTransitGatewayRoutesValidationMiddleware(stack); err != nil {
142		return err
143	}
144	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opExportTransitGatewayRoutes(options.Region), middleware.Before); err != nil {
145		return err
146	}
147	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
148		return err
149	}
150	if err = addResponseErrorMiddleware(stack); err != nil {
151		return err
152	}
153	if err = addRequestResponseLogging(stack, options); err != nil {
154		return err
155	}
156	return nil
157}
158
159func newServiceMetadataMiddleware_opExportTransitGatewayRoutes(region string) *awsmiddleware.RegisterServiceMetadata {
160	return &awsmiddleware.RegisterServiceMetadata{
161		Region:        region,
162		ServiceID:     ServiceID,
163		SigningName:   "ec2",
164		OperationName: "ExportTransitGatewayRoutes",
165	}
166}
167