
software.amazon.awssdk.services.rdsdata.model.BatchExecuteStatementRequest 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.rdsdata.model;
import java.beans.Transient;
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 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;
/**
*
* The request parameters represent the input of a SQL statement over an array of data.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class BatchExecuteStatementRequest extends RdsDataRequest implements
ToCopyableBuilder {
private static final SdkField DATABASE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("database").getter(getter(BatchExecuteStatementRequest::database)).setter(setter(Builder::database))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("database").build()).build();
private static final SdkField>> PARAMETER_SETS_FIELD = SdkField
.>> builder(MarshallingType.LIST)
.memberName("parameterSets")
.getter(getter(BatchExecuteStatementRequest::parameterSets))
.setter(setter(Builder::parameterSets))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("parameterSets").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField.> builder(MarshallingType.LIST)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(SqlParameter::builder)
.traits(LocationTrait.builder()
.location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build())
.build()).build()).build()).build();
private static final SdkField RESOURCE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("resourceArn").getter(getter(BatchExecuteStatementRequest::resourceArn))
.setter(setter(Builder::resourceArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("resourceArn").build()).build();
private static final SdkField SCHEMA_FIELD = SdkField. builder(MarshallingType.STRING).memberName("schema")
.getter(getter(BatchExecuteStatementRequest::schema)).setter(setter(Builder::schema))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("schema").build()).build();
private static final SdkField SECRET_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("secretArn").getter(getter(BatchExecuteStatementRequest::secretArn)).setter(setter(Builder::secretArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("secretArn").build()).build();
private static final SdkField SQL_FIELD = SdkField. builder(MarshallingType.STRING).memberName("sql")
.getter(getter(BatchExecuteStatementRequest::sql)).setter(setter(Builder::sql))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("sql").build()).build();
private static final SdkField TRANSACTION_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("transactionId").getter(getter(BatchExecuteStatementRequest::transactionId))
.setter(setter(Builder::transactionId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("transactionId").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(DATABASE_FIELD,
PARAMETER_SETS_FIELD, RESOURCE_ARN_FIELD, SCHEMA_FIELD, SECRET_ARN_FIELD, SQL_FIELD, TRANSACTION_ID_FIELD));
private final String database;
private final List> parameterSets;
private final String resourceArn;
private final String schema;
private final String secretArn;
private final String sql;
private final String transactionId;
private BatchExecuteStatementRequest(BuilderImpl builder) {
super(builder);
this.database = builder.database;
this.parameterSets = builder.parameterSets;
this.resourceArn = builder.resourceArn;
this.schema = builder.schema;
this.secretArn = builder.secretArn;
this.sql = builder.sql;
this.transactionId = builder.transactionId;
}
/**
*
* The name of the database.
*
*
* @return The name of the database.
*/
public final String database() {
return database;
}
/**
* For responses, this returns true if the service returned a value for the ParameterSets 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 hasParameterSets() {
return parameterSets != null && !(parameterSets instanceof SdkAutoConstructList);
}
/**
*
* The parameter set for the batch operation.
*
*
* The SQL statement is executed as many times as the number of parameter sets provided. To execute a SQL statement
* with no parameters, use one of the following options:
*
*
* -
*
* Specify one or more empty parameter sets.
*
*
* -
*
* Use the ExecuteStatement
operation instead of the BatchExecuteStatement
operation.
*
*
*
*
*
* Array parameters are not supported.
*
*
*
* 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 #hasParameterSets} method.
*
*
* @return The parameter set for the batch operation.
*
* The SQL statement is executed as many times as the number of parameter sets provided. To execute a SQL
* statement with no parameters, use one of the following options:
*
*
* -
*
* Specify one or more empty parameter sets.
*
*
* -
*
* Use the ExecuteStatement
operation instead of the BatchExecuteStatement
* operation.
*
*
*
*
*
* Array parameters are not supported.
*
*/
public final List> parameterSets() {
return parameterSets;
}
/**
*
* The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.
*
*
* @return The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.
*/
public final String resourceArn() {
return resourceArn;
}
/**
*
* The name of the database schema.
*
*
* @return The name of the database schema.
*/
public final String schema() {
return schema;
}
/**
*
* The name or ARN of the secret that enables access to the DB cluster.
*
*
* @return The name or ARN of the secret that enables access to the DB cluster.
*/
public final String secretArn() {
return secretArn;
}
/**
*
* The SQL statement to run.
*
*
* @return The SQL statement to run.
*/
public final String sql() {
return sql;
}
/**
*
* The identifier of a transaction that was started by using the BeginTransaction
operation. Specify
* the transaction ID of the transaction that you want to include the SQL statement in.
*
*
* If the SQL statement is not part of a transaction, don't set this parameter.
*
*
* @return The identifier of a transaction that was started by using the BeginTransaction
operation.
* Specify the transaction ID of the transaction that you want to include the SQL statement in.
*
* If the SQL statement is not part of a transaction, don't set this parameter.
*/
public final String transactionId() {
return transactionId;
}
@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(database());
hashCode = 31 * hashCode + Objects.hashCode(hasParameterSets() ? parameterSets() : null);
hashCode = 31 * hashCode + Objects.hashCode(resourceArn());
hashCode = 31 * hashCode + Objects.hashCode(schema());
hashCode = 31 * hashCode + Objects.hashCode(secretArn());
hashCode = 31 * hashCode + Objects.hashCode(sql());
hashCode = 31 * hashCode + Objects.hashCode(transactionId());
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 BatchExecuteStatementRequest)) {
return false;
}
BatchExecuteStatementRequest other = (BatchExecuteStatementRequest) obj;
return Objects.equals(database(), other.database()) && hasParameterSets() == other.hasParameterSets()
&& Objects.equals(parameterSets(), other.parameterSets()) && Objects.equals(resourceArn(), other.resourceArn())
&& Objects.equals(schema(), other.schema()) && Objects.equals(secretArn(), other.secretArn())
&& Objects.equals(sql(), other.sql()) && Objects.equals(transactionId(), other.transactionId());
}
/**
* 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("BatchExecuteStatementRequest").add("Database", database())
.add("ParameterSets", hasParameterSets() ? parameterSets() : null).add("ResourceArn", resourceArn())
.add("Schema", schema()).add("SecretArn", secretArn()).add("Sql", sql()).add("TransactionId", transactionId())
.build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "database":
return Optional.ofNullable(clazz.cast(database()));
case "parameterSets":
return Optional.ofNullable(clazz.cast(parameterSets()));
case "resourceArn":
return Optional.ofNullable(clazz.cast(resourceArn()));
case "schema":
return Optional.ofNullable(clazz.cast(schema()));
case "secretArn":
return Optional.ofNullable(clazz.cast(secretArn()));
case "sql":
return Optional.ofNullable(clazz.cast(sql()));
case "transactionId":
return Optional.ofNullable(clazz.cast(transactionId()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function
*
* The SQL statement is executed as many times as the number of parameter sets provided. To execute a SQL
* statement with no parameters, use one of the following options:
*
*
* -
*
* Specify one or more empty parameter sets.
*
*
* -
*
* Use the ExecuteStatement
operation instead of the BatchExecuteStatement
* operation.
*
*
*
*
*
* Array parameters are not supported.
*
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder parameterSets(Collection extends Collection> parameterSets);
/**
*
* The parameter set for the batch operation.
*
*
* The SQL statement is executed as many times as the number of parameter sets provided. To execute a SQL
* statement with no parameters, use one of the following options:
*
*
* -
*
* Specify one or more empty parameter sets.
*
*
* -
*
* Use the ExecuteStatement
operation instead of the BatchExecuteStatement
operation.
*
*
*
*
*
* Array parameters are not supported.
*
*
*
* @param parameterSets
* The parameter set for the batch operation.
*
* The SQL statement is executed as many times as the number of parameter sets provided. To execute a SQL
* statement with no parameters, use one of the following options:
*
*
* -
*
* Specify one or more empty parameter sets.
*
*
* -
*
* Use the ExecuteStatement
operation instead of the BatchExecuteStatement
* operation.
*
*
*
*
*
* Array parameters are not supported.
*
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder parameterSets(Collection... parameterSets);
/**
*
* The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.
*
*
* @param resourceArn
* The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder resourceArn(String resourceArn);
/**
*
* The name of the database schema.
*
*
* @param schema
* The name of the database schema.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder schema(String schema);
/**
*
* The name or ARN of the secret that enables access to the DB cluster.
*
*
* @param secretArn
* The name or ARN of the secret that enables access to the DB cluster.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder secretArn(String secretArn);
/**
*
* The SQL statement to run.
*
*
* @param sql
* The SQL statement to run.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder sql(String sql);
/**
*
* The identifier of a transaction that was started by using the BeginTransaction
operation.
* Specify the transaction ID of the transaction that you want to include the SQL statement in.
*
*
* If the SQL statement is not part of a transaction, don't set this parameter.
*
*
* @param transactionId
* The identifier of a transaction that was started by using the BeginTransaction
operation.
* Specify the transaction ID of the transaction that you want to include the SQL statement in.
*
* If the SQL statement is not part of a transaction, don't set this parameter.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder transactionId(String transactionId);
@Override
Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration);
@Override
Builder overrideConfiguration(Consumer builderConsumer);
}
static final class BuilderImpl extends RdsDataRequest.BuilderImpl implements Builder {
private String database;
private List> parameterSets = DefaultSdkAutoConstructList.getInstance();
private String resourceArn;
private String schema;
private String secretArn;
private String sql;
private String transactionId;
private BuilderImpl() {
}
private BuilderImpl(BatchExecuteStatementRequest model) {
super(model);
database(model.database);
parameterSets(model.parameterSets);
resourceArn(model.resourceArn);
schema(model.schema);
secretArn(model.secretArn);
sql(model.sql);
transactionId(model.transactionId);
}
public final String getDatabase() {
return database;
}
public final void setDatabase(String database) {
this.database = database;
}
@Override
@Transient
public final Builder database(String database) {
this.database = database;
return this;
}
public final List> getParameterSets() {
List> result = SqlParameterSetsCopier.copyToBuilder(this.parameterSets);
if (result instanceof SdkAutoConstructList) {
return null;
}
return result;
}
public final void setParameterSets(Collection extends Collection> parameterSets) {
this.parameterSets = SqlParameterSetsCopier.copyFromBuilder(parameterSets);
}
@Override
@Transient
public final Builder parameterSets(Collection extends Collection> parameterSets) {
this.parameterSets = SqlParameterSetsCopier.copy(parameterSets);
return this;
}
@Override
@Transient
@SafeVarargs
public final Builder parameterSets(Collection... parameterSets) {
parameterSets(Arrays.asList(parameterSets));
return this;
}
public final String getResourceArn() {
return resourceArn;
}
public final void setResourceArn(String resourceArn) {
this.resourceArn = resourceArn;
}
@Override
@Transient
public final Builder resourceArn(String resourceArn) {
this.resourceArn = resourceArn;
return this;
}
public final String getSchema() {
return schema;
}
public final void setSchema(String schema) {
this.schema = schema;
}
@Override
@Transient
public final Builder schema(String schema) {
this.schema = schema;
return this;
}
public final String getSecretArn() {
return secretArn;
}
public final void setSecretArn(String secretArn) {
this.secretArn = secretArn;
}
@Override
@Transient
public final Builder secretArn(String secretArn) {
this.secretArn = secretArn;
return this;
}
public final String getSql() {
return sql;
}
public final void setSql(String sql) {
this.sql = sql;
}
@Override
@Transient
public final Builder sql(String sql) {
this.sql = sql;
return this;
}
public final String getTransactionId() {
return transactionId;
}
public final void setTransactionId(String transactionId) {
this.transactionId = transactionId;
}
@Override
@Transient
public final Builder transactionId(String transactionId) {
this.transactionId = transactionId;
return this;
}
@Override
public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) {
super.overrideConfiguration(overrideConfiguration);
return this;
}
@Override
public Builder overrideConfiguration(Consumer builderConsumer) {
super.overrideConfiguration(builderConsumer);
return this;
}
@Override
public BatchExecuteStatementRequest build() {
return new BatchExecuteStatementRequest(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}