software.amazon.awssdk.services.athena.model.StartQueryExecutionRequest Maven / Gradle / Ivy
Show all versions of athena 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.athena.model;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.DefaultValueTrait;
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 StartQueryExecutionRequest extends AthenaRequest implements
ToCopyableBuilder {
private static final SdkField QUERY_STRING_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("QueryString").getter(getter(StartQueryExecutionRequest::queryString))
.setter(setter(Builder::queryString))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("QueryString").build()).build();
private static final SdkField CLIENT_REQUEST_TOKEN_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("ClientRequestToken")
.getter(getter(StartQueryExecutionRequest::clientRequestToken))
.setter(setter(Builder::clientRequestToken))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ClientRequestToken").build(),
DefaultValueTrait.idempotencyToken()).build();
private static final SdkField QUERY_EXECUTION_CONTEXT_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("QueryExecutionContext")
.getter(getter(StartQueryExecutionRequest::queryExecutionContext)).setter(setter(Builder::queryExecutionContext))
.constructor(QueryExecutionContext::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("QueryExecutionContext").build())
.build();
private static final SdkField RESULT_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ResultConfiguration")
.getter(getter(StartQueryExecutionRequest::resultConfiguration)).setter(setter(Builder::resultConfiguration))
.constructor(ResultConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResultConfiguration").build())
.build();
private static final SdkField WORK_GROUP_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("WorkGroup").getter(getter(StartQueryExecutionRequest::workGroup)).setter(setter(Builder::workGroup))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("WorkGroup").build()).build();
private static final SdkField> EXECUTION_PARAMETERS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("ExecutionParameters")
.getter(getter(StartQueryExecutionRequest::executionParameters))
.setter(setter(Builder::executionParameters))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExecutionParameters").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField RESULT_REUSE_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ResultReuseConfiguration")
.getter(getter(StartQueryExecutionRequest::resultReuseConfiguration))
.setter(setter(Builder::resultReuseConfiguration)).constructor(ResultReuseConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResultReuseConfiguration").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(QUERY_STRING_FIELD,
CLIENT_REQUEST_TOKEN_FIELD, QUERY_EXECUTION_CONTEXT_FIELD, RESULT_CONFIGURATION_FIELD, WORK_GROUP_FIELD,
EXECUTION_PARAMETERS_FIELD, RESULT_REUSE_CONFIGURATION_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("QueryString", QUERY_STRING_FIELD);
put("ClientRequestToken", CLIENT_REQUEST_TOKEN_FIELD);
put("QueryExecutionContext", QUERY_EXECUTION_CONTEXT_FIELD);
put("ResultConfiguration", RESULT_CONFIGURATION_FIELD);
put("WorkGroup", WORK_GROUP_FIELD);
put("ExecutionParameters", EXECUTION_PARAMETERS_FIELD);
put("ResultReuseConfiguration", RESULT_REUSE_CONFIGURATION_FIELD);
}
});
private final String queryString;
private final String clientRequestToken;
private final QueryExecutionContext queryExecutionContext;
private final ResultConfiguration resultConfiguration;
private final String workGroup;
private final List executionParameters;
private final ResultReuseConfiguration resultReuseConfiguration;
private StartQueryExecutionRequest(BuilderImpl builder) {
super(builder);
this.queryString = builder.queryString;
this.clientRequestToken = builder.clientRequestToken;
this.queryExecutionContext = builder.queryExecutionContext;
this.resultConfiguration = builder.resultConfiguration;
this.workGroup = builder.workGroup;
this.executionParameters = builder.executionParameters;
this.resultReuseConfiguration = builder.resultReuseConfiguration;
}
/**
*
* The SQL query statements to be executed.
*
*
* @return The SQL query statements to be executed.
*/
public final String queryString() {
return queryString;
}
/**
*
* A unique case-sensitive string used to ensure the request to create the query is idempotent (executes only once).
* If another StartQueryExecution
request is received, the same response is returned and another query
* is not created. An error is returned if a parameter, such as QueryString
, has changed. A call to
* StartQueryExecution
that uses a previous client request token returns the same
* QueryExecutionId
even if the requester doesn't have permission on the tables specified in
* QueryString
.
*
*
*
* This token is listed as not required because Amazon Web Services SDKs (for example the Amazon Web Services SDK
* for Java) auto-generate the token for users. If you are not using the Amazon Web Services SDK or the Amazon Web
* Services CLI, you must provide this token or the action will fail.
*
*
*
* @return A unique case-sensitive string used to ensure the request to create the query is idempotent (executes
* only once). If another StartQueryExecution
request is received, the same response is
* returned and another query is not created. An error is returned if a parameter, such as
* QueryString
, has changed. A call to StartQueryExecution
that uses a previous
* client request token returns the same QueryExecutionId
even if the requester doesn't have
* permission on the tables specified in QueryString
.
*
* This token is listed as not required because Amazon Web Services SDKs (for example the Amazon Web
* Services SDK for Java) auto-generate the token for users. If you are not using the Amazon Web Services
* SDK or the Amazon Web Services CLI, you must provide this token or the action will fail.
*
*/
public final String clientRequestToken() {
return clientRequestToken;
}
/**
*
* The database within which the query executes.
*
*
* @return The database within which the query executes.
*/
public final QueryExecutionContext queryExecutionContext() {
return queryExecutionContext;
}
/**
*
* Specifies information about where and how to save the results of the query execution. If the query runs in a
* workgroup, then workgroup's settings may override query settings. This affects the query results location. The
* workgroup settings override is specified in EnforceWorkGroupConfiguration (true/false) in the
* WorkGroupConfiguration. See WorkGroupConfiguration$EnforceWorkGroupConfiguration.
*
*
* @return Specifies information about where and how to save the results of the query execution. If the query runs
* in a workgroup, then workgroup's settings may override query settings. This affects the query results
* location. The workgroup settings override is specified in EnforceWorkGroupConfiguration (true/false) in
* the WorkGroupConfiguration. See WorkGroupConfiguration$EnforceWorkGroupConfiguration.
*/
public final ResultConfiguration resultConfiguration() {
return resultConfiguration;
}
/**
*
* The name of the workgroup in which the query is being started.
*
*
* @return The name of the workgroup in which the query is being started.
*/
public final String workGroup() {
return workGroup;
}
/**
* For responses, this returns true if the service returned a value for the ExecutionParameters 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 hasExecutionParameters() {
return executionParameters != null && !(executionParameters instanceof SdkAutoConstructList);
}
/**
*
* A list of values for the parameters in a query. The values are applied sequentially to the parameters in the
* query in the order in which the parameters occur.
*
*
* 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 #hasExecutionParameters} method.
*
*
* @return A list of values for the parameters in a query. The values are applied sequentially to the parameters in
* the query in the order in which the parameters occur.
*/
public final List executionParameters() {
return executionParameters;
}
/**
*
* Specifies the query result reuse behavior for the query.
*
*
* @return Specifies the query result reuse behavior for the query.
*/
public final ResultReuseConfiguration resultReuseConfiguration() {
return resultReuseConfiguration;
}
@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(queryString());
hashCode = 31 * hashCode + Objects.hashCode(clientRequestToken());
hashCode = 31 * hashCode + Objects.hashCode(queryExecutionContext());
hashCode = 31 * hashCode + Objects.hashCode(resultConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(workGroup());
hashCode = 31 * hashCode + Objects.hashCode(hasExecutionParameters() ? executionParameters() : null);
hashCode = 31 * hashCode + Objects.hashCode(resultReuseConfiguration());
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 StartQueryExecutionRequest)) {
return false;
}
StartQueryExecutionRequest other = (StartQueryExecutionRequest) obj;
return Objects.equals(queryString(), other.queryString())
&& Objects.equals(clientRequestToken(), other.clientRequestToken())
&& Objects.equals(queryExecutionContext(), other.queryExecutionContext())
&& Objects.equals(resultConfiguration(), other.resultConfiguration())
&& Objects.equals(workGroup(), other.workGroup()) && hasExecutionParameters() == other.hasExecutionParameters()
&& Objects.equals(executionParameters(), other.executionParameters())
&& Objects.equals(resultReuseConfiguration(), other.resultReuseConfiguration());
}
/**
* 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("StartQueryExecutionRequest").add("QueryString", queryString())
.add("ClientRequestToken", clientRequestToken()).add("QueryExecutionContext", queryExecutionContext())
.add("ResultConfiguration", resultConfiguration()).add("WorkGroup", workGroup())
.add("ExecutionParameters", hasExecutionParameters() ? executionParameters() : null)
.add("ResultReuseConfiguration", resultReuseConfiguration()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "QueryString":
return Optional.ofNullable(clazz.cast(queryString()));
case "ClientRequestToken":
return Optional.ofNullable(clazz.cast(clientRequestToken()));
case "QueryExecutionContext":
return Optional.ofNullable(clazz.cast(queryExecutionContext()));
case "ResultConfiguration":
return Optional.ofNullable(clazz.cast(resultConfiguration()));
case "WorkGroup":
return Optional.ofNullable(clazz.cast(workGroup()));
case "ExecutionParameters":
return Optional.ofNullable(clazz.cast(executionParameters()));
case "ResultReuseConfiguration":
return Optional.ofNullable(clazz.cast(resultReuseConfiguration()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Function