software.amazon.awssdk.services.migrationhub.model.PutResourceAttributesRequest 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.migrationhub.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.awscore.AwsRequestOverrideConfiguration;
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 PutResourceAttributesRequest extends MigrationHubRequest implements
ToCopyableBuilder {
private static final SdkField PROGRESS_UPDATE_STREAM_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ProgressUpdateStream").getter(getter(PutResourceAttributesRequest::progressUpdateStream))
.setter(setter(Builder::progressUpdateStream))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ProgressUpdateStream").build())
.build();
private static final SdkField MIGRATION_TASK_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("MigrationTaskName").getter(getter(PutResourceAttributesRequest::migrationTaskName))
.setter(setter(Builder::migrationTaskName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MigrationTaskName").build()).build();
private static final SdkField> RESOURCE_ATTRIBUTE_LIST_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("ResourceAttributeList")
.getter(getter(PutResourceAttributesRequest::resourceAttributeList))
.setter(setter(Builder::resourceAttributeList))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourceAttributeList").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ResourceAttribute::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField DRY_RUN_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("DryRun").getter(getter(PutResourceAttributesRequest::dryRun)).setter(setter(Builder::dryRun))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DryRun").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(PROGRESS_UPDATE_STREAM_FIELD,
MIGRATION_TASK_NAME_FIELD, RESOURCE_ATTRIBUTE_LIST_FIELD, DRY_RUN_FIELD));
private final String progressUpdateStream;
private final String migrationTaskName;
private final List resourceAttributeList;
private final Boolean dryRun;
private PutResourceAttributesRequest(BuilderImpl builder) {
super(builder);
this.progressUpdateStream = builder.progressUpdateStream;
this.migrationTaskName = builder.migrationTaskName;
this.resourceAttributeList = builder.resourceAttributeList;
this.dryRun = builder.dryRun;
}
/**
*
* The name of the ProgressUpdateStream.
*
*
* @return The name of the ProgressUpdateStream.
*/
public final String progressUpdateStream() {
return progressUpdateStream;
}
/**
*
* Unique identifier that references the migration task. Do not store personal data in this field.
*
*
* @return Unique identifier that references the migration task. Do not store personal data in this field.
*/
public final String migrationTaskName() {
return migrationTaskName;
}
/**
* Returns true if the ResourceAttributeList 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 final boolean hasResourceAttributeList() {
return resourceAttributeList != null && !(resourceAttributeList instanceof SdkAutoConstructList);
}
/**
*
* Information about the resource that is being migrated. This data will be used to map the task to a resource in
* the Application Discovery Service repository.
*
*
*
* Takes the object array of ResourceAttribute
where the Type
field is reserved for the
* following values:
* IPV4_ADDRESS | IPV6_ADDRESS | MAC_ADDRESS | FQDN | VM_MANAGER_ID | VM_MANAGED_OBJECT_REFERENCE | VM_NAME | VM_PATH | BIOS_ID | MOTHERBOARD_SERIAL_NUMBER
* where the identifying value can be a string up to 256 characters.
*
*
*
* -
*
* If any "VM" related value is set for a ResourceAttribute
object, it is required that
* VM_MANAGER_ID
, as a minimum, is always set. If VM_MANAGER_ID
is not set, then all "VM"
* fields will be discarded and "VM" fields will not be used for matching the migration task to a server in
* Application Discovery Service repository. See the Example section below for a use case of specifying "VM" related values.
*
*
* -
*
* If a server you are trying to match has multiple IP or MAC addresses, you should provide as many as you know in
* separate type/value pairs passed to the ResourceAttributeList
parameter to maximize the chances of
* matching.
*
*
*
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasResourceAttributeList()} to see if a value was sent in this field.
*
*
* @return Information about the resource that is being migrated. This data will be used to map the task to a
* resource in the Application Discovery Service repository.
*
* Takes the object array of ResourceAttribute
where the Type
field is reserved
* for the following values:
* IPV4_ADDRESS | IPV6_ADDRESS | MAC_ADDRESS | FQDN | VM_MANAGER_ID | VM_MANAGED_OBJECT_REFERENCE | VM_NAME | VM_PATH | BIOS_ID | MOTHERBOARD_SERIAL_NUMBER
* where the identifying value can be a string up to 256 characters.
*
*
*
* -
*
* If any "VM" related value is set for a ResourceAttribute
object, it is required that
* VM_MANAGER_ID
, as a minimum, is always set. If VM_MANAGER_ID
is not set, then
* all "VM" fields will be discarded and "VM" fields will not be used for matching the migration task to a
* server in Application Discovery Service repository. See the Example section below for a use case of specifying "VM" related values.
*
*
* -
*
* If a server you are trying to match has multiple IP or MAC addresses, you should provide as many as you
* know in separate type/value pairs passed to the ResourceAttributeList
parameter to maximize
* the chances of matching.
*
*
*
*/
public final List resourceAttributeList() {
return resourceAttributeList;
}
/**
*
* Optional boolean flag to indicate whether any effect should take place. Used to test if the caller has permission
* to make the call.
*
*
* @return Optional boolean flag to indicate whether any effect should take place. Used to test if the caller has
* permission to make the call.
*/
public final Boolean dryRun() {
return dryRun;
}
@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 final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(progressUpdateStream());
hashCode = 31 * hashCode + Objects.hashCode(migrationTaskName());
hashCode = 31 * hashCode + Objects.hashCode(hasResourceAttributeList() ? resourceAttributeList() : null);
hashCode = 31 * hashCode + Objects.hashCode(dryRun());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof PutResourceAttributesRequest)) {
return false;
}
PutResourceAttributesRequest other = (PutResourceAttributesRequest) obj;
return Objects.equals(progressUpdateStream(), other.progressUpdateStream())
&& Objects.equals(migrationTaskName(), other.migrationTaskName())
&& hasResourceAttributeList() == other.hasResourceAttributeList()
&& Objects.equals(resourceAttributeList(), other.resourceAttributeList())
&& Objects.equals(dryRun(), other.dryRun());
}
/**
* 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 final String toString() {
return ToString.builder("PutResourceAttributesRequest").add("ProgressUpdateStream", progressUpdateStream())
.add("MigrationTaskName", migrationTaskName())
.add("ResourceAttributeList", hasResourceAttributeList() ? resourceAttributeList() : null)
.add("DryRun", dryRun()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ProgressUpdateStream":
return Optional.ofNullable(clazz.cast(progressUpdateStream()));
case "MigrationTaskName":
return Optional.ofNullable(clazz.cast(migrationTaskName()));
case "ResourceAttributeList":
return Optional.ofNullable(clazz.cast(resourceAttributeList()));
case "DryRun":
return Optional.ofNullable(clazz.cast(dryRun()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function