Skip to content

✨ web-api interface for tags sharing and add to services #6298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions api/specs/web-server/_catalog_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument
# pylint: disable=unused-variable
# pylint: disable=too-many-arguments


from typing import Annotated

from fastapi import APIRouter, Depends
from models_library.api_schemas_webserver.catalog import CatalogServiceGet
from models_library.generics import Envelope
from simcore_service_webserver._meta import API_VTAG
from simcore_service_webserver.catalog._tags_handlers import (
ServicePathParams,
ServiceTagPathParams,
)
from simcore_service_webserver.tags.schemas import TagGet

router = APIRouter(
prefix=f"/{API_VTAG}",
tags=[
"catalog",
"tags",
],
)


@router.get(
"/catalog/services/{service_key}/{service_version}/tags",
response_model=Envelope[list[TagGet]],
)
def list_service_tags(
_path_params: Annotated[ServicePathParams, Depends()],
):
...


@router.post(
"/catalog/services/{service_key}/{service_version}/tags/{tag_id}:add",
response_model=Envelope[CatalogServiceGet],
)
def add_service_tag(
_path_params: Annotated[ServiceTagPathParams, Depends()],
):
...


@router.post(
"/catalog/services/{service_key}/{service_version}/tags/{tag_id}:remove",
response_model=Envelope[CatalogServiceGet],
)
def remove_service_tag(
_path_params: Annotated[ServiceTagPathParams, Depends()],
):
...
4 changes: 1 addition & 3 deletions api/specs/web-server/_projects_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

router = APIRouter(
prefix=f"/{API_VTAG}",
tags=[
"projects",
],
tags=["projects", "groups"],
)


Expand Down
16 changes: 10 additions & 6 deletions api/specs/web-server/_projects_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,31 @@
)


