software.amazon.awssdk.services.lexmodelbuilding.model.StartImportRequest Maven / Gradle / Ivy
Show all versions of lexmodelbuilding Show documentation
/*
* 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.lexmodelbuilding.model;
import java.nio.ByteBuffer;
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.SdkBytes;
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 StartImportRequest extends LexModelBuildingRequest implements
ToCopyableBuilder {
private static final SdkField PAYLOAD_FIELD = SdkField. builder(MarshallingType.SDK_BYTES)
.memberName("payload").getter(getter(StartImportRequest::payload)).setter(setter(Builder::payload))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("payload").build()).build();
private static final SdkField RESOURCE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("resourceType").getter(getter(StartImportRequest::resourceTypeAsString))
.setter(setter(Builder::resourceType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("resourceType").build()).build();
private static final SdkField MERGE_STRATEGY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("mergeStrategy").getter(getter(StartImportRequest::mergeStrategyAsString))
.setter(setter(Builder::mergeStrategy))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("mergeStrategy").build()).build();
private static final SdkField> TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("tags")
.getter(getter(StartImportRequest::tags))
.setter(setter(Builder::tags))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("tags").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Tag::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(PAYLOAD_FIELD,
RESOURCE_TYPE_FIELD, MERGE_STRATEGY_FIELD, TAGS_FIELD));
private final SdkBytes payload;
private final String resourceType;
private final String mergeStrategy;
private final List tags;
private StartImportRequest(BuilderImpl builder) {
super(builder);
this.payload = builder.payload;
this.resourceType = builder.resourceType;
this.mergeStrategy = builder.mergeStrategy;
this.tags = builder.tags;
}
/**
*
* A zip archive in binary format. The archive should contain one file, a JSON file containing the resource to
* import. The resource should match the type specified in the resourceType
field.
*
*
* @return A zip archive in binary format. The archive should contain one file, a JSON file containing the resource
* to import. The resource should match the type specified in the resourceType
field.
*/
public final SdkBytes payload() {
return payload;
}
/**
*
* Specifies the type of resource to export. Each resource also exports any resources that it depends on.
*
*
* -
*
* A bot exports dependent intents.
*
*
* -
*
* An intent exports dependent slot types.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #resourceType} will
* return {@link ResourceType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #resourceTypeAsString}.
*
*
* @return Specifies the type of resource to export. Each resource also exports any resources that it depends on.
*
*
* -
*
* A bot exports dependent intents.
*
*
* -
*
* An intent exports dependent slot types.
*
*
* @see ResourceType
*/
public final ResourceType resourceType() {
return ResourceType.fromValue(resourceType);
}
/**
*
* Specifies the type of resource to export. Each resource also exports any resources that it depends on.
*
*
* -
*
* A bot exports dependent intents.
*
*
* -
*
* An intent exports dependent slot types.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #resourceType} will
* return {@link ResourceType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #resourceTypeAsString}.
*
*
* @return Specifies the type of resource to export. Each resource also exports any resources that it depends on.
*
*
* -
*
* A bot exports dependent intents.
*
*
* -
*
* An intent exports dependent slot types.
*
*
* @see ResourceType
*/
public final String resourceTypeAsString() {
return resourceType;
}
/**
*
* Specifies the action that the StartImport
operation should take when there is an existing resource
* with the same name.
*
*
* -
*
* FAIL_ON_CONFLICT - The import operation is stopped on the first conflict between a resource in the import file
* and an existing resource. The name of the resource causing the conflict is in the failureReason
* field of the response to the GetImport
operation.
*
*
* OVERWRITE_LATEST - The import operation proceeds even if there is a conflict with an existing resource. The
* $LASTEST version of the existing resource is overwritten with the data from the import file.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #mergeStrategy}
* will return {@link MergeStrategy#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #mergeStrategyAsString}.
*
*
* @return Specifies the action that the StartImport
operation should take when there is an existing
* resource with the same name.
*
* -
*
* FAIL_ON_CONFLICT - The import operation is stopped on the first conflict between a resource in the import
* file and an existing resource. The name of the resource causing the conflict is in the
* failureReason
field of the response to the GetImport
operation.
*
*
* OVERWRITE_LATEST - The import operation proceeds even if there is a conflict with an existing resource.
* The $LASTEST version of the existing resource is overwritten with the data from the import file.
*
*
* @see MergeStrategy
*/
public final MergeStrategy mergeStrategy() {
return MergeStrategy.fromValue(mergeStrategy);
}
/**
*
* Specifies the action that the StartImport
operation should take when there is an existing resource
* with the same name.
*
*
* -
*
* FAIL_ON_CONFLICT - The import operation is stopped on the first conflict between a resource in the import file
* and an existing resource. The name of the resource causing the conflict is in the failureReason
* field of the response to the GetImport
operation.
*
*
* OVERWRITE_LATEST - The import operation proceeds even if there is a conflict with an existing resource. The
* $LASTEST version of the existing resource is overwritten with the data from the import file.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #mergeStrategy}
* will return {@link MergeStrategy#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #mergeStrategyAsString}.
*
*
* @return Specifies the action that the StartImport
operation should take when there is an existing
* resource with the same name.
*
* -
*
* FAIL_ON_CONFLICT - The import operation is stopped on the first conflict between a resource in the import
* file and an existing resource. The name of the resource causing the conflict is in the
* failureReason
field of the response to the GetImport
operation.
*
*
* OVERWRITE_LATEST - The import operation proceeds even if there is a conflict with an existing resource.
* The $LASTEST version of the existing resource is overwritten with the data from the import file.
*
*
* @see MergeStrategy
*/
public final String mergeStrategyAsString() {
return mergeStrategy;
}
/**
* For responses, this returns true if the service returned a value for the Tags property. This DOES NOT check that
* the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). This is useful
* because the SDK will never return a null collection or map, but you may need to differentiate between the service
* returning nothing (or null) and the service returning an empty collection or map. For requests, this returns true
* if a value for the property was specified in the request builder, and false if a value was not specified.
*/
public final boolean hasTags() {
return tags != null && !(tags instanceof SdkAutoConstructList);
}
/**
*
* A list of tags to add to the imported bot. You can only add tags when you import a bot, you can't add tags to an
* intent or slot type.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasTags} method.
*
*
* @return A list of tags to add to the imported bot. You can only add tags when you import a bot, you can't add
* tags to an intent or slot type.
*/
public final 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 final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(payload());
hashCode = 31 * hashCode + Objects.hashCode(resourceTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(mergeStrategyAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null);
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 StartImportRequest)) {
return false;
}
StartImportRequest other = (StartImportRequest) obj;
return Objects.equals(payload(), other.payload()) && Objects.equals(resourceTypeAsString(), other.resourceTypeAsString())
&& Objects.equals(mergeStrategyAsString(), other.mergeStrategyAsString()) && hasTags() == other.hasTags()
&& 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 final String toString() {
return ToString.builder("StartImportRequest").add("Payload", payload()).add("ResourceType", resourceTypeAsString())
.add("MergeStrategy", mergeStrategyAsString()).add("Tags", hasTags() ? tags() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "payload":
return Optional.ofNullable(clazz.cast(payload()));
case "resourceType":
return Optional.ofNullable(clazz.cast(resourceTypeAsString()));
case "mergeStrategy":
return Optional.ofNullable(clazz.cast(mergeStrategyAsString()));
case "tags":
return Optional.ofNullable(clazz.cast(tags()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function