Commit 0928c0a2 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Titouan Soulard

slapos_jio_api_style: Add dedicated JSON form to get Software Instance

This is needed as we get software instances by their reference and not
their relative urls
parent 91a696c9
......@@ -77,7 +77,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Base_asJSONTextFromJSON</string> </value>
<value> <string>string:${object_url}/SoftwareInstance_getFromJSON</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="JSON Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>after_method_id</string> </key>
<value> <string>Base_asJSONText</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/json</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SoftwareInstance_getFromJSON</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareInstance_getFromJSON</string> </value>
</item>
<item>
<key> <string>output_schema</string> </key>
<value> <string>{\n
"title": "bar"\n
}</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>JSON Form</string> </value>
</item>
<item>
<key> <string>text_content</string> </key>
<value> <string>{\n
"$schema": "http://json-schema.org/draft-07/schema#",\n
"title": "Get Compute Node",\n
"description": "Data necessary to get Compute Node",\n
"type": "object",\n
"oneOf": [\n
{\n
"properties": {\n
"reference": {\n
"title": "Software Instance Id/Reference",\n
"type": "string",\n
"description": "The unique reference of the Software Instance, example: SOFTINST-1234"\n
},\n
"portal_type": {\n
"title": "Portal Type",\n
"const": "Software Instance",\n
"type": "string"\n
}\n
},\n
"required": [\n
"reference",\n
"portal_type"\n
]\n
},\n
{\n
"properties": {\n
"id": {\n
"title": "ID",\n
"type": "string",\n
"description": "Unique Id of the object. This ID is defined by KD Portal. It is not editable."\n
}\n
},\n
"required": [\n
"id"\n
]\n
}\n
]\n
}\n
</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>01</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -9,4 +9,10 @@ if portal_type == "Software Installation":
if compute_node:
return compute_node.getSoftwareInstallationFromUrl(data_dict["software_release_uri"])
elif portal_type == "Software Instance":
if "reference" in data_dict:
software_instance = portal.portal_catalog.getSoftwareInstanceObject(data_dict["reference"])
if software_instance:
return software_instance
return None
portal_callables/SoftwareInstallation_updateFromJSON
portal_callables/SoftwareInstance_getFromJSON
portal_callables/jIOWebSection_createComputeNodeFromJSON
portal_callables/jIOWebSection_createSoftwareInstallationFromJSON
portal_callables/jIOWebSection_requestComputerPartitionFromJSON
\ No newline at end of file
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