Skip to content

Commit

Permalink
moves model classes of api schemas to models_library
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Jun 26, 2023
1 parent 01c2306 commit 35a49a4
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 43 deletions.
18 changes: 9 additions & 9 deletions api/specs/webserver/scripts/openapi_projects_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
create_openapi_specs,
)
from fastapi import FastAPI, Query, status
from models_library.api_schemas_webserver.projects import (
ProjectCopyOverride,
ProjectCreateNew,
ProjectGet,
ProjectListItem,
ProjectReplace,
ProjectUpdate,
TaskGet,
)
from models_library.generics import Envelope
from models_library.projects import ProjectID
from models_library.rest_pagination import DEFAULT_NUMBER_OF_ITEMS_PER_PAGE, Page
Expand All @@ -29,15 +38,6 @@
_ProjectCreateParams,
_ProjectListParams,
)
from simcore_service_webserver.projects._rest_schemas import (
ProjectCopyOverride,
ProjectCreateNew,
ProjectGet,
ProjectListItem,
ProjectReplace,
ProjectUpdate,
TaskGet,
)

app = FastAPI(redoc_url=None)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

from typing import Any

from models_library.utils.change_case import snake_to_camel
from pydantic import BaseModel, Extra

from ..utils.change_case import snake_to_camel


class InputSchema(BaseModel):
class Config: # type: ignore[pydantic-alias]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@

from typing import Any, Literal, TypeAlias

from models_library.emails import LowerCaseEmailStr
from models_library.projects import ClassifierID, DateTimeStr, NodesDict, ProjectID
from models_library.projects_access import AccessRights, GroupIDStr
from models_library.projects_nodes import HttpUrlWithCustomMinLength
from models_library.projects_state import ProjectState
from models_library.projects_ui import StudyUI
from models_library.utils.common_validators import empty_str_to_none, none_to_empty_str
from pydantic import BaseModel, Extra, Field, validator
from servicelib.aiohttp.long_running_tasks.server import TaskGet

from ..rest.schemas_base import InputSchema, OutputSchema
from ._permalink_api import ProjectPermalink
from ..emails import LowerCaseEmailStr
from ..projects import ClassifierID, DateTimeStr, NodesDict, ProjectID
from ..projects_access import AccessRights, GroupIDStr
from ..projects_nodes import HttpUrlWithCustomMinLength
from ..projects_state import ProjectState
from ..projects_ui import StudyUI
from ..utils.common_validators import empty_str_to_none, none_to_empty_str
from ._base import InputSchema, OutputSchema
from .projects_permalink import ProjectPermalink

NOT_REQUIRED = Field(default=None)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from pydantic import BaseModel, HttpUrl


class ProjectPermalink(BaseModel):
url: HttpUrl
is_public: bool
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from aiohttp import web
from jsonschema import ValidationError as JsonSchemaValidationError
from models_library.api_schemas_webserver.projects import ProjectGet
from models_library.projects import ProjectID
from models_library.projects_nodes_io import NodeID, NodeIDStr
from models_library.projects_state import ProjectStatus
Expand All @@ -30,7 +31,6 @@
from ..users.api import get_user_name
from . import projects_api
from ._permalink_api import update_or_pop_permalink_in_project
from ._rest_schemas import ProjectGet
from .db import ProjectDBAPI
from .exceptions import ProjectInvalidRightsError, ProjectNotFoundError
from .models import ProjectDict
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
from enum import Enum

from aiohttp import web
from models_library.api_schemas_webserver._base import OutputSchema
from models_library.api_schemas_webserver.projects import ProjectListItem
from models_library.projects import ProjectID
from models_library.users import UserID
from pydantic import BaseModel, Extra, Field, NonNegativeInt, PositiveInt
from servicelib.utils import logged_gather
from simcore_postgres_database.webserver_models import ProjectType as ProjectTypeDB

from ..catalog.client import get_services_for_user_in_product
from ..rest.schemas_base import OutputSchema
from . import projects_api
from ._permalink_api import update_or_pop_permalink_in_project
from ._rest_schemas import ProjectListItem
from .db import ProjectDBAPI
from .models import ProjectDict, ProjectTypeAPI

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@

from aiohttp import web
from jsonschema import ValidationError as JsonSchemaValidationError
from models_library.api_schemas_webserver.projects import (
EmptyModel,
ProjectCopyOverride,
ProjectCreateNew,
ProjectGet,
ProjectUpdate,
)
from models_library.projects import Project, ProjectID
from models_library.projects_state import ProjectLocked
from models_library.rest_pagination import DEFAULT_NUMBER_OF_ITEMS_PER_PAGE, Page
Expand Down Expand Up @@ -42,13 +49,6 @@
from . import _crud_create_utils, _crud_read_utils, projects_api
from ._crud_read_utils import OrderDirection, ProjectListFilters, ProjectOrderBy
from ._permalink_api import update_or_pop_permalink_in_project
from ._rest_schemas import (
EmptyModel,
ProjectCopyOverride,
ProjectCreateNew,
ProjectGet,
ProjectUpdate,
)
from .db import ProjectDBAPI
from .exceptions import (
ProjectDeleteError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,15 @@
from typing import Any, Callable, Coroutine, cast

from aiohttp import web
from models_library.api_schemas_webserver.projects_permalink import ProjectPermalink
from models_library.projects import ProjectID
from pydantic import BaseModel, HttpUrl

from .exceptions import PermalinkFactoryError, PermalinkNotAllowedError
from .models import ProjectDict

_PROJECT_PERMALINK = f"{__name__}"
_logger = logging.getLogger(__name__)


class ProjectPermalink(BaseModel):
url: HttpUrl
is_public: bool


_CreateLinkCallable = Callable[
[web.Request, ProjectID], Coroutine[Any, Any, ProjectPermalink]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@


import pytest
from models_library.api_schemas_webserver.projects import (
ProjectCreateNew,
ProjectGet,
ProjectListItem,
ProjectReplace,
TaskProjectGet,
)
from models_library.generics import Envelope
from models_library.rest_pagination import Page
from pydantic import parse_obj_as
Expand All @@ -19,13 +26,6 @@
REPLACE_PROJECT_ON_MODIFIED,
HttpApiCallCapture,
)
from simcore_service_webserver.projects._rest_schemas import (
ProjectCreateNew,
ProjectGet,
ProjectListItem,
ProjectReplace,
TaskProjectGet,
)


@pytest.mark.parametrize(
Expand Down

0 comments on commit 35a49a4

Please sign in to comment.