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