Skip to content
Guy Margalit edited this page Feb 23, 2019 · 11 revisions

NooBaa RPC is basically a JSON-in-JSON-out API.

API Schema

The API's are defined as JSON-schema which are located in the project under src/api/.

Transports

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.

CURL Examples:

(Note: I'm using jq to pretty print json. Install it on Mac with brew install jq)

Create System

$ curl http://127.0.0.1:5001/rpc/ -sd '{
  "api": "system_api",
  "method": "create_system",
  "params": {
    "name": "demo",
    "email": "[email protected]",
    "password": XXXXX,
    "activation_code": "123"
  }
}' | jq

{
  "op": "res",
  "reqid": null,
  "took": 2017.9986989996396,
  "reply": {
    "token": XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  }
}

Auth Token

Most of the API's require auth token (JWT token) to authenticate to the API (the first create_system is allowed without a token). You can copy-pasta the token inline for the next API calls, but it would be much easier to save it to a file (or a shell variable if you prefer to leave no traces on the local machine).

Here is an example using create_auth and using jq to extract the token from the reply and save to .nbtoken file:

curl http://127.0.0.1:5001/rpc/ -sd '{
  "api": "auth_api",
  "method": "create_auth",
  "params": {
    "role": "admin",
    "system": "demo",
    "email": "[email protected]",
    "password": XXXXX
  }
}' | jq -r '.reply.token' > .nbtoken

Read System (no params, just auth_token)

$ curl http://127.0.0.1:5001/rpc/ -sd '{
  "api": "auth_api",
  "method": "read_auth",
  "auth_token": "'$(cat .nbtoken)'"
}' | 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": "'$(cat .nbtoken)'"
}' | jq

{
  "op": "res",
  "reqid": null,
  "took": 47.75764900026843,
  "reply": {
    "name": "demo",
    ...
    ...
  }
}

Get node installation string (example with params)

$ curl http://127.0.0.1:5001/rpc/ -sd '{
  "api": "system_api",
  "method": "get_node_installation_string",
  "params": { "exclude_drives": ["C:"] },
  "auth_token": "'$(cat .nbtoken)'"
}' | jq

{
  "op": "res",
  "reqid": null,
  "took": 58.89307500002906,
  "reply": {
    "LINUX": "wget ...",
    "WINDOWS": "Import-Module BitsTransfer ; Start-BitsTransfer ...",
    "KUBERNETES": "apiVersion: apps/v1beta1\nkind: StatefulSet\nmetadata:\n  name: noobaa-agent\n ..."
  }
}
Clone this wiki locally