software.amazon.awssdk.services.redshiftdata.model.StatementData 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.redshiftdata.model;
import java.io.Serializable;
import java.time.Instant;
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 java.util.stream.Collectors;
import java.util.stream.Stream;
import software.amazon.awssdk.annotations.Generated;
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 SQL statement to run.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class StatementData implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField CREATED_AT_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("CreatedAt").getter(getter(StatementData::createdAt)).setter(setter(Builder::createdAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreatedAt").build()).build();
private static final SdkField ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Id")
.getter(getter(StatementData::id)).setter(setter(Builder::id))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Id").build()).build();
private static final SdkField IS_BATCH_STATEMENT_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("IsBatchStatement").getter(getter(StatementData::isBatchStatement))
.setter(setter(Builder::isBatchStatement))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("IsBatchStatement").build()).build();
private static final SdkField> QUERY_PARAMETERS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("QueryParameters")
.getter(getter(StatementData::queryParameters))
.setter(setter(Builder::queryParameters))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("QueryParameters").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();
private static final SdkField QUERY_STRING_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("QueryString").getter(getter(StatementData::queryString)).setter(setter(Builder::queryString))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("QueryString").build()).build();
private static final SdkField> QUERY_STRINGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("QueryStrings")
.getter(getter(StatementData::queryStrings))
.setter(setter(Builder::queryStrings))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("QueryStrings").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_FORMAT_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ResultFormat").getter(getter(StatementData::resultFormatAsString)).setter(setter(Builder::resultFormat))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResultFormat").build()).build();
private static final SdkField SECRET_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SecretArn").getter(getter(StatementData::secretArn)).setter(setter(Builder::secretArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SecretArn").build()).build();
private static final SdkField SESSION_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SessionId").getter(getter(StatementData::sessionId)).setter(setter(Builder::sessionId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SessionId").build()).build();
private static final SdkField STATEMENT_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("StatementName").getter(getter(StatementData::statementName)).setter(setter(Builder::statementName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StatementName").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Status")
.getter(getter(StatementData::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField UPDATED_AT_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("UpdatedAt").getter(getter(StatementData::updatedAt)).setter(setter(Builder::updatedAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UpdatedAt").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CREATED_AT_FIELD, ID_FIELD,
IS_BATCH_STATEMENT_FIELD, QUERY_PARAMETERS_FIELD, QUERY_STRING_FIELD, QUERY_STRINGS_FIELD, RESULT_FORMAT_FIELD,
SECRET_ARN_FIELD, SESSION_ID_FIELD, STATEMENT_NAME_FIELD, STATUS_FIELD, UPDATED_AT_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("CreatedAt", CREATED_AT_FIELD);
put("Id", ID_FIELD);
put("IsBatchStatement", IS_BATCH_STATEMENT_FIELD);
put("QueryParameters", QUERY_PARAMETERS_FIELD);
put("QueryString", QUERY_STRING_FIELD);
put("QueryStrings", QUERY_STRINGS_FIELD);
put("ResultFormat", RESULT_FORMAT_FIELD);
put("SecretArn", SECRET_ARN_FIELD);
put("SessionId", SESSION_ID_FIELD);
put("StatementName", STATEMENT_NAME_FIELD);
put("Status", STATUS_FIELD);
put("UpdatedAt", UPDATED_AT_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final Instant createdAt;
private final String id;
private final Boolean isBatchStatement;
private final List queryParameters;
private final String queryString;
private final List queryStrings;
private final String resultFormat;
private final String secretArn;
private final String sessionId;
private final String statementName;
private final String status;
private final Instant updatedAt;
private StatementData(BuilderImpl builder) {
this.createdAt = builder.createdAt;
this.id = builder.id;
this.isBatchStatement = builder.isBatchStatement;
this.queryParameters = builder.queryParameters;
this.queryString = builder.queryString;
this.queryStrings = builder.queryStrings;
this.resultFormat = builder.resultFormat;
this.secretArn = builder.secretArn;
this.sessionId = builder.sessionId;
this.statementName = builder.statementName;
this.status = builder.status;
this.updatedAt = builder.updatedAt;
}
/**
*
* The date and time (UTC) the statement was created.
*
*
* @return The date and time (UTC) the statement was created.
*/
public final Instant createdAt() {
return createdAt;
}
/**
*
* The SQL statement identifier. This value is a universally unique identifier (UUID) generated by Amazon Redshift
* Data API.
*
*
* @return The SQL statement identifier. This value is a universally unique identifier (UUID) generated by Amazon
* Redshift Data API.
*/
public final String id() {
return id;
}
/**
*
* A value that indicates whether the statement is a batch query request.
*
*
* @return A value that indicates whether the statement is a batch query request.
*/
public final Boolean isBatchStatement() {
return isBatchStatement;
}
/**
* For responses, this returns true if the service returned a value for the QueryParameters 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 hasQueryParameters() {
return queryParameters != null && !(queryParameters instanceof SdkAutoConstructList);
}
/**
*
* The parameters used in a SQL statement.
*
*
* 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 #hasQueryParameters} method.
*
*
* @return The parameters used in a SQL statement.
*/
public final List queryParameters() {
return queryParameters;
}
/**
*
* The SQL statement.
*
*
* @return The SQL statement.
*/
public final String queryString() {
return queryString;
}
/**
* For responses, this returns true if the service returned a value for the QueryStrings 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 hasQueryStrings() {
return queryStrings != null && !(queryStrings instanceof SdkAutoConstructList);
}
/**
*
* One or more SQL statements. Each query string in the array corresponds to one of the queries in a batch query
* request.
*
*
* 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 #hasQueryStrings} method.
*
*
* @return One or more SQL statements. Each query string in the array corresponds to one of the queries in a batch
* query request.
*/
public final List queryStrings() {
return queryStrings;
}
/**
*
* The data format of the result of the SQL statement.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #resultFormat} will
* return {@link ResultFormatString#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #resultFormatAsString}.
*
*
* @return The data format of the result of the SQL statement.
* @see ResultFormatString
*/
public final ResultFormatString resultFormat() {
return ResultFormatString.fromValue(resultFormat);
}
/**
*
* The data format of the result of the SQL statement.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #resultFormat} will
* return {@link ResultFormatString#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #resultFormatAsString}.
*
*
* @return The data format of the result of the SQL statement.
* @see ResultFormatString
*/
public final String resultFormatAsString() {
return resultFormat;
}
/**
*
* The name or Amazon Resource Name (ARN) of the secret that enables access to the database.
*
*
* @return The name or Amazon Resource Name (ARN) of the secret that enables access to the database.
*/
public final String secretArn() {
return secretArn;
}
/**
*
* The session identifier of the query.
*
*
* @return The session identifier of the query.
*/
public final String sessionId() {
return sessionId;
}
/**
*
* The name of the SQL statement.
*
*
* @return The name of the SQL statement.
*/
public final String statementName() {
return statementName;
}
/**
*
* The status of the SQL statement. An example is the that the SQL statement finished.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link StatusString#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the SQL statement. An example is the that the SQL statement finished.
* @see StatusString
*/
public final StatusString status() {
return StatusString.fromValue(status);
}
/**
*
* The status of the SQL statement. An example is the that the SQL statement finished.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link StatusString#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the SQL statement. An example is the that the SQL statement finished.
* @see StatusString
*/
public final String statusAsString() {
return status;
}
/**
*
* The date and time (UTC) that the statement metadata was last updated.
*
*
* @return The date and time (UTC) that the statement metadata was last updated.
*/
public final Instant updatedAt() {
return updatedAt;
}
@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 + Objects.hashCode(createdAt());
hashCode = 31 * hashCode + Objects.hashCode(id());
hashCode = 31 * hashCode + Objects.hashCode(isBatchStatement());
hashCode = 31 * hashCode + Objects.hashCode(hasQueryParameters() ? queryParameters() : null);
hashCode = 31 * hashCode + Objects.hashCode(queryString());
hashCode = 31 * hashCode + Objects.hashCode(hasQueryStrings() ? queryStrings() : null);
hashCode = 31 * hashCode + Objects.hashCode(resultFormatAsString());
hashCode = 31 * hashCode + Objects.hashCode(secretArn());
hashCode = 31 * hashCode + Objects.hashCode(sessionId());
hashCode = 31 * hashCode + Objects.hashCode(statementName());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(updatedAt());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof StatementData)) {
return false;
}
StatementData other = (StatementData) obj;
return Objects.equals(createdAt(), other.createdAt()) && Objects.equals(id(), other.id())
&& Objects.equals(isBatchStatement(), other.isBatchStatement())
&& hasQueryParameters() == other.hasQueryParameters()
&& Objects.equals(queryParameters(), other.queryParameters())
&& Objects.equals(queryString(), other.queryString()) && hasQueryStrings() == other.hasQueryStrings()
&& Objects.equals(queryStrings(), other.queryStrings())
&& Objects.equals(resultFormatAsString(), other.resultFormatAsString())
&& Objects.equals(secretArn(), other.secretArn()) && Objects.equals(sessionId(), other.sessionId())
&& Objects.equals(statementName(), other.statementName())
&& Objects.equals(statusAsString(), other.statusAsString()) && Objects.equals(updatedAt(), other.updatedAt());
}
/**
* 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("StatementData").add("CreatedAt", createdAt()).add("Id", id())
.add("IsBatchStatement", isBatchStatement())
.add("QueryParameters", hasQueryParameters() ? queryParameters() : null).add("QueryString", queryString())
.add("QueryStrings", hasQueryStrings() ? queryStrings() : null).add("ResultFormat", resultFormatAsString())
.add("SecretArn", secretArn()).add("SessionId", sessionId()).add("StatementName", statementName())
.add("Status", statusAsString()).add("UpdatedAt", updatedAt()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "CreatedAt":
return Optional.ofNullable(clazz.cast(createdAt()));
case "Id":
return Optional.ofNullable(clazz.cast(id()));
case "IsBatchStatement":
return Optional.ofNullable(clazz.cast(isBatchStatement()));
case "QueryParameters":
return Optional.ofNullable(clazz.cast(queryParameters()));
case "QueryString":
return Optional.ofNullable(clazz.cast(queryString()));
case "QueryStrings":
return Optional.ofNullable(clazz.cast(queryStrings()));
case "ResultFormat":
return Optional.ofNullable(clazz.cast(resultFormatAsString()));
case "SecretArn":
return Optional.ofNullable(clazz.cast(secretArn()));
case "SessionId":
return Optional.ofNullable(clazz.cast(sessionId()));
case "StatementName":
return Optional.ofNullable(clazz.cast(statementName()));
case "Status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "UpdatedAt":
return Optional.ofNullable(clazz.cast(updatedAt()));
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