@router.put(
"/projects/{project_uuid}/tags/{tag_id}",
@router.post(
"/projects/{project_uuid}/tags/{tag_id}:add",
response_model=Envelope[ProjectGet],
)
def add_tag(
def add_project_tag(
project_uuid: ProjectID,
tag_id: int,
):
"""
Links an existing label with an existing study

NOTE: that the tag is not created here
"""


@router.delete(
"/projects/{project_uuid}/tags/{tag_id}",
@router.post(
"/projects/{project_uuid}/tags/{tag_id}:remove",
response_model=Envelope[ProjectGet],
)
def remove_tag(
def remove_project_tag(
project_uuid: ProjectID,
tag_id: int,
):
"""
Removes an existing link between a label and a study

NOTE: that the tag is not deleted here
"""
2 changes: 1 addition & 1 deletion api/specs/web-server/_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from fastapi import APIRouter, Depends, status
from models_library.generics import Envelope
from simcore_service_webserver._meta import API_VTAG
from simcore_service_webserver.tags._handlers import (
from simcore_service_webserver.tags.schemas import (
TagCreate,
TagGet,
TagPathParams,
Expand Down
63 changes: 63 additions & 0 deletions api/specs/web-server/_tags_groups.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument
# pylint: disable=unused-variable
# pylint: disable=too-many-arguments


from typing import Annotated

from fastapi import APIRouter, Depends, status
from models_library.generics import Envelope
from simcore_service_webserver._meta import API_VTAG
from simcore_service_webserver.tags.schemas import (
TagGet,
TagGroupCreate,
TagGroupGet,
TagGroupPathParams,
TagPathParams,
)

router = APIRouter(
prefix=f"/{API_VTAG}",
tags=[
"tags",
"groups",
],
)


@router.get(
"/tags/{tag_id}/groups",
response_model=Envelope[list[TagGroupGet]],
)
async def list_tag_groups(_path_params: Annotated[TagPathParams, Depends()]):
...


@router.post(
"/tags/{tag_id}/groups/{group_id}",
response_model=Envelope[TagGet],
status_code=status.HTTP_201_CREATED,
)
async def create_tag_group(
_path_params: Annotated[TagGroupPathParams, Depends()], _body: TagGroupCreate
):
...


@router.put(
"/tags/{tag_id}/groups/{group_id}",
response_model=Envelope[list[TagGroupGet]],
)
async def replace_tag_groups(
_path_params: Annotated[TagGroupPathParams, Depends()], _body: TagGroupCreate
):
...


@router.delete(
"/tags/{tag_id}/groups/{group_id}",
status_code=status.HTTP_204_NO_CONTENT,
)
async def delete_tag_group(_path_params: Annotated[TagGroupPathParams, Depends()]):
...
6 changes: 6 additions & 0 deletions api/specs/web-server/_wallets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# pylint: disable=too-many-arguments


from enum import Enum
from typing import Annotated

from fastapi import APIRouter, Depends, status
Expand Down Expand Up @@ -214,12 +215,14 @@ async def replace_wallet_autorecharge(


### Wallets groups
_extra_tags: list[str | Enum] = ["groups"]


@router.post(
"/wallets/{wallet_id}/groups/{group_id}",
response_model=Envelope[WalletGroupGet],
status_code=status.HTTP_201_CREATED,
tags=_extra_tags,
)
async def create_wallet_group(
wallet_id: WalletID, group_id: GroupID, body: _WalletsGroupsBodyParams
Expand All @@ -230,6 +233,7 @@ async def create_wallet_group(
@router.get(
"/wallets/{wallet_id}/groups",
response_model=Envelope[list[WalletGroupGet]],
tags=_extra_tags,
)
async def list_wallet_groups(wallet_id: WalletID):
...
Expand All @@ -238,6 +242,7 @@ async def list_wallet_groups(wallet_id: WalletID):
@router.put(
"/wallets/{wallet_id}/groups/{group_id}",
response_model=Envelope[WalletGroupGet],
tags=_extra_tags,
)
async def update_wallet_group(
wallet_id: WalletID, group_id: GroupID, body: _WalletsGroupsBodyParams
Expand All @@ -248,6 +253,7 @@ async def update_wallet_group(
@router.delete(
"/wallets/{wallet_id}/groups/{group_id}",
status_code=status.HTTP_204_NO_CONTENT,
tags=_extra_tags,
)
async def delete_wallet_group(wallet_id: WalletID, group_id: GroupID):
...
26 changes: 19 additions & 7 deletions api/specs/web-server/_workspaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@
# pylint: disable=too-many-arguments


from fastapi import APIRouter, status
from enum import Enum
from typing import Annotated

from fastapi import APIRouter, Depends, status
from models_library.api_schemas_webserver.workspaces import (
CreateWorkspaceBodyParams,
PutWorkspaceBodyParams,
WorkspaceGet,
)
from models_library.generics import Envelope
from models_library.users import GroupID
from models_library.workspaces import WorkspaceID
from simcore_service_webserver._meta import API_VTAG
from simcore_service_webserver.workspaces._groups_api import WorkspaceGroupGet
from simcore_service_webserver.workspaces._groups_handlers import (
_WorkspacesGroupsBodyParams,
_WorkspacesGroupsPathParams,
)

router = APIRouter(
Expand All @@ -37,7 +40,7 @@
response_model=Envelope[WorkspaceGet],
status_code=status.HTTP_201_CREATED,
)
async def create_workspace(body: CreateWorkspaceBodyParams):
async def create_workspace(_body: CreateWorkspaceBodyParams):
...


Expand All @@ -61,7 +64,7 @@ async def get_workspace(workspace_id: WorkspaceID):
"/workspaces/{workspace_id}",
response_model=Envelope[WorkspaceGet],
)
async def replace_workspace(workspace_id: WorkspaceID, body: PutWorkspaceBodyParams):
async def replace_workspace(workspace_id: WorkspaceID, _body: PutWorkspaceBodyParams):
...


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


### Workspaces groups
_extra_tags: list[str | Enum] = ["groups"]


@router.post(
"/workspaces/{workspace_id}/groups/{group_id}",
response_model=Envelope[WorkspaceGroupGet],
status_code=status.HTTP_201_CREATED,
tags=_extra_tags,
)
async def create_workspace_group(
workspace_id: WorkspaceID, group_id: GroupID, body: _WorkspacesGroupsBodyParams
_path_parms: Annotated[_WorkspacesGroupsPathParams, Depends()],
_body: _WorkspacesGroupsBodyParams,
):
...


@router.get(
"/workspaces/{workspace_id}/groups",
response_model=Envelope[list[WorkspaceGroupGet]],
tags=_extra_tags,
)
async def list_workspace_groups(workspace_id: WorkspaceID):
...
Expand All @@ -98,16 +105,21 @@ async def list_workspace_groups(workspace_id: WorkspaceID):
@router.put(
"/workspaces/{workspace_id}/groups/{group_id}",
response_model=Envelope[WorkspaceGroupGet],
tags=_extra_tags,
)
async def replace_workspace_group(
workspace_id: WorkspaceID, group_id: GroupID, body: _WorkspacesGroupsBodyParams
_path_parms: Annotated[_WorkspacesGroupsPathParams, Depends()],
_body: _WorkspacesGroupsBodyParams,
):
...


@router.delete(
"/workspaces/{workspace_id}/groups/{group_id}",
status_code=status.HTTP_204_NO_CONTENT,
tags=_extra_tags,
)
async def delete_workspace_group(workspace_id: WorkspaceID, group_id: GroupID):
async def delete_workspace_group(
_path_parms: Annotated[_WorkspacesGroupsPathParams, Depends()]
):
...
32 changes: 20 additions & 12 deletions api/specs/web-server/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,37 @@
openapi_modules = [
importlib.import_module(name)
for name in (
# NOTE: order matters on how the paths are displayed in the OAS!
# It does not have to be alphabetical
#
# core ---
"_auth",
"_groups",
"_tags",
"_tags_groups", # after _tags
"_products",
"_users",
"_wallets",
# add-ons ---
"_activity",
"_admin",
"_announcements",
"_auth",
"_catalog",
"_catalog_tags", # after _catalog
"_cluster",
"_computations",
"_diagnostics",
"_exporter",
"_folders",
"_groups",
"_long_running_tasks",
"_metamodeling",
"_nih_sparc_redirections",
"_nih_sparc",
"_products",
"_projects_nodes_pricing_unit",
"_projects_comments",
"_nih_sparc_redirections",
"_projects_crud",
"_projects_groups",
"_projects_comments",
"_projects_folders",
"_projects_groups",
"_projects_metadata",
"_projects_nodes",
"_projects_nodes_pricing_unit", # after _projects_nodes
"_projects_ports",
"_projects_states",
"_projects_tags",
Expand All @@ -47,11 +55,11 @@
"_resource_usage",
"_statics",
"_storage",
"_tags",
"_users",
"_version_control",
"_wallets",
"_workspaces",
# maintenance ----
"_admin",
"_diagnostics",
)
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,13 @@ qx.Class.define("osparc.data.Resources", {
},
addTag: {
useCache: false,
method: "PUT",
url: statics.API + "/projects/{studyId}/tags/{tagId}"
method: "POST",
url: statics.API + "/projects/{studyId}/tags/{tagId}:add"
},
removeTag: {
useCache: false,
method: "DELETE",
url: statics.API + "/projects/{studyId}/tags/{tagId}"
method: "POST",
url: statics.API + "/projects/{studyId}/tags/{tagId}:remove"
},
getInactivity: {
useCache: false,
Expand Down
Loading
Loading