Skip to content

Commit 8e96ffc

Browse files
committed
to_domain_model
1 parent 28ff2fa commit 8e96ffc

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed

packages/models-library/src/models_library/api_schemas_webserver/groups.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class GroupCreate(InputSchema):
151151
description: str
152152
thumbnail: AnyUrl | None = None
153153

154-
def to_model(self) -> StandardGroupCreate:
154+
def to_domain_model(self) -> StandardGroupCreate:
155155
data = remap_keys(
156156
self.model_dump(
157157
mode="json",
@@ -169,7 +169,7 @@ class GroupUpdate(InputSchema):
169169
description: str | None = None
170170
thumbnail: AnyUrl | None = None
171171

172-
def to_model(self) -> StandardGroupUpdate:
172+
def to_domain_model(self) -> StandardGroupUpdate:
173173
data = remap_keys(
174174
self.model_dump(
175175
mode="json",

packages/models-library/src/models_library/api_schemas_webserver/projects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class ProjectPatch(InputSchema):
171171
] = Field(default=None)
172172
quality: dict[str, Any] | None = Field(default=None)
173173

174-
def to_model(self) -> dict[str, Any]:
174+
def to_domain_model(self) -> dict[str, Any]:
175175
return self.model_dump(exclude_unset=True, by_alias=False)
176176

177177

packages/models-library/src/models_library/api_schemas_webserver/users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ class MyTokenCreate(InputSchemaWithoutCamelCase):
293293
token_key: IDStr
294294
token_secret: IDStr
295295

296-
def to_model(self) -> UserThirdPartyToken:
296+
def to_domain_model(self) -> UserThirdPartyToken:
297297
return UserThirdPartyToken(
298298
service=self.service,
299299
token_key=self.token_key,

services/web/server/src/simcore_service_webserver/groups/_groups_rest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ async def create_group(request: web.Request):
114114
group, access_rights = await _groups_service.create_standard_group(
115115
request.app,
116116
user_id=req_ctx.user_id,
117-
create=create.to_model(),
117+
create=create.to_domain_model(),
118118
)
119119

120120
created_group = GroupGet.from_domain_model(group, access_rights)
@@ -135,7 +135,7 @@ async def update_group(request: web.Request):
135135
request.app,
136136
user_id=req_ctx.user_id,
137137
group_id=path_params.gid,
138-
update=update.to_model(),
138+
update=update.to_domain_model(),
139139
)
140140

141141
updated_group = GroupGet.from_domain_model(group, access_rights)

services/web/server/src/simcore_service_webserver/projects/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class ProjectPatchExtended(ProjectPatch):
101101

102102
model_config = ConfigDict(populate_by_name=True, extra="forbid")
103103

104-
def to_model(self) -> dict[str, Any]:
104+
def to_domain_model(self) -> dict[str, Any]:
105105
return remap_keys(
106106
self.model_dump(exclude_unset=True, by_alias=False),
107107
rename={"trashed_at": "trashed"},

services/web/server/src/simcore_service_webserver/projects/projects_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ async def patch_project(
254254
project_patch: ProjectPatch | ProjectPatchExtended,
255255
product_name: ProductName,
256256
):
257-
patch_project_data = project_patch.to_model()
257+
patch_project_data = project_patch.to_domain_model()
258258
db: ProjectDBAPI = app[APP_PROJECT_DBAPI]
259259

260260
# 1. Get project

services/web/server/src/simcore_service_webserver/users/_tokens_rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ async def create_token(request: web.Request) -> web.Response:
5858
token_create = await parse_request_body_as(MyTokenCreate, request)
5959

6060
token = await _tokens_service.create_token(
61-
request.app, req_ctx.user_id, token_create.to_model()
61+
request.app, req_ctx.user_id, token_create.to_domain_model()
6262
)
6363

6464
return envelope_json_response(MyTokenGet.from_domain_model(token), web.HTTPCreated)

services/web/server/tests/unit/isolated/test_groups_models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ def test_input_schemas_to_models(faker: Faker):
8282
input_schema = GroupCreate(
8383
label=faker.word(), description=faker.sentence(), thumbnail=faker.url()
8484
)
85-
domain_model = input_schema.to_model()
85+
domain_model = input_schema.to_domain_model()
8686
assert isinstance(domain_model, StandardGroupCreate)
8787
assert domain_model.name == input_schema.label
8888

8989
# input : scheam -> model
9090
input_schema = GroupUpdate(label=faker.word())
91-
domain_model = input_schema.to_model()
91+
domain_model = input_schema.to_domain_model()
9292
assert isinstance(domain_model, StandardGroupUpdate)
9393
assert domain_model.name == input_schema.label
9494

0 commit comments

Comments
 (0)