All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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 getter(Function g) { return obj -> g.apply((StartQueryExecutionRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends AthenaRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The SQL query statements to be executed. *

* * @param queryString * The SQL query statements to be executed. * @return Returns a reference to this object so that method calls can be chained together. */ Builder queryString(String 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. *

*
* * @param clientRequestToken * 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 Returns a reference to this object so that method calls can be chained together. */ Builder clientRequestToken(String clientRequestToken); /** *

* The database within which the query executes. *

* * @param queryExecutionContext * The database within which the query executes. * @return Returns a reference to this object so that method calls can be chained together. */ Builder queryExecutionContext(QueryExecutionContext queryExecutionContext); /** *

* The database within which the query executes. *

* This is a convenience that creates an instance of the {@link QueryExecutionContext.Builder} avoiding the need * to create one manually via {@link QueryExecutionContext#builder()}. * * When the {@link Consumer} completes, {@link QueryExecutionContext.Builder#build()} is called immediately and * its result is passed to {@link #queryExecutionContext(QueryExecutionContext)}. * * @param queryExecutionContext * a consumer that will call methods on {@link QueryExecutionContext.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #queryExecutionContext(QueryExecutionContext) */ default Builder queryExecutionContext(Consumer queryExecutionContext) { return queryExecutionContext(QueryExecutionContext.builder().applyMutation(queryExecutionContext).build()); } /** *

* 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. *

* * @param resultConfiguration * 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 Returns a reference to this object so that method calls can be chained together. */ Builder resultConfiguration(ResultConfiguration resultConfiguration); /** *

* 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. *

* This is a convenience that creates an instance of the {@link ResultConfiguration.Builder} avoiding the need * to create one manually via {@link ResultConfiguration#builder()}. * * When the {@link Consumer} completes, {@link ResultConfiguration.Builder#build()} is called immediately and * its result is passed to {@link #resultConfiguration(ResultConfiguration)}. * * @param resultConfiguration * a consumer that will call methods on {@link ResultConfiguration.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #resultConfiguration(ResultConfiguration) */ default Builder resultConfiguration(Consumer resultConfiguration) { return resultConfiguration(ResultConfiguration.builder().applyMutation(resultConfiguration).build()); } /** *

* The name of the workgroup in which the query is being started. *

* * @param workGroup * The name of the workgroup in which the query is being started. * @return Returns a reference to this object so that method calls can be chained together. */ Builder workGroup(String workGroup); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends AthenaRequest.BuilderImpl implements Builder { private String queryString; private String clientRequestToken; private QueryExecutionContext queryExecutionContext; private ResultConfiguration resultConfiguration; private String workGroup; private BuilderImpl() { } private BuilderImpl(StartQueryExecutionRequest model) { super(model); queryString(model.queryString); clientRequestToken(model.clientRequestToken); queryExecutionContext(model.queryExecutionContext); resultConfiguration(model.resultConfiguration); workGroup(model.workGroup); } public final String getQueryString() { return queryString; } @Override public final Builder queryString(String queryString) { this.queryString = queryString; return this; } public final void setQueryString(String queryString) { this.queryString = queryString; } public final String getClientRequestToken() { return clientRequestToken; } @Override public final Builder clientRequestToken(String clientRequestToken) { this.clientRequestToken = clientRequestToken; return this; } public final void setClientRequestToken(String clientRequestToken) { this.clientRequestToken = clientRequestToken; } public final QueryExecutionContext.Builder getQueryExecutionContext() { return queryExecutionContext != null ? queryExecutionContext.toBuilder() : null; } @Override public final Builder queryExecutionContext(QueryExecutionContext queryExecutionContext) { this.queryExecutionContext = queryExecutionContext; return this; } public final void setQueryExecutionContext(QueryExecutionContext.BuilderImpl queryExecutionContext) { this.queryExecutionContext = queryExecutionContext != null ? queryExecutionContext.build() : null; } public final ResultConfiguration.Builder getResultConfiguration() { return resultConfiguration != null ? resultConfiguration.toBuilder() : null; } @Override public final Builder resultConfiguration(ResultConfiguration resultConfiguration) { this.resultConfiguration = resultConfiguration; return this; } public final void setResultConfiguration(ResultConfiguration.BuilderImpl resultConfiguration) { this.resultConfiguration = resultConfiguration != null ? resultConfiguration.build() : null; } public final String getWorkGroup() { return workGroup; } @Override public final Builder workGroup(String workGroup) { this.workGroup = workGroup; return this; } public final void setWorkGroup(String workGroup) { this.workGroup = workGroup; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public StartQueryExecutionRequest build() { return new StartQueryExecutionRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy