1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package macie2
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/macie2/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Creates and defines the settings for a classification job.
16func (c *Client) CreateClassificationJob(ctx context.Context, params *CreateClassificationJobInput, optFns ...func(*Options)) (*CreateClassificationJobOutput, error) {
17	if params == nil {
18		params = &CreateClassificationJobInput{}
19	}
20
21	result, metadata, err := c.invokeOperation(ctx, "CreateClassificationJob", params, optFns, addOperationCreateClassificationJobMiddlewares)
22	if err != nil {
23		return nil, err
24	}
25
26	out := result.(*CreateClassificationJobOutput)
27	out.ResultMetadata = metadata
28	return out, nil
29}
30
31type CreateClassificationJobInput struct {
32
33	// A unique, case-sensitive token that you provide to ensure the idempotency of the
34	// request.
35	//
36	// This member is required.
37	ClientToken *string
38
39	// The schedule for running the job. Valid values are:
40	//
41	// * ONE_TIME - Run the job
42	// only once. If you specify this value, don't specify a value for the
43	// scheduleFrequency property.
44	//
45	// * SCHEDULED - Run the job on a daily, weekly, or
46	// monthly basis. If you specify this value, use the scheduleFrequency property to
47	// define the recurrence pattern for the job.
48	//
49	// This member is required.
50	JobType types.JobType
51
52	// A custom name for the job. The name can contain as many as 500 characters.
53	//
54	// This member is required.
55	Name *string
56
57	// The S3 buckets that contain the objects to analyze, and the scope of that
58	// analysis.
59	//
60	// This member is required.
61	S3JobDefinition *types.S3JobDefinition
62
63	// The custom data identifiers to use for data analysis and classification.
64	CustomDataIdentifierIds []string
65
66	// A custom description of the job. The description can contain as many as 200
67	// characters.
68	Description *string
69
70	// Specifies whether to analyze all existing, eligible objects immediately after
71	// the job is created.
72	InitialRun bool
73
74	// The sampling depth, as a percentage, to apply when processing objects. This
75	// value determines the percentage of eligible objects that the job analyzes. If
76	// this value is less than 100, Amazon Macie selects the objects to analyze at
77	// random, up to the specified percentage, and analyzes all the data in those
78	// objects.
79	SamplingPercentage int32
80
81	// The recurrence pattern for running the job. To run the job only once, don't
82	// specify a value for this property and set the value for the jobType property to
83	// ONE_TIME.
84	ScheduleFrequency *types.JobScheduleFrequency
85
86	// A map of key-value pairs that specifies the tags to associate with the job. A
87	// job can have a maximum of 50 tags. Each tag consists of a tag key and an
88	// associated tag value. The maximum length of a tag key is 128 characters. The
89	// maximum length of a tag value is 256 characters.
90	Tags map[string]string
91}
92
93type CreateClassificationJobOutput struct {
94
95	// The Amazon Resource Name (ARN) of the job.
96	JobArn *string
97
98	// The unique identifier for the job.
99	JobId *string
100
101	// Metadata pertaining to the operation's result.
102	ResultMetadata middleware.Metadata
103}
104
105func addOperationCreateClassificationJobMiddlewares(stack *middleware.Stack, options Options) (err error) {
106	err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateClassificationJob{}, middleware.After)
107	if err != nil {
108		return err
109	}
110	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateClassificationJob{}, middleware.After)
111	if err != nil {
112		return err
113	}
114	if err = addSetLoggerMiddleware(stack, options); err != nil {
115		return err
116	}
117	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
118		return err
119	}
120	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
121		return err
122	}
123	if err = addResolveEndpointMiddleware(stack, options); err != nil {
124		return err
125	}
126	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
127		return err
128	}
129	if err = addRetryMiddlewares(stack, options); err != nil {
130		return err
131	}
132	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
133		return err
134	}
135	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
136		return err
137	}
138	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
139		return err
140	}
141	if err = addClientUserAgent(stack); err != nil {
142		return err
143	}
144	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
145		return err
146	}
147	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
148		return err
149	}
150	if err = addIdempotencyToken_opCreateClassificationJobMiddleware(stack, options); err != nil {
151		return err
152	}
153	if err = addOpCreateClassificationJobValidationMiddleware(stack); err != nil {
154		return err
155	}
156	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateClassificationJob(options.Region), middleware.Before); err != nil {
157		return err
158	}
159	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
160		return err
161	}
162	if err = addResponseErrorMiddleware(stack); err != nil {
163		return err
164	}
165	if err = addRequestResponseLogging(stack, options); err != nil {
166		return err
167	}
168	return nil
169}
170
171type idempotencyToken_initializeOpCreateClassificationJob struct {
172	tokenProvider IdempotencyTokenProvider
173}
174
175func (*idempotencyToken_initializeOpCreateClassificationJob) ID() string {
176	return "OperationIdempotencyTokenAutoFill"
177}
178
179func (m *idempotencyToken_initializeOpCreateClassificationJob) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
180	out middleware.InitializeOutput, metadata middleware.Metadata, err error,
181) {
182	if m.tokenProvider == nil {
183		return next.HandleInitialize(ctx, in)
184	}
185
186	input, ok := in.Parameters.(*CreateClassificationJobInput)
187	if !ok {
188		return out, metadata, fmt.Errorf("expected middleware input to be of type *CreateClassificationJobInput ")
189	}
190
191	if input.ClientToken == nil {
192		t, err := m.tokenProvider.GetIdempotencyToken()
193		if err != nil {
194			return out, metadata, err
195		}
196		input.ClientToken = &t
197	}
198	return next.HandleInitialize(ctx, in)
199}
200func addIdempotencyToken_opCreateClassificationJobMiddleware(stack *middleware.Stack, cfg Options) error {
201	return stack.Initialize.Add(&idempotencyToken_initializeOpCreateClassificationJob{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before)
202}
203
204func newServiceMetadataMiddleware_opCreateClassificationJob(region string) *awsmiddleware.RegisterServiceMetadata {
205	return &awsmiddleware.RegisterServiceMetadata{
206		Region:        region,
207		ServiceID:     ServiceID,
208		SigningName:   "macie2",
209		OperationName: "CreateClassificationJob",
210	}
211}
212