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

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 getEventBusSample(client: EventBridge): Promise<void> {
        try {
            let getEventBusRequest = new $EventBridge.GetEventBusRequest({ });
            getEventBusRequest.eventBusName = "demo-bus";
            let resp = await client.getEventBus(getEventBusRequest);
            Console.log("--------------------get event bus 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.getEventBusSample(client);
    }

}

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