I am trying to patch(update) a job present in the cloud scheduler from a function mentioned below. This function uses api to update the Job's attribute(access_token). However its not deploying correctly. Are there any issues in code?
import base64 from pprint import pprint
from googleapiclient import discovery from oauth2client.client import GoogleCredentials
def hello_pubsub(event, context):
credentials = GoogleCredentials.get_application_default()
service = discovery.build('cloudscheduler', 'v1', credentials=credentials)
name = 'projects/XYZ/locations/TempLocation/jobs/TestTopic'
job_body = {
"name": "temp",
"description": temp,
"pubsubTarget": {
"topicName": "projects/XYZ/topics/TestTopic",
"attributes": {
"access_token": "blabla"
}
},
"httpTarget": {
"uri": "https://cloudscheduler.googleapis.com/v1/projects/XYZ/locations/TempLocation/jobs/TestTopic",
"httpMethod": "POST",
"headers": {
"Content-Type": "application/json",
},
"oauthToken": {
"serviceAccountEmail": "xyz@gmail.com",
}
}
}
request = service.projects().locations().jobs().patch(name=name, body=job_body)
response = request.execute()
pprint(response)