Commit c2f5f1f6 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

slapos_jio_api_style: Add limit and pagination on search instance

parent 15bb0ac6
......@@ -35,6 +35,16 @@
"title": "allDocs: Response Payload",\n
"description": "Payload returned by allDocs method.",\n
"properties": {\n
"result_number": {\n
"title": "Result Number",\n
"type": "number",\n
"description": "Quantity of results found"\n
},\n
"max_result_number_allowed": {\n
"title": "Max Result Number",\n
"type": "number",\n
"description": "Highest number of result given by the system. To get the rest of the result you can use \'from_processing_timestamp\' parameter for pagination."\n
},\n
"result_list": {\n
"title": "Result List",\n
"description": "Contains a representation of the items",\n
......
portal_type = data_dict["portal_type"]
portal = context.getPortalObject()
# Hardcoded
limit = 1000
reverse_slap_state_dict = {
"stopped": "stop_requested",
"started": "start_requested",
......@@ -17,7 +20,9 @@ if portal_type == "Software Instance":
search_kw = {
"portal_type": "Software Instance",
"validation_state": "validated",
"select_list": ("title", "reference", "portal_type", "slap_state", "aggregate_reference", "url_string", "slap_date")
"select_list": ("title", "reference", "portal_type", "slap_state", "aggregate_reference", "url_string", "slap_date"),
"sort_on": ("slap_date", "ASC"),
"limit": limit
}
if "title" in data_dict:
......@@ -47,7 +52,9 @@ elif portal_type == "Shared Instance":
search_kw = {
"portal_type": "Slave Instance",
"validation_state": "validated",
"select_list": ("title", "reference", "portal_type", "slap_state", "aggregate_reference", "slap_date")
"select_list": ("title", "reference", "portal_type", "slap_state", "aggregate_reference", "slap_date"),
"sort_on": ("slap_date", "ASC"),
"limit": limit
}
if "host_instance_reference" in data_dict:
host_instance_list = portal.portal_catalog(
......@@ -89,5 +96,7 @@ else:
import json
return json.dumps({
"$schema": json_form.absolute_url().strip() + "/getOutputJSONSchema",
"result_list": result_list
"result_list": result_list,
"result_number": len(result_list),
"max_result_number_allowed": limit,
}, indent=2)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment