Skip to content

Instantly share code, notes, and snippets.

@nomtrosk
Created April 13, 2020 09:23
Show Gist options
  • Select an option

  • Save nomtrosk/32692613907c90223e0ec144bf807314 to your computer and use it in GitHub Desktop.

Select an option

Save nomtrosk/32692613907c90223e0ec144bf807314 to your computer and use it in GitHub Desktop.
Google cloud schedule Python example
from google.cloud.scheduler import CloudSchedulerClient
def create_job(project_id: str, region: str, job_name: str, http_target: str):
"""
Create a job with the name in job_name invoking the url in http_target every one minute
"""
client = CloudSchedulerClient()
location_path = client.location_path(project_id, region)
job_path = client.job_path(project_id, region, job_name)
job = {
"name": job_path,
"schedule": "* * * * *",
"http_target": {"uri": http_target},
"time_zone": "UTC",
}
return client.create_job(location_path, job)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment