
software.amazon.awssdk.services.ec2.model.ExportImageResponse 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.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;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class ExportImageResponse extends Ec2Response implements
ToCopyableBuilder {
private static final SdkField DESCRIPTION_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Description")
.getter(getter(ExportImageResponse::description))
.setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description")
.unmarshallLocationName("description").build()).build();
private static final SdkField DISK_IMAGE_FORMAT_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("DiskImageFormat")
.getter(getter(ExportImageResponse::diskImageFormatAsString))
.setter(setter(Builder::diskImageFormat))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DiskImageFormat")
.unmarshallLocationName("diskImageFormat").build()).build();
private static final SdkField EXPORT_IMAGE_TASK_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("ExportImageTaskId")
.getter(getter(ExportImageResponse::exportImageTaskId))
.setter(setter(Builder::exportImageTaskId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExportImageTaskId")
.unmarshallLocationName("exportImageTaskId").build()).build();
private static final SdkField IMAGE_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("ImageId")
.getter(getter(ExportImageResponse::imageId))
.setter(setter(Builder::imageId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ImageId")
.unmarshallLocationName("imageId").build()).build();
private static final SdkField ROLE_NAME_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("RoleName")
.getter(getter(ExportImageResponse::roleName))
.setter(setter(Builder::roleName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RoleName")
.unmarshallLocationName("roleName").build()).build();
private static final SdkField PROGRESS_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Progress")
.getter(getter(ExportImageResponse::progress))
.setter(setter(Builder::progress))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Progress")
.unmarshallLocationName("progress").build()).build();
private static final SdkField S3_EXPORT_LOCATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("S3ExportLocation")
.getter(getter(ExportImageResponse::s3ExportLocation))
.setter(setter(Builder::s3ExportLocation))
.constructor(ExportTaskS3Location::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("S3ExportLocation")
.unmarshallLocationName("s3ExportLocation").build()).build();
private static final SdkField STATUS_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Status")
.getter(getter(ExportImageResponse::status))
.setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status")
.unmarshallLocationName("status").build()).build();
private static final SdkField STATUS_MESSAGE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("StatusMessage")
.getter(getter(ExportImageResponse::statusMessage))
.setter(setter(Builder::statusMessage))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StatusMessage")
.unmarshallLocationName("statusMessage").build()).build();
private static final SdkField> TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Tags")
.getter(getter(ExportImageResponse::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(DESCRIPTION_FIELD,
DISK_IMAGE_FORMAT_FIELD, EXPORT_IMAGE_TASK_ID_FIELD, IMAGE_ID_FIELD, ROLE_NAME_FIELD, PROGRESS_FIELD,
S3_EXPORT_LOCATION_FIELD, STATUS_FIELD, STATUS_MESSAGE_FIELD, TAGS_FIELD));
private final String description;
private final String diskImageFormat;
private final String exportImageTaskId;
private final String imageId;
private final String roleName;
private final String progress;
private final ExportTaskS3Location s3ExportLocation;
private final String status;
private final String statusMessage;
private final List tags;
private ExportImageResponse(BuilderImpl builder) {
super(builder);
this.description = builder.description;
this.diskImageFormat = builder.diskImageFormat;
this.exportImageTaskId = builder.exportImageTaskId;
this.imageId = builder.imageId;
this.roleName = builder.roleName;
this.progress = builder.progress;
this.s3ExportLocation = builder.s3ExportLocation;
this.status = builder.status;
this.statusMessage = builder.statusMessage;
this.tags = builder.tags;
}
/**
*
* A description of the image being exported.
*
*
* @return A description of the image being exported.
*/
public String description() {
return description;
}
/**
*
* The disk image format for the exported image.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #diskImageFormat}
* will return {@link DiskImageFormat#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #diskImageFormatAsString}.
*
*
* @return The disk image format for the exported image.
* @see DiskImageFormat
*/
public DiskImageFormat diskImageFormat() {
return DiskImageFormat.fromValue(diskImageFormat);
}
/**
*
* The disk image format for the exported image.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #diskImageFormat}
* will return {@link DiskImageFormat#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #diskImageFormatAsString}.
*
*
* @return The disk image format for the exported image.
* @see DiskImageFormat
*/
public String diskImageFormatAsString() {
return diskImageFormat;
}
/**
*
* The ID of the export image task.
*
*
* @return The ID of the export image task.
*/
public String exportImageTaskId() {
return exportImageTaskId;
}
/**
*
* The ID of the image.
*
*
* @return The ID of the image.
*/
public String imageId() {
return imageId;
}
/**
*
* The name of the role that grants VM Import/Export permission to export images to your Amazon S3 bucket.
*
*
* @return The name of the role that grants VM Import/Export permission to export images to your Amazon S3 bucket.
*/
public String roleName() {
return roleName;
}
/**
*
* The percent complete of the export image task.
*
*
* @return The percent complete of the export image task.
*/
public String progress() {
return progress;
}
/**
*
* Information about the destination Amazon S3 bucket.
*
*
* @return Information about the destination Amazon S3 bucket.
*/
public ExportTaskS3Location s3ExportLocation() {
return s3ExportLocation;
}
/**
*
* The status of the export image task. The possible values are active
, completed
,
* deleting
, and deleted
.
*
*
* @return The status of the export image task. The possible values are active
, completed
,
* deleting
, and deleted
.
*/
public String status() {
return status;
}
/**
*
* The status message for the export image task.
*
*
* @return The status message for the export image task.
*/
public String statusMessage() {
return statusMessage;
}
/**
* 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 image being exported.
*
*
* 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 image being exported.
*/
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 + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(diskImageFormatAsString());
hashCode = 31 * hashCode + Objects.hashCode(exportImageTaskId());
hashCode = 31 * hashCode + Objects.hashCode(imageId());
hashCode = 31 * hashCode + Objects.hashCode(roleName());
hashCode = 31 * hashCode + Objects.hashCode(progress());
hashCode = 31 * hashCode + Objects.hashCode(s3ExportLocation());
hashCode = 31 * hashCode + Objects.hashCode(status());
hashCode = 31 * hashCode + Objects.hashCode(statusMessage());
hashCode = 31 * hashCode + Objects.hashCode(tags());
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 ExportImageResponse)) {
return false;
}
ExportImageResponse other = (ExportImageResponse) obj;
return Objects.equals(description(), other.description())
&& Objects.equals(diskImageFormatAsString(), other.diskImageFormatAsString())
&& Objects.equals(exportImageTaskId(), other.exportImageTaskId()) && Objects.equals(imageId(), other.imageId())
&& Objects.equals(roleName(), other.roleName()) && Objects.equals(progress(), other.progress())
&& Objects.equals(s3ExportLocation(), other.s3ExportLocation()) && Objects.equals(status(), other.status())
&& Objects.equals(statusMessage(), other.statusMessage()) && 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("ExportImageResponse").add("Description", description())
.add("DiskImageFormat", diskImageFormatAsString()).add("ExportImageTaskId", exportImageTaskId())
.add("ImageId", imageId()).add("RoleName", roleName()).add("Progress", progress())
.add("S3ExportLocation", s3ExportLocation()).add("Status", status()).add("StatusMessage", statusMessage())
.add("Tags", tags()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Description":
return Optional.ofNullable(clazz.cast(description()));
case "DiskImageFormat":
return Optional.ofNullable(clazz.cast(diskImageFormatAsString()));
case "ExportImageTaskId":
return Optional.ofNullable(clazz.cast(exportImageTaskId()));
case "ImageId":
return Optional.ofNullable(clazz.cast(imageId()));
case "RoleName":
return Optional.ofNullable(clazz.cast(roleName()));
case "Progress":
return Optional.ofNullable(clazz.cast(progress()));
case "S3ExportLocation":
return Optional.ofNullable(clazz.cast(s3ExportLocation()));
case "Status":
return Optional.ofNullable(clazz.cast(status()));
case "StatusMessage":
return Optional.ofNullable(clazz.cast(statusMessage()));
case "Tags":
return Optional.ofNullable(clazz.cast(tags()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function