Skip to content

Commit 4c15e6c

Browse files
✨ Add Function groups permissions management endpoints (#8226)
Co-authored-by: Odei Maiz <[email protected]>
1 parent b0784c9 commit 4c15e6c

File tree

10 files changed

+536
-46
lines changed

10 files changed

+536
-46
lines changed

api/specs/web-server/_functions.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@
1010
from _common import as_query
1111
from fastapi import APIRouter, Depends, status
1212
from models_library.api_schemas_webserver.functions import (
13+
FunctionGroupAccessRightsGet,
14+
FunctionGroupAccessRightsUpdate,
1315
FunctionToRegister,
1416
RegisteredFunctionGet,
1517
RegisteredFunctionUpdate,
1618
)
1719
from models_library.generics import Envelope
20+
from models_library.groups import GroupID
1821
from simcore_service_webserver._meta import API_VTAG
22+
from simcore_service_webserver.functions._controller._functions_rest import (
23+
FunctionGroupPathParams,
24+
)
1925
from simcore_service_webserver.functions._controller._functions_rest_schemas import (
2026
FunctionGetQueryParams,
2127
FunctionPathParams,
@@ -75,3 +81,33 @@ async def update_function(
7581
async def delete_function(
7682
_path: Annotated[FunctionPathParams, Depends()],
7783
): ...
84+
85+
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+
95+
@router.put(
96+
"/functions/{function_id}/groups/{group_id}",
97+
summary="Create or update a Function Group",
98+
response_model=Envelope[FunctionGroupAccessRightsGet],
99+
)
100+
async def create_or_update_function_group(
101+
_path: Annotated[FunctionGroupPathParams, Depends()],
102+
_body: FunctionGroupAccessRightsUpdate,
103+
): ...
104+
105+
106+
@router.delete(
107+
"/functions/{function_id}/groups/{group_id}",
108+
summary="Delete a Function Group",
109+
status_code=status.HTTP_204_NO_CONTENT,
110+
)
111+
async def delete_function_group(
112+
_path: Annotated[FunctionGroupPathParams, Depends()],
113+
): ...

packages/models-library/src/models_library/api_schemas_webserver/functions.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from ..functions import (
77
Function,
8-
FunctionAccessRights,
98
FunctionBase,
109
FunctionClass,
1110
FunctionClassSpecificData,
@@ -49,6 +48,7 @@
4948
UnsupportedFunctionClassError,
5049
UnsupportedFunctionFunctionJobClassCombinationError,
5150
)
51+
from ..groups import GroupID
5252
from ..projects import ProjectID
5353
from ._base import InputSchema, OutputSchema
5454

@@ -114,11 +114,23 @@
114114
]
115115

116116

117+
class FunctionGroupAccessRightsGet(OutputSchema):
118+
read: bool
119+
write: bool
120+
execute: bool
121+
122+
123+
class FunctionGroupAccessRightsUpdate(InputSchema):
124+
read: bool
125+
write: bool
126+
execute: bool
127+
128+
117129
class RegisteredSolverFunctionGet(RegisteredSolverFunction, OutputSchema):
118130
uid: Annotated[FunctionID, Field(alias="uuid")]
119131
created_at: Annotated[datetime.datetime, Field(alias="creationDate")]
120132
modified_at: Annotated[datetime.datetime, Field(alias="lastChangeDate")]
121-
access_rights: FunctionAccessRights | None = None
133+
access_rights: dict[GroupID, FunctionGroupAccessRightsGet]
122134
thumbnail: HttpUrl | None = None
123135

124136

@@ -127,7 +139,7 @@ class RegisteredProjectFunctionGet(RegisteredProjectFunction, OutputSchema):
127139
project_id: Annotated[ProjectID, Field(alias="templateId")]
128140
created_at: Annotated[datetime.datetime, Field(alias="creationDate")]
129141
modified_at: Annotated[datetime.datetime, Field(alias="lastChangeDate")]
130-
access_rights: FunctionAccessRights | None = None
142+
access_rights: dict[GroupID, FunctionGroupAccessRightsGet]
131143
thumbnail: HttpUrl | None = None
132144

133145

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

Lines changed: 142 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3761,6 +3761,86 @@ paths:
37613761
responses:
37623762
'204':
37633763
description: Successful Response
3764+
/v0/functions/{function_id}/groups:
3765+
get:
3766+
tags:
3767+
- functions
3768+
summary: Get Function Groups
3769+
operationId: get_function_groups
3770+
parameters:
3771+
- name: function_id
3772+
in: path
3773+
required: true
3774+
schema:
3775+
type: string
3776+
format: uuid
3777+
title: Function Id
3778+
responses:
3779+
'200':
3780+
description: Successful Response
3781+
content:
3782+
application/json:
3783+
schema:
3784+
$ref: '#/components/schemas/Envelope_dict_Annotated_int__Gt___FunctionGroupAccessRightsGet__'
3785+
/v0/functions/{function_id}/groups/{group_id}:
3786+
put:
3787+
tags:
3788+
- functions
3789+
summary: Create or update a Function Group
3790+
operationId: create_or_update_function_group
3791+
parameters:
3792+
- name: function_id
3793+
in: path
3794+
required: true
3795+
schema:
3796+
type: string
3797+
format: uuid
3798+
title: Function Id
3799+
- name: group_id
3800+
in: path
3801+
required: true
3802+
schema:
3803+
type: integer
3804+
exclusiveMinimum: true
3805+
title: Group Id
3806+
minimum: 0
3807+
requestBody:
3808+
required: true
3809+
content:
3810+
application/json:
3811+
schema:
3812+
$ref: '#/components/schemas/FunctionGroupAccessRightsUpdate'
3813+
responses:
3814+
'200':
3815+
description: Successful Response
3816+
content:
3817+
application/json:
3818+
schema:
3819+
$ref: '#/components/schemas/Envelope_FunctionGroupAccessRightsGet_'
3820+
delete:
3821+
tags:
3822+
- functions
3823+
summary: Delete a Function Group
3824+
operationId: delete_function_group
3825+
parameters:
3826+
- name: function_id
3827+
in: path
3828+
required: true
3829+
schema:
3830+
type: string
3831+
format: uuid
3832+
title: Function Id
3833+
- name: group_id
3834+
in: path
3835+
required: true
3836+
schema:
3837+
type: integer
3838+
exclusiveMinimum: true
3839+
title: Group Id
3840+
minimum: 0
3841+
responses:
3842+
'204':
3843+
description: Successful Response
37643844
/v0/tasks:
37653845
get:
37663846
tags:
@@ -10802,6 +10882,19 @@ components:
1080210882
title: Error
1080310883
type: object
1080410884
title: Envelope[FolderGet]
10885+
Envelope_FunctionGroupAccessRightsGet_:
10886+
properties:
10887+
data:
10888+
anyOf:
10889+
- $ref: '#/components/schemas/FunctionGroupAccessRightsGet'
10890+
- type: 'null'
10891+
error:
10892+
anyOf:
10893+
- {}
10894+
- type: 'null'
10895+
title: Error
10896+
type: object
10897+
title: Envelope[FunctionGroupAccessRightsGet]
1080510898
Envelope_GetProjectInactivityResponse_:
1080610899
properties:
1080710900
data:
@@ -11511,6 +11604,22 @@ components:
1151111604
title: Error
1151211605
type: object
1151311606
title: Envelope[_ProjectNodePreview]
11607+
Envelope_dict_Annotated_int__Gt___FunctionGroupAccessRightsGet__:
11608+
properties:
11609+
data:
11610+
anyOf:
11611+
- additionalProperties:
11612+
$ref: '#/components/schemas/FunctionGroupAccessRightsGet'
11613+
type: object
11614+
- type: 'null'
11615+
title: Data
11616+
error:
11617+
anyOf:
11618+
- {}
11619+
- type: 'null'
11620+
title: Error
11621+
type: object
11622+
title: Envelope[dict[Annotated[int, Gt], FunctionGroupAccessRightsGet]]
1151411623
Envelope_dict_Annotated_str__StringConstraints___ImageResources__:
1151511624
properties:
1151611625
data:
@@ -12632,23 +12741,40 @@ components:
1263212741
required:
1263312742
- name
1263412743
title: FolderReplaceBodyParams
12635-
FunctionAccessRights:
12744+
FunctionGroupAccessRightsGet:
1263612745
properties:
1263712746
read:
1263812747
type: boolean
1263912748
title: Read
12640-
default: false
1264112749
write:
1264212750
type: boolean
1264312751
title: Write
12644-
default: false
1264512752
execute:
1264612753
type: boolean
1264712754
title: Execute
12648-
default: false
12649-
additionalProperties: false
1265012755
type: object
12651-
title: FunctionAccessRights
12756+
required:
12757+
- read
12758+
- write
12759+
- execute
12760+
title: FunctionGroupAccessRightsGet
12761+
FunctionGroupAccessRightsUpdate:
12762+
properties:
12763+
read:
12764+
type: boolean
12765+
title: Read
12766+
write:
12767+
type: boolean
12768+
title: Write
12769+
execute:
12770+
type: boolean
12771+
title: Execute
12772+
type: object
12773+
required:
12774+
- read
12775+
- write
12776+
- execute
12777+
title: FunctionGroupAccessRightsUpdate
1265212778
GetProjectInactivityResponse:
1265312779
properties:
1265412780
is_inactive:
@@ -16463,9 +16589,10 @@ components:
1646316589
format: uuid
1646416590
title: Templateid
1646516591
accessRights:
16466-
anyOf:
16467-
- $ref: '#/components/schemas/FunctionAccessRights'
16468-
- type: 'null'
16592+
additionalProperties:
16593+
$ref: '#/components/schemas/FunctionGroupAccessRightsGet'
16594+
type: object
16595+
title: Accessrights
1646916596
thumbnail:
1647016597
anyOf:
1647116598
- type: string
@@ -16483,6 +16610,7 @@ components:
1648316610
- creationDate
1648416611
- lastChangeDate
1648516612
- templateId
16613+
- accessRights
1648616614
title: RegisteredProjectFunctionGet
1648716615
RegisteredSolverFunctionGet:
1648816616
properties:
@@ -16542,9 +16670,10 @@ components:
1654216670
pattern: ^(0|[1-9]\d*)(\.(0|[1-9]\d*)){2}(-(0|[1-9]\d*|\d*[-a-zA-Z][-\da-zA-Z]*)(\.(0|[1-9]\d*|\d*[-a-zA-Z][-\da-zA-Z]*))*)?(\+[-\da-zA-Z]+(\.[-\da-zA-Z-]+)*)?$
1654316671
title: Solverversion
1654416672
accessRights:
16545-
anyOf:
16546-
- $ref: '#/components/schemas/FunctionAccessRights'
16547-
- type: 'null'
16673+
additionalProperties:
16674+
$ref: '#/components/schemas/FunctionGroupAccessRightsGet'
16675+
type: object
16676+
title: Accessrights
1654816677
thumbnail:
1654916678
anyOf:
1655016679
- type: string
@@ -16563,6 +16692,7 @@ components:
1656316692
- lastChangeDate
1656416693
- solverKey
1656516694
- solverVersion
16695+
- accessRights
1656616696
title: RegisteredSolverFunctionGet
1656716697
ReplaceWalletAutoRecharge:
1656816698
properties:

0 commit comments

Comments
 (0)