Add endpoint for listing process models in a group
Add pagination for listing process groups
This commit is contained in:
parent
20810fd999
commit
1524b12a4a
|
@ -11,6 +11,19 @@ security:
|
|||
|
||||
paths:
|
||||
/process-groups:
|
||||
parameters:
|
||||
- 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 groups to show per page. Defaults to page 10.
|
||||
schema:
|
||||
type: integer
|
||||
# process_groups_list
|
||||
get:
|
||||
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_groups_list
|
||||
|
@ -92,6 +105,42 @@ paths:
|
|||
schema:
|
||||
$ref: "#/components/schemas/WorkflowSpecCategory"
|
||||
|
||||
/process-groups/{process_group_id}/process-models:
|
||||
parameters:
|
||||
- name: process_group_id
|
||||
in: path
|
||||
required: true
|
||||
description: The group containing the models we want to return
|
||||
schema:
|
||||
type: string
|
||||
- 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 models to show per page. Defaults to page 10.
|
||||
schema:
|
||||
type: integer
|
||||
# process_model_list
|
||||
get:
|
||||
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_model_list
|
||||
summary: Return a list of process models for a given process group
|
||||
tags:
|
||||
- Process Models
|
||||
responses:
|
||||
"200":
|
||||
description: Successfully return the requested models
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/WorkflowSpec"
|
||||
|
||||
/process-models:
|
||||
# process_model_add
|
||||
post:
|
||||
|
|
|
@ -59,10 +59,11 @@ def process_group_update(process_group_id, body):
|
|||
return ProcessGroupSchema().dump(process_group)
|
||||
|
||||
|
||||
def process_groups_list():
|
||||
def process_groups_list(page=1, per_page=100):
|
||||
"""Process_groups_list."""
|
||||
process_groups = ProcessModelService().get_process_groups()
|
||||
return ProcessGroupSchema(many=True).dump(process_groups)
|
||||
batch = ProcessModelService().get_batch(process_groups, page, per_page)
|
||||
return ProcessGroupSchema(many=True).dump(batch)
|
||||
|
||||
|
||||
def process_group_show(process_group_id):
|
||||
|
|
|
@ -26,6 +26,12 @@ class ProcessModelService(FileSystemService):
|
|||
GROUP_SCHEMA = ProcessGroupSchema()
|
||||
WF_SCHEMA = ProcessModelInfoSchema()
|
||||
|
||||
@staticmethod
|
||||
def get_batch(items, page=1, per_page=10):
|
||||
start = (page - 1) * per_page
|
||||
end = start + per_page
|
||||
return items[start:end]
|
||||
|
||||
def add_spec(self, spec: ProcessModelInfo):
|
||||
"""Add_spec."""
|
||||
display_order = self.next_display_order(spec)
|
||||
|
|
Loading…
Reference in New Issue