added api endpoint to delete a process instance w/ burnettk

This commit is contained in:
jasquat 2022-06-20 16:44:25 -04:00
parent 65da9ccbaa
commit 17e741280d
2 changed files with 52 additions and 1 deletions

View File

@ -325,6 +325,39 @@ paths:
items:
$ref: "#/components/schemas/Workflow"
/process-models/{process_group_id}/{process_model_id}/process-instances/{process_instance_id}:
parameters:
- name: process_group_id
in: path
required: true
description: The unique id of an existing process group
schema:
type: string
- name: process_model_id
in: path
required: true
description: The unique id of an existing workflow specification.
schema:
type: string
- name: process_instance_id
in: path
required: true
description: The unique id of an existing process instance.
schema:
type: integer
delete:
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_instance_delete
summary: Deletes a single process group
tags:
- Process Groups
responses:
"200":
description: The process instance was deleted.
content:
application/json:
schema:
$ref: "#components/schemas/OkTrue"
/process-models/{process_group_id}/{process_model_id}/process-instances/report:
parameters:
- name: process_group_id

View File

@ -6,6 +6,7 @@ from flask import Blueprint
from flask import g
from flask import Response
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from spiffworkflow_backend.models.file import FileSchema
from spiffworkflow_backend.models.file import FileType
@ -251,7 +252,7 @@ def process_instance_list(process_group_id, process_model_id, page=1, per_page=1
if process_model is None:
raise (
ApiError(
code="process_mode_cannot_be_found",
code="process_model_cannot_be_found",
message=f"Process model cannot be found: {process_model_id}",
status_code=400,
)
@ -282,6 +283,23 @@ def process_instance_list(process_group_id, process_model_id, page=1, per_page=1
return Response(json.dumps(response_json), status=200, mimetype="application/json")
def process_instance_delete(process_group_id, process_model_id, process_instance_id):
"""Create_process_instance."""
process_instance = ProcessInstanceModel.query.filter_by(id=process_instance_id).first()
if process_instance is None:
raise (
ApiError(
code="process_instance_cannot_be_found",
message=f"Process instance cannot be found: {process_instance_id}",
status_code=400,
)
)
db.session.delete(process_instance)
db.session.commit()
return Response(json.dumps({"ok": True}), status=200, mimetype="application/json")
def process_instance_report(process_group_id, process_model_id, page=1, per_page=100):
"""Process_instance_list."""
process_model = ProcessModelService().get_process_model(