1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package lexmodelsv2
4
5import (
6	"context"
7	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
8	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
9	"github.com/aws/aws-sdk-go-v2/service/lexmodelsv2/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12	"time"
13)
14
15// Creates a slot in an intent. A slot is a variable needed to fulfill an intent.
16// For example, an OrderPizza intent might need slots for size, crust, and number
17// of pizzas. For each slot, you define one or more utterances that Amazon Lex uses
18// to elicit a response from the user.
19func (c *Client) CreateSlot(ctx context.Context, params *CreateSlotInput, optFns ...func(*Options)) (*CreateSlotOutput, error) {
20	if params == nil {
21		params = &CreateSlotInput{}
22	}
23
24	result, metadata, err := c.invokeOperation(ctx, "CreateSlot", params, optFns, addOperationCreateSlotMiddlewares)
25	if err != nil {
26		return nil, err
27	}
28
29	out := result.(*CreateSlotOutput)
30	out.ResultMetadata = metadata
31	return out, nil
32}
33
34type CreateSlotInput struct {
35
36	// The identifier of the bot associated with the slot.
37	//
38	// This member is required.
39	BotId *string
40
41	// The version of the bot associated with the slot.
42	//
43	// This member is required.
44	BotVersion *string
45
46	// The identifier of the intent that contains the slot.
47	//
48	// This member is required.
49	IntentId *string
50
51	// The identifier of the language and locale that the slot will be used in. The
52	// string must match one of the supported locales. All of the bots, intents, slot
53	// types used by the slot must have the same locale. For more information, see
54	// https://docs.aws.amazon.com/lex/latest/dg/supported-locales.html
55	// (https://docs.aws.amazon.com/lex/latest/dg/supported-locales.html).
56	//
57	// This member is required.
58	LocaleId *string
59
60	// The name of the slot. Slot names must be unique within the bot that contains the
61	// slot.
62	//
63	// This member is required.
64	SlotName *string
65
66	// The unique identifier for the slot type associated with this slot. The slot type
67	// determines the values that can be entered into the slot.
68	//
69	// This member is required.
70	SlotTypeId *string
71
72	// Specifies prompts that Amazon Lex sends to the user to elicit a response that
73	// provides the value for the slot.
74	//
75	// This member is required.
76	ValueElicitationSetting *types.SlotValueElicitationSetting
77
78	// A description of the slot. Use this to help identify the slot in lists.
79	Description *string
80
81	// Determines how slot values are used in Amazon CloudWatch logs. If the value of
82	// the obfuscationSetting parameter is DefaultObfuscation, slot values are
83	// obfuscated in the log output. If the value is None, the actual value is present
84	// in the log output. The default is to obfuscate values in the CloudWatch logs.
85	ObfuscationSetting *types.ObfuscationSetting
86}
87
88type CreateSlotOutput struct {
89
90	// The unique identifier of the bot associated with the slot.
91	BotId *string
92
93	// The version of the bot associated with the slot.
94	BotVersion *string
95
96	// The timestamp of the date and time that the slot was created.
97	CreationDateTime *time.Time
98
99	// The description associated with the slot.
100	Description *string
101
102	// The unique identifier of the intent associated with the slot.
103	IntentId *string
104
105	// The language and local specified for the slot.
106	LocaleId *string
107
108	// Indicates whether the slot is configured to obfuscate values in Amazon
109	// CloudWatch logs.
110	ObfuscationSetting *types.ObfuscationSetting
111
112	// The unique identifier associated with the slot. Use this to identify the slot
113	// when you update or delete it.
114	SlotId *string
115
116	// The name specified for the slot.
117	SlotName *string
118
119	// The unique identifier of the slot type associated with this slot.
120	SlotTypeId *string
121
122	// The value elicitation settings specified for the slot.
123	ValueElicitationSetting *types.SlotValueElicitationSetting
124
125	// Metadata pertaining to the operation's result.
126	ResultMetadata middleware.Metadata
127}
128
129func addOperationCreateSlotMiddlewares(stack *middleware.Stack, options Options) (err error) {
130	err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateSlot{}, middleware.After)
131	if err != nil {
132		return err
133	}
134	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateSlot{}, middleware.After)
135	if err != nil {
136		return err
137	}
138	if err = addSetLoggerMiddleware(stack, options); err != nil {
139		return err
140	}
141	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
142		return err
143	}
144	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
145		return err
146	}
147	if err = addResolveEndpointMiddleware(stack, options); err != nil {
148		return err
149	}
150	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
151		return err
152	}
153	if err = addRetryMiddlewares(stack, options); err != nil {
154		return err
155	}
156	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
157		return err
158	}
159	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
160		return err
161	}
162	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
163		return err
164	}
165	if err = addClientUserAgent(stack); err != nil {
166		return err
167	}
168	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
169		return err
170	}
171	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
172		return err
173	}
174	if err = addOpCreateSlotValidationMiddleware(stack); err != nil {
175		return err
176	}
177	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateSlot(options.Region), middleware.Before); err != nil {
178		return err
179	}
180	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
181		return err
182	}
183	if err = addResponseErrorMiddleware(stack); err != nil {
184		return err
185	}
186	if err = addRequestResponseLogging(stack, options); err != nil {
187		return err
188	}
189	return nil
190}
191
192func newServiceMetadataMiddleware_opCreateSlot(region string) *awsmiddleware.RegisterServiceMetadata {
193	return &awsmiddleware.RegisterServiceMetadata{
194		Region:        region,
195		ServiceID:     ServiceID,
196		SigningName:   "lex",
197		OperationName: "CreateSlot",
198	}
199}
200