Commit bdab2670 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Romain Courteaud

slapos_jio_api_style: Add limit and pagination on search instance

parent 6410b52f
...@@ -35,6 +35,16 @@ ...@@ -35,6 +35,16 @@
"title": "allDocs: Response Payload",\n "title": "allDocs: Response Payload",\n
"description": "Payload returned by allDocs method.",\n "description": "Payload returned by allDocs method.",\n
"properties": {\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 "result_list": {\n
"title": "Result List",\n "title": "Result List",\n
"description": "Contains a representation of the items",\n "description": "Contains a representation of the items",\n
......
portal_type = data_dict["portal_type"] portal_type = data_dict["portal_type"]
portal = context.getPortalObject() portal = context.getPortalObject()
# Hardcoded
limit = 1000
reverse_slap_state_dict = { reverse_slap_state_dict = {
"stopped": "stop_requested", "stopped": "stop_requested",
"started": "start_requested", "started": "start_requested",
...@@ -17,7 +20,9 @@ if portal_type == "Software Instance": ...@@ -17,7 +20,9 @@ if portal_type == "Software Instance":
search_kw = { search_kw = {
"portal_type": "Software Instance", "portal_type": "Software Instance",
"validation_state": "validated", "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: if "title" in data_dict:
...@@ -47,7 +52,9 @@ elif portal_type == "Shared Instance": ...@@ -47,7 +52,9 @@ elif portal_type == "Shared Instance":
search_kw = { search_kw = {
"portal_type": "Slave Instance", "portal_type": "Slave Instance",
"validation_state": "validated", "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: if "host_instance_reference" in data_dict:
host_instance_list = portal.portal_catalog( host_instance_list = portal.portal_catalog(
...@@ -89,5 +96,7 @@ else: ...@@ -89,5 +96,7 @@ else:
import json import json
return json.dumps({ return json.dumps({
"$schema": json_form.absolute_url().strip() + "/getOutputJSONSchema", "$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) }, 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