开发者社区 > 云原生 > Serverless > 正文

有Serverless 工作流的Node.js SDK 使用示例吗?

有Serverless 工作流的Node.js SDK 使用示例吗?

展开
收起
小天使爱美 2020-03-27 11:11:18 1175 0
1 条回答
写回答
取消 提交回答
  • 本文介绍使用 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();

    2020-03-27 11:23:15
    赞同 展开评论 打赏

快速交付实现商业价值。

相关产品

  • 函数计算
  • 相关电子书

    更多
    All in Serverless 阿里云核心产品全面升级 立即下载
    AIGC 浪潮之上,森马的 Serverless 实践之旅 立即下载
    极氪大数据 Serverless 应用实践 立即下载