1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package ec2
4
5import (
6	"context"
7	"fmt"
8	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
9	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
10	"github.com/aws/aws-sdk-go-v2/service/ec2/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Lists the route tables to which the specified resource attachment propagates
16// routes.
17func (c *Client) GetTransitGatewayAttachmentPropagations(ctx context.Context, params *GetTransitGatewayAttachmentPropagationsInput, optFns ...func(*Options)) (*GetTransitGatewayAttachmentPropagationsOutput, error) {
18	if params == nil {
19		params = &GetTransitGatewayAttachmentPropagationsInput{}
20	}
21
22	result, metadata, err := c.invokeOperation(ctx, "GetTransitGatewayAttachmentPropagations", params, optFns, addOperationGetTransitGatewayAttachmentPropagationsMiddlewares)
23	if err != nil {
24		return nil, err
25	}
26
27	out := result.(*GetTransitGatewayAttachmentPropagationsOutput)
28	out.ResultMetadata = metadata
29	return out, nil
30}
31
32type GetTransitGatewayAttachmentPropagationsInput struct {
33
34	// The ID of the attachment.
35	//
36	// This member is required.
37	TransitGatewayAttachmentId *string
38
39	// Checks whether you have the required permissions for the action, without
40	// actually making the request, and provides an error response. If you have the
41	// required permissions, the error response is DryRunOperation. Otherwise, it is
42	// UnauthorizedOperation.
43	DryRun bool
44
45	// One or more filters. The possible values are:
46	//
47	// * transit-gateway-route-table-id
48	// - The ID of the transit gateway route table.
49	Filters []types.Filter
50
51	// The maximum number of results to return with a single call. To retrieve the
52	// remaining results, make another call with the returned nextToken value.
53	MaxResults int32
54
55	// The token for the next page of results.
56	NextToken *string
57}
58
59type GetTransitGatewayAttachmentPropagationsOutput struct {
60
61	// The token to use to retrieve the next page of results. This value is null when
62	// there are no more results to return.
63	NextToken *string
64
65	// Information about the propagation route tables.
66	TransitGatewayAttachmentPropagations []types.TransitGatewayAttachmentPropagation
67
68	// Metadata pertaining to the operation's result.
69	ResultMetadata middleware.Metadata
70}
71
72func addOperationGetTransitGatewayAttachmentPropagationsMiddlewares(stack *middleware.Stack, options Options) (err error) {
73	err = stack.Serialize.Add(&awsEc2query_serializeOpGetTransitGatewayAttachmentPropagations{}, middleware.After)
74	if err != nil {
75		return err
76	}
77	err = stack.Deserialize.Add(&awsEc2query_deserializeOpGetTransitGatewayAttachmentPropagations{}, middleware.After)
78	if err != nil {
79		return err
80	}
81	if err = addSetLoggerMiddleware(stack, options); err != nil {
82		return err
83	}
84	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
85		return err
86	}
87	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
88		return err
89	}
90	if err = addResolveEndpointMiddleware(stack, options); err != nil {
91		return err
92	}
93	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
94		return err
95	}
96	if err = addRetryMiddlewares(stack, options); err != nil {
97		return err
98	}
99	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
100		return err
101	}
102	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
103		return err
104	}
105	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
106		return err
107	}
108	if err = addClientUserAgent(stack); err != nil {
109		return err
110	}
111	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
112		return err
113	}
114	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
115		return err
116	}
117	if err = addOpGetTransitGatewayAttachmentPropagationsValidationMiddleware(stack); err != nil {
118		return err
119	}
120	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetTransitGatewayAttachmentPropagations(options.Region), middleware.Before); err != nil {
121		return err
122	}
123	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
124		return err
125	}
126	if err = addResponseErrorMiddleware(stack); err != nil {
127		return err
128	}
129	if err = addRequestResponseLogging(stack, options); err != nil {
130		return err
131	}
132	return nil
133}
134
135// GetTransitGatewayAttachmentPropagationsAPIClient is a client that implements the
136// GetTransitGatewayAttachmentPropagations operation.
137type GetTransitGatewayAttachmentPropagationsAPIClient interface {
138	GetTransitGatewayAttachmentPropagations(context.Context, *GetTransitGatewayAttachmentPropagationsInput, ...func(*Options)) (*GetTransitGatewayAttachmentPropagationsOutput, error)
139}
140
141var _ GetTransitGatewayAttachmentPropagationsAPIClient = (*Client)(nil)
142
143// GetTransitGatewayAttachmentPropagationsPaginatorOptions is the paginator options
144// for GetTransitGatewayAttachmentPropagations
145type GetTransitGatewayAttachmentPropagationsPaginatorOptions struct {
146	// The maximum number of results to return with a single call. To retrieve the
147	// remaining results, make another call with the returned nextToken value.
148	Limit int32
149
150	// Set to true if pagination should stop if the service returns a pagination token
151	// that matches the most recent token provided to the service.
152	StopOnDuplicateToken bool
153}
154
155// GetTransitGatewayAttachmentPropagationsPaginator is a paginator for
156// GetTransitGatewayAttachmentPropagations
157type GetTransitGatewayAttachmentPropagationsPaginator struct {
158	options   GetTransitGatewayAttachmentPropagationsPaginatorOptions
159	client    GetTransitGatewayAttachmentPropagationsAPIClient
160	params    *GetTransitGatewayAttachmentPropagationsInput
161	nextToken *string
162	firstPage bool
163}
164
165// NewGetTransitGatewayAttachmentPropagationsPaginator returns a new
166// GetTransitGatewayAttachmentPropagationsPaginator
167func NewGetTransitGatewayAttachmentPropagationsPaginator(client GetTransitGatewayAttachmentPropagationsAPIClient, params *GetTransitGatewayAttachmentPropagationsInput, optFns ...func(*GetTransitGatewayAttachmentPropagationsPaginatorOptions)) *GetTransitGatewayAttachmentPropagationsPaginator {
168	options := GetTransitGatewayAttachmentPropagationsPaginatorOptions{}
169	if params.MaxResults != 0 {
170		options.Limit = params.MaxResults
171	}
172
173	for _, fn := range optFns {
174		fn(&options)
175	}
176
177	if params == nil {
178		params = &GetTransitGatewayAttachmentPropagationsInput{}
179	}
180
181	return &GetTransitGatewayAttachmentPropagationsPaginator{
182		options:   options,
183		client:    client,
184		params:    params,
185		firstPage: true,
186	}
187}
188
189// HasMorePages returns a boolean indicating whether more pages are available
190func (p *GetTransitGatewayAttachmentPropagationsPaginator) HasMorePages() bool {
191	return p.firstPage || p.nextToken != nil
192}
193
194// NextPage retrieves the next GetTransitGatewayAttachmentPropagations page.
195func (p *GetTransitGatewayAttachmentPropagationsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*GetTransitGatewayAttachmentPropagationsOutput, error) {
196	if !p.HasMorePages() {
197		return nil, fmt.Errorf("no more pages available")
198	}
199
200	params := *p.params
201	params.NextToken = p.nextToken
202
203	params.MaxResults = p.options.Limit
204
205	result, err := p.client.GetTransitGatewayAttachmentPropagations(ctx, &params, optFns...)
206	if err != nil {
207		return nil, err
208	}
209	p.firstPage = false
210
211	prevToken := p.nextToken
212	p.nextToken = result.NextToken
213
214	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
215		p.nextToken = nil
216	}
217
218	return result, nil
219}
220
221func newServiceMetadataMiddleware_opGetTransitGatewayAttachmentPropagations(region string) *awsmiddleware.RegisterServiceMetadata {
222	return &awsmiddleware.RegisterServiceMetadata{
223		Region:        region,
224		ServiceID:     ServiceID,
225		SigningName:   "ec2",
226		OperationName: "GetTransitGatewayAttachmentPropagations",
227	}
228}
229