tencentcloud-sdk-nodejs-common

  • Version 4.1.220
  • Published
  • 114 kB
  • 9 dependencies
  • Apache-2.0 license

Install

npm i tencentcloud-sdk-nodejs-common
yarn add tencentcloud-sdk-nodejs-common
pnpm add tencentcloud-sdk-nodejs-common

Overview

腾讯云 API NODEJS SDK

Index

Variables

variable SUPPORT_LANGUAGE_LIST

const SUPPORT_LANGUAGE_LIST: string[];
  • Supported values for ClientProfile.language property

Classes

class AbstractClient

class AbstractClient {}
  • Abstract base client for Tencent Cloud SDK

    This class provides common functionality for making API requests to Tencent Cloud services, including request signing, error handling, and response parsing.

constructor

constructor(
endpoint: string,
version: string,
{ credential, region, profile }: ClientConfig
);
  • Constructs a new AbstractClient instance

    Parameter endpoint

    The service endpoint URL (e.g. "cvm.tencentcloudapi.com")

    Parameter version

    The API version of the service (e.g. "2017-03-12")

    Parameter config

    Configuration object containing:

    Parameter

    {Credential|DynamicCredential} config.credential - Credentials for authentication

    Parameter

    {string} [config.region] - The region of the service (e.g. "ap-shanghai")

    Parameter

    {ClientProfile} [config.profile={}] - Optional client configuration profile

    Throws

    {TencentCloudSDKHttpException} If invalid language is specified in profile

    Example 1

    const client = new AbstractClient( "cvm.tencentcloudapi.com", "2017-03-12", { credential: { secretId: process.env.secretId, secretKey: process.env.secretKey, }, region: "ap-shanghai", profile: {} } );

property apiVersion

apiVersion: string;
  • The API version of the service (e.g. "2017-03-12")

property credential

credential: Credential | DynamicCredential;
  • User's security credentials (SecretId, SecretKey, Token)

property endpoint

endpoint: string;
  • The service endpoint URL (e.g. "cvm.tencentcloudapi.com")

property path

path: string;
  • API request path (usually "/")

property profile

profile: ClientProfile;
  • Optional configuration instance

property region

region: string;
  • The region of the service (e.g. "ap-shanghai")

property sdkVersion

sdkVersion: string;
  • SDK version string

method getCredential

getCredential: () => Promise<Credential>;
  • Get credential information

    Returns

    {Promise} Promise that resolves with credential information

method request

request: (
action: string,
req: any,
options?: ResponseCallback | RequestOptions,
cb?: ResponseCallback
) => Promise<ResponseData>;
  • Make an API request to Tencent Cloud service

    Parameter action

    The API action name to call

    Parameter req

    The request payload/parameters

    Parameter options

    Either request options or callback function

    Parameter cb

    Optional callback function for async operation

    Returns

    {Promise} Promise that resolves with the API response data

    Example 1

    // Using promise client.request('DescribeInstances', {Limit: 10}) .then(data => console.log(data)) .catch(err => console.error(err));

    // Using callback client.request('DescribeInstances', {Limit: 10}, (err, data) => { if (err) console.error(err); else console.log(data); });

    // With options client.request('DescribeInstances', {Limit: 10}, {signal: abortController.signal}) .then(data => console.log(data)) .catch(err => console.error(err));

method requestOctetStream

requestOctetStream: (
action: string,
req: any,
options?: ResponseCallback | RequestOptions,
cb?: ResponseCallback
) => Promise<any>;
  • Make a request with octet-stream content type

    Parameter action

    API action name

    Parameter req

    Request data

    Parameter options

    Request options or callback

    Parameter cb

    Callback function

    Returns

    {Promise} Promise that resolves with response data

class BasicCredential

class BasicCredential implements Credential {}
  • Basic credential with secret id and secret key

constructor

