diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/api.yml b/spiffworkflow-backend/src/spiffworkflow_backend/api.yml index cbd21576f..8d92dad23 100755 --- a/spiffworkflow-backend/src/spiffworkflow_backend/api.yml +++ b/spiffworkflow-backend/src/spiffworkflow_backend/api.yml @@ -141,6 +141,12 @@ paths: /process-groups: parameters: + - name: process_group_identifier + in: query + required: false + description: Optional parameter to filter by a single group + schema: + type: string - name: page 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 6e68b524d..e043172fd 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py @@ -178,9 +178,12 @@ def process_group_update( return make_response(jsonify(process_group), 200) -def process_groups_list(page: int = 1, per_page: int = 100) -> flask.wrappers.Response: +def process_groups_list(process_group_identifier: str = None, page: int = 1, per_page: int = 100) -> flask.wrappers.Response: """Process_groups_list.""" - process_groups = ProcessModelService().get_process_groups() + if process_group_identifier is not None: + process_groups = ProcessModelService().get_process_groups(process_group_identifier) + else: + process_groups = ProcessModelService().get_process_groups() batch = ProcessModelService().get_batch( items=process_groups, page=page, per_page=per_page ) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py index 8bf889abf..1b7d4c94f 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py @@ -160,9 +160,9 @@ class ProcessModelService(FileSystemService): process_models.sort() return process_models - def get_process_groups(self) -> list[ProcessGroup]: + def get_process_groups(self, process_group_id: str = None) -> list[ProcessGroup]: """Returns the process_groups as a list in display order.""" - process_groups = self.__scan_process_groups() + process_groups = self.__scan_process_groups(process_group_id) process_groups.sort() return process_groups @@ -254,12 +254,16 @@ class ProcessModelService(FileSystemService): index += 1 return process_groups - def __scan_process_groups(self) -> list[ProcessGroup]: + def __scan_process_groups(self, process_group_id: str = None) -> list[ProcessGroup]: """__scan_process_groups.""" if not os.path.exists(FileSystemService.root_path()): return [] # Nothing to scan yet. There are no files. + if process_group_id is not None: + scan_path = os.path.join(FileSystemService.root_path(), process_group_id) + else: + scan_path = FileSystemService.root_path() - with os.scandir(FileSystemService.root_path()) as directory_items: + with os.scandir(scan_path) as directory_items: process_groups = [] for item in directory_items: # if item.is_dir() and not item.name[0] == ".":