How To Set Up dsshubserver Using REST API - DSS 6 | Data Source Solutions Documentation
Documentation: How To Set Up dsshubserver Using REST API - DSS 6 | Data Source Solutions Documentation
How To Set Up dsshubserver Using REST API
Question
How can I set up dsshubserver using the REST API?
Environment
DSS 6
Answer
Create a user/schema/database for DSS to use as the repository. In this example, the DSS repository is a PostgreSQL database, so a database called hvhub6 is created in PostgreSQL with OS user jigsaw.
The example below is using HTTP port 5540 on a hubserver called malta.
-
Download and install DSS. Learn how in our Installing DSS documentation.
-
After installation, create
$DSS_CONFIG/etc/dsshubserver.confon the hubserver, as shown below:{ "HTTP_Port": "5540" }or
dsshubserverconfig HTTP_Port=5540to create the above file. -
Start
dsshubserveron Linux with the command:dsshubserver -dor on Windows with the command:
dsshubserver -acs -P<password of logged-in OS account> or without -P to run as local system account
The above dsshubserver commands will start the dsshubserver in SETUP mode.
Get Authorization bearer code
You can either use REST or use the command line dsslogin. If you use dsslogin, the authentication code can be saved into a reusable environment variable called $DSS_LOGIN_ACCESS_TOKEN.
The REST API to get the authorization token while DSS Hub Server is in setup mode:
curl -X POST "http://malta:5540/auth/v1/setup" -H "Content-Type: application/json"
Set the database details for the dsshubserver
The below example sets the hub database to PostgreSQL with database name hvhub6:
curl -X PATCH "http://malta:5540/api/v0/hubserver/props" \
-H "Authorization: Bearer <copy Authorization bearer from http://malta:5540/auth/v1/setup call>” \
-H 'Content-Type: application/json' \
--data '{"HTTP_Port":"5540","Database_Host":"localhost","Database_Port":5463,"Database_Name":"hvhub6","Database_User":"jigsaw","Database_Password":"passw","Repository_Class":"postgresql","Setup_Mode":true}'
or if using a bash script like below:
#!/bin/bash
R=http://malta:5540
eval $(dsslogin -s -a -S -R$R)
curl -X PATCH $R/api/v0/hubserver/props \
-H "Authorization: Bearer $DSS_LOGIN_ACCESS_TOKEN" \
-H 'Content-Type: application/json' \
--data '{"HTTP_Port":"5540","Database_Host":"localhost","Database_Port":5463,"Database_Name":"hvhub6","Database_User":"jigsaw","Database_Password":"passw","Repository_Class":"postgresql","Setup_Mode":true}'
Create DSS repository
The below command creates the repository tables in the database hvhub6:
curl -X POST "http://malta:5540/api/v0/repos" \
-H "Authorization: Bearer $DSS_LOGIN_ACCESS_TOKEN or <copy Authorization bearer from http://malta:5540/auth/v1/setup call>“
Add license to hub
Create an input file with the following content:
{"license":"<license file name>","raw":"<stringified content of generated license>"}
To stringify the original license file, see https://onlinetexttools.com/json-stringify-text.
curl -X POST "http://malta:5540/api/v0/licenses" \
-H "Authorization: Bearer $DSS_LOGIN_ACCESS_TOKEN or <copy Authorization bearer from http://malta:5540/auth/v1/setup call>“ \
-H 'Content-Type: application/json' \
--data-binary @<input file>
Add user to access the DSS system
The below example creates a DSS user called dssadmin (a DSS application user, not a real OS user, because authentication is local):
curl -X POST "http://malta:5540/api/v0/users"
-H "Authorization: Bearer $DSS_LOGIN_ACCESS_TOKEN or <copy Authorization bearer from http://malta:5540/auth/v1/setup call>“
-H 'Content-Type: application/json'
--data '{"user":"dssadmin","authentication":"local"","password":"mypass"}'
Authentication can also be pam instead of local.
Give user SysAdmin privilege
curl -X PATCH "http://malta:5540/api/v0/repos/props" \
-H "Authorization: Bearer $DSS_LOGIN_ACCESS_TOKEN or <copy Authorization bearer from http://malta:5540/auth/v1/setup call>“ \
-H 'Content-Type: application/json' \
--data '{"Access_List":[{"user":"dssadmin","level":"SysAdmin"}]}'
Since 6.1.5/2, the following should be used:
curl -X PATCH "http://malta:5540/api/v0/repos/props" \
-H "Authorization: Bearer $DSS_LOGIN_ACCESS_TOKEN or <copy Authorization bearer from http://malta:5540/auth/v1/setup call>“ \
-H 'Content-Type: application/json' \
--data '{"User_Access":{"dssadmin":{"sysadmin":true}}}'
Create a hub
The below example creates a hub called dsshub6:
curl -X POST $R/api/v0/hubs \
-H "Authorization: Bearer $DSS_LOGIN_ACCESS_TOKEN or <copy Authorization bearer from http://malta:5540/auth/v1/setup call>“ \
-H 'Content-Type: application/json' \
--data '{"hub":"dsshub6"}'
End dsshubserver’s setup mode
The below example will end the dsshubserver’s setup mode, so channels can be created on the hub:
curl -X PATCH "http://malta:5540/api/v0/hubserver/props" \
-H "Authorization: Bearer $DSS_LOGIN_ACCESS_TOKEN or <copy Authorization bearer from http://malta:5540/auth/v1/setup call>“ \
-H 'Content-Type: application/json' \
--data '{"Setup_Mode":null}'
You can now go to the browser to malta:5540 and log in with user dssadmin to create other users or set up channels, etc.