Reverse API Module

 

reverseAPI_add

URL/api/v1/api.php?target=reverseAPI&action=add
Description

Add a Reverse API Endpoint

Returns

Examples:

SUCCESSFUL

performs ResourceAPI-﹥Get operation to return the newly-created entry, thus will appear similar to a "Get" return:

{"success":1,"message":"Reverse API endpoint added","data":{"id":"1","name":"TestPoint2","type":"local","created_by":"user","last_modified":"2015-04-01 12:24:57","call":"http:\/\/www.test.com?api.php","presentation":null}}

ERROR{"success":0, "message":"error message"}
Required Parameters
NameTypeExampleDescription
name STRINGTestPoint2The name of the rAPI object
typeSTRINGlocalThe type of the rAPI object. Valid settings are 'local' and 'external'.
callSTRINGhttp://www.test.com?api.php&server={serverId}

The URL or the system path which is first decoded against a resource and then hit when this rAPI endpoint is invoked.

Optional Parameters
NameTypeExampleDescription
presentationSTRINGendpoint = function(data, outputDiv) {console.log(outputDiv);};The Javascript code used to display this endpoint on a resource page.
Example URL

/api/v1/api.php?target=reverseAPI&action=add&name=TestPoint2&type=local&call=http://www.test.com?api.php&server={serverId}

 

 

reverseAPI_get

URL/api/v1/api.php?target=reverseAPI&action=get
Description

Fetches one or more Reverse API endpoints

Returns

Examples:

SUCCESSFUL

An array of ReverseAPI objects:

{"id":"535","name":"Observium RAM Graph","type":"external","created_by":"user","last_modified":"2015-03-18 09:16:49","call":"http:\/\/observium.tcp0.com\/graph.php?height=200&width=265&type=device_ucd_memory&legend=no&username=api&password=password&device={observium-id}","presentation":"endpoint = function(data, outputDiv) {\n\n    outputDiv.css('font-family','Helvetica, Arial, sans-serif;');\n\n\toutputDiv.append(\"﹤div style='font-size:18;'﹥RAM Usage﹤\/div﹥\");\n\n\tif (data == \"\") {\n\t\toutputDiv.append(\"﹤div ﹥No data returned﹤\/div﹥\");\n\t\treturn;\n\t}\n\n\toutputDiv.append('﹤div style=\"margin-left:-18px;margin-top:-3px;\"﹥﹤img src=\"data:image\/png;base64,' + btoa(data) + '\" \/﹥﹤\/div﹥');\n};"}

ERROR{"success":0, "message":"error message"}

Return Detail:

NameTypeDescription
idINTEGERThe id of the rAPI objectSt
nameSTRINGThe name of the rAPI object
typeSTRINGThe type of the rAPI object
created_bySTRINGWhat user created the rAPI object
last_modifiedDATETIMEWhen this rAPI object was last changed
callSTRING

The URL or the system path which is first decoded against a resource and then hit when this rAPI endpoint is invoked.

presentationSTRINGThe Javascript code used to display this endpoint on a resource page.
Required Parameters

None

Optional Parameters
NameTypeExampleDescription
idINTEGER535The id of the rAPI objectSt
nameSTRINGTestPoint2The name of the rAPI object
typeSTRINGexternalThe type of the rAPI object. Valid settings are 'local' and 'external'.
created_bySTRINGuserThe user who created the rAPI object
Example URL

/api/v1/api.php?target=reverseAPI&action=get&name=TestPoint2

 

 

reverseAPI_delete

URL/api/v1/api.php?target=reverseAPI&action=delete
Description

Delete a rAPI endpoint

Returns

Examples:

SUCCESSFUL{"success":1,"message":"Reverse API endpoint deleted"}
ERROR{"success":0, "message":"error message"}
Required Parameters
NameTypeExampleDescription
idINTEGER535The id of the rAPI objectSt
nameSTRINGTestPoint2The name of the rAPI object
Optional Parameters

None

Example URL

/api/v1/api.php?target=reverseAPI&action=delete&id=535&name=TestPoint2

 

 

reverseAPI_update

URL/api/v1/api.php?target=reverseAPI&action=update
DescriptionUpdate an existing rAPI endpoint
Returns

Examples:

SUCCESSFULResourceAPI-﹥Get updated object, thus will appear the same as a "Get" return:

{"id":"535","name":"Observium RAM Graph","type":"external","created_by":"user","last_modified":"2015-03-18 09:16:49","call":"http:\/\/observium.tcp0.com\/graph.php?height=200&width=265&type=device_ucd_memory&legend=no&username=api&password=password&device={observium-id}","presentation":"endpoint = function(data, outputDiv) {\n\n    outputDiv.css('font-family','Helvetica, Arial, sans-serif;');\n\n\toutputDiv.append(\"﹤div style='font-size:18;'﹥RAM Usage﹤\/div﹥\");\n\n\tif (data == \"\") {\n\t\toutputDiv.append(\"﹤div ﹥No data returned﹤\/div﹥\");\n\t\treturn;\n\t}\n\n\toutputDiv.append('﹤div style=\"margin-left:-18px;margin-top:-3px;\"﹥﹤img src=\"data:image\/png;base64,' + btoa(data) + '\" \/﹥﹤\/div﹥');\n};"}

ERROR{"success":0, "message":"error message"}
Required Parameters
NameTypeExampleDescription
idINTEGER535The id of the rAPI objectSt
Optional Parameters
NameTypeExampleDescription
nameSTRINGTestPoint2The name of the rAPI object
typeSTRINGexternalThe type of the rAPI object. Valid settings are 'local' and 'external'.
callSTRING

http://www.test.com?api.php&server={serverId}&action=12

The URL or the system path which is first decoded against a resource and then hit when this rAPI endpoint is invoked.
presentationSTRINGendpoint = function(data, outputDiv) {console.log(outputDiv);};The Javascript code used to display this endpoint on a resource page.
Example URL

/api/v1/api.php?target=reverseAPI&action=update&id=535&name=TestPoint2

 

 

reverseAPI_execute

URL/api/v1/api.php?target=reverseAPI&action=execute
Description

Decodes a rAPI call against a Resource, executes the resulting string, returns the result along with the presentation code

Returns

Examples:

SUCCESSFUL

The result of a rAPI call customized for the supplied resource

{“data”:”\u0017\u00fbD","presentation":"endpoint = function(data, outputDiv) {\n\n\toutputDiv.css('font-family','Helvetica, Arial, sans-serif;');\n\n\toutputDiv.append(\"﹤div style='font-size:18;'﹥Port Traffic﹤\/div﹥\");\n\n\tif (data == \"\") {\n\t\toutputDiv.append(\"﹤div﹥No data returned﹤\/div﹥\");\n\t\treturn;\n\t}\n\n\toutputDiv.append('﹤div style=\"margin-left:-15px;margin-top:-3px;\"﹥﹤img src=\"data:image\/png;base64,' + btoa(data) + '\" \/﹥﹤\/div﹥');\n};"}}

ERROR{"success":0, "message":"error message"}

Return Detail:

NameTypeDescription
dataMIXEDThe result of the reverse API call.  Could be binary data, could be JSON.
presentationSTRINGThe presentation javascript which pairs with this rAPI call
Required Parameters
NameTypeExampleDescription
idINTEGER537The id of the rAPI objectSt
resource_idINTEGER2245ID of the resource
Optional ParametersNone
Example URL

/api/v1/api.php?target=reverseAPI&action=execute&id=537&resource_id=2245


  • No labels