1

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)
ZAIN Ali
  • 95
  • 9
  • Here is the error I found in the logs Downloading oauth2client-4.0.0-py2.py3-none-any.whl (184 kB) ERROR: Could not find a version that satisfies the requirement googleapiclient (from -r requirements.txt (line 4)) (from versions: none) ERROR: No matching distribution found for googleapiclient (from -r requirements.txt (line 4)); Error ID: 0ea8a540 – ZAIN Ali Jan 07 '22 at 06:16
  • Try pip install google-api-python-client as specified [here](https://github.com/googleapis/google-api-python-client). Or else you can checkout the [thread1](https://stackoverflow.com/questions/61510900/the-google-api-python-client-distribution-was-not-found-and-is-required-by-the) & [thread2](https://stackoverflow.com/questions/32302379/could-not-find-a-version-that-satisfies-the-requirement-package). – Akshansha Singhal Jan 07 '22 at 09:52

1 Answers1

1

As mentioned by @Akshansha Singhal, please refer here.

For "googleapiclient", the latest and default Version 2.0 is supported only on Python 3.6+.

If on Python 2.7+, use version 1.x.

You can configure these version dependencies in your "requirements.txt".

Gourav B
  • 864
  • 5
  • 17