Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Panaetius committed Jan 13, 2025
1 parent b204cc0 commit 6bf6923
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion components/renku_data_services/session/api.spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ paths:
type: object
additionalProperties: false
properties:
with_archived:
include_archived:
type: boolean
default: false
description: Whether to return archived environments or not
Expand Down
4 changes: 2 additions & 2 deletions components/renku_data_services/session/apispec.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated by datamodel-codegen:
# filename: api.spec.yaml
# timestamp: 2025-01-10T14:46:43+00:00
# timestamp: 2025-01-13T09:07:25+00:00

from __future__ import annotations

Expand Down Expand Up @@ -33,7 +33,7 @@ class GetEnvironmentParams(BaseAPISpec):
model_config = ConfigDict(
extra="forbid",
)
with_archived: bool = Field(
include_archived: bool = Field(
False, description="Whether to return archived environments or not"
)

Expand Down
2 changes: 1 addition & 1 deletion components/renku_data_services/session/blueprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_all(self) -> BlueprintFactoryResponse:

@validate_query(query=apispec.GetEnvironmentParams)
async def _get_all(_: Request, query: apispec.GetEnvironmentParams) -> JSONResponse:
environments = await self.session_repo.get_environments(with_archived=query.with_archived)
environments = await self.session_repo.get_environments(include_archived=query.include_archived)
return validated_json(apispec.EnvironmentList, environments)

return "/environments", ["GET"], _get_all
Expand Down
4 changes: 2 additions & 2 deletions components/renku_data_services/session/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ def __init__(
self.project_authz: Authz = project_authz
self.resource_pools: ResourcePoolRepository = resource_pools

async def get_environments(self, with_archived: bool = False) -> list[models.Environment]:
async def get_environments(self, include_archived: bool = False) -> list[models.Environment]:
"""Get all global session environments from the database."""
async with self.session_maker() as session:
statement = select(schemas.EnvironmentORM).where(
schemas.EnvironmentORM.environment_kind == models.EnvironmentKind.GLOBAL.value
)
if not with_archived:
if not include_archived:
statement = statement.where(schemas.EnvironmentORM.is_archived.is_(False))
res = await session.scalars(statement)
environments = res.all()
Expand Down
2 changes: 1 addition & 1 deletion test/bases/renku_data_services/data_api/test_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async def test_get_all_session_environments(
"Environment 2",
"Environment 3",
}
_, res = await sanic_client.get("/api/data/environments?with_archived=true", headers=unauthorized_headers)
_, res = await sanic_client.get("/api/data/environments?include_archived=true", headers=unauthorized_headers)

assert res.status_code == 200, res.text
assert res.json is not None
Expand Down

0 comments on commit 6bf6923

Please sign in to comment.