Skip to main content

Node Management

In RainMaker, all provisioned devices are called nodes. Each node has a hierarchical structure that contains configuration, devices, services, and their parameters.

Node Hierarchy Structure

The following interactive tree diagram illustrates the complete hierarchy of a RainMaker node. Click on any node to expand/collapse it, and configure links to navigate to detailed documentation for each component.

info

Interactive Tree Visualization

The tree below is interactive - you can:

  • Click nodes to expand/collapse branches
  • Drag to pan around the tree
  • Scroll/zoom to adjust the view
  • Click nodes to navigate to documentation (links can be configured)

To configure navigation links for nodes, update the nodeLinkMap prop in the component.

Get User Nodes

To retrieve all provisioned devices (nodes) associated with the logged-in user, use the getUserNodes method. This method allows you to specify the number of results to return. If the number of nodes associated with the logged-in user is more than the specified resultCount, pagination is handled automatically.

// Example usage with pagination
try {
const resultCount = 10; // Number of nodes to retrieve initially

let response = await userInstance.getUserNodes(resultCount);

console.log("User nodes retrieved:", response.nodes);

// Handle pagination
while (response.hasNext) {
response = await response.fetchNext();
console.log("Next set of user nodes retrieved:", response.nodes);
}
} catch (error) {
console.error("Error fetching user nodes:", error);
}

Get Node Details

To retrieve detailed information about a specific node, use the getNodeDetails method:

/*
- nodeId: The ID of the node to fetch.
*/

try {
const nodeDetails = await userInstance.getNodeDetails("node_id_123");
console.log("Node details:", nodeDetails);

// Access node configuration
const nodeConfig = nodeDetails.nodeConfig;
// ... access devices and services as shown above
} catch (error) {
console.error("Error fetching node details:", error);
}

Get Node Configuration

To fetch the complete configuration of a node, use the getNodeConfig method on a node instance:

try {
const nodeConfig = await node.getNodeConfig();
console.log("Node configuration:", nodeConfig);
console.log("Devices:", nodeConfig.devices);
console.log("Services:", nodeConfig.services);
} catch (error) {
console.error("Error fetching node config:", error);
}

Get Services

To fetch all services associated with a node, use the getServices method:

try {
const services = await node.getServices();
console.log("Node services:", services);

services.forEach((service) => {
console.log("Service:", service.name, "Type:", service.type);
console.log("Parameters:", service.params);
});
} catch (error) {
console.error("Error fetching services:", error);
}

Get User Nodes With Filters

To retrieve nodes with specific filters and pagination options, use the getUserNodesWith method:

/*
- getUserNodesWithRequestParams: The parameters for the request to get user nodes.
*/

const getUserNodesWithRequestParams = {
result_count: 20,
page_num: 1,
// Add other filters as needed
};

try {
const nodes = await userInstance.getUserNodesWith(getUserNodesWithRequestParams);
console.log("Filtered nodes:", nodes);
} catch (error) {
console.error("Error fetching nodes with filters:", error);
}

Delete Node

Delete the mapping of the current node with the user using the delete method. This removes the node from the user's account.

try {
const response = await node.delete();
console.log("Node deleted successfully:", response);
} catch (error) {
console.error("Error deleting node:", error);
}
warning

Deleting a node removes it from your account. This action cannot be undone. Make sure you want to delete the node before proceeding.

On this page