feat: use of service model dependency
This commit is contained in:
parent
f06b19340c
commit
1a29da73c2
1 changed files with 2 additions and 4 deletions
|
|
@ -24,7 +24,7 @@ from sqlalchemy.exc import IntegrityError
|
||||||
from src.iam.exceptions import GroupNotFoundException
|
from src.iam.exceptions import GroupNotFoundException
|
||||||
from src.organisation.exceptions import OrgNotFoundException
|
from src.organisation.exceptions import OrgNotFoundException
|
||||||
from src.schemas import GroupSummary, OrgSummary, ResourceName
|
from src.schemas import GroupSummary, OrgSummary, ResourceName
|
||||||
from src.service.exceptions import ServiceNotFoundException
|
from src.service.dependencies import service_model_body_dependency
|
||||||
from src.exceptions import (
|
from src.exceptions import (
|
||||||
ConflictException,
|
ConflictException,
|
||||||
ForbiddenException,
|
ForbiddenException,
|
||||||
|
|
@ -488,13 +488,11 @@ async def create_new_permission(
|
||||||
db: db_dependency,
|
db: db_dependency,
|
||||||
su: super_admin_dependency,
|
su: super_admin_dependency,
|
||||||
request_model: IAMPostPermissionRequest,
|
request_model: IAMPostPermissionRequest,
|
||||||
|
service_model: service_model_body_dependency, # Used to verify service model exists
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Allows a super admin to create a new IAM permission for a service.
|
Allows a super admin to create a new IAM permission for a service.
|
||||||
"""
|
"""
|
||||||
service_model = db.get(Service, request_model.service_id)
|
|
||||||
if service_model is None:
|
|
||||||
raise ServiceNotFoundException(service_id=request_model.service_id)
|
|
||||||
perm_model = Perm(**request_model.__dict__)
|
perm_model = Perm(**request_model.__dict__)
|
||||||
db.add(perm_model)
|
db.add(perm_model)
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue