Complete governed reporting execution and publication
This commit is contained in:
@@ -396,7 +396,12 @@ def publish_execution(
|
||||
options: Mapping[str, object],
|
||||
) -> dict[str, object]:
|
||||
_require_scope(principal, PUBLISH_SCOPE)
|
||||
execution_payload = get_execution(session, principal, execution_id=execution_id)
|
||||
execution_payload = get_execution(
|
||||
session,
|
||||
principal,
|
||||
execution_id=execution_id,
|
||||
registry=registry,
|
||||
)
|
||||
if execution_payload is None:
|
||||
raise LookupError("Reporting execution not found.")
|
||||
if execution_payload["status"] != "succeeded":
|
||||
@@ -497,14 +502,54 @@ def publish_execution(
|
||||
return _publication_payload(publication)
|
||||
|
||||
|
||||
def list_publications(
|
||||
session: Session,
|
||||
principal: object,
|
||||
*,
|
||||
execution_id: str | None = None,
|
||||
limit: int = 100,
|
||||
registry: object | None = None,
|
||||
) -> tuple[dict[str, object], ...]:
|
||||
_require_scope(principal, PUBLISH_SCOPE)
|
||||
statement = session.query(ReportingPublication).filter(
|
||||
ReportingPublication.tenant_id == _tenant(principal)
|
||||
)
|
||||
if execution_id:
|
||||
if (
|
||||
get_execution(
|
||||
session,
|
||||
principal,
|
||||
execution_id=execution_id,
|
||||
registry=registry,
|
||||
)
|
||||
is None
|
||||
):
|
||||
return ()
|
||||
statement = statement.filter(
|
||||
ReportingPublication.execution_id == execution_id
|
||||
)
|
||||
rows = (
|
||||
statement.order_by(ReportingPublication.created_at.desc())
|
||||
.limit(max(1, min(limit, 200)))
|
||||
.all()
|
||||
)
|
||||
return tuple(_publication_payload(row) for row in rows)
|
||||
|
||||
|
||||
def export_execution(
|
||||
session: Session,
|
||||
principal: object,
|
||||
*,
|
||||
execution_id: str,
|
||||
format: str,
|
||||
registry: object | None = None,
|
||||
) -> tuple[bytes, str, str]:
|
||||
payload = get_execution(session, principal, execution_id=execution_id)
|
||||
payload = get_execution(
|
||||
session,
|
||||
principal,
|
||||
execution_id=execution_id,
|
||||
registry=registry,
|
||||
)
|
||||
if payload is None:
|
||||
raise LookupError("Reporting execution not found.")
|
||||
if payload["status"] != "succeeded":
|
||||
@@ -850,6 +895,7 @@ __all__ = [
|
||||
"dispatch_due_schedules",
|
||||
"export_execution",
|
||||
"list_import_assessments",
|
||||
"list_publications",
|
||||
"list_saved_views",
|
||||
"list_schedules",
|
||||
"publish_execution",
|
||||
|
||||
Reference in New Issue
Block a user