Amazon CloudWatch Events

2018/11/29 - Amazon CloudWatch Events - 4 updated api methods

Changes  Update events client to latest version

DeleteRule (updated) Link ¶
Changes (request)
{'Force': 'boolean'}

Deletes the specified rule.

Before you can delete the rule, you must remove all targets, using RemoveTargets.

When you delete a rule, incoming events might continue to match to the deleted rule. Allow a short period of time for changes to take effect.

Managed rules are rules created and managed by another AWS service on your behalf. These rules are created by those other AWS services to support functionality in those services. You can delete these rules using the Force option, but you should do so only if you are sure the other service is not still using that rule.

See also: AWS API Documentation

Request Syntax

client.delete_rule(
    Name='string',
    Force=True|False
)
type Name:

string

param Name:

[REQUIRED]

The name of the rule.

type Force:

boolean

param Force:

If this is a managed rule, created by an AWS service on your behalf, you must specify Force as True to delete the rule. This parameter is ignored for rules that are not managed rules. You can check whether a rule is a managed rule by using DescribeRule or ListRules and checking the ManagedBy field of the response.

returns:

None

DescribeRule (updated) Link ¶
Changes (response)
{'ManagedBy': 'string'}

Describes the specified rule.

DescribeRule does not list the targets of a rule. To see the targets associated with a rule, use ListTargetsByRule.

See also: AWS API Documentation

Request Syntax

client.describe_rule(
    Name='string'
)
type Name:

string

param Name:

[REQUIRED]

The name of the rule.

rtype:

dict

returns:

Response Syntax

{
    'Name': 'string',
    'Arn': 'string',
    'EventPattern': 'string',
    'ScheduleExpression': 'string',
    'State': 'ENABLED'|'DISABLED',
    'Description': 'string',
    'RoleArn': 'string',
    'ManagedBy': 'string'
}

Response Structure

  • (dict) --

    • Name (string) --

      The name of the rule.

    • Arn (string) --

      The Amazon Resource Name (ARN) of the rule.

    • EventPattern (string) --

      The event pattern. For more information, see Events and Event Patterns in the Amazon CloudWatch Events User Guide.

    • ScheduleExpression (string) --

      The scheduling expression. For example, "cron(0 20 * * ? *)", "rate(5 minutes)".

    • State (string) --

      Specifies whether the rule is enabled or disabled.

    • Description (string) --

      The description of the rule.

    • RoleArn (string) --

      The Amazon Resource Name (ARN) of the IAM role associated with the rule.

    • ManagedBy (string) --

      If this is a managed rule, created by an AWS service on your behalf, this field displays the principal name of the AWS service that created the rule.

ListRules (updated) Link ¶
Changes (response)
{'Rules': {'ManagedBy': 'string'}}

Lists your Amazon CloudWatch Events rules. You can either list all the rules or you can provide a prefix to match to the rule names.

ListRules does not list the targets of a rule. To see the targets associated with a rule, use ListTargetsByRule.

See also: AWS API Documentation

Request Syntax

client.list_rules(
    NamePrefix='string',
    NextToken='string',
    Limit=123
)
type NamePrefix:

string

param NamePrefix:

The prefix matching the rule name.

type NextToken:

string

param NextToken:

The token returned by a previous call to retrieve the next set of results.

type Limit:

integer

param Limit:

The maximum number of results to return.

rtype:

dict

returns:

Response Syntax

{
    'Rules': [
        {
            'Name': 'string',
            'Arn': 'string',
            'EventPattern': 'string',
            'State': 'ENABLED'|'DISABLED',
            'Description': 'string',
            'ScheduleExpression': 'string',
            'RoleArn': 'string',
            'ManagedBy': 'string'
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • Rules (list) --

      The rules that match the specified criteria.

      • (dict) --

        Contains information about a rule in Amazon CloudWatch Events.

        • Name (string) --

          The name of the rule.

        • Arn (string) --

          The Amazon Resource Name (ARN) of the rule.

        • EventPattern (string) --

          The event pattern of the rule. For more information, see Events and Event Patterns in the Amazon CloudWatch Events User Guide.

        • State (string) --

          The state of the rule.

        • Description (string) --

          The description of the rule.

        • ScheduleExpression (string) --

          The scheduling expression. For example, "cron(0 20 * * ? *)", "rate(5 minutes)".

        • RoleArn (string) --

          The Amazon Resource Name (ARN) of the role that is used for target invocation.

        • ManagedBy (string) --

          If the rule was created on behalf of your account by an AWS service, this field displays the principal name of the service that created the rule.

    • NextToken (string) --

      Indicates whether there are additional results to retrieve. If there are no more results, the value is null.

RemoveTargets (updated) Link ¶
Changes (request)
{'Force': 'boolean'}

Removes the specified targets from the specified rule. When the rule is triggered, those targets are no longer be invoked.

When you remove a target, when the associated rule triggers, removed targets might continue to be invoked. Allow a short period of time for changes to take effect.

This action can partially fail if too many requests are made at the same time. If that happens, FailedEntryCount is non-zero in the response and each entry in FailedEntries provides the ID of the failed target and the error code.

See also: AWS API Documentation

Request Syntax

client.remove_targets(
    Rule='string',
    Ids=[
        'string',
    ],
    Force=True|False
)
type Rule:

string

param Rule:

[REQUIRED]

The name of the rule.

type Ids:

list

param Ids:

[REQUIRED]

The IDs of the targets to remove from the rule.

  • (string) --

type Force:

boolean

param Force:

If this is a managed rule, created by an AWS service on your behalf, you must specify Force as True to remove targets. This parameter is ignored for rules that are not managed rules. You can check whether a rule is a managed rule by using DescribeRule or ListRules and checking the ManagedBy field of the response.

rtype:

dict

returns:

Response Syntax

{
    'FailedEntryCount': 123,
    'FailedEntries': [
        {
            'TargetId': 'string',
            'ErrorCode': 'string',
            'ErrorMessage': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    • FailedEntryCount (integer) --

      The number of failed entries.

    • FailedEntries (list) --

      The failed target entries.

      • (dict) --

        Represents a target that failed to be removed from a rule.

        • TargetId (string) --

          The ID of the target.

        • ErrorCode (string) --

          The error code that indicates why the target removal failed. If the value is ConcurrentModificationException, too many requests were made at the same time.

        • ErrorMessage (string) --

          The error message that explains why the target removal failed.