1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package chime
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/chime/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// List all AppInstanceUsers created under a single AppInstance.
16func (c *Client) ListAppInstanceUsers(ctx context.Context, params *ListAppInstanceUsersInput, optFns ...func(*Options)) (*ListAppInstanceUsersOutput, error) {
17	if params == nil {
18		params = &ListAppInstanceUsersInput{}
19	}
20
21	result, metadata, err := c.invokeOperation(ctx, "ListAppInstanceUsers", params, optFns, c.addOperationListAppInstanceUsersMiddlewares)
22	if err != nil {
23		return nil, err
24	}
25
26	out := result.(*ListAppInstanceUsersOutput)
27	out.ResultMetadata = metadata
28	return out, nil
29}
30
31type ListAppInstanceUsersInput struct {
32
33	// The ARN of the AppInstance.
34	//
35	// This member is required.
36	AppInstanceArn *string
37
38	// The maximum number of requests that you want returned.
39	MaxResults *int32
40
41	// The token passed by previous API calls until all requested users are returned.
42	NextToken *string
43
44	noSmithyDocumentSerde
45}
46
47type ListAppInstanceUsersOutput struct {
48
49	// The ARN of the AppInstance.
50	AppInstanceArn *string
51
52	// The information for each requested AppInstanceUser.
53	AppInstanceUsers []types.AppInstanceUserSummary
54
55	// The token passed by previous API calls until all requested users are returned.
56	NextToken *string
57
58	// Metadata pertaining to the operation's result.
59	ResultMetadata middleware.Metadata
60
61	noSmithyDocumentSerde
62}
63
64func (c *Client) addOperationListAppInstanceUsersMiddlewares(stack *middleware.Stack, options Options) (err error) {
65	err = stack.Serialize.Add(&awsRestjson1_serializeOpListAppInstanceUsers{}, middleware.After)
66	if err != nil {
67		return err
68	}
69	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpListAppInstanceUsers{}, 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 = addEndpointPrefix_opListAppInstanceUsersMiddleware(stack); err != nil {
110		return err
111	}
112	if err = addOpListAppInstanceUsersValidationMiddleware(stack); err != nil {
113		return err
114	}
115	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListAppInstanceUsers(options.Region), middleware.Before); err != nil {
116		return err
117	}
118	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
119		return err
120	}
121	if err = addResponseErrorMiddleware(stack); err != nil {
122		return err
123	}
124	if err = addRequestResponseLogging(stack, options); err != nil {
125		return err
126	}
127	return nil
128}
129
130type endpointPrefix_opListAppInstanceUsersMiddleware struct {
131}
132
133func (*endpointPrefix_opListAppInstanceUsersMiddleware) ID() string {
134	return "EndpointHostPrefix"
135}
136
137func (m *endpointPrefix_opListAppInstanceUsersMiddleware) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
138	out middleware.SerializeOutput, metadata middleware.Metadata, err error,
139) {
140	if smithyhttp.GetHostnameImmutable(ctx) || smithyhttp.IsEndpointHostPrefixDisabled(ctx) {
141		return next.HandleSerialize(ctx, in)
142	}
143
144	req, ok := in.Request.(*smithyhttp.Request)
145	if !ok {
146		return out, metadata, fmt.Errorf("unknown transport type %T", in.Request)
147	}
148
149	req.URL.Host = "identity-" + req.URL.Host
150
151	return next.HandleSerialize(ctx, in)
152}
153func addEndpointPrefix_opListAppInstanceUsersMiddleware(stack *middleware.Stack) error {
154	return stack.Serialize.Insert(&endpointPrefix_opListAppInstanceUsersMiddleware{}, `OperationSerializer`, middleware.After)
155}
156
157// ListAppInstanceUsersAPIClient is a client that implements the
158// ListAppInstanceUsers operation.
159type ListAppInstanceUsersAPIClient interface {
160	ListAppInstanceUsers(context.Context, *ListAppInstanceUsersInput, ...func(*Options)) (*ListAppInstanceUsersOutput, error)
161}
162
163var _ ListAppInstanceUsersAPIClient = (*Client)(nil)
164
165// ListAppInstanceUsersPaginatorOptions is the paginator options for
166// ListAppInstanceUsers
167type ListAppInstanceUsersPaginatorOptions struct {
168	// The maximum number of requests that you want returned.
169	Limit int32
170
171	// Set to true if pagination should stop if the service returns a pagination token
172	// that matches the most recent token provided to the service.
173	StopOnDuplicateToken bool
174}
175
176// ListAppInstanceUsersPaginator is a paginator for ListAppInstanceUsers
177type ListAppInstanceUsersPaginator struct {
178	options   ListAppInstanceUsersPaginatorOptions
179	client    ListAppInstanceUsersAPIClient
180	params    *ListAppInstanceUsersInput
181	nextToken *string
182	firstPage bool
183}
184
185// NewListAppInstanceUsersPaginator returns a new ListAppInstanceUsersPaginator
186func NewListAppInstanceUsersPaginator(client ListAppInstanceUsersAPIClient, params *ListAppInstanceUsersInput, optFns ...func(*ListAppInstanceUsersPaginatorOptions)) *ListAppInstanceUsersPaginator {
187	if params == nil {
188		params = &ListAppInstanceUsersInput{}
189	}
190
191	options := ListAppInstanceUsersPaginatorOptions{}
192	if params.MaxResults != nil {
193		options.Limit = *params.MaxResults
194	}
195
196	for _, fn := range optFns {
197		fn(&options)
198	}
199
200	return &ListAppInstanceUsersPaginator{
201		options:   options,
202		client:    client,
203		params:    params,
204		firstPage: true,
205	}
206}
207
208// HasMorePages returns a boolean indicating whether more pages are available
209func (p *ListAppInstanceUsersPaginator) HasMorePages() bool {
210	return p.firstPage || p.nextToken != nil
211}
212
213// NextPage retrieves the next ListAppInstanceUsers page.
214func (p *ListAppInstanceUsersPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListAppInstanceUsersOutput, error) {
215	if !p.HasMorePages() {
216		return nil, fmt.Errorf("no more pages available")
217	}
218
219	params := *p.params
220	params.NextToken = p.nextToken
221
222	var limit *int32
223	if p.options.Limit > 0 {
224		limit = &p.options.Limit
225	}
226	params.MaxResults = limit
227
228	result, err := p.client.ListAppInstanceUsers(ctx, &params, optFns...)
229	if err != nil {
230		return nil, err
231	}
232	p.firstPage = false
233
234	prevToken := p.nextToken
235	p.nextToken = result.NextToken
236
237	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
238		p.nextToken = nil
239	}
240
241	return result, nil
242}
243
244func newServiceMetadataMiddleware_opListAppInstanceUsers(region string) *awsmiddleware.RegisterServiceMetadata {
245	return &awsmiddleware.RegisterServiceMetadata{
246		Region:        region,
247		ServiceID:     ServiceID,
248		SigningName:   "chime",
249		OperationName: "ListAppInstanceUsers",
250	}
251}
252