【发布时间】:2021-08-20 01:18:50
【问题描述】:
我想使用 python 删除 GCP 中 10 天前的快照。我尝试使用以下程序使用过滤器表达式,但不幸的是我遇到了以下错误
from datetime import datetime
from googleapiclient import discovery
import google.oauth2.credentials
from oauth2client.service_account import ServiceAccountCredentials
import sys
def get_disks(project,zone):
credentials = ServiceAccountCredentials.from_json_keyfile_name(r"D:\Users\ganeshb\Desktop\Json\auth.json",
scopes='https://www.googleapis.com/auth/compute')
service = discovery.build('compute', 'v1',credentials=credentials)
request = service.snapshots().list(project='xxxx',FILTER="creationTimestamp<'2021-05-31'")
response = request.execute()
print (response)
output = get_disks("xxxxxxxx", "europe-west1-b")
【问题讨论】:
-
错误是什么?
-
对于
scope,我推荐使用https://www.googleapis.com/auth/cloud-platform。实际权限应由分配给身份的角色确定。 -
你能分享你遇到的错误吗?
-
返回“字段 'filter' 的值无效:'creationTimestamp = >'2021-06-01''。列表过滤器表达式无效。”。详细信息:“[{'message':“字段'filter'的值无效:'creationTimestamp = >'2021-06-01''。列表过滤器表达式无效。", 'domain': 'global', 'reason': 'invalid'}]">
-
嗨团队,我的想法是首先我想过滤最近 5 天的时间戳快照的创建。我想删除其余的快照文件
标签: python python-3.x google-cloud-platform snapshot