Datasource

The datasource API provides the ability to create, alter, delete and read a relational, file-delimited, MS Excel (non ODBC) or MS Excel datasources in the non-published area and virtual (published) databases. The following operations can be performed:

GET/datasource

PUT/datasource

POST/datasource

DELETE/datasource

GET/datasource/adapter/definitions

GET/datasource/virtual

PUT/datasource/virtual

POST/datasource/virtual

DELETE/datasource/virtual

DELETE/datasource/virtual/dsName

GET/datasource/virtual/adapter/definitions

GET/datasource

This API is used to get datasource summary and/or detailed information.

Parameters:

Name

Description

Parameter Type

Data Type

path

datasource path

query

string

summary

fetch datasource summary

query

boolean

Example to get datasource summary "/shared/examples/ds1"

curl -X GET -u admin:admin "http://localhost:9400/rest/datasource/v1?path=%2Fshared%2Fexamples%2Fds_orders&summary=true" -H "Content-Type:application/json"

Example to get detailed information of datasource "/shared/examples/ds1"

curl -X GET -u admin:admin "http://localhost:9400/rest/datasource/v1?path=%2Fshared%2Fexamples%2Fds_orders" -H "Content-Type:application/json"

PUT/datasource

This API is used to update datasources.

Parameters:

None.

Request Body

Example Value - Schema

[
{
"parentPath": "string",
"name": "string",
"adapterName": "string",
"nativeProperties": {
"additionalProp1": {},
"additionalProp2": {},
"additionalProp3": {}
},
"annotation": "string",
"newPath": "string",
"newName": "string",
"ifNotExists": true
}
]

Example to rename and Relocate a relational datasource

curl -X PUT -u admin:admin "http://localhost:9400/rest/datasource/v1" -H "Content-Type:application/json" -d "[{\"parentPath\":\"/shared\",  \"name\":\"ds1\", \"adapterName\":\"PostgreSQL 9.1\", \"newPath\":\"/shared/examples/dsnew\"  }]" 

Example to update annotation and database name of a relational datasource "/shared/examples/ds1"

curl -X PUT -u admin:admin "http://localhost:9400/rest/datasource/v1" -H "Content-Type:application/json" -d "[{\"parentPath\":\"/shared/examples\",  \"name\":\"ds1\", \"adapterName\":\"PostgreSQL 9.1\", \"annotation\":\"Edited annotation of a postgres datasource created using REST api\", \"nativeProperties\":{\"urlDatabaseName\":\"inventory\"} }]" 

Example to update annotation and delimiter of a file-delimited datasource "/shared/examples/csv_ds"

Sample CURL Invocation of a file-delimited datasource :

curl -X PUT -u admin:admin "http://localhost:9400/rest/datasource/v1" -H "Content-Type:application/json" -d "[{\"parentPath\":\"/shared/examples\",  \"name\":\"csv_ds\", \"adapterName\":\"File-Delimited\", \"annotation\":\"Edited annotation of a csv datasource created using REST api\", \"nativeProperties\":{\"delimiter\":\":\"} }]" 

Example to update annotation and data range of a MS excel (non-ODBC) datasource "/shared/examples/excel_ds"

Sample CURL Invocation of a MS excel (non-ODBC) datasource :

curl -X PUT -u admin:admin "http://localhost:9400/rest/datasource/v1" -H "Content-Type:application/json" -d "[{\"parentPath\":\"/shared/examples\",  \"name\":\"excel_ds\", \"adapterName\":\"Microsoft Excel (non-ODBC)\", \"annotation\":\"Edited annotation of a MS excel datasource created using REST api\", \"nativeProperties\":{\"dataRange\":\"A2\"} }]" 

Example to update annotation and dsn of a MS excel (ODBC) datasource "/shared/examples/excel_ds"

Sample CURL Invocation of a MS excel (ODBC) datasource :

curl -X PUT -u admin:admin "http://localhost:9400/rest/datasource/v1" -H "Content-Type:application/json" -d "[{\"parentPath\":\"/shared/examples\",  \"name\":\"excel_ds\", \"adapterName\":\"Microsoft Excel\", \"annotation\":\"Edited annotation of a MS excel datasource created using REST api\", \"nativeProperties\":{\"dsn\":\"excelodbc1\"} }]" 

api\", \"nativeProperties\":{\"dataRange\":\"A2\"} }]"

Example to Unset annotation of a relational datasource "/shared/examples/ds1"

curl -X PUT -u admin:admin "http://localhost:9400/rest/datasource/v1" -H "Content-Type:application/json" -d "[{\"parentPath\":\"/shared/examples\",  \"name\":\"ds1\", \"adapterName\":\"PostgreSQL 9.1\", \"annotation\":\"null\"}]" 

POST/datasource

This API is used to creates datasources for specified database adapter, path and properties

Parameters:

None.

Request Body

Example Value - Schema

