Skip to content

Commit 9f06e36

Browse files
authored
✨ web-api interface for tags sharing and add to services (#6298)
1 parent 1c918c2 commit 9f06e36

File tree

17 files changed

+3782
-3097
lines changed

17 files changed

+3782
-3097
lines changed

api/specs/web-server/_catalog_tags.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# pylint: disable=redefined-outer-name
2+
# pylint: disable=unused-argument
3+
# pylint: disable=unused-variable
4+
# pylint: disable=too-many-arguments
5+
6+
7+
from typing import Annotated
8+
9+
from fastapi import APIRouter, Depends
10+
from models_library.api_schemas_webserver.catalog import CatalogServiceGet
11+
from models_library.generics import Envelope
12+
from simcore_service_webserver._meta import API_VTAG
13+
from simcore_service_webserver.catalog._tags_handlers import (
14+
ServicePathParams,
15+
ServiceTagPathParams,
16+
)
17+
from simcore_service_webserver.tags.schemas import TagGet
18+
19+
router = APIRouter(
20+
prefix=f"/{API_VTAG}",
21+
tags=[
22+
"catalog",
23+
"tags",
24+
],
25+
)
26+
27+
28+
@router.get(
29+
"/catalog/services/{service_key}/{service_version}/tags",
30+
response_model=Envelope[list[TagGet]],
31+
)
32+
def list_service_tags(
33+
_path_params: Annotated[ServicePathParams, Depends()],
34+
):
35+
...
36+
37+
38+
@router.post(
39+
"/catalog/services/{service_key}/{service_version}/tags/{tag_id}:add",
40+
response_model=Envelope[CatalogServiceGet],
41+
)
42+
def add_service_tag(
43+
_path_params: Annotated[ServiceTagPathParams, Depends()],
44+
):
45+
...
46+
47+
48+
@router.post(
49+
"/catalog/services/{service_key}/{service_version}/tags/{tag_id}:remove",
50+
response_model=Envelope[CatalogServiceGet],
51+
)
52+
def remove_service_tag(
53+
_path_params: Annotated[ServiceTagPathParams, Depends()],
54+
):
55+
...

api/specs/web-server/_projects_groups.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818

1919
router = APIRouter(
2020
prefix=f"/{API_VTAG}",
21-
tags=[
22-
"projects",
23-
],
21+
tags=["projects", "groups"],
2422
)
2523

2624

api/specs/web-server/_projects_tags.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,31 @@
1919
)
2020

2121

