Skip to content

Instantly share code, notes, and snippets.

@nownabe
Last active May 19, 2022 03:54
Show Gist options
  • Save nownabe/06396c5512a4ca822ceb1ba1d1af4e12 to your computer and use it in GitHub Desktop.
Save nownabe/06396c5512a4ca822ceb1ba1d1af4e12 to your computer and use it in GitHub Desktop.
Python Sample for executing Cloud Workflow
import json
from google.cloud.workflows_v1 import WorkflowsClient
from google.cloud.workflows.executions_v1 import ExecutionsClient
from google.cloud.workflows.executions_v1.types.executions import Execution
project = 'PROJECT ID'
location = 'REGION'
workflow = 'WORKFLOW NAME'
argument = {
"key1": "val1",
"key2": "val2"
}
parent = WorkflowsClient().workflow_path(project, location, workflow)
client = ExecutionsClient()
execution = Execution(argument=json.dumps(argument))
response = client.create_execution(parent=parent, execution=execution)
print(f"Created execution: {response.name}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment