Loading src/srm/adapters/database/repos/catalog.py +18 −0 Viewed Changes for src/srm/adapters/database/repos/catalog.py: 18 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -73,6 +73,24 @@ class SqlServiceSpecificationRepository(ServiceSpecificationRepository): row = await self._session.scalar(stmt) return ServiceSpecificationMapper.to_domain(row) if row is not None else None async def list_by_app_provider_id(self, app_provider_id: str) -> list[ServiceSpecification]: stmt = ( select(ServiceSpecificationRow) .options( selectinload(ServiceSpecificationRow.deployment_units), selectinload(ServiceSpecificationRow.capability_requirements), ) .where(ServiceSpecificationRow.app_provider_id == app_provider_id) .order_by( ServiceSpecificationRow.name, ServiceSpecificationRow.ref, ServiceSpecificationRow.version, ServiceSpecificationRow.id, ) ) rows = (await self._session.scalars(stmt)).all() return [ServiceSpecificationMapper.to_domain(row) for row in rows] async def create(self, service_specification: ServiceSpecification) -> ServiceSpecification: row = ServiceSpecificationMapper.to_row(service_specification) _link_requirement_deployment_unit_rows(row) Loading src/srm/api/rest/router.py +22 −1 Viewed Changes for src/srm/api/rest/router.py: 22 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ from typing import Annotated from uuid import UUID import structlog from fastapi import APIRouter, Header, HTTPException, Response, status from fastapi import APIRouter, Header, HTTPException, Query, Response, status from fastapi.responses import JSONResponse from srm.adapters.errors import DuplicateServiceSpecificationError, ServiceSpecificationInUseError Loading @@ -14,6 +14,7 @@ from srm.api.dependencies import ( GetServiceSpecificationUseCaseDep, ListNetworkCapabilityInstanceByProviderUseCaseDep, ListServiceInstancesByProviderUseCaseDep, ListServiceSpecificationsByProviderUseCaseDep, ListZonesUseCaseDep, LocationQueryUseCaseDep, ZoneProviderNameDep, Loading Loading @@ -314,6 +315,26 @@ async def create_service_specification( return _build_response(saved) @internal.get("/catalog/service-specifications") async def list_service_specifications_by_provider( use_case: ListServiceSpecificationsByProviderUseCaseDep, app_provider_id: Annotated[str, Query(min_length=1)], ) -> list[GetServiceSpecificationResponse]: logger.info( "list_service_specifications_by_provider_requested", app_provider_id=app_provider_id, ) specifications = await use_case.execute(app_provider_id) logger.info( "list_service_specifications_by_provider_succeeded", app_provider_id=app_provider_id, count=len(specifications), ) return [_build_get_spec_response(specification) for specification in specifications] @internal.get( "/catalog/service-specifications/{id}", responses={ Loading src/srm/api/dependencies.py +11 −0 Viewed Changes for src/srm/api/dependencies.py: 11 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ from srm.application.use_cases.catalog import ( CreateServiceSpecificationUseCase, DeleteServiceSpecificationUseCase, GetServiceSpecificationUseCase, ListServiceSpecificationsByProviderUseCase, ) from srm.application.use_cases.location_query import LocationQueryUseCase from srm.application.use_cases.runtime_inventory import ( Loading Loading @@ -78,6 +79,12 @@ def get_service_specification_use_case( return GetServiceSpecificationUseCase(SqlServiceSpecificationRepository(session)) def list_service_specifications_by_provider_use_case( session: SessionDep, ) -> ListServiceSpecificationsByProviderUseCase: return ListServiceSpecificationsByProviderUseCase(SqlServiceSpecificationRepository(session)) def get_delete_service_specification_use_case( session: SessionDep, ) -> DeleteServiceSpecificationUseCase: Loading Loading @@ -126,6 +133,10 @@ GetServiceSpecificationUseCaseDep = Annotated[ GetServiceSpecificationUseCase, Depends(get_service_specification_use_case), ] ListServiceSpecificationsByProviderUseCaseDep = Annotated[ ListServiceSpecificationsByProviderUseCase, Depends(list_service_specifications_by_provider_use_case), ] DeleteServiceSpecificationUseCaseDep = Annotated[ DeleteServiceSpecificationUseCase, Depends(get_delete_service_specification_use_case), Loading src/srm/application/use_cases/catalog.py +8 −0 Viewed Changes for src/srm/application/use_cases/catalog.py: 8 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -78,6 +78,14 @@ class GetServiceSpecificationUseCase: return await self._repository.get_by_id(id) class ListServiceSpecificationsByProviderUseCase: def __init__(self, repository: ServiceSpecificationRepository) -> None: self._repository = repository async def execute(self, app_provider_id: str) -> list[ServiceSpecification]: return await self._repository.list_by_app_provider_id(app_provider_id) class DeleteServiceSpecificationUseCase: def __init__(self, repository: ServiceSpecificationRepository) -> None: self._repository = repository Loading src/srm/domain/ports/database/catalog.py +4 −0 Viewed Changes for src/srm/domain/ports/database/catalog.py: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -15,6 +15,10 @@ class ServiceSpecificationRepository(ABC): async def get_by_id(self, id: UUID) -> ServiceSpecification | None: pass @abstractmethod async def list_by_app_provider_id(self, app_provider_id: str) -> list[ServiceSpecification]: pass @abstractmethod async def create(self, service_specification: ServiceSpecification) -> ServiceSpecification: pass Loading Loading
src/srm/adapters/database/repos/catalog.py +18 −0 Viewed Changes for src/srm/adapters/database/repos/catalog.py: 18 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -73,6 +73,24 @@ class SqlServiceSpecificationRepository(ServiceSpecificationRepository): row = await self._session.scalar(stmt) return ServiceSpecificationMapper.to_domain(row) if row is not None else None async def list_by_app_provider_id(self, app_provider_id: str) -> list[ServiceSpecification]: stmt = ( select(ServiceSpecificationRow) .options( selectinload(ServiceSpecificationRow.deployment_units), selectinload(ServiceSpecificationRow.capability_requirements), ) .where(ServiceSpecificationRow.app_provider_id == app_provider_id) .order_by( ServiceSpecificationRow.name, ServiceSpecificationRow.ref, ServiceSpecificationRow.version, ServiceSpecificationRow.id, ) ) rows = (await self._session.scalars(stmt)).all() return [ServiceSpecificationMapper.to_domain(row) for row in rows] async def create(self, service_specification: ServiceSpecification) -> ServiceSpecification: row = ServiceSpecificationMapper.to_row(service_specification) _link_requirement_deployment_unit_rows(row) Loading
src/srm/api/rest/router.py +22 −1 Viewed Changes for src/srm/api/rest/router.py: 22 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ from typing import Annotated from uuid import UUID import structlog from fastapi import APIRouter, Header, HTTPException, Response, status from fastapi import APIRouter, Header, HTTPException, Query, Response, status from fastapi.responses import JSONResponse from srm.adapters.errors import DuplicateServiceSpecificationError, ServiceSpecificationInUseError Loading @@ -14,6 +14,7 @@ from srm.api.dependencies import ( GetServiceSpecificationUseCaseDep, ListNetworkCapabilityInstanceByProviderUseCaseDep, ListServiceInstancesByProviderUseCaseDep, ListServiceSpecificationsByProviderUseCaseDep, ListZonesUseCaseDep, LocationQueryUseCaseDep, ZoneProviderNameDep, Loading Loading @@ -314,6 +315,26 @@ async def create_service_specification( return _build_response(saved) @internal.get("/catalog/service-specifications") async def list_service_specifications_by_provider( use_case: ListServiceSpecificationsByProviderUseCaseDep, app_provider_id: Annotated[str, Query(min_length=1)], ) -> list[GetServiceSpecificationResponse]: logger.info( "list_service_specifications_by_provider_requested", app_provider_id=app_provider_id, ) specifications = await use_case.execute(app_provider_id) logger.info( "list_service_specifications_by_provider_succeeded", app_provider_id=app_provider_id, count=len(specifications), ) return [_build_get_spec_response(specification) for specification in specifications] @internal.get( "/catalog/service-specifications/{id}", responses={ Loading
src/srm/api/dependencies.py +11 −0 Viewed Changes for src/srm/api/dependencies.py: 11 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ from srm.application.use_cases.catalog import ( CreateServiceSpecificationUseCase, DeleteServiceSpecificationUseCase, GetServiceSpecificationUseCase, ListServiceSpecificationsByProviderUseCase, ) from srm.application.use_cases.location_query import LocationQueryUseCase from srm.application.use_cases.runtime_inventory import ( Loading Loading @@ -78,6 +79,12 @@ def get_service_specification_use_case( return GetServiceSpecificationUseCase(SqlServiceSpecificationRepository(session)) def list_service_specifications_by_provider_use_case( session: SessionDep, ) -> ListServiceSpecificationsByProviderUseCase: return ListServiceSpecificationsByProviderUseCase(SqlServiceSpecificationRepository(session)) def get_delete_service_specification_use_case( session: SessionDep, ) -> DeleteServiceSpecificationUseCase: Loading Loading @@ -126,6 +133,10 @@ GetServiceSpecificationUseCaseDep = Annotated[ GetServiceSpecificationUseCase, Depends(get_service_specification_use_case), ] ListServiceSpecificationsByProviderUseCaseDep = Annotated[ ListServiceSpecificationsByProviderUseCase, Depends(list_service_specifications_by_provider_use_case), ] DeleteServiceSpecificationUseCaseDep = Annotated[ DeleteServiceSpecificationUseCase, Depends(get_delete_service_specification_use_case), Loading
src/srm/application/use_cases/catalog.py +8 −0 Viewed Changes for src/srm/application/use_cases/catalog.py: 8 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -78,6 +78,14 @@ class GetServiceSpecificationUseCase: return await self._repository.get_by_id(id) class ListServiceSpecificationsByProviderUseCase: def __init__(self, repository: ServiceSpecificationRepository) -> None: self._repository = repository async def execute(self, app_provider_id: str) -> list[ServiceSpecification]: return await self._repository.list_by_app_provider_id(app_provider_id) class DeleteServiceSpecificationUseCase: def __init__(self, repository: ServiceSpecificationRepository) -> None: self._repository = repository Loading
src/srm/domain/ports/database/catalog.py +4 −0 Viewed Changes for src/srm/domain/ports/database/catalog.py: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -15,6 +15,10 @@ class ServiceSpecificationRepository(ABC): async def get_by_id(self, id: UUID) -> ServiceSpecification | None: pass @abstractmethod async def list_by_app_provider_id(self, app_provider_id: str) -> list[ServiceSpecification]: pass @abstractmethod async def create(self, service_specification: ServiceSpecification) -> ServiceSpecification: pass Loading