【发布时间】:2020-10-02 10:14:55
【问题描述】:
我正在使用 postman 中的 rest api 从谷歌项目中检索计算引擎快照。我想使用过滤器检索在某个时间戳值之后创建的快照,如果我将 "=" 作为运算符传递,它 works 如下所示:
https://compute.googleapis.com/compute/v1/projects/my-project/global/snapshots?filter=(creationTimestamp="2020-05-25T06:06:45.366-07:00")
我想过滤大于特定时间戳的记录,所以我使用它
https://compute.googleapis.com/compute/v1/projects/my-project/global/snapshots?filter=(creationTimestamp>"2020-05-25T06:06:45.366-07:00")
或
(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
但即使对于 运算符,我也得到了这个:
{
"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"
}
]
}
}
谁能提出解决方案?谢谢
更新
我的最终目标是在 data-studio 中创建一个快照报告,那么有什么方法可以将其余的 api 快照数据获取到 bigquery 或任何其他可以创建此报告的数据源?
【问题讨论】:
-
来自文档:
The value must be a string, a number, or a boolean. The comparison operator must be either =, !=, >, or <。您将字符串与比较运算符一起传递(>):我对他的作品有些怀疑。 -
是的,但既然他们给出了 > 或
-
你可以通过
=检查两个字符串是否相等,但是不能通过<比较字符串。我猜,比较只适用于数字。 -
是的,但是我必须过滤时间戳值,api中还有其他方法吗?
-
您可以使用 gcloud CLI 还是需要 REST API?
标签: google-cloud-platform postman google-compute-engine google-compute-api