1.18.2 • Published 2 days ago
@volcengine/openapi v1.18.2
Volcano Engine OpenAPI node sdk
Requirements:
- Node.js >= 12
Installation
npm install -S @volcengine/openapi
Basic Usage
1. Setting OpenAPI service's AK&SK
Available in three settings
1. Use API to set AK&SK
// Use the default service instance. You can also create a new instance.
// `const iamService = new iam.IamService();`
const iamService = iam.defaultService;
// set aksk
iamService.setAccessKeyId(AccessKeyId);
iamService.setSecretKey(SecretKey);
// If you use sts to request, you need to set up `SessionToken` after aksk is set
iamService.setSessionToken(SessionToken);
2. Use environment variables to set AK & SK
VOLC_ACCESSKEY="your ak" VOLC_SECRETKEY="your sk"
3. Use configuration file
Put it in ~/.volc/config
in json format, the format is:
{"VOLC_ACCESSKEY":"your ak","VOLC_SECRETKEY":"your sk"}
Request OpenAPI
Take the ListUsers API of the iam service as an example
import { iam } from'@volcengine/openapi';
async function main(AccessKeyId, SecretKey) {
// Use the default service instance. You can also create a new instance.
// `const iamService = new iam.IamService();`
const iamService = iam.defaultService;
// set aksk
iamService.setAccessKeyId(AccessKeyId);
iamService.setSecretKey(SecretKey);
// Request OpenAPI
const usersResponse = await iamService.ListUsers({
Limit: 10,
Offset: 0,
});
}
OpenAPI signature method
By HTTP Header
import {Signer} from '@volcengine/openapi';
// http request data
const openApiRequestData: RequestObj = {
region: 'cn-north-1',
method: 'GET',
// [optional] http request url query
params: {},
// http request headers
headers: {},
// [optional] http request body
body: "",
}
const signer = new Signer(openApiRequestData, "iam");
// sign
signer.addAuthorization({accessKeyId, secretKey, sessionToken});
// Print signed headers
console.log(openApiRequestData.headers);
By HTTP Query
const openApiRequestData: RequestObj = {
method: "POST",
region: "cn-north-1",
params: {
Action: "AssumeRole",
Version: "2018-01-01",
RoleTrn: "trn:iam::200:role/STSRole",
RoleSessionName: "test",
},
}
const credentials: Credentials = {
accessKeyId: VOLC_ACCESSKEY,
secretKey: VOLC_SECRETKEY,
sessionToken: "",
}
const signer = new Signer(openApiRequestData, "sts");
const signedQueryString = signer.getSignUrl(credentials);
1.18.2
2 days ago
1.18.1
21 days ago
1.18.0
30 days ago
1.17.0
1 month ago
1.17.0-alpha.0
4 months ago
1.16.0
4 months ago
1.15.0
4 months ago
1.14.1
5 months ago
1.14.0
6 months ago
1.13.0
6 months ago
1.11.2
7 months ago
1.12.0
7 months ago
1.11.1
9 months ago
1.10.2
10 months ago
1.11.0
9 months ago
1.9.3
12 months ago
1.10.0
11 months ago
1.9.1
12 months ago
1.9.0
12 months ago
1.8.0
1 year ago
1.7.1
1 year ago
1.7.0
1 year ago
1.6.1
1 year ago
1.5.2
2 years ago
1.5.1
2 years ago
1.5.0
2 years ago
1.4.1
2 years ago
1.4.0
2 years ago
1.2.3
2 years ago
1.2.0
2 years ago
1.1.4
2 years ago
1.2.2
2 years ago
1.1.3
2 years ago
1.2.1
2 years ago
1.1.2
2 years ago
1.1.1
3 years ago
1.0.10
3 years ago
1.0.9
3 years ago
1.0.8
3 years ago
1.0.7
3 years ago
1.0.6
3 years ago
1.0.5
3 years ago
1.0.4
3 years ago
1.0.3
3 years ago
1.0.2
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago
0.0.0
3 years ago
0.0.0-alpha.1
3 years ago
0.0.0-alpha.0
3 years ago