Python 通过API列出GCP文件夹-“;methodResource()接受1个位置参数,但给出了2个;

Python 通过API列出GCP文件夹-“;methodResource()接受1个位置参数,但给出了2个;,python,api,google-cloud-platform,Python,Api,Google Cloud Platform,使用其文档页面中的API可以: 但是,在Python中使用API时,我目前收到了错误: “methodResource()接受1个位置参数,但提供了2个” 我的代码如下: credentials = ServiceAccountCredentials.from_json_keyfile_name(JSONPath) cloudresman = discovery.build('cloudresourcemanager', 'v2beta1', credentials=credentials) O

使用其文档页面中的API可以:

但是,在Python中使用API时,我目前收到了错误:

“methodResource()接受1个位置参数,但提供了2个”

我的代码如下:

credentials = ServiceAccountCredentials.from_json_keyfile_name(JSONPath)
cloudresman = discovery.build('cloudresourcemanager', 'v2beta1', credentials=credentials)
ORGID = "organizations/12345678910"
folderdicts = cloudresman.folders(ORGID).list().execute()

从我在网上看到的情况来看,这似乎是课堂上的一个问题;但当然,谷歌已经推出了“发现”类。我做错什么了吗?其他人是否可以使用Python API列出GCP组织内的文件夹?

在我的代码中,我有一个搜索示例

...
    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

在beta API中,我想问题在于
folders()
方法上的ORGID设置。您是否尝试在
list()
中将其设置为我代码中的body参数名称?

Hmm,这很奇怪。。。当使用cloudresman=discovery.build('cloudresourcemanager','v2',credentials=credentials)并尝试cloudresman.folders().search时,我得到的响应是:“function”对象没有“search”属性,“list”属性也会发生同样的情况。您的需求文件呢?你能分享一下吗?