How to get gcp project name by project id



  • Using cloud function - trying to make get call to get the project name and with the id - https://cloud.google.com/resource-manager/docs/creating-managing-projects#listing_projects

     from googleapiclient import discovery
     from oauth2client.client import OAuth2Credentials as creds
     crm = discovery.build(
         'cloudresourcemanager', 'v3', 
          http=creds.authorize(httplib2.Http()))
    

    project = crm.projects().get(name="projects/"+projectId).execute()

    `



  • from googleapiclient import discovery
    from oauth2client.client import OAuth2Credentials as creds
    crm = discovery.build(
     'cloudresourcemanager', 'v3', 
      http=creds.authorize(httplib2.Http()))
    
    project = crm.projects().get(name="projects/"+projectId).execute()
    project_name = project['displayName']
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2