Skip to content

Commit 46f6805

Browse files
feat!: migrate to microgenerator (#29)
* 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]>
1 parent 6570af1 commit 46f6805

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

scheduler/snippets/create_job.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def create_scheduler_job(project_id, location_id, service_id):
2727
# service_id = 'my-service'
2828

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

3232
# Construct the request body.
3333
job = {
@@ -36,15 +36,20 @@ def create_scheduler_job(project_id, location_id, service_id):
3636
'service': service_id
3737
},
3838
'relative_uri': '/log_payload',
39-
'http_method': 'POST',
39+
'http_method': 1,
4040
'body': 'Hello World'.encode()
4141
},
4242
'schedule': '* * * * *',
4343
'time_zone': 'America/Los_Angeles'
4444
}
4545

4646
# Use the client to send the job creation request.
47-
response = client.create_job(parent, job)
47+
response = client.create_job(
48+
request={
49+
"parent": parent,
50+
"job": job
51+
}
52+
)
4853

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

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

7176
# Use the client to send the job deletion request.
7277
try:
73-
client.delete_job(job)
78+
client.delete_job(name=job)
7479
print("Job deleted.")
7580
except GoogleAPICallError as e:
7681
print("Error: %s" % e)

0 commit comments

Comments
 (0)