在哪里可以找到 gcloud 调用的 API?
Where can I find which APIs gcloud calls?
我正在开发一个新项目,我计划用 Google Cloud 替换一组调用 gcloud
和 gsutil
的一次性 shell 脚本Go APIs 和客户端库。这背后的主要驱动因素是我可以使用更易于维护和可测试的代码来管理大型 GCP 自动化项目。
我已经翻阅了所有 Google 文档,但似乎无法找到任何涵盖 APIs glcoud
调用或 glcoud
源代码的内容代码。除此之外,GCP go APIs 似乎没有涵盖我正在寻找的内容。我已经能够在 REST API 中找到一些我需要的东西,但即便如此,还不完全清楚什么 gcloud
命令映射到什么 REST API 端点。
例如:gcloud addresses describe gce_vm_foo
我唯一能找到合适的是来自 REST API 的端点,通过挖掘大量文档和反复试验发现:https://godoc.org/google.golang.org/api/compute/v1#InstancesService.Get
我意识到这是一个非常开放的问题,但非常感谢任何指向正确方向的问题。
如果您想知道 gcloud 正在调用什么,请添加 --log-http 标志并可能使用 grep 来缩小您的搜索范围,例如:
~ gcloud --log-http compute addresses list 2>&1 | grep "GET" \
GET /compute/v1/projects/<redacted>/aggregated/addresses?alt=json HTTP/1.1
然后可能转到页面的 Compute Engine API page and search (or just google) for the distinguishing part of the request uri from above, like 'aggregated/addresses', which should get you to the REST Resource: v1.addresses 部分,从这里应该相对容易。
我正在开发一个新项目,我计划用 Google Cloud 替换一组调用 gcloud
和 gsutil
的一次性 shell 脚本Go APIs 和客户端库。这背后的主要驱动因素是我可以使用更易于维护和可测试的代码来管理大型 GCP 自动化项目。
我已经翻阅了所有 Google 文档,但似乎无法找到任何涵盖 APIs glcoud
调用或 glcoud
源代码的内容代码。除此之外,GCP go APIs 似乎没有涵盖我正在寻找的内容。我已经能够在 REST API 中找到一些我需要的东西,但即便如此,还不完全清楚什么 gcloud
命令映射到什么 REST API 端点。
例如:gcloud addresses describe gce_vm_foo
我唯一能找到合适的是来自 REST API 的端点,通过挖掘大量文档和反复试验发现:https://godoc.org/google.golang.org/api/compute/v1#InstancesService.Get
我意识到这是一个非常开放的问题,但非常感谢任何指向正确方向的问题。
如果您想知道 gcloud 正在调用什么,请添加 --log-http 标志并可能使用 grep 来缩小您的搜索范围,例如:
~ gcloud --log-http compute addresses list 2>&1 | grep "GET" \
GET /compute/v1/projects/<redacted>/aggregated/addresses?alt=json HTTP/1.1
然后可能转到页面的 Compute Engine API page and search (or just google) for the distinguishing part of the request uri from above, like 'aggregated/addresses', which should get you to the REST Resource: v1.addresses 部分,从这里应该相对容易。