1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package comprehend
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/comprehend/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Starts an asynchronous document classification job. Use the operation to track
16// the progress of the job.
17func (c *Client) StartDocumentClassificationJob(ctx context.Context, params *StartDocumentClassificationJobInput, optFns ...func(*Options)) (*StartDocumentClassificationJobOutput, error) {
18	if params == nil {
19		params = &StartDocumentClassificationJobInput{}
20	}
21
22	result, metadata, err := c.invokeOperation(ctx, "StartDocumentClassificationJob", params, optFns, c.addOperationStartDocumentClassificationJobMiddlewares)
23	if err != nil {
24		return nil, err
25	}
26
27	out := result.(*StartDocumentClassificationJobOutput)
28	out.ResultMetadata = metadata
29	return out, nil
30}
31
32type StartDocumentClassificationJobInput struct {
33
34	// The Amazon Resource Name (ARN) of the AWS Identity and Access Management (IAM)
35	// role that grants Amazon Comprehend read access to your input data.
36	//
37	// This member is required.
38	DataAccessRoleArn *string
39
40	// The Amazon Resource Name (ARN) of the document classifier to use to process the
41	// job.
42	//
43	// This member is required.
44	DocumentClassifierArn *string
45
46	// Specifies the format and location of the input data for the job.
47	//
48	// This member is required.
49	InputDataConfig *types.InputDataConfig
50
51	// Specifies where to send the output files.
52	//
53	// This member is required.
54	OutputDataConfig *types.OutputDataConfig
55
56	// A unique identifier for the request. If you do not set the client request token,
57	// Amazon Comprehend generates one.
58	ClientRequestToken *string
59
60	// The identifier of the job.
61	JobName *string
62
63	// Tags to be associated with the document classification job. A tag is a key-value
64	// pair that adds metadata to a resource used by Amazon Comprehend. For example, a
65	// tag with "Sales" as the key might be added to a resource to indicate its use by
66	// the sales department.
67	Tags []types.Tag
68
69	// ID for the AWS Key Management Service (KMS) key that Amazon Comprehend uses to
70	// encrypt data on the storage volume attached to the ML compute instance(s) that
71	// process the analysis job. The VolumeKmsKeyId can be either of the following
72	// formats:
73	//
74	// * KMS Key ID: "1234abcd-12ab-34cd-56ef-1234567890ab"
75	//
76	// * Amazon
77	// Resource Name (ARN) of a KMS Key:
78	// "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"
79	VolumeKmsKeyId *string
80
81	// Configuration parameters for an optional private Virtual Private Cloud (VPC)
82	// containing the resources you are using for your document classification job. For
83	// more information, see Amazon VPC
84	// (https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html).
85	VpcConfig *types.VpcConfig
86
87	noSmithyDocumentSerde
88}
89
90type StartDocumentClassificationJobOutput struct {
91
92	// The Amazon Resource Name (ARN) of the document classification job. It is a
93	// unique, fully qualified identifier for the job. It includes the AWS account,
94	// Region, and the job ID. The format of the ARN is as follows:
95	// arn::comprehend:::document-classification-job/ The following is an example job
96	// ARN:
97	// arn:aws:comprehend:us-west-2:111122223333:document-classification-job/1234abcd12ab34cd56ef1234567890ab
98	JobArn *string
99
100	// The identifier generated for the job. To get the status of the job, use this
101	// identifier with the operation.
102	JobId *string
103
104	// The status of the job:
105	//
106	// * SUBMITTED - The job has been received and queued for
107	// processing.
108	//
109	// * IN_PROGRESS - Amazon Comprehend is processing the job.
110	//
111	// *
112	// COMPLETED - The job was successfully completed and the output is available.
113	//
114	// *
115	// FAILED - The job did not complete. For details, use the operation.
116	//
117	// *
118	// STOP_REQUESTED - Amazon Comprehend has received a stop request for the job and
119	// is processing the request.
120	//
121	// * STOPPED - The job was successfully stopped without
122	// completing.
123	JobStatus types.JobStatus
124
125	// Metadata pertaining to the operation's result.
126	ResultMetadata middleware.Metadata
127
128	noSmithyDocumentSerde
129}
130
131func (c *Client) addOperationStartDocumentClassificationJobMiddlewares(stack *middleware.Stack, options Options) (err error) {
132	err = stack.Serialize.Add(&awsAwsjson11_serializeOpStartDocumentClassificationJob{}, middleware.After)
133	if err != nil {
134		return err
135	}
136	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpStartDocumentClassificationJob{}, middleware.After)
137	if err != nil {
138		return err
139	}
140	if err = addSetLoggerMiddleware(stack, options); err != nil {
141		return err
142	}
143	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
144		return err
145	}
146	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
147		return err
148	}
149	if err = addResolveEndpointMiddleware(stack, options); err != nil {
150		return err
151	}
152	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
153		return err
154	}
155	if err = addRetryMiddlewares(stack, options); err != nil {
156		return err
157	}
158	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
159		return err
160	}
161	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
162		return err
163	}
164	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
165		return err
166	}
167	if err = addClientUserAgent(stack); err != nil {
168		return err
169	}
170	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
171		return err
172	}
173	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
174		return err
175	}
176	if err = addIdempotencyToken_opStartDocumentClassificationJobMiddleware(stack, options); err != nil {
177		return err
178	}
179	if err = addOpStartDocumentClassificationJobValidationMiddleware(stack); err != nil {
180		return err
181	}
182	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opStartDocumentClassificationJob(options.Region), middleware.Before); err != nil {
183		return err
184	}
185	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
186		return err
187	}
188	if err = addResponseErrorMiddleware(stack); err != nil {
189		return err
190	}
191	if err = addRequestResponseLogging(stack, options); err != nil {
192		return err
193	}
194	return nil
195}
196
197type idempotencyToken_initializeOpStartDocumentClassificationJob struct {
198	tokenProvider IdempotencyTokenProvider
199}
200
201func (*idempotencyToken_initializeOpStartDocumentClassificationJob) ID() string {
202	return "OperationIdempotencyTokenAutoFill"
203}
204
205func (m *idempotencyToken_initializeOpStartDocumentClassificationJob) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
206	out middleware.InitializeOutput, metadata middleware.Metadata, err error,
207) {
208	if m.tokenProvider == nil {
209		return next.HandleInitialize(ctx, in)
210	}
211
212	input, ok := in.Parameters.(*StartDocumentClassificationJobInput)
213	if !ok {
214		return out, metadata, fmt.Errorf("expected middleware input to be of type *StartDocumentClassificationJobInput ")
215	}
216
217	if input.ClientRequestToken == nil {
218		t, err := m.tokenProvider.GetIdempotencyToken()
219		if err != nil {
220			return out, metadata, err
221		}
222		input.ClientRequestToken = &t
223	}
224	return next.HandleInitialize(ctx, in)
225}
226func addIdempotencyToken_opStartDocumentClassificationJobMiddleware(stack *middleware.Stack, cfg Options) error {
227	return stack.Initialize.Add(&idempotencyToken_initializeOpStartDocumentClassificationJob{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before)
228}
229
230func newServiceMetadataMiddleware_opStartDocumentClassificationJob(region string) *awsmiddleware.RegisterServiceMetadata {
231	return &awsmiddleware.RegisterServiceMetadata{
232		Region:        region,
233		ServiceID:     ServiceID,
234		SigningName:   "comprehend",
235		OperationName: "StartDocumentClassificationJob",
236	}
237}
238