Add organizations.tag_resource

This commit is contained in:
gruebel 2019-11-17 14:52:57 +01:00
commit febec75364
4 changed files with 49 additions and 1 deletions

View file

@ -57,6 +57,7 @@ class FakeAccount(BaseModel):
self.joined_method = "CREATED"
self.parent_id = organization.root_id
self.attached_policies = []
self.tags = {}
@property
def arn(self):
@ -442,5 +443,17 @@ class OrganizationsBackend(BaseBackend):
]
return dict(Targets=objects)
def tag_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.",
)
new_tags = {tag["Key"]: tag["Value"] for tag in kwargs["Tags"]}
account.tags.update(new_tags)
organizations_backend = OrganizationsBackend()

View file

@ -119,3 +119,8 @@ class OrganizationsResponse(BaseResponse):
return json.dumps(
self.organizations_backend.list_targets_for_policy(**self.request_params)
)
def tag_resource(self):
return json.dumps(
self.organizations_backend.tag_resource(**self.request_params)
)