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// Returns a list of the administrators in the AppInstance.
16func (c *Client) ListAppInstanceAdmins(ctx context.Context, params *ListAppInstanceAdminsInput, optFns ...func(*Options)) (*ListAppInstanceAdminsOutput, error) {
17	if params == nil {
18		params = &ListAppInstanceAdminsInput{}
19	}
20
21	result, metadata, err := c.invokeOperation(ctx, "ListAppInstanceAdmins", params, optFns, addOperationListAppInstanceAdminsMiddlewares)
22	if err != nil {
23		return nil, err
24	}
25
26	out := result.(*ListAppInstanceAdminsOutput)
27	out.ResultMetadata = metadata
28	return out, nil
29}
30
31type ListAppInstanceAdminsInput struct {
32
33	// The ARN of the AppInstance.
34	//
35	// This member is required.
36	AppInstanceArn *string
37
38	// The maximum number of administrators that you want to return.
39	MaxResults *int32
40
41	// The token returned from previous API requests until the number of administrators
42	// is reached.
43	NextToken *string
44}
45
46type ListAppInstanceAdminsOutput struct {
47
48	// The information for each administrator.
49	AppInstanceAdmins []types.AppInstanceAdminSummary
50
51	// The ARN of the AppInstance.
52	AppInstanceArn *string
53
54	// The token returned from previous API requests until the number of administrators
55	// is reached.
56	NextToken *string
57
58	// Metadata pertaining to the operation's result.
59	ResultMetadata middleware.Metadata
60}
61
62func addOperationListAppInstanceAdminsMiddlewares(stack *middleware.Stack, options Options) (err error) {
63	err = stack.Serialize.Add(&awsRestjson1_serializeOpListAppInstanceAdmins{}, middleware.After)
64	if err != nil {
65		return err
66	}
67	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpListAppInstanceAdmins{}, middleware.After)
68	if err != nil {
69		return err
70	}
71	if err = addSetLoggerMiddleware(stack, options); err != nil {
72		return err
73	}
74	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
75		return err
76	}
77	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
78		return err
79	}
80	if err = addResolveEndpointMiddleware(stack, options); err != nil {
81		return err
82	}
83	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
84		return err
85	}
86	if err = addRetryMiddlewares(stack, options); err != nil {
87		return err
88	}
89	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
90		return err
91	}
92	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
93		return err
94	}
95	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
96		return err
97	}
98	if err = addClientUserAgent(stack); err != nil {
99		return err
100	}
101	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
102		return err
103	}
104	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
105		return err
106	}
107	if err = addEndpointPrefix_opListAppInstanceAdminsMiddleware(stack); err != nil {
108		return err
109	}
110	if err = addOpListAppInstanceAdminsValidationMiddleware(stack); err != nil {
111		return err
112	}
113	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListAppInstanceAdmins(options.Region), middleware.Before); err != nil {
114		return err
115	}
116	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
117		return err
118	}
119	if err = addResponseErrorMiddleware(stack); err != nil {
120		return err
121	}
122	if err = addRequestResponseLogging(stack, options); err != nil {
123		return err
124	}
125	return nil
126}
127
128type endpointPrefix_opListAppInstanceAdminsMiddleware struct {
129}
130
131func (*endpointPrefix_opListAppInstanceAdminsMiddleware) ID() string {
132	return "EndpointHostPrefix"
133}
134
135func (m *endpointPrefix_opListAppInstanceAdminsMiddleware) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (
136	out middleware.SerializeOutput, metadata middleware.Metadata, err error,
137) {
138	if smithyhttp.GetHostnameImmutable(ctx) || smithyhttp.IsEndpointHostPrefixDisabled(ctx) {
139		return next.HandleSerialize(ctx, in)
140	}
141
142	req, ok := in.Request.(*smithyhttp.Request)
143	if !ok {
144		return out, metadata, fmt.Errorf("unknown transport type %T", in.Request)
145	}
146
147	req.URL.Host = "identity-" + req.URL.Host
148
149	return next.HandleSerialize(ctx, in)
150}
151func addEndpointPrefix_opListAppInstanceAdminsMiddleware(stack *middleware.Stack) error {
152	return stack.Serialize.Insert(&endpointPrefix_opListAppInstanceAdminsMiddleware{}, `OperationSerializer`, middleware.After)
153}
154
155// ListAppInstanceAdminsAPIClient is a client that implements the
156// ListAppInstanceAdmins operation.
157type ListAppInstanceAdminsAPIClient interface {
158	ListAppInstanceAdmins(context.Context, *ListAppInstanceAdminsInput, ...func(*Options)) (*ListAppInstanceAdminsOutput, error)
159}
160
161var _ ListAppInstanceAdminsAPIClient = (*Client)(nil)
162
163// ListAppInstanceAdminsPaginatorOptions is the paginator options for
164// ListAppInstanceAdmins
165type ListAppInstanceAdminsPaginatorOptions struct {
166	// The maximum number of administrators that you want to return.
167	Limit int32
168
169	// Set to true if pagination should stop if the service returns a pagination token
170	// that matches the most recent token provided to the service.
171	StopOnDuplicateToken bool
172}
173
174// ListAppInstanceAdminsPaginator is a paginator for ListAppInstanceAdmins
175type ListAppInstanceAdminsPaginator struct {
176	options   ListAppInstanceAdminsPaginatorOptions
177	client    ListAppInstanceAdminsAPIClient
178	params    *ListAppInstanceAdminsInput
179	nextToken *string
180	firstPage bool
181}
182
183// NewListAppInstanceAdminsPaginator returns a new ListAppInstanceAdminsPaginator
184func NewListAppInstanceAdminsPaginator(client ListAppInstanceAdminsAPIClient, params *ListAppInstanceAdminsInput, optFns ...func(*ListAppInstanceAdminsPaginatorOptions)) *ListAppInstanceAdminsPaginator {
185	if params == nil {
186		params = &ListAppInstanceAdminsInput{}
187	}
188
189	options := ListAppInstanceAdminsPaginatorOptions{}
190	if params.MaxResults != nil {
191		options.Limit = *params.MaxResults
192	}
193
194	for _, fn := range optFns {
195		fn(&options)
196	}
197
198	return &ListAppInstanceAdminsPaginator{
199		options:   options,
200		client:    client,
201		params:    params,
202		firstPage: true,
203	}
204}
205
206// HasMorePages returns a boolean indicating whether more pages are available
207func (p *ListAppInstanceAdminsPaginator) HasMorePages() bool {
208	return p.firstPage || p.nextToken != nil
209}
210
211// NextPage retrieves the next ListAppInstanceAdmins page.
212func (p *ListAppInstanceAdminsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListAppInstanceAdminsOutput, error) {
213	if !p.HasMorePages() {
214		return nil, fmt.Errorf("no more pages available")
215	}
216
217	params := *p.params
218	params.NextToken = p.nextToken
219
220	var limit *int32
221	if p.options.Limit > 0 {
222		limit = &p.options.Limit
223	}
224	params.MaxResults = limit
225
226	result, err := p.client.ListAppInstanceAdmins(ctx, &params, optFns...)
227	if err != nil {
228		return nil, err
229	}
230	p.firstPage = false
231
232	prevToken := p.nextToken
233	p.nextToken = result.NextToken
234
235	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
236		p.nextToken = nil
237	}
238
239	return result, nil
240}
241
242func newServiceMetadataMiddleware_opListAppInstanceAdmins(region string) *awsmiddleware.RegisterServiceMetadata {
243	return &awsmiddleware.RegisterServiceMetadata{
244		Region:        region,
245		ServiceID:     ServiceID,
246		SigningName:   "chime",
247		OperationName: "ListAppInstanceAdmins",
248	}
249}
250