1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package transcribe
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/transcribe/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12	"time"
13)
14
15// Creates a new custom vocabulary that you can use to change the way Amazon
16// Transcribe handles transcription of an audio file.
17func (c *Client) CreateVocabulary(ctx context.Context, params *CreateVocabularyInput, optFns ...func(*Options)) (*CreateVocabularyOutput, error) {
18	if params == nil {
19		params = &CreateVocabularyInput{}
20	}
21
22	result, metadata, err := c.invokeOperation(ctx, "CreateVocabulary", params, optFns, addOperationCreateVocabularyMiddlewares)
23	if err != nil {
24		return nil, err
25	}
26
27	out := result.(*CreateVocabularyOutput)
28	out.ResultMetadata = metadata
29	return out, nil
30}
31
32type CreateVocabularyInput struct {
33
34	// The language code of the vocabulary entries.
35	//
36	// This member is required.
37	LanguageCode types.LanguageCode
38
39	// The name of the vocabulary. The name must be unique within an AWS account. The
40	// name is case sensitive. If you try to create a vocabulary with the same name as
41	// a previous vocabulary you will receive a ConflictException error.
42	//
43	// This member is required.
44	VocabularyName *string
45
46	// An array of strings that contains the vocabulary entries.
47	Phrases []string
48
49	// The S3 location of the text file that contains the definition of the custom
50	// vocabulary. The URI must be in the same region as the API endpoint that you are
51	// calling. The general form is For more information about S3 object names, see
52	// Object Keys
53	// (http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#object-keys)
54	// in the Amazon S3 Developer Guide. For more information about custom
55	// vocabularies, see Custom Vocabularies
56	// (http://docs.aws.amazon.com/transcribe/latest/dg/how-it-works.html#how-vocabulary).
57	VocabularyFileUri *string
58}
59
60type CreateVocabularyOutput struct {
61
62	// If the VocabularyState field is FAILED, this field contains information about
63	// why the job failed.
64	FailureReason *string
65
66	// The language code of the vocabulary entries.
67	LanguageCode types.LanguageCode
68
69	// The date and time that the vocabulary was created.
70	LastModifiedTime *time.Time
71
72	// The name of the vocabulary.
73	VocabularyName *string
74
75	// The processing state of the vocabulary. When the VocabularyState field contains
76	// READY the vocabulary is ready to be used in a StartTranscriptionJob request.
77	VocabularyState types.VocabularyState
78
79	// Metadata pertaining to the operation's result.
80	ResultMetadata middleware.Metadata
81}
82
83func addOperationCreateVocabularyMiddlewares(stack *middleware.Stack, options Options) (err error) {
84	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateVocabulary{}, middleware.After)
85	if err != nil {
86		return err
87	}
88	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateVocabulary{}, middleware.After)
89	if err != nil {
90		return err
91	}
92	if err = addSetLoggerMiddleware(stack, options); err != nil {
93		return err
94	}
95	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
96		return err
97	}
98	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
99		return err
100	}
101	if err = addResolveEndpointMiddleware(stack, options); err != nil {
102		return err
103	}
104	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
105		return err
106	}
107	if err = addRetryMiddlewares(stack, options); err != nil {
108		return err
109	}
110	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
111		return err
112	}
113	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
114		return err
115	}
116	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
117		return err
118	}
119	if err = addClientUserAgent(stack); err != nil {
120		return err
121	}
122	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
123		return err
124	}
125	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
126		return err
127	}
128	if err = addOpCreateVocabularyValidationMiddleware(stack); err != nil {
129		return err
130	}
131	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateVocabulary(options.Region), middleware.Before); err != nil {
132		return err
133	}
134	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
135		return err
136	}
137	if err = addResponseErrorMiddleware(stack); err != nil {
138		return err
139	}
140	if err = addRequestResponseLogging(stack, options); err != nil {
141		return err
142	}
143	return nil
144}
145
146func newServiceMetadataMiddleware_opCreateVocabulary(region string) *awsmiddleware.RegisterServiceMetadata {
147	return &awsmiddleware.RegisterServiceMetadata{
148		Region:        region,
149		ServiceID:     ServiceID,
150		SigningName:   "transcribe",
151		OperationName: "CreateVocabulary",
152	}
153}
154