Programmatically get version list from appengine

I would like to get a list of deployed versions from appengine, either from a remote API or through appcfg.py. I can't seem to find a way to do this, of course, not documented. Does anyone know of any way to do this (even undocumented)?

+4
source share
3 answers

You can specify the deployed versions in the administrator console in the "Administrator Logs" section. With the exception of the screen clearing this page, there is no way to access this data programmatically.

You can send this as a request for improvement in tracking issues .

+1
source

I was able to do this by copying some of the RPC code from appcfg.py into my application. I published this meaning , which talks in detail about how to do this, but I will repeat them here for posterity.

  • Install python API client . This will give you the OAuth2 and httplib2 libraries needed to interact with Google RPC servers from your application.
  • Copy this file from the GAE SDK installed on your development machine: google/appengine/tools/appengine_rpc_httplib2.py into your GAE web application.
  • Get the update token by running appcfg.py list_versions . --oauth2 appcfg.py list_versions . --oauth2 from your local computer. This will open a browser so you can log in to your Google account. Then you can find refresh_token in ~ / .appcfg_oauth2_tokens
  • Modify and run the following code inside the web handler:

Enjoy.

 from third_party.google_api_python_client import appengine_rpc_httplib2 # Not-so-secret IDs cribbed from appcfg.py # https://code.google.com/p/googleappengine/source/browse/trunk/python/google/appengine/tools/appcfg.py#144 APPCFG_CLIENT_ID = '550516889912.apps.googleusercontent.com' APPCFG_CLIENT_NOTSOSECRET = 'ykPq-0UYfKNprLRjVx1hBBar' APPCFG_SCOPES = ['https://www.googleapis.com/auth/appengine.admin'] source = (APPCFG_CLIENT_ID, APPCFG_CLIENT_NOTSOSECRET, APPCFG_SCOPES, None) rpc_server = appengine_rpc_httplib2.HttpRpcServerOauth2( 'appengine.google.com', # NOTE: Here there the refresh token is used "your OAuth2 refresh token goes here", "appcfg_py/1.8.3 Darwin/12.5.0 Python/2.7.2.final.0", source, host_override=None, save_cookies=False, auth_tries=1, account_type='HOSTED_OR_GOOGLE', secure=True, ignore_certs=False) # NOTE: You must insert the correct app_id here, too response = rpc_server.Send('/api/versions/list', app_id="khan-academy") # The response is in YAML format parsed_response = yaml.safe_load(response) if not parsed_response: return None else: return parsed_response 
+1
source

It looks like Google recently released the get_versions() function in the google.appengine.api.modules package. I recommend using this over a hack that I implemented in my other answer.

More details: https://developers.google.com/appengine/docs/python/modules/functions

0
source

Source: https://habr.com/ru/post/1380606/


All Articles