[
{
"parentPath": "string",
"name": "string",
"adapterName": "string",
"nativeProperties": {
"additionalProp1": {},
"additionalProp2": {},
"additionalProp3": {}
},
"annotation": "string",
"newPath": "string",
"newName": "string",
"ifNotExists": true
}
]

Example to create relational datasource "/shared/examples/ds1"

Sample CURL Invocation

curl -X POST -u admin:admin "http://localhost:9400/rest/datasource/v1" -H "Content-Type:application/json" -d "[{\"parentPath\":\"/shared/examples\",  \"name\":\"ds1\", \"adapterName\":\"PostgreSQL 9.1\", \"annotation\":\"This is a postgres datasource created using REST api\", \"nativeProperties\":{\"urlIP\":\"localhost\", \"urlPort\":5432, \"urlDatabaseName\":\"orders\", \"login\":\"tutorial\", \"password\":\"password\"} }]" 

Example to create file-delimited datasource "/shared/examples/csv_ds"

Sample CURL Invocation

curl -X POST -u admin:admin "http://localhost:9400/rest/datasource/v1" -H "Content-Type:application/json" -d "[{\"parentPath\":\"/shared/examples\",  \"name\":\"csv_ds\", \"adapterName\":\"File-Delimited\", \"annotation\":\"This is a csv datasource created using REST api\", \"nativeProperties\":{\"root\":\"/Users/Shared\", \"filters\":\"*.csv\", \"charset\":\"utf-8\"} }]" 

Example to Creates MS excel (non-ODBC) datasource "/shared/examples/excel_ds"

curl -X POST -u admin:admin "http://localhost:9400/rest/datasource/v1" -H "Content-Type:application/json" -d "[{\"parentPath\":\"/shared/examples\",  \"name\":\"excel_ds\", \"adapterName\":\"Microsoft Excel (non-ODBC)\", \"annotation\":\"This is a Microsoft excel datasource created using REST api\", \"nativeProperties\":{\"root\":\"/Users/Shared\", \"filters\":\"*.xls\", \"charset\":\"utf-8\"} }]" 

Example to Creates MS excel (ODBC) datasource "/shared/examples/excel_ds"

Sample CURL Invocation of a MS excel (non-ODBC) datasource :

curl -X POST -u admin:admin "http://localhost:9400/rest/datasource/v1" -H "Content-Type:application/json" -d "[{\"parentPath\":\"/shared/examples\",  \"name\":\"excel_ds\", \"adapterName\":\"Microsoft Excel\", \"annotation\":\"This is a Microsoft excel datasource created using REST api\", \"nativeProperties\":{\"dsn\":\"excelodbc\", \"charset\":\"utf-8\"} }]" 

DELETE/datasource

This API is used to delete datasources.

Parameters:

None

Request Body

Example Value - Schema

[
"string"
]

Example to Delete datasource "/shared/examples/ds1"

curl -X DELETE -u admin:admin "http://localhost:9400/rest/datasource/v1" -H "Content-Type:application/json" -d "[\"/shared/examples/ds1\"]"

GET/datasource/adapter/definitions

This API is used to get datasource attribute definitions. Schema of returned result is [ADAPTER_NAME, ADAPTER_TYPE, ADAPTER_TYPE_CATEGORY, DEFINITION_NAME, DISPLAY_NAME, DEFINITION_TYPE, REQUIRED, DEFAULT_VALUE, ALLOWED_VALUES, EDITOR_HINT, IS_ADVANCED,DISPLAY_PARENT_NAME, DEPENDENCY_EXPRESSION, UPDATE_RULE, ANNOTATION, DEFINITION_PARENT_NAME]

Parameters:

Name

Description

Parameter Type

Data Type

adapterName

Name of the adapter

query

string

Example to Get datasource attribute defs for "PostgreSQL 9.1"

Sample CURL Invocation

curl -X GET -u admin:admin "http://localhost:9400/rest/datasource/v1/adapter/definitions?adapterName=PostgreSQL%209.1" -H "Content-Type:application/json"

Example to Get datasource attribute defs for "File-Delimited"

Sample CURL Invocation

curl -X GET -u admin:admin "http://localhost:9400/rest/datasource/v1/adapter/definitions?adapterName=File-Delimited" -H "Content-Type:application/json"

Example to Get datasource attribute defs for "Microsoft Excel (non-ODBC)"

curl -X GET -u admin:admin "http://localhost:9400/rest/datasource/v1/adapter/definitions?adapterName=Microsoft%20Excel%20(non-ODBC)" -H "Content-Type:application/json"

Example to Get datasource attribute defs for "Microsoft Excel"

curl -X GET -u admin:admin "http://localhost:9400/rest/datasource/v1/adapter/definitions?adapterName=Microsoft%20Excel" -H "Content-Type:application/json"

GET/datasource/virtual

This API is used to get virtual database summary and/or detailed information.

Parameters:

Name

Description

Parameter Type

Data Type

name

name of the virtual database

query

string

summary

fetch virtual database summary

query

boolean

Example to Get summary for virtual database "/services/databases/ publishedDB"

