Commit 94438c55 authored by George Papathanail's avatar George Papathanail
Browse files

feat: add SRM client read methods

parent e667920c
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -7,6 +7,9 @@ import structlog
from open_exposure_gateway.api.camara.quality_on_demand.v0_10_1.schemas import (
    SessionInfo,
)
from open_exposure_gateway.api.camara.traffic_influence.vwip.schemas import (
    TrafficInfluence,
)
from open_exposure_gateway.core.config import get_settings
from open_exposure_gateway.core.exceptions import (
    DownstreamServiceException,
@@ -133,6 +136,35 @@ class SRMClient:
        data = await self._request("GET", f"/sessions/{session_id}", headers=headers)
        return SessionInfo.model_validate(data)

    # NOTE: /internal/network-capabilities is not documented in
    # architecture/srm/interface-contract.md §E -- same open gap as
    # get_qod_session's "/sessions/{id}" call above. Confirm the real path
    # with the SRM dev before relying on this in production.
    async def get_traffic_influence(
        self,
        traffic_influence_id: str,
        x_correlator: str | None = None,
    ) -> TrafficInfluence:
        headers = {"x-correlator": x_correlator} if x_correlator else None
        data = await self._request(
            "GET", f"/internal/network-capabilities/{traffic_influence_id}", headers=headers
        )
        return TrafficInfluence.model_validate(data)

    async def get_traffic_influences(
        self,
        app_id: UUID | None = None,
        x_correlator: str | None = None,
    ) -> list[TrafficInfluence]:
        params = {"capability_type": "traffic_influence"}
        if app_id is not None:
            params["app_id"] = str(app_id)
        headers = {"x-correlator": x_correlator} if x_correlator else None
        data = await self._request(
            "GET", "/internal/network-capabilities", params=params, headers=headers
        )
        return [TrafficInfluence.model_validate(t) for t in data]

    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(
+15 −0
Original line number Diff line number Diff line
@@ -4,6 +4,9 @@ from uuid import UUID
from open_exposure_gateway.api.camara.quality_on_demand.v0_10_1.schemas import (
    SessionInfo,
)
from open_exposure_gateway.api.camara.traffic_influence.vwip.schemas import (
    TrafficInfluence,
)
from open_exposure_gateway.domain.edge_application_management import (
    SRMCatalogPayload,
    SRMCatalogServiceSpecificationCreated,
@@ -39,3 +42,15 @@ class SRMClientPort(Protocol):
    ) -> list[SRMServiceInstance]: ...

    async def get_qod_session(self, session_id: str, x_correlator: str | None) -> SessionInfo: ...

    # NOTE: no such SRM endpoint is documented in architecture/srm/interface-contract.md
    # §E (only service-instances-by-id and operations-by-id exist there) -- this is an
    # open OEG<->SRM contract gap, tracked the same way get_qod_session's undocumented
    # "/sessions/{id}" call already is. Do not treat this as a confirmed wire shape.
    async def get_traffic_influence(
        self, traffic_influence_id: str, x_correlator: str | None
    ) -> TrafficInfluence: ...

    async def get_traffic_influences(
        self, app_id: UUID | None, x_correlator: str | None
    ) -> list[TrafficInfluence]: ...