qcloudapi-sdk
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -78,2 +78,4 @@ var request = require('request') | ||
var isAPIv3 = !!data.Version | ||
param = dotQs.flatten(param) | ||
@@ -96,3 +98,4 @@ | ||
// 排除上传文件的参数 | ||
if (method === 'POST' && val && val[0] === '@') { | ||
// modify 2018-10-25 云APIv3调用不排除‘@’字符开头的参数 | ||
if (!isAPIv3 && method === 'POST' && val && val[0] === '@') { | ||
return | ||
@@ -99,0 +102,0 @@ } |
{ | ||
"name": "qcloudapi-sdk", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "腾讯云 API SDK for node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,8 +0,6 @@ | ||
Tencent Qcloud API SDK for node.js | ||
================================== | ||
# Tencent Qcloud API SDK for node.js | ||
`qcloudapi-sdk` 是[腾讯云 API 2.0](https://www.qcloud.com/doc/api) 的 node.js SDK 工具包. | ||
`qcloudapi-sdk` 是[腾讯云 API 2.0/3.0](https://www.qcloud.com/doc/api) 的 node.js SDK 工具包. | ||
安装 | ||
---- | ||
## 安装 | ||
@@ -13,62 +11,68 @@ ```bash | ||
使用 | ||
---- | ||
## 使用 | ||
1. 使用之前请在腾讯云的[云 API 控制台](https://console.qcloud.com/capi)中创建自己的安全凭证(SecretId 和 SecretKey). SecretKey 要严格保管, 避免泄露. | ||
2. 安装并引入本 SDK. | ||
1. 使用之前请在腾讯云的[云 API 控制台](https://console.qcloud.com/capi)中创建自己的安全凭证(SecretId 和 SecretKey). SecretKey 要严格保管, 避免泄露. | ||
2. 安装并引入本 SDK. | ||
示例 | ||
---- | ||
## 示例 | ||
```js | ||
var Capi = require('qcloudapi-sdk') | ||
var Capi = require("qcloudapi-sdk"); | ||
//通过构造函数传入的参数将作为默认配置 | ||
var capi = new Capi({ | ||
SecretId: 'Your SecretId here', | ||
SecretKey: 'Your SecretKey here', | ||
serviceType: 'account' | ||
}) | ||
SecretId: "Your SecretId here", | ||
SecretKey: "Your SecretKey here", | ||
serviceType: "account" | ||
}); | ||
capi.request({ | ||
Region: 'gz', | ||
Action: 'DescribeProject', | ||
otherParam1: 'otherParam1', | ||
otherParam2: 'otherParam2' | ||
}, function(error, data) { | ||
console.log(data) | ||
}) | ||
capi.request( | ||
{ | ||
Region: "gz", | ||
Action: "DescribeProject", | ||
otherParam1: "otherParam1", | ||
otherParam2: "otherParam2" | ||
}, | ||
function(error, data) { | ||
console.log(data); | ||
} | ||
); | ||
//传入配置以覆盖默认项 | ||
capi.request({ | ||
Region: 'gz', | ||
Action: 'DescribeInstances', | ||
otherParam1: 'otherParam1', | ||
otherParam2: 'otherParam2' | ||
}, { | ||
serviceType: 'cvm' | ||
}, function(error, data) { | ||
console.log(data) | ||
}) | ||
capi.request( | ||
{ | ||
Region: "gz", | ||
Action: "DescribeInstances", | ||
otherParam1: "otherParam1", | ||
otherParam2: "otherParam2" | ||
}, | ||
{ | ||
serviceType: "cvm" | ||
}, | ||
function(error, data) { | ||
console.log(data); | ||
} | ||
); | ||
//生成 querystring | ||
var qs = capi.generateQueryString({ | ||
Region: 'gz', | ||
Action: 'DescribeInstances', | ||
otherParam1: 'otherParam1', | ||
otherParam2: 'otherParam2' | ||
}, { | ||
serviceType: 'cvm' | ||
}) | ||
var qs = capi.generateQueryString( | ||
{ | ||
Region: "gz", | ||
Action: "DescribeInstances", | ||
otherParam1: "otherParam1", | ||
otherParam2: "otherParam2" | ||
}, | ||
{ | ||
serviceType: "cvm" | ||
} | ||
); | ||
//'Region=gz&SecretId=&Timestamp=1449461969&Nonce=20874&Action=DescribeInstances&otherParam1=otherParam1&otherParam2=otherParam2&Signature=r%2Fa9nqMxEIn5RsMjqmIksQ5XcYc%3D' | ||
``` | ||
SDK API | ||
------- | ||
## SDK API | ||
请访问 [api.md](./api.md) | ||
资源 | ||
---- | ||
## 资源 | ||
- [API 列表](https://www.qcloud.com/doc/api) | ||
- [API 列表](https://www.qcloud.com/doc/api) |
@@ -192,1 +192,26 @@ var assert = require('assert') | ||
) | ||
// 支持腾讯云 API 3.0的请求 | ||
var capiv3 = new Capi({ | ||
SecretId: config.SecretId, | ||
SecretKey: config.SecretKey, | ||
baseHost: 'tencentcloudapi.com', | ||
path: '/' | ||
}) | ||
capiv3.request( | ||
{ | ||
Region: 'ap-guangzhou', | ||
Action: 'DescribeInstances', | ||
Version: '2017-03-12' | ||
}, | ||
{ | ||
serviceType: 'cvm', | ||
method: 'post' | ||
}, | ||
function(error, data) { | ||
assert.equal(error, null) | ||
assert.equal(typeof data, 'object') | ||
assert.equal(data.Response.Error, null) | ||
} | ||
) |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
28736
403
78