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// Describes your transit gateway peering attachments. 16func (c *Client) DescribeTransitGatewayPeeringAttachments(ctx context.Context, params *DescribeTransitGatewayPeeringAttachmentsInput, optFns ...func(*Options)) (*DescribeTransitGatewayPeeringAttachmentsOutput, error) { 17 if params == nil { 18 params = &DescribeTransitGatewayPeeringAttachmentsInput{} 19 } 20 21 result, metadata, err := c.invokeOperation(ctx, "DescribeTransitGatewayPeeringAttachments", params, optFns, addOperationDescribeTransitGatewayPeeringAttachmentsMiddlewares) 22 if err != nil { 23 return nil, err 24 } 25 26 out := result.(*DescribeTransitGatewayPeeringAttachmentsOutput) 27 out.ResultMetadata = metadata 28 return out, nil 29} 30 31type DescribeTransitGatewayPeeringAttachmentsInput struct { 32 33 // Checks whether you have the required permissions for the action, without 34 // actually making the request, and provides an error response. If you have the 35 // required permissions, the error response is DryRunOperation. Otherwise, it is 36 // UnauthorizedOperation. 37 DryRun bool 38 39 // One or more filters. The possible values are: 40 // 41 // * transit-gateway-attachment-id - 42 // The ID of the transit gateway attachment. 43 // 44 // * local-owner-id - The ID of your AWS 45 // account. 46 // 47 // * remote-owner-id - The ID of the AWS account in the remote Region 48 // that owns the transit gateway. 49 // 50 // * state - The state of the peering attachment. 51 // Valid values are available | deleted | deleting | failed | failing | 52 // initiatingRequest | modifying | pendingAcceptance | pending | rollingBack | 53 // rejected | rejecting). 54 // 55 // * tag: - The key/value combination of a tag assigned to 56 // the resource. Use the tag key in the filter name and the tag value as the filter 57 // value. For example, to find all resources that have a tag with the key Owner and 58 // the value TeamA, specify tag:Owner for the filter name and TeamA for the filter 59 // value. 60 // 61 // * tag-key - The key of a tag assigned to the resource. Use this filter 62 // to find all resources that have a tag with a specific key, regardless of the tag 63 // value. 64 // 65 // * transit-gateway-id - The ID of the transit gateway. 66 Filters []types.Filter 67 68 // The maximum number of results to return with a single call. To retrieve the 69 // remaining results, make another call with the returned nextToken value. 70 MaxResults int32 71 72 // The token for the next page of results. 73 NextToken *string 74 75 // One or more IDs of the transit gateway peering attachments. 76 TransitGatewayAttachmentIds []string 77} 78 79type DescribeTransitGatewayPeeringAttachmentsOutput struct { 80 81 // The token to use to retrieve the next page of results. This value is null when 82 // there are no more results to return. 83 NextToken *string 84 85 // The transit gateway peering attachments. 86 TransitGatewayPeeringAttachments []types.TransitGatewayPeeringAttachment 87 88 // Metadata pertaining to the operation's result. 89 ResultMetadata middleware.Metadata 90} 91 92func addOperationDescribeTransitGatewayPeeringAttachmentsMiddlewares(stack *middleware.Stack, options Options) (err error) { 93 err = stack.Serialize.Add(&awsEc2query_serializeOpDescribeTransitGatewayPeeringAttachments{}, middleware.After) 94 if err != nil { 95 return err 96 } 97 err = stack.Deserialize.Add(&awsEc2query_deserializeOpDescribeTransitGatewayPeeringAttachments{}, middleware.After) 98 if err != nil { 99 return err 100 } 101 if err = addSetLoggerMiddleware(stack, options); err != nil { 102 return err 103 } 104 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 105 return err 106 } 107 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 108 return err 109 } 110 if err = addResolveEndpointMiddleware(stack, options); err != nil { 111 return err 112 } 113 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 114 return err 115 } 116 if err = addRetryMiddlewares(stack, options); err != nil { 117 return err 118 } 119 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 120 return err 121 } 122 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 123 return err 124 } 125 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 126 return err 127 } 128 if err = addClientUserAgent(stack); err != nil { 129 return err 130 } 131 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 132 return err 133 } 134 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 135 return err 136 } 137 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeTransitGatewayPeeringAttachments(options.Region), middleware.Before); err != nil { 138 return err 139 } 140 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 141 return err 142 } 143 if err = addResponseErrorMiddleware(stack); err != nil { 144 return err 145 } 146 if err = addRequestResponseLogging(stack, options); err != nil { 147 return err 148 } 149 return nil 150} 151 152// DescribeTransitGatewayPeeringAttachmentsAPIClient is a client that implements 153// the DescribeTransitGatewayPeeringAttachments operation. 154type DescribeTransitGatewayPeeringAttachmentsAPIClient interface { 155 DescribeTransitGatewayPeeringAttachments(context.Context, *DescribeTransitGatewayPeeringAttachmentsInput, ...func(*Options)) (*DescribeTransitGatewayPeeringAttachmentsOutput, error) 156} 157 158var _ DescribeTransitGatewayPeeringAttachmentsAPIClient = (*Client)(nil) 159 160// DescribeTransitGatewayPeeringAttachmentsPaginatorOptions is the paginator 161// options for DescribeTransitGatewayPeeringAttachments 162type DescribeTransitGatewayPeeringAttachmentsPaginatorOptions struct { 163 // The maximum number of results to return with a single call. To retrieve the 164 // remaining results, make another call with the returned nextToken value. 165 Limit int32 166 167 // Set to true if pagination should stop if the service returns a pagination token 168 // that matches the most recent token provided to the service. 169 StopOnDuplicateToken bool 170} 171 172// DescribeTransitGatewayPeeringAttachmentsPaginator is a paginator for 173// DescribeTransitGatewayPeeringAttachments 174type DescribeTransitGatewayPeeringAttachmentsPaginator struct { 175 options DescribeTransitGatewayPeeringAttachmentsPaginatorOptions 176 client DescribeTransitGatewayPeeringAttachmentsAPIClient 177 params *DescribeTransitGatewayPeeringAttachmentsInput 178 nextToken *string 179 firstPage bool 180} 181 182// NewDescribeTransitGatewayPeeringAttachmentsPaginator returns a new 183// DescribeTransitGatewayPeeringAttachmentsPaginator 184func NewDescribeTransitGatewayPeeringAttachmentsPaginator(client DescribeTransitGatewayPeeringAttachmentsAPIClient, params *DescribeTransitGatewayPeeringAttachmentsInput, optFns ...func(*DescribeTransitGatewayPeeringAttachmentsPaginatorOptions)) *DescribeTransitGatewayPeeringAttachmentsPaginator { 185 options := DescribeTransitGatewayPeeringAttachmentsPaginatorOptions{} 186 if params.MaxResults != 0 { 187 options.Limit = params.MaxResults 188 } 189 190 for _, fn := range optFns { 191 fn(&options) 192 } 193 194 if params == nil { 195 params = &DescribeTransitGatewayPeeringAttachmentsInput{} 196 } 197 198 return &DescribeTransitGatewayPeeringAttachmentsPaginator{ 199 options: options, 200 client: client, 201 params: params, 202 firstPage: true, 203 } 204} 205 206// HasMorePages returns a boolean indicating whether more pages are available 207func (p *DescribeTransitGatewayPeeringAttachmentsPaginator) HasMorePages() bool { 208 return p.firstPage || p.nextToken != nil 209} 210 211// NextPage retrieves the next DescribeTransitGatewayPeeringAttachments page. 212func (p *DescribeTransitGatewayPeeringAttachmentsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeTransitGatewayPeeringAttachmentsOutput, error) { 213 if !p.HasMorePages() { 214 return nil, fmt.Errorf("no more pages available") 215 } 216 217 params := *p.params 218 params.NextToken = p.nextToken 219 220 params.MaxResults = p.options.Limit 221 222 result, err := p.client.DescribeTransitGatewayPeeringAttachments(ctx, ¶ms, optFns...) 223 if err != nil { 224 return nil, err 225 } 226 p.firstPage = false 227 228 prevToken := p.nextToken 229 p.nextToken = result.NextToken 230 231 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 232 p.nextToken = nil 233 } 234 235 return result, nil 236} 237 238func newServiceMetadataMiddleware_opDescribeTransitGatewayPeeringAttachments(region string) *awsmiddleware.RegisterServiceMetadata { 239 return &awsmiddleware.RegisterServiceMetadata{ 240 Region: region, 241 ServiceID: ServiceID, 242 SigningName: "ec2", 243 OperationName: "DescribeTransitGatewayPeeringAttachments", 244 } 245} 246