software.amazon.awssdk.services.athena.model.StartQueryExecutionRequest Maven / Gradle / Ivy
/*
* Copyright 2014-2019 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.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.DefaultValueTrait;
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;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class StartQueryExecutionRequest extends AthenaRequest implements
ToCopyableBuilder {
private static final SdkField QUERY_STRING_FIELD = SdkField. builder(MarshallingType.STRING)
.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)
.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)
.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)
.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)
.getter(getter(StartQueryExecutionRequest::workGroup)).setter(setter(Builder::workGroup))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("WorkGroup").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));
private final String queryString;
private final String clientRequestToken;
private final QueryExecutionContext queryExecutionContext;
private final ResultConfiguration resultConfiguration;
private final String workGroup;
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;
}
/**
*
* The SQL query statements to be executed.
*
*
* @return The SQL query statements to be executed.
*/
public 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. If a parameter has changed, for example, the QueryString
, an error is returned.
*
*
*
* This token is listed as not required because AWS SDKs (for example the AWS SDK for Java) auto-generate the token
* for users. If you are not using the AWS SDK or the AWS 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. If a parameter has changed, for example, the
* QueryString
, an error is returned.
*
* This token is listed as not required because AWS SDKs (for example the AWS SDK for Java) auto-generate
* the token for users. If you are not using the AWS SDK or the AWS CLI, you must provide this token or the
* action will fail.
*
*/
public String clientRequestToken() {
return clientRequestToken;
}
/**
*
* The database within which the query executes.
*
*
* @return The database within which the query executes.
*/
public 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 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 String workGroup() {
return workGroup;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public 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());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public 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());
}
/**
* 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 String toString() {
return ToString.builder("StartQueryExecutionRequest").add("QueryString", queryString())
.add("ClientRequestToken", clientRequestToken()).add("QueryExecutionContext", queryExecutionContext())
.add("ResultConfiguration", resultConfiguration()).add("WorkGroup", workGroup()).build();
}
public 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()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function