software.amazon.awssdk.services.timestreamquery.model.CreateScheduledQueryRequest Maven / Gradle / Ivy
Show all versions of timestreamquery 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.timestreamquery.model;
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.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 CreateScheduledQueryRequest extends TimestreamQueryRequest implements
ToCopyableBuilder {
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name")
.getter(getter(CreateScheduledQueryRequest::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build();
private static final SdkField QUERY_STRING_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("QueryString").getter(getter(CreateScheduledQueryRequest::queryString))
.setter(setter(Builder::queryString))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("QueryString").build()).build();
private static final SdkField SCHEDULE_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ScheduleConfiguration")
.getter(getter(CreateScheduledQueryRequest::scheduleConfiguration)).setter(setter(Builder::scheduleConfiguration))
.constructor(ScheduleConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ScheduleConfiguration").build())
.build();
private static final SdkField NOTIFICATION_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("NotificationConfiguration")
.getter(getter(CreateScheduledQueryRequest::notificationConfiguration))
.setter(setter(Builder::notificationConfiguration)).constructor(NotificationConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NotificationConfiguration").build())
.build();
private static final SdkField TARGET_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("TargetConfiguration")
.getter(getter(CreateScheduledQueryRequest::targetConfiguration)).setter(setter(Builder::targetConfiguration))
.constructor(TargetConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TargetConfiguration").build())
.build();
private static final SdkField CLIENT_TOKEN_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("ClientToken")
.getter(getter(CreateScheduledQueryRequest::clientToken))
.setter(setter(Builder::clientToken))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ClientToken").build(),
DefaultValueTrait.idempotencyToken()).build();
private static final SdkField SCHEDULED_QUERY_EXECUTION_ROLE_ARN_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("ScheduledQueryExecutionRoleArn")
.getter(getter(CreateScheduledQueryRequest::scheduledQueryExecutionRoleArn))
.setter(setter(Builder::scheduledQueryExecutionRoleArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ScheduledQueryExecutionRoleArn")
.build()).build();
private static final SdkField> TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Tags")
.getter(getter(CreateScheduledQueryRequest::tags))
.setter(setter(Builder::tags))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Tags").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Tag::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField KMS_KEY_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("KmsKeyId").getter(getter(CreateScheduledQueryRequest::kmsKeyId)).setter(setter(Builder::kmsKeyId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KmsKeyId").build()).build();
private static final SdkField ERROR_REPORT_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ErrorReportConfiguration")
.getter(getter(CreateScheduledQueryRequest::errorReportConfiguration))
.setter(setter(Builder::errorReportConfiguration)).constructor(ErrorReportConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ErrorReportConfiguration").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD,
QUERY_STRING_FIELD, SCHEDULE_CONFIGURATION_FIELD, NOTIFICATION_CONFIGURATION_FIELD, TARGET_CONFIGURATION_FIELD,
CLIENT_TOKEN_FIELD, SCHEDULED_QUERY_EXECUTION_ROLE_ARN_FIELD, TAGS_FIELD, KMS_KEY_ID_FIELD,
ERROR_REPORT_CONFIGURATION_FIELD));
private final String name;
private final String queryString;
private final ScheduleConfiguration scheduleConfiguration;
private final NotificationConfiguration notificationConfiguration;
private final TargetConfiguration targetConfiguration;
private final String clientToken;
private final String scheduledQueryExecutionRoleArn;
private final List tags;
private final String kmsKeyId;
private final ErrorReportConfiguration errorReportConfiguration;
private CreateScheduledQueryRequest(BuilderImpl builder) {
super(builder);
this.name = builder.name;
this.queryString = builder.queryString;
this.scheduleConfiguration = builder.scheduleConfiguration;
this.notificationConfiguration = builder.notificationConfiguration;
this.targetConfiguration = builder.targetConfiguration;
this.clientToken = builder.clientToken;
this.scheduledQueryExecutionRoleArn = builder.scheduledQueryExecutionRoleArn;
this.tags = builder.tags;
this.kmsKeyId = builder.kmsKeyId;
this.errorReportConfiguration = builder.errorReportConfiguration;
}
/**
*
* Name of the scheduled query.
*
*
* @return Name of the scheduled query.
*/
public final String name() {
return name;
}
/**
*
* The query string to run. Parameter names can be specified in the query string @
character followed
* by an identifier. The named Parameter @scheduled_runtime
is reserved and can be used in the query to
* get the time at which the query is scheduled to run.
*
*
* The timestamp calculated according to the ScheduleConfiguration parameter, will be the value of
* @scheduled_runtime
paramater for each query run. For example, consider an instance of a scheduled
* query executing on 2021-12-01 00:00:00. For this instance, the @scheduled_runtime
parameter is
* initialized to the timestamp 2021-12-01 00:00:00 when invoking the query.
*
*
* @return The query string to run. Parameter names can be specified in the query string @
character
* followed by an identifier. The named Parameter @scheduled_runtime
is reserved and can be
* used in the query to get the time at which the query is scheduled to run.
*
* The timestamp calculated according to the ScheduleConfiguration parameter, will be the value of
* @scheduled_runtime
paramater for each query run. For example, consider an instance of a
* scheduled query executing on 2021-12-01 00:00:00. For this instance, the @scheduled_runtime
* parameter is initialized to the timestamp 2021-12-01 00:00:00 when invoking the query.
*/
public final String queryString() {
return queryString;
}
/**
*
* The schedule configuration for the query.
*
*
* @return The schedule configuration for the query.
*/
public final ScheduleConfiguration scheduleConfiguration() {
return scheduleConfiguration;
}
/**
*
* Notification configuration for the scheduled query. A notification is sent by Timestream when a query run
* finishes, when the state is updated or when you delete it.
*
*
* @return Notification configuration for the scheduled query. A notification is sent by Timestream when a query run
* finishes, when the state is updated or when you delete it.
*/
public final NotificationConfiguration notificationConfiguration() {
return notificationConfiguration;
}
/**
*
* Configuration used for writing the result of a query.
*
*
* @return Configuration used for writing the result of a query.
*/
public final TargetConfiguration targetConfiguration() {
return targetConfiguration;
}
/**
*
* Using a ClientToken makes the call to CreateScheduledQuery idempotent, in other words, making the same request
* repeatedly will produce the same result. Making multiple identical CreateScheduledQuery requests has the same
* effect as making a single request.
*
*
* -
*
* If CreateScheduledQuery is called without a ClientToken
, the Query SDK generates a
* ClientToken
on your behalf.
*
*
* -
*
* After 8 hours, any request with the same ClientToken
is treated as a new request.
*
*
*
*
* @return Using a ClientToken makes the call to CreateScheduledQuery idempotent, in other words, making the same
* request repeatedly will produce the same result. Making multiple identical CreateScheduledQuery requests
* has the same effect as making a single request.
*
* -
*
* If CreateScheduledQuery is called without a ClientToken
, the Query SDK generates a
* ClientToken
on your behalf.
*
*
* -
*
* After 8 hours, any request with the same ClientToken
is treated as a new request.
*
*
*/
public final String clientToken() {
return clientToken;
}
/**
*
* The ARN for the IAM role that Timestream will assume when running the scheduled query.
*
*
* @return The ARN for the IAM role that Timestream will assume when running the scheduled query.
*/
public final String scheduledQueryExecutionRoleArn() {
return scheduledQueryExecutionRoleArn;
}
/**
* For responses, this returns true if the service returned a value for the Tags 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 hasTags() {
return tags != null && !(tags instanceof SdkAutoConstructList);
}
/**
*
* A list of key-value pairs to label the scheduled query.
*
*
* 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 #hasTags} method.
*
*
* @return A list of key-value pairs to label the scheduled query.
*/
public final List tags() {
return tags;
}
/**
*
* The Amazon KMS key used to encrypt the scheduled query resource, at-rest. If the Amazon KMS key is not specified,
* the scheduled query resource will be encrypted with a Timestream owned Amazon KMS key. To specify a KMS key, use
* the key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix the name with alias/
*
*
* If ErrorReportConfiguration uses SSE_KMS
as encryption type, the same KmsKeyId is used to encrypt
* the error report at rest.
*
*
* @return The Amazon KMS key used to encrypt the scheduled query resource, at-rest. If the Amazon KMS key is not
* specified, the scheduled query resource will be encrypted with a Timestream owned Amazon KMS key. To
* specify a KMS key, use the key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix
* the name with alias/
*
* If ErrorReportConfiguration uses SSE_KMS
as encryption type, the same KmsKeyId is used to
* encrypt the error report at rest.
*/
public final String kmsKeyId() {
return kmsKeyId;
}
/**
*
* Configuration for error reporting. Error reports will be generated when a problem is encountered when writing the
* query results.
*
*
* @return Configuration for error reporting. Error reports will be generated when a problem is encountered when
* writing the query results.
*/
public final ErrorReportConfiguration errorReportConfiguration() {
return errorReportConfiguration;
}
@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(name());
hashCode = 31 * hashCode + Objects.hashCode(queryString());
hashCode = 31 * hashCode + Objects.hashCode(scheduleConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(notificationConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(targetConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(clientToken());
hashCode = 31 * hashCode + Objects.hashCode(scheduledQueryExecutionRoleArn());
hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null);
hashCode = 31 * hashCode + Objects.hashCode(kmsKeyId());
hashCode = 31 * hashCode + Objects.hashCode(errorReportConfiguration());
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 CreateScheduledQueryRequest)) {
return false;
}
CreateScheduledQueryRequest other = (CreateScheduledQueryRequest) obj;
return Objects.equals(name(), other.name()) && Objects.equals(queryString(), other.queryString())
&& Objects.equals(scheduleConfiguration(), other.scheduleConfiguration())
&& Objects.equals(notificationConfiguration(), other.notificationConfiguration())
&& Objects.equals(targetConfiguration(), other.targetConfiguration())
&& Objects.equals(clientToken(), other.clientToken())
&& Objects.equals(scheduledQueryExecutionRoleArn(), other.scheduledQueryExecutionRoleArn())
&& hasTags() == other.hasTags() && Objects.equals(tags(), other.tags())
&& Objects.equals(kmsKeyId(), other.kmsKeyId())
&& Objects.equals(errorReportConfiguration(), other.errorReportConfiguration());
}
/**
* 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("CreateScheduledQueryRequest").add("Name", name())
.add("QueryString", queryString() == null ? null : "*** Sensitive Data Redacted ***")
.add("ScheduleConfiguration", scheduleConfiguration())
.add("NotificationConfiguration", notificationConfiguration()).add("TargetConfiguration", targetConfiguration())
.add("ClientToken", clientToken() == null ? null : "*** Sensitive Data Redacted ***")
.add("ScheduledQueryExecutionRoleArn", scheduledQueryExecutionRoleArn()).add("Tags", hasTags() ? tags() : null)
.add("KmsKeyId", kmsKeyId()).add("ErrorReportConfiguration", errorReportConfiguration()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "QueryString":
return Optional.ofNullable(clazz.cast(queryString()));
case "ScheduleConfiguration":
return Optional.ofNullable(clazz.cast(scheduleConfiguration()));
case "NotificationConfiguration":
return Optional.ofNullable(clazz.cast(notificationConfiguration()));
case "TargetConfiguration":
return Optional.ofNullable(clazz.cast(targetConfiguration()));
case "ClientToken":
return Optional.ofNullable(clazz.cast(clientToken()));
case "ScheduledQueryExecutionRoleArn":
return Optional.ofNullable(clazz.cast(scheduledQueryExecutionRoleArn()));
case "Tags":
return Optional.ofNullable(clazz.cast(tags()));
case "KmsKeyId":
return Optional.ofNullable(clazz.cast(kmsKeyId()));
case "ErrorReportConfiguration":
return Optional.ofNullable(clazz.cast(errorReportConfiguration()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function