update layercake version
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from layercake.dateutils import now
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair, TransactItems
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair
|
||||
|
||||
|
||||
def update_policies(
|
||||
@@ -11,30 +11,30 @@ def update_policies(
|
||||
persistence_layer: DynamoDBPersistenceLayer,
|
||||
):
|
||||
now_ = now()
|
||||
transact = TransactItems(persistence_layer.table_name)
|
||||
|
||||
if payment_policy:
|
||||
transact.put(
|
||||
item={
|
||||
'id': id,
|
||||
'sk': 'metadata#payment_policy',
|
||||
'create_date': now_,
|
||||
}
|
||||
| payment_policy
|
||||
)
|
||||
else:
|
||||
transact.delete(key=KeyPair(id, 'metadata#payment_policy'))
|
||||
with persistence_layer.transact_writer() as transact:
|
||||
if payment_policy:
|
||||
transact.put(
|
||||
item={
|
||||
'id': id,
|
||||
'sk': 'metadata#payment_policy',
|
||||
'create_date': now_,
|
||||
}
|
||||
| payment_policy
|
||||
)
|
||||
else:
|
||||
transact.delete(key=KeyPair(id, 'metadata#payment_policy'))
|
||||
|
||||
if billing_policy:
|
||||
transact.put(
|
||||
item={
|
||||
'id': id,
|
||||
'sk': 'metadata#billing_policy',
|
||||
'create_date': now_,
|
||||
}
|
||||
| billing_policy
|
||||
)
|
||||
else:
|
||||
transact.delete(key=KeyPair(id, 'metadata#billing_policy'))
|
||||
if billing_policy:
|
||||
transact.put(
|
||||
item={
|
||||
'id': id,
|
||||
'sk': 'metadata#billing_policy',
|
||||
'create_date': now_,
|
||||
}
|
||||
| billing_policy
|
||||
)
|
||||
else:
|
||||
transact.delete(key=KeyPair(id, 'metadata#billing_policy'))
|
||||
|
||||
return persistence_layer.transact_write_items(transact)
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user