Table of Contents |
---|
Related Documentation
- We can also manage this information using the Admin GUI.
- opCharts API for reading node data opCore API V2
Nodes API
We can also manage nodes using the API.
Operation | Method | URL | Response | Example | ||
---|---|---|---|---|---|---|
Get Nodes | GET | http://host/en/omk/admin/api/v2/nodes.json | http://athena.opmantek.net/en/omk/admin/api/v2/nodes.json?page=1&per_page=5&sort_by=name&order=asc See Query Parameters | |||
Get Node | GET | http://host/en/omk/admin/api/v2/nodes/{node_uuid}.json | http://uburnto.opmantek.net/en/omk/admin/api/v2/nodes/86a82b4c-6ef6-4691-8c8c-1fc8da334d6f.json | |||
Create Node | POST | http://host/en/omk/admin/api/v2/nodes.json To create a remote node in an opHA cluster see below. | The node in json from the recently created node, including the UUID | http://uburnto.opmantek.net/en/omk/admin/api/v2/nodes.json
| ||
Update Node | PUT | http://host/en/omk/admin/api/v2/nodes/{node_uuid}.json To update a remote node in an opHA cluster see below. | http://uburnto.opmantek.net/en/omk/admin/api/v2/nodes/b56ba595-69e7-4702-9fe5-49512e1340b0.json
| |||
Delete Node | DELETE | http://host/en/omk/admin/api/v2/nodes/{node_uuid}.json | http://uburnto.opmantek.net/en/omk/admin/api/v2/nodes/b56ba595-69e7-4702-9fe5-49512e1340b0.json |
Request Modifiers (query parameters)
Not all requests will use all request modifiers.
Query Parameter | Possible Values |
---|---|
| Array of property names. If provided only the properties specified will be returned (instead of the whole document). eg: By default all properties if no fields_hash is specified. |
| Which page of the requested document to be returned, from 1 .. n, defaults to no pagination. |
| How many results are returned per page, defaults to 25 |
| List of For a string, if it starts with regex: or iregex: then a case-sensitive or case-insensitive regular expression match is used. |
| Property to sort by. eg: sort_by=name to sort by node name |
| Sort order. asc | desc : sort the response by sort_by ascending or descending. |
By example, the queries will look something like this:
Authentication
Important: All these methods are authenticated.
Operation | Method | URL | Response | Example | ||
---|---|---|---|---|---|---|
Authenticate | POST | http://host/en/omk/admin/login | http://uburnto.opmantek.net/en/omk/admin/login
|
We should receive a 200 response and a cookie, that we can reuse for next API calls.
Create a remote Node
If we want to create a node in a remote cluster, we should indicate the remote cluster id in configuration.pollers: cluster_id
.
cluster_id
is the uuid of which opHA server the node belongs to.
E.x.
Create Remote | POST | http://host/en/omk/admin/api/v2/nodes.json | It will return the json node, the same structure that the CREATE. | http://uburnto.opmantek.net/en/omk/admin/api/v2/nodes.json It will return the same output as for a local node:
|
Update a remote Node
If we want to update a node in a remote cluster, we should indicate the remote cluster id in configuration.pollers: cluster_id
.
cluster_id
is the uuid of which opHA server the node belongs to.
E.x.
Update Remote | PUT | http://host/en/omk/admin/api/v2/nodes/node_uuid.json | It will return the json node, the same structure that the CREATE. | http://volla.opmantek.net:6042/en/omk/admin/api/v2/nodes/6ce5fd5c-d703-4d03-b36c-b8e01439a9f2.json
|
Remote Nodes Error
If any operation has a remote cluster id, the API will try to edit in the remote server. If this operation is not possible, it will fail.
In order to succeed:
- opHA needs to be pulling that peer. This is because the peer sends the API url to update the remote in the registry data. And this information should be updated at least once a day.
- The peer has to be online.
If we should want to edit the remote node locally for some reason, we should use node_admin cli tool.