tencentcloud-sdk-nodejs 4.1.63 → 4.1.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/common/sdk_version.js +1 -1
- package/es/services/bh/v20230418/bh_client.js +20 -2
- package/es/services/emr/v20190103/emr_client.js +161 -158
- package/es/services/kms/v20190118/kms_client.js +59 -14
- package/es/services/lke/v20231130/lke_client.js +16 -4
- package/es/services/trocket/v20230308/trocket_client.js +5 -2
- package/es/services/wedata/v20210820/wedata_client.js +10 -4
- package/package.json +1 -1
- package/tencentcloud/common/abstract_client.d.ts +111 -13
- package/tencentcloud/common/abstract_client.js +82 -15
- package/tencentcloud/common/common_client.d.ts +7 -0
- package/tencentcloud/common/common_client.js +7 -0
- package/tencentcloud/common/cvm_role_credential.d.ts +6 -0
- package/tencentcloud/common/cvm_role_credential.js +10 -1
- package/tencentcloud/common/http/http_connection.js +1 -2
- package/tencentcloud/common/interface.d.ts +35 -36
- package/tencentcloud/common/interface.js +1 -1
- package/tencentcloud/common/sdk_version.d.ts +1 -1
- package/tencentcloud/common/sdk_version.js +1 -1
- package/tencentcloud/common/sign.js +1 -1
- package/tencentcloud/common/sse_response_model.d.ts +26 -2
- package/tencentcloud/common/sse_response_model.js +17 -2
- package/tencentcloud/services/bh/v20230418/bh_client.d.ts +27 -3
- package/tencentcloud/services/bh/v20230418/bh_client.js +39 -3
- package/tencentcloud/services/bh/v20230418/bh_models.d.ts +315 -56
- package/tencentcloud/services/ccc/v20200210/ccc_models.d.ts +1 -1
- package/tencentcloud/services/cdb/v20170320/cdb_client.d.ts +25 -19
- package/tencentcloud/services/cdb/v20170320/cdb_client.js +25 -19
- package/tencentcloud/services/cdb/v20170320/cdb_models.d.ts +143 -107
- package/tencentcloud/services/csip/v20221121/csip_models.d.ts +12 -2
- package/tencentcloud/services/cvm/v20170312/cvm_models.d.ts +4 -0
- package/tencentcloud/services/cwp/v20180228/cwp_models.d.ts +44 -0
- package/tencentcloud/services/cynosdb/v20190107/cynosdb_models.d.ts +12 -0
- package/tencentcloud/services/dsgc/v20190723/dsgc_client.d.ts +1 -3
- package/tencentcloud/services/dsgc/v20190723/dsgc_client.js +1 -3
- package/tencentcloud/services/dsgc/v20190723/dsgc_models.d.ts +93 -6
- package/tencentcloud/services/emr/v20190103/emr_client.d.ts +182 -178
- package/tencentcloud/services/emr/v20190103/emr_client.js +272 -266
- package/tencentcloud/services/emr/v20190103/emr_models.d.ts +5762 -5634
- package/tencentcloud/services/ess/v20201111/ess_client.d.ts +1 -0
- package/tencentcloud/services/ess/v20201111/ess_client.js +1 -0
- package/tencentcloud/services/ess/v20201111/ess_models.d.ts +13 -3
- package/tencentcloud/services/essbasic/v20210526/essbasic_client.d.ts +1 -0
- package/tencentcloud/services/essbasic/v20210526/essbasic_client.js +1 -0
- package/tencentcloud/services/gs/v20191118/gs_models.d.ts +4 -0
- package/tencentcloud/services/kms/v20190118/kms_client.d.ts +76 -16
- package/tencentcloud/services/kms/v20190118/kms_client.js +112 -22
- package/tencentcloud/services/kms/v20190118/kms_models.d.ts +572 -53
- package/tencentcloud/services/live/v20180801/live_models.d.ts +4 -0
- package/tencentcloud/services/lke/v20231130/lke_client.d.ts +21 -5
- package/tencentcloud/services/lke/v20231130/lke_client.js +30 -6
- package/tencentcloud/services/lke/v20231130/lke_models.d.ts +5094 -4554
- package/tencentcloud/services/mqtt/v20240516/mqtt_models.d.ts +32 -0
- package/tencentcloud/services/organization/v20210331/organization_models.d.ts +4 -0
- package/tencentcloud/services/partners/v20180321/partners_models.d.ts +2 -2
- package/tencentcloud/services/postgres/v20170312/postgres_models.d.ts +2 -0
- package/tencentcloud/services/ses/v20201002/ses_models.d.ts +0 -4
- package/tencentcloud/services/tcss/v20201101/tcss_models.d.ts +4 -0
- package/tencentcloud/services/thpc/v20230321/thpc_models.d.ts +14 -2
- package/tencentcloud/services/tione/v20211111/tione_models.d.ts +4 -0
- package/tencentcloud/services/trocket/v20230308/trocket_client.d.ts +42 -20
- package/tencentcloud/services/trocket/v20230308/trocket_client.js +44 -20
- package/tencentcloud/services/trocket/v20230308/trocket_models.d.ts +198 -119
- package/tencentcloud/services/vpc/v20170312/vpc_models.d.ts +4 -0
- package/tencentcloud/services/waf/v20180125/waf_models.d.ts +33 -9
- package/tencentcloud/services/wedata/v20210820/wedata_client.d.ts +15 -7
- package/tencentcloud/services/wedata/v20210820/wedata_client.js +20 -8
- package/tencentcloud/services/wedata/v20210820/wedata_models.d.ts +256 -54
|
@@ -36,6 +36,9 @@ export class Client extends AbstractClient {
|
|
|
36
36
|
async StopWorkflowRun(req, cb) {
|
|
37
37
|
return this.request("StopWorkflowRun", req, cb);
|
|
38
38
|
}
|
|
39
|
+
async ModifyAgent(req, cb) {
|
|
40
|
+
return this.request("ModifyAgent", req, cb);
|
|
41
|
+
}
|
|
39
42
|
async CreateAttributeLabel(req, cb) {
|
|
40
43
|
return this.request("CreateAttributeLabel", req, cb);
|
|
41
44
|
}
|
|
@@ -87,8 +90,8 @@ export class Client extends AbstractClient {
|
|
|
87
90
|
async DescribeSearchStatsGraph(req, cb) {
|
|
88
91
|
return this.request("DescribeSearchStatsGraph", req, cb);
|
|
89
92
|
}
|
|
90
|
-
async
|
|
91
|
-
return this.request("
|
|
93
|
+
async DeleteDocCate(req, cb) {
|
|
94
|
+
return this.request("DeleteDocCate", req, cb);
|
|
92
95
|
}
|
|
93
96
|
async VerifyQA(req, cb) {
|
|
94
97
|
return this.request("VerifyQA", req, cb);
|
|
@@ -147,8 +150,8 @@ export class Client extends AbstractClient {
|
|
|
147
150
|
async DescribeNodeRun(req, cb) {
|
|
148
151
|
return this.request("DescribeNodeRun", req, cb);
|
|
149
152
|
}
|
|
150
|
-
async
|
|
151
|
-
return this.request("
|
|
153
|
+
async ListWorkflowRuns(req, cb) {
|
|
154
|
+
return this.request("ListWorkflowRuns", req, cb);
|
|
152
155
|
}
|
|
153
156
|
async ListQACate(req, cb) {
|
|
154
157
|
return this.request("ListQACate", req, cb);
|
|
@@ -165,6 +168,9 @@ export class Client extends AbstractClient {
|
|
|
165
168
|
async ModifyDoc(req, cb) {
|
|
166
169
|
return this.request("ModifyDoc", req, cb);
|
|
167
170
|
}
|
|
171
|
+
async DeleteAgent(req, cb) {
|
|
172
|
+
return this.request("DeleteAgent", req, cb);
|
|
173
|
+
}
|
|
168
174
|
async CreateQACate(req, cb) {
|
|
169
175
|
return this.request("CreateQACate", req, cb);
|
|
170
176
|
}
|
|
@@ -207,6 +213,9 @@ export class Client extends AbstractClient {
|
|
|
207
213
|
async ExportQAList(req, cb) {
|
|
208
214
|
return this.request("ExportQAList", req, cb);
|
|
209
215
|
}
|
|
216
|
+
async CreateAgent(req, cb) {
|
|
217
|
+
return this.request("CreateAgent", req, cb);
|
|
218
|
+
}
|
|
210
219
|
async UploadAttributeLabel(req, cb) {
|
|
211
220
|
return this.request("UploadAttributeLabel", req, cb);
|
|
212
221
|
}
|
|
@@ -285,6 +294,9 @@ export class Client extends AbstractClient {
|
|
|
285
294
|
async DescribeWorkflowRun(req, cb) {
|
|
286
295
|
return this.request("DescribeWorkflowRun", req, cb);
|
|
287
296
|
}
|
|
297
|
+
async DescribeAppAgentList(req, cb) {
|
|
298
|
+
return this.request("DescribeAppAgentList", req, cb);
|
|
299
|
+
}
|
|
288
300
|
async RetryDocAudit(req, cb) {
|
|
289
301
|
return this.request("RetryDocAudit", req, cb);
|
|
290
302
|
}
|
|
@@ -99,6 +99,9 @@ export class Client extends AbstractClient {
|
|
|
99
99
|
async DescribeMQTTMessage(req, cb) {
|
|
100
100
|
return this.request("DescribeMQTTMessage", req, cb);
|
|
101
101
|
}
|
|
102
|
+
async ChangeMigratingTopicToNextStage(req, cb) {
|
|
103
|
+
return this.request("ChangeMigratingTopicToNextStage", req, cb);
|
|
104
|
+
}
|
|
102
105
|
async DescribeConsumerLag(req, cb) {
|
|
103
106
|
return this.request("DescribeConsumerLag", req, cb);
|
|
104
107
|
}
|
|
@@ -189,8 +192,8 @@ export class Client extends AbstractClient {
|
|
|
189
192
|
async DescribeMigrationTaskList(req, cb) {
|
|
190
193
|
return this.request("DescribeMigrationTaskList", req, cb);
|
|
191
194
|
}
|
|
192
|
-
async
|
|
193
|
-
return this.request("
|
|
195
|
+
async DescribeConsumerClientList(req, cb) {
|
|
196
|
+
return this.request("DescribeConsumerClientList", req, cb);
|
|
194
197
|
}
|
|
195
198
|
async DescribeMigratingTopicStats(req, cb) {
|
|
196
199
|
return this.request("DescribeMigratingTopicStats", req, cb);
|
|
@@ -423,6 +423,9 @@ export class Client extends AbstractClient {
|
|
|
423
423
|
async DescribeDatabaseInfoList(req, cb) {
|
|
424
424
|
return this.request("DescribeDatabaseInfoList", req, cb);
|
|
425
425
|
}
|
|
426
|
+
async ModifyRuleTemplate(req, cb) {
|
|
427
|
+
return this.request("ModifyRuleTemplate", req, cb);
|
|
428
|
+
}
|
|
426
429
|
async DescribeDependOpsTasks(req, cb) {
|
|
427
430
|
return this.request("DescribeDependOpsTasks", req, cb);
|
|
428
431
|
}
|
|
@@ -462,8 +465,8 @@ export class Client extends AbstractClient {
|
|
|
462
465
|
async CreateRule(req, cb) {
|
|
463
466
|
return this.request("CreateRule", req, cb);
|
|
464
467
|
}
|
|
465
|
-
async
|
|
466
|
-
return this.request("
|
|
468
|
+
async DescribeRuleGroupSubscription(req, cb) {
|
|
469
|
+
return this.request("DescribeRuleGroupSubscription", req, cb);
|
|
467
470
|
}
|
|
468
471
|
async DescribeEvent(req, cb) {
|
|
469
472
|
return this.request("DescribeEvent", req, cb);
|
|
@@ -519,6 +522,9 @@ export class Client extends AbstractClient {
|
|
|
519
522
|
async UploadContent(req, cb) {
|
|
520
523
|
return this.request("UploadContent", req, cb);
|
|
521
524
|
}
|
|
525
|
+
async DescribeDsTaskVersionList(req, cb) {
|
|
526
|
+
return this.request("DescribeDsTaskVersionList", req, cb);
|
|
527
|
+
}
|
|
522
528
|
async DescribeCodeTemplateDetail(req, cb) {
|
|
523
529
|
return this.request("DescribeCodeTemplateDetail", req, cb);
|
|
524
530
|
}
|
|
@@ -627,8 +633,8 @@ export class Client extends AbstractClient {
|
|
|
627
633
|
async RegisterDsEventListener(req, cb) {
|
|
628
634
|
return this.request("RegisterDsEventListener", req, cb);
|
|
629
635
|
}
|
|
630
|
-
async
|
|
631
|
-
return this.request("
|
|
636
|
+
async DescribeDsTaskVersionInfo(req, cb) {
|
|
637
|
+
return this.request("DescribeDsTaskVersionInfo", req, cb);
|
|
632
638
|
}
|
|
633
639
|
async DeleteTaskDs(req, cb) {
|
|
634
640
|
return this.request("DeleteTaskDs", req, cb);
|
package/package.json
CHANGED
|
@@ -1,40 +1,124 @@
|
|
|
1
1
|
import { ClientProfile, Credential, ClientConfig, HttpProfile, DynamicCredential } from "./interface";
|
|
2
|
+
/**
|
|
3
|
+
* Callback function type for API responses
|
|
4
|
+
* @template TReuslt Type of the response data
|
|
5
|
+
*/
|
|
2
6
|
export declare type ResponseCallback<TReuslt = any> = (error: string, rep: TReuslt) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Options for HTTP requests
|
|
9
|
+
*/
|
|
3
10
|
export interface RequestOptions extends Partial<Pick<HttpProfile, "headers">> {
|
|
11
|
+
/**
|
|
12
|
+
* Whether the request is multipart
|
|
13
|
+
*/
|
|
4
14
|
multipart?: boolean;
|
|
5
15
|
/**
|
|
6
|
-
*
|
|
16
|
+
* Abort request signal
|
|
7
17
|
*/
|
|
8
18
|
signal?: AbortSignal;
|
|
9
19
|
}
|
|
10
20
|
declare type ResponseData = any;
|
|
11
21
|
/**
|
|
12
|
-
*
|
|
22
|
+
* Abstract base client for Tencent Cloud SDK
|
|
23
|
+
*
|
|
24
|
+
* This class provides common functionality for making API requests to Tencent Cloud services,
|
|
25
|
+
* including request signing, error handling, and response parsing.
|
|
13
26
|
*/
|
|
14
27
|
export declare class AbstractClient {
|
|
28
|
+
/**
|
|
29
|
+
* SDK version string
|
|
30
|
+
*/
|
|
15
31
|
sdkVersion: string;
|
|
32
|
+
/**
|
|
33
|
+
* API request path (usually "/")
|
|
34
|
+
*/
|
|
16
35
|
path: string;
|
|
36
|
+
/**
|
|
37
|
+
* User's security credentials (SecretId, SecretKey, Token)
|
|
38
|
+
*/
|
|
17
39
|
credential: Credential | DynamicCredential;
|
|
40
|
+
/**
|
|
41
|
+
* The region of the service (e.g. "ap-shanghai")
|
|
42
|
+
*/
|
|
18
43
|
region: string;
|
|
44
|
+
/**
|
|
45
|
+
* The API version of the service (e.g. "2017-03-12")
|
|
46
|
+
*/
|
|
19
47
|
apiVersion: string;
|
|
48
|
+
/**
|
|
49
|
+
* The service endpoint URL (e.g. "cvm.tencentcloudapi.com")
|
|
50
|
+
*/
|
|
20
51
|
endpoint: string;
|
|
52
|
+
/**
|
|
53
|
+
* Optional configuration instance
|
|
54
|
+
*/
|
|
21
55
|
profile: ClientProfile;
|
|
22
56
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* @param {string}
|
|
26
|
-
* @param {
|
|
27
|
-
* @param {
|
|
28
|
-
* @param {
|
|
57
|
+
* Constructs a new AbstractClient instance
|
|
58
|
+
*
|
|
59
|
+
* @param {string} endpoint - The service endpoint URL (e.g. "cvm.tencentcloudapi.com")
|
|
60
|
+
* @param {string} version - The API version of the service (e.g. "2017-03-12")
|
|
61
|
+
* @param {ClientConfig} config - Configuration object containing:
|
|
62
|
+
* @param {Credential|DynamicCredential} config.credential - Credentials for authentication
|
|
63
|
+
* @param {string} [config.region] - The region of the service (e.g. "ap-shanghai")
|
|
64
|
+
* @param {ClientProfile} [config.profile={}] - Optional client configuration profile
|
|
65
|
+
*
|
|
66
|
+
* @throws {TencentCloudSDKHttpException} If invalid language is specified in profile
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* const client = new AbstractClient(
|
|
70
|
+
* "cvm.tencentcloudapi.com",
|
|
71
|
+
* "2017-03-12",
|
|
72
|
+
* {
|
|
73
|
+
* credential: {
|
|
74
|
+
* secretId: process.env.secretId,
|
|
75
|
+
* secretKey: process.env.secretKey,
|
|
76
|
+
* },
|
|
77
|
+
* region: "ap-shanghai",
|
|
78
|
+
* profile: {}
|
|
79
|
+
* }
|
|
80
|
+
* );
|
|
29
81
|
*/
|
|
30
82
|
constructor(endpoint: string, version: string, { credential, region, profile }: ClientConfig);
|
|
83
|
+
/**
|
|
84
|
+
* Get credential information
|
|
85
|
+
* @returns {Promise<Credential>} Promise that resolves with credential information
|
|
86
|
+
*/
|
|
31
87
|
getCredential(): Promise<Credential>;
|
|
32
88
|
/**
|
|
33
|
-
*
|
|
89
|
+
* Make an API request to Tencent Cloud service
|
|
90
|
+
*
|
|
91
|
+
* @param {string} action - The API action name to call
|
|
92
|
+
* @param {any} req - The request payload/parameters
|
|
93
|
+
* @param {ResponseCallback|RequestOptions} [options] - Either request options or callback function
|
|
94
|
+
* @param {ResponseCallback} [cb] - Optional callback function for async operation
|
|
95
|
+
* @returns {Promise<ResponseData>} Promise that resolves with the API response data
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* // Using promise
|
|
99
|
+
* client.request('DescribeInstances', {Limit: 10})
|
|
100
|
+
* .then(data => console.log(data))
|
|
101
|
+
* .catch(err => console.error(err));
|
|
102
|
+
*
|
|
103
|
+
* // Using callback
|
|
104
|
+
* client.request('DescribeInstances', {Limit: 10}, (err, data) => {
|
|
105
|
+
* if (err) console.error(err);
|
|
106
|
+
* else console.log(data);
|
|
107
|
+
* });
|
|
108
|
+
*
|
|
109
|
+
* // With options
|
|
110
|
+
* client.request('DescribeInstances', {Limit: 10}, {signal: abortController.signal})
|
|
111
|
+
* .then(data => console.log(data))
|
|
112
|
+
* .catch(err => console.error(err));
|
|
34
113
|
*/
|
|
35
114
|
request(action: string, req: any, options?: ResponseCallback | RequestOptions, cb?: ResponseCallback): Promise<ResponseData>;
|
|
36
115
|
/**
|
|
37
|
-
*
|
|
116
|
+
* Make a request with octet-stream content type
|
|
117
|
+
* @param {string} action API action name
|
|
118
|
+
* @param {any} req Request data
|
|
119
|
+
* @param {ResponseCallback|RequestOptions} [options] Request options or callback
|
|
120
|
+
* @param {ResponseCallback} [cb] Callback function
|
|
121
|
+
* @returns {Promise<any>} Promise that resolves with response data
|
|
38
122
|
*/
|
|
39
123
|
requestOctetStream(action: string, req: any, options?: ResponseCallback | RequestOptions, cb?: ResponseCallback): Promise<any>;
|
|
40
124
|
/**
|
|
@@ -45,17 +129,31 @@ export declare class AbstractClient {
|
|
|
45
129
|
* @inner
|
|
46
130
|
*/
|
|
47
131
|
private doRequestWithSign3;
|
|
132
|
+
/**
|
|
133
|
+
* Parse HTTP response
|
|
134
|
+
* @param {Response} res HTTP response object
|
|
135
|
+
* @returns {Promise<ResponseData>} Promise that resolves with parsed response data
|
|
136
|
+
* @throws {TencentCloudSDKHttpException} If response contains error
|
|
137
|
+
*/
|
|
48
138
|
private parseResponse;
|
|
49
139
|
/**
|
|
50
|
-
*
|
|
140
|
+
* Merge nested data into flat structure
|
|
141
|
+
* @param {any} data Input data
|
|
142
|
+
* @param {string} [prefix=""] Key prefix
|
|
143
|
+
* @returns {any} Flattened data object
|
|
51
144
|
*/
|
|
52
145
|
private mergeData;
|
|
53
146
|
/**
|
|
54
|
-
*
|
|
147
|
+
* Format request data with required fields and signature
|
|
148
|
+
* @param {string} action API action name
|
|
149
|
+
* @param {RequestData} params Request parameters
|
|
150
|
+
* @returns {Promise<RequestData>} Promise that resolves with formatted request data
|
|
55
151
|
*/
|
|
56
152
|
private formatRequestData;
|
|
57
153
|
/**
|
|
58
|
-
*
|
|
154
|
+
* Format string for signature calculation
|
|
155
|
+
* @param {RequestData} params Request parameters
|
|
156
|
+
* @returns {string} String to be signed
|
|
59
157
|
*/
|
|
60
158
|
private formatSignString;
|
|
61
159
|
}
|
|
@@ -10,21 +10,42 @@ const tencent_cloud_sdk_exception_1 = tslib_1.__importDefault(require("./excepti
|
|
|
10
10
|
const sse_response_model_1 = require("./sse_response_model");
|
|
11
11
|
const uuid_1 = require("uuid");
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Abstract base client for Tencent Cloud SDK
|
|
14
|
+
*
|
|
15
|
+
* This class provides common functionality for making API requests to Tencent Cloud services,
|
|
16
|
+
* including request signing, error handling, and response parsing.
|
|
14
17
|
*/
|
|
15
18
|
class AbstractClient {
|
|
16
19
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @param {string}
|
|
20
|
-
* @param {
|
|
21
|
-
* @param {
|
|
22
|
-
* @param {
|
|
20
|
+
* Constructs a new AbstractClient instance
|
|
21
|
+
*
|
|
22
|
+
* @param {string} endpoint - The service endpoint URL (e.g. "cvm.tencentcloudapi.com")
|
|
23
|
+
* @param {string} version - The API version of the service (e.g. "2017-03-12")
|
|
24
|
+
* @param {ClientConfig} config - Configuration object containing:
|
|
25
|
+
* @param {Credential|DynamicCredential} config.credential - Credentials for authentication
|
|
26
|
+
* @param {string} [config.region] - The region of the service (e.g. "ap-shanghai")
|
|
27
|
+
* @param {ClientProfile} [config.profile={}] - Optional client configuration profile
|
|
28
|
+
*
|
|
29
|
+
* @throws {TencentCloudSDKHttpException} If invalid language is specified in profile
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const client = new AbstractClient(
|
|
33
|
+
* "cvm.tencentcloudapi.com",
|
|
34
|
+
* "2017-03-12",
|
|
35
|
+
* {
|
|
36
|
+
* credential: {
|
|
37
|
+
* secretId: process.env.secretId,
|
|
38
|
+
* secretKey: process.env.secretKey,
|
|
39
|
+
* },
|
|
40
|
+
* region: "ap-shanghai",
|
|
41
|
+
* profile: {}
|
|
42
|
+
* }
|
|
43
|
+
* );
|
|
23
44
|
*/
|
|
24
45
|
constructor(endpoint, version, { credential, region, profile = {} }) {
|
|
25
46
|
this.path = "/";
|
|
26
47
|
/**
|
|
27
|
-
*
|
|
48
|
+
* Credential instance
|
|
28
49
|
*/
|
|
29
50
|
if (credential && "getCredential" in credential) {
|
|
30
51
|
this.credential = credential;
|
|
@@ -37,14 +58,14 @@ class AbstractClient {
|
|
|
37
58
|
}, credential);
|
|
38
59
|
}
|
|
39
60
|
/**
|
|
40
|
-
*
|
|
61
|
+
* The region of the service
|
|
41
62
|
*/
|
|
42
63
|
this.region = region || null;
|
|
43
64
|
this.sdkVersion = "SDK_NODEJS_" + sdk_version_1.sdkVersion;
|
|
44
65
|
this.apiVersion = version;
|
|
45
66
|
this.endpoint = (profile && profile.httpProfile && profile.httpProfile.endpoint) || endpoint;
|
|
46
67
|
/**
|
|
47
|
-
*
|
|
68
|
+
* Optional configuration instance
|
|
48
69
|
* @type {ClientProfile}
|
|
49
70
|
*/
|
|
50
71
|
this.profile = {
|
|
@@ -61,6 +82,10 @@ class AbstractClient {
|
|
|
61
82
|
throw new tencent_cloud_sdk_exception_1.default(`Language invalid, choices: ${interface_1.SUPPORT_LANGUAGE_LIST.join("|")}`);
|
|
62
83
|
}
|
|
63
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Get credential information
|
|
87
|
+
* @returns {Promise<Credential>} Promise that resolves with credential information
|
|
88
|
+
*/
|
|
64
89
|
async getCredential() {
|
|
65
90
|
if ("getCredential" in this.credential) {
|
|
66
91
|
return await this.credential.getCredential();
|
|
@@ -68,7 +93,30 @@ class AbstractClient {
|
|
|
68
93
|
return this.credential;
|
|
69
94
|
}
|
|
70
95
|
/**
|
|
71
|
-
*
|
|
96
|
+
* Make an API request to Tencent Cloud service
|
|
97
|
+
*
|
|
98
|
+
* @param {string} action - The API action name to call
|
|
99
|
+
* @param {any} req - The request payload/parameters
|
|
100
|
+
* @param {ResponseCallback|RequestOptions} [options] - Either request options or callback function
|
|
101
|
+
* @param {ResponseCallback} [cb] - Optional callback function for async operation
|
|
102
|
+
* @returns {Promise<ResponseData>} Promise that resolves with the API response data
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* // Using promise
|
|
106
|
+
* client.request('DescribeInstances', {Limit: 10})
|
|
107
|
+
* .then(data => console.log(data))
|
|
108
|
+
* .catch(err => console.error(err));
|
|
109
|
+
*
|
|
110
|
+
* // Using callback
|
|
111
|
+
* client.request('DescribeInstances', {Limit: 10}, (err, data) => {
|
|
112
|
+
* if (err) console.error(err);
|
|
113
|
+
* else console.log(data);
|
|
114
|
+
* });
|
|
115
|
+
*
|
|
116
|
+
* // With options
|
|
117
|
+
* client.request('DescribeInstances', {Limit: 10}, {signal: abortController.signal})
|
|
118
|
+
* .then(data => console.log(data))
|
|
119
|
+
* .catch(err => console.error(err));
|
|
72
120
|
*/
|
|
73
121
|
async request(action, req, options, cb) {
|
|
74
122
|
if (typeof options === "function") {
|
|
@@ -86,7 +134,12 @@ class AbstractClient {
|
|
|
86
134
|
}
|
|
87
135
|
}
|
|
88
136
|
/**
|
|
89
|
-
*
|
|
137
|
+
* Make a request with octet-stream content type
|
|
138
|
+
* @param {string} action API action name
|
|
139
|
+
* @param {any} req Request data
|
|
140
|
+
* @param {ResponseCallback|RequestOptions} [options] Request options or callback
|
|
141
|
+
* @param {ResponseCallback} [cb] Callback function
|
|
142
|
+
* @returns {Promise<any>} Promise that resolves with response data
|
|
90
143
|
*/
|
|
91
144
|
async requestOctetStream(action, req, options, cb) {
|
|
92
145
|
if (typeof options === "function") {
|
|
@@ -191,6 +244,12 @@ class AbstractClient {
|
|
|
191
244
|
}
|
|
192
245
|
return this.parseResponse(res);
|
|
193
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* Parse HTTP response
|
|
249
|
+
* @param {Response} res HTTP response object
|
|
250
|
+
* @returns {Promise<ResponseData>} Promise that resolves with parsed response data
|
|
251
|
+
* @throws {TencentCloudSDKHttpException} If response contains error
|
|
252
|
+
*/
|
|
194
253
|
async parseResponse(res) {
|
|
195
254
|
const traceId = res.headers.get("x-tc-traceid");
|
|
196
255
|
if (res.status !== 200) {
|
|
@@ -216,7 +275,10 @@ class AbstractClient {
|
|
|
216
275
|
}
|
|
217
276
|
}
|
|
218
277
|
/**
|
|
219
|
-
*
|
|
278
|
+
* Merge nested data into flat structure
|
|
279
|
+
* @param {any} data Input data
|
|
280
|
+
* @param {string} [prefix=""] Key prefix
|
|
281
|
+
* @returns {any} Flattened data object
|
|
220
282
|
*/
|
|
221
283
|
mergeData(data, prefix = "") {
|
|
222
284
|
const ret = {};
|
|
@@ -234,7 +296,10 @@ class AbstractClient {
|
|
|
234
296
|
return ret;
|
|
235
297
|
}
|
|
236
298
|
/**
|
|
237
|
-
*
|
|
299
|
+
* Format request data with required fields and signature
|
|
300
|
+
* @param {string} action API action name
|
|
301
|
+
* @param {RequestData} params Request parameters
|
|
302
|
+
* @returns {Promise<RequestData>} Promise that resolves with formatted request data
|
|
238
303
|
*/
|
|
239
304
|
async formatRequestData(action, params) {
|
|
240
305
|
params.Action = action;
|
|
@@ -263,7 +328,9 @@ class AbstractClient {
|
|
|
263
328
|
return params;
|
|
264
329
|
}
|
|
265
330
|
/**
|
|
266
|
-
*
|
|
331
|
+
* Format string for signature calculation
|
|
332
|
+
* @param {RequestData} params Request parameters
|
|
333
|
+
* @returns {string} String to be signed
|
|
267
334
|
*/
|
|
268
335
|
formatSignString(params) {
|
|
269
336
|
let strParam = "";
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import { AbstractClient } from "./abstract_client";
|
|
2
|
+
/**
|
|
3
|
+
* Common client class for Tencent Cloud SDK
|
|
4
|
+
*
|
|
5
|
+
* You only need to install the tencentcloud-sdk-nodejs-common package to Make an API request to any product
|
|
6
|
+
*
|
|
7
|
+
* @see {@link https://github.com/TencentCloud/tencentcloud-sdk-nodejs/tree/master/examples/common} view exmaple
|
|
8
|
+
*/
|
|
2
9
|
export declare class CommonClient extends AbstractClient {
|
|
3
10
|
}
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommonClient = void 0;
|
|
4
4
|
const abstract_client_1 = require("./abstract_client");
|
|
5
|
+
/**
|
|
6
|
+
* Common client class for Tencent Cloud SDK
|
|
7
|
+
*
|
|
8
|
+
* You only need to install the tencentcloud-sdk-nodejs-common package to Make an API request to any product
|
|
9
|
+
*
|
|
10
|
+
* @see {@link https://github.com/TencentCloud/tencentcloud-sdk-nodejs/tree/master/examples/common} view exmaple
|
|
11
|
+
*/
|
|
5
12
|
class CommonClient extends abstract_client_1.AbstractClient {
|
|
6
13
|
}
|
|
7
14
|
exports.CommonClient = CommonClient;
|
|
@@ -7,6 +7,12 @@ interface CvmRoleCredentialResult {
|
|
|
7
7
|
Token: string;
|
|
8
8
|
Code: string;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Tencent Cloud Credential via CVM role
|
|
12
|
+
*
|
|
13
|
+
* Automatically generates temporary credentials when binding a service role to instance.
|
|
14
|
+
* @see {@link https://cloud.tencent.com/document/product/598/85616} for more information.
|
|
15
|
+
*/
|
|
10
16
|
export default class CvmRoleCredential implements DynamicCredential {
|
|
11
17
|
protected roleNameTask: Promise<string> | null;
|
|
12
18
|
protected credentialTask: Promise<CvmRoleCredentialResult> | null;
|
|
@@ -5,7 +5,14 @@ const fetch_1 = tslib_1.__importDefault(require("./http/fetch"));
|
|
|
5
5
|
const META_URL = "http://metadata.tencentyun.com/latest/meta-data/";
|
|
6
6
|
const ROLE_URL = META_URL + "cam/security-credentials/";
|
|
7
7
|
const EXPIRE_BUFFER = 30 * 1000;
|
|
8
|
+
/**
|
|
9
|
+
* Tencent Cloud Credential via CVM role
|
|
10
|
+
*
|
|
11
|
+
* Automatically generates temporary credentials when binding a service role to instance.
|
|
12
|
+
* @see {@link https://cloud.tencent.com/document/product/598/85616} for more information.
|
|
13
|
+
*/
|
|
8
14
|
class CvmRoleCredential {
|
|
15
|
+
// Method to fetch the role name from the metadata server
|
|
9
16
|
async getRoleName() {
|
|
10
17
|
const response = await fetch_1.default(ROLE_URL, {});
|
|
11
18
|
if (!response.ok) {
|
|
@@ -13,6 +20,7 @@ class CvmRoleCredential {
|
|
|
13
20
|
}
|
|
14
21
|
return await response.text();
|
|
15
22
|
}
|
|
23
|
+
// Method to fetch credentials for a given role name
|
|
16
24
|
async getRoleCredential(roleName) {
|
|
17
25
|
const response = await fetch_1.default(ROLE_URL + roleName, {});
|
|
18
26
|
if (!response.ok) {
|
|
@@ -24,6 +32,7 @@ class CvmRoleCredential {
|
|
|
24
32
|
}
|
|
25
33
|
return json;
|
|
26
34
|
}
|
|
35
|
+
// Method to get the current credential, refreshing if expired
|
|
27
36
|
async getCredential() {
|
|
28
37
|
if (!this.roleNameTask) {
|
|
29
38
|
this.roleNameTask = this.getRoleName();
|
|
@@ -33,7 +42,7 @@ class CvmRoleCredential {
|
|
|
33
42
|
this.credentialTask = this.getRoleCredential(roleName);
|
|
34
43
|
}
|
|
35
44
|
const credential = await this.credentialTask;
|
|
36
|
-
// expired
|
|
45
|
+
// Check if the credential is expired
|
|
37
46
|
if (credential.ExpiredTime * 1000 - EXPIRE_BUFFER <= Date.now()) {
|
|
38
47
|
this.credentialTask = null;
|
|
39
48
|
return this.getCredential();
|
|
@@ -34,8 +34,7 @@ class HttpConnection {
|
|
|
34
34
|
return await fetch_1.default(url, config);
|
|
35
35
|
}
|
|
36
36
|
static async doRequestWithSign3({ method, url, data, service, action, region, version, secretId, secretKey, multipart = false, timeout = 60000, token, requestClient, language, headers = {}, agent, proxy, signal, }) {
|
|
37
|
-
//
|
|
38
|
-
// 所以这里把 readStream 转为 Buffer
|
|
37
|
+
// Convert readStream to Buffer to calculate the hash of the entire body
|
|
39
38
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
40
39
|
await convertReadStreamToBuffer(data);
|
|
41
40
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|