How To Set Up hvrhubserver Using REST API
Create a user/schema/database for Local Data Processing to use as the repository. In this example, the Local Data Processing repository is a PostgreSQL database, so a database called hvhub6 is created in PostgreSQL with OS user jigsaw.
NOTE: The example below is using HTTP port
5540on a hubserver calledmalta.
Download and install Local Data Processing. Learn how in our .
After installation, create
$HVR_CONFIG/etc/hvrhubserver.confon the hubserver, as shown below:{ "HTTP_Port": "5540" }content_copyor
hvrhubserverconfig HTTP_Port=5540to create the above file.Start
hvrhubserveron Linux with the command:hvrhubserver -dor on Windows with the command:
hvrhubserver -acs -P<password of logged-in OS account> or without -P to run as local system account
The above commands will start the hvrhubserver in SETUP mode.
Get Authorization bearer code
You can either use REST or use the command line . If you use hvrlogin, the authentication code can be saved into a reusable environment variable called $HVR_LOGIN_ACCESS_TOKEN.
The REST API to get the authorization token while Local Data Processing 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 hvrhubserver
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}'
content_copyor if using a bash script like below:
#!/bin/bash
R=http://malta:5540
eval $(hvrlogin -s -a -S -R$R)
curl -X PATCH $R/api/v0/hubserver/props \
-H "Authorization: Bearer $HVR_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}'
content_copyCreate Local Data Processing repository
The below command creates the repository tables in the database hvhub6:
curl -X POST "http://malta:5540/api/v0/repos" \
-H "Authorization: Bearer $HVR_LOGIN_ACCESS_TOKEN or <copy Authorization bearer from http://malta:5540/auth/v1/setup call>“
content_copyAdd 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 .
curl -X POST "http://malta:5540/api/v0/licenses" \
-H "Authorization: Bearer $HVR_LOGIN_ACCESS_TOKEN or <copy Authorization bearer from http://malta:5540/auth/v1/setup call>“ \
-H 'Content-Type: application/json' \
--data-binary @<input file>
content_copyAdd user to access the Local Data Processing system
The below example creates a Local Data Processing user called hvradmin (a Local Data Processing application user, not a real OS user, because authentication is local):
curl -X POST "http://malta:5540/api/v0/users"
-H "Authorization: Bearer $HVR_LOGIN_ACCESS_TOKEN or <copy Authorization bearer from http://malta:5540/auth/v1/setup call>“
-H 'Content-Type: application/json'
--data '{"user":"hvradmin","authentication":"local"","password":"mypass"}'
content_copyAuthentication can also be pam instead of local.
Give user SysAdmin privilege
curl -X PATCH "http://malta:5540/api/v0/repos/props" \
-H "Authorization: Bearer $HVR_LOGIN_ACCESS_TOKEN or <copy Authorization bearer from http://malta:5540/auth/v1/setup call>“ \
-H 'Content-Type: application/json' \
--data '{"Access_List":[{"user":"hvradmin","level":"SysAdmin"}]}'
content_copyCreate a hub
The below example creates a hub called hvrhub6:
curl -X POST $R/api/v0/hubs \
-H "Authorization: Bearer $HVR_LOGIN_ACCESS_TOKEN or <copy Authorization bearer from http://malta:5540/auth/v1/setup call>“ \
-H 'Content-Type: application/json' \
--data '{"hub":"hvrhub6"}'
content_copyEnd hvrhubserver’s setup mode
The below example will end the hvrhubserver’s setup mode, so channels can be created on the hub:
curl -X PATCH "http://malta:5540/api/v0/hubserver/props" \
-H "Authorization: Bearer $HVR_LOGIN_ACCESS_TOKEN or <copy Authorization bearer from http://malta:5540/auth/v1/setup call>“ \
-H 'Content-Type: application/json' \
--data '{"Setup_Mode":null}'
content_copyYou can now go to the browser to malta:5540 and log in with user hvradmin to create other users or set up channels, etc.
Comments
0 comments
Please sign in to leave a comment.