
software.amazon.awssdk.services.ec2.model.ExportTask 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.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 an instance export task.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ExportTask implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField DESCRIPTION_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Description")
.getter(getter(ExportTask::description))
.setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description")
.unmarshallLocationName("description").build()).build();
private static final SdkField EXPORT_TASK_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("ExportTaskId")
.getter(getter(ExportTask::exportTaskId))
.setter(setter(Builder::exportTaskId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExportTaskId")
.unmarshallLocationName("exportTaskId").build()).build();
private static final SdkField EXPORT_TO_S3_TASK_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("ExportToS3Task")
.getter(getter(ExportTask::exportToS3Task))
.setter(setter(Builder::exportToS3Task))
.constructor(ExportToS3Task::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExportToS3")
.unmarshallLocationName("exportToS3").build()).build();
private static final SdkField INSTANCE_EXPORT_DETAILS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("InstanceExportDetails")
.getter(getter(ExportTask::instanceExportDetails))
.setter(setter(Builder::instanceExportDetails))
.constructor(InstanceExportDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceExport")
.unmarshallLocationName("instanceExport").build()).build();
private static final SdkField STATE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("State")
.getter(getter(ExportTask::stateAsString))
.setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("State")
.unmarshallLocationName("state").build()).build();
private static final SdkField STATUS_MESSAGE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("StatusMessage")
.getter(getter(ExportTask::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(ExportTask::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,
EXPORT_TASK_ID_FIELD, EXPORT_TO_S3_TASK_FIELD, INSTANCE_EXPORT_DETAILS_FIELD, STATE_FIELD, STATUS_MESSAGE_FIELD,
TAGS_FIELD));
private static final long serialVersionUID = 1L;
private final String description;
private final String exportTaskId;
private final ExportToS3Task exportToS3Task;
private final InstanceExportDetails instanceExportDetails;
private final String state;
private final String statusMessage;
private final List tags;
private ExportTask(BuilderImpl builder) {
this.description = builder.description;
this.exportTaskId = builder.exportTaskId;
this.exportToS3Task = builder.exportToS3Task;
this.instanceExportDetails = builder.instanceExportDetails;
this.state = builder.state;
this.statusMessage = builder.statusMessage;
this.tags = builder.tags;
}
/**
*
* A description of the resource being exported.
*
*
* @return A description of the resource being exported.
*/
public String description() {
return description;
}
/**
*
* The ID of the export task.
*
*
* @return The ID of the export task.
*/
public String exportTaskId() {
return exportTaskId;
}
/**
*
* Information about the export task.
*
*
* @return Information about the export task.
*/
public ExportToS3Task exportToS3Task() {
return exportToS3Task;
}
/**
*
* Information about the instance to export.
*
*
* @return Information about the instance to export.
*/
public InstanceExportDetails instanceExportDetails() {
return instanceExportDetails;
}
/**
*
* The state of the export task.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link ExportTaskState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of the export task.
* @see ExportTaskState
*/
public ExportTaskState state() {
return ExportTaskState.fromValue(state);
}
/**
*
* The state of the export task.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link ExportTaskState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of the export task.
* @see ExportTaskState
*/
public String stateAsString() {
return state;
}
/**
*
* The status message related to the export task.
*
*
* @return The status message related to the export 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);
}
/**
*
* The tags for the export task.
*
*
* 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 The tags for the export task.
*/
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(description());
hashCode = 31 * hashCode + Objects.hashCode(exportTaskId());
hashCode = 31 * hashCode + Objects.hashCode(exportToS3Task());
hashCode = 31 * hashCode + Objects.hashCode(instanceExportDetails());
hashCode = 31 * hashCode + Objects.hashCode(stateAsString());
hashCode = 31 * hashCode + Objects.hashCode(statusMessage());
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 ExportTask)) {
return false;
}
ExportTask other = (ExportTask) obj;
return Objects.equals(description(), other.description()) && Objects.equals(exportTaskId(), other.exportTaskId())
&& Objects.equals(exportToS3Task(), other.exportToS3Task())
&& Objects.equals(instanceExportDetails(), other.instanceExportDetails())
&& Objects.equals(stateAsString(), other.stateAsString())
&& 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("ExportTask").add("Description", description()).add("ExportTaskId", exportTaskId())
.add("ExportToS3Task", exportToS3Task()).add("InstanceExportDetails", instanceExportDetails())
.add("State", stateAsString()).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 "ExportTaskId":
return Optional.ofNullable(clazz.cast(exportTaskId()));
case "ExportToS3Task":
return Optional.ofNullable(clazz.cast(exportToS3Task()));
case "InstanceExportDetails":
return Optional.ofNullable(clazz.cast(instanceExportDetails()));
case "State":
return Optional.ofNullable(clazz.cast(stateAsString()));
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