
software.amazon.awssdk.services.ec2.model.CreateVolumeResponse 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.time.Instant;
import java.util.Arrays;
import java.util.Collection;
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.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Describes a volume.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class CreateVolumeResponse extends Ec2Response implements
ToCopyableBuilder {
private static final SdkField> ATTACHMENTS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Attachments")
.getter(getter(CreateVolumeResponse::attachments))
.setter(setter(Builder::attachments))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AttachmentSet")
.unmarshallLocationName("attachmentSet").build(),
ListTrait
.builder()
.memberLocationName("item")
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(VolumeAttachment::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("Item").unmarshallLocationName("item").build()).build())
.build()).build();
private static final SdkField AVAILABILITY_ZONE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("AvailabilityZone")
.getter(getter(CreateVolumeResponse::availabilityZone))
.setter(setter(Builder::availabilityZone))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AvailabilityZone")
.unmarshallLocationName("availabilityZone").build()).build();
private static final SdkField CREATE_TIME_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("CreateTime")
.getter(getter(CreateVolumeResponse::createTime))
.setter(setter(Builder::createTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreateTime")
.unmarshallLocationName("createTime").build()).build();
private static final SdkField ENCRYPTED_FIELD = SdkField
. builder(MarshallingType.BOOLEAN)
.memberName("Encrypted")
.getter(getter(CreateVolumeResponse::encrypted))
.setter(setter(Builder::encrypted))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Encrypted")
.unmarshallLocationName("encrypted").build()).build();
private static final SdkField KMS_KEY_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("KmsKeyId")
.getter(getter(CreateVolumeResponse::kmsKeyId))
.setter(setter(Builder::kmsKeyId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KmsKeyId")
.unmarshallLocationName("kmsKeyId").build()).build();
private static final SdkField OUTPOST_ARN_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("OutpostArn")
.getter(getter(CreateVolumeResponse::outpostArn))
.setter(setter(Builder::outpostArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OutpostArn")
.unmarshallLocationName("outpostArn").build()).build();
private static final SdkField SIZE_FIELD = SdkField
. builder(MarshallingType.INTEGER)
.memberName("Size")
.getter(getter(CreateVolumeResponse::size))
.setter(setter(Builder::size))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Size")
.unmarshallLocationName("size").build()).build();
private static final SdkField SNAPSHOT_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("SnapshotId")
.getter(getter(CreateVolumeResponse::snapshotId))
.setter(setter(Builder::snapshotId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SnapshotId")
.unmarshallLocationName("snapshotId").build()).build();
private static final SdkField STATE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("State")
.getter(getter(CreateVolumeResponse::stateAsString))
.setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status")
.unmarshallLocationName("status").build()).build();
private static final SdkField VOLUME_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("VolumeId")
.getter(getter(CreateVolumeResponse::volumeId))
.setter(setter(Builder::volumeId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("VolumeId")
.unmarshallLocationName("volumeId").build()).build();
private static final SdkField IOPS_FIELD = SdkField
. builder(MarshallingType.INTEGER)
.memberName("Iops")
.getter(getter(CreateVolumeResponse::iops))
.setter(setter(Builder::iops))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Iops")
.unmarshallLocationName("iops").build()).build();
private static final SdkField> TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Tags")
.getter(getter(CreateVolumeResponse::tags))
.setter(setter(Builder::tags))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TagSet")
.unmarshallLocationName("tagSet").build(),
ListTrait
.builder()
.memberLocationName("item")
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Tag::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("Item").unmarshallLocationName("item").build()).build())
.build()).build();
private static final SdkField VOLUME_TYPE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("VolumeType")
.getter(getter(CreateVolumeResponse::volumeTypeAsString))
.setter(setter(Builder::volumeType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("VolumeType")
.unmarshallLocationName("volumeType").build()).build();
private static final SdkField FAST_RESTORED_FIELD = SdkField
. builder(MarshallingType.BOOLEAN)
.memberName("FastRestored")
.getter(getter(CreateVolumeResponse::fastRestored))
.setter(setter(Builder::fastRestored))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FastRestored")
.unmarshallLocationName("fastRestored").build()).build();
private static final SdkField MULTI_ATTACH_ENABLED_FIELD = SdkField
. builder(MarshallingType.BOOLEAN)
.memberName("MultiAttachEnabled")
.getter(getter(CreateVolumeResponse::multiAttachEnabled))
.setter(setter(Builder::multiAttachEnabled))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MultiAttachEnabled")
.unmarshallLocationName("multiAttachEnabled").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ATTACHMENTS_FIELD,
AVAILABILITY_ZONE_FIELD, CREATE_TIME_FIELD, ENCRYPTED_FIELD, KMS_KEY_ID_FIELD, OUTPOST_ARN_FIELD, SIZE_FIELD,
SNAPSHOT_ID_FIELD, STATE_FIELD, VOLUME_ID_FIELD, IOPS_FIELD, TAGS_FIELD, VOLUME_TYPE_FIELD, FAST_RESTORED_FIELD,
MULTI_ATTACH_ENABLED_FIELD));
private final List attachments;
private final String availabilityZone;
private final Instant createTime;
private final Boolean encrypted;
private final String kmsKeyId;
private final String outpostArn;
private final Integer size;
private final String snapshotId;
private final String state;
private final String volumeId;
private final Integer iops;
private final List tags;
private final String volumeType;
private final Boolean fastRestored;
private final Boolean multiAttachEnabled;
private CreateVolumeResponse(BuilderImpl builder) {
super(builder);
this.attachments = builder.attachments;
this.availabilityZone = builder.availabilityZone;
this.createTime = builder.createTime;
this.encrypted = builder.encrypted;
this.kmsKeyId = builder.kmsKeyId;
this.outpostArn = builder.outpostArn;
this.size = builder.size;
this.snapshotId = builder.snapshotId;
this.state = builder.state;
this.volumeId = builder.volumeId;
this.iops = builder.iops;
this.tags = builder.tags;
this.volumeType = builder.volumeType;
this.fastRestored = builder.fastRestored;
this.multiAttachEnabled = builder.multiAttachEnabled;
}
/**
* Returns true if the Attachments property was specified by the sender (it may be empty), or false if the sender
* did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service.
*/
public boolean hasAttachments() {
return attachments != null && !(attachments instanceof SdkAutoConstructList);
}
/**
*
* Information about the volume attachments.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasAttachments()} to see if a value was sent in this field.
*
*
* @return Information about the volume attachments.
*/
public List attachments() {
return attachments;
}
/**
*
* The Availability Zone for the volume.
*
*
* @return The Availability Zone for the volume.
*/
public String availabilityZone() {
return availabilityZone;
}
/**
*
* The time stamp when volume creation was initiated.
*
*
* @return The time stamp when volume creation was initiated.
*/
public Instant createTime() {
return createTime;
}
/**
*
* Indicates whether the volume is encrypted.
*
*
* @return Indicates whether the volume is encrypted.
*/
public Boolean encrypted() {
return encrypted;
}
/**
*
* The Amazon Resource Name (ARN) of the AWS Key Management Service (AWS KMS) customer master key (CMK) that was
* used to protect the volume encryption key for the volume.
*
*
* @return The Amazon Resource Name (ARN) of the AWS Key Management Service (AWS KMS) customer master key (CMK) that
* was used to protect the volume encryption key for the volume.
*/
public String kmsKeyId() {
return kmsKeyId;
}
/**
*
* The Amazon Resource Name (ARN) of the Outpost.
*
*
* @return The Amazon Resource Name (ARN) of the Outpost.
*/
public String outpostArn() {
return outpostArn;
}
/**
*
* The size of the volume, in GiBs.
*
*
* @return The size of the volume, in GiBs.
*/
public Integer size() {
return size;
}
/**
*
* The snapshot from which the volume was created, if applicable.
*
*
* @return The snapshot from which the volume was created, if applicable.
*/
public String snapshotId() {
return snapshotId;
}
/**
*
* The volume state.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link VolumeState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The volume state.
* @see VolumeState
*/
public VolumeState state() {
return VolumeState.fromValue(state);
}
/**
*
* The volume state.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link VolumeState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The volume state.
* @see VolumeState
*/
public String stateAsString() {
return state;
}
/**
*
* The ID of the volume.
*
*
* @return The ID of the volume.
*/
public String volumeId() {
return volumeId;
}
/**
*
* The number of I/O operations per second (IOPS) that the volume supports. For Provisioned IOPS SSD volumes, this
* represents the number of IOPS that are provisioned for the volume. For General Purpose SSD volumes, this
* represents the baseline performance of the volume and the rate at which the volume accumulates I/O credits for
* bursting. For more information, see Amazon EBS volume types in the
* Amazon Elastic Compute Cloud User Guide.
*
*
* Constraints: Range is 100-16,000 IOPS for gp2
volumes and 100 to 64,000 IOPS for io1
* and io2
volumes, in most Regions. The maximum IOPS for io1
and io2
of
* 64,000 is guaranteed only on Nitro-based
* instances. Other instance families guarantee performance up to 32,000 IOPS.
*
*
* Condition: This parameter is required for requests to create io1
and io2
volumes; it is
* not used in requests to create gp2
, st1
, sc1
, or standard
* volumes.
*
*
* @return The number of I/O operations per second (IOPS) that the volume supports. For Provisioned IOPS SSD
* volumes, this represents the number of IOPS that are provisioned for the volume. For General Purpose SSD
* volumes, this represents the baseline performance of the volume and the rate at which the volume
* accumulates I/O credits for bursting. For more information, see Amazon EBS volume
* types in the Amazon Elastic Compute Cloud User Guide.
*
* Constraints: Range is 100-16,000 IOPS for gp2
volumes and 100 to 64,000 IOPS for
* io1
and io2
volumes, in most Regions. The maximum IOPS for io1
and
* io2
of 64,000 is guaranteed only on Nitro-based instances. Other instance families guarantee performance up to 32,000 IOPS.
*
*
* Condition: This parameter is required for requests to create io1
and io2
* volumes; it is not used in requests to create gp2
, st1
, sc1
, or
* standard
volumes.
*/
public Integer iops() {
return iops;
}
/**
* Returns true if the Tags property was specified by the sender (it may be empty), or false if the sender did not
* specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service.
*/
public boolean hasTags() {
return tags != null && !(tags instanceof SdkAutoConstructList);
}
/**
*
* Any tags assigned to the volume.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasTags()} to see if a value was sent in this field.
*
*
* @return Any tags assigned to the volume.
*/
public List tags() {
return tags;
}
/**
*
* The volume type. This can be gp2
for General Purpose SSD, io1
or io2
for
* Provisioned IOPS SSD, st1
for Throughput Optimized HDD, sc1
for Cold HDD, or
* standard
for Magnetic volumes.
*
*
* 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. This can be gp2
for General Purpose SSD, io1
or
* io2
for Provisioned IOPS SSD, st1
for Throughput Optimized HDD,
* sc1
for Cold HDD, or standard
for Magnetic volumes.
* @see VolumeType
*/
public VolumeType volumeType() {
return VolumeType.fromValue(volumeType);
}
/**
*
* The volume type. This can be gp2
for General Purpose SSD, io1
or io2
for
* Provisioned IOPS SSD, st1
for Throughput Optimized HDD, sc1
for Cold HDD, or
* standard
for Magnetic volumes.
*
*
* 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. This can be gp2
for General Purpose SSD, io1
or
* io2
for Provisioned IOPS SSD, st1
for Throughput Optimized HDD,
* sc1
for Cold HDD, or standard
for Magnetic volumes.
* @see VolumeType
*/
public String volumeTypeAsString() {
return volumeType;
}
/**
*
* Indicates whether the volume was created using fast snapshot restore.
*
*
* @return Indicates whether the volume was created using fast snapshot restore.
*/
public Boolean fastRestored() {
return fastRestored;
}
/**
*
* Indicates whether Amazon EBS Multi-Attach is enabled.
*
*
* @return Indicates whether Amazon EBS Multi-Attach is enabled.
*/
public Boolean multiAttachEnabled() {
return multiAttachEnabled;
}
@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 + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(attachments());
hashCode = 31 * hashCode + Objects.hashCode(availabilityZone());
hashCode = 31 * hashCode + Objects.hashCode(createTime());
hashCode = 31 * hashCode + Objects.hashCode(encrypted());
hashCode = 31 * hashCode + Objects.hashCode(kmsKeyId());
hashCode = 31 * hashCode + Objects.hashCode(outpostArn());
hashCode = 31 * hashCode + Objects.hashCode(size());
hashCode = 31 * hashCode + Objects.hashCode(snapshotId());
hashCode = 31 * hashCode + Objects.hashCode(stateAsString());
hashCode = 31 * hashCode + Objects.hashCode(volumeId());
hashCode = 31 * hashCode + Objects.hashCode(iops());
hashCode = 31 * hashCode + Objects.hashCode(tags());
hashCode = 31 * hashCode + Objects.hashCode(volumeTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(fastRestored());
hashCode = 31 * hashCode + Objects.hashCode(multiAttachEnabled());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof CreateVolumeResponse)) {
return false;
}
CreateVolumeResponse other = (CreateVolumeResponse) obj;
return Objects.equals(attachments(), other.attachments()) && Objects.equals(availabilityZone(), other.availabilityZone())
&& Objects.equals(createTime(), other.createTime()) && Objects.equals(encrypted(), other.encrypted())
&& Objects.equals(kmsKeyId(), other.kmsKeyId()) && Objects.equals(outpostArn(), other.outpostArn())
&& Objects.equals(size(), other.size()) && Objects.equals(snapshotId(), other.snapshotId())
&& Objects.equals(stateAsString(), other.stateAsString()) && Objects.equals(volumeId(), other.volumeId())
&& Objects.equals(iops(), other.iops()) && Objects.equals(tags(), other.tags())
&& Objects.equals(volumeTypeAsString(), other.volumeTypeAsString())
&& Objects.equals(fastRestored(), other.fastRestored())
&& Objects.equals(multiAttachEnabled(), other.multiAttachEnabled());
}
/**
* 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("CreateVolumeResponse").add("Attachments", attachments())
.add("AvailabilityZone", availabilityZone()).add("CreateTime", createTime()).add("Encrypted", encrypted())
.add("KmsKeyId", kmsKeyId()).add("OutpostArn", outpostArn()).add("Size", size()).add("SnapshotId", snapshotId())
.add("State", stateAsString()).add("VolumeId", volumeId()).add("Iops", iops()).add("Tags", tags())
.add("VolumeType", volumeTypeAsString()).add("FastRestored", fastRestored())
.add("MultiAttachEnabled", multiAttachEnabled()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Attachments":
return Optional.ofNullable(clazz.cast(attachments()));
case "AvailabilityZone":
return Optional.ofNullable(clazz.cast(availabilityZone()));
case "CreateTime":
return Optional.ofNullable(clazz.cast(createTime()));
case "Encrypted":
return Optional.ofNullable(clazz.cast(encrypted()));
case "KmsKeyId":
return Optional.ofNullable(clazz.cast(kmsKeyId()));
case "OutpostArn":
return Optional.ofNullable(clazz.cast(outpostArn()));
case "Size":
return Optional.ofNullable(clazz.cast(size()));
case "SnapshotId":
return Optional.ofNullable(clazz.cast(snapshotId()));
case "State":
return Optional.ofNullable(clazz.cast(stateAsString()));
case "VolumeId":
return Optional.ofNullable(clazz.cast(volumeId()));
case "Iops":
return Optional.ofNullable(clazz.cast(iops()));
case "Tags":
return Optional.ofNullable(clazz.cast(tags()));
case "VolumeType":
return Optional.ofNullable(clazz.cast(volumeTypeAsString()));
case "FastRestored":
return Optional.ofNullable(clazz.cast(fastRestored()));
case "MultiAttachEnabled":
return Optional.ofNullable(clazz.cast(multiAttachEnabled()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function