How can I find the python client library for a gcloud command?

43 views Asked by At

To write a Python script to collect various details about all projects deployed in the organization, how can we find which shared-vpc host project/network is being used?

There's a gcloud command that provides details

gcloud compute shared-vpc get-host-project strong-bad-2g0v

## provides results
results
kind: compute#project
name: shared-vpc-host-52ey86a9

However, I want to use Python for the script, so following the docs on how to use the Python Client and searching Google Cloud Python Client repo for "shared-vpc" or "vpc" doesn't provide relevant results. Looking under /compute_v1 (assuming a similar structure as gcloud), doesn't show results for "shared-vpc" or "vpc"

1

There are 1 answers

1
codeangler On

Using the flag --log-http with cloud provides more details about the API being called.

gcloud  compute shared-vpc get-host-project strong-bad-2g0v --log-http

##==== request start ====
uri: https://compute.googleapis.com/compute/v1/projects/strong-bad-2g0v/getXpnHost?alt=json
method: GET

seeing that the path element "getXpnHost", return to Google Cloud Python Client repo and search and found examples.