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, 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 location to store the results of training.
41	//
42	// This member is required.
43	OutputConfig *types.OutputConfig
44
45	// The ARN of the Amazon Rekognition Custom Labels project that manages the model
46	// that you want to train.
47	//
48	// This member is required.
49	ProjectArn *string
50
51	// The dataset to use for testing.
52	//
53	// This member is required.
54	TestingData *types.TestingData
55
56	// The dataset to use for training.
57	//
58	// This member is required.
59	TrainingData *types.TrainingData
60
61	// A name for the version of the model. This value must be unique.
62	//
63	// This member is required.
64	VersionName *string
65}
66
67type CreateProjectVersionOutput struct {
68
69	// The ARN of the model version that was created. Use DescribeProjectVersion to get
70	// the current status of the training operation.
71	ProjectVersionArn *string
72
73	// Metadata pertaining to the operation's result.
74	ResultMetadata middleware.Metadata
75}
76
77func addOperationCreateProjectVersionMiddlewares(stack *middleware.Stack, options Options) (err error) {
78	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateProjectVersion{}, middleware.After)
79	if err != nil {
80		return err
81	}
82	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateProjectVersion{}, middleware.After)
83	if err != nil {
84		return err
85	}
86	if err = addSetLoggerMiddleware(stack, options); err != nil {
87		return err
88	}
89	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
90		return err
91	}
92	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
93		return err
94	}
95	if err = addResolveEndpointMiddleware(stack, options); err != nil {
96		return err
97	}
98	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
99		return err
100	}
101	if err = addRetryMiddlewares(stack, options); err != nil {
102		return err
103	}
104	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
105		return err
106	}
107	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
108		return err
109	}
110	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
111		return err
112	}
113	if err = addClientUserAgent(stack); err != nil {
114		return err
115	}
116	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
117		return err
118	}
119	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
120		return err
121	}
122	if err = addOpCreateProjectVersionValidationMiddleware(stack); err != nil {
123		return err
124	}
125	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateProjectVersion(options.Region), middleware.Before); err != nil {
126		return err
127	}
128	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
129		return err
130	}
131	if err = addResponseErrorMiddleware(stack); err != nil {
132		return err
133	}
134	if err = addRequestResponseLogging(stack, options); err != nil {
135		return err
136	}
137	return nil
138}
139
140func newServiceMetadataMiddleware_opCreateProjectVersion(region string) *awsmiddleware.RegisterServiceMetadata {
141	return &awsmiddleware.RegisterServiceMetadata{
142		Region:        region,
143		ServiceID:     ServiceID,
144		SigningName:   "rekognition",
145		OperationName: "CreateProjectVersion",
146	}
147}
148