Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Warning

Looking for the documentation on the newest versions of SIL Engine and the Simple Issue Language for Jira 8 for Server/Data Center? Click here !

Contents

Table of Contents

Info
titleAvailability

Available since katl-commons starting with SIL Engine™ 2.5.5.

Introduction

Since Starting with version 2.5.5, katl-commons exposes SIL Engine™ exposes a REST service to facilitate arbitrary execution of SIL SIL™ scripts. These services are available via HTTP POST at <your_base_url>/rest/keplerrominfo/refapp/latest/async-script and <your_base_url>/rest/keplerrominfo/refapp/latest/async. The service responses are all JSON formatted (see Beans below).

...

Note
titleAuthentication

Note that all the services require that the calling user is authenticated. You can use Basic authentication with your HTTP request.


Services

MethodFull PathAvailability
findScriptFiles<your_base_url>/rest/keplerrominfo/refapp/latest/async-script/findScriptFiles4.0.0+
checkScript<your_base_url>/rest/keplerrominfo/refapp/latest/async-script/checkScript4.0.0+
runScript<your_base_url>/rest/keplerrominfo/refapp/latest/async-script/runScript4.0.0+
runDetachedScript<your_base_url>/rest/keplerrominfo/refapp/latest/async-script/runDetachedScript4.0.0+
getResult<your_base_url>/rest/keplerrominfo/refapp/latest/async/getResult4.0.0+

findScriptFiles

Allows you to scan a folder for specific files for which where the filename matches a specific regular expression.

ParameterTypeRequiredDescription
dirPathstringyesThe path of the directory to scan. Can be absolute or relative to the silprograms folder. If absolute, it must still point to a location under silprograms.
regexstringyesThe regular expression to match the filenames against

Returns a ScriptFileListResponse.


Code Block
languagejavascript
titleExample Request using AJS
AJS.$.ajax({
 type: 'POST',
 contentType: "application/json",
 url : "http://localhost:7210/rest/keplerrominfo/refapp/latest/async-script/findScriptFiles",
 data : JSON.stringify({
 	dirPath : "D:/test",
    regex : "[^.]*\.sil"
 }),
 success : function(data) {
	console.log(data);
 },
 beforeSend: function (xhr){ 
	 xhr.setRequestHeader('Authorization', "Basic " + btoa(username + ":" + password)); 
 }
}); 



Code Block
languagejavascript
titleExample JSON Response
{
 "files":[
   "D:\\test\\test_1234567890 - Copy (5).sil",
   "D:\\test\\test_1234567890 - Copy (6).sil",
   "D:\\test\\test_1234567890 - Copy.sil",
   "D:\\test\\test_1234567890.sil"
 ]
}  


checkScript

Schedules a check script task to be run asynchronously for the given script and returns a ScriptScheduledResponse.

ParameterTypeRequiredDescription
source

ScriptSource

yesThe script to check


Code Block
titleExample Request using AJS
AJS.$.ajax({
 type: 'POST',
 contentType: "application/json",
 url : "http://localhost:7210/rest/keplerrominfo/refapp/latest/async-script/checkScript",
 data : JSON.stringify({
   source : {
   	type: "fileINLINE",
   	code: "return 1;"
 	}
 }),
 success : function(data) {
    console.log(data);
 },
 beforeSend: function (xhr){
     xhr.setRequestHeader('Authorization', "Basic " + btoa(username + ":" + password));
 }
});



Code Block
titleExample JSON Response
{
 "key" : 4
} 




runScript

Schedules a run script task to be run asynchronously for the given script and returns a ScriptScheduledResponse. To run in the context of an issue, pass a property with the key "sil.issue.key" and value with the issue key.

ParameterTypeRequiredDescription
source

ScriptSource

yesThe script to run
propertiesarray of objects containing "key" and "value"no
Code Block
titleexample properties
"properties": [
	{
		"key": "sil.issue.key",
		"value": "TEST-1"
	}
]
argsarray of stringsnowill be passed into the script as the "argv" variable


Code Block
titleExample Request using AJS
AJS.$.ajax({
 type: 'POST',
 contentType: "application/json",
 url : "http://localhost:7210/rest/keplerrominfo/refapp/latest/async-script/runScript",
 data : JSON.stringify({
   source: {
   		type: "fileFILE",
   		code: "return 1;"
	}: "example.sil"
	},
   properties: [{
        "key": "sil.issue.key",
        "value": "TEST-1"
    }],
   args: ["first", "second"]
 }),
 success : function(data) {
    console.log(data);
 },
 beforeSend: function (xhr){
     xhr.setRequestHeader('Authorization', "Basic " + btoa(username + ":" + password));
 }
});



