Home | History | Annotate | Download | only in googleappengine
      1 # To be used to test GoogleCredentials.get_application_default()
      2 # from devel GAE (ie, dev_appserver.py).
      3 
      4 from googleapiclient.discovery import build
      5 import webapp2
      6 
      7 from oauth2client.client import GoogleCredentials
      8 
      9 
     10 PROJECT = 'bamboo-machine-422'  # Provide your own GCE project here
     11 ZONE = 'us-central1-a'          # Put here a zone which has some VMs
     12 
     13 
     14 def 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 
     21 class MainPage(webapp2.RequestHandler):
     22 
     23     def get(self):
     24         self.response.write(get_instances())
     25 
     26 
     27 app = webapp2.WSGIApplication([('/', MainPage), ], debug=True)
     28