Loading src/open_exposure_gateway/adapters/http/srm_client.py +17 −0 Original line number Diff line number Diff line Loading @@ -124,6 +124,15 @@ class SRMClient: ) return [SRMZone.model_validate(z) for z in data] async def create_qod_session( self, payload: dict[str, Any], x_correlator: str | None = None, ) -> SessionInfo: headers = {"x-correlator": x_correlator} if x_correlator else None data = await self._request("POST", "/sessions", json=payload, headers=headers) return SessionInfo.model_validate(data) async def get_qod_session( self, session_id: str, Loading @@ -133,6 +142,14 @@ class SRMClient: data = await self._request("GET", f"/sessions/{session_id}", headers=headers) return SessionInfo.model_validate(data) async def delete_qod_session( self, session_id: str, x_correlator: str | None = None, ) -> None: headers = {"x-correlator": x_correlator} if x_correlator else None await self._request("DELETE", f"/sessions/{session_id}", headers=headers) async def get_apps(self, x_correlator: str | None = None) -> list[SRMCatalogPayload]: headers = {"x-correlator": x_correlator} if x_correlator else None data = await self._request( Loading src/open_exposure_gateway/ports/srm_port.py +6 −0 Original line number Diff line number Diff line Loading @@ -38,4 +38,10 @@ class SRMClientPort(Protocol): x_correlator: str | None, ) -> list[SRMServiceInstance]: ... async def create_qod_session( self, payload: dict[str, Any], x_correlator: str | None ) -> SessionInfo: ... async def get_qod_session(self, session_id: str, x_correlator: str | None) -> SessionInfo: ... async def delete_qod_session(self, session_id: str, x_correlator: str | None) -> None: ... tests/unit/fakes.py +26 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ from open_exposure_gateway.adapters.errors import ( DuplicateOperationError, ) from open_exposure_gateway.api.camara.quality_on_demand.v0_10_1.schemas import ( QosStatus, SessionInfo, ) from open_exposure_gateway.application.services.edge_application_management_service import ( Loading Loading @@ -152,6 +153,26 @@ class FakeSRMClient: result = [i for i in result if i.service_instance_id == str(app_instance_id)] return result async def create_qod_session( self, payload: dict[str, Any], x_correlator: str | None = None ) -> SessionInfo: duration = payload.get("duration", 86400) session = SessionInfo( sessionId=uuid4(), device=payload["device"], applicationServer=payload["applicationServer"], qosProfile=payload["qosProfile"], duration=duration, startedAt=1_750_000_000, expiresAt=1_750_000_000 + duration, qosStatus=QosStatus.REQUESTED, devicePorts=payload.get("devicePorts"), applicationServerPorts=payload.get("applicationServerPorts"), webhook=payload.get("webhook"), ) self.qod_sessions[str(session.sessionId)] = session return session async def get_qod_session( self, session_id: str, x_correlator: str | None = None ) -> SessionInfo: Loading @@ -160,6 +181,11 @@ class FakeSRMClient: raise NotFoundException(message=f"Session {session_id} not found") return session async def delete_qod_session(self, session_id: str, x_correlator: str | None = None) -> None: if session_id not in self.qod_sessions: raise NotFoundException(message=f"Session {session_id} not found") del self.qod_sessions[session_id] def completion_payload(operation_id: str, **overrides: Any) -> dict[str, Any]: payload: dict[str, Any] = { Loading Loading
src/open_exposure_gateway/adapters/http/srm_client.py +17 −0 Original line number Diff line number Diff line Loading @@ -124,6 +124,15 @@ class SRMClient: ) return [SRMZone.model_validate(z) for z in data] async def create_qod_session( self, payload: dict[str, Any], x_correlator: str | None = None, ) -> SessionInfo: headers = {"x-correlator": x_correlator} if x_correlator else None data = await self._request("POST", "/sessions", json=payload, headers=headers) return SessionInfo.model_validate(data) async def get_qod_session( self, session_id: str, Loading @@ -133,6 +142,14 @@ class SRMClient: data = await self._request("GET", f"/sessions/{session_id}", headers=headers) return SessionInfo.model_validate(data) async def delete_qod_session( self, session_id: str, x_correlator: str | None = None, ) -> None: headers = {"x-correlator": x_correlator} if x_correlator else None await self._request("DELETE", f"/sessions/{session_id}", headers=headers) async def get_apps(self, x_correlator: str | None = None) -> list[SRMCatalogPayload]: headers = {"x-correlator": x_correlator} if x_correlator else None data = await self._request( Loading
src/open_exposure_gateway/ports/srm_port.py +6 −0 Original line number Diff line number Diff line Loading @@ -38,4 +38,10 @@ class SRMClientPort(Protocol): x_correlator: str | None, ) -> list[SRMServiceInstance]: ... async def create_qod_session( self, payload: dict[str, Any], x_correlator: str | None ) -> SessionInfo: ... async def get_qod_session(self, session_id: str, x_correlator: str | None) -> SessionInfo: ... async def delete_qod_session(self, session_id: str, x_correlator: str | None) -> None: ...
tests/unit/fakes.py +26 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ from open_exposure_gateway.adapters.errors import ( DuplicateOperationError, ) from open_exposure_gateway.api.camara.quality_on_demand.v0_10_1.schemas import ( QosStatus, SessionInfo, ) from open_exposure_gateway.application.services.edge_application_management_service import ( Loading Loading @@ -152,6 +153,26 @@ class FakeSRMClient: result = [i for i in result if i.service_instance_id == str(app_instance_id)] return result async def create_qod_session( self, payload: dict[str, Any], x_correlator: str | None = None ) -> SessionInfo: duration = payload.get("duration", 86400) session = SessionInfo( sessionId=uuid4(), device=payload["device"], applicationServer=payload["applicationServer"], qosProfile=payload["qosProfile"], duration=duration, startedAt=1_750_000_000, expiresAt=1_750_000_000 + duration, qosStatus=QosStatus.REQUESTED, devicePorts=payload.get("devicePorts"), applicationServerPorts=payload.get("applicationServerPorts"), webhook=payload.get("webhook"), ) self.qod_sessions[str(session.sessionId)] = session return session async def get_qod_session( self, session_id: str, x_correlator: str | None = None ) -> SessionInfo: Loading @@ -160,6 +181,11 @@ class FakeSRMClient: raise NotFoundException(message=f"Session {session_id} not found") return session async def delete_qod_session(self, session_id: str, x_correlator: str | None = None) -> None: if session_id not in self.qod_sessions: raise NotFoundException(message=f"Session {session_id} not found") del self.qod_sessions[session_id] def completion_payload(operation_id: str, **overrides: Any) -> dict[str, Any]: payload: dict[str, Any] = { Loading