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 VPC endpoint connections to your VPC endpoint services, including
16// any endpoints that are pending your acceptance.
17func (c *Client) DescribeVpcEndpointConnections(ctx context.Context, params *DescribeVpcEndpointConnectionsInput, optFns ...func(*Options)) (*DescribeVpcEndpointConnectionsOutput, error) {
18	if params == nil {
19		params = &DescribeVpcEndpointConnectionsInput{}
20	}
21
22	result, metadata, err := c.invokeOperation(ctx, "DescribeVpcEndpointConnections", params, optFns, addOperationDescribeVpcEndpointConnectionsMiddlewares)
23	if err != nil {
24		return nil, err
25	}
26
27	out := result.(*DescribeVpcEndpointConnectionsOutput)
28	out.ResultMetadata = metadata
29	return out, nil
30}
31
32type DescribeVpcEndpointConnectionsInput 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	// One or more filters.
41	//
42	// * service-id - The ID of the service.
43	//
44	// *
45	// vpc-endpoint-owner - The AWS account number of the owner of the endpoint.
46	//
47	// *
48	// vpc-endpoint-state - The state of the endpoint (pendingAcceptance | pending |
49	// available | deleting | deleted | rejected | failed).
50	//
51	// * vpc-endpoint-id - The ID
52	// of the endpoint.
53	Filters []types.Filter
54
55	// The maximum number of results to return for the request in a single page. The
56	// remaining results of the initial request can be seen by sending another request
57	// with the returned NextToken value. This value can be between 5 and 1,000; if
58	// MaxResults is given a value larger than 1,000, only 1,000 results are returned.
59	MaxResults *int32
60
61	// The token to retrieve the next page of results.
62	NextToken *string
63}
64
65type DescribeVpcEndpointConnectionsOutput struct {
66
67	// The token to use to retrieve the next page of results. This value is null when
68	// there are no more results to return.
69	NextToken *string
70
71	// Information about one or more VPC endpoint connections.
72	VpcEndpointConnections []types.VpcEndpointConnection
73
74	// Metadata pertaining to the operation's result.
75	ResultMetadata middleware.Metadata
76}
77
78func addOperationDescribeVpcEndpointConnectionsMiddlewares(stack *middleware.Stack, options Options) (err error) {
79	err = stack.Serialize.Add(&awsEc2query_serializeOpDescribeVpcEndpointConnections{}, middleware.After)
80	if err != nil {
81		return err
82	}
83	err = stack.Deserialize.Add(&awsEc2query_deserializeOpDescribeVpcEndpointConnections{}, middleware.After)
84	if err != nil {
85		return err
86	}
87	if err = addSetLoggerMiddleware(stack, options); err != nil {
88		return err
89	}
90	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
91		return err
92	}
93	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
94		return err
95	}
96	if err = addResolveEndpointMiddleware(stack, options); err != nil {
97		return err
98	}
99	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
100		return err
101	}
102	if err = addRetryMiddlewares(stack, options); err != nil {
103		return err
104	}
105	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
106		return err
107	}
108	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
109		return err
110	}
111	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
112		return err
113	}
114	if err = addClientUserAgent(stack); err != nil {
115		return err
116	}
117	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
118		return err
119	}
120	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
121		return err
122	}
123	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeVpcEndpointConnections(options.Region), middleware.Before); err != nil {
124		return err
125	}
126	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
127		return err
128	}
129	if err = addResponseErrorMiddleware(stack); err != nil {
130		return err
131	}
132	if err = addRequestResponseLogging(stack, options); err != nil {
133		return err
134	}
135	return nil
136}
137
138// DescribeVpcEndpointConnectionsAPIClient is a client that implements the
139// DescribeVpcEndpointConnections operation.
140type DescribeVpcEndpointConnectionsAPIClient interface {
141	DescribeVpcEndpointConnections(context.Context, *DescribeVpcEndpointConnectionsInput, ...func(*Options)) (*DescribeVpcEndpointConnectionsOutput, error)
142}
143
144var _ DescribeVpcEndpointConnectionsAPIClient = (*Client)(nil)
145
146// DescribeVpcEndpointConnectionsPaginatorOptions is the paginator options for
147// DescribeVpcEndpointConnections
148type DescribeVpcEndpointConnectionsPaginatorOptions struct {
149	// The maximum number of results to return for the request in a single page. The
150	// remaining results of the initial request can be seen by sending another request
151	// with the returned NextToken value. This value can be between 5 and 1,000; if
152	// MaxResults is given a value larger than 1,000, only 1,000 results are returned.
153	Limit int32
154
155	// Set to true if pagination should stop if the service returns a pagination token
156	// that matches the most recent token provided to the service.
157	StopOnDuplicateToken bool
158}
159
160// DescribeVpcEndpointConnectionsPaginator is a paginator for
161// DescribeVpcEndpointConnections
162type DescribeVpcEndpointConnectionsPaginator struct {
163	options   DescribeVpcEndpointConnectionsPaginatorOptions
164	client    DescribeVpcEndpointConnectionsAPIClient
165	params    *DescribeVpcEndpointConnectionsInput
166	nextToken *string
167	firstPage bool
168}
169
170// NewDescribeVpcEndpointConnectionsPaginator returns a new
171// DescribeVpcEndpointConnectionsPaginator
172func NewDescribeVpcEndpointConnectionsPaginator(client DescribeVpcEndpointConnectionsAPIClient, params *DescribeVpcEndpointConnectionsInput, optFns ...func(*DescribeVpcEndpointConnectionsPaginatorOptions)) *DescribeVpcEndpointConnectionsPaginator {
173	if params == nil {
174		params = &DescribeVpcEndpointConnectionsInput{}
175	}
176
177	options := DescribeVpcEndpointConnectionsPaginatorOptions{}
178	if params.MaxResults != nil {
179		options.Limit = *params.MaxResults
180	}
181
182	for _, fn := range optFns {
183		fn(&options)
184	}
185
186	return &DescribeVpcEndpointConnectionsPaginator{
187		options:   options,
188		client:    client,
189		params:    params,
190		firstPage: true,
191	}
192}
193
194// HasMorePages returns a boolean indicating whether more pages are available
195func (p *DescribeVpcEndpointConnectionsPaginator) HasMorePages() bool {
196	return p.firstPage || p.nextToken != nil
197}
198
199// NextPage retrieves the next DescribeVpcEndpointConnections page.
200func (p *DescribeVpcEndpointConnectionsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeVpcEndpointConnectionsOutput, error) {
201	if !p.HasMorePages() {
202		return nil, fmt.Errorf("no more pages available")
203	}
204
205	params := *p.params
206	params.NextToken = p.nextToken
207
208	var limit *int32
209	if p.options.Limit > 0 {
210		limit = &p.options.Limit
211	}
212	params.MaxResults = limit
213
214	result, err := p.client.DescribeVpcEndpointConnections(ctx, &params, optFns...)
215	if err != nil {
216		return nil, err
217	}
218	p.firstPage = false
219
220	prevToken := p.nextToken
221	p.nextToken = result.NextToken
222
223	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
224		p.nextToken = nil
225	}
226
227	return result, nil
228}
229
230func newServiceMetadataMiddleware_opDescribeVpcEndpointConnections(region string) *awsmiddleware.RegisterServiceMetadata {
231	return &awsmiddleware.RegisterServiceMetadata{
232		Region:        region,
233		ServiceID:     ServiceID,
234		SigningName:   "ec2",
235		OperationName: "DescribeVpcEndpointConnections",
236	}
237}
238