
software.amazon.awssdk.services.ec2.model.LaunchTemplateEbsBlockDevice 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.ec2.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;
/**
*
* Describes a block device for an EBS volume.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class LaunchTemplateEbsBlockDevice implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField ENCRYPTED_FIELD = SdkField
. builder(MarshallingType.BOOLEAN)
.memberName("Encrypted")
.getter(getter(LaunchTemplateEbsBlockDevice::encrypted))
.setter(setter(Builder::encrypted))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Encrypted")
.unmarshallLocationName("encrypted").build()).build();
private static final SdkField DELETE_ON_TERMINATION_FIELD = SdkField
. builder(MarshallingType.BOOLEAN)
.memberName("DeleteOnTermination")
.getter(getter(LaunchTemplateEbsBlockDevice::deleteOnTermination))
.setter(setter(Builder::deleteOnTermination))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DeleteOnTermination")
.unmarshallLocationName("deleteOnTermination").build()).build();
private static final SdkField IOPS_FIELD = SdkField
. builder(MarshallingType.INTEGER)
.memberName("Iops")
.getter(getter(LaunchTemplateEbsBlockDevice::iops))
.setter(setter(Builder::iops))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Iops")
.unmarshallLocationName("iops").build()).build();
private static final SdkField KMS_KEY_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("KmsKeyId")
.getter(getter(LaunchTemplateEbsBlockDevice::kmsKeyId))
.setter(setter(Builder::kmsKeyId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KmsKeyId")
.unmarshallLocationName("kmsKeyId").build()).build();
private static final SdkField SNAPSHOT_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("SnapshotId")
.getter(getter(LaunchTemplateEbsBlockDevice::snapshotId))
.setter(setter(Builder::snapshotId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SnapshotId")
.unmarshallLocationName("snapshotId").build()).build();
private static final SdkField VOLUME_SIZE_FIELD = SdkField
. builder(MarshallingType.INTEGER)
.memberName("VolumeSize")
.getter(getter(LaunchTemplateEbsBlockDevice::volumeSize))
.setter(setter(Builder::volumeSize))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("VolumeSize")
.unmarshallLocationName("volumeSize").build()).build();
private static final SdkField VOLUME_TYPE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("VolumeType")
.getter(getter(LaunchTemplateEbsBlockDevice::volumeTypeAsString))
.setter(setter(Builder::volumeType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("VolumeType")
.unmarshallLocationName("volumeType").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ENCRYPTED_FIELD,
DELETE_ON_TERMINATION_FIELD, IOPS_FIELD, KMS_KEY_ID_FIELD, SNAPSHOT_ID_FIELD, VOLUME_SIZE_FIELD, VOLUME_TYPE_FIELD));
private static final long serialVersionUID = 1L;
private final Boolean encrypted;
private final Boolean deleteOnTermination;
private final Integer iops;
private final String kmsKeyId;
private final String snapshotId;
private final Integer volumeSize;
private final String volumeType;
private LaunchTemplateEbsBlockDevice(BuilderImpl builder) {
this.encrypted = builder.encrypted;
this.deleteOnTermination = builder.deleteOnTermination;
this.iops = builder.iops;
this.kmsKeyId = builder.kmsKeyId;
this.snapshotId = builder.snapshotId;
this.volumeSize = builder.volumeSize;
this.volumeType = builder.volumeType;
}
/**
*
* Indicates whether the EBS volume is encrypted.
*
*
* @return Indicates whether the EBS volume is encrypted.
*/
public Boolean encrypted() {
return encrypted;
}
/**
*
* Indicates whether the EBS volume is deleted on instance termination.
*
*
* @return Indicates whether the EBS volume is deleted on instance termination.
*/
public Boolean deleteOnTermination() {
return deleteOnTermination;
}
/**
*
* The number of I/O operations per second (IOPS) that the volume supports.
*
*
* @return The number of I/O operations per second (IOPS) that the volume supports.
*/
public Integer iops() {
return iops;
}
/**
*
* The ARN of the AWS Key Management Service (AWS KMS) CMK used for encryption.
*
*
* @return The ARN of the AWS Key Management Service (AWS KMS) CMK used for encryption.
*/
public String kmsKeyId() {
return kmsKeyId;
}
/**
*
* The ID of the snapshot.
*
*
* @return The ID of the snapshot.
*/
public String snapshotId() {
return snapshotId;
}
/**
*
* The size of the volume, in GiB.
*
*
* @return The size of the volume, in GiB.
*/
public Integer volumeSize() {
return volumeSize;
}
/**
*
* The volume type.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #volumeType} will
* return {@link VolumeType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #volumeTypeAsString}.
*
*
* @return The volume type.
* @see VolumeType
*/
public VolumeType volumeType() {
return VolumeType.fromValue(volumeType);
}
/**
*
* The volume type.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #volumeType} will
* return {@link VolumeType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #volumeTypeAsString}.
*
*
* @return The volume type.
* @see VolumeType
*/
public String volumeTypeAsString() {
return volumeType;
}
@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 int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(encrypted());
hashCode = 31 * hashCode + Objects.hashCode(deleteOnTermination());
hashCode = 31 * hashCode + Objects.hashCode(iops());
hashCode = 31 * hashCode + Objects.hashCode(kmsKeyId());
hashCode = 31 * hashCode + Objects.hashCode(snapshotId());
hashCode = 31 * hashCode + Objects.hashCode(volumeSize());
hashCode = 31 * hashCode + Objects.hashCode(volumeTypeAsString());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof LaunchTemplateEbsBlockDevice)) {
return false;
}
LaunchTemplateEbsBlockDevice other = (LaunchTemplateEbsBlockDevice) obj;
return Objects.equals(encrypted(), other.encrypted())
&& Objects.equals(deleteOnTermination(), other.deleteOnTermination()) && Objects.equals(iops(), other.iops())
&& Objects.equals(kmsKeyId(), other.kmsKeyId()) && Objects.equals(snapshotId(), other.snapshotId())
&& Objects.equals(volumeSize(), other.volumeSize())
&& Objects.equals(volumeTypeAsString(), other.volumeTypeAsString());
}
/**
* 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 String toString() {
return ToString.builder("LaunchTemplateEbsBlockDevice").add("Encrypted", encrypted())
.add("DeleteOnTermination", deleteOnTermination()).add("Iops", iops()).add("KmsKeyId", kmsKeyId())
.add("SnapshotId", snapshotId()).add("VolumeSize", volumeSize()).add("VolumeType", volumeTypeAsString()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Encrypted":
return Optional.ofNullable(clazz.cast(encrypted()));
case "DeleteOnTermination":
return Optional.ofNullable(clazz.cast(deleteOnTermination()));
case "Iops":
return Optional.ofNullable(clazz.cast(iops()));
case "KmsKeyId":
return Optional.ofNullable(clazz.cast(kmsKeyId()));
case "SnapshotId":
return Optional.ofNullable(clazz.cast(snapshotId()));
case "VolumeSize":
return Optional.ofNullable(clazz.cast(volumeSize()));
case "VolumeType":
return Optional.ofNullable(clazz.cast(volumeTypeAsString()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function