This topic describes how to use SDK for Python to update the settings of an event rule.

Sample code:

# -*- coding: utf-8 -*-

from alibabacloud_eventbridge.client import Client as EventBridgeClient
from alibabacloud_eventbridge import models as event_bridge_models
from alibabacloud_tea_console.client import Client as ConsoleClient
from alibabacloud_tea_util.client import Client as UtilClient


class update_event_rule_sample(object):
    def __init__(self):
        pass

    @staticmethod
    def create_client():
        """
        Uses the create_client() function to initialize common request parameters.
        """
        config = event_bridge_models.Config(

        )
        # Your AccessKey ID.
        config.access_key_id = "<accessKeyId>"
        # Your AccessKey secret.
        config.access_key_secret = "<accessKeySecret>"
        # Your endpoint.
        config.endpoint = "<endpoint>"
        return EventBridgeClient(config)

    @staticmethod
    def update_event_rule_sample(client):
        try:
            update_event_rule_request = event_bridge_models.UpdateRuleRequest(

            )
            update_event_rule_request.event_bus_name = "demo-bus"
            update_event_rule_request.rule_name = "myRule"
            update_event_rule_request.filter_pattern = "{\"source\":[\"acs.oss\"],\"type\":[\"oss:BucketQueried:GetBucketStat\"]}"
            client.update_rule(update_event_rule_request)
            ConsoleClient.log("--------------------update rule success--------------------")
        except Exception as error:
            ConsoleClient.log(error.message)

    @staticmethod
    def main(args):
        client = update_event_rule_sample.create_client()
        update_event_rule_sample.update_event_rule_sample(client)

update_event_rule_sample.main("")