|
8 | 8 |
|
9 | 9 | from fastapi import APIRouter, Depends, status |
10 | 10 | from models_library.api_schemas_webserver.groups import ( |
11 | | - AllUsersGroups, |
| 11 | + GroupCreate, |
| 12 | + GroupGet, |
| 13 | + GroupUpdate, |
12 | 14 | GroupUserGet, |
13 | | - UsersGroup, |
| 15 | + MyGroupsGet, |
14 | 16 | ) |
15 | 17 | from models_library.generics import Envelope |
16 | | -from models_library.users import GroupID, UserID |
17 | 18 | from simcore_service_webserver._meta import API_VTAG |
18 | | -from simcore_service_webserver.groups._handlers import _ClassifiersQuery |
| 19 | +from simcore_service_webserver.groups._handlers import ( |
| 20 | + GroupUserAdd, |
| 21 | + GroupUserUpdate, |
| 22 | + _ClassifiersQuery, |
| 23 | + _GroupPathParams, |
| 24 | + _GroupUserPathParams, |
| 25 | +) |
19 | 26 | from simcore_service_webserver.scicrunch.models import ResearchResource, ResourceHit |
20 | 27 |
|
21 | 28 | router = APIRouter( |
|
28 | 35 |
|
29 | 36 | @router.get( |
30 | 37 | "/groups", |
31 | | - response_model=Envelope[AllUsersGroups], |
| 38 | + response_model=Envelope[MyGroupsGet], |
32 | 39 | ) |
33 | 40 | async def list_groups(): |
34 | | - ... |
| 41 | + """ |
| 42 | + List all groups (organizations, primary, everyone and products) I belong to |
| 43 | + """ |
35 | 44 |
|
36 | 45 |
|
37 | 46 | @router.post( |
38 | 47 | "/groups", |
39 | | - response_model=Envelope[UsersGroup], |
| 48 | + response_model=Envelope[GroupGet], |
40 | 49 | status_code=status.HTTP_201_CREATED, |
41 | 50 | ) |
42 | | -async def create_group(): |
43 | | - ... |
| 51 | +async def create_group(_b: GroupCreate): |
| 52 | + """ |
| 53 | + Creates an organization group |
| 54 | + """ |
44 | 55 |
|
45 | 56 |
|
46 | 57 | @router.get( |
47 | 58 | "/groups/{gid}", |
48 | | - response_model=Envelope[UsersGroup], |
| 59 | + response_model=Envelope[GroupGet], |
49 | 60 | ) |
50 | | -async def get_group(gid: GroupID): |
51 | | - ... |
| 61 | +async def get_group(_p: Annotated[_GroupPathParams, Depends()]): |
| 62 | + """ |
| 63 | + Get an organization group |
| 64 | + """ |
52 | 65 |
|
53 | 66 |
|
54 | 67 | @router.patch( |
55 | 68 | "/groups/{gid}", |
56 | | - response_model=Envelope[UsersGroup], |
| 69 | + response_model=Envelope[GroupGet], |
57 | 70 | ) |
58 | | -async def update_group(gid: GroupID, _update: UsersGroup): |
59 | | - ... |
| 71 | +async def update_group( |
| 72 | + _p: Annotated[_GroupPathParams, Depends()], |
| 73 | + _b: GroupUpdate, |
| 74 | +): |
| 75 | + """ |
| 76 | + Updates organization groups |
| 77 | + """ |
60 | 78 |
|
61 | 79 |
|
62 | 80 | @router.delete( |
63 | 81 | "/groups/{gid}", |
64 | 82 | status_code=status.HTTP_204_NO_CONTENT, |
65 | 83 | ) |
66 | | -async def delete_group(gid: GroupID): |
67 | | - ... |
| 84 | +async def delete_group(_p: Annotated[_GroupPathParams, Depends()]): |
| 85 | + """ |
| 86 | + Deletes organization groups |
| 87 | + """ |
68 | 88 |
|
69 | 89 |
|
70 | 90 | @router.get( |
71 | 91 | "/groups/{gid}/users", |
72 | 92 | response_model=Envelope[list[GroupUserGet]], |
73 | 93 | ) |
74 | | -async def get_group_users(gid: GroupID): |
75 | | - ... |
| 94 | +async def get_all_group_users(_p: Annotated[_GroupPathParams, Depends()]): |
| 95 | + """ |
| 96 | + Gets users in organization groups |
| 97 | + """ |
76 | 98 |
|
77 | 99 |
|
78 | 100 | @router.post( |
79 | 101 | "/groups/{gid}/users", |
80 | 102 | status_code=status.HTTP_204_NO_CONTENT, |
81 | 103 | ) |
82 | 104 | async def add_group_user( |
83 | | - gid: GroupID, |
84 | | - _new: GroupUserGet, |
| 105 | + _p: Annotated[_GroupPathParams, Depends()], |
| 106 | + _b: GroupUserAdd, |
85 | 107 | ): |
86 | | - ... |
| 108 | + """ |
| 109 | + Adds a user to an organization group |
| 110 | + """ |
87 | 111 |
|
88 | 112 |
|
89 | 113 | @router.get( |
90 | 114 | "/groups/{gid}/users/{uid}", |
91 | 115 | response_model=Envelope[GroupUserGet], |
92 | 116 | ) |
93 | 117 | async def get_group_user( |
94 | | - gid: GroupID, |
95 | | - uid: UserID, |
| 118 | + _p: Annotated[_GroupUserPathParams, Depends()], |
96 | 119 | ): |
97 | | - ... |
| 120 | + """ |
| 121 | + Gets specific user in an organization group |
| 122 | + """ |
98 | 123 |
|
99 | 124 |
|
100 | 125 | @router.patch( |
101 | 126 | "/groups/{gid}/users/{uid}", |
102 | 127 | response_model=Envelope[GroupUserGet], |
103 | 128 | ) |
104 | 129 | async def update_group_user( |
105 | | - gid: GroupID, |
106 | | - uid: UserID, |
107 | | - _update: GroupUserGet, |
| 130 | + _p: Annotated[_GroupUserPathParams, Depends()], |
| 131 | + _b: GroupUserUpdate, |
108 | 132 | ): |
109 | | - # FIXME: update type |
110 | | - ... |
| 133 | + """ |
| 134 | + Updates user (access-rights) to an organization group |
| 135 | + """ |
111 | 136 |
|
112 | 137 |
|
113 | 138 | @router.delete( |
114 | 139 | "/groups/{gid}/users/{uid}", |
115 | 140 | status_code=status.HTTP_204_NO_CONTENT, |
116 | 141 | ) |
117 | 142 | async def delete_group_user( |
118 | | - gid: GroupID, |
119 | | - uid: UserID, |
| 143 | + _p: Annotated[_GroupUserPathParams, Depends()], |
120 | 144 | ): |
121 | | - ... |
| 145 | + """ |
| 146 | + Removes a user from an organization group |
| 147 | + """ |
| 148 | + |
| 149 | + |
| 150 | +# |
| 151 | +# Classifiers |
| 152 | +# |
122 | 153 |
|
123 | 154 |
|
124 | 155 | @router.get( |
125 | 156 | "/groups/{gid}/classifiers", |
126 | 157 | response_model=Envelope[dict[str, Any]], |
127 | 158 | ) |
128 | 159 | async def get_group_classifiers( |
129 | | - gid: GroupID, |
130 | | - _query: Annotated[_ClassifiersQuery, Depends()], |
| 160 | + _p: Annotated[_GroupPathParams, Depends()], |
| 161 | + _q: Annotated[_ClassifiersQuery, Depends()], |
131 | 162 | ): |
132 | 163 | ... |
133 | 164 |
|
|
0 commit comments