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