Initialize GovOPlaN SOAP connector
This commit is contained in:
5
src/govoplan_soap/__init__.py
Normal file
5
src/govoplan_soap/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
"""SOAP connector module for GovOPlaN."""
|
||||
|
||||
__all__ = ["__version__"]
|
||||
|
||||
__version__ = "0.1.7"
|
||||
1
src/govoplan_soap/backend/__init__.py
Normal file
1
src/govoplan_soap/backend/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""Backend integration points for the SOAP connector module."""
|
||||
38
src/govoplan_soap/backend/contracts.py
Normal file
38
src/govoplan_soap/backend/contracts.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Mapping, Sequence
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any, Literal, Protocol
|
||||
|
||||
|
||||
SoapOperationVisibility = Literal["internal", "authenticated", "public"]
|
||||
|
||||
CAPABILITY_SOAP_OPERATION_PROVIDER = "soap.operationProvider"
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class SoapOperationDescriptor:
|
||||
id: str
|
||||
module_id: str
|
||||
name: str
|
||||
summary: str
|
||||
service_name: str
|
||||
operation_name: str
|
||||
visibility: SoapOperationVisibility = "authenticated"
|
||||
required_scopes: tuple[str, ...] = ()
|
||||
request_schema: Mapping[str, Any] = field(default_factory=dict)
|
||||
response_schema: Mapping[str, Any] = field(default_factory=dict)
|
||||
tags: tuple[str, ...] = ()
|
||||
|
||||
|
||||
class SoapOperationProvider(Protocol):
|
||||
def soap_operations(self) -> Sequence[SoapOperationDescriptor]:
|
||||
...
|
||||
|
||||
def invoke_soap_operation(
|
||||
self,
|
||||
operation_id: str,
|
||||
payload: Mapping[str, Any],
|
||||
context: Mapping[str, Any],
|
||||
) -> Mapping[str, Any]:
|
||||
...
|
||||
57
src/govoplan_soap/backend/manifest.py
Normal file
57
src/govoplan_soap/backend/manifest.py
Normal file
@@ -0,0 +1,57 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from govoplan_core.core.access import CAPABILITY_AUTH_PERMISSION_EVALUATOR, CAPABILITY_AUTH_PRINCIPAL_RESOLVER
|
||||
from govoplan_core.core.modules import ModuleContext, ModuleInterfaceProvider, ModuleManifest, PermissionDefinition, RoleTemplate
|
||||
|
||||
SOAP_READ_SCOPE = "soap:endpoint:read"
|
||||
SOAP_READ_SCOPES = (SOAP_READ_SCOPE, "system:settings:read", "admin:settings:read")
|
||||
|
||||
|
||||
def _permission(scope: str, label: str, description: str) -> PermissionDefinition:
|
||||
module_id, resource, action = scope.split(":", 2)
|
||||
return PermissionDefinition(
|
||||
scope=scope,
|
||||
label=label,
|
||||
description=description,
|
||||
category="SOAP connector",
|
||||
level="system",
|
||||
module_id=module_id,
|
||||
resource=resource,
|
||||
action=action,
|
||||
)
|
||||
|
||||
|
||||
def _route_factory(context: ModuleContext):
|
||||
del context
|
||||
from govoplan_soap.backend.router import router
|
||||
|
||||
return router
|
||||
|
||||
|
||||
manifest = ModuleManifest(
|
||||
id="soap",
|
||||
name="SOAP Connector",
|
||||
version="0.1.7",
|
||||
required_capabilities=(CAPABILITY_AUTH_PRINCIPAL_RESOLVER, CAPABILITY_AUTH_PERMISSION_EVALUATOR),
|
||||
optional_dependencies=("audit", "docs", "policy"),
|
||||
provides_interfaces=(
|
||||
ModuleInterfaceProvider(name="soap.operationPublication", version="0.1.0"),
|
||||
),
|
||||
permissions=(
|
||||
_permission(SOAP_READ_SCOPE, "View SOAP connector", "Read SOAP connector status and published operation metadata."),
|
||||
),
|
||||
role_templates=(
|
||||
RoleTemplate(
|
||||
slug="soap_connector_reader",
|
||||
name="SOAP connector reader",
|
||||
description="Read SOAP connector diagnostics and published operation metadata.",
|
||||
permissions=(SOAP_READ_SCOPE,),
|
||||
level="system",
|
||||
),
|
||||
),
|
||||
route_factory=_route_factory,
|
||||
)
|
||||
|
||||
|
||||
def get_manifest() -> ModuleManifest:
|
||||
return manifest
|
||||
28
src/govoplan_soap/backend/router.py
Normal file
28
src/govoplan_soap/backend/router.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from fastapi import APIRouter, Depends, Request, status
|
||||
|
||||
from govoplan_core.auth import ApiPrincipal, require_any_scope
|
||||
from govoplan_core.core.registry import PlatformRegistry
|
||||
|
||||
from govoplan_soap.backend.manifest import SOAP_READ_SCOPES
|
||||
|
||||
router = APIRouter(prefix="/soap", tags=["soap"])
|
||||
|
||||
|
||||
@router.get("/status", status_code=status.HTTP_200_OK)
|
||||
def soap_status(
|
||||
request: Request,
|
||||
principal: ApiPrincipal = Depends(require_any_scope(*SOAP_READ_SCOPES)),
|
||||
) -> dict[str, Any]:
|
||||
del principal
|
||||
registry = getattr(request.app.state, "govoplan_registry", None)
|
||||
module_count = len(registry.manifests()) if isinstance(registry, PlatformRegistry) else 0
|
||||
return {
|
||||
"module": "soap",
|
||||
"status": "ok",
|
||||
"module_count": module_count,
|
||||
"published_operation_count": 0,
|
||||
}
|
||||
1
src/govoplan_soap/py.typed
Normal file
1
src/govoplan_soap/py.typed
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
Reference in New Issue
Block a user