1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package connect
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/connect/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Provides information about the queues for the specified Amazon Connect instance.
16// For more information about queues, see Queues: Standard and Agent
17// (https://docs.aws.amazon.com/connect/latest/adminguide/concepts-queues-standard-and-agent.html)
18// in the Amazon Connect Administrator Guide.
19func (c *Client) ListQueues(ctx context.Context, params *ListQueuesInput, optFns ...func(*Options)) (*ListQueuesOutput, error) {
20	if params == nil {
21		params = &ListQueuesInput{}
22	}
23
24	result, metadata, err := c.invokeOperation(ctx, "ListQueues", params, optFns, addOperationListQueuesMiddlewares)
25	if err != nil {
26		return nil, err
27	}
28
29	out := result.(*ListQueuesOutput)
30	out.ResultMetadata = metadata
31	return out, nil
32}
33
34type ListQueuesInput struct {
35
36	// The identifier of the Amazon Connect instance.
37	//
38	// This member is required.
39	InstanceId *string
40
41	// The maximimum number of results to return per page.
42	MaxResults int32
43
44	// The token for the next set of results. Use the value returned in the previous
45	// response in the next request to retrieve the next set of results.
46	NextToken *string
47
48	// The type of queue.
49	QueueTypes []types.QueueType
50}
51
52type ListQueuesOutput struct {
53
54	// If there are additional results, this is the token for the next set of results.
55	NextToken *string
56
57	// Information about the queues.
58	QueueSummaryList []types.QueueSummary
59
60	// Metadata pertaining to the operation's result.
61	ResultMetadata middleware.Metadata
62}
63
64func addOperationListQueuesMiddlewares(stack *middleware.Stack, options Options) (err error) {
65	err = stack.Serialize.Add(&awsRestjson1_serializeOpListQueues{}, middleware.After)
66	if err != nil {
67		return err
68	}
69	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpListQueues{}, middleware.After)
70	if err != nil {
71		return err
72	}
73	if err = addSetLoggerMiddleware(stack, options); err != nil {
74		return err
75	}
76	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
77		return err
78	}
79	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
80		return err
81	}
82	if err = addResolveEndpointMiddleware(stack, options); err != nil {
83		return err
84	}
85	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
86		return err
87	}
88	if err = addRetryMiddlewares(stack, options); err != nil {
89		return err
90	}
91	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
92		return err
93	}
94	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
95		return err
96	}
97	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
98		return err
99	}
100	if err = addClientUserAgent(stack); err != nil {
101		return err
102	}
103	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
104		return err
105	}
106	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
107		return err
108	}
109	if err = addOpListQueuesValidationMiddleware(stack); err != nil {
110		return err
111	}
112	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListQueues(options.Region), middleware.Before); err != nil {
113		return err
114	}
115	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
116		return err
117	}
118	if err = addResponseErrorMiddleware(stack); err != nil {
119		return err
120	}
121	if err = addRequestResponseLogging(stack, options); err != nil {
122		return err
123	}
124	return nil
125}
126
127// ListQueuesAPIClient is a client that implements the ListQueues operation.
128type ListQueuesAPIClient interface {
129	ListQueues(context.Context, *ListQueuesInput, ...func(*Options)) (*ListQueuesOutput, error)
130}
131
132var _ ListQueuesAPIClient = (*Client)(nil)
133
134// ListQueuesPaginatorOptions is the paginator options for ListQueues
135type ListQueuesPaginatorOptions struct {
136	// The maximimum number of results to return per page.
137	Limit int32
138
139	// Set to true if pagination should stop if the service returns a pagination token
140	// that matches the most recent token provided to the service.
141	StopOnDuplicateToken bool
142}
143
144// ListQueuesPaginator is a paginator for ListQueues
145type ListQueuesPaginator struct {
146	options   ListQueuesPaginatorOptions
147	client    ListQueuesAPIClient
148	params    *ListQueuesInput
149	nextToken *string
150	firstPage bool
151}
152
153// NewListQueuesPaginator returns a new ListQueuesPaginator
154func NewListQueuesPaginator(client ListQueuesAPIClient, params *ListQueuesInput, optFns ...func(*ListQueuesPaginatorOptions)) *ListQueuesPaginator {
155	options := ListQueuesPaginatorOptions{}
156	if params.MaxResults != 0 {
157		options.Limit = params.MaxResults
158	}
159
160	for _, fn := range optFns {
161		fn(&options)
162	}
163
164	if params == nil {
165		params = &ListQueuesInput{}
166	}
167
168	return &ListQueuesPaginator{
169		options:   options,
170		client:    client,
171		params:    params,
172		firstPage: true,
173	}
174}
175
176// HasMorePages returns a boolean indicating whether more pages are available
177func (p *ListQueuesPaginator) HasMorePages() bool {
178	return p.firstPage || p.nextToken != nil
179}
180
181// NextPage retrieves the next ListQueues page.
182func (p *ListQueuesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListQueuesOutput, error) {
183	if !p.HasMorePages() {
184		return nil, fmt.Errorf("no more pages available")
185	}
186
187	params := *p.params
188	params.NextToken = p.nextToken
189
190	params.MaxResults = p.options.Limit
191
192	result, err := p.client.ListQueues(ctx, &params, optFns...)
193	if err != nil {
194		return nil, err
195	}
196	p.firstPage = false
197
198	prevToken := p.nextToken
199	p.nextToken = result.NextToken
200
201	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
202		p.nextToken = nil
203	}
204
205	return result, nil
206}
207
208func newServiceMetadataMiddleware_opListQueues(region string) *awsmiddleware.RegisterServiceMetadata {
209	return &awsmiddleware.RegisterServiceMetadata{
210		Region:        region,
211		ServiceID:     ServiceID,
212		SigningName:   "connect",
213		OperationName: "ListQueues",
214	}
215}
216