Connector für Cloud Tasks

Workflow-Connector, der die integrierte Funktion definiert, mit der in einem Workflow auf Cloud Tasks zugegriffen wird.

Weitere Informationen

Eine ausführliche Dokumentation, die dieses Codebeispiel enthält, finden Sie hier:

Codebeispiel

YAML

# This workflow demonstrates how to use the Cloud Tasks connector:
# Create a Cloud Tasks queue and create a task in that queue
# Delete the task and then the queue
# Expected output: "SUCCESS"
- init:
    assign:
      - project_id: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}
      - location_id: "us-central1"
      - queue_id: "example-queue-id"
      - task_id: "example-task-id"
      # Replace TIME_IN_ZULU_FORMAT and CLOUD_FUNCTION_URL placeholders
      - schedule_time: "TIME_IN_ZULU_FORMAT"  # time in RFC3339 UTC "Zulu" format (eg. "2014-10-02T15:01:23Z")
      - cloud_function_url: "CLOUD_FUNCTION_URL"  # Cloud Function URL to be triggered by the task
- create_queue:
    call: googleapis.cloudtasks.v2.projects.locations.queues.create
    args:
      parent: ${"projects/" + project_id + "/locations/" + location_id}
      body:
        name: ${"projects/" + project_id + "/locations/" + location_id + "/queues/" + queue_id}
    result: queue
- create_task:
    call: googleapis.cloudtasks.v2.projects.locations.queues.tasks.create
    args:
      parent: ${queue.name}
      body:
        task:
          name: ${queue.name + "/tasks/" + task_id}
          scheduleTime: ${schedule_time}
          httpRequest:
            url: ${cloud_function_url}
            httpMethod: "GET"
    result: task
- get_task:
    call: googleapis.cloudtasks.v2.projects.locations.queues.tasks.get
    args:
      name: ${task.name}
- delete_task:
    call: googleapis.cloudtasks.v2.projects.locations.queues.tasks.delete
    args:
      name: ${task.name}
- delete_queue:
    call: googleapis.cloudtasks.v2.projects.locations.queues.delete
    args:
      name: ${queue.name}
- the_end:
    return: "SUCCESS"

Nächste Schritte

Informationen zum Suchen und Filtern von Codebeispielen für andere Google Cloud-Produkte finden Sie im Google Cloud-Beispielbrowser.