KalimaCTL - Command-Line Tool
weight: 190 linkTitle: “Kalima Ctl”
This document explains how to use KalimaCTL, presents the different commands available in KalimaCTL and describes the expected results.
Start-up
KalimaCTL is a Kalima client node, it must be launched with a : The path of its config file.
Exemple : java -jar bin/KalimaCTL.jar etc/cfg/node.config
Commande help
The help command allows to get the list of available commands, as well as a small documentation on each command. KalimaCTL will actually read the text files in the man folder.
If you simply type help, you get a list of available commands. The -c parameter allows you to get the documentation on a specific command (ex : help -c get caches).
KalimaCTL# help
KalimaCTL
Available commands :
get caches Get the cache list.
get Get one or all records of a cache path
put Add or edit records
delete Delete a record, or delete all records in a cache paths
get perm Get one or all permissions
add perm Add new permission (Kalima_Permission + Kalima_Group)
delete perm Delete one or all permissions
get auth Get one or all auths
add auth Add new auths (Kalima_Auth)
delete auth Delete one or all auths
get stock Get one or all devices in stock
add stock Add new device in stock (Kalima_Device_Stock)
delete stock Delete one or all devices in stock
help Display this help menu or help -c \ for command details (ex: help -c get caches)
clear Clear the screen
exit Close KalimaCTL
KalimaCTL# help -c get caches
GET CACHES
NAME
get caches - Get one or all records of a cache path.
DESCRIPTION
Get the cache list.
You can change the display with -three or -list flags.
By default, the cache list is displayed as a one line string, with all caches separated by a “,”.
OPTIONS
-three
Print cache list as three. It’s the more readable way.
-list
Print cache list with one line / caches.
Commande get caches
The get caches command will display the list of available caches. This will display the caches present in the java node, which means that if you don’t authorise your node on all the caches on the blockchain, you won’t see the full list that actually exists on the blockchain, but only those on which your node is authorised.
By default, the display is on one line, with a comma as a separator between each cache:
KalimaCTL# get caches
/Morigny/users_hdr,/Morigny/things_hdr,/versions_hdr,/Grigny/zones_val,/Epinay/auths_json,/StAubin/dp/dp/StAubin/alarms_val …
It can also be displayed as a list via the flag -list :
KalimaCTL# get caches -list
/Morigny/users_hdr
/Morigny/things_hdr
/versions_hdr
/Grigny/zones_val
/Epinay/auths_json
/StAubin/dp/dp/StAubin/alarms_val
/StAubin/dp/data_val
/Aubervilliers/Plan/drawings
/Essonnes/alarms_fmt
/StAubin/users_fmt
/Grigny/Plan/drawings_fmt
/StAubin/auths_val
/Morigny/Schema/drawings_fmt
…
Or in a more readable ’three’ form, via la flag -three :
KalimaCTL# get caches -three
—-/Aubervilliers weight: 190 linkTitle: “Kalima Ctl”
|—-/Plan
| |—-/drawings
| |—-/layers
|—-/Schema
| |—-/drawings
| |—-/layers
|—-/alarms
|—-/auths
|—-/devices
|—-/things
|—-/users
|—-/zones
—-/Chartreux weight: 190 linkTitle: “Kalima Ctl”
|—-/Plan
| |—-/drawings
| |—-/layers
|—-/Schema
| |—-/drawings
| |—-/layers
|—-/alarms
|—-/auths
|—-/devices
|—-/things
|—-/users
|—-/zones
—-/Epinay weight: 190 linkTitle: “Kalima Ctl”
|—-/Plan
| |—-/drawings
| |—-/layers
|—-/Schema
| |—-/drawings
| |—-/layers
|—-/alarms
|—-/auths
|—-/devices
|—-/things
|—-/users
|—-/zones
…
Commande get
The get command allows you to read the contents of a cache path, or a specific record in a cache path.
The -cachePath parameter must be specified:
KalimaCTL# get -cachePath /Essonnes/zones
key=Ground_Floor body=7B226964223A2247726F756E645F466C6F6F72222C226973416374697665223A747275652C22637265617465644279223A22222C22757064617465644279223A22222C226E616D65223A2247726F756E6420666C6F6F72222C226E6F56657273696F6E223A22222C226465736372697074696F6E223A22222C2270726F7073223A7B7D2C2274797065223A22222C22737461747573223A22222C22736974654964223A224573736F6E6E6573222C22706172656E745A6F6E654964223A22222C227468756D626E61696C55726C223A2268747470733A2F2F66696C652E7365727665722E6B616C696D6164622E636F6D2F4573736F6E6E65732F47726F756E645F466C6F6F722F222C22677261706869634964223A22222C226C6576656C4C697374223A5B5D2C227A6F6E65496473223A5B5D2C227468696E6773496473223A5B5D2C226C6F636174696F6E4964223A22222C2278223A302E302C2279223A302E302C227A223A302E302C2264697374616E6365223A302E302C22616C61726D416374697665223A747275652C227374617465223A22227D
key=Underfloor_1 body=7B22736974654964223A224573736F6E6E6573222C22706172656E745A6F6E654964223A22222C227468756D626E61696C55726C223A22222C22677261706869634964223A22222C226C6576656C4C697374223A5B5D2C227A6F6E65496473223A5B5D2C227468696E6773496473223A5B5D2C226C6F636174696F6E4964223A22222C2278223A302C2279223A302C227A223A302C2264697374616E6365223A302C22616C61726D416374697665223A747275652C227374617465223A22222C226964223A22556E646572666C6F6F725F31222C226973416374697665223A747275652C2263726561746564223A22222C22637265617465644279223A22222C2275706461746564223A22222C22757064617465644279223A22222C226E616D65223A22556E646572666C6F6F722031222C226E6F56657273696F6E223A22222C226465736372697074696F6E223A22222C2270726F7073223A7B7D2C2274797065223A22222C22737461747573223A22227D
You can display only a particular record by specifying the -key :
KalimaCTL# get -cachePath /Essonnes/zones -key Ground_Floor
key=Ground_Floor body=7B226964223A2247726F756E645F466C6F6F72222C226973416374697665223A747275652C22637265617465644279223A22222C22757064617465644279223A22222C226E616D65223A2247726F756E6420666C6F6F72222C226E6F56657273696F6E223A22222C226465736372697074696F6E223A22222C2270726F7073223A7B7D2C2274797065223A22222C22737461747573223A22222C22736974654964223A224573736F6E6E6573222C22706172656E745A6F6E654964223A22222C227468756D626E61696C55726C223A2268747470733A2F2F66696C652E7365727665722E6B616C696D6164622E636F6D2F4573736F6E6E65732F47726F756E645F466C6F6F722F222C22677261706869634964223A22222C226C6576656C4C697374223A5B5D2C227A6F6E65496473223A5B5D2C227468696E6773496473223A5B5D2C226C6F636174696F6E4964223A22222C2278223A302E302C2279223A302E302C227A223A302E302C2264697374616E6365223A302E302C22616C61726D416374697665223A747275652C227374617465223A22227D
The content of the transaction (body) will be displayed as a sequence of hexadecimal characters by default. However, it is possible to convert the content to String (ASCII) via the -string flag:
KalimaCTL# get -cachePath /Essonnes/zones -key Ground_Floor -string
key=Ground_Floor body={“id”:“Ground_Floor”,“isActive”:true,“createdBy”:"",“updatedBy”:"",“name”:“Ground floor”,“noVersion”:"",“description”:"",“props”:{},“type”:"",“status”:"",“siteId”:“Essonnes”,“parentZoneId”:"",“thumbnailUrl”:“https://file.server.kalimadb.com/Essonnes/Ground_Floor/","graphicId":"","levelList":[],“zoneIds”:[],“thingsIds”:[],“locationId”:”",“x”:0.0,“y”:0.0,“z”:0.0,“distance”:0.0,“alarmActive”:true,“state”:""}
If the record contains a JSON, as is the case in our example, it can be displayed in a more readable way via the -json flag:
KalimaCTL# get -cachePath /Essonnes/zones -key Ground_Floor -json
key=Ground_Floor body=
********************
{
“id”: “Ground_Floor”,
“isActive”: true,
“createdBy”: “”,
“updatedBy”: “”,
“name”: “Ground floor”,
“noVersion”: “”,
“description”: “”,
“props”: {},
“type”: “”,
“status”: “”,
“siteId”: “Essonnes”,
“parentZoneId”: “”,
“thumbnailUrl”: “https://file.server.kalimadb.com/Essonnes/Ground_Floor/",
“graphicId”: “”,
“levelList”: [],
“zoneIds”: [],
“thingsIds”: [],
“locationId”: “”,
“x”: 0.0,
“y”: 0.0,
“z”: 0.0,
“distance”: 0.0,
“alarmActive”: true,
“state”: "”
}
********************
Commande put
The put command is used to create new transactions on the blockchain to add or edit a record.
The parameters -cachePath, -key and -body are mandatory:
- cachePath allows you to choose the cache you want to write to
- key allows you to choose the key of the record
- body the content of your record
You can also choose the ttl (Time To Live) via the -ttl parameter:
KalimaCTL# put -cachePath /Essonnes/users -key test -body hello world ! -ttl 5
If there is a problem, an error message will be displayed after the order.
Commande delete
The delete command deletes all records in a cache, or a particular record.
The -cachePath parameter is mandatory. If this is the only parameter set, then the entire cache will be deleted, but a confirmation will be requested as a precaution:
KalimaCTL# delete -cachePath /Essonnes/users
Do you want delete all records in /Essonnes/users? (Y / n): Y
To delete a single record, simply specify the -key parameter:
delete -cachePath /Essonnes/users -key test
Commande get perm
The get perm command reads the current permissions. It works in the same way as the get command, except that the -cachePath parameter is not required:
KalimaCTL# get perm -json
key=admin body=
********************
{
“permissions”: {
“0”: “/”,
“1”: “/”
},
“id”: “admin”,
“isActive”: false,
“name”: “admin”,
“description”: ""
}
********************
key=louis body=
********************
{
“permissions”: {
“0”: “/Essonnes/devices”,
“1”: “/Essonnes/devices”
},
“id”: “louis”,
“isActive”: false,
“name”: “louis”,
“description”: ""
}
********************
Or :
KalimaCTL# get perm -string -key admin
key=admin body={“permissions”:{“0”:"/",“1”:"/"},“id”:“admin”,“isActive”:false,“name”:“admin”,“description”:""}
Commande add perm
The add perm command adds a permission.
A permission contains the list of caches allowed in SUBSCRIBE (read) and PUBLISH (read + write).
It is mandatory to specify the -key parameter as well as the -pub and/or -sub parameter:
- key: The key of the permission
- sub: The list of caches allowed in SUBSCRIBE. You can define a list of permissions (separating each cache by a comma). Moreover, it is not obligatory to put the name of the caches in full. Indeed, if you authorize on /Company, the authorization will be effective on all the caches inside /Company (/Company/devices, /Company/things, etc). The authorization on “/” therefore corresponds to all path caches.
- pub: The list of caches allowed in PUBLISH. If a cache is authorised in PUBLISH, it will also be authorised in SUBSCRIBE. It is therefore not necessary to specify it again in -sub.
We can also add a description to our permission, to make it easier to find later, via the optional parameter -description :
KalimaCTL# add perm -pub /Essonnes,/Morigny/devices -sub /versions -key test -description Test d’ajout d’une permission
This is the content of the permission that has been added é :
KalimaCTL# get perm -key test -json
key=test body=
********************
{
“permissions”: {
“0”: “/Essonnes,/Morigny/devices,/versions”,
“1”: “/Essonnes,/Morigny/devices”
},
“id”: “test”,
“isActive”: false,
“name”: “test”,
“description”: “Test d\u0027ajout d\u0027une permission”
}
********************
Commande delete perm
The delete perm command is used to delete a permission. It works like the delete command, but without the -cachePath parameter:
KalimaCTL# delete perm -key test
KalimaCTL# delete perm
Do you want delete all permissions ? (Y / n): n
delete cancelled
Commande get auth
The get auth command works like the get perm command, but displays permissions instead of permissions. An auth points to one or more permissions:
KalimaCTL# get auth -string
key=admin body={“groupIds”:[“admin”],“id”:“admin”,“isActive”:false,“name”:“admin”,“description”:""}
key=all_sites body={“groupIds”:[“staubin”,“saclay”],“id”:“all_sites”,“isActive”:false,“name”:“all_sites”,“description”:""}
key=louis body={“groupIds”:[“louis”],“id”:“louis”,“isActive”:false,“name”:“louis”,“description”:""}
key=morigny body={“groupIds”:[“Morigny”],“id”:“morigny”,“isActive”:false,“name”:“morigny”,“description”:""}
key=saclay body={“groupIds”:[“saclay”],“id”:“saclay”,“isActive”:false,“name”:“saclay”,“description”:""}
key=staubin body={“groupIds”:[“staubin”],“id”:“staubin”,“isActive”:false,“name”:“staubin”,“description”:""}
Commande add auth
The add auth command is used to add a permission.
It is necessary to specify the -perms parameter which allows you to define the key of each permission to which this authorization will point.
For example, let’s imagine a monitoring application with several sites (StAubin, Saclay, Morigny). For example, we can imagine a permission for each of the sites (/StAubin in PUBLISH for example), and then create a permission for each of these sites, and a more global permission, allowing us to be authorised on each site at the same time.
For this example, we will create our 3 permissions:
KalimaCTL# add perm -key staubin -pub /StAubin
KalimaCTL# add perm -key saclay -pub /Saclay
KalimaCTL# add perm -key morigny -pub /Morigny
Then our four authorisations:
KalimaCTL# add auth -key staubin -perms staubin
KalimaCTL# add auth -key saclay -perms saclay
KalimaCTL# add auth -key morigny -perms morigny
KalimaCTL# add auth -key all_sites -perms staubin,saclay,morigny
Commande delete auth
The delete auth command is used to delete an authorization and works in the same way as the delete perm command:
KalimaCTL# delete auth -key all_sites
Commande get stock
The get stock command allows you to see temporarily authorized devices (in the /Kalima_Device_Stock cache), and works like the other get commands:
KalimaCTL# get stock -json
key=test body=
********************
{
“x”: 0.0,
“y”: 0.0,
“z”: 0.0,
“productSerial”: “test”,
“authId”: “admin”,
“id”: “test”,
“isActive”: false,
“name”: “test”,
“description”: ""
}
********************
Commande add stock
The add stock command allows you to temporarily authorise a device on certain cache paths. Two parameters are mandatory:
-serial_id: The serialId of the device, which will allow it to authenticate itself on its first connection -auth: The id of the corresponding authorization
We can also add a description via the -description parameter. Transactions will be carried out with a ttl of 300, so the authorisations will no longer be valid after 5 minutes.
add stock -serial_id test -auth admin -description noeud admin pour kalima explorer
Commande delete stock
The delete stock command deletes a device from the list of temporary authorisations (or any devices if the serial id is not specified). It works like the other delete commands:
delete stock -serial_id test
Commande clear
The clear command clears the contents of the console, which can be useful for readability purposes.
Commande exit
The exit command closes KalimaCTL