Reputation: 341
Using the API from their documentation page works: https://cloud.google.com/resource-manager/reference/rest/v2beta1/folders/list?apix_params=%7B%22parent%22%3A%22organizations%2F319808429458%22%7D
However, when using the API within Python, I'm presently receiving the error:
"methodResource() takes 1 positional argument but 2 were given"
My code is as follows:
credentials = ServiceAccountCredentials.from_json_keyfile_name(JSONPath)
cloudresman = discovery.build('cloudresourcemanager', 'v2beta1', credentials=credentials)
ORGID = "organizations/12345678910"
folderdicts = cloudresman.folders(ORGID).list().execute()
From what I've read online, this seems to be a problem with the class; but of course, Google have made the 'discovery' class. Am I doing something wrong? Can anyone else use the Python API to list folders within their GCP organisation?
Upvotes: 0
Views: 165
Reputation: 75810
In my code, I have this working example for a search.
...
CREDENTIALS = GoogleCredentials.get_application_default()
SERVICE_RESOURCE_MANAGER_FOLDER = discovery.build('cloudresourcemanager', 'v2', credentials=CREDENTIALS)
request = SERVICE_RESOURCE_MANAGER_FOLDER.folders().search(body=body)
response = request.execute()
return response
In your beta API, I guess that the problem is the ORGID set on the folders()
method. Did you try to set it in the list()
as the body param name in my code?
Upvotes: 1