
software.amazon.awssdk.services.rdsdata.model.ExecuteSqlRequest 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.util.Arrays;
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.LocationTrait;
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 request to run one or more SQL statements.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ExecuteSqlRequest extends RdsDataRequest implements
ToCopyableBuilder {
private static final SdkField DB_CLUSTER_OR_INSTANCE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("dbClusterOrInstanceArn").getter(getter(ExecuteSqlRequest::dbClusterOrInstanceArn))
.setter(setter(Builder::dbClusterOrInstanceArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("dbClusterOrInstanceArn").build())
.build();
private static final SdkField AWS_SECRET_STORE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("awsSecretStoreArn").getter(getter(ExecuteSqlRequest::awsSecretStoreArn))
.setter(setter(Builder::awsSecretStoreArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("awsSecretStoreArn").build()).build();
private static final SdkField SQL_STATEMENTS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("sqlStatements").getter(getter(ExecuteSqlRequest::sqlStatements)).setter(setter(Builder::sqlStatements))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("sqlStatements").build()).build();
private static final SdkField DATABASE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("database").getter(getter(ExecuteSqlRequest::database)).setter(setter(Builder::database))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("database").build()).build();
private static final SdkField SCHEMA_FIELD = SdkField. builder(MarshallingType.STRING).memberName("schema")
.getter(getter(ExecuteSqlRequest::schema)).setter(setter(Builder::schema))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("schema").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(
DB_CLUSTER_OR_INSTANCE_ARN_FIELD, AWS_SECRET_STORE_ARN_FIELD, SQL_STATEMENTS_FIELD, DATABASE_FIELD, SCHEMA_FIELD));
private final String dbClusterOrInstanceArn;
private final String awsSecretStoreArn;
private final String sqlStatements;
private final String database;
private final String schema;
private ExecuteSqlRequest(BuilderImpl builder) {
super(builder);
this.dbClusterOrInstanceArn = builder.dbClusterOrInstanceArn;
this.awsSecretStoreArn = builder.awsSecretStoreArn;
this.sqlStatements = builder.sqlStatements;
this.database = builder.database;
this.schema = builder.schema;
}
/**
*
* The ARN of the Aurora Serverless DB cluster.
*
*
* @return The ARN of the Aurora Serverless DB cluster.
*/
public final String dbClusterOrInstanceArn() {
return dbClusterOrInstanceArn;
}
/**
*
* The Amazon Resource Name (ARN) of the secret that enables access to the DB cluster. Enter the database user name
* and password for the credentials in the secret.
*
*
* For information about creating the secret, see Create a database
* secret.
*
*
* @return The Amazon Resource Name (ARN) of the secret that enables access to the DB cluster. Enter the database
* user name and password for the credentials in the secret.
*
* For information about creating the secret, see Create a
* database secret.
*/
public final String awsSecretStoreArn() {
return awsSecretStoreArn;
}
/**
*
* One or more SQL statements to run on the DB cluster.
*
*
* You can separate SQL statements from each other with a semicolon (;). Any valid SQL statement is permitted,
* including data definition, data manipulation, and commit statements.
*
*
* @return One or more SQL statements to run on the DB cluster.
*
* You can separate SQL statements from each other with a semicolon (;). Any valid SQL statement is
* permitted, including data definition, data manipulation, and commit statements.
*/
public final String sqlStatements() {
return sqlStatements;
}
/**
*
* The name of the database.
*
*
* @return The name of the database.
*/
public final String database() {
return database;
}
/**
*
* The name of the database schema.
*
*
* @return The name of the database schema.
*/
public final String schema() {
return schema;
}
@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(dbClusterOrInstanceArn());
hashCode = 31 * hashCode + Objects.hashCode(awsSecretStoreArn());
hashCode = 31 * hashCode + Objects.hashCode(sqlStatements());
hashCode = 31 * hashCode + Objects.hashCode(database());
hashCode = 31 * hashCode + Objects.hashCode(schema());
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 ExecuteSqlRequest)) {
return false;
}
ExecuteSqlRequest other = (ExecuteSqlRequest) obj;
return Objects.equals(dbClusterOrInstanceArn(), other.dbClusterOrInstanceArn())
&& Objects.equals(awsSecretStoreArn(), other.awsSecretStoreArn())
&& Objects.equals(sqlStatements(), other.sqlStatements()) && Objects.equals(database(), other.database())
&& Objects.equals(schema(), other.schema());
}
/**
* 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("ExecuteSqlRequest").add("DbClusterOrInstanceArn", dbClusterOrInstanceArn())
.add("AwsSecretStoreArn", awsSecretStoreArn()).add("SqlStatements", sqlStatements()).add("Database", database())
.add("Schema", schema()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "dbClusterOrInstanceArn":
return Optional.ofNullable(clazz.cast(dbClusterOrInstanceArn()));
case "awsSecretStoreArn":
return Optional.ofNullable(clazz.cast(awsSecretStoreArn()));
case "sqlStatements":
return Optional.ofNullable(clazz.cast(sqlStatements()));
case "database":
return Optional.ofNullable(clazz.cast(database()));
case "schema":
return Optional.ofNullable(clazz.cast(schema()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function