forked from sr2/cloud-api
parent
5a433dfe41
commit
294baadcb7
7 changed files with 90 additions and 19 deletions
|
|
@ -21,6 +21,7 @@ from sqlalchemy.exc import IntegrityError
|
|||
|
||||
from src.iam.exceptions import GroupNotFoundException
|
||||
from src.organisation.exceptions import OrgNotFoundException
|
||||
from src.schemas import GroupSummary, OrgSummary
|
||||
from src.service.exceptions import ServiceNotFoundException
|
||||
from src.exceptions import ConflictException
|
||||
from src.database import db_dependency
|
||||
|
|
@ -127,7 +128,11 @@ async def get_group_permissions(
|
|||
):
|
||||
if group_model.org_id != org_model.id:
|
||||
raise UnauthorizedException("Group does not belong to this organization")
|
||||
return {"permissions": group_model.permission_rel}
|
||||
return {
|
||||
"organisation": org_model,
|
||||
"group": group_model,
|
||||
"permissions": group_model.permission_rel,
|
||||
}
|
||||
|
||||
|
||||
@router.get("/group/users", response_model=IAMGetGroupUsersResponse)
|
||||
|
|
@ -137,7 +142,11 @@ async def get_group_users(
|
|||
):
|
||||
if group_model.org_id != org_model.id:
|
||||
raise UnauthorizedException("Group does not belong to this organization")
|
||||
return {"users": group_model.user_rel}
|
||||
return {
|
||||
"organisation": org_model,
|
||||
"group": group_model,
|
||||
"users": group_model.user_rel,
|
||||
}
|
||||
|
||||
|
||||
@router.post("/group", response_model=IAMPostGroupResponse)
|
||||
|
|
@ -180,7 +189,8 @@ async def add_group_permission(
|
|||
|
||||
db.flush()
|
||||
response = IAMPutGroupPermissionResponse(
|
||||
group=GroupSchema(**group_model.__dict__),
|
||||
organisation=OrgSummary(**org_model.__dict__),
|
||||
group=GroupSummary(**group_model.__dict__),
|
||||
permissions=group_model.permission_rel,
|
||||
)
|
||||
db.commit()
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@ from src.schemas import (
|
|||
UserIDMixin,
|
||||
PermIDMixin,
|
||||
GroupIDMixin,
|
||||
GroupSummary,
|
||||
OrgSummary,
|
||||
UserSummary,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -50,11 +53,15 @@ class IAMCAoRRequest(CustomBaseModel):
|
|||
|
||||
|
||||
class IAMGetGroupPermissionsResponse(CustomBaseModel):
|
||||
organisation: OrgSummary
|
||||
group: GroupSummary
|
||||
permissions: list[PermissionSchema]
|
||||
|
||||
|
||||
class IAMGetGroupUsersResponse(CustomBaseModel):
|
||||
users: list[UserSchema]
|
||||
organisation: OrgSummary
|
||||
group: GroupSummary
|
||||
users: list[UserSummary]
|
||||
|
||||
|
||||
class IAMPostGroupRequest(OrgIDMixin):
|
||||
|
|
@ -70,7 +77,8 @@ class IAMPutGroupPermissionRequest(GroupIDMixin, PermIDMixin, OrgIDMixin):
|
|||
|
||||
|
||||
class IAMPutGroupPermissionResponse(CustomBaseModel):
|
||||
group: GroupSchema
|
||||
organisation: OrgSummary
|
||||
group: GroupSummary
|
||||
permissions: list[PermissionSchema]
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue