Skip to content

Commit ec54693

Browse files
committed
fixed also get project state
1 parent a02affc commit ec54693

File tree

3 files changed

+20
-50
lines changed

3 files changed

+20
-50
lines changed

api/specs/web-server/_projects_states.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
from typing import Annotated
88

99
from fastapi import APIRouter, Body, Depends
10-
from models_library.api_schemas_webserver.projects import ProjectGet
10+
from models_library.api_schemas_webserver.projects import (
11+
ProjectGet,
12+
ProjectStateOutputSchema,
13+
)
1114
from models_library.generics import Envelope
12-
from models_library.projects_state import ProjectState
1315
from pydantic import ValidationError
1416
from servicelib.aiohttp import status
1517
from simcore_service_webserver._meta import API_VTAG
@@ -80,7 +82,9 @@ def close_project(
8082
): ...
8183

8284

83-
@router.get("/projects/{project_id}/state", response_model=Envelope[ProjectState])
85+
@router.get(
86+
"/projects/{project_id}/state", response_model=Envelope[ProjectStateOutputSchema]
87+
)
8488
def get_project_state(
8589
_path_params: Annotated[ProjectPathParams, Depends()],
8690
): ...

services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6304,7 +6304,7 @@ paths:
63046304
content:
63056305
application/json:
63066306
schema:
6307-
$ref: '#/components/schemas/Envelope_ProjectState_'
6307+
$ref: '#/components/schemas/Envelope_ProjectStateOutputSchema_'
63086308
/v0/projects/{project_uuid}/tags/{tag_id}:add:
63096309
post:
63106310
tags:
@@ -10830,19 +10830,19 @@ components:
1083010830
title: Error
1083110831
type: object
1083210832
title: Envelope[ProjectShareAccepted]
10833-
Envelope_ProjectState_:
10833+
Envelope_ProjectStateOutputSchema_:
1083410834
properties:
1083510835
data:
1083610836
anyOf:
10837-
- $ref: '#/components/schemas/ProjectState'
10837+
- $ref: '#/components/schemas/ProjectStateOutputSchema'
1083810838
- type: 'null'
1083910839
error:
1084010840
anyOf:
1084110841
- {}
1084210842
- type: 'null'
1084310843
title: Error
1084410844
type: object
10845-
title: Envelope[ProjectState]
10845+
title: Envelope[ProjectStateOutputSchema]
1084610846
Envelope_ProjectsCommentsAPI_:
1084710847
properties:
1084810848
data:
@@ -15719,31 +15719,6 @@ components:
1571915719
- shareeEmail
1572015720
- confirmationLink
1572115721
title: ProjectShareAccepted
15722-
ProjectShareState:
15723-
properties:
15724-
status:
15725-
$ref: '#/components/schemas/ProjectStatus'
15726-
description: The status of the project
15727-
locked:
15728-
type: boolean
15729-
title: Locked
15730-
description: True if the project is locked
15731-
current_user_groupids:
15732-
items:
15733-
type: integer
15734-
exclusiveMinimum: true
15735-
minimum: 0
15736-
type: array
15737-
title: Current User Groupids
15738-
description: Current users in the project (if the project is locked, the
15739-
list contains only the lock owner)
15740-
additionalProperties: false
15741-
type: object
15742-
required:
15743-
- status
15744-
- locked
15745-
- current_user_groupids
15746-
title: ProjectShareState
1574715722
ProjectShareStateOutputSchema:
1574815723
properties:
1574915724
status:
@@ -15768,20 +15743,6 @@ components:
1576815743
- locked
1576915744
- currentUserGroupids
1577015745
title: ProjectShareStateOutputSchema
15771-
ProjectState:
15772-
properties:
15773-
share_state:
15774-
$ref: '#/components/schemas/ProjectShareState'
15775-
description: The project share state
15776-
state:
15777-
$ref: '#/components/schemas/ProjectRunningState'
15778-
description: The project running state
15779-
additionalProperties: false
15780-
type: object
15781-
required:
15782-
- share_state
15783-
- state
15784-
title: ProjectState
1578515746
ProjectStateOutputSchema:
1578615747
properties:
1578715748
shareState:

services/web/server/src/simcore_service_webserver/projects/_controller/projects_states_rest.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from aiohttp import web
66
from models_library.api_schemas_webserver.projects import ProjectGet
7-
from models_library.projects_state import ProjectState
87
from pydantic import BaseModel
98
from servicelib.aiohttp import status
109
from servicelib.aiohttp.requests_validation import (
@@ -16,6 +15,7 @@
1615
UNDEFINED_DEFAULT_SIMCORE_USER_AGENT_VALUE,
1716
X_SIMCORE_USER_AGENT,
1817
)
18+
from servicelib.rest_constants import RESPONSE_MODEL_POLICY
1919
from simcore_postgres_database.models.users import UserRole
2020
from simcore_postgres_database.webserver_models import ProjectType
2121

@@ -218,11 +218,16 @@ async def get_project_state(request: web.Request) -> web.Response:
218218
path_params = parse_request_path_parameters_as(ProjectPathParams, request)
219219

220220
# check that project exists and queries state
221-
validated_project = await _projects_service.get_project_for_user(
221+
project = await _projects_service.get_project_for_user(
222222
request.app,
223223
project_uuid=f"{path_params.project_id}",
224224
user_id=req_ctx.user_id,
225225
include_state=True,
226226
)
227-
project_state = ProjectState(**validated_project["state"])
228-
return envelope_json_response(project_state.model_dump())
227+
project_state = ProjectGet.from_domain_model(project).state
228+
assert project_state # nosec
229+
return envelope_json_response(
230+
project_state.model_dump(
231+
**RESPONSE_MODEL_POLICY,
232+
)
233+
)

0 commit comments

Comments
 (0)