Data Sources
You are looking at an older version of the documentation. The latest version is found here.
List of Sources
You can access the list of data sources present in the system by executing the following GET request:
GET http://<datavirtuality-server-address>:8080/rest/api/source
STATUS 200
[
{"Name":"SYS"},
{"Name":"SYSADMIN"},
{"Name":"UTILS"},
{"Name":"SYSLOG"},
{"Name":"views"}
]
Source Content
The content of each source (tables, views, and stored procedures) can be accessed by the following GET request:
GET http://<datavirtuality-server-address>:8080/rest/api/source/{name}
STATUS 200
[
{"Name":"CliTemplates","Type":"Table","Description":null,"SchemaName":"SYSADMIN"},
{"Name":"DVConnectorPropDefaults","Type":"Table","Description":null,"SchemaName":"SYSADMIN"},
{"Name":"dropIndexByName","Type":"Procedure","Description":null,"SchemaName":"SYSADMIN"}
]
If the requested source is missing, status 404 with an explanatory message will be returned. In the following example, the problem is caused by a typo in the schema name:
STATUS 404
{"title":"Something is wrong","description":"Schema 'sysadmind' doesn't exist.","hint":null}
Operations with Sources
Removing Source
A source can be removed using the DELETE method.
DELETE http://<datavirtuality-server-address>:8080/rest/api/source/{source}
STATUS 200
// No content in response
However, if the source is missing, the following message will appear:
DELETE http://<datavirtuality-server-address>:8080/rest/api/source/{source}
STATUS 404
{"title":"Something is wrong","description":"Schema 'doesntexist' doesn't exist.","hint":null}
Adding Source
A new source can be added with the following POST request. Please note that request body should strictly follow the given template.
POST http://<datavirtuality-server-address>:8080/rest/api/source/
Body (application/json):
{
"name":"trackNtrace",
"template":"ws",
"translator":"dhl",
"connectionProps":"",
"modelProps":"",
"translatorProps":"",
"encryptedProperties":""
}
STATUS 200
// No content in response
The encryptedProperties
parameter is available since v2.4.29
Retrieving Table Content
To access the content of a particular table, you can use the following GET request:
GET http://<datavirtuality-server-address>:8080/rest/api/source/{source-name}/{table-name}
STATUS 200
[{"id":2, "Name":"test"}, {"id":3, "Name":"newone"}]
If you want to reduce the amount of data transferred, you might want to use an SQL query endpoint with array=true. It uses 2D array instead of the JSON objects collection (see Example 1 in SQL Queries). If the table is missing, you'll see the following message:
GET http://<datavirtuality-server-address>:8080/rest/api/source/{source-name}/{table-name}
STATUS 404
{"title":"Something is wrong","description":"Table 'doesntexist' doesn't exist.","hint":null}
Calling Stored Procedure
Stored procedures can be invoked from REST API as well. Calling parameters should be provided in the request's body. Stored procedures may return an empty array, an array with a single object, or an array with multiple objects.
POST http://<datavirtuality-server-address>:8080/rest/api/source/{source-name}/{procedure-name}
Body (application/json):
{"param" : "please md5 it"}
// or
[{"param" : "please md5 it"}]
STATUS 200
[{"hash":"4BC3338E788464C21918D09A64AB6212"}]
If the stored procedure is missing, you will see status 404 accompanied by the following message:
POST http://<datavirtuality-server-address>:8080/rest/api/source/{source-name}/{procedure-name}
STATUS 404
{"title":"Something is wrong","description":"Procedure 'doesntexist' doesn't exist.","hint":null}
Calling Stored Procedure in Bulk Mode
There is a way to call a procedure in the bulk mode with one POST request. In this case, the response will contain a result for each set of parameters sent to the stored procedure. These results will then be marked as the original name of the called stored procedure and concatenated with "_index", to separate the results from one call to the stored procedure from the next call. For example, if the procedure has two parameters a and b, the HTTP body could look like this, representing two procedure calls:
POST http://<datavirtuality-server-address>:8080/rest/api/source/{source-name}/{procedure-name}
Body (application/json):
[{"a" : "value_1", "b" : "value_2"}, {"a" : "value_3", "b" : "value_4"}]
STATUS 200
[
{
"test_rest_1": [
{
"r": "result= 1 test"
}
]
},
{
"test_rest_2": [
{
"r": "result= 2 test2"
}
]
}
]
If the stored procedure is missing, you will see status 404 accompanied by the following message:
POST http://<datavirtuality-server-address>:8080/rest/api/source/{source-name}/{procedure-name}
STATUS 404
{"title":"Something is wrong","description":"Procedure 'doesntexist' doesn't exist.","hint":null}