当我尝试在python脚本中使用App Engine管理API时,会抛出错误
我尝试了https://cloud.google.com/appengine/docs/admin-api/v1beta2/quickstart/
中的代码示例
from oauth2client.client import GoogleCredentials
from googleapiclient.discovery import build
def main():
# Authenticate and construct service.
service = build('appengine', 'v1beta',
credentials=GoogleCredentials.get_application_default())
# Get a list of your applications.
response = service.apps().list().execute()
apps_list = response.get('apps', [])
for app in apps_list:
print ('App Title: ', app['title'])
print ('App ID: ', app['appId'])
# List all modules on the application.
response = service.apps().modules().list(
appId=app['appId']).execute()
modules_list = response.get('modules', [])
print (' Modules for this app:')
for module in modules_list:
print (' Module ID: ', module['moduleId'])
# List all versions on this module.
response = service.apps().modules().versions().list(
appId=app['appId'],
moduleId=module['moduleId']).execute()
versions_list = response.get('versions', [])
print (' Versions on this module: ')
for version in versions_list:
print (' Version ID: ', version['versionId'])
print (' Runtime: ', version['runtime'])
print (' Deployment Timestamp: ', version['deployedTimestamp'])
if version['isDefault']:
print (' ** This is the default version. **')
if __name__ == '__main__':
main()
我遇到以下错误
Traceback (most recent call last):
File "test.py", line 53, in <module>
main()
File "test.py", line 21, in main
response = service.apps().list().execute()
AttributeError: 'Resource' object has no attribute 'list'