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 IPv6 address pools.
16func (c *Client) DescribeIpv6Pools(ctx context.Context, params *DescribeIpv6PoolsInput, optFns ...func(*Options)) (*DescribeIpv6PoolsOutput, error) {
17	if params == nil {
18		params = &DescribeIpv6PoolsInput{}
19	}
20
21	result, metadata, err := c.invokeOperation(ctx, "DescribeIpv6Pools", params, optFns, addOperationDescribeIpv6PoolsMiddlewares)
22	if err != nil {
23		return nil, err
24	}
25
26	out := result.(*DescribeIpv6PoolsOutput)
27	out.ResultMetadata = metadata
28	return out, nil
29}
30
31type DescribeIpv6PoolsInput 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	// * tag: - The key/value combination of a tag assigned to
42	// the resource. Use the tag key in the filter name and the tag value as the filter
43	// value. For example, to find all resources that have a tag with the key Owner and
44	// the value TeamA, specify tag:Owner for the filter name and TeamA for the filter
45	// value.
46	//
47	// * tag-key - The key of a tag assigned to the resource. Use this filter
48	// to find all resources assigned a tag with a specific key, regardless of the tag
49	// value.
50	Filters []types.Filter
51
52	// The maximum number of results to return with a single call. To retrieve the
53	// remaining results, make another call with the returned nextToken value.
54	MaxResults int32
55
56	// The token for the next page of results.
57	NextToken *string
58
59	// The IDs of the IPv6 address pools.
60	PoolIds []string
61}
62
63type DescribeIpv6PoolsOutput struct {
64
65	// Information about the IPv6 address pools.
66	Ipv6Pools []types.Ipv6Pool
67
68	// The token to use to retrieve the next page of results. This value is null when
69	// there are no more results to return.
70	NextToken *string
71
72	// Metadata pertaining to the operation's result.
73	ResultMetadata middleware.Metadata
74}
75
76func addOperationDescribeIpv6PoolsMiddlewares(stack *middleware.Stack, options Options) (err error) {
77	err = stack.Serialize.Add(&awsEc2query_serializeOpDescribeIpv6Pools{}, middleware.After)
78	if err != nil {
79		return err
80	}
81	err = stack.Deserialize.Add(&awsEc2query_deserializeOpDescribeIpv6Pools{}, middleware.After)
82	if err != nil {
83		return err
84	}
85	if err = addSetLoggerMiddleware(stack, options); err != nil {
86		return err
87	}
88	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
89		return err
90	}
91	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
92		return err
93	}
94	if err = addResolveEndpointMiddleware(stack, options); err != nil {
95		return err
96	}
97	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
98		return err
99	}
100	if err = addRetryMiddlewares(stack, options); err != nil {
101		return err
102	}
103	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
104		return err
105	}
106	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
107		return err
108	}
109	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
110		return err
111	}
112	if err = addClientUserAgent(stack); err != nil {
113		return err
114	}
115	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
116		return err
117	}
118	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
119		return err
120	}
121	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeIpv6Pools(options.Region), middleware.Before); err != nil {
122		return err
123	}
124	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
125		return err
126	}
127	if err = addResponseErrorMiddleware(stack); err != nil {
128		return err
129	}
130	if err = addRequestResponseLogging(stack, options); err != nil {
131		return err
132	}
133	return nil
134}
135
136// DescribeIpv6PoolsAPIClient is a client that implements the DescribeIpv6Pools
137// operation.
138type DescribeIpv6PoolsAPIClient interface {
139	DescribeIpv6Pools(context.Context, *DescribeIpv6PoolsInput, ...func(*Options)) (*DescribeIpv6PoolsOutput, error)
140}
141
142var _ DescribeIpv6PoolsAPIClient = (*Client)(nil)
143
144// DescribeIpv6PoolsPaginatorOptions is the paginator options for DescribeIpv6Pools
145type DescribeIpv6PoolsPaginatorOptions 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// DescribeIpv6PoolsPaginator is a paginator for DescribeIpv6Pools
156type DescribeIpv6PoolsPaginator struct {
157	options   DescribeIpv6PoolsPaginatorOptions
158	client    DescribeIpv6PoolsAPIClient
159	params    *DescribeIpv6PoolsInput
160	nextToken *string
161	firstPage bool
162}
163
164// NewDescribeIpv6PoolsPaginator returns a new DescribeIpv6PoolsPaginator
165func NewDescribeIpv6PoolsPaginator(client DescribeIpv6PoolsAPIClient, params *DescribeIpv6PoolsInput, optFns ...func(*DescribeIpv6PoolsPaginatorOptions)) *DescribeIpv6PoolsPaginator {
166	options := DescribeIpv6PoolsPaginatorOptions{}
167	if params.MaxResults != 0 {
168		options.Limit = params.MaxResults
169	}
170
171	for _, fn := range optFns {
172		fn(&options)
173	}
174
175	if params == nil {
176		params = &DescribeIpv6PoolsInput{}
177	}
178
179	return &DescribeIpv6PoolsPaginator{
180		options:   options,
181		client:    client,
182		params:    params,
183		firstPage: true,
184	}
185}
186
187// HasMorePages returns a boolean indicating whether more pages are available
188func (p *DescribeIpv6PoolsPaginator) HasMorePages() bool {
189	return p.firstPage || p.nextToken != nil
190}
191
192// NextPage retrieves the next DescribeIpv6Pools page.
193func (p *DescribeIpv6PoolsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeIpv6PoolsOutput, error) {
194	if !p.HasMorePages() {
195		return nil, fmt.Errorf("no more pages available")
196	}
197
198	params := *p.params
199	params.NextToken = p.nextToken
200
201	params.MaxResults = p.options.Limit
202
203	result, err := p.client.DescribeIpv6Pools(ctx, &params, optFns...)
204	if err != nil {
205		return nil, err
206	}
207	p.firstPage = false
208
209	prevToken := p.nextToken
210	p.nextToken = result.NextToken
211
212	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
213		p.nextToken = nil
214	}
215
216	return result, nil
217}
218
219func newServiceMetadataMiddleware_opDescribeIpv6Pools(region string) *awsmiddleware.RegisterServiceMetadata {
220	return &awsmiddleware.RegisterServiceMetadata{
221		Region:        region,
222		ServiceID:     ServiceID,
223		SigningName:   "ec2",
224		OperationName: "DescribeIpv6Pools",
225	}
226}
227