feat: route bounded hierarchy postbox copies
This commit is contained in:
@@ -39,6 +39,8 @@ from govoplan_postbox.backend.schemas import (
|
||||
PostboxMessageListResponse,
|
||||
PostboxMessageStateRequest,
|
||||
PostboxOrganizationTargetsResponse,
|
||||
PostboxRouteDryRunRequest,
|
||||
PostboxRouteDryRunResponse,
|
||||
PostboxTemplateCreateRequest,
|
||||
PostboxTemplateItem,
|
||||
PostboxTemplateListResponse,
|
||||
@@ -395,6 +397,30 @@ def api_deliver_to_postbox(
|
||||
return PostboxDeliveryResponse.model_validate(asdict(result))
|
||||
|
||||
|
||||
@router.post(
|
||||
"/routing/dry-run",
|
||||
response_model=PostboxRouteDryRunResponse,
|
||||
)
|
||||
def api_preview_postbox_routing(
|
||||
payload: PostboxRouteDryRunRequest,
|
||||
session: Session = Depends(get_session),
|
||||
principal: ApiPrincipal = Depends(get_api_principal),
|
||||
) -> PostboxRouteDryRunResponse:
|
||||
_require_any(principal, DELIVERY_SCOPE, TEMPLATE_ADMIN_SCOPE)
|
||||
try:
|
||||
result = get_service().preview_hierarchy_routes(
|
||||
session,
|
||||
tenant_id=principal.tenant_id,
|
||||
target=PostboxTargetRef(**payload.target.model_dump()),
|
||||
producer_module=payload.producer_module,
|
||||
classification=payload.classification,
|
||||
expires_at=payload.expires_at,
|
||||
)
|
||||
except PostboxError as exc:
|
||||
raise _http_error(exc) from exc
|
||||
return PostboxRouteDryRunResponse.model_validate(result)
|
||||
|
||||
|
||||
@router.get("/groupings", response_model=PostboxGroupingListResponse)
|
||||
def api_list_postbox_groupings(
|
||||
session: Session = Depends(get_session),
|
||||
@@ -502,7 +528,12 @@ def api_postbox_organization_targets(
|
||||
return PostboxOrganizationTargetsResponse(
|
||||
units=list(
|
||||
get_service().organization_targets(tenant_id=principal.tenant_id)
|
||||
)
|
||||
),
|
||||
structures=list(
|
||||
get_service().organization_hierarchy_targets(
|
||||
tenant_id=principal.tenant_id
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user