constructor(secretId: string, secretKey: string, token?: string);

    property secretId

    readonly secretId: string;

      property secretKey

      readonly secretKey: string;

        property token

        readonly token?: string;

          class CommonClient

          class CommonClient extends AbstractClient {}

          class CvmRoleCredential

          class CvmRoleCredential implements DynamicCredential {}

          property credentialTask

          protected credentialTask: Promise<CvmRoleCredentialResult>;

            property roleNameTask

            protected roleNameTask: Promise<string>;

              method getCredential

              getCredential: () => Promise<Credential>;

                method getRoleCredential

                protected getRoleCredential: (
                roleName: string
                ) => Promise<CvmRoleCredentialResult>;

                  method getRoleName

                  protected getRoleName: () => Promise<string>;

                    class DefaultCredentialProvider

                    class DefaultCredentialProvider implements DynamicCredential {}
                    • Tencent Cloud DefaultCredentialProvider

                    constructor

                    constructor();

                      method getCredential

                      getCredential: () => Promise<Credential>;

                        class EnvironmentVariableCredential

                        class EnvironmentVariableCredential implements DynamicCredential {}
                        • Environment variable credential Get credential from environment variables: - TENCENTCLOUD_SECRET_ID - TENCENTCLOUD_SECRET_KEY - TENCENTCLOUD_SESSION_TOKEN (optional)

                        method getCredential

                        getCredential: () => Promise<Credential>;

                          class OIDCRoleArnCredential

                          class OIDCRoleArnCredential implements DynamicCredential {}

                          constructor

                          constructor();
                          • Constructs a new OIDCRoleArnCredential instance

                            Parameter clientConfig

                            Optional request client Configuration object

                            Parameter assumeRoleParams

                            Optional request parameters of the AssumeRole interface

                            See Also

                          constructor

                          constructor(
                          clientConfig: ClientConfig,
                          assumeRoleWithWebIdentityParams: AssumeRoleParams
                          );

                            property credentialTask

                            protected credentialTask: Promise<CredentialResult>;

                              property expirationReservationTime

                              protected expirationReservationTime: number;

                                property region

                                protected region: string;

                                  method getCredential

                                  getCredential: () => Promise<Credential>;

                                    method getCredentialWithStsAssumeRoleWithWebIdentity

                                    protected getCredentialWithStsAssumeRoleWithWebIdentity: () => Promise<CredentialResult>;

                                      class ProfileCredential

                                      class ProfileCredential implements DynamicCredential {}
                                      • Profile credential Get credential from profile file ~/.tencentcloud/credentials or /etc/tencentcloud/credentials example credentials file: [default] secret_id = your-secret-id secret_key = your-secret-key

                                      method getCredential

                                      getCredential: () => Promise<Credential>;

                                        class STSCredential

                                        class STSCredential implements DynamicCredential {}

                                        constructor

                                        constructor(clientConfig: ClientConfig, assumeRoleParams: AssumeRoleParams);
                                        • Constructs a new STSCredential instance

                                          Parameter clientConfig

                                          Request client Configuration object

                                          Parameter assumeRoleParams

                                          Request parameters of the AssumeRole interface

                                          See Also

                                        property credentialTask

                                        credentialTask: Promise<CredentialResult>;

                                          method getCredential

                                          getCredential: () => Promise<Credential>;

                                            method getCredentialWithStsAssumeRole

                                            protected getCredentialWithStsAssumeRole: () => Promise<CredentialResult>;

                                              Interfaces

                                              interface ClientConfig

                                              interface ClientConfig {}
                                              • Configuration type for initializing client object

                                              property credential

                                              credential: Credential | DynamicCredential;
                                              • Parameter credential

                                                Authentication information

                                              property profile

                                              profile?: ClientProfile;
                                              • Parameter profile

                                                Optional configuration instance Optional, can be skipped if no special requirements

                                              property region

                                              region?: string;
                                              • Parameter region

                                                Product region Required for region-specific products (e.g. CVM), optional for non-region products (e.g. SMS)

                                              interface ClientProfile

                                              interface ClientProfile {}
                                              • Optional configuration instance

                                              property httpProfile

                                              httpProfile?: HttpProfile;
                                              • HTTP related options instance {HttpProfile} Optional

                                              property language

                                              language?: 'zh-CN' | 'en-US';
                                              • Language field attached to API requests {"zh-CN" | "en-US"} Optional

                                              property signMethod

                                              signMethod?: 'TC3-HMAC-SHA256' | 'HmacSHA256' | 'HmacSHA1';
                                              • Signature method (TC3-HMAC-SHA256 HmacSHA1 HmacSHA256) {string} Optional

                                              interface Credential

                                              interface Credential {}
                                              • Credential information class

                                              property secretId

                                              secretId?: string;
                                              • Tencent Cloud account secretId and secretKey Optional, mutually exclusive with token

                                              property secretKey

                                              secretKey?: string;
                                              • Tencent Cloud account secretKey Optional, mutually exclusive with token

                                              property token

                                              token?: string;
                                              • Tencent Cloud account token Optional, mutually exclusive with secretId

                                              interface CredentialResult

                                              interface CredentialResult {}

                                                property Expiration

                                                Expiration: string;

                                                  property ExpiredTime

                                                  ExpiredTime: number;

                                                    property TmpSecretId

                                                    TmpSecretId: string;

                                                      property TmpSecretKey

                                                      TmpSecretKey: string;

                                                        property Token

                                                        Token: string;

                                                          interface DynamicCredential

                                                          interface DynamicCredential {}
                                                          • Dynamic credential information

                                                          method getCredential

                                                          getCredential: () => Promise<Credential>;

                                                            interface HttpProfile

                                                            interface HttpProfile {}

                                                              property agent

                                                              agent?: Agent;
                                                              • Advanced request agent, e.g. new HttpsProxyAgent("http://127.0.0.1:8899")

                                                                Higher priority than proxy configuration

                                                              property endpoint

                                                              endpoint?: string;
                                                              • The service endpoint URL (e.g. "cvm.tencentcloudapi.com") {string} Optional

                                                              property headers

                                                              headers?: Record<string, string>;
                                                              • Custom headers, e.g. { "X-TC-TraceId": "ffe0c072-8a5d-4e17-8887-a8a60252abca" } {Record<string, string>} Optional

                                                              property protocol

                                                              protocol?: string;
                                                              • Protocol, currently supports "https://" {string} Optional

                                                              property proxy

                                                              proxy?: string;
                                                              • HTTP request proxy, e.g. "http://127.0.0.1:8899"

                                                              property reqMethod

                                                              reqMethod?: 'POST' | 'GET';
                                                              • Request method {"POST" | "GET"} Optional

                                                              property reqTimeout

                                                              reqTimeout?: number;
                                                              • Request timeout in seconds, default 60s {number} Optional

                                                              interface RequestOptions

                                                              interface RequestOptions extends Partial<Pick<HttpProfile, 'headers'>> {}
                                                              • Options for HTTP requests

                                                              property multipart

                                                              multipart?: boolean;
                                                              • Whether the request is multipart

                                                              property signal

                                                              signal?: AbortSignal;
                                                              • Abort request signal

                                                              property skipSign

                                                              skipSign?: boolean;
                                                              • Set Authorization with SKIP false

                                                              Type Aliases

                                                              type ResponseCallback

                                                              type ResponseCallback<TReuslt = any> = (error: string, rep: TReuslt) => void;
                                                              • Callback function type for API responses TReuslt Type of the response data

                                                              Package Files (6)

                                                              Dependencies (9)

                                                              Dev Dependencies (19)

                                                              Peer Dependencies (0)

                                                              No peer dependencies.

                                                              Badge

                                                              To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                              You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/tencentcloud-sdk-nodejs-common.

                                                              • Markdown
                                                                [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/tencentcloud-sdk-nodejs-common)
                                                              • HTML
                                                                <a href="https://www.jsdocs.io/package/tencentcloud-sdk-nodejs-common"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>