Add organizations.list_tags_for_resource
This commit is contained in:
parent
febec75364
commit
c10afa3ab5
4 changed files with 59 additions and 1 deletions
|
|
@ -455,5 +455,17 @@ class OrganizationsBackend(BaseBackend):
|
|||
new_tags = {tag["Key"]: tag["Value"] for tag in kwargs["Tags"]}
|
||||
account.tags.update(new_tags)
|
||||
|
||||
def list_tags_for_resource(self, **kwargs):
|
||||
account = next((a for a in self.accounts if a.id == kwargs["ResourceId"]), None)
|
||||
|
||||
if account is None:
|
||||
raise RESTError(
|
||||
"InvalidInputException",
|
||||
"You provided a value that does not match the required pattern.",
|
||||
)
|
||||
|
||||
tags = [{"Key": key, "Value": value} for key, value in account.tags.items()]
|
||||
return dict(Tags=tags)
|
||||
|
||||
|
||||
organizations_backend = OrganizationsBackend()
|
||||
|
|
|
|||
|
|
@ -124,3 +124,8 @@ class OrganizationsResponse(BaseResponse):
|
|||
return json.dumps(
|
||||
self.organizations_backend.tag_resource(**self.request_params)
|
||||
)
|
||||
|
||||
def list_tags_for_resource(self):
|
||||
return json.dumps(
|
||||
self.organizations_backend.list_tags_for_resource(**self.request_params)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue