'How to filter out DEPRECATED || OBSOLETE images using filter field Google Cloud Compute API
So, I am trying to get images that are not DEPRECATED or OBSOLETE. I am using API which is available in the docs. What I have tried already is putting (deprecated.state != "DEPRECATED") this works but it shows OBSOLETE ones in the response. My next attempt was trying the request with following filter (deprecated.state != "DEPRECATED") OR (deprecated.state != "OBSOLETE"). But for some unknown reason it still returns OBSOLETE ones. Another idea was just filter those images which does not have deprecated.state field. But I didn't succeed to create such filter.
https://cloud.google.com/compute/docs/reference/rest/v1/images/list the link to test
Solution 1:[1]
You need to use AND your query, because you only want images which are not OBSOLETE AND not DEPRECATED.
(deprecated.state != "OBSOLETE") AND (deprecated.state != "DEPRECATED")
or this, as AND is implicit:
(deprecated.state != "OBSOLETE") (deprecated.state != "DEPRECATED")
Tested right now with the API Explorer on https://cloud.google.com/compute/docs/reference/rest/v1/images/list.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sebastian |
