RedshiftServerless / Client / create_scheduled_action

create_scheduled_action#

RedshiftServerless.Client.create_scheduled_action(**kwargs)#

Creates a scheduled action. A scheduled action contains a schedule and an Amazon Redshift API action. For example, you can create a schedule of when to run the CreateSnapshot API operation.

See also: AWS API Documentation

Request Syntax

response = client.create_scheduled_action(
    enabled=True|False,
    endTime=datetime(2015, 1, 1),
    namespaceName='string',
    roleArn='string',
    schedule={
        'at': datetime(2015, 1, 1),
        'cron': 'string'
    },
    scheduledActionDescription='string',
    scheduledActionName='string',
    startTime=datetime(2015, 1, 1),
    targetAction={
        'createSnapshot': {
            'namespaceName': 'string',
            'retentionPeriod': 123,
            'snapshotNamePrefix': 'string',
            'tags': [
                {
                    'key': 'string',
                    'value': 'string'
                },
            ]
        }
    }
)
Parameters:
  • enabled (boolean) – Indicates whether the schedule is enabled. If false, the scheduled action does not trigger. For more information about state of the scheduled action, see ScheduledAction.

  • endTime (datetime) – The end time in UTC when the schedule is no longer active. After this time, the scheduled action does not trigger.

  • namespaceName (string) –

    [REQUIRED]

    The name of the namespace for which to create a scheduled action.

  • roleArn (string) –

    [REQUIRED]

    The ARN of the IAM role to assume to run the scheduled action. This IAM role must have permission to run the Amazon Redshift Serverless API operation in the scheduled action. This IAM role must allow the Amazon Redshift scheduler to schedule creating snapshots. (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

  • schedule (dict) –

    [REQUIRED]

    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.

    Note

    This is a Tagged Union structure. Only one of the following top level keys can be set: at, cron.

    • at (datetime) –

      The timestamp of when Amazon Redshift Serverless should run the scheduled action. Format of at expressions is “ at(yyyy-mm-ddThh:mm:ss)”. For example, “ at(2016-03-04T17:27:00)”.

    • cron (string) –

      The cron expression to use to schedule a recurring scheduled action. Schedule invocations must be separated by at least one hour.

      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.

  • scheduledActionDescription (string) – The description of the scheduled action.

  • scheduledActionName (string) –

    [REQUIRED]

    The name of the scheduled action.

  • startTime (datetime) – The start time in UTC when the schedule is active. Before this time, the scheduled action does not trigger.

  • targetAction (dict) –

    [REQUIRED]

    A JSON format string of the Amazon Redshift Serverless API operation with input parameters. The following is an example of a target action.

    "{"CreateSnapshot": {"NamespaceName": "sampleNamespace","SnapshotName": "sampleSnapshot", "retentionPeriod": "1"}}"

    Note

    This is a Tagged Union structure. Only one of the following top level keys can be set: createSnapshot.

    • createSnapshot (dict) –

      The parameters that you can use to configure a scheduled action to create a snapshot. For more information about creating a scheduled action, see CreateScheduledAction.

      • namespaceName (string) – [REQUIRED]

        The name of the namespace for which you want to configure a scheduled action to create a snapshot.

      • retentionPeriod (integer) –

        The retention period of the snapshot created by the scheduled action.

      • snapshotNamePrefix (string) – [REQUIRED]

        A string prefix that is attached to the name of the snapshot created by the scheduled action. The final name of the snapshot is the string prefix appended by the date and time of when the snapshot was created.

      • tags (list) –

        An array of Tag objects to associate with the snapshot.

        • (dict) –

          A map of key-value pairs.

          • key (string) – [REQUIRED]

            The key to use in the tag.

          • value (string) – [REQUIRED]

            The value of the tag.

Return type:

dict

Returns:

Response Syntax

{
    'scheduledAction': {
        'endTime': datetime(2015, 1, 1),
        'namespaceName': 'string',
        'nextInvocations': [
            datetime(2015, 1, 1),
        ],
        'roleArn': 'string',
        'schedule': {
            'at': datetime(2015, 1, 1),
            'cron': 'string'
        },
        'scheduledActionDescription': 'string',
        'scheduledActionName': 'string',
        'scheduledActionUuid': 'string',
        'startTime': datetime(2015, 1, 1),
        'state': 'ACTIVE'|'DISABLED',
        'targetAction': {
            'createSnapshot': {
                'namespaceName': 'string',
                'retentionPeriod': 123,
                'snapshotNamePrefix': 'string',
                'tags': [
                    {
                        'key': 'string',
                        'value': 'string'
                    },
                ]
            }
        }
    }
}

Response Structure

  • (dict) –

    • scheduledAction (dict) –

      The returned ScheduledAction object that describes the properties of a scheduled action.

      • endTime (datetime) –

        The end time of

      • namespaceName (string) –

        The end time in UTC when the schedule is no longer active. After this time, the scheduled action does not trigger.

      • nextInvocations (list) –

        An array of timestamps of when the next scheduled actions will trigger.

        • (datetime) –

      • roleArn (string) –

        The ARN of the IAM role to assume to run the scheduled action. This IAM role must have permission to run the Amazon Redshift Serverless API operation in the scheduled action. This IAM role must allow the Amazon Redshift scheduler to schedule creating snapshots. (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

      • schedule (dict) –

        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.

        Note

        This is a Tagged Union structure. Only one of the following top level keys will be set: at, cron. If a client receives an unknown member it will set SDK_UNKNOWN_MEMBER as the top level key, which maps to the name or tag of the unknown member. The structure of SDK_UNKNOWN_MEMBER is as follows:

        'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}
        
        • at (datetime) –

          The timestamp of when Amazon Redshift Serverless should run the scheduled action. Format of at expressions is “ at(yyyy-mm-ddThh:mm:ss)”. For example, “ at(2016-03-04T17:27:00)”.

        • cron (string) –

          The cron expression to use to schedule a recurring scheduled action. Schedule invocations must be separated by at least one hour.

          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.

      • scheduledActionDescription (string) –

        The description of the scheduled action.

      • scheduledActionName (string) –

        The name of the scheduled action.

      • scheduledActionUuid (string) –

        The uuid of the scheduled action.

      • startTime (datetime) –

        The start time in UTC when the schedule is active. Before this time, the scheduled action does not trigger.

      • state (string) –

        The state of the scheduled action.

      • targetAction (dict) –

        A JSON format string of the Amazon Redshift Serverless API operation with input parameters. The following is an example of a target action.

        "{"CreateSnapshot": {"NamespaceName": "sampleNamespace","SnapshotName": "sampleSnapshot", "retentionPeriod": "1"}}"

        Note

        This is a Tagged Union structure. Only one of the following top level keys will be set: createSnapshot. If a client receives an unknown member it will set SDK_UNKNOWN_MEMBER as the top level key, which maps to the name or tag of the unknown member. The structure of SDK_UNKNOWN_MEMBER is as follows:

        'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}
        
        • createSnapshot (dict) –

          The parameters that you can use to configure a scheduled action to create a snapshot. For more information about creating a scheduled action, see CreateScheduledAction.

          • namespaceName (string) –

            The name of the namespace for which you want to configure a scheduled action to create a snapshot.

          • retentionPeriod (integer) –

            The retention period of the snapshot created by the scheduled action.

          • snapshotNamePrefix (string) –

            A string prefix that is attached to the name of the snapshot created by the scheduled action. The final name of the snapshot is the string prefix appended by the date and time of when the snapshot was created.

          • tags (list) –

            An array of Tag objects to associate with the snapshot.

            • (dict) –

              A map of key-value pairs.

              • key (string) –

                The key to use in the tag.

              • value (string) –

                The value of the tag.

Exceptions

  • RedshiftServerless.Client.exceptions.InternalServerException

  • RedshiftServerless.Client.exceptions.ResourceNotFoundException

  • RedshiftServerless.Client.exceptions.ConflictException

  • RedshiftServerless.Client.exceptions.ValidationException