api endpoint for instance logs

This commit is contained in:
mike cullerton 2022-09-07 17:03:33 -04:00
parent c7548dc664
commit fdae67db2b
2 changed files with 35 additions and 0 deletions

View File

@ -925,6 +925,28 @@ paths:
schema:
$ref: "#/components/schemas/Workflow"
/process-instance/{process_instance_id}/logs:
parameters:
- name: process_instance_id
in: path
required: true
description: the id of the process instance
schema:
type: integer
get:
tags:
- Process Instances
operationId: spiffworkflow_backend.routes.process_api_blueprint.get_process_instance_logs
summary: returns a list of logs associated with the process instance
responses:
"200":
description: list of logs
content:
application/json:
schema:
type: array
components:
securitySchemes:
jwt:

View File

@ -19,6 +19,7 @@ from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from SpiffWorkflow import Task as SpiffTask # type: ignore
from SpiffWorkflow import TaskState
from spiffworkflow_backend.models.spiff_logging import SpiffLoggingModel, SpiffLoggingModelSchema
from sqlalchemy import desc
from spiffworkflow_backend.exceptions.process_entity_not_found_error import (
@ -349,6 +350,18 @@ def process_instance_terminate(
return Response(json.dumps({"ok": True}), status=200, mimetype="application/json")
def get_process_instance_logs(process_instance_id: int) -> Response:
logs = SpiffLoggingModel.query.\
filter(SpiffLoggingModel.process_instance_id == process_instance_id).\
all()
log_schema = SpiffLoggingModelSchema(many=True).dump(logs)
return Response(
json.dumps(log_schema),
status=200,
mimetype="application/json",
)
# body: {
# payload: dict,
# process_instance_id: Optional[int],