in person/person.py [0:0]
def update_person(self, **kwargs):
dynamodb = boto3.resource('dynamodb')
name = kwargs.get('Name')
windows = kwargs.get('Windows')
req_phys_conf = kwargs.get('RequirePhysicalConfirmation')
attr = {}
expr = []
upd_expr = ""
if windows:
expr.append('windows=:windows')
attr[':windows'] = json.dumps(yaml.load(windows))
if req_phys_conf is not None:
expr.append('req_phys_confirm=:pc')
attr[':pc'] = req_phys_conf
if len(expr) > 0:
upd_expr = 'SET ' + ",".join(expr)
table = dynamodb.Table(PERSON_TABLE)
if (upd_expr):
table.update_item(
Key={
PERSON_HASH_KEY: name
},
UpdateExpression=upd_expr,
ExpressionAttributeValues=attr
)
else:
table.update_item(
Key={
PERSON_HASH_KEY: name
}
)