1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package lexmodelsv2
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/lexmodelsv2/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Gets a list of built-in slot types that meet the specified criteria.
16func (c *Client) ListBuiltInSlotTypes(ctx context.Context, params *ListBuiltInSlotTypesInput, optFns ...func(*Options)) (*ListBuiltInSlotTypesOutput, error) {
17	if params == nil {
18		params = &ListBuiltInSlotTypesInput{}
19	}
20
21	result, metadata, err := c.invokeOperation(ctx, "ListBuiltInSlotTypes", params, optFns, addOperationListBuiltInSlotTypesMiddlewares)
22	if err != nil {
23		return nil, err
24	}
25
26	out := result.(*ListBuiltInSlotTypesOutput)
27	out.ResultMetadata = metadata
28	return out, nil
29}
30
31type ListBuiltInSlotTypesInput struct {
32
33	// The identifier of the language and locale of the slot types to list. The string
34	// must match one of the supported locales. For more information, see
35	// https://docs.aws.amazon.com/lex/latest/dg/supported-locales.html
36	// (https://docs.aws.amazon.com/lex/latest/dg/supported-locales.html).
37	//
38	// This member is required.
39	LocaleId *string
40
41	// The maximum number of built-in slot types to return in each page of results. If
42	// there are fewer results than the max page size, only the actual number of
43	// results are returned.
44	MaxResults *int32
45
46	// If the response from the ListBuiltInSlotTypes operation contains more results
47	// than specified in the maxResults parameter, a token is returned in the response.
48	// Use that token in the nextToken parameter to return the next page of results.
49	NextToken *string
50
51	// Determines the sort order for the response from the ListBuiltInSlotTypes
52	// operation. You can choose to sort by the slot type signature in either ascending
53	// or descending order.
54	SortBy *types.BuiltInSlotTypeSortBy
55}
56
57type ListBuiltInSlotTypesOutput struct {
58
59	// Summary information for the built-in slot types that meet the filter criteria
60	// specified in the request. The length of the list is specified in the maxResults
61	// parameter of the request. If there are more slot types available, the nextToken
62	// field contains a token to get the next page of results.
63	BuiltInSlotTypeSummaries []types.BuiltInSlotTypeSummary
64
65	// The language and locale of the slot types in the list.
66	LocaleId *string
67
68	// A token that indicates whether there are more results to return in a response to
69	// the ListBuiltInSlotTypes operation. If the nextToken field is present, you send
70	// the contents as the nextToken parameter of a LIstBuiltInSlotTypes operation
71	// request to get the next page of results.
72	NextToken *string
73
74	// Metadata pertaining to the operation's result.
75	ResultMetadata middleware.Metadata
76}
77
78func addOperationListBuiltInSlotTypesMiddlewares(stack *middleware.Stack, options Options) (err error) {
79	err = stack.Serialize.Add(&awsRestjson1_serializeOpListBuiltInSlotTypes{}, middleware.After)
80	if err != nil {
81		return err
82	}
83	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpListBuiltInSlotTypes{}, middleware.After)
84	if err != nil {
85		return err
86	}
87	if err = addSetLoggerMiddleware(stack, options); err != nil {
88		return err
89	}
90	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
91		return err
92	}
93	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
94		return err
95	}
96	if err = addResolveEndpointMiddleware(stack, options); err != nil {
97		return err
98	}
99	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
100		return err
101	}
102	if err = addRetryMiddlewares(stack, options); err != nil {
103		return err
104	}
105	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
106		return err
107	}
108	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
109		return err
110	}
111	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
112		return err
113	}
114	if err = addClientUserAgent(stack); err != nil {
115		return err
116	}
117	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
118		return err
119	}
120	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
121		return err
122	}
123	if err = addOpListBuiltInSlotTypesValidationMiddleware(stack); err != nil {
124		return err
125	}
126	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListBuiltInSlotTypes(options.Region), middleware.Before); err != nil {
127		return err
128	}
129	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
130		return err
131	}
132	if err = addResponseErrorMiddleware(stack); err != nil {
133		return err
134	}
135	if err = addRequestResponseLogging(stack, options); err != nil {
136		return err
137	}
138	return nil
139}
140
141// ListBuiltInSlotTypesAPIClient is a client that implements the
142// ListBuiltInSlotTypes operation.
143type ListBuiltInSlotTypesAPIClient interface {
144	ListBuiltInSlotTypes(context.Context, *ListBuiltInSlotTypesInput, ...func(*Options)) (*ListBuiltInSlotTypesOutput, error)
145}
146
147var _ ListBuiltInSlotTypesAPIClient = (*Client)(nil)
148
149// ListBuiltInSlotTypesPaginatorOptions is the paginator options for
150// ListBuiltInSlotTypes
151type ListBuiltInSlotTypesPaginatorOptions struct {
152	// The maximum number of built-in slot types to return in each page of results. If
153	// there are fewer results than the max page size, only the actual number of
154	// results are returned.
155	Limit int32
156
157	// Set to true if pagination should stop if the service returns a pagination token
158	// that matches the most recent token provided to the service.
159	StopOnDuplicateToken bool
160}
161
162// ListBuiltInSlotTypesPaginator is a paginator for ListBuiltInSlotTypes
163type ListBuiltInSlotTypesPaginator struct {
164	options   ListBuiltInSlotTypesPaginatorOptions
165	client    ListBuiltInSlotTypesAPIClient
166	params    *ListBuiltInSlotTypesInput
167	nextToken *string
168	firstPage bool
169}
170
171// NewListBuiltInSlotTypesPaginator returns a new ListBuiltInSlotTypesPaginator
172func NewListBuiltInSlotTypesPaginator(client ListBuiltInSlotTypesAPIClient, params *ListBuiltInSlotTypesInput, optFns ...func(*ListBuiltInSlotTypesPaginatorOptions)) *ListBuiltInSlotTypesPaginator {
173	if params == nil {
174		params = &ListBuiltInSlotTypesInput{}
175	}
176
177	options := ListBuiltInSlotTypesPaginatorOptions{}
178	if params.MaxResults != nil {
179		options.Limit = *params.MaxResults
180	}
181
182	for _, fn := range optFns {
183		fn(&options)
184	}
185
186	return &ListBuiltInSlotTypesPaginator{
187		options:   options,
188		client:    client,
189		params:    params,
190		firstPage: true,
191	}
192}
193
194// HasMorePages returns a boolean indicating whether more pages are available
195func (p *ListBuiltInSlotTypesPaginator) HasMorePages() bool {
196	return p.firstPage || p.nextToken != nil
197}
198
199// NextPage retrieves the next ListBuiltInSlotTypes page.
200func (p *ListBuiltInSlotTypesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListBuiltInSlotTypesOutput, error) {
201	if !p.HasMorePages() {
202		return nil, fmt.Errorf("no more pages available")
203	}
204
205	params := *p.params
206	params.NextToken = p.nextToken
207
208	var limit *int32
209	if p.options.Limit > 0 {
210		limit = &p.options.Limit
211	}
212	params.MaxResults = limit
213
214	result, err := p.client.ListBuiltInSlotTypes(ctx, &params, optFns...)
215	if err != nil {
216		return nil, err
217	}
218	p.firstPage = false
219
220	prevToken := p.nextToken
221	p.nextToken = result.NextToken
222
223	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
224		p.nextToken = nil
225	}
226
227	return result, nil
228}
229
230func newServiceMetadataMiddleware_opListBuiltInSlotTypes(region string) *awsmiddleware.RegisterServiceMetadata {
231	return &awsmiddleware.RegisterServiceMetadata{
232		Region:        region,
233		ServiceID:     ServiceID,
234		SigningName:   "lex",
235		OperationName: "ListBuiltInSlotTypes",
236	}
237}
238