How can i get price, uptime and user name of an instance using python google api client

89 views
Skip to first unread message

Shoaib Akhtar

unread,
Aug 22, 2019, 1:05:07 PM8/22/19
to gce-discussion
Am using python googleapi client library to get instance data for a project

Am getting instances like this:

    from googleapiclient import discovery
   
from google.oauth2 import service_account
   
    scopes
= ['https://www.googleapis.com/auth/cloud-platform']
    service_cred_file
= 'service-credentials.json'
    zone
= 'us-central1-c'
    project_id
= 'my_project_id'
   
    credentials
= service_account.Credentials.from_service_account_file(service_cred_file, scopes=scopes)


    service
= discovery.build('compute', 'v1', credentials=credentials)
   
    request
= service.instances().list(project=project_id, zone=zone)
   
while request is not None:
        response
= request.execute()
       
for instance in response['items']:
           
print(instance)




Instance response does not contain uptime, user data (data of user that created instance) and current billing price 
How can i get these attributes?

Milad (Google Cloud Platform)

unread,
Aug 22, 2019, 6:52:20 PM8/22/19
to gce-dis...@googlegroups.com

Did you installed both google-auth and google-auth-httplib2 ? I recommend you to take a look at this document about Google Compute Engine Python API Client Library. Also, you can find examples and further information concerning the Google API Client here.
Reply all
Reply to author
Forward
0 new messages