Code Block
titleExample JSON Response
{
 "key" : 4
} 



runDetachedScript

Schedules a task to execute the script passed in as parameter on the server side and does not return the response or any information about it (simply runs the script).

ParameterTypeRequiredDescription

source

ScriptSource
yesThe script to run
propertiesarray of objects containing "key" and "value"no
Code Block
titleexample properties
"properties": [
	{	
		"key": "sil.issue.key",
		"value": "TEST-1"
	}
]
argsarray of stringsnowill be passed into the script as the "argv" variable


Code Block
titleExample Request using AJS
AJS.$.ajax({
 type: 'POST',
 contentType: "application/json",
 url : "http://localhost:7210/rest/keplerrominfo/refapp/latest/async-script/runDetachedScript",
 data : JSON.stringify({
   source: {
   	type: "fileINLINE",
   	code: "return 1;"
 }
 }),
 success : function(data) {
    console.log(data);
 },
 beforeSend: function (xhr){
     xhr.setRequestHeader('Authorization', "Basic " + btoa(username + ":" + password));
 }
});



Code Block
titleExample JSON Response
nullHTTP 204 No content



getResult

Checks if the task identified by the provided id is still running or has finished and returns an AsyncResultResponse. If the task has finished execution, the result is removed from memory and returned in the response. Subsequent calls to this method will not return the result. If the task has not finished execution, you may repeat the call to getResult until the response contains "running": false.

ParameterTypeRequiredDescription

key

intyesThe unique key identifying a scheduled task.


Code Block
titleExample Request using AJS
AJS.$.ajax({
 type: 'POST',
 contentType: "application/json",
 url : "http://localhost:7210/rest/keplerrominfo/refapp/latest/async/getResult",
 data : JSON.stringify({
   key: 4
  }),
 success : function(data) {
    console.log(data);
 },
 beforeSend: function (xhr){
     xhr.setRequestHeader('Authorization', "Basic " + btoa(username + ":" + password));
 }
});



Code Block
titleExample JSON Response for checkScript
{
 "running":false,
 "outcome": {
	 "valid": true
 }
}



Code Block
titleExample JSON Response for checkScript
{
 "running":false,
 "outcome" : {
 	"errors" : 

...

[
		

...

{
			"errLine":1
			"error":"Encountered <DOUBLE>  at line 1, column 13. Was expecting one of:  ";" , "." , "." "
		}
	]
 }
}
Code Block
titleExample JSON Response for runScript
{
 "running":false,
 "outcome" : {
	"results":["string returned from script"] // array of values returned by script using "return val1, val2";
 }
}



Beans

Anchor
ScriptFileListResponse
ScriptFileListResponse
ScriptFileListResponse

FieldTypeDescription
filesstring []List of absolute paths


Anchor
AsyncResultResponse
AsyncResultResponse
AsyncResultResponse


FieldTypeDescription

running

booleanSignals that the script is still running and that you should wait a bit before retrying the call.
outcomeObjectThe results


Anchor
ScriptScheduledResponse
ScriptScheduledResponse
ScriptScheduledResponse

FieldTypeDescription
keyintThe unique key of the scheduled task


Anchor
ScriptSource
ScriptSource
ScriptSource

FieldTypeDescription
typestringThe type of the source. Either "INLINE" or "FILE".
codestringThe source code

If type is "INLINE", this should contain some SIL source code

if type id "FILE", this should contain a path to a file. The path can either be absolute or relative to the silprograms folder. If absolute, must still point to a file under silprograms (e.g. "/opt/jira/home/silprograms/fld1/fld2/script.sil" and "fld1/fld2/script.sil" point to the same file)

CURL Example


The following curl calls show how you would call SIL SIL™ scripts from your favourite system (that's Linux, I hope). The commands assume that username / password is 'admin'

Notice the way you pass multiple parameters to the SIL SIL™ scripts. The logic is the same, you post the script to start running asynchronously, then you come back later for the results.

...

Code Block
$curl -H "Content-Type: application/json" -u admin:admin -d " {\"source\" : { \"type\": \"fileINLINE\", \"code\": \"return 1;\"}}" 192.168.19.250:7210/rest/keplerrominfo/refapp/latest/async-script/runScript
{"key":43}

$curl -H "Content-Type: application/json" -u admin:admin -d "{\"key\" : 3}" 192.168.19.250:7210/rest/keplerrominfo/refapp/latest/async/getResult 
{"running":false,"outcome":{"results":["1"]}}

...