in code/lambda_layer/metadata-services/python/datastore.py [0:0]
def startDocumentTracking(self, documentId, bucketName, objectName, status, stage, timestamp, versionId=None):
ret = None
dynamodb = AwsHelper().getResource("dynamodb")
table = dynamodb.Table(self._opsTableName)
item = {
"documentId": documentId,
"bucketName": bucketName,
"objectName": objectName,
"documentStatus": status,
"documentStage": stage,
"lastUpdate": timestamp,
"timeline": [{
"timestamp": timestamp,
"stage": stage,
"status": status
}]
}
if versionId:
item['documentVersion'] = versionId
try:
table.put_item(
ConditionExpression = "attribute_not_exists(documentId)",
Item = item
)
ret = {
'Status': 200
}
except ClientError as e:
print(e)
ret = {
'Status': e.response['ResponseMetadata']['HTTPStatusCode'],
'Error': e.response['Error']['Message']
}
except Exception as e:
print(e)
ret = {
'Error': 'Unknown error occurred during updating document',
'Status': 400
}
return ret