4
4
# pylint: disable=too-many-arguments
5
5
6
6
7
+ from enum import Enum
7
8
from typing import Annotated
8
9
9
10
from fastapi import APIRouter , Depends , status
13
14
MyProfilePatch ,
14
15
MyTokenCreate ,
15
16
MyTokenGet ,
17
+ UserForAdminGet ,
16
18
UserGet ,
17
- UsersSearchQueryParams ,
19
+ UsersForAdminSearchQueryParams ,
20
+ UsersSearch ,
18
21
)
19
22
from models_library .api_schemas_webserver .users_preferences import PatchRequestBody
20
23
from models_library .generics import Envelope
29
32
from simcore_service_webserver .users ._notifications_rest import _NotificationPathParams
30
33
from simcore_service_webserver .users ._tokens_rest import _TokenPathParams
31
34
32
- router = APIRouter (prefix = f"/{ API_VTAG } " , tags = ["user " ])
35
+ router = APIRouter (prefix = f"/{ API_VTAG } " , tags = ["users " ])
33
36
34
37
35
38
@router .get (
@@ -44,7 +47,7 @@ async def get_my_profile():
44
47
"/me" ,
45
48
status_code = status .HTTP_204_NO_CONTENT ,
46
49
)
47
- async def update_my_profile (_profile : MyProfilePatch ):
50
+ async def update_my_profile (_body : MyProfilePatch ):
48
51
...
49
52
50
53
@@ -54,7 +57,7 @@ async def update_my_profile(_profile: MyProfilePatch):
54
57
deprecated = True ,
55
58
description = "Use PATCH instead" ,
56
59
)
57
- async def replace_my_profile (_profile : MyProfilePatch ):
60
+ async def replace_my_profile (_body : MyProfilePatch ):
58
61
...
59
62
60
63
@@ -64,7 +67,7 @@ async def replace_my_profile(_profile: MyProfilePatch):
64
67
)
65
68
async def set_frontend_preference (
66
69
preference_id : PreferenceIdentifier ,
67
- body_item : PatchRequestBody ,
70
+ _body : PatchRequestBody ,
68
71
):
69
72
...
70
73
@@ -82,23 +85,25 @@ async def list_tokens():
82
85
response_model = Envelope [MyTokenGet ],
83
86
status_code = status .HTTP_201_CREATED ,
84
87
)
85
- async def create_token (_token : MyTokenCreate ):
88
+ async def create_token (_body : MyTokenCreate ):
86
89
...
87
90
88
91
89
92
@router .get (
90
93
"/me/tokens/{service}" ,
91
94
response_model = Envelope [MyTokenGet ],
92
95
)
93
- async def get_token (_params : Annotated [_TokenPathParams , Depends ()]):
96
+ async def get_token (
97
+ _path : Annotated [_TokenPathParams , Depends ()],
98
+ ):
94
99
...
95
100
96
101
97
102
@router .delete (
98
103
"/me/tokens/{service}" ,
99
104
status_code = status .HTTP_204_NO_CONTENT ,
100
105
)
101
- async def delete_token (_params : Annotated [_TokenPathParams , Depends ()]):
106
+ async def delete_token (_path : Annotated [_TokenPathParams , Depends ()]):
102
107
...
103
108
104
109
@@ -114,7 +119,9 @@ async def list_user_notifications():
114
119
"/me/notifications" ,
115
120
status_code = status .HTTP_204_NO_CONTENT ,
116
121
)
117
- async def create_user_notification (_notification : UserNotificationCreate ):
122
+ async def create_user_notification (
123
+ _body : UserNotificationCreate ,
124
+ ):
118
125
...
119
126
120
127
@@ -123,8 +130,8 @@ async def create_user_notification(_notification: UserNotificationCreate):
123
130
status_code = status .HTTP_204_NO_CONTENT ,
124
131
)
125
132
async def mark_notification_as_read (
126
- _params : Annotated [_NotificationPathParams , Depends ()],
127
- _notification : UserNotificationPatch ,
133
+ _path : Annotated [_NotificationPathParams , Depends ()],
134
+ _body : UserNotificationPatch ,
128
135
):
129
136
...
130
137
@@ -137,24 +144,43 @@ async def list_user_permissions():
137
144
...
138
145
139
146
140
- @router .get (
147
+ #
148
+ # USERS public
149
+ #
150
+
151
+
152
+ @router .post (
141
153
"/users:search" ,
142
154
response_model = Envelope [list [UserGet ]],
143
- tags = [
144
- "po" ,
145
- ],
155
+ description = "Search among users who are publicly visible to the caller (i.e., me) based on their privacy settings." ,
146
156
)
147
- async def search_users (_params : Annotated [UsersSearchQueryParams , Depends ()]):
157
+ async def search_users (_body : UsersSearch ):
158
+ ...
159
+
160
+
161
+ #
162
+ # USERS admin
163
+ #
164
+
165
+ _extra_tags : list [str | Enum ] = ["admin" ]
166
+
167
+
168
+ @router .get (
169
+ "/admin/users:search" ,
170
+ response_model = Envelope [list [UserForAdminGet ]],
171
+ tags = _extra_tags ,
172
+ )
173
+ async def search_users_for_admin (
174
+ _query : Annotated [UsersForAdminSearchQueryParams , Depends ()]
175
+ ):
148
176
# NOTE: see `Search` in `Common Custom Methods` in https://cloud.google.com/apis/design/custom_methods
149
177
...
150
178
151
179
152
180
@router .post (
153
- "/users:pre-register" ,
154
- response_model = Envelope [UserGet ],
155
- tags = [
156
- "po" ,
157
- ],
181
+ "/admin/users:pre-register" ,
182
+ response_model = Envelope [UserForAdminGet ],
183
+ tags = _extra_tags ,
158
184
)
159
- async def pre_register_user (_body : PreRegisteredUserGet ):
185
+ async def pre_register_user_for_admin (_body : PreRegisteredUserGet ):
160
186
...
0 commit comments