Skip to content

create_schedule async

create_schedule(
    name: Name,
    schedule_expression: ScheduleExpression,
    target: Target,
    flexible_time_window: FlexibleTimeWindow,
    *,
    config_overrides: Optional[AsyncSchedulerClientConfig] = None,
    group_name: Optional[ScheduleGroupName] = None,
    start_date: Optional[StartDate] = None,
    end_date: Optional[EndDate] = None,
    description: Optional[Description] = None,
    schedule_expression_timezone: Optional[ScheduleExpressionTimezone] = None,
    state: Optional[ScheduleState] = None,
    kms_key_arn: Optional[KmsKeyArn] = None,
    client_token: Optional[ClientToken] = None,
    action_after_completion: Optional[ActionAfterCompletion] = None,
) -> CreateScheduleOutput

Creates the specified schedule.

Parameters:

  • name (Name) –

    The name of the schedule that you are creating.

  • group_name (Optional[ScheduleGroupName], default: None ) –

    The name of the schedule group to associate with this schedule. If you omit this, the default schedule group is used.

  • schedule_expression (ScheduleExpression) –

    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.

  • start_date (Optional[StartDate], default: None ) –

    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.

  • end_date (Optional[EndDate], default: None ) –

    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.

  • description (Optional[Description], default: None ) –

    The description you specify for the schedule.

  • schedule_expression_timezone (Optional[ScheduleExpressionTimezone], default: None ) –

    The timezone in which the scheduling expression is evaluated.

  • state (Optional[ScheduleState], default: None ) –

    Specifies whether the schedule is enabled or disabled.

  • kms_key_arn (Optional[KmsKeyArn], default: None ) –

    The Amazon Resource Name (ARN) for the customer managed KMS key that EventBridge Scheduler will use to encrypt and decrypt your data.

  • target (Target) –

    The schedule's target.

  • flexible_time_window (FlexibleTimeWindow) –

    Allows you to configure a time window during which EventBridge Scheduler invokes the schedule.

  • client_token (Optional[ClientToken], default: None ) –

    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.

  • action_after_completion (Optional[ActionAfterCompletion], default: None ) –

    Specifies the action that EventBridge Scheduler applies to the schedule after the schedule completes invoking the target.

Raises:

