software.amazon.awssdk.services.redshiftdata.model.DescribeStatementResponse 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.beans.Transient;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
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 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;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class DescribeStatementResponse extends RedshiftDataResponse implements
ToCopyableBuilder {
private static final SdkField CLUSTER_IDENTIFIER_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ClusterIdentifier").getter(getter(DescribeStatementResponse::clusterIdentifier))
.setter(setter(Builder::clusterIdentifier))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ClusterIdentifier").build()).build();
private static final SdkField CREATED_AT_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("CreatedAt").getter(getter(DescribeStatementResponse::createdAt)).setter(setter(Builder::createdAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreatedAt").build()).build();
private static final SdkField DATABASE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Database").getter(getter(DescribeStatementResponse::database)).setter(setter(Builder::database))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Database").build()).build();
private static final SdkField DB_USER_FIELD = SdkField. builder(MarshallingType.STRING).memberName("DbUser")
.getter(getter(DescribeStatementResponse::dbUser)).setter(setter(Builder::dbUser))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DbUser").build()).build();
private static final SdkField DURATION_FIELD = SdkField. builder(MarshallingType.LONG).memberName("Duration")
.getter(getter(DescribeStatementResponse::duration)).setter(setter(Builder::duration))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Duration").build()).build();
private static final SdkField ERROR_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Error")
.getter(getter(DescribeStatementResponse::error)).setter(setter(Builder::error))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Error").build()).build();
private static final SdkField HAS_RESULT_SET_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("HasResultSet").getter(getter(DescribeStatementResponse::hasResultSet))
.setter(setter(Builder::hasResultSet))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HasResultSet").build()).build();
private static final SdkField ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Id")
.getter(getter(DescribeStatementResponse::id)).setter(setter(Builder::id))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Id").build()).build();
private static final SdkField> QUERY_PARAMETERS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("QueryParameters")
.getter(getter(DescribeStatementResponse::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(DescribeStatementResponse::queryString))
.setter(setter(Builder::queryString))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("QueryString").build()).build();
private static final SdkField REDSHIFT_PID_FIELD = SdkField. builder(MarshallingType.LONG)
.memberName("RedshiftPid").getter(getter(DescribeStatementResponse::redshiftPid))
.setter(setter(Builder::redshiftPid))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RedshiftPid").build()).build();
private static final SdkField REDSHIFT_QUERY_ID_FIELD = SdkField. builder(MarshallingType.LONG)
.memberName("RedshiftQueryId").getter(getter(DescribeStatementResponse::redshiftQueryId))
.setter(setter(Builder::redshiftQueryId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RedshiftQueryId").build()).build();
private static final SdkField RESULT_ROWS_FIELD = SdkField. builder(MarshallingType.LONG)
.memberName("ResultRows").getter(getter(DescribeStatementResponse::resultRows)).setter(setter(Builder::resultRows))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResultRows").build()).build();
private static final SdkField RESULT_SIZE_FIELD = SdkField. builder(MarshallingType.LONG)
.memberName("ResultSize").getter(getter(DescribeStatementResponse::resultSize)).setter(setter(Builder::resultSize))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResultSize").build()).build();
private static final SdkField SECRET_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SecretArn").getter(getter(DescribeStatementResponse::secretArn)).setter(setter(Builder::secretArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SecretArn").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Status")
.getter(getter(DescribeStatementResponse::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField> SUB_STATEMENTS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("SubStatements")
.getter(getter(DescribeStatementResponse::subStatements))
.setter(setter(Builder::subStatements))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SubStatements").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(SubStatementData::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField UPDATED_AT_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("UpdatedAt").getter(getter(DescribeStatementResponse::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(CLUSTER_IDENTIFIER_FIELD,
CREATED_AT_FIELD, DATABASE_FIELD, DB_USER_FIELD, DURATION_FIELD, ERROR_FIELD, HAS_RESULT_SET_FIELD, ID_FIELD,
QUERY_PARAMETERS_FIELD, QUERY_STRING_FIELD, REDSHIFT_PID_FIELD, REDSHIFT_QUERY_ID_FIELD, RESULT_ROWS_FIELD,
RESULT_SIZE_FIELD, SECRET_ARN_FIELD, STATUS_FIELD, SUB_STATEMENTS_FIELD, UPDATED_AT_FIELD));
private final String clusterIdentifier;
private final Instant createdAt;
private final String database;
private final String dbUser;
private final Long duration;
private final String error;
private final Boolean hasResultSet;
private final String id;
private final List queryParameters;
private final String queryString;
private final Long redshiftPid;
private final Long redshiftQueryId;
private final Long resultRows;
private final Long resultSize;
private final String secretArn;
private final String status;
private final List subStatements;
private final Instant updatedAt;
private DescribeStatementResponse(BuilderImpl builder) {
super(builder);
this.clusterIdentifier = builder.clusterIdentifier;
this.createdAt = builder.createdAt;
this.database = builder.database;
this.dbUser = builder.dbUser;
this.duration = builder.duration;
this.error = builder.error;
this.hasResultSet = builder.hasResultSet;
this.id = builder.id;
this.queryParameters = builder.queryParameters;
this.queryString = builder.queryString;
this.redshiftPid = builder.redshiftPid;
this.redshiftQueryId = builder.redshiftQueryId;
this.resultRows = builder.resultRows;
this.resultSize = builder.resultSize;
this.secretArn = builder.secretArn;
this.status = builder.status;
this.subStatements = builder.subStatements;
this.updatedAt = builder.updatedAt;
}
/**
*
* The cluster identifier.
*
*
* @return The cluster identifier.
*/
public final String clusterIdentifier() {
return clusterIdentifier;
}
/**
*
* The date and time (UTC) when the SQL statement was submitted to run.
*
*
* @return The date and time (UTC) when the SQL statement was submitted to run.
*/
public final Instant createdAt() {
return createdAt;
}
/**
*
* The name of the database.
*
*
* @return The name of the database.
*/
public final String database() {
return database;
}
/**
*
* The database user name.
*
*
* @return The database user name.
*/
public final String dbUser() {
return dbUser;
}
/**
*
* The amount of time in nanoseconds that the statement ran.
*
*
* @return The amount of time in nanoseconds that the statement ran.
*/
public final Long duration() {
return duration;
}
/**
*
* The error message from the cluster if the SQL statement encountered an error while running.
*
*
* @return The error message from the cluster if the SQL statement encountered an error while running.
*/
public final String error() {
return error;
}
/**
*
* A value that indicates whether the statement has a result set. The result set can be empty. The value is true for
* an empty result set. The value is true if any substatement returns a result set.
*
*
* @return A value that indicates whether the statement has a result set. The result set can be empty. The value is
* true for an empty result set. The value is true if any substatement returns a result set.
*/
public final Boolean hasResultSet() {
return hasResultSet;
}
/**
*
* The identifier of the SQL statement described. This value is a universally unique identifier (UUID) generated by
* Amazon Redshift Data API.
*
*
* @return The identifier of the SQL statement described. This value is a universally unique identifier (UUID)
* generated by Amazon Redshift Data API.
*/
public final String id() {
return id;
}
/**
* 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 for the 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 for the SQL statement.
*/
public final List queryParameters() {
return queryParameters;
}
/**
*
* The SQL statement text.
*
*
* @return The SQL statement text.
*/
public final String queryString() {
return queryString;
}
/**
*
* The process identifier from Amazon Redshift.
*
*
* @return The process identifier from Amazon Redshift.
*/
public final Long redshiftPid() {
return redshiftPid;
}
/**
*
* The identifier of the query generated by Amazon Redshift. These identifiers are also available in the
* query
column of the STL_QUERY
system view.
*
*
* @return The identifier of the query generated by Amazon Redshift. These identifiers are also available in the
* query
column of the STL_QUERY
system view.
*/
public final Long redshiftQueryId() {
return redshiftQueryId;
}
/**
*
* Either the number of rows returned from the SQL statement or the number of rows affected. If result size is
* greater than zero, the result rows can be the number of rows affected by SQL statements such as INSERT, UPDATE,
* DELETE, COPY, and others. A -1
indicates the value is null.
*
*
* @return Either the number of rows returned from the SQL statement or the number of rows affected. If result size
* is greater than zero, the result rows can be the number of rows affected by SQL statements such as
* INSERT, UPDATE, DELETE, COPY, and others. A -1
indicates the value is null.
*/
public final Long resultRows() {
return resultRows;
}
/**
*
* The size in bytes of the returned results. A -1
indicates the value is null.
*
*
* @return The size in bytes of the returned results. A -1
indicates the value is null.
*/
public final Long resultSize() {
return resultSize;
}
/**
*
* 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 status of the SQL statement being described. Status values are defined as follows:
*
*
* -
*
* ABORTED - The query run was stopped by the user.
*
*
* -
*
* ALL - A status value that includes all query statuses. This value can be used to filter results.
*
*
* -
*
* FAILED - The query run failed.
*
*
* -
*
* FINISHED - The query has finished running.
*
*
* -
*
* PICKED - The query has been chosen to be run.
*
*
* -
*
* STARTED - The query run has started.
*
*
* -
*
* SUBMITTED - The query was submitted, but not yet processed.
*
*
*
*
* 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 being described. Status values are defined as follows:
*
* -
*
* ABORTED - The query run was stopped by the user.
*
*
* -
*
* ALL - A status value that includes all query statuses. This value can be used to filter results.
*
*
* -
*
* FAILED - The query run failed.
*
*
* -
*
* FINISHED - The query has finished running.
*
*
* -
*
* PICKED - The query has been chosen to be run.
*
*
* -
*
* STARTED - The query run has started.
*
*
* -
*
* SUBMITTED - The query was submitted, but not yet processed.
*
*
* @see StatusString
*/
public final StatusString status() {
return StatusString.fromValue(status);
}
/**
*
* The status of the SQL statement being described. Status values are defined as follows:
*
*
* -
*
* ABORTED - The query run was stopped by the user.
*
*
* -
*
* ALL - A status value that includes all query statuses. This value can be used to filter results.
*
*
* -
*
* FAILED - The query run failed.
*
*
* -
*
* FINISHED - The query has finished running.
*
*
* -
*
* PICKED - The query has been chosen to be run.
*
*
* -
*
* STARTED - The query run has started.
*
*
* -
*
* SUBMITTED - The query was submitted, but not yet processed.
*
*
*
*
* 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 being described. Status values are defined as follows:
*
* -
*
* ABORTED - The query run was stopped by the user.
*
*
* -
*
* ALL - A status value that includes all query statuses. This value can be used to filter results.
*
*
* -
*
* FAILED - The query run failed.
*
*
* -
*
* FINISHED - The query has finished running.
*
*
* -
*
* PICKED - The query has been chosen to be run.
*
*
* -
*
* STARTED - The query run has started.
*
*
* -
*
* SUBMITTED - The query was submitted, but not yet processed.
*
*
* @see StatusString
*/
public final String statusAsString() {
return status;
}
/**
* For responses, this returns true if the service returned a value for the SubStatements 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 hasSubStatements() {
return subStatements != null && !(subStatements instanceof SdkAutoConstructList);
}
/**
*
* The SQL statements from a multiple statement run.
*
*
* 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 #hasSubStatements} method.
*
*
* @return The SQL statements from a multiple statement run.
*/
public final List subStatements() {
return subStatements;
}
/**
*
* The date and time (UTC) that the metadata for the SQL statement was last updated. An example is the time the
* status last changed.
*
*
* @return The date and time (UTC) that the metadata for the SQL statement was last updated. An example is the time
* the status last changed.
*/
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 + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(clusterIdentifier());
hashCode = 31 * hashCode + Objects.hashCode(createdAt());
hashCode = 31 * hashCode + Objects.hashCode(database());
hashCode = 31 * hashCode + Objects.hashCode(dbUser());
hashCode = 31 * hashCode + Objects.hashCode(duration());
hashCode = 31 * hashCode + Objects.hashCode(error());
hashCode = 31 * hashCode + Objects.hashCode(hasResultSet());
hashCode = 31 * hashCode + Objects.hashCode(id());
hashCode = 31 * hashCode + Objects.hashCode(hasQueryParameters() ? queryParameters() : null);
hashCode = 31 * hashCode + Objects.hashCode(queryString());
hashCode = 31 * hashCode + Objects.hashCode(redshiftPid());
hashCode = 31 * hashCode + Objects.hashCode(redshiftQueryId());
hashCode = 31 * hashCode + Objects.hashCode(resultRows());
hashCode = 31 * hashCode + Objects.hashCode(resultSize());
hashCode = 31 * hashCode + Objects.hashCode(secretArn());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasSubStatements() ? subStatements() : null);
hashCode = 31 * hashCode + Objects.hashCode(updatedAt());
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 DescribeStatementResponse)) {
return false;
}
DescribeStatementResponse other = (DescribeStatementResponse) obj;
return Objects.equals(clusterIdentifier(), other.clusterIdentifier()) && Objects.equals(createdAt(), other.createdAt())
&& Objects.equals(database(), other.database()) && Objects.equals(dbUser(), other.dbUser())
&& Objects.equals(duration(), other.duration()) && Objects.equals(error(), other.error())
&& Objects.equals(hasResultSet(), other.hasResultSet()) && Objects.equals(id(), other.id())
&& hasQueryParameters() == other.hasQueryParameters()
&& Objects.equals(queryParameters(), other.queryParameters())
&& Objects.equals(queryString(), other.queryString()) && Objects.equals(redshiftPid(), other.redshiftPid())
&& Objects.equals(redshiftQueryId(), other.redshiftQueryId()) && Objects.equals(resultRows(), other.resultRows())
&& Objects.equals(resultSize(), other.resultSize()) && Objects.equals(secretArn(), other.secretArn())
&& Objects.equals(statusAsString(), other.statusAsString()) && hasSubStatements() == other.hasSubStatements()
&& Objects.equals(subStatements(), other.subStatements()) && 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("DescribeStatementResponse").add("ClusterIdentifier", clusterIdentifier())
.add("CreatedAt", createdAt()).add("Database", database()).add("DbUser", dbUser()).add("Duration", duration())
.add("Error", error()).add("HasResultSet", hasResultSet()).add("Id", id())
.add("QueryParameters", hasQueryParameters() ? queryParameters() : null).add("QueryString", queryString())
.add("RedshiftPid", redshiftPid()).add("RedshiftQueryId", redshiftQueryId()).add("ResultRows", resultRows())
.add("ResultSize", resultSize()).add("SecretArn", secretArn()).add("Status", statusAsString())
.add("SubStatements", hasSubStatements() ? subStatements() : null).add("UpdatedAt", updatedAt()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ClusterIdentifier":
return Optional.ofNullable(clazz.cast(clusterIdentifier()));
case "CreatedAt":
return Optional.ofNullable(clazz.cast(createdAt()));
case "Database":
return Optional.ofNullable(clazz.cast(database()));
case "DbUser":
return Optional.ofNullable(clazz.cast(dbUser()));
case "Duration":
return Optional.ofNullable(clazz.cast(duration()));
case "Error":
return Optional.ofNullable(clazz.cast(error()));
case "HasResultSet":
return Optional.ofNullable(clazz.cast(hasResultSet()));
case "Id":
return Optional.ofNullable(clazz.cast(id()));
case "QueryParameters":
return Optional.ofNullable(clazz.cast(queryParameters()));
case "QueryString":
return Optional.ofNullable(clazz.cast(queryString()));
case "RedshiftPid":
return Optional.ofNullable(clazz.cast(redshiftPid()));
case "RedshiftQueryId":
return Optional.ofNullable(clazz.cast(redshiftQueryId()));
case "ResultRows":
return Optional.ofNullable(clazz.cast(resultRows()));
case "ResultSize":
return Optional.ofNullable(clazz.cast(resultSize()));
case "SecretArn":
return Optional.ofNullable(clazz.cast(secretArn()));
case "Status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "SubStatements":
return Optional.ofNullable(clazz.cast(subStatements()));
case "UpdatedAt":
return Optional.ofNullable(clazz.cast(updatedAt()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function