部署您的第一个工作流

将一周中的当前日期作为搜索字词传递给 Wikipedia API。系统会返回相关 Wikipedia 文章的列表。

代码示例

Node.js

试用此示例之前,请按照《Workflows 快速入门:使用客户端库》中的 Node.js 设置说明进行操作。 如需了解详情,请参阅 Workflows Node.js API 参考文档

如需向 Workflows 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证

        },
        workflowId: WORKFLOW_ID,
      });
    }
  });

  it('should execute the quickstart', async () => {
    // Execute workflow, with long test timeout
    const result = execSync(
      `node --loader ts-node/esm ./index.ts ${PROJECT_ID} ${LOCATION_ID} ${WORKFLOW_ID}`
    );

    assert.strictEqual(
      result.length > 0,
      true,
      'Quickstart must return non-empty result'
    );
  }).timeout(5000);
});

YAML

- getCurrentTime:
    call: http.get
    args:
      url: https://timeapi.io/api/Time/current/zone?timeZone=Europe/Amsterdam
    result: currentTime
- readWikipedia:
    call: http.get
    args:
      url: https://en.wikipedia.org/w/api.php
      query:
        action: opensearch
        search: ${currentTime.body.dayOfWeek}
    result: wikiResult
- returnResult:
    return: ${wikiResult.body[1]}

后续步骤

如需搜索和过滤其他 Google Cloud 产品的代码示例,请参阅Google Cloud 示例浏览器