
software.amazon.awssdk.services.transfer.model.CreateAgreementRequest 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.transfer.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 CreateAgreementRequest extends TransferRequest implements
ToCopyableBuilder {
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Description").getter(getter(CreateAgreementRequest::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description").build()).build();
private static final SdkField SERVER_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ServerId").getter(getter(CreateAgreementRequest::serverId)).setter(setter(Builder::serverId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ServerId").build()).build();
private static final SdkField LOCAL_PROFILE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("LocalProfileId").getter(getter(CreateAgreementRequest::localProfileId))
.setter(setter(Builder::localProfileId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LocalProfileId").build()).build();
private static final SdkField PARTNER_PROFILE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PartnerProfileId").getter(getter(CreateAgreementRequest::partnerProfileId))
.setter(setter(Builder::partnerProfileId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PartnerProfileId").build()).build();
private static final SdkField BASE_DIRECTORY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("BaseDirectory").getter(getter(CreateAgreementRequest::baseDirectory))
.setter(setter(Builder::baseDirectory))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BaseDirectory").build()).build();
private static final SdkField ACCESS_ROLE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AccessRole").getter(getter(CreateAgreementRequest::accessRole)).setter(setter(Builder::accessRole))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AccessRole").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Status")
.getter(getter(CreateAgreementRequest::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField> TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Tags")
.getter(getter(CreateAgreementRequest::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(DESCRIPTION_FIELD,
SERVER_ID_FIELD, LOCAL_PROFILE_ID_FIELD, PARTNER_PROFILE_ID_FIELD, BASE_DIRECTORY_FIELD, ACCESS_ROLE_FIELD,
STATUS_FIELD, TAGS_FIELD));
private final String description;
private final String serverId;
private final String localProfileId;
private final String partnerProfileId;
private final String baseDirectory;
private final String accessRole;
private final String status;
private final List tags;
private CreateAgreementRequest(BuilderImpl builder) {
super(builder);
this.description = builder.description;
this.serverId = builder.serverId;
this.localProfileId = builder.localProfileId;
this.partnerProfileId = builder.partnerProfileId;
this.baseDirectory = builder.baseDirectory;
this.accessRole = builder.accessRole;
this.status = builder.status;
this.tags = builder.tags;
}
/**
*
* A name or short description to identify the agreement.
*
*
* @return A name or short description to identify the agreement.
*/
public final String description() {
return description;
}
/**
*
* A system-assigned unique identifier for a server instance. This is the specific server that the agreement uses.
*
*
* @return A system-assigned unique identifier for a server instance. This is the specific server that the agreement
* uses.
*/
public final String serverId() {
return serverId;
}
/**
*
* A unique identifier for the AS2 local profile.
*
*
* @return A unique identifier for the AS2 local profile.
*/
public final String localProfileId() {
return localProfileId;
}
/**
*
* A unique identifier for the partner profile used in the agreement.
*
*
* @return A unique identifier for the partner profile used in the agreement.
*/
public final String partnerProfileId() {
return partnerProfileId;
}
/**
*
* The landing directory (folder) for files transferred by using the AS2 protocol.
*
*
* A BaseDirectory
example is /DOC-EXAMPLE-BUCKET/home/mydirectory
.
*
*
* @return The landing directory (folder) for files transferred by using the AS2 protocol.
*
* A BaseDirectory
example is /DOC-EXAMPLE-BUCKET/home/mydirectory
.
*/
public final String baseDirectory() {
return baseDirectory;
}
/**
*
* Connectors are used to send files using either the AS2 or SFTP protocol. For the access role, provide the Amazon
* Resource Name (ARN) of the Identity and Access Management role to use.
*
*
* For AS2 connectors
*
*
* With AS2, you can send files by calling StartFileTransfer
and specifying the file paths in the
* request parameter, SendFilePaths
. We use the file’s parent directory (for example, for
* --send-file-paths /bucket/dir/file.txt
, parent directory is /bucket/dir/
) to
* temporarily store a processed AS2 message file, store the MDN when we receive them from the partner, and write a
* final JSON file containing relevant metadata of the transmission. So, the AccessRole
needs to
* provide read and write access to the parent directory of the file location used in the
* StartFileTransfer
request. Additionally, you need to provide read and write access to the parent
* directory of the files that you intend to send with StartFileTransfer
.
*
*
* If you are using Basic authentication for your AS2 connector, the access role requires the
* secretsmanager:GetSecretValue
permission for the secret. If the secret is encrypted using a
* customer-managed key instead of the Amazon Web Services managed key in Secrets Manager, then the role also needs
* the kms:Decrypt
permission for that key.
*
*
* For SFTP connectors
*
*
* Make sure that the access role provides read and write access to the parent directory of the file location that's
* used in the StartFileTransfer
request. Additionally, make sure that the role provides
* secretsmanager:GetSecretValue
permission to Secrets Manager.
*
*
* @return Connectors are used to send files using either the AS2 or SFTP protocol. For the access role, provide the
* Amazon Resource Name (ARN) of the Identity and Access Management role to use.
*
* For AS2 connectors
*
*
* With AS2, you can send files by calling StartFileTransfer
and specifying the file paths in
* the request parameter, SendFilePaths
. We use the file’s parent directory (for example, for
* --send-file-paths /bucket/dir/file.txt
, parent directory is /bucket/dir/
) to
* temporarily store a processed AS2 message file, store the MDN when we receive them from the partner, and
* write a final JSON file containing relevant metadata of the transmission. So, the AccessRole
* needs to provide read and write access to the parent directory of the file location used in the
* StartFileTransfer
request. Additionally, you need to provide read and write access to the
* parent directory of the files that you intend to send with StartFileTransfer
.
*
*
* If you are using Basic authentication for your AS2 connector, the access role requires the
* secretsmanager:GetSecretValue
permission for the secret. If the secret is encrypted using a
* customer-managed key instead of the Amazon Web Services managed key in Secrets Manager, then the role
* also needs the kms:Decrypt
permission for that key.
*
*
* For SFTP connectors
*
*
* Make sure that the access role provides read and write access to the parent directory of the file
* location that's used in the StartFileTransfer
request. Additionally, make sure that the role
* provides secretsmanager:GetSecretValue
permission to Secrets Manager.
*/
public final String accessRole() {
return accessRole;
}
/**
*
* The status of the agreement. The agreement can be either ACTIVE
or INACTIVE
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link AgreementStatusType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #statusAsString}.
*
*
* @return The status of the agreement. The agreement can be either ACTIVE
or INACTIVE
.
* @see AgreementStatusType
*/
public final AgreementStatusType status() {
return AgreementStatusType.fromValue(status);
}
/**
*
* The status of the agreement. The agreement can be either ACTIVE
or INACTIVE
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link AgreementStatusType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #statusAsString}.
*
*
* @return The status of the agreement. The agreement can be either ACTIVE
or INACTIVE
.
* @see AgreementStatusType
*/
public final String statusAsString() {
return status;
}
/**
* 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);
}
/**
*
* Key-value pairs that can be used to group and search for agreements.
*
*
* 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 Key-value pairs that can be used to group and search for agreements.
*/
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(description());
hashCode = 31 * hashCode + Objects.hashCode(serverId());
hashCode = 31 * hashCode + Objects.hashCode(localProfileId());
hashCode = 31 * hashCode + Objects.hashCode(partnerProfileId());
hashCode = 31 * hashCode + Objects.hashCode(baseDirectory());
hashCode = 31 * hashCode + Objects.hashCode(accessRole());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
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 CreateAgreementRequest)) {
return false;
}
CreateAgreementRequest other = (CreateAgreementRequest) obj;
return Objects.equals(description(), other.description()) && Objects.equals(serverId(), other.serverId())
&& Objects.equals(localProfileId(), other.localProfileId())
&& Objects.equals(partnerProfileId(), other.partnerProfileId())
&& Objects.equals(baseDirectory(), other.baseDirectory()) && Objects.equals(accessRole(), other.accessRole())
&& Objects.equals(statusAsString(), other.statusAsString()) && 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("CreateAgreementRequest").add("Description", description()).add("ServerId", serverId())
.add("LocalProfileId", localProfileId()).add("PartnerProfileId", partnerProfileId())
.add("BaseDirectory", baseDirectory()).add("AccessRole", accessRole()).add("Status", statusAsString())
.add("Tags", hasTags() ? tags() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Description":
return Optional.ofNullable(clazz.cast(description()));
case "ServerId":
return Optional.ofNullable(clazz.cast(serverId()));
case "LocalProfileId":
return Optional.ofNullable(clazz.cast(localProfileId()));
case "PartnerProfileId":
return Optional.ofNullable(clazz.cast(partnerProfileId()));
case "BaseDirectory":
return Optional.ofNullable(clazz.cast(baseDirectory()));
case "AccessRole":
return Optional.ofNullable(clazz.cast(accessRole()));
case "Status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "Tags":
return Optional.ofNullable(clazz.cast(tags()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function