API: Nodes

From Yombo
Jump to: navigation, search

Summary

Nodes are used to store nearly any type of data. Modules can use to store extra configuration or user data. The data can be binary or text up to 5 megabytes. Note: Max total data size limit will be enforced when a node is created or updated. If a users' maximum storage limit is reached, the node will not be saved or updated.

GET - All nodes

Retrieve all nodes available to the current user.

Filters

List of available filters:

  • id
  • node_type
  • label
  • machine_label
  • gateway_id
  • weight
  • always_load
  • status
  • created_at
  • updated_at

Request URLs

  • GET https://api.yombo.net/api/v1/node

Parameters

None

Example

  <div id="curl<random_number></random_number>" class="tab-pane fade in active" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
curl \
-H "x-api-key: abc123xyz789" \
-H "authorization: Bearer Waro7g0Mwl4YBJ..." \
https://api.yombo.net/api/v1/node?_filters[machine_label]=module_phone_bandwidth&_pagelimit=1
  <div id="python<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
import requests

url = 'https://api.yombo.net/api/v1/node?_filters[machine_label]=module_phone_bandwidth&_pagelimit=1'
headers = {
    'x-api-key': 'abc123xyz789',
    'authorization': 'Waro7g0Mwl4YBJ...',
    }
response = requests.get(url, headers=headers)
  <div id="output<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
 1 {
 2     "response": {
 3         "uri": "/api/v1/node?_filters[machine_label]=module_phone_bandwidth&_pagelimit=1",
 4         "uri_description": "List nodes.",
 5         "doc_uri": "https://yombo.net/API:Nodes",
 6         "node": [
 7             {
 8                 "id": "LdRevqk9p6rKZV24",
 9                 "parent_id": "",
10                 "user_id": "wE9v8xp4pqa0GQbrde",
11                 "gateway_id": "E31ebmxkm8M7lRv0",
12                 "node_type": "module_phone_bandwidth",
13                 "weight": 0,
14                 "label": "Module Phone Bandwidth",
15                 "machine_label": "module_phone_bandwidth",
16                 "always_load": 1,
17                 "destination": "gw",
18                 "data": "{\"allowed\":[],\"phones\":{\"allowed\":[]},\"active_phones\":{\"x2m8V37ebPO06zrX\":{\"send\":1,\"receive\":1,\"pin\":\"  aaka\"

}",

               "data_content_type": "json",
               "status": 1,
               "created_at": 1517722722,
               "updated_at": 1517738066
           }
       ],
       "locator": "node",
       "locator_type": "objects"
   },
   "code": 200,
   "warnings": [],
   "filters": [
       {
           "field": "machine_label",
           "operator": "=",
           "search": "module_phone_bandwidth"
       }
   ],
   "filter_operator": "and",
   "pages": {
       "total_items": 2,
       "page_limit": 1,
       "total_pages": 2,
       "page_start": 1
   },
   "message": "OK",
   "html_message": "OK"

} }}

GET - Specific node

Retrieve a specific node id.

Request URLs

  • GET https://api.yombo.net/api/v1/node/{node_id}

Parameters

None

Example

  <div id="curl<random_number></random_number>" class="tab-pane fade in active" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
curl \
-H "x-api-key: abc123xyz789" \
-H "authorization: Bearer Waro7g0Mwl4YBJ..." \
https://api.yombo.net/api/v1/node/aWvzB0ENZ23JO
  <div id="python<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
import requests

url = 'https://api.yombo.net/api/v1/node/aWvzB0ENZ23JO
headers = {
    'x-api-key': 'abc123xyz789',
    'authorization': 'Waro7g0Mwl4YBJ...',
    }
response = requests.get(url, headers=headers)
  <div id="output<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
 1 {
 2     "response": {
 3         "uri": "/api/v1/node/LdRevqk9p6rKZV24",
 4         "uri_description": "Detailed information for a single node.",
 5         "doc_uri": "https://yombo.net/API:Nodes",
 6         "node": {
 7             "id": "LdRevqk9p6rKZV24",
 8             "parent_id": "",
 9             "user_id": "wE9v8xp4pqa0GQbrde",
10             "gateway_id": "E31ebmxkm8M7lRv0",
11             "node_type": "module_phone_bandwidth",
12             "weight": 0,
13             "label": "Module Phone Bandwidth",
14             "machine_label": "module_phone_bandwidth",
15             "always_load": 1,
16             "destination": "gw",
17             "data": "{\"allowed\":[],\"phones\":{\"allowed\":[]},\"active_phones\":{\"x2m8V37ebPO06zrX\":{\"send\":1,\"receive\":1,\"pin\":\"  aaka\"

}",

           "data_content_type": "json",
           "status": 1,
           "created_at": 1517722722,
           "updated_at": 1517738066
       },
       "locator": "node",
       "locator_type": "object"
   },
   "code": 200,
   "warnings": [],
   "message": "OK",
   "html_message": "OK"

} }}

POST - Create new node

Creates a new node.

Request URLs

  • POST https://api.yombo.net/api/v1/node

Parameters

Name Type Description
Required
node_type string A string to help search for node types. No predefined list. Can only contain: a-z and _ (underscore).
node_type string/binary Whatever data you want stored. Typically, this is one of: json, msgpack, json_zip, msgpack_zip. Other ideas can be: binary, jpeg, gif.
Optional
parent_id string For parent/sibling/child relationships, list the parent node.
gateway_id string If this node should be associated with a gateway, put the gateway id here.
label string A short human friendly label for the none.
machine_name string Machine name for this none. Once set, this shouldn't be changed, but this is not enforced. Can only contain: a-z and _ (underscore).
weight integer Default: 0 - Useful if nodes should be sorted.
description string A detailed description of what the input type checks for.
always_load integer Default: 0 - Just another attribute you can use for anything. The gateway uses this to load some nodes into memory on startup or when receiving updates.
destination string Like always_load, can be used for anything you want. If 'gw' is used, this will always be sent to the gateway when the gateway requests updates or first starts.
status integer Default: 1 - Status for the node.

DELETE - Delete a node

Delete a node. This doesn't actually delete the node right away, but simply marks it for deletion later. This is the same as setting the status to 2. To undelete the node, simply change the status back to 1.

Request URLs

  • DELETE https://api.yombo.net/api/v1/node/{node_id}

Parameters

None

Example

  <div id="curl<random_number></random_number>" class="tab-pane fade in active" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
curl \
-H "x-api-key: abc123xyz789" \
-H "authorization: Bearer Waro7g0Mwl4YBJ..." \
-X DELETE https://api.yombo.net/api/v1/node/LdRevqk9p6rKZV24
  <div id="python<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
import requests

url = 'https://api.yombo.net/api/v1/node/LdRevqk9p6rKZV24'
headers = {
    'x-api-key': 'abc123xyz789',
    'authorization': 'Waro7g0Mwl4YBJ...',
    }

response = requests.put(url, headers=headers)
  <div id="output<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
 1 {
 2     "response": {
 3         "uri": "/api/v1/node/LdRevqk9p6rKZV24",
 4         "uri_description": "Delete a node.",
 5         "doc_uri": "https://yombo.net/API:Nodes",
 6         "node": "Deleted",
 7         "locator": "node",
 8         "locator_type": "string"
 9     },
10     "code": 200,
11     "warnings": [],
12     "message": "Deleted",
13     "html_message": "Deleted"
14 }
This page was last edited on 14 September 2018.