organiziaions: 2 new endpoints:

list_organizational_units_for_parents
list_parents
This commit is contained in:
Ashley Gould 2018-07-15 13:58:27 -07:00
commit fc2447c6a4
4 changed files with 92 additions and 13 deletions

View file

@ -14,6 +14,7 @@ ACCOUNT_ARN_FORMAT = 'arn:aws:organizations::{0}:account/{1}/{2}'
ROOT_ARN_FORMAT = 'arn:aws:organizations::{0}:root/{1}/{2}'
OU_ARN_FORMAT = 'arn:aws:organizations::{0}:ou/{1}/{2}'
class FakeOrganization(BaseModel):
def __init__(self, feature_set):
@ -125,7 +126,6 @@ class FakeRoot(BaseModel):
}
class FakeOrganizationalUnit(BaseModel):
def __init__(self, organization, root_id, **kwargs):
@ -152,6 +152,7 @@ class FakeOrganizationalUnit(BaseModel):
}
}
class OrganizationsBackend(BaseBackend):
def __init__(self):
@ -184,6 +185,35 @@ class OrganizationsBackend(BaseBackend):
].pop(0)
return ou.describe()
def list_organizational_units_for_parent(self, **kwargs):
return dict(
OrganizationalUnits=[
{
'Id': ou.id,
'Arn': ou.arn,
'Name': ou.name,
}
for ou in self.ou
if ou.parent_id == kwargs['ParentId']
]
)
def list_parents(self, **kwargs):
parent_id = [
ou.parent_id for ou in self.ou if ou.id == kwargs['ChildId']
].pop(0)
root_parents = [
dict(Id=root.id, Type='ROOT')
for root in self.roots
if root.id == parent_id
]
ou_parents = [
dict(Id=ou.id, Type='ORGANIZATIONAL_UNIT')
for ou in self.ou
if ou.id == parent_id
]
return dict(Parents=root_parents + ou_parents)
def create_account(self, **kwargs):
new_account = FakeAccount(self.org, **kwargs)
self.accounts.append(new_account)

View file

@ -46,6 +46,16 @@ class OrganizationsResponse(BaseResponse):
self.organizations_backend.describe_organizational_unit(**self.request_params)
)
def list_organizational_units_for_parent(self):
return json.dumps(
self.organizations_backend.list_organizational_units_for_parent(**self.request_params)
)
def list_parents(self):
return json.dumps(
self.organizations_backend.list_parents(**self.request_params)
)
def create_account(self):
return json.dumps(
self.organizations_backend.create_account(**self.request_params)