本文介绍如何使用TypeScript SDK删除一个事件总线。

示例代码如下:

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 {

    /**
     * Create client初始化公共请求参数。
     */
    static async createClient(): Promise<EventBridge> {
        let config = new $EventBridge.Config({ });
        // 您的AccessKey ID。
        config.accessKeyId = "<accessKeyId>";
        // 您的AccessKey Secret。
        config.accessKeySecret = "<accessKeySecret>";
        // 您的接入点。
        config.endpoint = "<endpoint>";
        return new EventBridge(config);
    }

    static async deleteEventBusSample(client: EventBridge): Promise<void> {
        try {
            let deleteEventBusRequest = new $EventBridge.DeleteEventBusRequest({ });
            deleteEventBusRequest.eventBusName = "demo-bus";
            let resp = await client.deleteEventBus(deleteEventBusRequest);
            Console.log("--------------------Delete 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.deleteEventBusSample(client);
    }

}

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