This topic describes how to use SDK for Node.js.
Installation
For example, run the following npm command to install SDK for Node.js:
npm install @alicloud/fnf-2019-03-15
Alibaba Cloud SDK for Node.js is also released at https://github.com/aliyun/aliyun-openapi-nodejs-sdk.
Quick start
You must have an Alibaba Cloud account and an AccessKey pair to use SDK for Node.js. Example:
const FnFClient = require('@alicloud/fnf-2019-03-15');
async function demo() {
const client = new FnFClient({
// Manually enter the service endpoint. For more information, see API references > Request syntax > Endpoints.
endpoint: '{endpoint}',
accessKeyId: 'xxx',
accessKeySecret: 'xxx'
});
// Create a flow.
const createResp = await client.createFlow ({
Name : 'test',
Definition :
`version: v1
type: flow
steps:
- type: pass
name: pass1`,
Description : 'test',
Type : 'FDL'
});
console.log("create: %s", createResp)
// Start an execution.
const startResp = await client.startExecution ({
FlowName: 'testabc'
});
console.log("start: %s", startResp)
// Query the execution result.
const getResultResp = await client.getExecutionHistory ({
FlowName: 'test',
ExecutionName: 'xxx'
});
console.log("start: %s", getResultResp)
// Update the flow.
const res = await client.updateFlow ({
Name : 'test',
Definition :
`version: v1
type: flow
steps:
- type: pass
name: pass2`
});
console.log("%s", res)
}
demo();