Skip to content

Commit 14a6599

Browse files
feat: add get permissions
1 parent 11f7b17 commit 14a6599

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

api/specs/web-server/_functions.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
RegisteredFunctionUpdate,
1818
)
1919
from models_library.generics import Envelope
20+
from models_library.groups import GroupID
2021
from simcore_service_webserver._meta import API_VTAG
2122
from simcore_service_webserver.functions._controller._functions_rest import (
2223
FunctionGroupPathParams,
@@ -82,6 +83,15 @@ async def delete_function(
8283
): ...
8384

8485

86+
@router.get(
87+
"/functions/{function_id}/groups",
88+
response_model=Envelope[dict[GroupID, FunctionGroupAccessRightsGet]],
89+
)
90+
async def get_function_groups(
91+
_path: Annotated[FunctionPathParams, Depends()],
92+
): ...
93+
94+
8595
@router.put(
8696
"/functions/{function_id}/groups/{group_id}",
8797
response_model=Envelope[FunctionGroupAccessRightsGet],

services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3478,6 +3478,27 @@ paths:
34783478
responses:
34793479
'204':
34803480
description: Successful Response
3481+
/v0/functions/{function_id}/groups:
3482+
get:
3483+
tags:
3484+
- functions
3485+
summary: Get Function Groups
3486+
operationId: get_function_groups
3487+
parameters:
3488+
- name: function_id
3489+
in: path
3490+
required: true
3491+
schema:
3492+
type: string
3493+
format: uuid
3494+
title: Function Id
3495+
responses:
3496+
'200':
3497+
description: Successful Response
3498+
content:
3499+
application/json:
3500+
schema:
3501+
$ref: '#/components/schemas/Envelope_dict_Annotated_int__Gt___FunctionGroupAccessRightsGet__'
34813502
/v0/functions/{function_id}/groups/{group_id}:
34823503
put:
34833504
tags:
@@ -11275,6 +11296,22 @@ components:
1127511296
title: Error
1127611297
type: object
1127711298
title: Envelope[_ProjectNodePreview]
11299+
Envelope_dict_Annotated_int__Gt___FunctionGroupAccessRightsGet__:
11300+
properties:
11301+
data:
11302+
anyOf:
11303+
- additionalProperties:
11304+
$ref: '#/components/schemas/FunctionGroupAccessRightsGet'
11305+
type: object
11306+
- type: 'null'
11307+
title: Data
11308+
error:
11309+
anyOf:
11310+
- {}
11311+
- type: 'null'
11312+
title: Error
11313+
type: object
11314+
title: Envelope[dict[Annotated[int, Gt], FunctionGroupAccessRightsGet]]
1127811315
Envelope_dict_Annotated_str__StringConstraints___ImageResources__:
1127911316
properties:
1128011317
data:

services/web/server/src/simcore_service_webserver/functions/_controller/_functions_rest.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,37 @@ async def delete_function(request: web.Request) -> web.Response:
368368
#
369369

370370

371+
@routes.get(
372+
f"/{VTAG}/functions/{{function_id}}/groups",
373+
name="update_function_group",
374+
)
375+
@login_required
376+
@permission_required("function.read")
377+
@handle_rest_requests_exceptions
378+
async def get_function_group(request: web.Request) -> web.Response:
379+
path_params = parse_request_path_parameters_as(FunctionPathParams, request)
380+
function_id = path_params.function_id
381+
382+
req_ctx = AuthenticatedRequestContext.model_validate(request)
383+
access_rights_list = await _functions_service.get_function_group_permissions(
384+
request.app,
385+
user_id=req_ctx.user_id,
386+
product_name=req_ctx.product_name,
387+
function_id=function_id,
388+
)
389+
390+
return envelope_json_response(
391+
{
392+
access_rights.group_id: {
393+
"read": access_rights.read,
394+
"write": access_rights.write,
395+
"execute": access_rights.execute,
396+
}
397+
for access_rights in access_rights_list
398+
}
399+
)
400+
401+
371402
@routes.put(
372403
f"/{VTAG}/functions/{{function_id}}/groups/{{group_id}}",
373404
name="update_function_group",

0 commit comments

Comments
 (0)