Close

REST API

Contents
AuthenticationExecutionFunctionWork sessionMetadataParameterParameter EntrySuperpackSnapshot

Authentication  #

Hyperon REST API uses basic authentication to authenticate and access API

Execution  #

/api/execution endpoint is related to retrieving values from parameters/functions for given context.

POST /execute

returns resolved value from parameters/functions for given context. Request example:

{ 
  "ctx": {    
    "properties": [{"key": "test", "value":"val_a"}]    
  },     
  "elements": [{"code":"tmp.rest", "type":"PARAMETER"}] 
}

Response example:

[
  {
    "element":{
    "code":"mg.tmp.rest",
    "type":"PARAMETER"
    },
    "resultValue":[{
     "flds":[{"f":"out1","v":"b"}]
    }]
  }
]

Function  #

api/function endpoint is related to functions in Hyperon.

GET /api/function?ids=<LIST_OF_IDS>

returns collection of functions with given in url params ids. Response example:

{
  "functions":[
    {
    "id":6925100,
    "code":"rest.fun.test",
    "type":"GROOVY",
    "version":"1",
    "regionId":302,
    "body":"return 2;",
    "args":["ctx"],
    "lastUpdate":1516282313129,
    "categories":["REST"],
    }
  ]
}

Work session  #

/api/workSession endpoint is related to every type of work session in Hyperon Studio.

POST /api/workSession/publish/{sessionId}

publishes session with given id. Response example:

{
    "result": 1, //1 = SUCCESS, 0 = ERROR
    "messages": "OK"
}

POST /api/workSession/reject/{sessionId}

rejects session with given id. Response example:

{
    "result": 1, //1 = SUCCESS,  ERROR has error-specific messege
    "messages": "OK"
}

Remote work session

api/workSession/remote endpoint is related to remote user's session in Hyperon Studio.

POST /api/workSession/remote/create/{ttlSeconds}

returns id of newly creates remote session, which ends after given {ttlSeconds}

Local work session

api/workSession/local endpoint is related to default user work session in Hyperon Studio.

POST /api/workSession/local/getOrCreate

returns id of existing or newly created work session. Response example:

{"workSessionId":77700}

Metadata  #

/api/metadata endpoint is related to Hyperon element's metadata.

GET /api/metadata/profiles

returns metadata of all profiles in Hyperon. Response example:

{"profiles":["ACME","TEST"]}

GET /api/metadata/regions

returns metadata of all regions in Hyperon. Response example:

{
  "regions":[
    {
    "id":100,
    "code":"TEST_REGION",
    "profile":"TEST",
    "versions":[{"id":100,"code":"1"}],
    "activeVersion":"1"
    }
  ]
}

GET /api/metadata/functions

returns metadata of all functions in Hyperon. Response example:

{
  "functions":[
    {
    "id":100,
    "code":"fun.test",
    "type":"GROOVY",
    "regionId":100,
    "version":"1",
    "checksum":"58e5255068f4fd0df38282add1e9f2dbdd1b4b15"
    }
  ]
}

GET /api/metadata/all

returns metadata of all profiles/regions/functions in Hyperon.

Parameter  #

api/parameter endpoint is related to Hyperon parameters.

GET /api/parameter/addParameterToWorkSession/{paramCode}

adds parameter with code {paramCode} to session and returns its id

POST /api/parameter/metadata

returns parameter's metadata. Request example:

{
  "parameterIdentifier": {
    "code":"test",
    "version":{
        "profile":"TEST",
        "region":"TEST_REGION",
        "version":"1"
    }
  },
  "sid":123
}

Response example:

{
  "overallStatus": "OK",
  "parameterDto": {
    "id": 123,
    "code": "param.metadata.test",
    "nullable": false,
    "cacheable": true,
    "archive": false,
    "lastUpdate": "2017-01-23",
    "head": true,
    "sessionId": 12345,
    "distinct": false,
    "slave": false,
    "label": "<no label>",
    "regionCode": "TEST_REGION",
    "regionVersionNumber": "1",
    "outputLevels": [{
            "code": "out_level",
            "label": "tmp output level",
            "type": "number",
            "array": false,
            "external": false
        }
    ],
    "inputLevels": [{
            "code": "in_level",
            "label": "tmp in level",
            "type": "string",
            "matcher": null,
            "levelCreator": null,
            "property": "risk.code",
            "source": "risk.code",
            "union": false
        }
    ],
    "categories": ["TEST"]
  }
}

Parameter Entry #

api/parameter/entry endpoint is related to parameter's matrix operation.

POST /api/parameter/entry/insert

adds given values to matrix. Returns parameter id and ids of new entries. Request example:

