Skip to content

Commit

Permalink
✨♻️ webserver: refactored groups plugin and new user privacy complian…
Browse files Browse the repository at this point in the history
…ce (#6917)
  • Loading branch information
pcrespov authored Dec 10, 2024
1 parent 561985c commit 3960405
Show file tree
Hide file tree
Showing 54 changed files with 3,697 additions and 2,276 deletions.
34 changes: 17 additions & 17 deletions api/specs/web-server/_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
GroupCreate,
GroupGet,
GroupUpdate,
GroupUserAdd,
GroupUserGet,
GroupUserUpdate,
MyGroupsGet,
)
from models_library.generics import Envelope
from simcore_service_webserver._meta import API_VTAG
from simcore_service_webserver.groups._handlers import (
GroupUserAdd,
GroupUserUpdate,
_ClassifiersQuery,
_GroupPathParams,
_GroupUserPathParams,
from simcore_service_webserver.groups._common.schemas import (
GroupsClassifiersQuery,
GroupsPathParams,
GroupsUsersPathParams,
)
from simcore_service_webserver.scicrunch.models import ResearchResource, ResourceHit

Expand Down Expand Up @@ -58,7 +58,7 @@ async def create_group(_body: GroupCreate):
"/groups/{gid}",
response_model=Envelope[GroupGet],
)
async def get_group(_path: Annotated[_GroupPathParams, Depends()]):
async def get_group(_path: Annotated[GroupsPathParams, Depends()]):
"""
Get an organization group
"""
Expand All @@ -69,7 +69,7 @@ async def get_group(_path: Annotated[_GroupPathParams, Depends()]):
response_model=Envelope[GroupGet],
)
async def update_group(
_path: Annotated[_GroupPathParams, Depends()],
_path: Annotated[GroupsPathParams, Depends()],
_body: GroupUpdate,
):
"""
Expand All @@ -81,7 +81,7 @@ async def update_group(
"/groups/{gid}",
status_code=status.HTTP_204_NO_CONTENT,
)
async def delete_group(_path: Annotated[_GroupPathParams, Depends()]):
async def delete_group(_path: Annotated[GroupsPathParams, Depends()]):
"""
Deletes organization groups
"""
Expand All @@ -91,7 +91,7 @@ async def delete_group(_path: Annotated[_GroupPathParams, Depends()]):
"/groups/{gid}/users",
response_model=Envelope[list[GroupUserGet]],
)
async def get_all_group_users(_path: Annotated[_GroupPathParams, Depends()]):
async def get_all_group_users(_path: Annotated[GroupsPathParams, Depends()]):
"""
Gets users in organization groups
"""
Expand All @@ -102,11 +102,11 @@ async def get_all_group_users(_path: Annotated[_GroupPathParams, Depends()]):
status_code=status.HTTP_204_NO_CONTENT,
)
async def add_group_user(
_path: Annotated[_GroupPathParams, Depends()],
_path: Annotated[GroupsPathParams, Depends()],
_body: GroupUserAdd,
):
"""
Adds a user to an organization group
Adds a user to an organization group using their username, user ID, or email (subject to privacy settings)
"""


Expand All @@ -115,7 +115,7 @@ async def add_group_user(
response_model=Envelope[GroupUserGet],
)
async def get_group_user(
_path: Annotated[_GroupUserPathParams, Depends()],
_path: Annotated[GroupsUsersPathParams, Depends()],
):
"""
Gets specific user in an organization group
Expand All @@ -127,7 +127,7 @@ async def get_group_user(
response_model=Envelope[GroupUserGet],
)
async def update_group_user(
_path: Annotated[_GroupUserPathParams, Depends()],
_path: Annotated[GroupsUsersPathParams, Depends()],
_body: GroupUserUpdate,
):
"""
Expand All @@ -140,7 +140,7 @@ async def update_group_user(
status_code=status.HTTP_204_NO_CONTENT,
)
async def delete_group_user(
_path: Annotated[_GroupUserPathParams, Depends()],
_path: Annotated[GroupsUsersPathParams, Depends()],
):
"""
Removes a user from an organization group
Expand All @@ -157,8 +157,8 @@ async def delete_group_user(
response_model=Envelope[dict[str, Any]],
)
async def get_group_classifiers(
_path: Annotated[_GroupPathParams, Depends()],
_query: Annotated[_ClassifiersQuery, Depends()],
_path: Annotated[GroupsPathParams, Depends()],
_query: Annotated[GroupsClassifiersQuery, Depends()],
):
...

Expand Down
8 changes: 4 additions & 4 deletions api/specs/web-server/_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Annotated

from fastapi import APIRouter, Depends, status
from models_library.api_schemas_webserver.users import ProfileGet, ProfileUpdate
from models_library.api_schemas_webserver.users import MyProfileGet, MyProfilePatch
from models_library.api_schemas_webserver.users_preferences import PatchRequestBody
from models_library.generics import Envelope
from models_library.user_preferences import PreferenceIdentifier
Expand All @@ -34,7 +34,7 @@

@router.get(
"/me",
response_model=Envelope[ProfileGet],
response_model=Envelope[MyProfileGet],
)
async def get_my_profile():
...
Expand All @@ -44,7 +44,7 @@ async def get_my_profile():
"/me",
status_code=status.HTTP_204_NO_CONTENT,
)
async def update_my_profile(_profile: ProfileUpdate):
async def update_my_profile(_profile: MyProfilePatch):
...


Expand All @@ -54,7 +54,7 @@ async def update_my_profile(_profile: ProfileUpdate):
deprecated=True,
description="Use PATCH instead",
)
async def replace_my_profile(_profile: ProfileUpdate):
async def replace_my_profile(_profile: MyProfilePatch):
...


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class InputSchemaWithoutCamelCase(BaseModel):

class InputSchema(BaseModel):
model_config = ConfigDict(
**InputSchemaWithoutCamelCase.model_config, alias_generator=snake_to_camel
**InputSchemaWithoutCamelCase.model_config,
alias_generator=snake_to_camel,
)


Expand All @@ -50,7 +51,7 @@ def data(
exclude_unset=exclude_unset,
exclude_defaults=exclude_defaults,
exclude_none=exclude_none,
**kwargs
**kwargs,
)

def data_json(
Expand All @@ -67,5 +68,5 @@ def data_json(
exclude_unset=exclude_unset,
exclude_defaults=exclude_defaults,
exclude_none=exclude_none,
**kwargs
**kwargs,
)
Loading

0 comments on commit 3960405

Please sign in to comment.