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/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// This API is in preview release for Amazon Connect and is subject to change.
15// Returns a paginated list of all Lambda functions that display in the dropdown
16// options in the relevant contact flow blocks.
17func (c *Client) ListLambdaFunctions(ctx context.Context, params *ListLambdaFunctionsInput, optFns ...func(*Options)) (*ListLambdaFunctionsOutput, error) {
18	if params == nil {
19		params = &ListLambdaFunctionsInput{}
20	}
21
22	result, metadata, err := c.invokeOperation(ctx, "ListLambdaFunctions", params, optFns, c.addOperationListLambdaFunctionsMiddlewares)
23	if err != nil {
24		return nil, err
25	}
26
27	out := result.(*ListLambdaFunctionsOutput)
28	out.ResultMetadata = metadata
29	return out, nil
30}
31
32type ListLambdaFunctionsInput struct {
33
34	// The identifier of the Amazon Connect instance. You can find the instanceId in
35	// the ARN of the instance.
36	//
37	// This member is required.
38	InstanceId *string
39
40	// The maximum number of results to return per page.
41	MaxResults int32
42
43	// The token for the next set of results. Use the value returned in the previous
44	// response in the next request to retrieve the next set of results.
45	NextToken *string
46
47	noSmithyDocumentSerde
48}
49
50type ListLambdaFunctionsOutput struct {
51
52	// The Lambdafunction ARNs associated with the specified instance.
53	LambdaFunctions []string
54
55	// If there are additional results, this is the token for the next set of results.
56	NextToken *string
57
58	// Metadata pertaining to the operation's result.
59	ResultMetadata middleware.Metadata
60
61	noSmithyDocumentSerde
62}
63
64func (c *Client) addOperationListLambdaFunctionsMiddlewares(stack *middleware.Stack, options Options) (err error) {
65	err = stack.Serialize.Add(&awsRestjson1_serializeOpListLambdaFunctions{}, middleware.After)
66	if err != nil {
67		return err
68	}
69	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpListLambdaFunctions{}, 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 = addOpListLambdaFunctionsValidationMiddleware(stack); err != nil {
110		return err
111	}
112	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListLambdaFunctions(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// ListLambdaFunctionsAPIClient is a client that implements the ListLambdaFunctions
128// operation.
129type ListLambdaFunctionsAPIClient interface {
130	ListLambdaFunctions(context.Context, *ListLambdaFunctionsInput, ...func(*Options)) (*ListLambdaFunctionsOutput, error)
131}
132
133var _ ListLambdaFunctionsAPIClient = (*Client)(nil)
134
135// ListLambdaFunctionsPaginatorOptions is the paginator options for
136// ListLambdaFunctions
137type ListLambdaFunctionsPaginatorOptions struct {
138	// The maximum number of results to return per page.
139	Limit int32
140
141	// Set to true if pagination should stop if the service returns a pagination token
142	// that matches the most recent token provided to the service.
143	StopOnDuplicateToken bool
144}
145
146// ListLambdaFunctionsPaginator is a paginator for ListLambdaFunctions
147type ListLambdaFunctionsPaginator struct {
148	options   ListLambdaFunctionsPaginatorOptions
149	client    ListLambdaFunctionsAPIClient
150	params    *ListLambdaFunctionsInput
151	nextToken *string
152	firstPage bool
153}
154
155// NewListLambdaFunctionsPaginator returns a new ListLambdaFunctionsPaginator
156func NewListLambdaFunctionsPaginator(client ListLambdaFunctionsAPIClient, params *ListLambdaFunctionsInput, optFns ...func(*ListLambdaFunctionsPaginatorOptions)) *ListLambdaFunctionsPaginator {
157	if params == nil {
158		params = &ListLambdaFunctionsInput{}
159	}
160
161	options := ListLambdaFunctionsPaginatorOptions{}
162	if params.MaxResults != 0 {
163		options.Limit = params.MaxResults
164	}
165
166	for _, fn := range optFns {
167		fn(&options)
168	}
169
170	return &ListLambdaFunctionsPaginator{
171		options:   options,
172		client:    client,
173		params:    params,
174		firstPage: true,
175	}
176}
177
178// HasMorePages returns a boolean indicating whether more pages are available
179func (p *ListLambdaFunctionsPaginator) HasMorePages() bool {
180	return p.firstPage || p.nextToken != nil
181}
182
183// NextPage retrieves the next ListLambdaFunctions page.
184func (p *ListLambdaFunctionsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListLambdaFunctionsOutput, error) {
185	if !p.HasMorePages() {
186		return nil, fmt.Errorf("no more pages available")
187	}
188
189	params := *p.params
190	params.NextToken = p.nextToken
191
192	params.MaxResults = p.options.Limit
193
194	result, err := p.client.ListLambdaFunctions(ctx, &params, optFns...)
195	if err != nil {
196		return nil, err
197	}
198	p.firstPage = false
199
200	prevToken := p.nextToken
201	p.nextToken = result.NextToken
202
203	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
204		p.nextToken = nil
205	}
206
207	return result, nil
208}
209
210func newServiceMetadataMiddleware_opListLambdaFunctions(region string) *awsmiddleware.RegisterServiceMetadata {
211	return &awsmiddleware.RegisterServiceMetadata{
212		Region:        region,
213		ServiceID:     ServiceID,
214		SigningName:   "connect",
215		OperationName: "ListLambdaFunctions",
216	}
217}
218