Append an entry to an AuditChain. The chain must not be closed. Call /audit/{chain_id}/close when done.
(
chain_id: str,
request: AuditChainAppendRequest,
db: Annotated[AsyncSession, Depends(get_db)],
)
| 691 | description="Append a new entry to an AuditChain.", |
| 692 | ) |
| 693 | async def append_entry( |
| 694 | chain_id: str, |
| 695 | request: AuditChainAppendRequest, |
| 696 | db: Annotated[AsyncSession, Depends(get_db)], |
| 697 | ) -> dict: |
| 698 | """ |
| 699 | Append an entry to an AuditChain. |
| 700 | |
| 701 | The chain must not be closed. Call /audit/{chain_id}/close when done. |
| 702 | """ |
| 703 | svc = AuditChainService() |
| 704 | try: |
| 705 | entry = await svc.append( |
| 706 | db, |
| 707 | chain_id=chain_id, |
| 708 | layer=request.layer, |
| 709 | event=request.event, |
| 710 | agent_id=request.agent_id, |
| 711 | mission_id=request.mission_id, |
| 712 | data=request.data, |
| 713 | token_id=request.token_id, |
| 714 | ) |
| 715 | return { |
| 716 | "entry_id": entry.entry_id, |
| 717 | "chain_id": entry.chain_id, |
| 718 | "sequence": entry.sequence, |
| 719 | "entry_hash": entry.entry_hash, |
| 720 | "message": "Entry appended", |
| 721 | } |
| 722 | except ValueError as e: |
| 723 | raise HTTPException(status_code=400, detail=str(e)) |
| 724 | |
| 725 | |
| 726 | @_audit.post( |
nothing calls this directly
no test coverage detected