Wesley Wang
Wesley Wang

Reputation: 77

How to query for shared VPC networks?

How do I view the list of networks/subnetworks available to me from a shared VPC? The following only returns the list of subnetworks in the current project and not shared to it:

from googleapiclient.discovery import build
compute = build('compute', 'v1')
compute.networks().list(project='project').execute()
compute.subnetworks().listUsable(project='project').execute()

Upvotes: 0

Views: 844

Answers (1)

Daniel Ocando
Daniel Ocando

Reputation: 3774

Taking into consideration that all of the existing VPC networks in the host project are Shared VPC networks you can use the getXpnHost method from the REST API to get the shared VPC host project that your project links to and from there use the same networks().list() and subnetworks().listUsable() to get the desired information.

Upvotes: 1

Related Questions