Skip to content

Commit

Permalink
feat!: migrate to microgenerator (#29)
Browse files Browse the repository at this point in the history
* feat!: migrate to microgenerator

* chore: lint and coverage fixes

* chore: uses correct method in example

Co-authored-by: Bu Sun Kim <[email protected]>

Co-authored-by: Bu Sun Kim <[email protected]>
  • Loading branch information
danoscarmike and busunkim96 authored Aug 27, 2020
1 parent 6570af1 commit 46f6805
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions scheduler/snippets/create_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def create_scheduler_job(project_id, location_id, service_id):
# service_id = 'my-service'

# Construct the fully qualified location path.
parent = client.location_path(project_id, location_id)
parent = f"projects/{project_id}/locations/{location_id}"

# Construct the request body.
job = {
Expand All @@ -36,15 +36,20 @@ def create_scheduler_job(project_id, location_id, service_id):
'service': service_id
},
'relative_uri': '/log_payload',
'http_method': 'POST',
'http_method': 1,
'body': 'Hello World'.encode()
},
'schedule': '* * * * *',
'time_zone': 'America/Los_Angeles'
}

# Use the client to send the job creation request.
response = client.create_job(parent, job)
response = client.create_job(
request={
"parent": parent,
"job": job
}
)

print('Created job: {}'.format(response.name))
# [END cloud_scheduler_create_job]
Expand All @@ -66,11 +71,11 @@ def delete_scheduler_job(project_id, location_id, job_id):
# job_id = 'JOB_ID'

# Construct the fully qualified job path.
job = client.job_path(project_id, location_id, job_id)
job = f"projects/{project_id}/locations/{location_id}/jobs/{job_id}"

# Use the client to send the job deletion request.
try:
client.delete_job(job)
client.delete_job(name=job)
print("Job deleted.")
except GoogleAPICallError as e:
print("Error: %s" % e)
Expand Down

0 comments on commit 46f6805

Please sign in to comment.