Попытка создать корзину и добавить для нее правило жизненного цикла через python, но возникает ошибка.
Код:
def bucketscreate(bucket_name):
client = storage.Client()
bucket = storage.Bucket(client, name='gc_' + bucket_name + '_consul_storage')
bucket.location = "us-east1"
bucket.storage_class = "NEARLINE"
try:
bucket = client.create_bucket(bucket)
except Conflict:
print("Bucket gc_" + bucket_name + "_consul_storage exists.")
bucket = client.get_bucket('gc_' + bucket_name + '_consul_storage')
rules = {
"action": {"type": "Delete"},
"condition": {
"age": 3
}
}
bucket.lifecycle_rules = rules
bucket.retention_period = 10
bucket.patch()
return bucket.name
Ошибка:
Traceback (most recent call last):
File "./consul_dump.py", line 103, in <module>
bucketscreate(argv)
File "./consul_dump.py", line 37, in bucketscreate
bucket.lifecycle_rules = rules
File "/home/sahaquiel/.local/lib/python3.6/site-packages/google/cloud/storage/bucket.py", line 2019, in lifecycle_rules
rules = [dict(rule) for rule in rules] # Convert helpers if needed
File "/home/sahaquiel/.local/lib/python3.6/site-packages/google/cloud/storage/bucket.py", line 2019, in <listcomp>
rules = [dict(rule) for rule in rules] # Convert helpers if needed
ValueError: dictionary update sequence element #0 has length 1; 2 is required
Помогите мне, пожалуйста, понять, что я делаю не так?