/
topic.demo.js
42 lines (36 loc) · 1.06 KB
/
topic.demo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const { tlsOpenapi } = require("@volcengine/openapi");
// topic
async function main() {
const tlsOpenapiService = tlsOpenapi.defaultService;
tlsOpenapi.setHost("your host");
tlsOpenapiService.setSecretKey("your secret key");
tlsOpenapiService.setAccessKeyId("your access key id");
// create topic
const topicCreateResp = await tlsOpenapiService.CreateTopic({
ProjectId: "project id",
ShardCount: "shard count",
TopicName: "topic name",
ttl: "topic ttl",
});
// query topic
const topicQueryResp = await tlsOpenapiService.DescribeTopic({
TopicId: "topic id",
});
// modify topic
const topicModifyResp = await tlsOpenapiService.ModifyTopic({
TopicId: "topic id",
Description: "topic description",
});
// delete topic
const topicDeleteResp = await tlsOpenapiService.DeleteTopic({
TopicId: "topic id",
});
// query topics
const topicListResp = await tlsOpenapiService.DescribeTopics({
PageNumber: 1,
PageSize: 10,
ProjectId: "project id",
TopicId: "topic id",
TopicName: "topic name",
});
}