アプリケーションプログラミングインターフェースガイド> REST API> TDVサーバーREST API> Script API
 
Script(スクリプト)API
スクリプト REST APIは、SQLスクリプトプロシージャを作成、変更、削除、読み取りする機能を提供します。リソースに対して実行できるオペレーションは次のとおりです。
GET /script
PUT /script
POST /script
DELETE /script
DELETE /script/{scriptPath}
GET /script
このAPIは、SQLスクリプトプロシージャの概要を取得するために使用されます。
パラメーター:
名前
説明
パラメータータイプ
データタイプ
path
SQLスクリプトプロシージャパス
query
string
summary
フェッチSQLスクリプトプロシージャの概要
query
boolean
SQLスクリプトプロシージャ「/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"
SQLスクリプトプロシージャ「/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
このAPIは、sqlスクリプトプロシージャを更新するために使用されます。
パラメーター:
なし。
リクエスト本文
値の例-スキーマ
[
{
“parentPath”: "string",
“name”: “string”,
“script”: “string”,
“properties”:
{
“additionalProp1”:{},
“additionalProp2”:{},
“additionalProp3”:{}
},
“annotation”: “string”,
“newPath”: “string”,
“ifNotExists”: true
}
]
変更されたCTASとスクリプト「/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\" }]"
スクリプト "/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
このAPIは、指定された定義スクリプトを使用してSQLスクリプトプロシージャを作成するために使用されます。
パラメーター:
なし。
リクエスト本文
値の例-スキーマ
[
{
“parentPath”: "string",
“name”: “string”,
“script”: “string”,
“properties”:
{
“additionalProp1”:{},
“additionalProp2”:{},
“additionalProp3”:{}
},
“annotation”: “string”,
“newPath”: “string”,
“ifNotExists”: true
}
]
スクリプト「/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\" }]"
「ifNotExists」構文を使用してスクリプト「/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\", \"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\" }]"
/scriptを削除
このAPIは、sqlスクリプトプロシージャを削除するために使用されます。
パラメーター:
 
名前
説明
パラメータータイプ
データタイプ
ifExists
リソースが存在するかどうかを示すフラグ
query
boolean
リクエスト本文
値の例-スキーマ
[
"string"
]
スクリプト「/shared/examples/script1」を削除する例
curl -X DELETE -u admin:admin "http://localhost:9400/rest/script/v1" -H "Content-Type:application/json" -d "[\"/shared/examples/script1\"]"
「ifExists」を使用したサンプルCURL呼び出し:
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}
このAPIは、スクリプトパスで指定されたsqlスクリプトプロシージャを削除するために使用されます。オプションで「存在する場合」を指定します。
パラメーター:
 
名前
説明
パラメータータイプ
データタイプ
scriptPath
スクリプトのパス
query
string
ifExists
リソースが存在するかどうかを示すFlaf
query
boolean
sqlスクリプトプロシージャを削除する例
curl -X DELETE -u admin:admin "http://localhost:9400/rest/script/v1/{scriptPath}?ifExists=true" -H "Content-Type: application/json"
「ifExists」を使用したサンプルCURL呼び出し:
curl -X DELETE -u admin:admin "http://localhost:9400/rest/script/v1/%2Fshared%2Fexamples%2Fscript1?ifExists=true" -H "Content-Type:application/json"