简体   繁体   English

GCP API 用于获取标签列表

[英]GCP API for getting list of labels

Is there an GCP API for getting labels for resources?是否有用于获取资源标签的 GCP API? I want to get a list of all labels for GCP Project.我想获取 GCP 项目的所有标签列表。 How to get all labels in GCP?如何获取 GCP 中的所有标签? Basically GCP Resource Manager API return the Lebel object for every resource.基本上 GCP Resource Manager API 为每个资源返回 Lebel object。 But I want to get list of all labels using one API call.但我想使用一次 API 调用获取所有标签的列表。

I tried the next workaround to get all the labels:我尝试了下一个解决方法来获取所有标签:

gcloud projects describe <YOUR-PROJECT-NAME> --format=json | jq -r '.labels|to_entries|map("\(.key)=\(.value|tostring)")|.[]'

You will receive a key=value list.您将收到一个键=值列表。

Currently it's not possible to list all labels within a GCP project.目前无法列出 GCP 项目中的所有标签。

Beside what you mention about GCP Resource Manager API , you could get some information from Asset Inventory , however it won't fulfill your requirements.除了您提到的GCP Resource Manager API ,您还可以从Asset Inventory获得一些信息,但它不能满足您的要求。

To achieve what you want, you can fill a Feature Request in GCP IssueTracker to create this possibility.要实现您想要的,您可以在 GCP IssueTracker中填写Feature Request以创建这种可能性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM