Merge #913.
This commit is contained in:
parent
408a70992c
commit
0adebeed24
36 changed files with 669 additions and 58 deletions
|
|
@ -200,6 +200,11 @@ class Table(BaseModel):
|
|||
self.global_indexes = global_indexes if global_indexes else []
|
||||
self.created_at = datetime.datetime.utcnow()
|
||||
self.items = defaultdict(dict)
|
||||
self.table_arn = self._generate_arn(table_name)
|
||||
self.tags = []
|
||||
|
||||
def _generate_arn(self, name):
|
||||
return 'arn:aws:dynamodb:us-east-1:123456789011:table/' + name
|
||||
|
||||
def describe(self, base_key='TableDescription'):
|
||||
results = {
|
||||
|
|
@ -209,11 +214,12 @@ class Table(BaseModel):
|
|||
'TableSizeBytes': 0,
|
||||
'TableName': self.name,
|
||||
'TableStatus': 'ACTIVE',
|
||||
'TableArn': self.table_arn,
|
||||
'KeySchema': self.schema,
|
||||
'ItemCount': len(self),
|
||||
'CreationDateTime': unix_time(self.created_at),
|
||||
'GlobalSecondaryIndexes': [index for index in self.global_indexes],
|
||||
'LocalSecondaryIndexes': [index for index in self.indexes]
|
||||
'LocalSecondaryIndexes': [index for index in self.indexes],
|
||||
}
|
||||
}
|
||||
return results
|
||||
|
|
@ -505,6 +511,18 @@ class DynamoDBBackend(BaseBackend):
|
|||
def delete_table(self, name):
|
||||
return self.tables.pop(name, None)
|
||||
|
||||
def tag_resource(self, table_arn, tags):
|
||||
for table in self.tables:
|
||||
if self.tables[table].table_arn == table_arn:
|
||||
self.tables[table].tags.extend(tags)
|
||||
|
||||
def list_tags_of_resource(self, table_arn):
|
||||
required_table = None
|
||||
for table in self.tables:
|
||||
if self.tables[table].table_arn == table_arn:
|
||||
required_table = self.tables[table]
|
||||
return required_table.tags
|
||||
|
||||
def update_table_throughput(self, name, throughput):
|
||||
table = self.tables[name]
|
||||
table.throughput = throughput
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue