software.amazon.awssdk.services.redshift.model.CreateScheduledActionResponse Maven / Gradle / Ivy
Show all versions of redshift 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.redshift.model;
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 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;
/**
*
* Describes a scheduled action. You can use a scheduled action to trigger some Amazon Redshift API operations on a
* schedule. For information about which API operations can be scheduled, see ScheduledActionType.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class CreateScheduledActionResponse extends RedshiftResponse implements
ToCopyableBuilder {
private static final SdkField SCHEDULED_ACTION_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ScheduledActionName").getter(getter(CreateScheduledActionResponse::scheduledActionName))
.setter(setter(Builder::scheduledActionName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ScheduledActionName").build())
.build();
private static final SdkField TARGET_ACTION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("TargetAction")
.getter(getter(CreateScheduledActionResponse::targetAction)).setter(setter(Builder::targetAction))
.constructor(ScheduledActionType::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TargetAction").build()).build();
private static final SdkField SCHEDULE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Schedule").getter(getter(CreateScheduledActionResponse::schedule)).setter(setter(Builder::schedule))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Schedule").build()).build();
private static final SdkField IAM_ROLE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("IamRole").getter(getter(CreateScheduledActionResponse::iamRole)).setter(setter(Builder::iamRole))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("IamRole").build()).build();
private static final SdkField SCHEDULED_ACTION_DESCRIPTION_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("ScheduledActionDescription")
.getter(getter(CreateScheduledActionResponse::scheduledActionDescription))
.setter(setter(Builder::scheduledActionDescription))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ScheduledActionDescription").build())
.build();
private static final SdkField STATE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("State")
.getter(getter(CreateScheduledActionResponse::stateAsString)).setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("State").build()).build();
private static final SdkField> NEXT_INVOCATIONS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("NextInvocations")
.getter(getter(CreateScheduledActionResponse::nextInvocations))
.setter(setter(Builder::nextInvocations))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NextInvocations").build(),
ListTrait
.builder()
.memberLocationName("ScheduledActionTime")
.memberFieldInfo(
SdkField. builder(MarshallingType.INSTANT)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("ScheduledActionTime").build()).build()).build()).build();
private static final SdkField START_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("StartTime").getter(getter(CreateScheduledActionResponse::startTime)).setter(setter(Builder::startTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StartTime").build()).build();
private static final SdkField END_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("EndTime").getter(getter(CreateScheduledActionResponse::endTime)).setter(setter(Builder::endTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EndTime").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SCHEDULED_ACTION_NAME_FIELD,
TARGET_ACTION_FIELD, SCHEDULE_FIELD, IAM_ROLE_FIELD, SCHEDULED_ACTION_DESCRIPTION_FIELD, STATE_FIELD,
NEXT_INVOCATIONS_FIELD, START_TIME_FIELD, END_TIME_FIELD));
private final String scheduledActionName;
private final ScheduledActionType targetAction;
private final String schedule;
private final String iamRole;
private final String scheduledActionDescription;
private final String state;
private final List nextInvocations;
private final Instant startTime;
private final Instant endTime;
private CreateScheduledActionResponse(BuilderImpl builder) {
super(builder);
this.scheduledActionName = builder.scheduledActionName;
this.targetAction = builder.targetAction;
this.schedule = builder.schedule;
this.iamRole = builder.iamRole;
this.scheduledActionDescription = builder.scheduledActionDescription;
this.state = builder.state;
this.nextInvocations = builder.nextInvocations;
this.startTime = builder.startTime;
this.endTime = builder.endTime;
}
/**
*
* The name of the scheduled action.
*
*
* @return The name of the scheduled action.
*/
public final String scheduledActionName() {
return scheduledActionName;
}
/**
*
* A JSON format string of the Amazon Redshift API operation with input parameters.
*
*
* "
* {\"ResizeCluster\":{\"NodeType\":\"ra3.4xlarge\",\"ClusterIdentifier\":\"my-test-cluster\",\"NumberOfNodes\":3}}
* ".
*
*
* @return A JSON format string of the Amazon Redshift API operation with input parameters.
*
* "
* {\"ResizeCluster\":{\"NodeType\":\"ra3.4xlarge\",\"ClusterIdentifier\":\"my-test-cluster\",\"NumberOfNodes\":3}}
* ".
*/
public final ScheduledActionType targetAction() {
return targetAction;
}
/**
*
* The schedule for a one-time (at format) or recurring (cron format) scheduled action. Schedule invocations must be
* separated by at least one hour.
*
*
* Format of at expressions is "at(yyyy-mm-ddThh:mm:ss)
". For example, "
* at(2016-03-04T17:27:00)
".
*
*
* Format of cron expressions is "cron(Minutes Hours Day-of-month Month Day-of-week Year)
* ". For example, "cron(0 10 ? * MON *)
* ". For more information, see Cron Expressions in the Amazon
* CloudWatch Events User Guide.
*
*
* @return The schedule for a one-time (at format) or recurring (cron format) scheduled action. Schedule invocations
* must be separated by at least one hour.
*
* Format of at expressions is "at(yyyy-mm-ddThh:mm:ss)
". For example, "
* at(2016-03-04T17:27:00)
".
*
*
* Format of cron expressions is "cron(Minutes Hours Day-of-month Month Day-of-week Year)
* ". For example, "cron(0 10 ? * MON *)
* ". For more information, see Cron Expressions in the
* Amazon CloudWatch Events User Guide.
*/
public final String schedule() {
return schedule;
}
/**
*
* The IAM role to assume to run the scheduled action. This IAM role must have permission to run the Amazon Redshift
* API operation in the scheduled action. This IAM role must allow the Amazon Redshift scheduler (Principal
* scheduler.redshift.amazonaws.com) to assume permissions on your behalf. For more information about the IAM role
* to use with the Amazon Redshift scheduler, see Using
* Identity-Based Policies for Amazon Redshift in the Amazon Redshift Cluster Management Guide.
*
*
* @return The IAM role to assume to run the scheduled action. This IAM role must have permission to run the Amazon
* Redshift API operation in the scheduled action. This IAM role must allow the Amazon Redshift scheduler
* (Principal scheduler.redshift.amazonaws.com) to assume permissions on your behalf. For more information
* about the IAM role to use with the Amazon Redshift scheduler, see Using Identity-Based Policies for Amazon Redshift in the Amazon Redshift Cluster Management
* Guide.
*/
public final String iamRole() {
return iamRole;
}
/**
*
* The description of the scheduled action.
*
*
* @return The description of the scheduled action.
*/
public final String scheduledActionDescription() {
return scheduledActionDescription;
}
/**
*
* The state of the scheduled action. For example, DISABLED
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link ScheduledActionState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of the scheduled action. For example, DISABLED
.
* @see ScheduledActionState
*/
public final ScheduledActionState state() {
return ScheduledActionState.fromValue(state);
}
/**
*
* The state of the scheduled action. For example, DISABLED
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link ScheduledActionState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of the scheduled action. For example, DISABLED
.
* @see ScheduledActionState
*/
public final String stateAsString() {
return state;
}
/**
* For responses, this returns true if the service returned a value for the NextInvocations 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 hasNextInvocations() {
return nextInvocations != null && !(nextInvocations instanceof SdkAutoConstructList);
}
/**
*
* List of times when the scheduled action will 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 #hasNextInvocations} method.
*
*
* @return List of times when the scheduled action will run.
*/
public final List nextInvocations() {
return nextInvocations;
}
/**
*
* The start time in UTC when the schedule is active. Before this time, the scheduled action does not trigger.
*
*
* @return The start time in UTC when the schedule is active. Before this time, the scheduled action does not
* trigger.
*/
public final Instant startTime() {
return startTime;
}
/**
*
* The end time in UTC when the schedule is no longer active. After this time, the scheduled action does not
* trigger.
*
*
* @return The end time in UTC when the schedule is no longer active. After this time, the scheduled action does not
* trigger.
*/
public final Instant endTime() {
return endTime;
}
@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(scheduledActionName());
hashCode = 31 * hashCode + Objects.hashCode(targetAction());
hashCode = 31 * hashCode + Objects.hashCode(schedule());
hashCode = 31 * hashCode + Objects.hashCode(iamRole());
hashCode = 31 * hashCode + Objects.hashCode(scheduledActionDescription());
hashCode = 31 * hashCode + Objects.hashCode(stateAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasNextInvocations() ? nextInvocations() : null);
hashCode = 31 * hashCode + Objects.hashCode(startTime());
hashCode = 31 * hashCode + Objects.hashCode(endTime());
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 CreateScheduledActionResponse)) {
return false;
}
CreateScheduledActionResponse other = (CreateScheduledActionResponse) obj;
return Objects.equals(scheduledActionName(), other.scheduledActionName())
&& Objects.equals(targetAction(), other.targetAction()) && Objects.equals(schedule(), other.schedule())
&& Objects.equals(iamRole(), other.iamRole())
&& Objects.equals(scheduledActionDescription(), other.scheduledActionDescription())
&& Objects.equals(stateAsString(), other.stateAsString()) && hasNextInvocations() == other.hasNextInvocations()
&& Objects.equals(nextInvocations(), other.nextInvocations()) && Objects.equals(startTime(), other.startTime())
&& Objects.equals(endTime(), other.endTime());
}
/**
* 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("CreateScheduledActionResponse").add("ScheduledActionName", scheduledActionName())
.add("TargetAction", targetAction()).add("Schedule", schedule()).add("IamRole", iamRole())
.add("ScheduledActionDescription", scheduledActionDescription()).add("State", stateAsString())
.add("NextInvocations", hasNextInvocations() ? nextInvocations() : null).add("StartTime", startTime())
.add("EndTime", endTime()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ScheduledActionName":
return Optional.ofNullable(clazz.cast(scheduledActionName()));
case "TargetAction":
return Optional.ofNullable(clazz.cast(targetAction()));
case "Schedule":
return Optional.ofNullable(clazz.cast(schedule()));
case "IamRole":
return Optional.ofNullable(clazz.cast(iamRole()));
case "ScheduledActionDescription":
return Optional.ofNullable(clazz.cast(scheduledActionDescription()));
case "State":
return Optional.ofNullable(clazz.cast(stateAsString()));
case "NextInvocations":
return Optional.ofNullable(clazz.cast(nextInvocations()));
case "StartTime":
return Optional.ofNullable(clazz.cast(startTime()));
case "EndTime":
return Optional.ofNullable(clazz.cast(endTime()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function