
software.amazon.awssdk.services.ec2.model.Snapshot 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.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 snapshot.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Snapshot implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField DATA_ENCRYPTION_KEY_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("DataEncryptionKeyId")
.getter(getter(Snapshot::dataEncryptionKeyId))
.setter(setter(Builder::dataEncryptionKeyId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DataEncryptionKeyId")
.unmarshallLocationName("dataEncryptionKeyId").build()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Description")
.getter(getter(Snapshot::description))
.setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description")
.unmarshallLocationName("description").build()).build();
private static final SdkField ENCRYPTED_FIELD = SdkField
. builder(MarshallingType.BOOLEAN)
.memberName("Encrypted")
.getter(getter(Snapshot::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(Snapshot::kmsKeyId))
.setter(setter(Builder::kmsKeyId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KmsKeyId")
.unmarshallLocationName("kmsKeyId").build()).build();
private static final SdkField OWNER_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("OwnerId")
.getter(getter(Snapshot::ownerId))
.setter(setter(Builder::ownerId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OwnerId")
.unmarshallLocationName("ownerId").build()).build();
private static final SdkField PROGRESS_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Progress")
.getter(getter(Snapshot::progress))
.setter(setter(Builder::progress))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Progress")
.unmarshallLocationName("progress").build()).build();
private static final SdkField SNAPSHOT_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("SnapshotId")
.getter(getter(Snapshot::snapshotId))
.setter(setter(Builder::snapshotId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SnapshotId")
.unmarshallLocationName("snapshotId").build()).build();
private static final SdkField START_TIME_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("StartTime")
.getter(getter(Snapshot::startTime))
.setter(setter(Builder::startTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StartTime")
.unmarshallLocationName("startTime").build()).build();
private static final SdkField STATE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("State")
.getter(getter(Snapshot::stateAsString))
.setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status")
.unmarshallLocationName("status").build()).build();
private static final SdkField STATE_MESSAGE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("StateMessage")
.getter(getter(Snapshot::stateMessage))
.setter(setter(Builder::stateMessage))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StatusMessage")
.unmarshallLocationName("statusMessage").build()).build();
private static final SdkField VOLUME_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("VolumeId")
.getter(getter(Snapshot::volumeId))
.setter(setter(Builder::volumeId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("VolumeId")
.unmarshallLocationName("volumeId").build()).build();
private static final SdkField VOLUME_SIZE_FIELD = SdkField
. builder(MarshallingType.INTEGER)
.memberName("VolumeSize")
.getter(getter(Snapshot::volumeSize))
.setter(setter(Builder::volumeSize))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("VolumeSize")
.unmarshallLocationName("volumeSize").build()).build();
private static final SdkField OWNER_ALIAS_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("OwnerAlias")
.getter(getter(Snapshot::ownerAlias))
.setter(setter(Builder::ownerAlias))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OwnerAlias")
.unmarshallLocationName("ownerAlias").build()).build();
private static final SdkField> TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Tags")
.getter(getter(Snapshot::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 List> SDK_FIELDS = Collections.unmodifiableList(Arrays
.asList(DATA_ENCRYPTION_KEY_ID_FIELD, DESCRIPTION_FIELD, ENCRYPTED_FIELD, KMS_KEY_ID_FIELD, OWNER_ID_FIELD,
PROGRESS_FIELD, SNAPSHOT_ID_FIELD, START_TIME_FIELD, STATE_FIELD, STATE_MESSAGE_FIELD, VOLUME_ID_FIELD,
VOLUME_SIZE_FIELD, OWNER_ALIAS_FIELD, TAGS_FIELD));
private static final long serialVersionUID = 1L;
private final String dataEncryptionKeyId;
private final String description;
private final Boolean encrypted;
private final String kmsKeyId;
private final String ownerId;
private final String progress;
private final String snapshotId;
private final Instant startTime;
private final String state;
private final String stateMessage;
private final String volumeId;
private final Integer volumeSize;
private final String ownerAlias;
private final List tags;
private Snapshot(BuilderImpl builder) {
this.dataEncryptionKeyId = builder.dataEncryptionKeyId;
this.description = builder.description;
this.encrypted = builder.encrypted;
this.kmsKeyId = builder.kmsKeyId;
this.ownerId = builder.ownerId;
this.progress = builder.progress;
this.snapshotId = builder.snapshotId;
this.startTime = builder.startTime;
this.state = builder.state;
this.stateMessage = builder.stateMessage;
this.volumeId = builder.volumeId;
this.volumeSize = builder.volumeSize;
this.ownerAlias = builder.ownerAlias;
this.tags = builder.tags;
}
/**
*
* The data encryption key identifier for the snapshot. This value is a unique identifier that corresponds to the
* data encryption key that was used to encrypt the original volume or snapshot copy. Because data encryption keys
* are inherited by volumes created from snapshots, and vice versa, if snapshots share the same data encryption key
* identifier, then they belong to the same volume/snapshot lineage. This parameter is only returned by
* DescribeSnapshots.
*
*
* @return The data encryption key identifier for the snapshot. This value is a unique identifier that corresponds
* to the data encryption key that was used to encrypt the original volume or snapshot copy. Because data
* encryption keys are inherited by volumes created from snapshots, and vice versa, if snapshots share the
* same data encryption key identifier, then they belong to the same volume/snapshot lineage. This parameter
* is only returned by DescribeSnapshots.
*/
public String dataEncryptionKeyId() {
return dataEncryptionKeyId;
}
/**
*
* The description for the snapshot.
*
*
* @return The description for the snapshot.
*/
public String description() {
return description;
}
/**
*
* Indicates whether the snapshot is encrypted.
*
*
* @return Indicates whether the snapshot 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 parent 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 parent volume.
*/
public String kmsKeyId() {
return kmsKeyId;
}
/**
*
* The AWS account ID of the EBS snapshot owner.
*
*
* @return The AWS account ID of the EBS snapshot owner.
*/
public String ownerId() {
return ownerId;
}
/**
*
* The progress of the snapshot, as a percentage.
*
*
* @return The progress of the snapshot, as a percentage.
*/
public String progress() {
return progress;
}
/**
*
* The ID of the snapshot. Each snapshot receives a unique identifier when it is created.
*
*
* @return The ID of the snapshot. Each snapshot receives a unique identifier when it is created.
*/
public String snapshotId() {
return snapshotId;
}
/**
*
* The time stamp when the snapshot was initiated.
*
*
* @return The time stamp when the snapshot was initiated.
*/
public Instant startTime() {
return startTime;
}
/**
*
* The snapshot state.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link SnapshotState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The snapshot state.
* @see SnapshotState
*/
public SnapshotState state() {
return SnapshotState.fromValue(state);
}
/**
*
* The snapshot state.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link SnapshotState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The snapshot state.
* @see SnapshotState
*/
public String stateAsString() {
return state;
}
/**
*
* Encrypted Amazon EBS snapshots are copied asynchronously. If a snapshot copy operation fails (for example, if the
* proper AWS Key Management Service (AWS KMS) permissions are not obtained) this field displays error state details
* to help you diagnose why the error occurred. This parameter is only returned by DescribeSnapshots.
*
*
* @return Encrypted Amazon EBS snapshots are copied asynchronously. If a snapshot copy operation fails (for
* example, if the proper AWS Key Management Service (AWS KMS) permissions are not obtained) this field
* displays error state details to help you diagnose why the error occurred. This parameter is only returned
* by DescribeSnapshots.
*/
public String stateMessage() {
return stateMessage;
}
/**
*
* The ID of the volume that was used to create the snapshot. Snapshots created by the CopySnapshot action
* have an arbitrary volume ID that should not be used for any purpose.
*
*
* @return The ID of the volume that was used to create the snapshot. Snapshots created by the CopySnapshot
* action have an arbitrary volume ID that should not be used for any purpose.
*/
public String volumeId() {
return volumeId;
}
/**
*
* The size of the volume, in GiB.
*
*
* @return The size of the volume, in GiB.
*/
public Integer volumeSize() {
return volumeSize;
}
/**
*
* The AWS owner alias, as maintained by Amazon. The possible values are: amazon
| self
|
* all
| aws-marketplace
| microsoft
. This AWS owner alias is not to be
* confused with the user-configured AWS account alias, which is set from the IAM console.
*
*
* @return The AWS owner alias, as maintained by Amazon. The possible values are: amazon
|
* self
| all
| aws-marketplace
| microsoft
. This AWS
* owner alias is not to be confused with the user-configured AWS account alias, which is set from the IAM
* console.
*/
public String ownerAlias() {
return ownerAlias;
}
/**
* 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 snapshot.
*
*
* 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 snapshot.
*/
public List tags() {
return tags;
}
@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(dataEncryptionKeyId());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(encrypted());
hashCode = 31 * hashCode + Objects.hashCode(kmsKeyId());
hashCode = 31 * hashCode + Objects.hashCode(ownerId());
hashCode = 31 * hashCode + Objects.hashCode(progress());
hashCode = 31 * hashCode + Objects.hashCode(snapshotId());
hashCode = 31 * hashCode + Objects.hashCode(startTime());
hashCode = 31 * hashCode + Objects.hashCode(stateAsString());
hashCode = 31 * hashCode + Objects.hashCode(stateMessage());
hashCode = 31 * hashCode + Objects.hashCode(volumeId());
hashCode = 31 * hashCode + Objects.hashCode(volumeSize());
hashCode = 31 * hashCode + Objects.hashCode(ownerAlias());
hashCode = 31 * hashCode + Objects.hashCode(tags());
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 Snapshot)) {
return false;
}
Snapshot other = (Snapshot) obj;
return Objects.equals(dataEncryptionKeyId(), other.dataEncryptionKeyId())
&& Objects.equals(description(), other.description()) && Objects.equals(encrypted(), other.encrypted())
&& Objects.equals(kmsKeyId(), other.kmsKeyId()) && Objects.equals(ownerId(), other.ownerId())
&& Objects.equals(progress(), other.progress()) && Objects.equals(snapshotId(), other.snapshotId())
&& Objects.equals(startTime(), other.startTime()) && Objects.equals(stateAsString(), other.stateAsString())
&& Objects.equals(stateMessage(), other.stateMessage()) && Objects.equals(volumeId(), other.volumeId())
&& Objects.equals(volumeSize(), other.volumeSize()) && Objects.equals(ownerAlias(), other.ownerAlias())
&& Objects.equals(tags(), other.tags());
}
/**
* 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("Snapshot").add("DataEncryptionKeyId", dataEncryptionKeyId()).add("Description", description())
.add("Encrypted", encrypted()).add("KmsKeyId", kmsKeyId()).add("OwnerId", ownerId()).add("Progress", progress())
.add("SnapshotId", snapshotId()).add("StartTime", startTime()).add("State", stateAsString())
.add("StateMessage", stateMessage()).add("VolumeId", volumeId()).add("VolumeSize", volumeSize())
.add("OwnerAlias", ownerAlias()).add("Tags", tags()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "DataEncryptionKeyId":
return Optional.ofNullable(clazz.cast(dataEncryptionKeyId()));
case "Description":
return Optional.ofNullable(clazz.cast(description()));
case "Encrypted":
return Optional.ofNullable(clazz.cast(encrypted()));
case "KmsKeyId":
return Optional.ofNullable(clazz.cast(kmsKeyId()));
case "OwnerId":
return Optional.ofNullable(clazz.cast(ownerId()));
case "Progress":
return Optional.ofNullable(clazz.cast(progress()));
case "SnapshotId":
return Optional.ofNullable(clazz.cast(snapshotId()));
case "StartTime":
return Optional.ofNullable(clazz.cast(startTime()));
case "State":
return Optional.ofNullable(clazz.cast(stateAsString()));
case "StateMessage":
return Optional.ofNullable(clazz.cast(stateMessage()));
case "VolumeId":
return Optional.ofNullable(clazz.cast(volumeId()));
case "VolumeSize":
return Optional.ofNullable(clazz.cast(volumeSize()));
case "OwnerAlias":
return Optional.ofNullable(clazz.cast(ownerAlias()));
case "Tags":
return Optional.ofNullable(clazz.cast(tags()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function