From 43069236d173b337ae13d6ec8410be667bafc987 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Mon, 7 Nov 2022 17:25:04 -0500 Subject: [PATCH] remove process_group_identifier from process-instances endpoint --- .../src/spiffworkflow_backend/api.yml | 6 ------ .../routes/process_api_blueprint.py | 18 ++++++++++++------ .../integration/test_process_api.py | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/api.yml b/spiffworkflow-backend/src/spiffworkflow_backend/api.yml index 137e62cd..a85a7730 100755 --- a/spiffworkflow-backend/src/spiffworkflow_backend/api.yml +++ b/spiffworkflow-backend/src/spiffworkflow_backend/api.yml @@ -368,12 +368,6 @@ paths: /process-instances: parameters: - - name: process_group_identifier - in: query - required: false - description: The unique id of an existing process group - schema: - type: string - name: process_model_identifier in: query required: false diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py index e19adfb9..b424ded9 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py @@ -136,6 +136,14 @@ def permissions_check(body: Dict[str, Dict[str, list[str]]]) -> flask.wrappers.R return make_response(jsonify({"results": response_dict}), 200) +def modify_process_model_id(process_model_id: str) -> str: + return process_model_id.replace('/', ':') + + +def un_modify_modified_process_model_id(modified_process_model_id: str) -> str: + return modified_process_model_id.replace(':', '/') + + def process_group_add(body: dict) -> flask.wrappers.Response: """Add_process_group.""" process_model_service = ProcessModelService() @@ -400,9 +408,7 @@ def process_instance_create( modified_process_model_id: str ) -> flask.wrappers.Response: """Create_process_instance.""" - # process_model_id = modified_process_model_id.replace(":", "/") - # process_model_identifier = f"{process_group_id}/{process_model_id}" - process_model_identifier = modified_process_model_id.replace(":", "/") + process_model_identifier = un_modify_modified_process_model_id(modified_process_model_id) process_instance = ProcessInstanceService.create_process_instance( process_model_identifier, g.user ) @@ -651,7 +657,6 @@ def message_start( def process_instance_list( - process_group_identifier: Optional[str] = None, process_model_identifier: Optional[str] = None, page: int = 1, per_page: int = 100, @@ -662,10 +667,11 @@ def process_instance_list( process_status: Optional[str] = None, ) -> flask.wrappers.Response: """Process_instance_list.""" + # process_model_identifier = un_modify_modified_process_model_id(modified_process_model_identifier) process_instance_query = ProcessInstanceModel.query - if process_model_identifier is not None and process_group_identifier is not None: + if process_model_identifier is not None: process_model = get_process_model( - f"{process_group_identifier}/{process_model_identifier}", + f"{process_model_identifier}", ) process_instance_query = process_instance_query.filter_by( diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py index 8998406b..b1685e94 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py @@ -1417,7 +1417,7 @@ class TestProcessApi(BaseTest): # Without filtering we should get all 5 instances response = client.get( - f"/v1.0/process-instances?process_group_identifier={process_group_id}&process_model_identifier={process_model_id}", + f"/v1.0/process-instances?process_model_identifier={process_model_identifier}", headers=self.logged_in_headers(with_super_admin_user), ) assert response.json is not None @@ -1428,7 +1428,7 @@ class TestProcessApi(BaseTest): # we should get 1 instance each time for i in range(5): response = client.get( - f"/v1.0/process-instances?process_status={ProcessInstanceStatus[statuses[i]].value}&process_group_identifier={process_group_id}&process_model_identifier={process_model_id}", + f"/v1.0/process-instances?process_status={ProcessInstanceStatus[statuses[i]].value}&process_model_identifier={process_model_identifier}", headers=self.logged_in_headers(with_super_admin_user), ) assert response.json is not None @@ -1437,7 +1437,7 @@ class TestProcessApi(BaseTest): assert results[0]["status"] == ProcessInstanceStatus[statuses[i]].value response = client.get( - f"/v1.0/process-instances?process_status=not_started,complete&process_group_identifier={process_group_id}&process_model_identifier={process_model_id}", + f"/v1.0/process-instances?process_status=not_started,complete&process_model_identifier={process_model_identifier}", headers=self.logged_in_headers(with_super_admin_user), ) assert response.json is not None