-
Notifications
You must be signed in to change notification settings - Fork 83
RPC
Guy Margalit edited this page Feb 22, 2019
·
11 revisions
NooBaa RPC is basically a simple JSON-in-JSON-out API.
The API's are defined as JSON-schema which are located in the project under src/api/
.
NooBaa RPC supports multiple transports for different internal use cases (tcp, ws, http, udp), but the easiest one to use as a person is HTTP with CURL.
(Note: I'm using jq
to pretty print json. Install it on Mac with brew install jq
)
$ curl http://127.0.0.1:5001/rpc/ -sd '{"api":"system_api","method":"create_system","auth_token":"","params":{ "name":"demo", "email":"[email protected]", "password":"*****", "activation_code":"123" }}' | jq
{
"op": "res",
"reqid": null,
"took": 2017.9986989996396,
"reply": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50X2lkIjoiNWM2ZmFjZjcxYjBlN2U1YmE1Mjg0MjgxIiwic3lzdGVtX2lkIjoiNWM2ZmFjZjcxYjBlN2U1YmE1Mjg0MjgyIiwicm9sZSI6ImFkbWluIiwiaWF0IjoxNTUwODIyNjQ3fQ.v0Yg-6H4nokGCQAeKVmSXnSSMs8PV9ciwUGR--LOe2s"
}
}
$ curl http://127.0.0.1:5001/rpc/ -sd '{"api":"auth_api","method":"read_auth","auth_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50X2lkIjoiNWM2ZmFjZjcxYjBlN2U1YmE1Mjg0MjgxIiwic3lzdGVtX2lkIjoiNWM2ZmFjZjcxYjBlN2U1YmE1Mjg0MjgyIiwicm9sZSI6ImFkbWluIiwiaWF0IjoxNTUwODIyNjQ3fQ.v0Yg-6H4nokGCQAeKVmSXnSSMs8PV9ciwUGR--LOe2s"}' | jq
{
"op": "res",
"reqid": null,
"took": 0.8202969999983907,
"reply": {
"role": "admin",
"account": {
"name": "demo",
"email": "[email protected]"
},
"system": {
"name": "demo"
}
}
}
$ curl http://127.0.0.1:5001/rpc/ -sd '{"api":"system_api","method":"read_system","auth_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50X2lkIjoiNWM2ZmFjZjcxYjBlN2U1YmE1Mjg0MjgxIiwic3lzdGVtX2lkIjoiNWM2ZmFjZjcxYjBlN2U1YmE1Mjg0MjgyIiwicm9sZSI6ImFkbWluIiwiaWF0IjoxNTUwODIyNjQ3fQ.v0Yg-6H4nokGCQAeKVmSXnSSMs8PV9ciwUGR--LOe2s"}' | jq
{
"op": "res",
"reqid": null,
"took": 47.75764900026843,
"reply": {
"name": "demo",
...
...
}
}