/* * Copyright 2010-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.amazonaws.services.rekognition.model; import java.io.Serializable; import com.amazonaws.AmazonWebServiceRequest; /** *

* Creates a new version of a model and begins training. Models are managed as * part of an Amazon Rekognition Custom Labels project. The response from * CreateProjectVersion is an Amazon Resource Name (ARN) for the * version of the model. *

*

* Training uses the training and test datasets associated with the project. For * more information, see Creating training and test dataset in the Amazon * Rekognition Custom Labels Developer Guide. *

* *

* You can train a model in a project that doesn't have associated datasets by * specifying manifest files in the TrainingData and * TestingData fields. *

*

* If you open the console after training a model with manifest files, Amazon * Rekognition Custom Labels creates the datasets for you using the most recent * manifest files. You can no longer train a model version for the project by * specifying manifest files. *

*

* Instead of training with a project without associated datasets, we recommend * that you use the manifest files to create training and test datasets for the * project. *

*
*

* Training takes a while to complete. You can get the current status by calling * DescribeProjectVersions. Training completed successfully if the value * of the Status field is TRAINING_COMPLETED. *

*

* If training fails, see Debugging a failed model training in the Amazon * Rekognition Custom Labels developer guide. *

*

* Once training has successfully completed, call DescribeProjectVersions * to get the training results and evaluate the model. For more information, see * Improving a trained Amazon Rekognition Custom Labels model in the Amazon * Rekognition Custom Labels developers guide. *

*

* After evaluating the model, you start the model by calling * StartProjectVersion. *

*

* This operation requires permissions to perform the * rekognition:CreateProjectVersion action. *

*/ public class CreateProjectVersionRequest extends AmazonWebServiceRequest implements Serializable { /** *

* The ARN of the Amazon Rekognition Custom Labels project that manages the * model that you want to train. *

*

* Constraints:
* Length: 20 - 2048
* Pattern: * (^arn:[a-z\d-]+:rekognition:[a-z\d-]+:\d{12}:project\/[a-zA * -Z0-9_.\-]{1,255}\/[0-9]+$)
*/ private String projectArn; /** *

* A name for the version of the model. This value must be unique. *

*

* Constraints:
* Length: 1 - 255
* Pattern: [a-zA-Z0-9_.\-]+
*/ private String versionName; /** *

* The Amazon S3 bucket location to store the results of training. The S3 * bucket can be in any AWS account as long as the caller has * s3:PutObject permissions on the S3 bucket. *

*/ private OutputConfig outputConfig; /** *

* Specifies an external manifest that the services uses to train the model. * If you specify TrainingData you must also specify * TestingData. The project must not have any associated * datasets. *

*/ private TrainingData trainingData; /** *

* Specifies an external manifest that the service uses to test the model. * If you specify TestingData you must also specify * TrainingData. The project must not have any associated * datasets. *

*/ private TestingData testingData; /** *

* A set of tags (key-value pairs) that you want to attach to the model. *

*/ private java.util.Map tags; /** *

* The identifier for your AWS Key Management Service key (AWS KMS key). You * can supply the Amazon Resource Name (ARN) of your KMS key, the ID of your * KMS key, an alias for your KMS key, or an alias ARN. The key is used to * encrypt training and test images copied into the service for model * training. Your source images are unaffected. The key is also used to * encrypt training results and manifest files written to the output Amazon * S3 bucket (OutputConfig). *

*

* If you choose to use your own KMS key, you need the following permissions * on the KMS key. *

* *

* If you don't specify a value for KmsKeyId, images copied * into the service are encrypted using a key that AWS owns and manages. *

*

* Constraints:
* Length: 1 - 2048
* Pattern: ^[A-Za-z0-9][A-Za-z0-9:_/+=,@.-]{0,2048}$
*/ private String kmsKeyId; /** *

* The ARN of the Amazon Rekognition Custom Labels project that manages the * model that you want to train. *

*

* Constraints:
* Length: 20 - 2048
* Pattern: * (^arn:[a-z\d-]+:rekognition:[a-z\d-]+:\d{12}:project\/[a-zA * -Z0-9_.\-]{1,255}\/[0-9]+$)
* * @return

* The ARN of the Amazon Rekognition Custom Labels project that * manages the model that you want to train. *

*/ public String getProjectArn() { return projectArn; } /** *

* The ARN of the Amazon Rekognition Custom Labels project that manages the * model that you want to train. *

*

* Constraints:
* Length: 20 - 2048
* Pattern: * (^arn:[a-z\d-]+:rekognition:[a-z\d-]+:\d{12}:project\/[a-zA * -Z0-9_.\-]{1,255}\/[0-9]+$)
* * @param projectArn

* The ARN of the Amazon Rekognition Custom Labels project that * manages the model that you want to train. *

*/ public void setProjectArn(String projectArn) { this.projectArn = projectArn; } /** *

* The ARN of the Amazon Rekognition Custom Labels project that manages the * model that you want to train. *

*

* Returns a reference to this object so that method calls can be chained * together. *

* Constraints:
* Length: 20 - 2048
* Pattern: * (^arn:[a-z\d-]+:rekognition:[a-z\d-]+:\d{12}:project\/[a-zA * -Z0-9_.\-]{1,255}\/[0-9]+$)
* * @param projectArn

* The ARN of the Amazon Rekognition Custom Labels project that * manages the model that you want to train. *

* @return A reference to this updated object so that method calls can be * chained together. */ public CreateProjectVersionRequest withProjectArn(String projectArn) { this.projectArn = projectArn; return this; } /** *

* A name for the version of the model. This value must be unique. *

*

* Constraints:
* Length: 1 - 255
* Pattern: [a-zA-Z0-9_.\-]+
* * @return

* A name for the version of the model. This value must be unique. *

*/ public String getVersionName() { return versionName; } /** *

* A name for the version of the model. This value must be unique. *

*

* Constraints:
* Length: 1 - 255
* Pattern: [a-zA-Z0-9_.\-]+
* * @param versionName

* A name for the version of the model. This value must be * unique. *

*/ public void setVersionName(String versionName) { this.versionName = versionName; } /** *

* A name for the version of the model. This value must be unique. *

*

* Returns a reference to this object so that method calls can be chained * together. *

* Constraints:
* Length: 1 - 255
* Pattern: [a-zA-Z0-9_.\-]+
* * @param versionName

* A name for the version of the model. This value must be * unique. *

* @return A reference to this updated object so that method calls can be * chained together. */ public CreateProjectVersionRequest withVersionName(String versionName) { this.versionName = versionName; return this; } /** *

* The Amazon S3 bucket location to store the results of training. The S3 * bucket can be in any AWS account as long as the caller has * s3:PutObject permissions on the S3 bucket. *

* * @return

* The Amazon S3 bucket location to store the results of training. * The S3 bucket can be in any AWS account as long as the caller has * s3:PutObject permissions on the S3 bucket. *

*/ public OutputConfig getOutputConfig() { return outputConfig; } /** *

* The Amazon S3 bucket location to store the results of training. The S3 * bucket can be in any AWS account as long as the caller has * s3:PutObject permissions on the S3 bucket. *

* * @param outputConfig

* The Amazon S3 bucket location to store the results of * training. The S3 bucket can be in any AWS account as long as * the caller has s3:PutObject permissions on the S3 * bucket. *

*/ public void setOutputConfig(OutputConfig outputConfig) { this.outputConfig = outputConfig; } /** *

* The Amazon S3 bucket location to store the results of training. The S3 * bucket can be in any AWS account as long as the caller has * s3:PutObject permissions on the S3 bucket. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param outputConfig

* The Amazon S3 bucket location to store the results of * training. The S3 bucket can be in any AWS account as long as * the caller has s3:PutObject permissions on the S3 * bucket. *

* @return A reference to this updated object so that method calls can be * chained together. */ public CreateProjectVersionRequest withOutputConfig(OutputConfig outputConfig) { this.outputConfig = outputConfig; return this; } /** *

* Specifies an external manifest that the services uses to train the model. * If you specify TrainingData you must also specify * TestingData. The project must not have any associated * datasets. *

* * @return

* Specifies an external manifest that the services uses to train * the model. If you specify TrainingData you must also * specify TestingData. The project must not have any * associated datasets. *

*/ public TrainingData getTrainingData() { return trainingData; } /** *

* Specifies an external manifest that the services uses to train the model. * If you specify TrainingData you must also specify * TestingData. The project must not have any associated * datasets. *

* * @param trainingData

* Specifies an external manifest that the services uses to train * the model. If you specify TrainingData you must * also specify TestingData. The project must not * have any associated datasets. *

*/ public void setTrainingData(TrainingData trainingData) { this.trainingData = trainingData; } /** *

* Specifies an external manifest that the services uses to train the model. * If you specify TrainingData you must also specify * TestingData. The project must not have any associated * datasets. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param trainingData

* Specifies an external manifest that the services uses to train * the model. If you specify TrainingData you must * also specify TestingData. The project must not * have any associated datasets. *

* @return A reference to this updated object so that method calls can be * chained together. */ public CreateProjectVersionRequest withTrainingData(TrainingData trainingData) { this.trainingData = trainingData; return this; } /** *

* Specifies an external manifest that the service uses to test the model. * If you specify TestingData you must also specify * TrainingData. The project must not have any associated * datasets. *

* * @return

* Specifies an external manifest that the service uses to test the * model. If you specify TestingData you must also * specify TrainingData. The project must not have any * associated datasets. *

*/ public TestingData getTestingData() { return testingData; } /** *

* Specifies an external manifest that the service uses to test the model. * If you specify TestingData you must also specify * TrainingData. The project must not have any associated * datasets. *

* * @param testingData

* Specifies an external manifest that the service uses to test * the model. If you specify TestingData you must * also specify TrainingData. The project must not * have any associated datasets. *

*/ public void setTestingData(TestingData testingData) { this.testingData = testingData; } /** *

* Specifies an external manifest that the service uses to test the model. * If you specify TestingData you must also specify * TrainingData. The project must not have any associated * datasets. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param testingData

* Specifies an external manifest that the service uses to test * the model. If you specify TestingData you must * also specify TrainingData. The project must not * have any associated datasets. *

* @return A reference to this updated object so that method calls can be * chained together. */ public CreateProjectVersionRequest withTestingData(TestingData testingData) { this.testingData = testingData; return this; } /** *

* A set of tags (key-value pairs) that you want to attach to the model. *

* * @return

* A set of tags (key-value pairs) that you want to attach to the * model. *

*/ public java.util.Map getTags() { return tags; } /** *

* A set of tags (key-value pairs) that you want to attach to the model. *

* * @param tags

* A set of tags (key-value pairs) that you want to attach to the * model. *

*/ public void setTags(java.util.Map tags) { this.tags = tags; } /** *

* A set of tags (key-value pairs) that you want to attach to the model. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param tags

* A set of tags (key-value pairs) that you want to attach to the * model. *

* @return A reference to this updated object so that method calls can be * chained together. */ public CreateProjectVersionRequest withTags(java.util.Map tags) { this.tags = tags; return this; } /** *

* A set of tags (key-value pairs) that you want to attach to the model. *

*

* The method adds a new key-value pair into Tags parameter, and returns a * reference to this object so that method calls can be chained together. * * @param key The key of the entry to be added into Tags. * @param value The corresponding value of the entry to be added into Tags. * @return A reference to this updated object so that method calls can be * chained together. */ public CreateProjectVersionRequest addTagsEntry(String key, String value) { if (null == this.tags) { this.tags = new java.util.HashMap(); } if (this.tags.containsKey(key)) throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided."); this.tags.put(key, value); return this; } /** * Removes all the entries added into Tags. *

* Returns a reference to this object so that method calls can be chained * together. */ public CreateProjectVersionRequest clearTagsEntries() { this.tags = null; return this; } /** *

* The identifier for your AWS Key Management Service key (AWS KMS key). You * can supply the Amazon Resource Name (ARN) of your KMS key, the ID of your * KMS key, an alias for your KMS key, or an alias ARN. The key is used to * encrypt training and test images copied into the service for model * training. Your source images are unaffected. The key is also used to * encrypt training results and manifest files written to the output Amazon * S3 bucket (OutputConfig). *

*

* If you choose to use your own KMS key, you need the following permissions * on the KMS key. *

*
    *
  • *

    * kms:CreateGrant *

    *
  • *
  • *

    * kms:DescribeKey *

    *
  • *
  • *

    * kms:GenerateDataKey *

    *
  • *
  • *

    * kms:Decrypt *

    *
  • *
*

* If you don't specify a value for KmsKeyId, images copied * into the service are encrypted using a key that AWS owns and manages. *

*

* Constraints:
* Length: 1 - 2048
* Pattern: ^[A-Za-z0-9][A-Za-z0-9:_/+=,@.-]{0,2048}$
* * @return

* The identifier for your AWS Key Management Service key (AWS KMS * key). You can supply the Amazon Resource Name (ARN) of your KMS * key, the ID of your KMS key, an alias for your KMS key, or an * alias ARN. The key is used to encrypt training and test images * copied into the service for model training. Your source images * are unaffected. The key is also used to encrypt training results * and manifest files written to the output Amazon S3 bucket ( * OutputConfig). *

*

* If you choose to use your own KMS key, you need the following * permissions on the KMS key. *

*
    *
  • *

    * kms:CreateGrant *

    *
  • *
  • *

    * kms:DescribeKey *

    *
  • *
  • *

    * kms:GenerateDataKey *

    *
  • *
  • *

    * kms:Decrypt *

    *
  • *
*

* If you don't specify a value for KmsKeyId, images * copied into the service are encrypted using a key that AWS owns * and manages. *

*/ public String getKmsKeyId() { return kmsKeyId; } /** *

* The identifier for your AWS Key Management Service key (AWS KMS key). You * can supply the Amazon Resource Name (ARN) of your KMS key, the ID of your * KMS key, an alias for your KMS key, or an alias ARN. The key is used to * encrypt training and test images copied into the service for model * training. Your source images are unaffected. The key is also used to * encrypt training results and manifest files written to the output Amazon * S3 bucket (OutputConfig). *

*

* If you choose to use your own KMS key, you need the following permissions * on the KMS key. *

*
    *
  • *

    * kms:CreateGrant *

    *
  • *
  • *

    * kms:DescribeKey *

    *
  • *
  • *

    * kms:GenerateDataKey *

    *
  • *
  • *

    * kms:Decrypt *

    *
  • *
*

* If you don't specify a value for KmsKeyId, images copied * into the service are encrypted using a key that AWS owns and manages. *

*

* Constraints:
* Length: 1 - 2048
* Pattern: ^[A-Za-z0-9][A-Za-z0-9:_/+=,@.-]{0,2048}$
* * @param kmsKeyId

* The identifier for your AWS Key Management Service key (AWS * KMS key). You can supply the Amazon Resource Name (ARN) of * your KMS key, the ID of your KMS key, an alias for your KMS * key, or an alias ARN. The key is used to encrypt training and * test images copied into the service for model training. Your * source images are unaffected. The key is also used to encrypt * training results and manifest files written to the output * Amazon S3 bucket (OutputConfig). *

*

* If you choose to use your own KMS key, you need the following * permissions on the KMS key. *

*
    *
  • *

    * kms:CreateGrant *

    *
  • *
  • *

    * kms:DescribeKey *

    *
  • *
  • *

    * kms:GenerateDataKey *

    *
  • *
  • *

    * kms:Decrypt *

    *
  • *
*

* If you don't specify a value for KmsKeyId, images * copied into the service are encrypted using a key that AWS * owns and manages. *

*/ public void setKmsKeyId(String kmsKeyId) { this.kmsKeyId = kmsKeyId; } /** *

* The identifier for your AWS Key Management Service key (AWS KMS key). You * can supply the Amazon Resource Name (ARN) of your KMS key, the ID of your * KMS key, an alias for your KMS key, or an alias ARN. The key is used to * encrypt training and test images copied into the service for model * training. Your source images are unaffected. The key is also used to * encrypt training results and manifest files written to the output Amazon * S3 bucket (OutputConfig). *

*

* If you choose to use your own KMS key, you need the following permissions * on the KMS key. *

*
    *
  • *

    * kms:CreateGrant *

    *
  • *
  • *

    * kms:DescribeKey *

    *
  • *
  • *

    * kms:GenerateDataKey *

    *
  • *
  • *

    * kms:Decrypt *

    *
  • *
*

* If you don't specify a value for KmsKeyId, images copied * into the service are encrypted using a key that AWS owns and manages. *

*

* Returns a reference to this object so that method calls can be chained * together. *

* Constraints:
* Length: 1 - 2048
* Pattern: ^[A-Za-z0-9][A-Za-z0-9:_/+=,@.-]{0,2048}$
* * @param kmsKeyId

* The identifier for your AWS Key Management Service key (AWS * KMS key). You can supply the Amazon Resource Name (ARN) of * your KMS key, the ID of your KMS key, an alias for your KMS * key, or an alias ARN. The key is used to encrypt training and * test images copied into the service for model training. Your * source images are unaffected. The key is also used to encrypt * training results and manifest files written to the output * Amazon S3 bucket (OutputConfig). *

*

* If you choose to use your own KMS key, you need the following * permissions on the KMS key. *

*
    *
  • *

    * kms:CreateGrant *

    *
  • *
  • *

    * kms:DescribeKey *

    *
  • *
  • *

    * kms:GenerateDataKey *

    *
  • *
  • *

    * kms:Decrypt *

    *
  • *
*

* If you don't specify a value for KmsKeyId, images * copied into the service are encrypted using a key that AWS * owns and manages. *

* @return A reference to this updated object so that method calls can be * chained together. */ public CreateProjectVersionRequest withKmsKeyId(String kmsKeyId) { this.kmsKeyId = kmsKeyId; return this; } /** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getProjectArn() != null) sb.append("ProjectArn: " + getProjectArn() + ","); if (getVersionName() != null) sb.append("VersionName: " + getVersionName() + ","); if (getOutputConfig() != null) sb.append("OutputConfig: " + getOutputConfig() + ","); if (getTrainingData() != null) sb.append("TrainingData: " + getTrainingData() + ","); if (getTestingData() != null) sb.append("TestingData: " + getTestingData() + ","); if (getTags() != null) sb.append("Tags: " + getTags() + ","); if (getKmsKeyId() != null) sb.append("KmsKeyId: " + getKmsKeyId()); sb.append("}"); return sb.toString(); } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getProjectArn() == null) ? 0 : getProjectArn().hashCode()); hashCode = prime * hashCode + ((getVersionName() == null) ? 0 : getVersionName().hashCode()); hashCode = prime * hashCode + ((getOutputConfig() == null) ? 0 : getOutputConfig().hashCode()); hashCode = prime * hashCode + ((getTrainingData() == null) ? 0 : getTrainingData().hashCode()); hashCode = prime * hashCode + ((getTestingData() == null) ? 0 : getTestingData().hashCode()); hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode()); hashCode = prime * hashCode + ((getKmsKeyId() == null) ? 0 : getKmsKeyId().hashCode()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof CreateProjectVersionRequest == false) return false; CreateProjectVersionRequest other = (CreateProjectVersionRequest) obj; if (other.getProjectArn() == null ^ this.getProjectArn() == null) return false; if (other.getProjectArn() != null && other.getProjectArn().equals(this.getProjectArn()) == false) return false; if (other.getVersionName() == null ^ this.getVersionName() == null) return false; if (other.getVersionName() != null && other.getVersionName().equals(this.getVersionName()) == false) return false; if (other.getOutputConfig() == null ^ this.getOutputConfig() == null) return false; if (other.getOutputConfig() != null && other.getOutputConfig().equals(this.getOutputConfig()) == false) return false; if (other.getTrainingData() == null ^ this.getTrainingData() == null) return false; if (other.getTrainingData() != null && other.getTrainingData().equals(this.getTrainingData()) == false) return false; if (other.getTestingData() == null ^ this.getTestingData() == null) return false; if (other.getTestingData() != null && other.getTestingData().equals(this.getTestingData()) == false) return false; if (other.getTags() == null ^ this.getTags() == null) return false; if (other.getTags() != null && other.getTags().equals(this.getTags()) == false) return false; if (other.getKmsKeyId() == null ^ this.getKmsKeyId() == null) return false; if (other.getKmsKeyId() != null && other.getKmsKeyId().equals(this.getKmsKeyId()) == false) return false; return true; } }