1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package gamelift
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/gamelift/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Retrieves the properties for one or more game session queues. When requesting
16// multiple queues, use the pagination parameters to retrieve results as a set of
17// sequential pages. If successful, a GameSessionQueue object is returned for each
18// requested queue. When specifying a list of queues, objects are returned only for
19// queues that currently exist in the Region. Learn more  View Your Queues
20// (https://docs.aws.amazon.com/gamelift/latest/developerguide/queues-console.html)
21// Related actions CreateGameSessionQueue | DescribeGameSessionQueues |
22// UpdateGameSessionQueue | DeleteGameSessionQueue | All APIs by task
23// (https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-awssdk.html#reference-awssdk-resources-fleets)
24func (c *Client) DescribeGameSessionQueues(ctx context.Context, params *DescribeGameSessionQueuesInput, optFns ...func(*Options)) (*DescribeGameSessionQueuesOutput, error) {
25	if params == nil {
26		params = &DescribeGameSessionQueuesInput{}
27	}
28
29	result, metadata, err := c.invokeOperation(ctx, "DescribeGameSessionQueues", params, optFns, addOperationDescribeGameSessionQueuesMiddlewares)
30	if err != nil {
31		return nil, err
32	}
33
34	out := result.(*DescribeGameSessionQueuesOutput)
35	out.ResultMetadata = metadata
36	return out, nil
37}
38
39// Represents the input for a request operation.
40type DescribeGameSessionQueuesInput struct {
41
42	// The maximum number of results to return. Use this parameter with NextToken to
43	// get results as a set of sequential pages. You can request up to 50 results.
44	Limit *int32
45
46	// A list of queue names to retrieve information for. You can use either the queue
47	// ID or ARN value. To request settings for all queues, leave this parameter empty.
48	Names []string
49
50	// A token that indicates the start of the next sequential page of results. Use the
51	// token that is returned with a previous call to this operation. To start at the
52	// beginning of the result set, do not specify a value.
53	NextToken *string
54}
55
56// Represents the returned data in response to a request operation.
57type DescribeGameSessionQueuesOutput struct {
58
59	// A collection of objects that describe the requested game session queues.
60	GameSessionQueues []types.GameSessionQueue
61
62	// A token that indicates where to resume retrieving results on the next call to
63	// this operation. If no token is returned, these results represent the end of the
64	// list.
65	NextToken *string
66
67	// Metadata pertaining to the operation's result.
68	ResultMetadata middleware.Metadata
69}
70
71func addOperationDescribeGameSessionQueuesMiddlewares(stack *middleware.Stack, options Options) (err error) {
72	err = stack.Serialize.Add(&awsAwsjson11_serializeOpDescribeGameSessionQueues{}, middleware.After)
73	if err != nil {
74		return err
75	}
76	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpDescribeGameSessionQueues{}, middleware.After)
77	if err != nil {
78		return err
79	}
80	if err = addSetLoggerMiddleware(stack, options); err != nil {
81		return err
82	}
83	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
84		return err
85	}
86	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
87		return err
88	}
89	if err = addResolveEndpointMiddleware(stack, options); err != nil {
90		return err
91	}
92	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
93		return err
94	}
95	if err = addRetryMiddlewares(stack, options); err != nil {
96		return err
97	}
98	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
99		return err
100	}
101	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
102		return err
103	}
104	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
105		return err
106	}
107	if err = addClientUserAgent(stack); err != nil {
108		return err
109	}
110	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
111		return err
112	}
113	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
114		return err
115	}
116	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeGameSessionQueues(options.Region), middleware.Before); err != nil {
117		return err
118	}
119	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
120		return err
121	}
122	if err = addResponseErrorMiddleware(stack); err != nil {
123		return err
124	}
125	if err = addRequestResponseLogging(stack, options); err != nil {
126		return err
127	}
128	return nil
129}
130
131// DescribeGameSessionQueuesAPIClient is a client that implements the
132// DescribeGameSessionQueues operation.
133type DescribeGameSessionQueuesAPIClient interface {
134	DescribeGameSessionQueues(context.Context, *DescribeGameSessionQueuesInput, ...func(*Options)) (*DescribeGameSessionQueuesOutput, error)
135}
136
137var _ DescribeGameSessionQueuesAPIClient = (*Client)(nil)
138
139// DescribeGameSessionQueuesPaginatorOptions is the paginator options for
140// DescribeGameSessionQueues
141type DescribeGameSessionQueuesPaginatorOptions struct {
142	// The maximum number of results to return. Use this parameter with NextToken to
143	// get results as a set of sequential pages. You can request up to 50 results.
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// DescribeGameSessionQueuesPaginator is a paginator for DescribeGameSessionQueues
152type DescribeGameSessionQueuesPaginator struct {
153	options   DescribeGameSessionQueuesPaginatorOptions
154	client    DescribeGameSessionQueuesAPIClient
155	params    *DescribeGameSessionQueuesInput
156	nextToken *string
157	firstPage bool
158}
159
160// NewDescribeGameSessionQueuesPaginator returns a new
161// DescribeGameSessionQueuesPaginator
162func NewDescribeGameSessionQueuesPaginator(client DescribeGameSessionQueuesAPIClient, params *DescribeGameSessionQueuesInput, optFns ...func(*DescribeGameSessionQueuesPaginatorOptions)) *DescribeGameSessionQueuesPaginator {
163	if params == nil {
164		params = &DescribeGameSessionQueuesInput{}
165	}
166
167	options := DescribeGameSessionQueuesPaginatorOptions{}
168	if params.Limit != nil {
169		options.Limit = *params.Limit
170	}
171
172	for _, fn := range optFns {
173		fn(&options)
174	}
175
176	return &DescribeGameSessionQueuesPaginator{
177		options:   options,
178		client:    client,
179		params:    params,
180		firstPage: true,
181	}
182}
183
184// HasMorePages returns a boolean indicating whether more pages are available
185func (p *DescribeGameSessionQueuesPaginator) HasMorePages() bool {
186	return p.firstPage || p.nextToken != nil
187}
188
189// NextPage retrieves the next DescribeGameSessionQueues page.
190func (p *DescribeGameSessionQueuesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeGameSessionQueuesOutput, error) {
191	if !p.HasMorePages() {
192		return nil, fmt.Errorf("no more pages available")
193	}
194
195	params := *p.params
196	params.NextToken = p.nextToken
197
198	var limit *int32
199	if p.options.Limit > 0 {
200		limit = &p.options.Limit
201	}
202	params.Limit = limit
203
204	result, err := p.client.DescribeGameSessionQueues(ctx, &params, optFns...)
205	if err != nil {
206		return nil, err
207	}
208	p.firstPage = false
209
210	prevToken := p.nextToken
211	p.nextToken = result.NextToken
212
213	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
214		p.nextToken = nil
215	}
216
217	return result, nil
218}
219
220func newServiceMetadataMiddleware_opDescribeGameSessionQueues(region string) *awsmiddleware.RegisterServiceMetadata {
221	return &awsmiddleware.RegisterServiceMetadata{
222		Region:        region,
223		ServiceID:     ServiceID,
224		SigningName:   "gamelift",
225		OperationName: "DescribeGameSessionQueues",
226	}
227}
228