本文介绍使用Node.js SDK的详细流程,包括安装和快速使用两部分。
安装
SDK使用npm安装,示例如下。
npm install @alicloud/fnf-2019-03-15
另外,Alibaba Cloud SDK for Node.js也会发布在https://github.com/aliyun/aliyun-openapi-nodejs-sdk。
快速使用
在您开始之前,您需要注册阿里云账号并获取您的凭证。简单示例如下。
const FnFClient = require('@alicloud/fnf-2019-03-15');
async function demo() {
const client = new FnFClient({
// 需要手动填写服务地址,请参考API参考-调用方式-接入地址
endpoint: '{endpoint}',
accessKeyId: 'xxx',
accessKeySecret: 'xxx'
});
// 创建流程
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)
// 开始一次执行
const startResp = await client.startExecution ({
FlowName: 'testabc'
});
console.log("start: %s", startResp)
// 查询执行结果
const getResultResp = await client.getExecutionHistory ({
FlowName: 'test',
ExecutionName: 'xxx'
});
console.log("start: %s", getResultResp)
// 更新流程
const res = await client.updateFlow ({
Name : 'test',
Definition :
`version: v1
type: flow
steps:
- type: pass
name: pass2`
});
console.log("%s", res)
}
demo();