Fix urls for uspend and resume endpoints

This commit is contained in:
mike cullerton 2022-11-06 14:23:16 -05:00
parent 2450800bbd
commit 0dad6788ff
4 changed files with 123 additions and 389 deletions

View File

@ -318,57 +318,6 @@ paths:
schema:
$ref: "#/components/schemas/File"
/process-models/{process_group_id}/{process_model_id}/files:
parameters:
- name: process_group_id
in: path
required: true
description: The group containing the models we want to return
schema:
type: string
- name: process_model_id
in: path
required: true
description: The unique id of an existing process model to validate.
schema:
type: string
# add_file
post:
operationId: spiffworkflow_backend.routes.process_api_blueprint.add_file
summary: Add a new workflow spec file
tags:
- Process Model Files
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
responses:
"201":
description: Metadata about the uploaded file, but not the file content.
content:
application/json:
schema:
$ref: "#/components/schemas/File"
# get:
# operationId: spiffworkflow_backend.api.process_api_blueprint.get_files
# summary: Provide a list of workflow spec files for the given workflow_spec_id. IMPORTANT, only includes metadata, not the file content.
# tags:
# - Process Model Files
# responses:
# '200':
# description: An array of file descriptions (not the file content)
# content:
# application/json:
# schema:
# type: array
# items:
# $ref: "#/components/schemas/File"
/process-models/{modified_process_model_identifier}:
parameters:
- name: modified_process_model_identifier
@ -419,64 +368,6 @@ paths:
schema:
$ref: "#/components/schemas/OkTrue"
/process-models/{process_group_id}/{process_model_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 process model.
schema:
type: string
# process_model_show
get:
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_model_show
summary: Returns a single process model
tags:
- Process Models
responses:
"200":
description: Workflow spec.
content:
application/json:
schema:
$ref: "#/components/schemas/ProcessModel"
# process_model_delete
delete:
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_model_delete
summary: Removes an existing process model
tags:
- Process Models
responses:
"200":
description: The process model has been removed.
content:
application/json:
schema:
$ref: "#/components/schemas/OkTrue"
put:
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_model_update
summary: Modifies an existing process mosel with the given parameters.
tags:
- Process Models
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/ProcessModel"
responses:
"200":
description: Process model updated successfully.
content:
application/json:
schema:
$ref: "#/components/schemas/ProcessModel"
/process-instances:
parameters:
- name: process_group_identifier
@ -652,34 +543,6 @@ paths:
schema:
$ref: "#/components/schemas/Workflow"
/process-models/{process_group_id}/{process_model_id}/process-instances:
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 process model.
schema:
type: string
# process_instance_create
post:
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_instance_create
summary: Creates an process instance from a process model and returns the instance
tags:
- Process Instances
responses:
"201":
description: Workflow generated successfully
content:
application/json:
schema:
$ref: "#/components/schemas/Workflow"
/process-instances/{process_instance_id}:
parameters:
- name: process_instance_id
@ -727,40 +590,6 @@ paths:
application/json:
schema:
$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 process model.
schema:
type: string
- name: process_instance_id
in: path
required: true
description: The unique id of an existing process instance.
schema:
type: integer
get:
tags:
- Process Instances
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_instance_show
summary: Show information about a process instance
responses:
"200":
description: One Process Instance
content:
application/json:
schema:
$ref: "#/components/schemas/Workflow"
# process_instance_delete
delete:
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_instance_delete
summary: Deletes a single process instance
@ -802,46 +631,6 @@ paths:
schema:
$ref: "#/components/schemas/Workflow"
/process-models/{process_group_id}/{process_model_id}/process-instances/{process_instance_id}/run:
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 process model.
schema:
type: string
- name: process_instance_id
in: path
required: true
description: The unique id of an existing process instance.
schema:
type: integer
- name: do_engine_steps
in: query
required: false
description: Defaults to true, can be set to false if you are just looking at the workflow not completeing it.
schema:
type: boolean
# process_instance_run
post:
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_instance_run
summary: Run a process instance
tags:
- Process Instances
responses:
"200":
description: Returns details about the workflows state and current task
content:
application/json:
schema:
$ref: "#/components/schemas/Workflow"
/process-instances/{process_instance_id}/terminate:
parameters:
- name: process_instance_id
@ -863,20 +652,8 @@ paths:
schema:
$ref: "#/components/schemas/OkTrue"
/process-models/{process_group_id}/{process_model_id}/process-instances/{process_instance_id}/terminate:
/process-instances/{process_instance_id}/suspend:
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 process model.
schema:
type: string
- name: process_instance_id
in: path
required: true
@ -884,40 +661,7 @@ paths:
schema:
type: integer
post:
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_instance_terminate
summary: Terminate a process instance
tags:
- Process Instances
responses:
"200":
description: Empty ok true response on successful termination.
content:
application/json:
schema:
$ref: "#/components/schemas/OkTrue"
/process-models/{process_group_id}/{process_model_id}/process-instances/{process_instance_id}/suspend:
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 process model.
schema:
type: string
- name: process_instance_id
in: path
required: true
description: The unique id of an existing process instance.
schema:
type: integer
post:
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_instance_suspend
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_instance_suspend_2
summary: Suspend a process instance
tags:
- Process Instances
@ -929,20 +673,8 @@ paths:
schema:
$ref: "#/components/schemas/OkTrue"
/process-models/{process_group_id}/{process_model_id}/process-instances/{process_instance_id}/resume:
/process-instances/{process_instance_id}/resume:
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 process model.
schema:
type: string
- name: process_instance_id
in: path
required: true
@ -1224,75 +956,6 @@ paths:
schema:
$ref: "#/components/schemas/OkTrue"
/process-models/{process_group_id}/{process_model_id}/files/{file_name}:
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 process model to validate.
schema:
type: string
- name: file_name
in: path
required: true
description: The id of the spec file
schema:
type: string
# get_file
get:
operationId: spiffworkflow_backend.routes.process_api_blueprint.get_file
summary: Returns metadata about the file
tags:
- Process Model Files
responses:
"200":
description: Returns the file information requested.
content:
application/json:
schema:
$ref: "#/components/schemas/File"
put:
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_model_file_update
summary: save the contents to the given file
tags:
- Process Model Files
requestBody:
description: Log Pagination Request
required: false
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
responses:
"200":
description: Metadata about the uploaded file, but not the file content.
content:
application/json:
schema:
$ref: "#/components/schemas/OkTrue"
delete:
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_model_file_delete
summary: Removes an existing process model file
tags:
- Process Model Files
responses:
"200":
description: The process model has been removed.
content:
application/json:
schema:
$ref: "#/components/schemas/OkTrue"
/tasks:
parameters:
- name: page
@ -1569,51 +1232,6 @@ paths:
schema:
$ref: "#/components/schemas/ProcessInstanceLog"
/process-models/{process_group_id}/{process_model_id}/process-instances/{process_instance_id}/logs:
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 process model.
schema:
type: string
- name: process_instance_id
in: path
required: true
description: the id of the process instance
schema:
type: integer
- name: page
in: query
required: false
description: The page number to return. Defaults to page 1.
schema:
type: integer
- name: per_page
in: query
required: false
description: The number of items to show per page. Defaults to page 10.
schema:
type: integer
get:
tags:
- Process Instances
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_instance_log_list
summary: returns a list of logs associated with the process instance
responses:
"200":
description: list of logs
content:
application/json:
schema:
$ref: "#/components/schemas/ProcessInstanceLog"
/secrets:
parameters:
- name: page

View File

@ -555,6 +555,10 @@ def process_instance_terminate(
return Response(json.dumps({"ok": True}), status=200, mimetype="application/json")
def process_instance_suspend_2(process_instance_id: int) -> flask.wrappers.Response:
return process_instance_suspend(None, None, process_instance_id)
def process_instance_suspend(
process_group_id: str,
process_model_id: str,
@ -569,6 +573,10 @@ def process_instance_suspend(
return Response(json.dumps({"ok": True}), status=200, mimetype="application/json")
def process_instance_resume_2(process_instance_id) -> flask.wrappers.Response:
return process_instance_resume(None, None, process_instance_id)
def process_instance_resume(
process_group_id: str,
process_model_id: str,
@ -1283,7 +1291,7 @@ def task_submit(
def script_unit_test_create(
process_group_id: str, process_model_id: str, body: Dict[str, Union[str, bool, int]]
) -> flask.wrappers.Response:
"""Script_unit_test_run."""
"""Script_unit_test_create."""
bpmn_task_identifier = _get_required_parameter_or_raise(
"bpmn_task_identifier", body
)

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:spiffworkflow="http://spiffworkflow.org/bpmn/schema/1.0/core" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_96f6665" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.0.0-dev">
<bpmn:process id="Proccess_ManualTask" name="Manual Task" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_1xlck7g</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_1xlck7g" sourceRef="StartEvent_1" targetRef="Activity_Hello" />
<bpmn:endEvent id="Event_0ia26nb">
<bpmn:incoming>Flow_0nnh2x9</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_0nnh2x9" sourceRef="Activity_Hello" targetRef="Event_0ia26nb" />
<bpmn:manualTask id="Activity_Hello" name="Hello">
<bpmn:extensionElements>
<spiffworkflow:instructionsForEndUser>## Hello</spiffworkflow:instructionsForEndUser>
</bpmn:extensionElements>
<bpmn:incoming>Flow_1xlck7g</bpmn:incoming>
<bpmn:outgoing>Flow_0nnh2x9</bpmn:outgoing>
</bpmn:manualTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Proccess_ManualTask">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="179" y="159" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0ia26nb_di" bpmnElement="Event_0ia26nb">
<dc:Bounds x="432" y="159" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1rcj16n_di" bpmnElement="Activity_Hello">
<dc:Bounds x="270" y="137" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1xlck7g_di" bpmnElement="Flow_1xlck7g">
<di:waypoint x="215" y="177" />
<di:waypoint x="270" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0nnh2x9_di" bpmnElement="Flow_0nnh2x9">
<di:waypoint x="370" y="177" />
<di:waypoint x="432" y="177" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -9,6 +9,8 @@ import pytest
from flask.app import Flask
from flask.testing import FlaskClient
from flask_bpmn.models.db import db
from spiffworkflow_backend.services.process_instance_service import ProcessInstanceService
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
@ -259,6 +261,7 @@ class TestProcessApi(BaseTest):
bpmn_file_name = "sample.bpmn"
bpmn_file_location = "sample"
process_model_identifier = f"{test_process_group_id}/{test_process_model_id}"
modified_process_model_identifier = process_model_identifier.replace("/", ":")
self.create_process_group(client, with_super_admin_user, test_process_group_id)
self.create_process_model_with_api(client, process_model_identifier, user=with_super_admin_user)
bpmn_file_data_bytes = self.get_test_data_file_contents(
@ -284,7 +287,7 @@ class TestProcessApi(BaseTest):
# try to delete the model
response = client.delete(
f"/v1.0/process-models/{test_process_group_id}/{test_process_model_id}",
f"/v1.0/process-models/{modified_process_model_identifier}",
headers=self.logged_in_headers(with_super_admin_user),
)
@ -707,8 +710,9 @@ class TestProcessApi(BaseTest):
# process_model = load_test_spec("random_fact")
bad_process_model_identifier = f"x{process_model_identifier}"
modified_bad_process_model_identifier = bad_process_model_identifier.replace("/", ":")
response = client.delete(
f"/v1.0/process-models/{bad_process_model_identifier}/files/random_fact.svg",
f"/v1.0/process-models/{modified_bad_process_model_identifier}/files/random_fact.svg",
follow_redirects=True,
headers=self.logged_in_headers(with_super_admin_user),
)
@ -894,8 +898,10 @@ class TestProcessApi(BaseTest):
"""Test_get_process_model_when_not_found."""
process_model_dir_name = "THIS_NO_EXISTS"
group_id = self.create_process_group(client, with_super_admin_user, "my_group")
bad_process_model_id = f"{group_id}/{process_model_dir_name}"
modified_bad_process_model_id = bad_process_model_id.replace("/", ":")
response = client.get(
f"/v1.0/process-models/{group_id}/{process_model_dir_name}",
f"/v1.0/process-models/{modified_bad_process_model_id}",
headers=self.logged_in_headers(with_super_admin_user),
)
assert response.status_code == 400
@ -2220,3 +2226,64 @@ class TestProcessApi(BaseTest):
# assert "pagingInfo" in rpc_json_data["result"]
#
# print("get_waku_messages")
def test_process_instance_suspend(
self,
app: Flask,
client: FlaskClient,
with_db_and_bpmn_file_cleanup: None,
with_super_admin_user: UserModel,
) -> None:
bpmn_file_name = "manual_task.bpmn"
bpmn_file_location = "manual_task"
process_model_identifier = self.basic_test_setup(
client=client,
user=with_super_admin_user,
process_model_id="manual_task",
bpmn_file_name=bpmn_file_name,
bpmn_file_location=bpmn_file_location
)
bpmn_file_data_bytes = self.get_test_data_file_contents(
bpmn_file_name, bpmn_file_location
)
self.create_spec_file(
client=client,
process_model_id=process_model_identifier,
process_model_location=process_model_identifier,
file_name=bpmn_file_name,
file_data=bpmn_file_data_bytes,
user=with_super_admin_user
)
headers = self.logged_in_headers(with_super_admin_user)
response = self.create_process_instance(
client, process_model_identifier, headers
)
assert response.json is not None
process_instance_id = response.json["id"]
client.post(
f"/v1.0/process-instances/{process_instance_id}/run",
headers=self.logged_in_headers(with_super_admin_user),
)
process_instance = ProcessInstanceService().get_process_instance(process_instance_id)
assert process_instance.status == "user_input_required"
client.post(
f"/v1.0/process-instances/{process_instance_id}/suspend",
headers=self.logged_in_headers(with_super_admin_user),
)
process_instance = ProcessInstanceService().get_process_instance(process_instance_id)
assert process_instance.status == "suspended"
# TODO: Why can I run a suspended process instance?
response = client.post(
f"/v1.0/process-instances/{process_instance_id}/run",
headers=self.logged_in_headers(with_super_admin_user),
)
# task = response.json['next_task']
print("test_process_instance_suspend")