Source code in docs_src/capo_scheduler/_services/async_scheduler.py
async def create_schedule(
    self,
    name: "capo_scheduler.types.name.Name",
    schedule_expression: "capo_scheduler.types.schedule_expression.ScheduleExpression",
    target: "capo_scheduler.types.target.Target",
    flexible_time_window: "capo_scheduler.types.flexible_time_window.FlexibleTimeWindow",
    *,
    config_overrides: Optional[AsyncSchedulerClientConfig] = None,
    group_name: Optional[
        "capo_scheduler.types.schedule_group_name.ScheduleGroupName"
    ] = None,
    start_date: Optional["capo_scheduler.types.start_date.StartDate"] = None,
    end_date: Optional["capo_scheduler.types.end_date.EndDate"] = None,
    description: Optional["capo_scheduler.types.description.Description"] = None,
    schedule_expression_timezone: Optional[
        "capo_scheduler.types.schedule_expression_timezone.ScheduleExpressionTimezone"
    ] = None,
    state: Optional["capo_scheduler.types.schedule_state.ScheduleState"] = None,
    kms_key_arn: Optional["capo_scheduler.types.kms_key_arn.KmsKeyArn"] = None,
    client_token: Optional["capo_scheduler.types.client_token.ClientToken"] = None,
    action_after_completion: Optional[
        "capo_scheduler.types.action_after_completion.ActionAfterCompletion"
    ] = None,
) -> "capo_scheduler.types.create_schedule_output.CreateScheduleOutput":
    """<p>Creates the specified schedule.</p>

    Args:
        name: <p>The name of the schedule that you are creating.</p>
        group_name: <p>The name of the schedule group to associate with this schedule. If you omit this, the default schedule group is used.</p>
        schedule_expression: <p> The expression that defines when the schedule runs. The following formats are supported. </p> <ul> <li> <p> <code>at</code> expression - <code>at(yyyy-mm-ddThh:mm:ss)</code> </p> </li> <li> <p> <code>rate</code> expression - <code>rate(value unit)</code> </p> </li> <li> <p> <code>cron</code> expression - <code>cron(fields)</code> </p> </li> </ul> <p> You can use <code>at</code> 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 <code>rate</code> and <code>cron</code> 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. </p> <p> A <code>cron</code> expression consists of six fields separated by white spaces: <code>(minutes hours day_of_month month day_of_week year)</code>. </p> <p> A <code>rate</code> expression consists of a <i>value</i> as a positive integer, and a <i>unit</i> with the following options: <code>minute</code> | <code>minutes</code> | <code>hour</code> | <code>hours</code> | <code>day</code> | <code>days</code> </p> <p> For more information and examples, see <a href="https://docs.aws.amazon.com/scheduler/latest/UserGuide/schedule-types.html">Schedule types on EventBridge Scheduler</a> in the <i>EventBridge Scheduler User Guide</i>. </p>
        start_date: <p>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 <code>StartDate</code> you specify. EventBridge Scheduler ignores <code>StartDate</code> for one-time schedules.</p>
        end_date: <p>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 <code>EndDate</code> you specify. EventBridge Scheduler ignores <code>EndDate</code> for one-time schedules.</p>
        description: <p>The description you specify for the schedule.</p>
        schedule_expression_timezone: <p>The timezone in which the scheduling expression is evaluated.</p>
        state: <p>Specifies whether the schedule is enabled or disabled.</p>
        kms_key_arn: <p>The Amazon Resource Name (ARN) for the customer managed KMS key that EventBridge Scheduler will use to encrypt and decrypt your data.</p>
        target: <p>The schedule's target.</p>
        flexible_time_window: <p>Allows you to configure a time window during which EventBridge Scheduler invokes the schedule.</p>
        client_token: <p> 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. </p>
        action_after_completion: <p>Specifies the action that EventBridge Scheduler applies to the schedule after the schedule completes invoking the target.</p>

    Raises:
        capo_scheduler.errors.conflict_exception.ConflictException: <p>Updating or deleting the resource can cause an inconsistent state.</p>
        capo_scheduler.errors.internal_server_exception.InternalServerException: <p>Unexpected error encountered while processing the request.</p>
        capo_scheduler.errors.resource_not_found_exception.ResourceNotFoundException: <p>The request references a resource which does not exist.</p>
        capo_scheduler.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request exceeds a service quota.</p>
        capo_scheduler.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
        capo_scheduler.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by an AWS service.</p>
        capo_scheduler.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_scheduler.types.create_schedule_input.CreateScheduleInput]",
    ) -> AsyncOperationResponse[
        "capo_scheduler.types.create_schedule_output.CreateScheduleOutput"
    ]:
        import capo_scheduler._operations.aws_chronos_service.create_schedule

        (
            output,
            http_response,
        ) = await capo_scheduler._operations.aws_chronos_service.create_schedule.async_create_schedule(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateSchedule")
    )
    input_: capo_scheduler.types.create_schedule_input.CreateScheduleInput = {
        "name": name,
        "schedule_expression": schedule_expression,
        "target": target,
        "flexible_time_window": flexible_time_window,
    }
    if group_name is not None:
        input_["group_name"] = group_name
    if start_date is not None:
        input_["start_date"] = start_date
    if end_date is not None:
        input_["end_date"] = end_date
    if description is not None:
        input_["description"] = description
    if schedule_expression_timezone is not None:
        input_["schedule_expression_timezone"] = schedule_expression_timezone
    if state is not None:
        input_["state"] = state
    if kms_key_arn is not None:
        input_["kms_key_arn"] = kms_key_arn
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if action_after_completion is not None:
        input_["action_after_completion"] = action_after_completion

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output