1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package rekognition
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/rekognition/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Creates a new version of a model and begins training. Models are managed as part
15// of an Amazon Rekognition Custom Labels project. You can specify one training
16// dataset and one testing dataset. The response from CreateProjectVersion is an
17// Amazon Resource Name (ARN) for the version of the model. Training takes a while
18// to complete. You can get the current status by calling DescribeProjectVersions.
19// Once training has successfully completed, call DescribeProjectVersions to get
20// the training results and evaluate the model. After evaluating the model, you
21// start the model by calling StartProjectVersion. This operation requires
22// permissions to perform the rekognition:CreateProjectVersion action.
23func (c *Client) CreateProjectVersion(ctx context.Context, params *CreateProjectVersionInput, optFns ...func(*Options)) (*CreateProjectVersionOutput, error) {
24	if params == nil {
25		params = &CreateProjectVersionInput{}
26	}
27
28	result, metadata, err := c.invokeOperation(ctx, "CreateProjectVersion", params, optFns, c.addOperationCreateProjectVersionMiddlewares)
29	if err != nil {
30		return nil, err
31	}
32
33	out := result.(*CreateProjectVersionOutput)
34	out.ResultMetadata = metadata
35	return out, nil
36}
37
38type CreateProjectVersionInput struct {
39
40	// The Amazon S3 bucket location to store the results of training. The S3 bucket
41	// can be in any AWS account as long as the caller has s3:PutObject permissions on
42	// the S3 bucket.
43	//
44	// This member is required.
45	OutputConfig *types.OutputConfig
46
47	// The ARN of the Amazon Rekognition Custom Labels project that manages the model
48	// that you want to train.
49	//
50	// This member is required.
51	ProjectArn *string
52
53	// The dataset to use for testing.
54	//
55	// This member is required.
56	TestingData *types.TestingData
57
58	// The dataset to use for training.
59	//
60	// This member is required.
61	TrainingData *types.TrainingData
62
63	// A name for the version of the model. This value must be unique.
64	//
65	// This member is required.
66	VersionName *string
67
68	// The identifier for your AWS Key Management Service (AWS KMS) customer master key
69	// (CMK). You can supply the Amazon Resource Name (ARN) of your CMK, the ID of your
70	// CMK, an alias for your CMK, or an alias ARN. The key is used to encrypt training
71	// and test images copied into the service for model training. Your source images
72	// are unaffected. The key is also used to encrypt training results and manifest
73	// files written to the output Amazon S3 bucket (OutputConfig). If you choose to
74	// use your own CMK, you need the following permissions on the CMK.
75	//
76	// *
77	// kms:CreateGrant
78	//
79	// * kms:DescribeKey
80	//
81	// * kms:GenerateDataKey
82	//
83	// * kms:Decrypt
84	//
85	// If you
86	// don't specify a value for KmsKeyId, images copied into the service are encrypted
87	// using a key that AWS owns and manages.
88	KmsKeyId *string
89
90	// A set of tags (key-value pairs) that you want to attach to the model.
91	Tags map[string]string
92
93	noSmithyDocumentSerde
94}
95
96type CreateProjectVersionOutput struct {
97
98	// The ARN of the model version that was created. Use DescribeProjectVersion to get
99	// the current status of the training operation.
100	ProjectVersionArn *string
101
102	// Metadata pertaining to the operation's result.
103	ResultMetadata middleware.Metadata
104
105	noSmithyDocumentSerde
106}
107
108func (c *Client) addOperationCreateProjectVersionMiddlewares(stack *middleware.Stack, options Options) (err error) {
109	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateProjectVersion{}, middleware.After)
110	if err != nil {
111		return err
112	}
113	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateProjectVersion{}, middleware.After)
114	if err != nil {
115		return err
116	}
117	if err = addSetLoggerMiddleware(stack, options); err != nil {
118		return err
119	}
120	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
121		return err
122	}
123	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
124		return err
125	}
126	if err = addResolveEndpointMiddleware(stack, options); err != nil {
127		return err
128	}
129	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
130		return err
131	}
132	if err = addRetryMiddlewares(stack, options); err != nil {
133		return err
134	}
135	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
136		return err
137	}
138	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
139		return err
140	}
141	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
142		return err
143	}
144	if err = addClientUserAgent(stack); err != nil {
145		return err
146	}
147	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
148		return err
149	}
150	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
151		return err
152	}
153	if err = addOpCreateProjectVersionValidationMiddleware(stack); err != nil {
154		return err
155	}
156	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateProjectVersion(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
171func newServiceMetadataMiddleware_opCreateProjectVersion(region string) *awsmiddleware.RegisterServiceMetadata {
172	return &awsmiddleware.RegisterServiceMetadata{
173		Region:        region,
174		ServiceID:     ServiceID,
175		SigningName:   "rekognition",
176		OperationName: "CreateProjectVersion",
177	}
178}
179