Configure using REST services

You can use REST services for communication between components. For example at clean/deploy configuration, the ConfigurationRest service is used to clean/update the configuration for a component.

Datastore REST services

Datastore Client provides RESTful API to allow external systems to send REST calls for various tasks like injecting/extracting data from the database and managing Datastore Runtime components configuration.

The following REST services are available for Datastore Client:

  • InjectRest - used to inject data into Datastore.
  • URL: http://<host>:<port>/dsclient-web/api/v1.0/inject
  • The following operations are supported on this resource:
    • POST /api/v1.0/inject - inject data into Datastore
    • GET /api/v1.0/inject/{taskId} - get the status of the inject operation
  • ExtractRest - used to extract data from Datastore
  • URL: http://<host>:<port>/dsclient-web/api/v1.0/extract
  • The following operations are applicable:
    • POST /api/v1.0/extract - extract the result of a query execution into a data file
    • GET /api/v1.0/extract/{taskId} - get the status of the extract operation
  • ManageConfigurationRest - used to update / clean the configuration for Datastore components
  • URL: http://<host>:<port>/dsclient-web/api/v1.0/configurations/{componentName}
  • The following operations are applicable:
    • PUT - update Datastore component configuration
    • DELETE - clean Datastore component configuration
    • GET - get Datastore component configuration
  • ImportRest - used to import document
  • URL: http://<host>:<port>/dsclient-web/api/v1.0/imports
  • The following resources are applicable:
    • /v1.0/imports - imports a business collection
    • /v1.0/imports/{taskId} - gets the import status

For details about REST services parameters, the Datastore Client RESTfull API documentation can be found at http://<host>:<port>/dsclient-web/apidocs.

All REST services can be tested using Swagger UI at http://<host>:<port>/dsclient-web/apidocs/ui.

Example for InjectRest call

POST request to http://localhost:8080/dsclient-web/api/v1.0/inject with the body:

{

"dataFile": "http://localhost:8080/dsclient-web/storage/ap.IEvent_Trace_S1",

"collectionTypeName": "AUDIT_COLLECTION",

"collectionTypeVersion": "1",

"dsComponentName": "DatastoreRuntime"

}

GET request to http://localhost:8080/dsclient-web/api/v1.0/inject/16953 for the response:

{

"taskId": "16953",

"status": "FINISHED",

"success": true,

"collectionTypeName": "AUDIT_COLLECTION",

"collectionTypeVersion": "1",

"totalTimeMiliSeconds": "595 milliseconds ",

"totalRecordsInjected": "9",

"totalErrors": "0"

}

Example for ExtractRest call

POST request to http://localhost:8080/dsclient-web/api/v1.0/extract with the body:

{

"queryFullName": "./Query Audit"

}

GET request to http://localhost:8080/dsclient-web/api/v1.0/extract/16962 for the response:

{

"taskId": "16962",

"status": "FINISHED",

"success": true,

"file": "/dsclient-web/download/005169635k4mwtwi9v5kjasg2q46r07s4qm61y2",

"totalTimeMiliSeconds": "51 milliseconds ",

"totalErrors": "0",

"totalRecordsExtracted": "708",

"queryName": "./Query Audit"

}

You can find the contents of the file attribute at http://localhost:8080/dsclient-web/download/005169635k4mwtwi9v5kjasg2q46r07s4qm61y2. It can also be sent to other services on the network.

Example for ManageConfigurationRest call

GET request to http://localhost:8080/dsclient-web/api/v1.0/configurations/DatastoreRuntime for the response:

{

"success": true,

"currentVersion": 49

}

Pooling mechanism

{

For example, for Rule Engine Server file processing, you must do a request to http://<host>:<port>/resrv-web/api/v1.0/process. The request format is:

{

"dataFile": "D:/ais-tools/ruleserver-tools/scanFolder/data/data/IEvent1.seq",

"configurationId": "aic2",

"application": "default",

"collectionTypeName": "LOAN",

"collectionTypeVersion": "1"

}

The request is processed and an asynchronous task and saved in the Repository database. The response contains the task identifier and the url used to check the status of the task.Using 315166 as the task identifier, the response is:

{

"taskId": "315166",

"resourceURI": "http://<host>:<port>/resrv-web/api/v1.0/process/315166"

}

The task status can be checked using resourceURI from the response: http://<host>:<port>/resrv-web/api/v1.0/process/315166.

If the task status is IN_PROGRESS, the response is:

{

"taskId": "315166",

"status": "IN_PROGRESS",

"reports": []

}

If the task status is FINISHED, the response is:

{

"taskId": "315166",

"status": "FINISHED",

"success": true,

"reports": [

{

"name": "RuleEngine.log",

"path": "/resrv-web/download/006315174196dvs19ckwwqgql1cjjc0o8znjlvqw",

"type": "DEBUG"

}

],

"collectionVersion": "1",

"reportsGenerated": true,

"outputResults": [

{

"name": "IAS",

"path": "/resrv-web/download/0063151708pvgk7how6iw2ay0k3h9qx1clgbqjaw",

"outputType": "OUTPUT_EVENT",

"propertyFile": null

},

{

"name": "LOCAL",

"path": "/resrv-web/download/006315171ktn9zbog8cufwnr8y6rqlm2rlqilz60",

"outputType": "OUTPUT_EVENT",

"propertyFile": null

},

{

"name": "NULL_FEES",

"path": "/resrv-web/download/006315172hn9j5vil80hpcwbolh9b5ck38aqsl93",

"outputType": "OUTPUT_EVENT",

"propertyFile": null

},

{

"name": "SESSION2",

"path": "/resrv-web/download/006315173nb1vmcnzg1cax3bla15nf3ivohzue42",

"outputType": "OUTPUT_EVENT",

"propertyFile": null

}

],

"inputTraceResult": {

"name": "InputAudit",

"path": "/resrv-web/download/0063151699pqzz07yl790xl2i7316jsrlr1w56h9",

"outputType": "INPUT_AUDIT",

"propertyFile": null

},

"outputTraceResult": {

"name": "OutputAudit",

"path": "/resrv-web/download/0063151682qcy3rteedx1ec0u58krkbvwi03cak6",

"outputType": "OUTPUT_AUDIT",

"propertyFile": null

},

"collectionName": "LOAN"

}

The paths from the response can be used to:

Download the generated files

Send a request to the next component. For example, to inject audit trace files in Datastore Runtime

{

"dataFile": "http://<host>:<port>/resrv- web/download/0063151682qcy3rteedx1ec0u58krkbvwi03cak6",

"collectionTypeName": "AUDIT_COLLECTION",

"collectionTypeVersion": "1",

"dsComponentName": "DatastoreRuntime"

}

Callback URL mechanism

Using the callback URL mechanism,you can set a callback URL in request(responseUri parameter) that is used to send a POST request with the result when the task is finished. The request is:

{

"dataFile": "D:/ais-tools/ruleserver-tools/scanFolder/data/data/IEvent1.seq",

"configurationId": "aic2",

"application": "default",

"collectionTypeName": "LOAN",

"collectionTypeVersion": "1",

"responseUri": "http://<host>:<port>/resrv-web/api/v1.0/processCallbackURL"

}

Rest service response message internationalization

If there is an error for a REST request, the response contains the errorCode parameters, and the message internationalized in the language from the request header. For example:

{

"error": {

"code": "error.inject.dsComponentName.notFound",

"message": {

"lang": "english",

"value": "The component with the name 'DatastoreRuntime' does not exist. ",

"parameters": [

"DatastoreRuntime"

]

}

}

}

After getting this response, you can either use the internationalized message or internationalize the message using errorCode and parameters.

Related Links