• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# To be used to test GoogleCredentials.get_application_default()
2# from devel GAE (ie, dev_appserver.py).
3
4from googleapiclient.discovery import build
5import webapp2
6
7from oauth2client.client import GoogleCredentials
8
9
10PROJECT = 'bamboo-machine-422'  # Provide your own GCE project here
11ZONE = 'us-central1-a'          # Put here a zone which has some VMs
12
13
14def get_instances():
15    credentials = GoogleCredentials.get_application_default()
16    service = build('compute', 'v1', credentials=credentials)
17    request = service.instances().list(project=PROJECT, zone=ZONE)
18    return request.execute()
19
20
21class MainPage(webapp2.RequestHandler):
22
23    def get(self):
24        self.response.write(get_instances())
25
26
27app = webapp2.WSGIApplication([('/', MainPage), ], debug=True)
28