Reputation: 1005
I am retrieving compute engine snapshots from google projects using rest api in postman. I want to retrieve snapshots that were created after a certain time stamp value using the filter, If I pass the "=" as operator it works like the below one:
https://compute.googleapis.com/compute/v1/projects/my-project/global/snapshots?filter=(creationTimestamp="2020-05-25T06:06:45.366-07:00")
I wanto to filter records which are larger than a particular timestamp so I use this
https://compute.googleapis.com/compute/v1/projects/my-project/global/snapshots?filter=(creationTimestamp>"2020-05-25T06:06:45.366-07:00")
or
(creationTimestamp>="2020-05-25T06:06:45.366-07:00") (Here I read in the documentation that we can only use !=, >, or <. so I am not sure whethere i can use >= or <=)
https://cloud.google.com/compute/docs/reference/rest/v1/snapshots/list
But even for < or > operator I am getting this:
{
"error": {
"code": 400,
"message": "Invalid value for field 'filter': 'creationTimestamp>2020-05-25T06:06:45.366-07:00'. Invalid list filter expression.",
"errors": [
{
"message": "Invalid value for field 'filter': 'creationTimestamp>2020-05-25T06:06:45.366-07:00'. Invalid list filter expression.",
"domain": "global",
"reason": "invalid"
}
]
}
}
Can anyone please suggest a solution?Thanks
Update
My end goal is to create a snapshot report in data-studio, so is there any way I can get the rest api snapshot data to bigquery or any other datasource through which I can create this report?
Upvotes: 1
Views: 503
Reputation: 4660
Posting this as Community Wiki based in the comments.
As you are comparing strings, unfortunately, the API will not answer in the way you want. You will need to manualy filter the creation date of your snapshot once you have the full list retrieved. This way, you won't be able to be filtering the data while returning it, but only after you retrieve the data from the instance.
Upvotes: 1