1.0.0 • Published 3 years ago

@tencent-sdk/common v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Tencent Cloud FaaS SDK

This is a SDK tool for Tencent Cloud FaaS service.

Usage

Cls is the only class for create a client request instance. You can use it like below:

import { Cls } from '@tencent-sdk/cls';

const client = new Cls({
  region: 'ap-guangzhou',
  secretId: 'Please input your SecretId',
  secretKey: 'Please input your SecretKey',
  token: 'Please input your Token',
  debug: false,
});

Support methods:

getLogsetList

Get logset list:

const res = await client.getLogsetList();

createLogset

Create logset:

const res = await client.createLogset({
  logset_name: 'cls-test',
  period: 7,
});

getLogset

Get logset:

const res = await client.getLogset({
  logset_id: 'xxx-xxx',
});

deleteLogset

Delete logset:

const res = await client.deleteLogset({
  logset_id: 'xxx-xxx',
});

getTopicList

Get topic list:

const res = await client.getTopicList();

createTopic

Create topic:

const res = await client.createTopic({
  logset_id: 'xxx-xxx',
  topic_name: 'cls-test-topic',
});

getTopic

Get topic:

const res = await client.getTopic({
  topic_id: 'xxx-xxx',
});

deleteTopic

Delete topic:

const res = await client.deleteTopic({
  topic_id: 'xxx-xxx',
});

updateIndex

Update topic index:

const res = await client.updateIndex({
  topic_id: 'xxx-xxx',
  effective: true,
  rule: {
    full_text: {
      case_sensitive: true,
      tokenizer: '!@#%^&*()_="\', <>/?|\\;:\n\t\r[]{}',
    },
    key_value: {
      case_sensitive: true,
      keys: ['SCF_RetMsg'],
      types: ['text'],
      tokenizers: [' '],
    },
  },
});

getIndex

Get topic index:

const res = await client.getIndex({
  topic_id: 'xxx-xxx',
});

Custom methods

If you need methods expect above list, you can use client.request() like below:

// create cls shipper
const res = await client.request({
  path: '/shipper',
  method: 'POST',
  data: {
    topic_id: 'xxxx-xx-xx-xx-xxxxxxxx',
    bucket: 'test-1250000001',
    prefix: 'test',
    shipper_name: 'myname',
    interval: 300,
    max_size: 100,
    partition: '%Y%m%d',
    compress: {
      format: 'none',
    },
    content: {
      format: 'csv',
      csv_info: {
        print_key: true,
        keys: ['key1', 'key2'],
        delimiter: '|',
        escape_char: "'",
        non_existing_field: 'null',
      },
    },
  },
});

Options

const client = new Cls(ClsOptions);

ClsOptions for Cls Construct

NameDescriptionTypeRequiredDefault
regionrequest regionstringtrueap-guangzhou
secretIdtencent account secret idstringtrue''
secretKeytencent account secret keystringtrue''
tokentencent account tokenstringfalse''
debugwhether enable log debug infobooleanfalsefalse
timeoutrequest timeout, unit msnumberfalse5000
expireexpire time for signature, unit msnumberfalse300000

License

MIT