22-
@router.put(
23-
"/projects/{project_uuid}/tags/{tag_id}",
22+
@router.post(
23+
"/projects/{project_uuid}/tags/{tag_id}:add",
2424
response_model=Envelope[ProjectGet],
2525
)
26-
def add_tag(
26+
def add_project_tag(
2727
project_uuid: ProjectID,
2828
tag_id: int,
2929
):
3030
"""
3131
Links an existing label with an existing study
32+
33+
NOTE: that the tag is not created here
3234
"""
3335

3436

35-
@router.delete(
36-
"/projects/{project_uuid}/tags/{tag_id}",
37+
@router.post(
38+
"/projects/{project_uuid}/tags/{tag_id}:remove",
3739
response_model=Envelope[ProjectGet],
3840
)
39-
def remove_tag(
41+
def remove_project_tag(
4042
project_uuid: ProjectID,
4143
tag_id: int,
4244
):
4345
"""
4446
Removes an existing link between a label and a study
47+
48+
NOTE: that the tag is not deleted here
4549
"""

api/specs/web-server/_tags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from fastapi import APIRouter, Depends, status
1010
from models_library.generics import Envelope
1111
from simcore_service_webserver._meta import API_VTAG
12-
from simcore_service_webserver.tags._handlers import (
12+
from simcore_service_webserver.tags.schemas import (
1313
TagCreate,
1414
TagGet,
1515
TagPathParams,

api/specs/web-server/_tags_groups.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# pylint: disable=redefined-outer-name
2+
# pylint: disable=unused-argument
3+
# pylint: disable=unused-variable
4+
# pylint: disable=too-many-arguments
5+
6+
7+
from typing import Annotated
8+
9+
from fastapi import APIRouter, Depends, status
10+
from models_library.generics import Envelope
11+
from simcore_service_webserver._meta import API_VTAG
12+
from simcore_service_webserver.tags.schemas import (
13+
TagGet,
14+
TagGroupCreate,
15+
TagGroupGet,
16+
TagGroupPathParams,
17+
TagPathParams,
18+
)
19+
20+
router = APIRouter(
21+
prefix=f"/{API_VTAG}",
22+
tags=[
23+
"tags",
24+
"groups",
25+
],
26+
)
27+
28+
29+
@router.get(
30+
"/tags/{tag_id}/groups",
31+
response_model=Envelope[list[TagGroupGet]],
32+
)
33+
async def list_tag_groups(_path_params: Annotated[TagPathParams, Depends()]):
34+
...
35+
36+
37+
@router.post(
38+
"/tags/{tag_id}/groups/{group_id}",
39+
response_model=Envelope[TagGet],
40+
status_code=status.HTTP_201_CREATED,
41+
)
42+
async def create_tag_group(
43+
_path_params: Annotated[TagGroupPathParams, Depends()], _body: TagGroupCreate
44+
):
45+
...
46+
47+
48+
@router.put(
49+
"/tags/{tag_id}/groups/{group_id}",
50+
response_model=Envelope[list[TagGroupGet]],
51+
)
52+
async def replace_tag_groups(
53+
_path_params: Annotated[TagGroupPathParams, Depends()], _body: TagGroupCreate
54+
):
55+
...
56+
57+
58+
@router.delete(
59+
"/tags/{tag_id}/groups/{group_id}",
60+
status_code=status.HTTP_204_NO_CONTENT,
61+
)
62+
async def delete_tag_group(_path_params: Annotated[TagGroupPathParams, Depends()]):
63+
...

api/specs/web-server/_wallets.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# pylint: disable=too-many-arguments
88

99

10+
from enum import Enum
1011
from typing import Annotated
1112

1213
from fastapi import APIRouter, Depends, status
@@ -214,12 +215,14 @@ async def replace_wallet_autorecharge(
214215

215216

216217
### Wallets groups
218+
_extra_tags: list[str | Enum] = ["groups"]
217219

218220

219221
@router.post(
220222
"/wallets/{wallet_id}/groups/{group_id}",
221223
response_model=Envelope[WalletGroupGet],
222224
status_code=status.HTTP_201_CREATED,
225+
tags=_extra_tags,
223226
)
224227
async def create_wallet_group(
225228
wallet_id: WalletID, group_id: GroupID, body: _WalletsGroupsBodyParams
@@ -230,6 +233,7 @@ async def create_wallet_group(
230233
@router.get(
231234
"/wallets/{wallet_id}/groups",
232235
response_model=Envelope[list[WalletGroupGet]],
236+
tags=_extra_tags,
233237
)
234238
async def list_wallet_groups(wallet_id: WalletID):
235239
...
@@ -238,6 +242,7 @@ async def list_wallet_groups(wallet_id: WalletID):
238242
@router.put(
239243
"/wallets/{wallet_id}/groups/{group_id}",
240244
response_model=Envelope[WalletGroupGet],
245+
tags=_extra_tags,
241246
)
242247
async def update_wallet_group(
243248
wallet_id: WalletID, group_id: GroupID, body: _WalletsGroupsBodyParams
@@ -248,6 +253,7 @@ async def update_wallet_group(
248253
@router.delete(
249254
"/wallets/{wallet_id}/groups/{group_id}",
250255
status_code=status.HTTP_204_NO_CONTENT,
256+
tags=_extra_tags,
251257
)
252258
async def delete_wallet_group(wallet_id: WalletID, group_id: GroupID):
253259
...

api/specs/web-server/_workspaces.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,22 @@
77
# pylint: disable=too-many-arguments
88

99

10-
from fastapi import APIRouter, status
10+
from enum import Enum
11+
from typing import Annotated
12+
13+
from fastapi import APIRouter, Depends, status
1114
from models_library.api_schemas_webserver.workspaces import (
1215
CreateWorkspaceBodyParams,
1316
PutWorkspaceBodyParams,
1417
WorkspaceGet,
1518
)
1619
from models_library.generics import Envelope
17-
from models_library.users import GroupID
1820
from models_library.workspaces import WorkspaceID
1921
from simcore_service_webserver._meta import API_VTAG
2022
from simcore_service_webserver.workspaces._groups_api import WorkspaceGroupGet
2123
from simcore_service_webserver.workspaces._groups_handlers import (
2224
_WorkspacesGroupsBodyParams,
25+
_WorkspacesGroupsPathParams,
2326
)
2427

2528
router = APIRouter(
@@ -37,7 +40,7 @@
3740
response_model=Envelope[WorkspaceGet],
3841
status_code=status.HTTP_201_CREATED,
3942
)
40-
async def create_workspace(body: CreateWorkspaceBodyParams):
43+
async def create_workspace(_body: CreateWorkspaceBodyParams):
4144
...
4245

4346

@@ -61,7 +64,7 @@ async def get_workspace(workspace_id: WorkspaceID):
6164
"/workspaces/{workspace_id}",
6265
response_model=Envelope[WorkspaceGet],
6366
)
64-
async def replace_workspace(workspace_id: WorkspaceID, body: PutWorkspaceBodyParams):
67+
async def replace_workspace(workspace_id: WorkspaceID, _body: PutWorkspaceBodyParams):
6568
...
6669

6770

@@ -74,22 +77,26 @@ async def delete_workspace(workspace_id: WorkspaceID):
7477

7578

7679
### Workspaces groups
80+
_extra_tags: list[str | Enum] = ["groups"]
7781

7882

7983
@router.post(
8084
"/workspaces/{workspace_id}/groups/{group_id}",
8185
response_model=Envelope[WorkspaceGroupGet],
8286
status_code=status.HTTP_201_CREATED,
87+
tags=_extra_tags,
8388
)
8489
async def create_workspace_group(
85-
workspace_id: WorkspaceID, group_id: GroupID, body: _WorkspacesGroupsBodyParams
90+
_path_parms: Annotated[_WorkspacesGroupsPathParams, Depends()],
91+
_body: _WorkspacesGroupsBodyParams,
8692
):
8793
...
8894

8995

9096
@router.get(
9197
"/workspaces/{workspace_id}/groups",
9298
response_model=Envelope[list[WorkspaceGroupGet]],
99+
tags=_extra_tags,
93100
)
94101
async def list_workspace_groups(workspace_id: WorkspaceID):
95102
...
@@ -98,16 +105,21 @@ async def list_workspace_groups(workspace_id: WorkspaceID):
98105
@router.put(
99106
"/workspaces/{workspace_id}/groups/{group_id}",
100107
response_model=Envelope[WorkspaceGroupGet],
108+
tags=_extra_tags,
101109
)
102110
async def replace_workspace_group(
103-
workspace_id: WorkspaceID, group_id: GroupID, body: _WorkspacesGroupsBodyParams
111+
_path_parms: Annotated[_WorkspacesGroupsPathParams, Depends()],
112+
_body: _WorkspacesGroupsBodyParams,
104113
):
105114
...
106115

107116

108117
@router.delete(
109118
"/workspaces/{workspace_id}/groups/{group_id}",
110119
status_code=status.HTTP_204_NO_CONTENT,
120+
tags=_extra_tags,
111121
)
112-
async def delete_workspace_group(workspace_id: WorkspaceID, group_id: GroupID):
122+
async def delete_workspace_group(
123+
_path_parms: Annotated[_WorkspacesGroupsPathParams, Depends()]
124+
):
113125
...

api/specs/web-server/openapi.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,37 @@
1515
openapi_modules = [
1616
importlib.import_module(name)
1717
for name in (
18+
# NOTE: order matters on how the paths are displayed in the OAS!
19+
# It does not have to be alphabetical
20+
#
21+
# core ---
22+
"_auth",
23+
"_groups",
24+
"_tags",
25+
"_tags_groups", # after _tags
26+
"_products",
27+
"_users",
28+
"_wallets",
29+
# add-ons ---
1830
"_activity",
19-
"_admin",
2031
"_announcements",
21-
"_auth",
2232
"_catalog",
33+
"_catalog_tags", # after _catalog
2334
"_cluster",
2435
"_computations",
25-
"_diagnostics",
2636
"_exporter",
2737
"_folders",
28-
"_groups",
2938
"_long_running_tasks",
3039
"_metamodeling",
31-
"_nih_sparc_redirections",
3240
"_nih_sparc",
33-
"_products",
34-
"_projects_nodes_pricing_unit",
35-
"_projects_comments",
41+
"_nih_sparc_redirections",
3642
"_projects_crud",
37-
"_projects_groups",
43+
"_projects_comments",
3844
"_projects_folders",
45+
"_projects_groups",
3946
"_projects_metadata",
4047
"_projects_nodes",
48+
"_projects_nodes_pricing_unit", # after _projects_nodes
4149
"_projects_ports",
4250
"_projects_states",
4351
"_projects_tags",
@@ -47,11 +55,11 @@
4755
"_resource_usage",
4856
"_statics",
4957
"_storage",
50-
"_tags",
51-
"_users",
5258
"_version_control",
53-
"_wallets",
5459
"_workspaces",
60+
# maintenance ----
61+
"_admin",
62+
"_diagnostics",
5563
)
5664
]
5765

services/static-webserver/client/source/class/osparc/data/Resources.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,13 @@ qx.Class.define("osparc.data.Resources", {
260260
},
261261
addTag: {
262262
useCache: false,
263-
method: "PUT",
264-
url: statics.API + "/projects/{studyId}/tags/{tagId}"
263+
method: "POST",
264+
url: statics.API + "/projects/{studyId}/tags/{tagId}:add"
265265
},
266266
removeTag: {
267267
useCache: false,
268-
method: "DELETE",
269-
url: statics.API + "/projects/{studyId}/tags/{tagId}"
268+
method: "POST",
269+
url: statics.API + "/projects/{studyId}/tags/{tagId}:remove"
270270
},
271271
getInactivity: {
272272
useCache: false,

0 commit comments

Comments
 (0)