Script

The script REST API provides the ability to create, alter, delete, read sql script procedures. The operations that can be performed on the resources are:

GET /script
PUT /script
POST /script
DELETE /script
DELETE /script/{scriptPath}

GET /script

This API is used to get summary of sql script procedure.

Parameters:

Name

Description

Parameter Type

Data Type

path

sql script procedure path

query

string

summary

fetch sql script procedure summary

query

boolean

Example to get summary of sql script procedure "/shared/examples/LookupProduct"

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

Example to Get detailed information about sql script procedure "/shared/examples/LookupProduct"

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

PUT /script

This API is used to Update sql script procedures.

Parameters:

None.

Request Body

Example Value - Schema

[
{
“parentPath”: "string",
“name”: “string”,
“script”: “string”,
“properties”:
{
“additionalProp1”:{},
“additionalProp2”:{},
“additionalProp3”:{}
},
“annotation”: “string”,
“newPath”: “string”,
“ifNotExists”: true
}
]

Example to update script with a modified CTAS and annotation of script "/shared/examples/script1"

curl -X PUT -u admin:admin "http://localhost:9400/rest/script/v1" -H "Content-Type:application/json" -d "[{\"parentPath\":\"/shared/examples\",  \"name\":\"script1\", \"script\":\"PROCEDURE script1() BEGIN CREATE TABLE /shared/examples/ds_inventory/tutorial/sampleTable as select OrderId, ProductID, OrderDate, CustomerContactFirstName, CustomerContactLastName FROM /shared/examples/ViewOrder; END\", \"annotation\":\"Edited annotation of a script created using REST api\" }]"

Example to Update script to unset annotation of script "/shared/examples/script1"

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

POST /script

This API is used to create sql script procedures with specified definition script.

Parameters:

None.

Request Body

Example Value - Schema

[
{
“parentPath”: "string",
“name”: “string”,
“script”: “string”,
“properties”:
{
“additionalProp1”:{},
“additionalProp2”:{},
“additionalProp3”:{}
},
“annotation”: “string”,
“newPath”: “string”,
“ifNotExists”: true
}
]

Example to create script "/shared/examples/script1"

curl -X POST -u admin:admin "http://localhost:9400/rest/script/v1" -H "Content-Type:application/json" -d "[{\"parentPath\":\"/shared/examples\",  \"name\":\"script1\", \"script\":\"PROCEDURE script1() BEGIN CREATE TABLE /shared/examples/ds_inventory/tutorial/sampleTable as select OrderId, ProductID, Discount, OrderDate, CompanyName, CustomerContactFirstName, CustomerContactLastName, CustomerContactPhone FROM /shared/examples/ViewOrder; END\", \"annotation\":\"This script is created using REST api\" }]"

Example to create script "/shared/examples/script1" with "ifNotExists" syntax

curl -X POST -u admin:admin "http://localhost:9400/rest/script/v1" -H "Content-Type:application/json" -d "[{\"parentPath\":\"/shared/examples\",  \"name\":\"script1\", \"ifNotExists\":true, \"script\":\"PROCEDURE script1() BEGIN CREATE TABLE /shared/examples/ds_inventory/tutorial/sampleTable as select OrderId, ProductID, Discount, OrderDate, CompanyName, CustomerContactFirstName, CustomerContactLastName, CustomerContactPhone FROM /shared/examples/ViewOrder; END\", \"annotation\":\"This script is created using REST api\" }]"

DELETE /script

This API is used to delete sql script procedures.

Parameters:

 

Name

Description

Parameter Type

Data Type

ifExists

Flag to indicate if resource exists

query

boolean

Request Body

Example Value - Schema

[
"string"
]

Example to delete script "/shared/examples/script1"

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

Sample CURL Invocation with "ifExists":

curl -X DELETE -u admin:admin "http://localhost:9400/rest/script/v1?ifExists=true" -H "Content-Type:application/json" -d "[\"/shared/examples/script1\"]"

DELETE /script/{scriptPath}

This API is used to Delete sql script procedure given in the script path. Optionally specify "if exists".

Parameters:

 

Name

Description

Parameter Type

Data Type

scriptPath

path of the script

query

string

ifExists

Flaf to indicate if resource exists

query

boolean

Example to delete sql script procedure

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

Sample CURL Invocation with "ifExists":

curl -X DELETE -u admin:admin "http://localhost:9400/rest/script/v1/%2Fshared%2Fexamples%2Fscript1?ifExists=true" -H "Content-Type:application/json"