software.amazon.awssdk.services.sagemaker.model.OutputDataConfig Maven / Gradle / Ivy
/*
* Copyright 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 software.amazon.awssdk.services.sagemaker.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Provides information about how to store model training results (model artifacts).
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class OutputDataConfig implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField KMS_KEY_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("KmsKeyId").getter(getter(OutputDataConfig::kmsKeyId)).setter(setter(Builder::kmsKeyId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KmsKeyId").build()).build();
private static final SdkField S3_OUTPUT_PATH_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("S3OutputPath").getter(getter(OutputDataConfig::s3OutputPath)).setter(setter(Builder::s3OutputPath))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("S3OutputPath").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(KMS_KEY_ID_FIELD,
S3_OUTPUT_PATH_FIELD));
private static final long serialVersionUID = 1L;
private final String kmsKeyId;
private final String s3OutputPath;
private OutputDataConfig(BuilderImpl builder) {
this.kmsKeyId = builder.kmsKeyId;
this.s3OutputPath = builder.s3OutputPath;
}
/**
*
* The Amazon Web Services Key Management Service (Amazon Web Services KMS) key that SageMaker uses to encrypt the
* model artifacts at rest using Amazon S3 server-side encryption. The KmsKeyId
can be any of the
* following formats:
*
*
* -
*
* // KMS Key ID
*
*
* "1234abcd-12ab-34cd-56ef-1234567890ab"
*
*
* -
*
* // Amazon Resource Name (ARN) of a KMS Key
*
*
* "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"
*
*
* -
*
* // KMS Key Alias
*
*
* "alias/ExampleAlias"
*
*
* -
*
* // Amazon Resource Name (ARN) of a KMS Key Alias
*
*
* "arn:aws:kms:us-west-2:111122223333:alias/ExampleAlias"
*
*
*
*
* If you use a KMS key ID or an alias of your KMS key, the SageMaker execution role must include permissions to
* call kms:Encrypt
. If you don't provide a KMS key ID, SageMaker uses the default KMS key for Amazon
* S3 for your role's account. SageMaker uses server-side encryption with KMS-managed keys for
* OutputDataConfig
. If you use a bucket policy with an s3:PutObject
permission that only
* allows objects with server-side encryption, set the condition key of s3:x-amz-server-side-encryption
* to "aws:kms"
. For more information, see KMS-Managed Encryption
* Keys in the Amazon Simple Storage Service Developer Guide.
*
*
* The KMS key policy must grant permission to the IAM role that you specify in your CreateTrainingJob
,
* CreateTransformJob
, or CreateHyperParameterTuningJob
requests. For more information,
* see Using Key Policies in
* Amazon Web Services KMS in the Amazon Web Services Key Management Service Developer Guide.
*
*
* @return The Amazon Web Services Key Management Service (Amazon Web Services KMS) key that SageMaker uses to
* encrypt the model artifacts at rest using Amazon S3 server-side encryption. The KmsKeyId
can
* be any of the following formats:
*
* -
*
* // KMS Key ID
*
*
* "1234abcd-12ab-34cd-56ef-1234567890ab"
*
*
* -
*
* // Amazon Resource Name (ARN) of a KMS Key
*
*
* "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"
*
*
* -
*
* // KMS Key Alias
*
*
* "alias/ExampleAlias"
*
*
* -
*
* // Amazon Resource Name (ARN) of a KMS Key Alias
*
*
* "arn:aws:kms:us-west-2:111122223333:alias/ExampleAlias"
*
*
*
*
* If you use a KMS key ID or an alias of your KMS key, the SageMaker execution role must include
* permissions to call kms:Encrypt
. If you don't provide a KMS key ID, SageMaker uses the
* default KMS key for Amazon S3 for your role's account. SageMaker uses server-side encryption with
* KMS-managed keys for OutputDataConfig
. If you use a bucket policy with an
* s3:PutObject
permission that only allows objects with server-side encryption, set the
* condition key of s3:x-amz-server-side-encryption
to "aws:kms"
. For more
* information, see KMS-Managed
* Encryption Keys in the Amazon Simple Storage Service Developer Guide.
*
*
* The KMS key policy must grant permission to the IAM role that you specify in your
* CreateTrainingJob
, CreateTransformJob
, or
* CreateHyperParameterTuningJob
requests. For more information, see Using Key Policies in
* Amazon Web Services KMS in the Amazon Web Services Key Management Service Developer Guide.
*/
public final String kmsKeyId() {
return kmsKeyId;
}
/**
*
* Identifies the S3 path where you want SageMaker to store the model artifacts. For example,
* s3://bucket-name/key-name-prefix
.
*
*
* @return Identifies the S3 path where you want SageMaker to store the model artifacts. For example,
* s3://bucket-name/key-name-prefix
.
*/
public final String s3OutputPath() {
return s3OutputPath;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(kmsKeyId());
hashCode = 31 * hashCode + Objects.hashCode(s3OutputPath());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof OutputDataConfig)) {
return false;
}
OutputDataConfig other = (OutputDataConfig) obj;
return Objects.equals(kmsKeyId(), other.kmsKeyId()) && Objects.equals(s3OutputPath(), other.s3OutputPath());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public final String toString() {
return ToString.builder("OutputDataConfig").add("KmsKeyId", kmsKeyId()).add("S3OutputPath", s3OutputPath()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "KmsKeyId":
return Optional.ofNullable(clazz.cast(kmsKeyId()));
case "S3OutputPath":
return Optional.ofNullable(clazz.cast(s3OutputPath()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function