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 the specified customer-owned address pools or all of your 16// customer-owned address pools. 17func (c *Client) DescribeCoipPools(ctx context.Context, params *DescribeCoipPoolsInput, optFns ...func(*Options)) (*DescribeCoipPoolsOutput, error) { 18 if params == nil { 19 params = &DescribeCoipPoolsInput{} 20 } 21 22 result, metadata, err := c.invokeOperation(ctx, "DescribeCoipPools", params, optFns, addOperationDescribeCoipPoolsMiddlewares) 23 if err != nil { 24 return nil, err 25 } 26 27 out := result.(*DescribeCoipPoolsOutput) 28 out.ResultMetadata = metadata 29 return out, nil 30} 31 32type DescribeCoipPoolsInput struct { 33 34 // Checks whether you have the required permissions for the action, without 35 // actually making the request, and provides an error response. If you have the 36 // required permissions, the error response is DryRunOperation. Otherwise, it is 37 // UnauthorizedOperation. 38 DryRun bool 39 40 // The filters. The following are the possible values: 41 // 42 // * coip-pool.pool-id 43 // 44 // * 45 // coip-pool.local-gateway-route-table-id 46 Filters []types.Filter 47 48 // The maximum number of results to return with a single call. To retrieve the 49 // remaining results, make another call with the returned nextToken value. 50 MaxResults int32 51 52 // The token for the next page of results. 53 NextToken *string 54 55 // The IDs of the address pools. 56 PoolIds []string 57} 58 59type DescribeCoipPoolsOutput struct { 60 61 // Information about the address pools. 62 CoipPools []types.CoipPool 63 64 // The token to use to retrieve the next page of results. This value is null when 65 // there are no more results to return. 66 NextToken *string 67 68 // Metadata pertaining to the operation's result. 69 ResultMetadata middleware.Metadata 70} 71 72func addOperationDescribeCoipPoolsMiddlewares(stack *middleware.Stack, options Options) (err error) { 73 err = stack.Serialize.Add(&awsEc2query_serializeOpDescribeCoipPools{}, middleware.After) 74 if err != nil { 75 return err 76 } 77 err = stack.Deserialize.Add(&awsEc2query_deserializeOpDescribeCoipPools{}, 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 = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeCoipPools(options.Region), middleware.Before); err != nil { 118 return err 119 } 120 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 121 return err 122 } 123 if err = addResponseErrorMiddleware(stack); err != nil { 124 return err 125 } 126 if err = addRequestResponseLogging(stack, options); err != nil { 127 return err 128 } 129 return nil 130} 131 132// DescribeCoipPoolsAPIClient is a client that implements the DescribeCoipPools 133// operation. 134type DescribeCoipPoolsAPIClient interface { 135 DescribeCoipPools(context.Context, *DescribeCoipPoolsInput, ...func(*Options)) (*DescribeCoipPoolsOutput, error) 136} 137 138var _ DescribeCoipPoolsAPIClient = (*Client)(nil) 139 140// DescribeCoipPoolsPaginatorOptions is the paginator options for DescribeCoipPools 141type DescribeCoipPoolsPaginatorOptions struct { 142 // The maximum number of results to return with a single call. To retrieve the 143 // remaining results, make another call with the returned nextToken value. 144 Limit int32 145 146 // Set to true if pagination should stop if the service returns a pagination token 147 // that matches the most recent token provided to the service. 148 StopOnDuplicateToken bool 149} 150 151// DescribeCoipPoolsPaginator is a paginator for DescribeCoipPools 152type DescribeCoipPoolsPaginator struct { 153 options DescribeCoipPoolsPaginatorOptions 154 client DescribeCoipPoolsAPIClient 155 params *DescribeCoipPoolsInput 156 nextToken *string 157 firstPage bool 158} 159 160// NewDescribeCoipPoolsPaginator returns a new DescribeCoipPoolsPaginator 161func NewDescribeCoipPoolsPaginator(client DescribeCoipPoolsAPIClient, params *DescribeCoipPoolsInput, optFns ...func(*DescribeCoipPoolsPaginatorOptions)) *DescribeCoipPoolsPaginator { 162 options := DescribeCoipPoolsPaginatorOptions{} 163 if params.MaxResults != 0 { 164 options.Limit = params.MaxResults 165 } 166 167 for _, fn := range optFns { 168 fn(&options) 169 } 170 171 if params == nil { 172 params = &DescribeCoipPoolsInput{} 173 } 174 175 return &DescribeCoipPoolsPaginator{ 176 options: options, 177 client: client, 178 params: params, 179 firstPage: true, 180 } 181} 182 183// HasMorePages returns a boolean indicating whether more pages are available 184func (p *DescribeCoipPoolsPaginator) HasMorePages() bool { 185 return p.firstPage || p.nextToken != nil 186} 187 188// NextPage retrieves the next DescribeCoipPools page. 189func (p *DescribeCoipPoolsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeCoipPoolsOutput, error) { 190 if !p.HasMorePages() { 191 return nil, fmt.Errorf("no more pages available") 192 } 193 194 params := *p.params 195 params.NextToken = p.nextToken 196 197 params.MaxResults = p.options.Limit 198 199 result, err := p.client.DescribeCoipPools(ctx, ¶ms, optFns...) 200 if err != nil { 201 return nil, err 202 } 203 p.firstPage = false 204 205 prevToken := p.nextToken 206 p.nextToken = result.NextToken 207 208 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 209 p.nextToken = nil 210 } 211 212 return result, nil 213} 214 215func newServiceMetadataMiddleware_opDescribeCoipPools(region string) *awsmiddleware.RegisterServiceMetadata { 216 return &awsmiddleware.RegisterServiceMetadata{ 217 Region: region, 218 ServiceID: ServiceID, 219 SigningName: "ec2", 220 OperationName: "DescribeCoipPools", 221 } 222} 223