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 one or more of your VPC peering connections. 16func (c *Client) DescribeVpcPeeringConnections(ctx context.Context, params *DescribeVpcPeeringConnectionsInput, optFns ...func(*Options)) (*DescribeVpcPeeringConnectionsOutput, error) { 17 if params == nil { 18 params = &DescribeVpcPeeringConnectionsInput{} 19 } 20 21 result, metadata, err := c.invokeOperation(ctx, "DescribeVpcPeeringConnections", params, optFns, addOperationDescribeVpcPeeringConnectionsMiddlewares) 22 if err != nil { 23 return nil, err 24 } 25 26 out := result.(*DescribeVpcPeeringConnectionsOutput) 27 out.ResultMetadata = metadata 28 return out, nil 29} 30 31type DescribeVpcPeeringConnectionsInput 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. 40 // 41 // * accepter-vpc-info.cidr-block - The IPv4 CIDR block of 42 // the accepter VPC. 43 // 44 // * accepter-vpc-info.owner-id - The AWS account ID of the 45 // owner of the accepter VPC. 46 // 47 // * accepter-vpc-info.vpc-id - The ID of the accepter 48 // VPC. 49 // 50 // * expiration-time - The expiration date and time for the VPC peering 51 // connection. 52 // 53 // * requester-vpc-info.cidr-block - The IPv4 CIDR block of the 54 // requester's VPC. 55 // 56 // * requester-vpc-info.owner-id - The AWS account ID of the 57 // owner of the requester VPC. 58 // 59 // * requester-vpc-info.vpc-id - The ID of the 60 // requester VPC. 61 // 62 // * status-code - The status of the VPC peering connection 63 // (pending-acceptance | failed | expired | provisioning | active | deleting | 64 // deleted | rejected). 65 // 66 // * status-message - A message that provides more 67 // information about the status of the VPC peering connection, if applicable. 68 // 69 // * 70 // tag: - The key/value combination of a tag assigned to the resource. Use the tag 71 // key in the filter name and the tag value as the filter value. For example, to 72 // find all resources that have a tag with the key Owner and the value TeamA, 73 // specify tag:Owner for the filter name and TeamA for the filter value. 74 // 75 // * tag-key 76 // - The key of a tag assigned to the resource. Use this filter to find all 77 // resources assigned a tag with a specific key, regardless of the tag value. 78 // 79 // * 80 // vpc-peering-connection-id - The ID of the VPC peering connection. 81 Filters []types.Filter 82 83 // The maximum number of results to return with a single call. To retrieve the 84 // remaining results, make another call with the returned nextToken value. 85 MaxResults int32 86 87 // The token for the next page of results. 88 NextToken *string 89 90 // One or more VPC peering connection IDs. Default: Describes all your VPC peering 91 // connections. 92 VpcPeeringConnectionIds []string 93} 94 95type DescribeVpcPeeringConnectionsOutput struct { 96 97 // The token to use to retrieve the next page of results. This value is null when 98 // there are no more results to return. 99 NextToken *string 100 101 // Information about the VPC peering connections. 102 VpcPeeringConnections []types.VpcPeeringConnection 103 104 // Metadata pertaining to the operation's result. 105 ResultMetadata middleware.Metadata 106} 107 108func addOperationDescribeVpcPeeringConnectionsMiddlewares(stack *middleware.Stack, options Options) (err error) { 109 err = stack.Serialize.Add(&awsEc2query_serializeOpDescribeVpcPeeringConnections{}, middleware.After) 110 if err != nil { 111 return err 112 } 113 err = stack.Deserialize.Add(&awsEc2query_deserializeOpDescribeVpcPeeringConnections{}, middleware.After) 114 if err != nil { 115 return err 116 } 117 if err = addSetLoggerMiddleware(stack, options); err != nil { 118 return err 119 } 120 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 121 return err 122 } 123 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 124 return err 125 } 126 if err = addResolveEndpointMiddleware(stack, options); err != nil { 127 return err 128 } 129 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 130 return err 131 } 132 if err = addRetryMiddlewares(stack, options); err != nil { 133 return err 134 } 135 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 136 return err 137 } 138 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 139 return err 140 } 141 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 142 return err 143 } 144 if err = addClientUserAgent(stack); err != nil { 145 return err 146 } 147 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 148 return err 149 } 150 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 151 return err 152 } 153 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeVpcPeeringConnections(options.Region), middleware.Before); err != nil { 154 return err 155 } 156 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 157 return err 158 } 159 if err = addResponseErrorMiddleware(stack); err != nil { 160 return err 161 } 162 if err = addRequestResponseLogging(stack, options); err != nil { 163 return err 164 } 165 return nil 166} 167 168// DescribeVpcPeeringConnectionsAPIClient is a client that implements the 169// DescribeVpcPeeringConnections operation. 170type DescribeVpcPeeringConnectionsAPIClient interface { 171 DescribeVpcPeeringConnections(context.Context, *DescribeVpcPeeringConnectionsInput, ...func(*Options)) (*DescribeVpcPeeringConnectionsOutput, error) 172} 173 174var _ DescribeVpcPeeringConnectionsAPIClient = (*Client)(nil) 175 176// DescribeVpcPeeringConnectionsPaginatorOptions is the paginator options for 177// DescribeVpcPeeringConnections 178type DescribeVpcPeeringConnectionsPaginatorOptions struct { 179 // The maximum number of results to return with a single call. To retrieve the 180 // remaining results, make another call with the returned nextToken value. 181 Limit int32 182 183 // Set to true if pagination should stop if the service returns a pagination token 184 // that matches the most recent token provided to the service. 185 StopOnDuplicateToken bool 186} 187 188// DescribeVpcPeeringConnectionsPaginator is a paginator for 189// DescribeVpcPeeringConnections 190type DescribeVpcPeeringConnectionsPaginator struct { 191 options DescribeVpcPeeringConnectionsPaginatorOptions 192 client DescribeVpcPeeringConnectionsAPIClient 193 params *DescribeVpcPeeringConnectionsInput 194 nextToken *string 195 firstPage bool 196} 197 198// NewDescribeVpcPeeringConnectionsPaginator returns a new 199// DescribeVpcPeeringConnectionsPaginator 200func NewDescribeVpcPeeringConnectionsPaginator(client DescribeVpcPeeringConnectionsAPIClient, params *DescribeVpcPeeringConnectionsInput, optFns ...func(*DescribeVpcPeeringConnectionsPaginatorOptions)) *DescribeVpcPeeringConnectionsPaginator { 201 options := DescribeVpcPeeringConnectionsPaginatorOptions{} 202 if params.MaxResults != 0 { 203 options.Limit = params.MaxResults 204 } 205 206 for _, fn := range optFns { 207 fn(&options) 208 } 209 210 if params == nil { 211 params = &DescribeVpcPeeringConnectionsInput{} 212 } 213 214 return &DescribeVpcPeeringConnectionsPaginator{ 215 options: options, 216 client: client, 217 params: params, 218 firstPage: true, 219 } 220} 221 222// HasMorePages returns a boolean indicating whether more pages are available 223func (p *DescribeVpcPeeringConnectionsPaginator) HasMorePages() bool { 224 return p.firstPage || p.nextToken != nil 225} 226 227// NextPage retrieves the next DescribeVpcPeeringConnections page. 228func (p *DescribeVpcPeeringConnectionsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeVpcPeeringConnectionsOutput, error) { 229 if !p.HasMorePages() { 230 return nil, fmt.Errorf("no more pages available") 231 } 232 233 params := *p.params 234 params.NextToken = p.nextToken 235 236 params.MaxResults = p.options.Limit 237 238 result, err := p.client.DescribeVpcPeeringConnections(ctx, ¶ms, optFns...) 239 if err != nil { 240 return nil, err 241 } 242 p.firstPage = false 243 244 prevToken := p.nextToken 245 p.nextToken = result.NextToken 246 247 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 248 p.nextToken = nil 249 } 250 251 return result, nil 252} 253 254func newServiceMetadataMiddleware_opDescribeVpcPeeringConnections(region string) *awsmiddleware.RegisterServiceMetadata { 255 return &awsmiddleware.RegisterServiceMetadata{ 256 Region: region, 257 ServiceID: ServiceID, 258 SigningName: "ec2", 259 OperationName: "DescribeVpcPeeringConnections", 260 } 261} 262