software.amazon.awssdk.services.scheduler.model.CreateScheduleRequest Maven / Gradle / Ivy
Show all versions of scheduler 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.scheduler.model;
import java.time.Instant;
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 CreateScheduleRequest extends SchedulerRequest implements
ToCopyableBuilder {
private static final SdkField ACTION_AFTER_COMPLETION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ActionAfterCompletion").getter(getter(CreateScheduleRequest::actionAfterCompletionAsString))
.setter(setter(Builder::actionAfterCompletion))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ActionAfterCompletion").build())
.build();
private static final SdkField CLIENT_TOKEN_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("ClientToken")
.getter(getter(CreateScheduleRequest::clientToken))
.setter(setter(Builder::clientToken))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ClientToken").build(),
DefaultValueTrait.idempotencyToken()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Description").getter(getter(CreateScheduleRequest::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description").build()).build();
private static final SdkField END_DATE_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("EndDate").getter(getter(CreateScheduleRequest::endDate)).setter(setter(Builder::endDate))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EndDate").build()).build();
private static final SdkField FLEXIBLE_TIME_WINDOW_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("FlexibleTimeWindow")
.getter(getter(CreateScheduleRequest::flexibleTimeWindow)).setter(setter(Builder::flexibleTimeWindow))
.constructor(FlexibleTimeWindow::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FlexibleTimeWindow").build())
.build();
private static final SdkField GROUP_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("GroupName").getter(getter(CreateScheduleRequest::groupName)).setter(setter(Builder::groupName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("GroupName").build()).build();
private static final SdkField KMS_KEY_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("KmsKeyArn").getter(getter(CreateScheduleRequest::kmsKeyArn)).setter(setter(Builder::kmsKeyArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KmsKeyArn").build()).build();
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name")
.getter(getter(CreateScheduleRequest::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PATH).locationName("Name").build()).build();
private static final SdkField SCHEDULE_EXPRESSION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ScheduleExpression").getter(getter(CreateScheduleRequest::scheduleExpression))
.setter(setter(Builder::scheduleExpression))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ScheduleExpression").build())
.build();
private static final SdkField SCHEDULE_EXPRESSION_TIMEZONE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("ScheduleExpressionTimezone")
.getter(getter(CreateScheduleRequest::scheduleExpressionTimezone))
.setter(setter(Builder::scheduleExpressionTimezone))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ScheduleExpressionTimezone").build())
.build();
private static final SdkField START_DATE_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("StartDate").getter(getter(CreateScheduleRequest::startDate)).setter(setter(Builder::startDate))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StartDate").build()).build();
private static final SdkField STATE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("State")
.getter(getter(CreateScheduleRequest::stateAsString)).setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("State").build()).build();
private static final SdkField TARGET_FIELD = SdkField. builder(MarshallingType.SDK_POJO).memberName("Target")
.getter(getter(CreateScheduleRequest::target)).setter(setter(Builder::target)).constructor(Target::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Target").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ACTION_AFTER_COMPLETION_FIELD,
CLIENT_TOKEN_FIELD, DESCRIPTION_FIELD, END_DATE_FIELD, FLEXIBLE_TIME_WINDOW_FIELD, GROUP_NAME_FIELD,
KMS_KEY_ARN_FIELD, NAME_FIELD, SCHEDULE_EXPRESSION_FIELD, SCHEDULE_EXPRESSION_TIMEZONE_FIELD, START_DATE_FIELD,
STATE_FIELD, TARGET_FIELD));
private final String actionAfterCompletion;
private final String clientToken;
private final String description;
private final Instant endDate;
private final FlexibleTimeWindow flexibleTimeWindow;
private final String groupName;
private final String kmsKeyArn;
private final String name;
private final String scheduleExpression;
private final String scheduleExpressionTimezone;
private final Instant startDate;
private final String state;
private final Target target;
private CreateScheduleRequest(BuilderImpl builder) {
super(builder);
this.actionAfterCompletion = builder.actionAfterCompletion;
this.clientToken = builder.clientToken;
this.description = builder.description;
this.endDate = builder.endDate;
this.flexibleTimeWindow = builder.flexibleTimeWindow;
this.groupName = builder.groupName;
this.kmsKeyArn = builder.kmsKeyArn;
this.name = builder.name;
this.scheduleExpression = builder.scheduleExpression;
this.scheduleExpressionTimezone = builder.scheduleExpressionTimezone;
this.startDate = builder.startDate;
this.state = builder.state;
this.target = builder.target;
}
/**
*
* Specifies the action that EventBridge Scheduler applies to the schedule after the schedule completes invoking the
* target.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #actionAfterCompletion} will return {@link ActionAfterCompletion#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #actionAfterCompletionAsString}.
*
*
* @return Specifies the action that EventBridge Scheduler applies to the schedule after the schedule completes
* invoking the target.
* @see ActionAfterCompletion
*/
public final ActionAfterCompletion actionAfterCompletion() {
return ActionAfterCompletion.fromValue(actionAfterCompletion);
}
/**
*
* Specifies the action that EventBridge Scheduler applies to the schedule after the schedule completes invoking the
* target.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #actionAfterCompletion} will return {@link ActionAfterCompletion#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #actionAfterCompletionAsString}.
*
*
* @return Specifies the action that EventBridge Scheduler applies to the schedule after the schedule completes
* invoking the target.
* @see ActionAfterCompletion
*/
public final String actionAfterCompletionAsString() {
return actionAfterCompletion;
}
/**
*
* Unique, case-sensitive identifier you provide to ensure the idempotency of the request. If you do not specify a
* client token, EventBridge Scheduler uses a randomly generated token for the request to ensure idempotency.
*
*
* @return Unique, case-sensitive identifier you provide to ensure the idempotency of the request. If you do not
* specify a client token, EventBridge Scheduler uses a randomly generated token for the request to ensure
* idempotency.
*/
public final String clientToken() {
return clientToken;
}
/**
*
* The description you specify for the schedule.
*
*
* @return The description you specify for the schedule.
*/
public final String description() {
return description;
}
/**
*
* The date, in UTC, before which the schedule can invoke its target. Depending on the schedule's recurrence
* expression, invocations might stop on, or before, the EndDate
you specify. EventBridge Scheduler
* ignores EndDate
for one-time schedules.
*
*
* @return The date, in UTC, before which the schedule can invoke its target. Depending on the schedule's recurrence
* expression, invocations might stop on, or before, the EndDate
you specify. EventBridge
* Scheduler ignores EndDate
for one-time schedules.
*/
public final Instant endDate() {
return endDate;
}
/**
*
* Allows you to configure a time window during which EventBridge Scheduler invokes the schedule.
*
*
* @return Allows you to configure a time window during which EventBridge Scheduler invokes the schedule.
*/
public final FlexibleTimeWindow flexibleTimeWindow() {
return flexibleTimeWindow;
}
/**
*
* The name of the schedule group to associate with this schedule. If you omit this, the default schedule group is
* used.
*
*
* @return The name of the schedule group to associate with this schedule. If you omit this, the default schedule
* group is used.
*/
public final String groupName() {
return groupName;
}
/**
*
* The Amazon Resource Name (ARN) for the customer managed KMS key that EventBridge Scheduler will use to encrypt
* and decrypt your data.
*
*
* @return The Amazon Resource Name (ARN) for the customer managed KMS key that EventBridge Scheduler will use to
* encrypt and decrypt your data.
*/
public final String kmsKeyArn() {
return kmsKeyArn;
}
/**
*
* The name of the schedule that you are creating.
*
*
* @return The name of the schedule that you are creating.
*/
public final String name() {
return name;
}
/**
*
* The expression that defines when the schedule runs. The following formats are supported.
*
*
* -
*
* at
expression - at(yyyy-mm-ddThh:mm:ss)
*
*
* -
*
* rate
expression - rate(value unit)
*
*
* -
*
* cron
expression - cron(fields)
*
*
*
*
* You can use at
expressions to create one-time schedules that invoke a target once, at the time and
* in the time zone, that you specify. You can use rate
and cron
expressions to create
* recurring schedules. Rate-based schedules are useful when you want to invoke a target at regular intervals, such
* as every 15 minutes or every five days. Cron-based schedules are useful when you want to invoke a target
* periodically at a specific time, such as at 8:00 am (UTC+0) every 1st day of the month.
*
*
* A cron
expression consists of six fields separated by white spaces:
* (minutes hours day_of_month month day_of_week year)
.
*
*
* A rate
expression consists of a value as a positive integer, and a unit with the
* following options: minute
| minutes
| hour
| hours
|
* day
| days
*
*
* For more information and examples, see Schedule types on EventBridge
* Scheduler in the EventBridge Scheduler User Guide.
*
*
* @return The expression that defines when the schedule runs. The following formats are supported.
*
* -
*
* at
expression - at(yyyy-mm-ddThh:mm:ss)
*
*
* -
*
* rate
expression - rate(value unit)
*
*
* -
*
* cron
expression - cron(fields)
*
*
*
*
* You can use at
expressions to create one-time schedules that invoke a target once, at the
* time and in the time zone, that you specify. You can use rate
and cron
* expressions to create recurring schedules. Rate-based schedules are useful when you want to invoke a
* target at regular intervals, such as every 15 minutes or every five days. Cron-based schedules are useful
* when you want to invoke a target periodically at a specific time, such as at 8:00 am (UTC+0) every 1st
* day of the month.
*
*
* A cron
expression consists of six fields separated by white spaces:
* (minutes hours day_of_month month day_of_week year)
.
*
*
* A rate
expression consists of a value as a positive integer, and a unit with
* the following options: minute
| minutes
| hour
|
* hours
| day
| days
*
*
* For more information and examples, see Schedule types on
* EventBridge Scheduler in the EventBridge Scheduler User Guide.
*/
public final String scheduleExpression() {
return scheduleExpression;
}
/**
*
* The timezone in which the scheduling expression is evaluated.
*
*
* @return The timezone in which the scheduling expression is evaluated.
*/
public final String scheduleExpressionTimezone() {
return scheduleExpressionTimezone;
}
/**
*
* The date, in UTC, after which the schedule can begin invoking its target. Depending on the schedule's recurrence
* expression, invocations might occur on, or after, the StartDate
you specify. EventBridge Scheduler
* ignores StartDate
for one-time schedules.
*
*
* @return The date, in UTC, after which the schedule can begin invoking its target. Depending on the schedule's
* recurrence expression, invocations might occur on, or after, the StartDate
you specify.
* EventBridge Scheduler ignores StartDate
for one-time schedules.
*/
public final Instant startDate() {
return startDate;
}
/**
*
* Specifies whether the schedule is enabled or disabled.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link ScheduleState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return Specifies whether the schedule is enabled or disabled.
* @see ScheduleState
*/
public final ScheduleState state() {
return ScheduleState.fromValue(state);
}
/**
*
* Specifies whether the schedule is enabled or disabled.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link ScheduleState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return Specifies whether the schedule is enabled or disabled.
* @see ScheduleState
*/
public final String stateAsString() {
return state;
}
/**
*
* The schedule's target.
*
*
* @return The schedule's target.
*/
public final Target target() {
return target;
}
@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(actionAfterCompletionAsString());
hashCode = 31 * hashCode + Objects.hashCode(clientToken());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(endDate());
hashCode = 31 * hashCode + Objects.hashCode(flexibleTimeWindow());
hashCode = 31 * hashCode + Objects.hashCode(groupName());
hashCode = 31 * hashCode + Objects.hashCode(kmsKeyArn());
hashCode = 31 * hashCode + Objects.hashCode(name());
hashCode = 31 * hashCode + Objects.hashCode(scheduleExpression());
hashCode = 31 * hashCode + Objects.hashCode(scheduleExpressionTimezone());
hashCode = 31 * hashCode + Objects.hashCode(startDate());
hashCode = 31 * hashCode + Objects.hashCode(stateAsString());
hashCode = 31 * hashCode + Objects.hashCode(target());
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 CreateScheduleRequest)) {
return false;
}
CreateScheduleRequest other = (CreateScheduleRequest) obj;
return Objects.equals(actionAfterCompletionAsString(), other.actionAfterCompletionAsString())
&& Objects.equals(clientToken(), other.clientToken()) && Objects.equals(description(), other.description())
&& Objects.equals(endDate(), other.endDate()) && Objects.equals(flexibleTimeWindow(), other.flexibleTimeWindow())
&& Objects.equals(groupName(), other.groupName()) && Objects.equals(kmsKeyArn(), other.kmsKeyArn())
&& Objects.equals(name(), other.name()) && Objects.equals(scheduleExpression(), other.scheduleExpression())
&& Objects.equals(scheduleExpressionTimezone(), other.scheduleExpressionTimezone())
&& Objects.equals(startDate(), other.startDate()) && Objects.equals(stateAsString(), other.stateAsString())
&& Objects.equals(target(), other.target());
}
/**
* 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("CreateScheduleRequest").add("ActionAfterCompletion", actionAfterCompletionAsString())
.add("ClientToken", clientToken()).add("Description", description()).add("EndDate", endDate())
.add("FlexibleTimeWindow", flexibleTimeWindow()).add("GroupName", groupName()).add("KmsKeyArn", kmsKeyArn())
.add("Name", name()).add("ScheduleExpression", scheduleExpression())
.add("ScheduleExpressionTimezone", scheduleExpressionTimezone()).add("StartDate", startDate())
.add("State", stateAsString()).add("Target", target()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ActionAfterCompletion":
return Optional.ofNullable(clazz.cast(actionAfterCompletionAsString()));
case "ClientToken":
return Optional.ofNullable(clazz.cast(clientToken()));
case "Description":
return Optional.ofNullable(clazz.cast(description()));
case "EndDate":
return Optional.ofNullable(clazz.cast(endDate()));
case "FlexibleTimeWindow":
return Optional.ofNullable(clazz.cast(flexibleTimeWindow()));
case "GroupName":
return Optional.ofNullable(clazz.cast(groupName()));
case "KmsKeyArn":
return Optional.ofNullable(clazz.cast(kmsKeyArn()));
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "ScheduleExpression":
return Optional.ofNullable(clazz.cast(scheduleExpression()));
case "ScheduleExpressionTimezone":
return Optional.ofNullable(clazz.cast(scheduleExpressionTimezone()));
case "StartDate":
return Optional.ofNullable(clazz.cast(startDate()));
case "State":
return Optional.ofNullable(clazz.cast(stateAsString()));
case "Target":
return Optional.ofNullable(clazz.cast(target()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function