curl -X GET -u admin:admin "http://localhost:9400/rest/datasource/v1/virtual?name=publishedDB&summary=true" -H "Content-Type:application/json"

Example to Get detailed information for virtual database "/services/databases/publishedDB"

curl -X GET -u admin:admin "http://localhost:9400/rest/datasource/v1/adapter/definitions?adapterName=File-Delimited" -H "Content-Type:application/json"

Example to Get datasource attribute defs for "Microsoft Excel (non-ODBC)"

curl -X GET -u admin:admin "http://localhost:9400/rest/datasource/v1/adapter/definitions?adapterName=Microsoft%20Excel%20(non-ODBC)" -H "Content-Type:application/json"

Example to Get datasource attribute defs for "Microsoft Excel"

curl -X GET -u admin:admin "http://localhost:9400/rest/datasource/v1/virtual?name=publishedDB" -H "Content-Type:application/json"

PUT/datasource/virtual

This API is used to update virtual datasources.

Parameters:

None.

Request Body

Example Value - Schema

[
{
"parentPath": "string",
"name": "string",
"adapterName": "string",
"nativeProperties": {
"additionalProp1": {},
"additionalProp2": {},
"additionalProp3": {}
},
"annotation": "string",
"newPath": "string",
"newName": "string",
"ifNotExists": true
}
]

Example to Update annotation and rename a published datasource "/services/databases/publishedDB to /services/databases/publishedNew"

curl -X PUT -u admin:admin "http://localhost:9400/rest/datasource/v1/virtual" -H "Content-Type:application/json" -d "[{\"name\":\"publishedDB\", \"annotation\":\"Edited published datasource created using REST api\", \"newName\":\"publishedNew\"  }]" 

Example to Unset annotation of a published datasource "/services/databases/publishedDB"

curl -X PUT -u admin:admin "http://localhost:9400/rest/datasource/v1/virtual" -H "Content-Type:application/json" -d "[{\"name\":\"publishedDB\", \"annotation\":\"null\"}]" 

POST/datasource/virtual

This API is used to create virtual datasources.

Parameters:

None.

Request Body

Example Value - Schema

[
{
"parentPath": "string",
"name": "string",
"adapterName": "string",
"nativeProperties": {
"additionalProp1": {},
"additionalProp2": {},
"additionalProp3": {}
},
"annotation": "string",
"newPath": "string",
"newName": "string",
"ifNotExists": true
}
]

Example to create virtual datasource "/services/databases/publishedDB"

curl -X POST -u admin:admin "http://localhost:9400/rest/datasource/v1/virtual" -H "Content-Type:application/json" -d "[{\"name\":\"ds1\", \"annotation\":\"This is a published datasource created using REST api\" }]" 

Sample CURL Invocation with ifNotExists:

curl -X POST -u admin:admin "http://localhost:9400/rest/datasource/v1/virtual" -H "Content-Type:application/json" -d "[{\"name\":\"ds1\", \"ifNotExists\":true,\"annotation\":\"This is a published datasource created using REST api\" }]" 

DELETE/datasource/virtual

This API is used to delete virtual datasources.

Parameters:

Name

Description

Parameter Type

Data Type

ifExists

Flaf to indicate if datasource exists

query

boolean

Request Body

Example Value - Schema

[
"string"
]

Example to Delete published datasource "/services/databases/publishedDB"

curl -X DELETE -u admin:admin "http://localhost:9400/rest/datasource/v1/virtual" -H "Content-Type:application/json" -d "[\"publishedDB\"]"

Sample CURL Invocation with "ifExists":

curl -X DELETE -u admin:admin "http://localhost:9400/rest/datasource/v1/virtual?ifExists=true" -H "Content-Type:application/json" -d "[\"publishedDB\"]"

DELETE/datasource/virtual/dsName

This API is used to delete virtual database.

Parameters:

Name

Description

Parameter Type

Data Type

dsName

Name of the database

query

string

ifExists

Flag to indicate if database exists

query

boolean

Example to delete virtual database

curl -X DELETE -u admin:admin  "http://localhost:9400/rest/datasource/v1/virtual/{dsName}?ifExists=true"  -H "Content-Type: application/json"

GET/datasource/virtual/adapter/definitions

This API is used to get datasource attribute definitions. Schema of returned result is [ADAPTER_NAME, ADAPTER_TYPE, ADAPTER_TYPE_CATEGORY, DEFINITION_NAME, DISPLAY_NAME, DEFINITION_TYPE, REQUIRED, DEFAULT_VALUE, ALLOWED_VALUES, EDITOR_HINT, IS_ADVANCED,DISPLAY_PARENT_NAME, DEPENDENCY_EXPRESSION, UPDATE_RULE, ANNOTATION, DEFINITION_PARENT_NAME]

Parameters:

None.

Example to get datasource attribute defs

curl -X GET -u admin:admin "http://localhost:9400/rest/datasource/v1/virtual/adapter/definitions" -H "Content-Type:application/json"