Complete governed reporting execution and publication
This commit is contained in:
@@ -18,6 +18,11 @@ from govoplan_reporting.backend.definitions import (
|
||||
list_definitions,
|
||||
update_definition,
|
||||
)
|
||||
from govoplan_reporting.backend.drilldown import (
|
||||
ReportingDrillError,
|
||||
create_drill_context,
|
||||
resolve_drill_context,
|
||||
)
|
||||
from govoplan_reporting.backend.execution import (
|
||||
QUALITY_SCOPE,
|
||||
RUN_SCOPE,
|
||||
@@ -38,6 +43,7 @@ from govoplan_reporting.backend.operations import (
|
||||
dispatch_due_schedules,
|
||||
export_execution,
|
||||
list_import_assessments,
|
||||
list_publications,
|
||||
list_saved_views,
|
||||
list_schedules,
|
||||
publish_execution,
|
||||
@@ -53,10 +59,12 @@ from govoplan_reporting.backend.provider_reports import (
|
||||
list_provider_reports,
|
||||
provider_parameter_options,
|
||||
)
|
||||
from govoplan_reporting.backend.publication_targets import publication_target_catalog
|
||||
from govoplan_reporting.backend.query_engine import ReportingQueryError
|
||||
from govoplan_reporting.backend.schemas import (
|
||||
DefinitionUpdateRequest,
|
||||
DefinitionWriteRequest,
|
||||
DrillContextCreateRequest,
|
||||
ImportAssessmentRequest,
|
||||
PublicationRequest,
|
||||
ProviderReportExecutionRequest,
|
||||
@@ -432,7 +440,13 @@ def create_router(registry: object | None) -> APIRouter:
|
||||
_require(principal, RUN_SCOPE)
|
||||
return {
|
||||
"executions": list(
|
||||
list_executions(session, principal, report_id=report_id, limit=limit)
|
||||
list_executions(
|
||||
session,
|
||||
principal,
|
||||
report_id=report_id,
|
||||
limit=limit,
|
||||
registry=registry,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -443,11 +457,69 @@ def create_router(registry: object | None) -> APIRouter:
|
||||
principal: ApiPrincipal = Depends(get_api_principal),
|
||||
) -> dict[str, object]:
|
||||
_require(principal, RUN_SCOPE)
|
||||
result = get_execution(session, principal, execution_id=execution_id)
|
||||
result = get_execution(
|
||||
session,
|
||||
principal,
|
||||
execution_id=execution_id,
|
||||
registry=registry,
|
||||
)
|
||||
if result is None:
|
||||
raise HTTPException(status_code=404, detail="Reporting execution not found")
|
||||
return result
|
||||
|
||||
@router.post("/executions/{execution_id}/drill-contexts", status_code=201)
|
||||
def api_create_drill_context(
|
||||
execution_id: str,
|
||||
payload: DrillContextCreateRequest,
|
||||
session: Session = Depends(get_session),
|
||||
principal: ApiPrincipal = Depends(get_api_principal),
|
||||
) -> dict[str, object]:
|
||||
_require(principal, RUN_SCOPE)
|
||||
try:
|
||||
result = create_drill_context(
|
||||
session,
|
||||
principal,
|
||||
registry=registry,
|
||||
execution_id=execution_id,
|
||||
aggregate_row=payload.aggregate_row,
|
||||
limit=payload.limit,
|
||||
)
|
||||
session.commit()
|
||||
except (
|
||||
ReportingDrillError,
|
||||
ReportingExecutionError,
|
||||
PermissionError,
|
||||
LookupError,
|
||||
) as exc:
|
||||
session.rollback()
|
||||
raise _error(exc) from exc
|
||||
return result
|
||||
|
||||
@router.get("/drill-contexts/{token}")
|
||||
def api_resolve_drill_context(
|
||||
token: str,
|
||||
session: Session = Depends(get_session),
|
||||
principal: ApiPrincipal = Depends(get_api_principal),
|
||||
) -> dict[str, object]:
|
||||
_require(principal, RUN_SCOPE)
|
||||
try:
|
||||
result = resolve_drill_context(
|
||||
session,
|
||||
principal,
|
||||
registry=registry,
|
||||
token=token,
|
||||
)
|
||||
session.commit()
|
||||
except (
|
||||
ReportingDrillError,
|
||||
ReportingExecutionError,
|
||||
PermissionError,
|
||||
LookupError,
|
||||
) as exc:
|
||||
session.rollback()
|
||||
raise _error(exc) from exc
|
||||
return result
|
||||
|
||||
@router.get("/executions/{execution_id}/export")
|
||||
def api_export_execution(
|
||||
execution_id: str,
|
||||
@@ -462,6 +534,7 @@ def create_router(registry: object | None) -> APIRouter:
|
||||
principal,
|
||||
execution_id=execution_id,
|
||||
format=format,
|
||||
registry=registry,
|
||||
)
|
||||
except (ReportingOperationError, LookupError) as exc:
|
||||
raise _error(exc) from exc
|
||||
@@ -493,6 +566,33 @@ def create_router(registry: object | None) -> APIRouter:
|
||||
raise _error(exc) from exc
|
||||
return result
|
||||
|
||||
@router.get("/publication-targets")
|
||||
def api_publication_targets(
|
||||
principal: ApiPrincipal = Depends(get_api_principal),
|
||||
) -> dict[str, object]:
|
||||
_require(principal, PUBLISH_SCOPE)
|
||||
return {"targets": list(publication_target_catalog(registry))}
|
||||
|
||||
@router.get("/publications")
|
||||
def api_list_publications(
|
||||
execution_id: str | None = None,
|
||||
limit: int = Query(default=100, ge=1, le=200),
|
||||
session: Session = Depends(get_session),
|
||||
principal: ApiPrincipal = Depends(get_api_principal),
|
||||
) -> dict[str, object]:
|
||||
_require(principal, PUBLISH_SCOPE)
|
||||
return {
|
||||
"publications": list(
|
||||
list_publications(
|
||||
session,
|
||||
principal,
|
||||
execution_id=execution_id,
|
||||
limit=limit,
|
||||
registry=registry,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@router.get("/reports/{report_id}/saved-views")
|
||||
def api_list_saved_views(
|
||||
report_id: str,
|
||||
|
||||
Reference in New Issue
Block a user