Created
April 13, 2020 09:23
-
-
Save nomtrosk/32692613907c90223e0ec144bf807314 to your computer and use it in GitHub Desktop.
Google cloud schedule Python example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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