ksyun-sdk-node 1.0.1
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/.browserslistrc +1 -0
- package/.eslintignore +1 -0
- package/.eslintrc.json +14 -0
- package/README.md +75 -0
- package/babel.config.json +11 -0
- package/dist/base/BaseClient.js +104 -0
- package/dist/index.js +41 -0
- package/dist/lib/fetch.js +35 -0
- package/dist/lib/sign.js +155 -0
- package/dist/service/Actiontrail/v20190401/index.js +58 -0
- package/dist/service/Bill/v20180601/index.js +117 -0
- package/dist/service/Bill_union/v20200101/index.js +118 -0
- package/dist/service/Bill_union/v20211209/index.js +45 -0
- package/dist/service/Ebs/v20160304/index.js +359 -0
- package/dist/service/Iam/v20151101/index.js +887 -0
- package/dist/service/Kad/v20161122/index.js +133 -0
- package/dist/service/Kead/v20200101/index.js +52 -0
- package/dist/service/Resourcemanager/v20210320/index.js +171 -0
- package/dist/service/Sts/v20151101/index.js +50 -0
- package/dist/service/Trade/v20200114/index.js +47 -0
- package/dist/service/Trade/v20200831/index.js +49 -0
- package/example/iam.js +40 -0
- package/example/res.js +43 -0
- package/package.json +33 -0
- package/src/base/BaseClient.js +92 -0
- package/src/index.js +34 -0
- package/src/lib/fetch.js +35 -0
- package/src/lib/sign.js +148 -0
- package/src/service/Actiontrail/v20190401/index.js +47 -0
- package/src/service/Bill/v20180601/index.js +111 -0
- package/src/service/Bill_union/v20200101/index.js +112 -0
- package/src/service/Bill_union/v20211209/index.js +35 -0
- package/src/service/Ebs/v20160304/index.js +348 -0
- package/src/service/Iam/v20151101/index.js +876 -0
- package/src/service/Kad/v20161122/index.js +122 -0
- package/src/service/Kead/v20200101/index.js +41 -0
- package/src/service/Resourcemanager/v20210320/index.js +161 -0
- package/src/service/Sts/v20151101/index.js +39 -0
- package/src/service/Trade/v20200114/index.js +36 -0
- package/src/service/Trade/v20200831/index.js +38 -0
package/.browserslistrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
node 10
|
package/.eslintignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
test
|
package/.eslintrc.json
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# 简介
|
|
2
|
+
|
|
3
|
+
欢迎使用金山云开发者工具套件(SDK)。为方便 NODEJS 开发者调试和接入金山云产品 API,这里向您介绍适用于 NODEJS 的金山云开发工具包,并提供首次使用开发工具包的简单示例。让您快速获取金山云 NODEJS SDK 并开始调用。
|
|
4
|
+
|
|
5
|
+
# 依赖环境
|
|
6
|
+
|
|
7
|
+
1. NODEJS 10.0.0 版本及以上
|
|
8
|
+
2. 从金山云控制台 开通相应产品
|
|
9
|
+
3. 获取 secretId、secretKey。
|
|
10
|
+
|
|
11
|
+
# 获取安装
|
|
12
|
+
|
|
13
|
+
安装 NODEJS SDK 前,先获取安全凭证。在第一次使用云 API 之前,用户首先需要在金山云控制台上申请安全凭证,安全凭证包括 secretId 和 secretKey, secretId 是用于标识 API 调用者的身份,secretKey 是用于加密签名字符串和服务器端验证签名字符串的密钥。secretKey 必须严格保管,避免泄露。
|
|
14
|
+
|
|
15
|
+
## 通过 Npm 安装
|
|
16
|
+
|
|
17
|
+
通过 npm 获取安装是使用 NODEJS SDK 的推荐方法,npm 是 NODEJS 的包管理工具。关于 npm 详细可参考[ npm 官网](https://www.npmjs.com/) 。
|
|
18
|
+
|
|
19
|
+
1. 执行以下安装命令:
|
|
20
|
+
> npm install ksyun-sdk-node --save
|
|
21
|
+
2. 在您的代码中引用对应模块代码,可参考示例。
|
|
22
|
+
|
|
23
|
+
## 通过源码包安装
|
|
24
|
+
|
|
25
|
+
1. 前往 [Github 仓库](https://github.com/kingsoftcloud/sdk-node)下载源码压缩包。
|
|
26
|
+
2. 解压源码包到您项目合适的位置。
|
|
27
|
+
3. 在您的代码中引用对应模块代码,可参考示例。
|
|
28
|
+
|
|
29
|
+
# 示例
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
const kscSdk = require('ksyun-sdk-node')
|
|
33
|
+
|
|
34
|
+
const Client = kscSdk.Iam.v20151101
|
|
35
|
+
const clientConfig = {
|
|
36
|
+
// 认证信息
|
|
37
|
+
credential: {
|
|
38
|
+
secretId: '',
|
|
39
|
+
secretKey: '',
|
|
40
|
+
},
|
|
41
|
+
// 产品地域
|
|
42
|
+
region: "cn-beijing-6",
|
|
43
|
+
// 可选配置实例
|
|
44
|
+
httpProfile: {
|
|
45
|
+
method: 'POST', // 请求方法 GET 或者 POST
|
|
46
|
+
timeout: 60, // 请求超时时间秒
|
|
47
|
+
protocol: '', // 协议 http:// 或者 https://
|
|
48
|
+
endpoint: '' // 接入点域名 如 iam.api.ksyun.com
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
let client = new Client(clientConfig)
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* client.request 参数
|
|
55
|
+
* @param {string} apiAction 接口名
|
|
56
|
+
* @param {object} data 参数
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
let apiAction = 'GetUser'
|
|
60
|
+
let data = {
|
|
61
|
+
"UserName": "test14"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
client.request(apiAction, data)
|
|
65
|
+
.then(res => res.json())
|
|
66
|
+
.then(data => {
|
|
67
|
+
console.log(JSON.stringify(data))
|
|
68
|
+
})
|
|
69
|
+
.catch(err => {
|
|
70
|
+
console.log(err)
|
|
71
|
+
})
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
# 更多示例
|
|
75
|
+
参见金山云控制台-API Explorer-对应服务-SDK示例
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.json.stringify.js");
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
|
|
7
|
+
const getSignedParams = require('../lib/sign.js').getSignedParams;
|
|
8
|
+
|
|
9
|
+
const fetch = require('../lib/fetch.js');
|
|
10
|
+
|
|
11
|
+
const dayjs = require('dayjs');
|
|
12
|
+
|
|
13
|
+
const utc = require('dayjs/plugin/utc.js');
|
|
14
|
+
|
|
15
|
+
const qs = require('qs');
|
|
16
|
+
|
|
17
|
+
dayjs.extend(utc);
|
|
18
|
+
module.exports = class BaseClient {
|
|
19
|
+
constructor(clientConfig) {
|
|
20
|
+
_defineProperty(this, "_baseConfig", {});
|
|
21
|
+
|
|
22
|
+
_defineProperty(this, "_apiList", {});
|
|
23
|
+
|
|
24
|
+
this.ak = clientConfig.credential.secretId, this.sk = clientConfig.credential.secretKey;
|
|
25
|
+
this.region = clientConfig.region;
|
|
26
|
+
this.httpProfile = clientConfig.httpProfile || {};
|
|
27
|
+
|
|
28
|
+
if (!this.ak || !this.sk) {
|
|
29
|
+
throw new Error('secretId and secretKey are required');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 发起请求
|
|
34
|
+
* @param {string} apiAction 接口名
|
|
35
|
+
* @param {object} data 参数 { body, query }
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
request(apiAction, params = {}) {
|
|
40
|
+
let apiConfig = this._apiList[apiAction];
|
|
41
|
+
let publicParams = {
|
|
42
|
+
Accesskey: this.ak,
|
|
43
|
+
Service: this._baseConfig.config.credentials.service,
|
|
44
|
+
Action: apiAction,
|
|
45
|
+
Version: apiConfig.config.query.Version,
|
|
46
|
+
Timestamp: dayjs().utc().format('YYYY-MM-DDThh:mm:ss') + 'Z',
|
|
47
|
+
SignatureVersion: '1.0',
|
|
48
|
+
SignatureMethod: 'HMAC-SHA256',
|
|
49
|
+
Region: this.region || this._baseConfig.config.credentials.region
|
|
50
|
+
};
|
|
51
|
+
let combainParams = { ...publicParams,
|
|
52
|
+
...params
|
|
53
|
+
};
|
|
54
|
+
let signedParams = getSignedParams(combainParams, this.sk);
|
|
55
|
+
let protocol = this.httpProfile.protocol || this._baseConfig.protocol;
|
|
56
|
+
let endpoint = this.httpProfile.endpoint || this._baseConfig.endpoint;
|
|
57
|
+
let method = this.httpProfile.method || apiConfig.method;
|
|
58
|
+
let url = `${protocol}${endpoint}${apiConfig.url}`;
|
|
59
|
+
|
|
60
|
+
if (['GET', 'DELETE', 'OPTION', 'HEAD'].includes(method.toUpperCase())) {
|
|
61
|
+
url += `?${qs.stringify(signedParams)}`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let headers = { ...(this._baseConfig.config.headers || {}),
|
|
65
|
+
...(apiConfig.config.headers || {}),
|
|
66
|
+
// 目前kop只支持application/x-www-form-urlencoded类型的签名解析
|
|
67
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
68
|
+
};
|
|
69
|
+
let body = this.getBody(method, headers['Content-Type'], signedParams);
|
|
70
|
+
let timeoutSecond = this.httpProfile.timeout || this._baseConfig.config.timeout;
|
|
71
|
+
return fetch(url, {
|
|
72
|
+
method: method,
|
|
73
|
+
timeout: timeoutSecond * 1000,
|
|
74
|
+
headers,
|
|
75
|
+
body
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 获取body
|
|
80
|
+
* @param {string} method 请求类型
|
|
81
|
+
* @param {string} contentType
|
|
82
|
+
* @param {object} signedParams 参数对象
|
|
83
|
+
* @returns {string}
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
getBody(method, contentType, signedParams) {
|
|
88
|
+
if (!['POST', 'PUT'].includes(method.toUpperCase())) {
|
|
89
|
+
return undefined;
|
|
90
|
+
} // 目前只有下面这两种
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
if (contentType == 'application/x-www-form-urlencoded') {
|
|
94
|
+
return qs.stringify(signedParams);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (contentType == 'application/json') {
|
|
98
|
+
return JSON.stringify(signedParams);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return JSON.stringify(signedParams);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
const path = require('path'); // /xxx/node-sdk/src/service
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
let servicePath = path.resolve(__dirname, './service'); // [Iam, Kec]
|
|
9
|
+
|
|
10
|
+
let serviceDirs = fs.readdirSync(servicePath);
|
|
11
|
+
/**
|
|
12
|
+
* {
|
|
13
|
+
* Iam: {
|
|
14
|
+
* v20150101: Client
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
module.exports = serviceDirs.reduce((acc, serviceDir) => {
|
|
20
|
+
// /xxx/node-sdk/src/service/iam
|
|
21
|
+
let versionPath = path.resolve(servicePath, serviceDir);
|
|
22
|
+
|
|
23
|
+
if (fs.statSync(versionPath).isDirectory()) {
|
|
24
|
+
// [v20151101, v20160606]
|
|
25
|
+
let versionDirs = fs.readdirSync(versionPath); // acc.Iam
|
|
26
|
+
|
|
27
|
+
acc[serviceDir] = versionDirs.reduce((accVersion, versionDir) => {
|
|
28
|
+
// /xxx/node-sdk/src/service/iam/v20151101/index.js
|
|
29
|
+
let filePath = path.resolve(versionPath, versionDir, 'index.js');
|
|
30
|
+
|
|
31
|
+
if (fs.existsSync(filePath)) {
|
|
32
|
+
// accVersion.v20151101
|
|
33
|
+
accVersion[versionDir] = require(filePath);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return accVersion;
|
|
37
|
+
}, {});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return acc;
|
|
41
|
+
}, {});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const nodeFetch = require('node-fetch');
|
|
4
|
+
|
|
5
|
+
const AbortController = require('abort-controller'); // const HttpsProxyAgent = require('https-proxy-agent')
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
let proxyConfig = {}; // if (process.env.isKscSdkTest) {
|
|
9
|
+
// 本地代理
|
|
10
|
+
// proxyConfig = {
|
|
11
|
+
// agent: new HttpsProxyAgent('http://localhost:9090')
|
|
12
|
+
// }
|
|
13
|
+
// }
|
|
14
|
+
|
|
15
|
+
module.exports = function (url, options) {
|
|
16
|
+
const controller = new AbortController();
|
|
17
|
+
|
|
18
|
+
if (options.timeout) {
|
|
19
|
+
setTimeout(() => {
|
|
20
|
+
controller.abort();
|
|
21
|
+
}, options.timeout);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return nodeFetch(url, {
|
|
25
|
+
signal: controller.signal,
|
|
26
|
+
...proxyConfig,
|
|
27
|
+
...options
|
|
28
|
+
}).catch(err => {
|
|
29
|
+
if (err.type == 'aborted') {
|
|
30
|
+
return new Error('timeout');
|
|
31
|
+
} else {
|
|
32
|
+
throw err;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
};
|
package/dist/lib/sign.js
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.array.sort.js");
|
|
4
|
+
|
|
5
|
+
const crypto = require("crypto-js"); // const qs = require("qs")
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
getSignedParams,
|
|
10
|
+
fixedEncodeURIComponent,
|
|
11
|
+
getFlatParams,
|
|
12
|
+
flatObj,
|
|
13
|
+
getFormatParams,
|
|
14
|
+
isArrayOrObjectNotNull
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* 简化版签名算法
|
|
18
|
+
* @param {*} params 参数
|
|
19
|
+
* @param {*} sk
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
function getSignedParams(params, sk) {
|
|
23
|
+
if (!sk) {
|
|
24
|
+
throw new Error('need sk');
|
|
25
|
+
} // 第零点一步:参数扁平化处理
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
let flatParams = getFlatParams(params); // 第零点二步:去除值为null的参数, boolean转字符串
|
|
29
|
+
|
|
30
|
+
flatParams = getFormatParams(flatParams); // 第一步:请求参数排序 请求参数包括公共参数和业务参数,不包含公共参数Signature。 排序规则以参数名按照字典排序.
|
|
31
|
+
|
|
32
|
+
let sortParamKeys = Object.keys(flatParams).sort(); // 第二步:请求参数编码
|
|
33
|
+
// 使用UTF-8字符集按照RFC3986规则编码请求参数和参数取值
|
|
34
|
+
// 第三步:请求参数拼接成CanonicalizedQueryString
|
|
35
|
+
// 每对URLEncode后的参数名称和参数值,用=进行连接。每对之间使用&进行连接。得到规范化请求字符串CanonicalizedQueryString
|
|
36
|
+
|
|
37
|
+
let canonicalizedQueryString = sortParamKeys.map(key => {
|
|
38
|
+
let value = flatParams[key];
|
|
39
|
+
return `${fixedEncodeURIComponent(key)}=${fixedEncodeURIComponent(value)}`;
|
|
40
|
+
}).join('&'); // 参见源码得qs的处理顺序-符合流程:1. 去除null 2. 排序、3. 编码 4. 按照url参数拼接
|
|
41
|
+
// let canonicalizedQueryString = qs.stringify(flatParams, {
|
|
42
|
+
// sort: (a, b) => a.localeCompare(b),
|
|
43
|
+
// format : 'RFC3986',
|
|
44
|
+
// skipNulls: true,
|
|
45
|
+
// arrayFormat: 'indices', // 数组转成a[0]
|
|
46
|
+
// allowDots: true, // 对象转成a.b.c
|
|
47
|
+
// } )
|
|
48
|
+
// 计算签名。
|
|
49
|
+
|
|
50
|
+
let sign = crypto.HmacSHA256(canonicalizedQueryString, sk).toString(); // 添加到请求参数
|
|
51
|
+
|
|
52
|
+
return { ...flatParams,
|
|
53
|
+
Signature: sign
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* RFC 3986
|
|
58
|
+
* https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
|
|
59
|
+
* @param {*} str
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
function fixedEncodeURIComponent(str) {
|
|
65
|
+
// encodeURIComponent比RFC 3986少了!'()*这个几个字符的转义
|
|
66
|
+
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
|
|
67
|
+
return '%' + c.charCodeAt(0).toString(16).toUpperCase();
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 格式化参数,对Array,Filter(Object),Object类型做扁平处理
|
|
72
|
+
* @example
|
|
73
|
+
* 转换前:{ arr: [1,2], filter: {1: {a: 1}} }
|
|
74
|
+
* 转换后:{ 'arr[0]':1, 'arr[1]':2, 'filter.1.a': 1 }
|
|
75
|
+
* @param {string} apiAction 接口名
|
|
76
|
+
* @param {object} params 参数值
|
|
77
|
+
* @returns 格式化后的参数
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
function getFlatParams(params) {
|
|
82
|
+
let res = {};
|
|
83
|
+
Object.keys(params).forEach(key => {
|
|
84
|
+
let value = params[key];
|
|
85
|
+
|
|
86
|
+
if (isArrayOrObjectNotNull(value)) {
|
|
87
|
+
res = { ...res,
|
|
88
|
+
...flatObj(key, params[key])
|
|
89
|
+
};
|
|
90
|
+
} else {
|
|
91
|
+
res[key] = value;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
return res;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 扁平化对象
|
|
98
|
+
* @param {string} pKey key
|
|
99
|
+
* @param {*} value 对象或者数组,非null
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
function flatObj(pKey, value) {
|
|
105
|
+
let res = {};
|
|
106
|
+
let prefixName = '';
|
|
107
|
+
Object.keys(value).forEach(key => {
|
|
108
|
+
if (Array.isArray(value)) {
|
|
109
|
+
prefixName = `${pKey}[${key}]`;
|
|
110
|
+
} else {
|
|
111
|
+
prefixName = `${pKey}.${key}`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
let childValue = value[key];
|
|
115
|
+
|
|
116
|
+
if (isArrayOrObjectNotNull(childValue)) {
|
|
117
|
+
res = { ...res,
|
|
118
|
+
...flatObj(prefixName, childValue)
|
|
119
|
+
};
|
|
120
|
+
} else {
|
|
121
|
+
res[prefixName] = childValue;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
return res;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* 1. 剔除null、undefined,
|
|
128
|
+
* 2. boolean转字符串
|
|
129
|
+
* @param {object} params 参数对象
|
|
130
|
+
* @returns {object}
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
function getFormatParams(params) {
|
|
135
|
+
Object.keys(params).forEach(key => {
|
|
136
|
+
if (params[key] == null) {
|
|
137
|
+
delete params[key];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (Object.prototype.toString.call(params[key]) == '[object Boolean]') {
|
|
141
|
+
params[key] = params[key].toString();
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
return params;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* 是否为数组或者对象,非null
|
|
148
|
+
* @param {any} value
|
|
149
|
+
* @returns {boolean}
|
|
150
|
+
*/
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
function isArrayOrObjectNotNull(value) {
|
|
154
|
+
return Array.isArray(value) || Object.prototype.toString.call(value) == '[object Object]';
|
|
155
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
|
|
5
|
+
const BaseClient = require("../../../base/BaseClient.js");
|
|
6
|
+
|
|
7
|
+
module.exports = class Client extends BaseClient {
|
|
8
|
+
constructor(...args) {
|
|
9
|
+
super(...args);
|
|
10
|
+
|
|
11
|
+
_defineProperty(this, "_baseConfig", {
|
|
12
|
+
'protocol': 'http://',
|
|
13
|
+
'endpoint': 'actiontrail.api.ksyun.com',
|
|
14
|
+
'config': {
|
|
15
|
+
'timeout': 60,
|
|
16
|
+
//设置timeout
|
|
17
|
+
'headers': {
|
|
18
|
+
'Accept': 'application/json'
|
|
19
|
+
},
|
|
20
|
+
'credentials': {
|
|
21
|
+
'region': 'cn-shanghai-3',
|
|
22
|
+
'service': 'actiontrail'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
_defineProperty(this, "_apiList", {
|
|
28
|
+
'ListOperateLogs': {
|
|
29
|
+
'url': '/',
|
|
30
|
+
'method': 'GET',
|
|
31
|
+
'config': {
|
|
32
|
+
'query': {
|
|
33
|
+
'Version': '2019-04-01',
|
|
34
|
+
'Action': 'ListOperateLogs'
|
|
35
|
+
},
|
|
36
|
+
'headers': {
|
|
37
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
'paramsType': {
|
|
41
|
+
'EventName': 'String',
|
|
42
|
+
'EventRw': 'String',
|
|
43
|
+
'ServiceName': 'String',
|
|
44
|
+
'UserName': 'String',
|
|
45
|
+
'AccessKey': 'String',
|
|
46
|
+
'EventBeginDate': 'String',
|
|
47
|
+
'EventEndDate': 'String',
|
|
48
|
+
'ResourceType': 'String',
|
|
49
|
+
'ResourceName': 'String',
|
|
50
|
+
'Page': 'String',
|
|
51
|
+
'PageSize': 'String',
|
|
52
|
+
'SearchAfter': 'String'
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
|
|
5
|
+
const BaseClient = require("../../../base/BaseClient.js");
|
|
6
|
+
|
|
7
|
+
module.exports = class Client extends BaseClient {
|
|
8
|
+
constructor(...args) {
|
|
9
|
+
super(...args);
|
|
10
|
+
|
|
11
|
+
_defineProperty(this, "_baseConfig", {
|
|
12
|
+
'protocol': 'http://',
|
|
13
|
+
'endpoint': 'bill.api.ksyun.com',
|
|
14
|
+
'config': {
|
|
15
|
+
'timeout': 60,
|
|
16
|
+
//设置timeout
|
|
17
|
+
'headers': {
|
|
18
|
+
'Accept': 'application/json'
|
|
19
|
+
},
|
|
20
|
+
'credentials': {
|
|
21
|
+
'region': 'cn-shanghai-3',
|
|
22
|
+
'service': 'bill'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
_defineProperty(this, "_apiList", {
|
|
28
|
+
'GetMonthBill': {
|
|
29
|
+
'url': '/',
|
|
30
|
+
'method': 'GET',
|
|
31
|
+
'config': {
|
|
32
|
+
'query': {
|
|
33
|
+
'Version': '2018-06-01',
|
|
34
|
+
'Action': 'GetMonthBill'
|
|
35
|
+
},
|
|
36
|
+
'headers': {
|
|
37
|
+
'Content-Type': 'application/json'
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
'paramsType': {
|
|
41
|
+
'Action': 'String'
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
'GetPostpayDetailBill': {
|
|
45
|
+
'url': '/',
|
|
46
|
+
'method': 'GET',
|
|
47
|
+
'config': {
|
|
48
|
+
'query': {
|
|
49
|
+
'Version': '2018-06-01',
|
|
50
|
+
'Action': 'GetPostpayDetailBill'
|
|
51
|
+
},
|
|
52
|
+
'headers': {
|
|
53
|
+
'Content-Type': 'application/json'
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
'paramsType': {}
|
|
57
|
+
},
|
|
58
|
+
'GetPostpayDetailBillCSV': {
|
|
59
|
+
'url': '/',
|
|
60
|
+
'method': 'GET',
|
|
61
|
+
'config': {
|
|
62
|
+
'query': {
|
|
63
|
+
'Version': '2018-06-01',
|
|
64
|
+
'Action': 'GetPostpayDetailBillCSV'
|
|
65
|
+
},
|
|
66
|
+
'headers': {
|
|
67
|
+
'Content-Type': 'application/json'
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
'paramsType': {}
|
|
71
|
+
},
|
|
72
|
+
'GetProductCode': {
|
|
73
|
+
'url': '/',
|
|
74
|
+
'method': 'GET',
|
|
75
|
+
'config': {
|
|
76
|
+
'query': {
|
|
77
|
+
'Version': '2018-06-01',
|
|
78
|
+
'Action': 'GetProductCode'
|
|
79
|
+
},
|
|
80
|
+
'headers': {
|
|
81
|
+
'Content-Type': 'application/json'
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
'paramsType': {}
|
|
85
|
+
},
|
|
86
|
+
'getMonthConsume': {
|
|
87
|
+
'url': '/',
|
|
88
|
+
'method': 'GET',
|
|
89
|
+
'config': {
|
|
90
|
+
'query': {
|
|
91
|
+
'Version': '2018-06-01',
|
|
92
|
+
'Action': 'getMonthConsume'
|
|
93
|
+
},
|
|
94
|
+
'headers': {
|
|
95
|
+
'Content-Type': 'application/json'
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
'paramsType': {}
|
|
99
|
+
},
|
|
100
|
+
'getPostpayDetailConsume': {
|
|
101
|
+
'url': '/',
|
|
102
|
+
'method': 'GET',
|
|
103
|
+
'config': {
|
|
104
|
+
'query': {
|
|
105
|
+
'Version': '2018-06-01',
|
|
106
|
+
'Action': 'getPostpayDetailConsume'
|
|
107
|
+
},
|
|
108
|
+
'headers': {
|
|
109
|
+
'Content-Type': 'application/json'
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
'paramsType': {}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
};
|