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 connection notifications for VPC endpoints and VPC endpoint
16// services.
17func (c *Client) DescribeVpcEndpointConnectionNotifications(ctx context.Context, params *DescribeVpcEndpointConnectionNotificationsInput, optFns ...func(*Options)) (*DescribeVpcEndpointConnectionNotificationsOutput, error) {
18	if params == nil {
19		params = &DescribeVpcEndpointConnectionNotificationsInput{}
20	}
21
22	result, metadata, err := c.invokeOperation(ctx, "DescribeVpcEndpointConnectionNotifications", params, optFns, addOperationDescribeVpcEndpointConnectionNotificationsMiddlewares)
23	if err != nil {
24		return nil, err
25	}
26
27	out := result.(*DescribeVpcEndpointConnectionNotificationsOutput)
28	out.ResultMetadata = metadata
29	return out, nil
30}
31
32type DescribeVpcEndpointConnectionNotificationsInput struct {
33
34	// The ID of the notification.
35	ConnectionNotificationId *string
36
37	// Checks whether you have the required permissions for the action, without
38	// actually making the request, and provides an error response. If you have the
39	// required permissions, the error response is DryRunOperation. Otherwise, it is
40	// UnauthorizedOperation.
41	DryRun bool
42
43	// One or more filters.
44	//
45	// * connection-notification-arn - The ARN of the SNS topic
46	// for the notification.
47	//
48	// * connection-notification-id - The ID of the
49	// notification.
50	//
51	// * connection-notification-state - The state of the notification
52	// (Enabled | Disabled).
53	//
54	// * connection-notification-type - The type of notification
55	// (Topic).
56	//
57	// * service-id - The ID of the endpoint service.
58	//
59	// * vpc-endpoint-id -
60	// The ID of the VPC endpoint.
61	Filters []types.Filter
62
63	// The maximum number of results to return in a single call. To retrieve the
64	// remaining results, make another request with the returned NextToken value.
65	MaxResults int32
66
67	// The token to request the next page of results.
68	NextToken *string
69}
70
71type DescribeVpcEndpointConnectionNotificationsOutput struct {
72
73	// One or more notifications.
74	ConnectionNotificationSet []types.ConnectionNotification
75
76	// The token to use to retrieve the next page of results. This value is null when
77	// there are no more results to return.
78	NextToken *string
79
80	// Metadata pertaining to the operation's result.
81	ResultMetadata middleware.Metadata
82}
83
84func addOperationDescribeVpcEndpointConnectionNotificationsMiddlewares(stack *middleware.Stack, options Options) (err error) {
85	err = stack.Serialize.Add(&awsEc2query_serializeOpDescribeVpcEndpointConnectionNotifications{}, middleware.After)
86	if err != nil {
87		return err
88	}
89	err = stack.Deserialize.Add(&awsEc2query_deserializeOpDescribeVpcEndpointConnectionNotifications{}, middleware.After)
90	if err != nil {
91		return err
92	}
93	if err = addSetLoggerMiddleware(stack, options); err != nil {
94		return err
95	}
96	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
97		return err
98	}
99	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
100		return err
101	}
102	if err = addResolveEndpointMiddleware(stack, options); err != nil {
103		return err
104	}
105	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
106		return err
107	}
108	if err = addRetryMiddlewares(stack, options); err != nil {
109		return err
110	}
111	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
112		return err
113	}
114	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
115		return err
116	}
117	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
118		return err
119	}
120	if err = addClientUserAgent(stack); err != nil {
121		return err
122	}
123	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
124		return err
125	}
126	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
127		return err
128	}
129	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeVpcEndpointConnectionNotifications(options.Region), middleware.Before); err != nil {
130		return err
131	}
132	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
133		return err
134	}
135	if err = addResponseErrorMiddleware(stack); err != nil {
136		return err
137	}
138	if err = addRequestResponseLogging(stack, options); err != nil {
139		return err
140	}
141	return nil
142}
143
144// DescribeVpcEndpointConnectionNotificationsAPIClient is a client that implements
145// the DescribeVpcEndpointConnectionNotifications operation.
146type DescribeVpcEndpointConnectionNotificationsAPIClient interface {
147	DescribeVpcEndpointConnectionNotifications(context.Context, *DescribeVpcEndpointConnectionNotificationsInput, ...func(*Options)) (*DescribeVpcEndpointConnectionNotificationsOutput, error)
148}
149
150var _ DescribeVpcEndpointConnectionNotificationsAPIClient = (*Client)(nil)
151
152// DescribeVpcEndpointConnectionNotificationsPaginatorOptions is the paginator
153// options for DescribeVpcEndpointConnectionNotifications
154type DescribeVpcEndpointConnectionNotificationsPaginatorOptions struct {
155	// The maximum number of results to return in a single call. To retrieve the
156	// remaining results, make another request with the returned NextToken value.
157	Limit int32
158
159	// Set to true if pagination should stop if the service returns a pagination token
160	// that matches the most recent token provided to the service.
161	StopOnDuplicateToken bool
162}
163
164// DescribeVpcEndpointConnectionNotificationsPaginator is a paginator for
165// DescribeVpcEndpointConnectionNotifications
166type DescribeVpcEndpointConnectionNotificationsPaginator struct {
167	options   DescribeVpcEndpointConnectionNotificationsPaginatorOptions
168	client    DescribeVpcEndpointConnectionNotificationsAPIClient
169	params    *DescribeVpcEndpointConnectionNotificationsInput
170	nextToken *string
171	firstPage bool
172}
173
174// NewDescribeVpcEndpointConnectionNotificationsPaginator returns a new
175// DescribeVpcEndpointConnectionNotificationsPaginator
176func NewDescribeVpcEndpointConnectionNotificationsPaginator(client DescribeVpcEndpointConnectionNotificationsAPIClient, params *DescribeVpcEndpointConnectionNotificationsInput, optFns ...func(*DescribeVpcEndpointConnectionNotificationsPaginatorOptions)) *DescribeVpcEndpointConnectionNotificationsPaginator {
177	if params == nil {
178		params = &DescribeVpcEndpointConnectionNotificationsInput{}
179	}
180
181	options := DescribeVpcEndpointConnectionNotificationsPaginatorOptions{}
182	if params.MaxResults != 0 {
183		options.Limit = params.MaxResults
184	}
185
186	for _, fn := range optFns {
187		fn(&options)
188	}
189
190	return &DescribeVpcEndpointConnectionNotificationsPaginator{
191		options:   options,
192		client:    client,
193		params:    params,
194		firstPage: true,
195	}
196}
197
198// HasMorePages returns a boolean indicating whether more pages are available
199func (p *DescribeVpcEndpointConnectionNotificationsPaginator) HasMorePages() bool {
200	return p.firstPage || p.nextToken != nil
201}
202
203// NextPage retrieves the next DescribeVpcEndpointConnectionNotifications page.
204func (p *DescribeVpcEndpointConnectionNotificationsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeVpcEndpointConnectionNotificationsOutput, error) {
205	if !p.HasMorePages() {
206		return nil, fmt.Errorf("no more pages available")
207	}
208
209	params := *p.params
210	params.NextToken = p.nextToken
211
212	params.MaxResults = p.options.Limit
213
214	result, err := p.client.DescribeVpcEndpointConnectionNotifications(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_opDescribeVpcEndpointConnectionNotifications(region string) *awsmiddleware.RegisterServiceMetadata {
231	return &awsmiddleware.RegisterServiceMetadata{
232		Region:        region,
233		ServiceID:     ServiceID,
234		SigningName:   "ec2",
235		OperationName: "DescribeVpcEndpointConnectionNotifications",
236	}
237}
238