dbm
dbm executes an action to add, modify, or remove tables,
directories, users, groups, companies, and roles in the Insights Platform, and is
the equivalent of <do action_="dbm"/> in the Insights Platform's Macro Language.
Description
The dbm endpoint allows you to edit anything you have permissions to
edit, including tables, directories, users, groups, companies, and roles.
URL
https://[host]/[1010-version]/api/dbm
Method
POST
Parameters
The dbm endpoint takes a single parameter, cmd, which should contain
a list of two items: the name of the dbm transaction to invoke and a dictionary of
parameters. These two items correspond to the trans_ and
data_ attributes in <do action_="dbm"/> in
macro code. For more information, refer to <do action_="dbm"/> in the
1010data Reference Manual.
For example, <do action_="dbm" trans_="x" data_="{y: 'z'}"/> in
macro code corresponds to the following JSON for input into the dbm
endpoint: {"cmd":["x",{"y": "z"}]}
Response
The result is a dictionary containing:
rc- A result code
0if thedbmaction was successful1if there was an error msg- When
rc=1,msgdisplays the error message. value- When
rc=0,valuedisplays any JSON object, depending on the transaction performed incmd.
curl Example
The following example in curl logs into the Insights Platform and returns the names of all the tables in the pub directory.
First, log in with the /!login endpoint and create
the authentication cookie cookie.txt:
$ curl -s -c cookie.txt -d uid=csmith -d pw=XXX
'https://www2.1010data.com/beta-latest/api/!login'
The following JSON response represents the authentication cookie:
{"uid": "csmith", "sid": "1343979483", "epw": "_______ca74fb26da1d29647b5cdc2acfb..."}
Then, input the JSON {"cmd": ["get_names_in_dir", {"path":
"pub"}]} into the /dbm endpoint. This is the
equivalent of the QuickApp code <do action_="dbm"
trans_="get_names_in_dir" data_="{pkg('path';'pub')}"
value_"@tab"/>
$ curl -s -b cookie.txt -H 'Content-type: application/json'
-d '{"cmd": ["get_names_in_dir", {"path": "pub"}]}' 'https://www2.1010data.com/beta-latest/api/dbm:json'
"rc":0 (because the
dbm action was successful), plus "value", which is
this case is a list of table names in the pub directory:{"rc":0,
"value":
[
["dir","dir","dir","dir","dir","dir","dir","dir","dir","dir","dir",
"dir","dir"],
["pub.fin","pub.geo","pub.demo","pub.reg","pub.audit","pub.consumer_data",
"pub.lib","pub.enigma","pub.public_data","pub.signal","pub.doc",
"pub.gui","pub.training_exercise_data"
]
]
}
