Conditional jump to a specific step

Jumps to a specific step depending on the day of the week returned by the first step of the workflow.

Documentation pages that include this code sample

To view the code sample used in context, see the following documentation:

Code sample

YAML

- getCurrentTime:
    call: http.get
    args:
      url: https://us-central1-workflowsample.cloudfunctions.net/datetime
    result: currentTime
- conditionalSwitch:
    switch:
      - condition: ${currentTime.body.dayOfTheWeek == "Friday"}
        next: friday
      - condition: ${currentTime.body.dayOfTheWeek == "Saturday" OR currentTime.body.dayOfTheWeek == "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."

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.