Hi,
I was recently looking into either modifying the already existing php class for the Linode API, or writing my own and was going to use the api.spec() call to load the parameters into an array. I have since done this, but noticed the call to api.spec() returns parameters in an order not consistent with the documentation. To me, it would make sense to either re-order the parameters, or add a parameter index to the returned parameters for the various methods, so that when the methods are dynamically generated with the php script, their calls will match the order given for the parameters in the documentation.
Here's an example of what I'm talking about with the method linode.config.create().
This is what the documentation states for its parameters, and presumably, their proper order.
Code:
LinodeID - numeric (required)
KernelID - numeric (required)
The KernelID for this profile. Found in avail.kernels()
Label - string (required)
The Label for this profile
Comments - string, default: '' (optional)
Comments you wish to save along with this profile
RAMLimit - numeric, default: '0' (optional)
RAMLimit in MB. 0 for max.
DiskList - string, default: ',,,,,,,,' (optional)
A comma deliminted list of DiskIDs; position reflects device node. The 9th element for specifying the initrd.
RunLevel - string, default: 'default' (optional)
One of 'default', 'single', 'binbash'
RootDeviceNum - numeric, default: '1' (optional)
Which device number (1-8) that contains the root partition. 0 to utilize RootDeviceCustom.
RootDeviceCustom - string, default: '' (optional)
A custom root device setting.
RootDeviceRO - boolean, default: 'true' (optional)
Enables the 'ro' kernel flag. Modern distros want this.
helper_disableUpdateDB - boolean, default: 'true' (optional)
Enable the disableUpdateDB filesystem helper
helper_xen - boolean, default: 'true' (optional)
Enable the Xen filesystem helper. Corrects fstab and inittab/upstart entries depending on the kernel you're booting. You want this.
helper_depmod - boolean, default: 'true' (optional)
Creates an empty modprobe file for the kernel you're booting.
devtmpfs_automount - boolean, default: 'true' (optional)
Controls if pv_ops kernels should automount devtmpfs at boot.
Here are the parameters from the raw JSON output of
https://api.linode.com/?api_action=api.specCode:
"linode.config.create":{"DESCRIPTION":"Creates a Linode Configuration Profile.","PARAMETERS":{"RootDeviceCustom":{"DESCRIPTION":"A custom root device setting.","default":"","TYPE":"string","REQUIRED":false},"Comments":{"DESCRIPTION":"Comments you wish to save along with this profile","default":"","TYPE":"string","REQUIRED":false},"devtmpfs_automount":{"DESCRIPTION":"Controls if pv_ops kernels should automount devtmpfs at boot. ","default":true,"TYPE":"boolean","REQUIRED":false},"helper_disableUpdateDB":{"DESCRIPTION":"Enable the disableUpdateDB filesystem helper","default":true,"TYPE":"boolean","REQUIRED":false},"Label":{"DESCRIPTION":"The Label for this profile","TYPE":"string","REQUIRED":true},"ConfigID":{"DESCRIPTION":"","TYPE":"numeric","REQUIRED":true},"DiskList":{"DESCRIPTION":"A comma deliminted list of DiskIDs; position reflects device node. The 9th element for specifying the initrd.","default":",,,,,,,,","TYPE":"string","REQUIRED":false},"RunLevel":{"DESCRIPTION":"One of 'default', 'single', 'binbash' ","default":"default","TYPE":"string","REQUIRED":false},"RootDeviceRO":{"DESCRIPTION":"Enables the 'ro' kernel flag. Modern distros want this. ","default":true,"TYPE":"boolean","REQUIRED":false},"RootDeviceNum":{"DESCRIPTION":"Which device number (1-8) that contains the root partition. 0 to utilize RootDeviceCustom.","default":1,"TYPE":"numeric","REQUIRED":false},"helper_xen":{"DESCRIPTION":"Enable the Xen filesystem helper. Corrects fstab and inittab\/upstart entries depending on the kernel you're booting. You want this.","default":true,"TYPE":"boolean","REQUIRED":false},"RAMLimit":{"DESCRIPTION":"RAMLimit in MB. 0 for max.","default":0,"TYPE":"numeric","REQUIRED":false},"LinodeID":{"DESCRIPTION":"","TYPE":"numeric","REQUIRED":true},"helper_depmod":{"DESCRIPTION":"Creates an empty modprobe file for the kernel you're booting. ","default":true,"TYPE":"boolean","REQUIRED":false},"KernelID":{"DESCRIPTION":"The KernelID for this profile. Found in avail.kernels()","TYPE":"numeric","REQUIRED":true}},"THROWS":"NOTFOUND,VALIDATION"}}
Other methods are similar to this in their parameter order. I could, of course, make the script re-order the parameters for each method, or write a JSON or XML file with the methods and parameters, but that would be defeating the point of the api.spec() call in my opinion.
Also, though this isn't nearly as big a problem, on a couple of the methods the REQUIRE element for a parameter will say no or yes, rather than true or false. The methods are avail.linodeplans() and linode.disk.createfromstackscript().
Blake