我将使用哪个 Google Cloud Platform (GCP) REST API 路由来列出 GCP 项目?
即,哪个 GCP REST API 路由会给出类似于list
Cloud SDK ( gcloud
) 命令输出的响应:
gcloud projects list
#=>
PROJECT_ID NAME PROJECT_NUMBER
. . . . . . . . .
我将使用哪个 Google Cloud Platform (GCP) REST API 路由来列出 GCP 项目?
即,哪个 GCP REST API 路由会给出类似于list
Cloud SDK ( gcloud
) 命令输出的响应:
gcloud projects list
#=>
PROJECT_ID NAME PROJECT_NUMBER
. . . . . . . . .
You need to enable the "Cloud Resource Manager API" here
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": [
. . .
]
}