googleapis / google-api-go-client

Auto-generated Google APIs for Go.
https://pkg.go.dev/google.golang.org/api
BSD 3-Clause "New" or "Revised" License
4k stars 1.12k forks source link

Compute: How to filter instances based on networkInterfaces #813

Closed rodrigopavan closed 3 years ago

rodrigopavan commented 3 years ago

How can I/It's possible filter instances base on network attribute inside networkInterfaces?

I've tried a few things like: req := c.ComputeService.Instances.List(projectID, zoneName).Filter('networkInterfaces[0].network=" + networkSelfLink + "')

req := c.ComputeService.Instances.List(projectID, zoneName).Filter('networkInterfaces.network=" + networkSelfLink + "')

But, none of them works, I always receive an: Invalid value for field 'filter': 'networkInterfaces[0].network="https://www.googleapis.com/compute/v1/projects/simreplicacao/global/networks/default"'. Invalid list filter expression.

codyoss commented 3 years ago

By looking at the docs it appears items[].networkInterfaces[].network might be what you are looking for.

rodrigopavan commented 3 years ago

@codyoss , doens't works...

{ "error": { "code": 400, "message": "Invalid value for field 'filter': 'networkInterfaces[].network=\"https://www.googleapis.com/compute/v1/projects/ns1-ddi-integration-proj-01/global/networks/default\"'. Invalid list filter expression.", "errors": [ { "message": "Invalid value for field 'filter': 'networkInterfaces[].network=\"https://www.googleapis.com/compute/v1/projects/ns1-ddi-integration-proj-01/global/networks/default\"'. Invalid list filter expression.", "domain": "global", "reason": "invalid" } ] } }

{ "error": { "code": 400, "message": "Invalid value for field 'filter': 'items[].networkInterfaces[].network=\"https://www.googleapis.com/compute/v1/projects/ns1-ddi-integration-proj-01/global/networks/default\"'. Invalid list filter expression.", "errors": [ { "message": "Invalid value for field 'filter': 'items[].networkInterfaces[].network=\"https://www.googleapis.com/compute/v1/projects/ns1-ddi-integration-proj-01/global/networks/default\"'. Invalid list filter expression.", "domain": "global", "reason": "invalid" } ] } }

codyoss commented 3 years ago

Sorry for the misdirection. If this field could be filtered on you could do it with a :, see AIP-160 for example syntax. I did also find an open issue related to unable to filter on networkinterfaces though as well: issue. If this is the case the issue is not with this client, but the backend service. I would recommend reaching out for support through one of the methods listed on the compute api support page.

This issue tracker is primarily used for issue relating the the generated code itself.