0

Which Google Cloud Platform (GCP) REST API route would I use for listing GCP projects?

I.e., which GCP REST API route would give a response similar to the output of the list Cloud SDK (gcloud) command:

gcloud projects list

#=>

PROJECT_ID     NAME           PROJECT_NUMBER
. . .          . . .          . . .
Stono
  • 2,337
  • 2
  • 16
  • 18
  • 2
    If you know which gcloud command makes an api call you are interested, you can use '--log-http' flag which will display all api calls and responses made by the command. – cherba Jul 02 '17 at 11:41

1 Answers1

0
  1. You need to enable the "Cloud Resource Manager API" here

  2. Use google.cloudresourcemanager('v1').projects.list:

    curl \
    --header "Authorization: Bearer $(gcloud auth print-access-token)" \
    --location \
    --request GET \
    "https://cloudresourcemanager.googleapis.com/v1/projects"
    
    #=>
    
    {
      "projects": [
        . . .
      ]
    }
    
Mike
  • 1,080
  • 1
  • 9
  • 25
Stono
  • 2,337
  • 2
  • 16
  • 18