Database operations are supported via a RESTful HTTP Interface on the Platform.
Temporary files are created on the Platform host when the user executes queries via Reference Data Management. These temporary files, which stored in $MZ_HOME/tmp/rowset
, are removed automatically when the user session expires. Users sessions expire automatically after six (6) hours.
Restful Operations
The tables below describe the various operation that are available for Reference Data Management.
The service endpoint URI is http(s)://<Platform host>:<port>/api/v1.
Basic authentication is used and you must pass user credentials for each RESTful call.
Create and Get Session
Resource path: /session
HTTP method: GET
This operation returns a session id which should be appended to all subsequent API calls where this parameter is applicable.
Example
$ curl -u \ user:passw http://localhost:9000/api/v1/session
Close Session
Resource path: /session/close?sessionid=<sessionid>
HTTP method: GET
This operation closes a session. This session id is no longer valid for any subsequent API calls.
Example - Closing a session
$ curl -u user:passw \ http://localhost:9000/api/v1/session/close?sessionid=vusncl88sjghv7h8nkb0ohja6t
Get Reference Data Profiles
Resource path: /refdatas
HTTP method: GET
This operation retrieves a list of all Reference Data profiles that are available to the user.
Example - Retrieving a list
$ curl -u \ user:passw http://localhost:9000/api/v1/refdatas
Get Metadata
Resource path: /refdatas/<Reference Data profile>/table/<table name>?sessionid=<session id>
HTTP method: GET
This operation retrieves table metadata that can be used for viewing or to derive parameters for other REST APIs. If Last Update feature is enabled, the values stored in the most recent Last Update user and timestamp column will be retrieved as well. The result is returned synchronously.
Example - Get metadata
$ curl -u user:passw \ http://localhost:9000/api/v1/refdatas/Default.refprofile_star/table/APP.STAR?sessionid=vusncl88sjghv7h8nkb0ohja6t
Get Query
Resource path: /refdatas/<Reference Data profile>/table/<table name>/rowset?sessionid=<session id>
HTTP method: PUT
Body: This is where the executeQuery will be included. The executeQuery JSON payload will include these options:
rowsPerPage - the max number of rows(Data Set size) that can be in a
rowset
of the retrieved result.selectedColumns - allows for specific columns to be selected.
filterExpression - allows optional definition of query expressions. The query will match all of the specified query expressions.
This operation executes database queries on specific a Reference Data profile and database table. The query is performed asynchronously and control is returned immediately. You can retrieve the result of the query by using /rowset/<rowset number>?sessionid=<session id>
. This operation requires input parameters that are passed in a JSON format as part of the HTTP message body.
Note!
Any ongoing query process running on the same session will be aborted and a new process for the latest query will be executed.
This operation will clear any uncommitted changes saved in the same session.
Example - Get query without query expression in JSON payload body
$ curl -X PUT -u user:passw -H 'content-type: application/json' \ http://localhost:9000/api/v1/refdatas/Default.refprofile_star/table/APP.STAR/rowset?sessionid=vusncl88sjghv7h8nkb0ohja6t \ -d '{"executeQuery": {"rowsPerPage":500,"selectedColumns":["ID","FIRSTNAME","LASTNAME"]}}'
Example - Get query with query expression in JSON payload body
$ curl -X PUT -u user:passw -H 'content-type: application/json' \ http://localhost:9000/api/v1/refdatas/Default.refprofile_star/table/APP.STAR/rowset?sessionid=vusncl88sjghv7h8nkb0ohja6t \ -d '{"executeQuery": {"rowsPerPage":500,"selectedColumns":["ID","FIRSTNAME","LASTNAME"],"filterExpression":[{"col":"ID","expr":9,"op":">="},{"col":"LAST_NAME","expr":"Smith","op":"not like"}]}}'
Example - Get query using a JSON payload file
$ curl -X PUT -T="example.json" -u user:passw -H 'content-type: application/json' \ 'http://localhost:9000/api/v1/refdatas/Default.refprofile_star/table/APP.STAR/rowset?sessionid=vusncl88sjghv7h8nkb0ohja6t
example.json:
{ "executeQuery": { "rowsPerPage": 500, "selectedColumns": ["ID", "FIRSTNAME", "LASTNAME"] } }
Get Data Sets
Resource path: /rowset/<rowset number>?sessionid=<session id>
HTTP method: GET
Data sets can be retrieved once downloaded to the file system of the Platform. This operation returns a data set for the given rowset (sequence number). The total number of available data sets can be queried with the status
operation.
Example - Get data sets
$ curl -u user:passw \ http://localhost:9000/api/v1/rowset/0?sessionid=vusncl88sjghv7h8nkb0ohja6t
Get Status
Resource path: /status?sessionid=<session id>
HTTP method: GET
This operation returns a status message. It can be used to retrieve active processes and to query the number of available rows, data sets and status of imports and exports. If Last Update feature is enabled, the values stored in the most recent Last Update user and timestamp column will be retrieved as well.
Example - Get status
$ curl -u user:passw \ http://localhost:9000/api/v1/status?sessionid=vusncl88sjghv7h8nkb0ohja6t
Abort process
Resource path: /status/abort?sessionid=<session id>
HTTP method: GET
This operation request the active process to abort.
Note!
To prevent a user from initiating another operation before the first operation initiated is complete, Abort Process
can be used before an operation is complete.
Example - Abort process
$ curl -u user:passw \ http://localhost:9000/api/v1/status/abort?sessionid=vusncl88sjghv7h8nkb0ohja6t
Table Export
Resource path: /refdatas/<Reference Data profile>/table/<table name>/download?sessionid=<sessionid>
HTTP method: POST
Body: This is where the exportParams will be included. The exportParams JSON payload will include these options:
opts
textQualifier - designated as double quotes by default.
separator - designated as a comma by default.
extent - designated as
all
by default.all - export all rows in the table
selected - export rows from the result of
Get Query
selectedColumns - allows for specific columns to be selected.
Note!
For the extend
option, selected
value is only applicable when Get Query
is applied prior Table Export
.
This operation performs a database table export. Input parameters are passed in a JSON format as part of the HTTP message body.
Example - Table export without options
$ curl -X POST \ 'http://localhost:9000/api/v1/refdatas/ref_data_mgmt_oracle.ref_data_mgmt_pf/table/TABLE.CUSTOMERS/download?sessionid=p3hce86dkb4rmls9peh4e8rps9' \ -u "user:passw" \ -d 'exportParams={}' \ > Export.csv
Example - Table export with options
$ curl -X POST \ 'http://localhost:9000/api/v1/refdatas/ref_data_mgmt_oracle.ref_data_mgmt_pf/table/TABLE.CUSTOMERS/download?sessionid=p3hce86dkb4rmls9peh4e8rps9' \ -u "user:passw" \ -d 'exportParams={"opts":{"textQualifier":"'\''","separator":";","extent":"all"},"selectedColumns":["CITY","CUSTOMER_NAME"]}' > Export.csv
Table Import
Resource path: /refdatas/<Reference Data profile>/table/<table name>/upload?sessionid=<sessionid>
HTTP method: POST
Body: This is where the file and the input parameters will be included. The exportParams format will include these optional opts:
textQualifier - designated as double quotes by default.
separator - designated as a comma by default.
opts - designated as
append
by default.append - import rows will be appended to the table
truncate - the existing data in the table will be truncated before the import is executed.
force - designated as
false
by default.
This operation performs a database table import. Input parameters are passed in a JSON format as part of the HTTP message body.
Example - Table import without options
$ curl -i -u "user:passw" \ 'http://localhost:9000/api/v1/refdatas/ref_data_mgmt_oracle.ref_data_mgmt_pf/table/TABLE.CUSTOMERS/upload?sessionid=rssrh20dcd8lc1j505b3bqnstc' \ -F file=@/path/to/import_test.csv
Example - Table import with options
$ curl -i -u "user:passw" \ 'http://localhost:9000/api/v1/refdatas/ref_data_mgmt_oracle.ref_data_mgmt_pf/table/TABLE.CUSTOMERS/upload?sessionid=p3hce86dkb4rmls9peh4e8rps9' \ -F file=@/path/to/import_test.csv \ -F 'opts={"textQualifier":"\'","separator":",","op":"truncate","force":false}'
Save Changes
Resource path: /save?sessionid=<session id>
HTTP method: PUT
This operation saves data grid edit modification (post insert/update/delete). Changes are saved within client session. This operation requires JSON payload as input.
Note!
tableName
and refProfile
are mandatory in order to save. A single table can be modified in a single session only.
Note!
The save operation is supported either on Oracle (based on ROWID pseudo column) or non-Oracle type tables containing Primary Key constraint. Non-Oracle tables without a Primary Key are not supported for data modifications.
Example - Save changes
$ curl -X PUT -T="example.json" \ http://user:passw@localhost:9000/api/v1/save? \ sessionid=vusncl88sjghv7h8nkb0ohja6t
example.json:
{ "dataEdit": { "refProfile": "Default.refTest", "tableName": "MZADMIN.REFRENCE_DATA", "updates": [{ "action": "insert", "values": [{ "column": "ID", "value": 645 }, { "column": "FIRSTNAME", "value": "Roberts" }, { "column": "LASTNAME", "value": "Polis" }] }] } }
Commit Changes
Resource path: /save/commit?force=<true|false>&sessionid=<session id>
HTTP method: GET
This operation applies saved edits in the database and commits the work in case of success. You can use "force" commit in case of errors.
Example - Commit changes
$ curl -u user:passw \ http://localhost:9000/api/v1/commit? \ force=false&sessionid=vusncl88sjghv7h8nkb0ohja6t
List Changes
Resource path: /save/list?sessionid=<session id>
HTTP method: GET
This operation returns a list of the modifications saved. You can use this operation to reapply changes in the Web UI during a grid refresh.
Example - List changes
$ curl -u user:passw \ http://localhost:9000/api/v1/save/list? \sessionid=vusncl88sjghv7h8nkb0ohja6t
Cancel Changes
Resource path: /save/cancel?sessionid=<session id>
HTTP method: PUT
This operation cancels the changes made from being saved. As the input, Json payload specifies either all the changes to be canceled or lists the selected Primary Keys to be cancelled. You can cancel the saving of several changes at the same time (one Primary Key per change). The scope is single or all. The format is the same as for the Save changes operation but the ID fields are stored in a root structure. Ids are in a JSON array to hold multiple Primary Keys to be cancelled.
Note!
The Web UI generates surrogate Primary Keys for inserted rows for the cancel function.
Example - Cancel changes
$ curl -u user:passw \ http://localhost:9000/api/v1/save/cancel? \ sessionid=vusncl88sjghv7h8nkb0ohja6t
example.json:
{ "dataEdit": { "scope": "single", "ids": [{ "id": [{ "column": "ORDER_NUM", "value": 10398005 }] }] } }
Example response:
{ "dataEdit": { "updates": [{ "action": "update", "ids": [{ "column": "ORDER_NUM", "value": 10398005 }], "undoRow": [{ "column": "SHIPPING_DATE", "value": "2011 - 05 - 24 00: 00: 00" }, { "column": "ORDER_NUM", "value": 10398005 }, { "column": "QUANTITY", "value": 100 } ], "values": [{ "column": "FREIGHT_COMPANY", "value": "Zagreb" }], "SaveSize": 3 }] } }
Note!
SaveSize
indicates the number of changes remaining.
Show Demo Query
Resource path: /demo/queryRequestParameters
HTTP method: GET
This operation shows the json payload format that applies for a query operation e g rowset/.
Show Demo Changes
Resource path: /demo/dataEditRequestParameters
HTTP method: GET
This operation shows the json payload format that applies to edit data via the Web UI e g save/commit.
Add Comment