执行条件跳转操作跳到特定步骤

根据工作流的第一步返回的星期几,跳转到特定步骤。

深入探索

如需查看包含此代码示例的详细文档,请参阅以下内容:

代码示例

YAML

- getCurrentTime:
    call: http.get
    args:
      url: https://timeapi.io/api/Time/current/zone?timeZone=Europe/Amsterdam
    result: currentTime
- conditionalSwitch:
    switch:
      - condition: ${currentTime.body.dayOfWeek == "Friday"}
        next: friday
      - condition: ${currentTime.body.dayOfWeek == "Saturday" or currentTime.body.dayOfWeek == "Sunday"}
        next: weekend
    next: workWeek
- friday:
    return: "It's Friday! Almost the weekend!"
- weekend:
    return: "It's the weekend!"
- workWeek:
    return: "It's the work week."

后续步骤

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