This topic describes how to use SDK for TypeScript to query the details of an event rule.

Sample code:

import EventBridge, * as $EventBridge from '@alicloud/eventbridge';
import Util from '@alicloud/tea-util';
import Console from '@alicloud/tea-console';
import * as $tea from '@alicloud/tea-typescript';

export default class Client {

    /**
     * Use the createClient() function to initialize common request parameters.
     */
    static async createClient(): Promise<EventBridge> {
        let config = new $EventBridge.Config({ });
        // Your AccessKey ID.
        config.accessKeyId = "<accessKeyId>";
        // Your AccessKey secret.
        config.accessKeySecret = "<accessKeySecret>";
        // Your endpoint.
        config.endpoint = "<endpoint>";
        return new EventBridge(config);
    }

    static async getEventRuleSample(client: EventBridge): Promise<void> {
        try {
            let getEventRuleRequest = new $EventBridge.GetRuleRequest({ });
            getEventRuleRequest.ruleName = "myRule";
            getEventRuleRequest.eventBusName = "demo-bus";
            let resp = await client.getRule(getEventRuleRequest);
            Console.log("--------------------get rule success--------------------");
            Console.log(Util.toJSONString($tea.toMap(resp)));
        } catch (error) {
            Console.log(error.message);
        }
    }

    static async main(args: string[]): Promise<void> {
        let client = await Client.createClient();
        await Client.getEventRuleSample(client);
    }

}

Client.main(process.argv.slice(2));