Batch API Connector Overview

The Workflows connector defines the built-in functions that can be used to access other Google Cloud products within a workflow.

This page provides an overview of the individual connector. There is no need to import or load connector libraries in a workflow—connectors work out of the box when used in a call step.

Batch API

An API to manage the running of batch jobs on Google Cloud Platform. To learn more, see the Batch API documentation.

Batch connector sample

YAML

# This workflow demonstrates how to use the Batch connector.
# This workflow sends a List request to Batch connector.
main:
  steps:
    - init:
        assign:
          - project: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}
          - location: ${sys.get_env("GOOGLE_CLOUD_LOCATION")}
          - jobId: "example-job"
    - create_job:
        call: googleapis.batch.v1.projects.locations.jobs.create
        args:
          parent: ${"projects/" + project + "/locations/" + location}
          jobId: ${jobId}
          body:
            priority: 99
            taskGroups:
              taskSpec:
                runnables:
                  script:
                    text: "echo Hello World!"
                computeResource:
                  cpuMilli: 2000
                  memoryMib: 16
              taskCount: 1
    - delete_job:
        call: googleapis.batch.v1.projects.locations.jobs.delete
        args:
          name: ${"projects/" + project + "/locations/" + location + "/jobs/" + jobId}

JSON

{
  "main": {
    "steps": [
      {
        "init": {
          "assign": [
            {
              "project": "${sys.get_env(\"GOOGLE_CLOUD_PROJECT_ID\")}"
            },
            {
              "location": "${sys.get_env(\"GOOGLE_CLOUD_LOCATION\")}"
            },
            {
              "jobId": "example-job"
            }
          ]
        }
      },
      {
        "create_job": {
          "call": "googleapis.batch.v1.projects.locations.jobs.create",
          "args": {
            "parent": "${\"projects/\" + project + \"/locations/\" + location}",
            "jobId": "${jobId}",
            "body": {
              "priority": 99,
              "taskGroups": {
                "taskSpec": {
                  "runnables": {
                    "script": {
                      "text": "echo Hello World!"
                    }
                  },
                  "computeResource": {
                    "cpuMilli": 2000,
                    "memoryMib": 16
                  }
                },
                "taskCount": 1
              }
            }
          }
        }
      },
      {
        "delete_job": {
          "call": "googleapis.batch.v1.projects.locations.jobs.delete",
          "args": {
            "name": "${\"projects/\" + project + \"/locations/\" + location + \"/jobs/\" + jobId}"
          }
        }
      }
    ]
  }
}

Module: googleapis.batch.v1.projects.locations

Functions
get Gets information about a location.
list Lists information about the supported locations for this service.

Module: googleapis.batch.v1.projects.locations.jobs

Functions
create Create a Job.
delete Delete a Job.
get Get a Job specified by its resource name.
list List all Jobs for a project within a region.

Module: googleapis.batch.v1.projects.locations.jobs.taskGroups.tasks

Functions
get Return a single Task.
list List Tasks associated with a job.

Module: googleapis.batch.v1.projects.locations.operations

Functions
get Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
list Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns UNIMPLEMENTED.