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