{
  "parameterIdentifier": {
    "code":"test",
    "version":{
        "profile":"TEST",
        "region":"TEST_REGION",
        "version":"1"
    }
  },
  "sid":123,
  "entries":[["val1", "val2"], ["val3", "val4"]]
}

Response example:

{
  "parameterId":123,
  "entriesIds":[1,2]
}

POST /api/parameter/entry/append

finds in matrix entries beginning with {key} value and adds entries (concatenated {key} with {values}). Returns parameter id and ids of new entries. Request example:

{
  "parameterIdentifier": {
    "code":"test",
    "version":{
        "profile":"TEST",
        "region":"TEST_REGION",
        "version":"1"
    }
  },
  "sid":123,
  "key":["test1"]
  "values":[["val1", "val2"], ["val3", "val4"]]
}

Response example:

{
  "parameterId":123,
  "entriesIds":[1,2]
}

PUT /api/parameter/entry/update

Finds in matrix entries beginning with {key} value and updates them with {values}. Returns parameter id and ids of new entries. Request example:

{
  "parameterIdentifier": {
    "code":"test",
    "version":{
        "profile":"TEST",
        "region":"TEST_REGION",
        "version":"1"
    }
  },
  "sid":123,
  "key":["test1"]
  "values":[["val1", "val2"], ["val3", "val4"]]
}

Response example:

{
  "parameterId":123,
  "entriesIds":[1,2]
}

POST /api/parameter/entry/truncate

Removes all entries from given parameter. Returns parameter id and ids of removed entries. Request example:

{
  "parameterIdentifier": {
    "code":"test",
    "version":{
        "profile":"TEST",
        "region":"TEST_REGION",
        "version":"1"
    }
  },
  "sid":123
}

Response example:

{
  "parameterId":123,
  "entriesIds":[1,2]
}

POST /api/parameter/entry/delete

Finds in matrix entries beginning with {key} and removes them. Returns parameter id and ids of removed entries. Request example:

{
  "parameterIdentifier": {
    "code":"test",
    "version":{
        "profile":"TEST",
        "region":"TEST_REGION",
        "version":"1"
    }
  },
  "sid":123,
  "key":["test1"]
}

Response example:

{
  "parameterId":123,
  "entriesIds":[1,2]
}

Superpack #

api/superpack endpoint is related to Hyperon superpack export/import actions.

POST /api/superpack/upload

Imports given superpack zip file. Input parameters:

file={fileName}.zip - superpack zip file

Request example:

curl -v -X POST -F file=@superpack.zip --user userName:userPasswd http://<Hyperon_url>/api/superpack/upload

Returns 200 HTTP code if import was successful, 500 HTTP code otherwise

POST /api/superpack/download

Exports superpack based on xml template passed as parameter. Input parameters:

file={superpack.template}.xml

Request example:

curl -v -X POST -F file=@pack-template.xml -o mysuperpack.zip --user userName:userPasswd http://<Hyperon_url>/api/superpack/download

Returns 200 HTTP code if import was successful, 500 HTTP code otherwise

Snapshot #

api/snapshot endpoint is related to Hyperon snapshot export/import actions.

POST /api/snapshot/import

Consumes: multipart/form-data

Input parameters:

Imports given snapshot zip file. Returns 200 HTTP code if import was successful, 500 HTTP code otherwise. Response example:

{
    "message": "everything ok",
    "importStatus": "OK",
    "jobResults":{
        "param": {...},
        "function": {...}
        ...
    }
}

POST /api/snapshot/export

produces: application/zip

Input parameters:

Exports snapshot with given configuration. Request body is optional. If request body is empty, then export will try to fetch active profile from given user or all profiles in the system, if user has no active profile. Request example:

{
   "profiles":["PROFILE_1"],   // which profiles should be used for export. If not present, user's currently selected profile is chosen
   "domain": {                 // if this node is present, domain will be exported for "PROFILE_1"
        "fromSession" : false  // it will export full domain tree
   },
   "functions": {              // if this node is present, functions will be exported for "PROFILE_1" 
        "fromSession": true,   // it will export only functions from user's session, which also starts with either "demo." or "test2" prefix
        "removeElementsNotInSnapshot": false // if false nothing happens during snapshot import
        "nameStartsWith": ["demo.", "test2"]
   },
   "parameters": {             // if this node is present, parameters will be exported for "PROFILE_1" 
        "fromSession": false,  // it will export all parameters, which starts with "demo.motor.coverage"
        "removeElementsNotInSnapshot": true //  if true, it will remove all parameters, where snapshot will be imported, that are within boundary defined by "nameStartsWith" and are not in imported snapshot zip.
        "nameStartsWith": ["demo.motor.coverage"]
   },
   "tags": false,              // tags will not be exported. Since it is "false", this node can be removed
   "profile": true             // "PROFILE_1" definition will be exported with context, regions/versions and harmonogram
}