Skip to content

Commit 3960405

Browse files
authored
✨♻️ webserver: refactored groups plugin and new user privacy compliance (#6917)
1 parent 561985c commit 3960405

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3697
-2276
lines changed

api/specs/web-server/_groups.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
GroupCreate,
1212
GroupGet,
1313
GroupUpdate,
14+
GroupUserAdd,
1415
GroupUserGet,
16+
GroupUserUpdate,
1517
MyGroupsGet,
1618
)
1719
from models_library.generics import Envelope
1820
from simcore_service_webserver._meta import API_VTAG
19-
from simcore_service_webserver.groups._handlers import (
20-
GroupUserAdd,
21-
GroupUserUpdate,
22-
_ClassifiersQuery,
23-
_GroupPathParams,
24-
_GroupUserPathParams,
21+
from simcore_service_webserver.groups._common.schemas import (
22+
GroupsClassifiersQuery,
23+
GroupsPathParams,
24+
GroupsUsersPathParams,
2525
)
2626
from simcore_service_webserver.scicrunch.models import ResearchResource, ResourceHit
2727

@@ -58,7 +58,7 @@ async def create_group(_body: GroupCreate):
5858
"/groups/{gid}",
5959
response_model=Envelope[GroupGet],
6060
)
61-
async def get_group(_path: Annotated[_GroupPathParams, Depends()]):
61+
async def get_group(_path: Annotated[GroupsPathParams, Depends()]):
6262
"""
6363
Get an organization group
6464
"""
@@ -69,7 +69,7 @@ async def get_group(_path: Annotated[_GroupPathParams, Depends()]):
6969
response_model=Envelope[GroupGet],
7070
)
7171
async def update_group(
72-
_path: Annotated[_GroupPathParams, Depends()],
72+
_path: Annotated[GroupsPathParams, Depends()],
7373
_body: GroupUpdate,
7474
):
7575
"""
@@ -81,7 +81,7 @@ async def update_group(
8181
"/groups/{gid}",
8282
status_code=status.HTTP_204_NO_CONTENT,
8383
)
84-
async def delete_group(_path: Annotated[_GroupPathParams, Depends()]):
84+
async def delete_group(_path: Annotated[GroupsPathParams, Depends()]):
8585
"""
8686
Deletes organization groups
8787
"""
@@ -91,7 +91,7 @@ async def delete_group(_path: Annotated[_GroupPathParams, Depends()]):
9191
"/groups/{gid}/users",
9292
response_model=Envelope[list[GroupUserGet]],
9393
)
94-
async def get_all_group_users(_path: Annotated[_GroupPathParams, Depends()]):
94+
async def get_all_group_users(_path: Annotated[GroupsPathParams, Depends()]):
9595
"""
9696
Gets users in organization groups
9797
"""
@@ -102,11 +102,11 @@ async def get_all_group_users(_path: Annotated[_GroupPathParams, Depends()]):
102102
status_code=status.HTTP_204_NO_CONTENT,
103103
)
104104
async def add_group_user(
105-
_path: Annotated[_GroupPathParams, Depends()],
105+
_path: Annotated[GroupsPathParams, Depends()],
106106
_body: GroupUserAdd,
107107
):
108108
"""
109-
Adds a user to an organization group
109+
Adds a user to an organization group using their username, user ID, or email (subject to privacy settings)
110110
"""
111111

112112

@@ -115,7 +115,7 @@ async def add_group_user(
115115
response_model=Envelope[GroupUserGet],
116116
)
117117
async def get_group_user(
118-
_path: Annotated[_GroupUserPathParams, Depends()],
118+
_path: Annotated[GroupsUsersPathParams, Depends()],
119119
):
120120
"""
121121
Gets specific user in an organization group
@@ -127,7 +127,7 @@ async def get_group_user(
127127
response_model=Envelope[GroupUserGet],
128128
)
129129
async def update_group_user(
130-
_path: Annotated[_GroupUserPathParams, Depends()],
130+
_path: Annotated[GroupsUsersPathParams, Depends()],
131131
_body: GroupUserUpdate,
132132
):
133133
"""
@@ -140,7 +140,7 @@ async def update_group_user(
140140
status_code=status.HTTP_204_NO_CONTENT,
141141
)
142142
async def delete_group_user(
143-
_path: Annotated[_GroupUserPathParams, Depends()],
143+
_path: Annotated[GroupsUsersPathParams, Depends()],
144144
):
145145
"""
146146
Removes a user from an organization group
@@ -157,8 +157,8 @@ async def delete_group_user(
157157
response_model=Envelope[dict[str, Any]],
158158
)
159159
async def get_group_classifiers(
160-
_path: Annotated[_GroupPathParams, Depends()],
161-
_query: Annotated[_ClassifiersQuery, Depends()],
160+
_path: Annotated[GroupsPathParams, Depends()],
161+
_query: Annotated[GroupsClassifiersQuery, Depends()],
162162
):
163163
...
164164

api/specs/web-server/_users.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from typing import Annotated
88

99
from fastapi import APIRouter, Depends, status
10-
from models_library.api_schemas_webserver.users import ProfileGet, ProfileUpdate
10+
from models_library.api_schemas_webserver.users import MyProfileGet, MyProfilePatch
1111
from models_library.api_schemas_webserver.users_preferences import PatchRequestBody
1212
from models_library.generics import Envelope
1313
from models_library.user_preferences import PreferenceIdentifier
@@ -34,7 +34,7 @@
3434

3535
@router.get(
3636
"/me",
37-
response_model=Envelope[ProfileGet],
37+
response_model=Envelope[MyProfileGet],
3838
)
3939
async def get_my_profile():
4040
...
@@ -44,7 +44,7 @@ async def get_my_profile():
4444
"/me",
4545
status_code=status.HTTP_204_NO_CONTENT,
4646
)
47-
async def update_my_profile(_profile: ProfileUpdate):
47+
async def update_my_profile(_profile: MyProfilePatch):
4848
...
4949

5050

@@ -54,7 +54,7 @@ async def update_my_profile(_profile: ProfileUpdate):
5454
deprecated=True,
5555
description="Use PATCH instead",
5656
)
57-
async def replace_my_profile(_profile: ProfileUpdate):
57+
async def replace_my_profile(_profile: MyProfilePatch):
5858
...
5959

6060

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class InputSchemaWithoutCamelCase(BaseModel):
2424

2525
class InputSchema(BaseModel):
2626
model_config = ConfigDict(
27-
**InputSchemaWithoutCamelCase.model_config, alias_generator=snake_to_camel
27+
**InputSchemaWithoutCamelCase.model_config,
28+
alias_generator=snake_to_camel,
2829
)
2930

3031

@@ -50,7 +51,7 @@ def data(
5051
exclude_unset=exclude_unset,
5152
exclude_defaults=exclude_defaults,
5253
exclude_none=exclude_none,
53-
**kwargs
54+
**kwargs,
5455
)
5556

5657
def data_json(
@@ -67,5 +68,5 @@ def data_json(
6768
exclude_unset=exclude_unset,
6869
exclude_defaults=exclude_defaults,
6970
exclude_none=exclude_none,
70-
**kwargs
71+
**kwargs,
7172
)

0 commit comments

Comments
 (0)