This page contains code samples for Workflows. To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.
Calculate math floor
After receiving an HTTP request, extracts input from the JSON body, calculates its math.floor, and returns the result.
Generate a random number and return result in JSON
After receiving an HTTP request, this function generates a random number between 1 and 100, and then returns the number in JSON format.
Invoke a Cloud Run workload that requires authentication
Makes an authenticated request within a workflow, using OpenID Connect (OIDC) to connect with Cloud Run.
Make a call to a sample API
Makes a call to a sample API. The returned day of the week is passed to the Wikipedia API. Relevant articles on Wikipedia about the current day of the week are returned.
Multiply by 2 and return result in JSON
After receiving an HTTP request, this function extracts the input from the JSON body, multiplies it by 2, and returns the result in JSON format.
Stop a Compute Engine instance through an HTTP request
Makes an authenticated request within a workflow, using OAuth 2.0 to stop a Compute Engine instance.
Translate text using the Cloud Translation API
Makes an HTTP POST request to the Cloud Translation API to translate text from English to Russian.
Use client libraries to execute a workflow
Use client libraries to execute a workflow. Polls the workflow's execution using exponential backoff until the execution terminates and then prints the results.
View in documentation