Skip to main content

Networks

A network is a virtual network that connects nodes as if they shared a local network, giving each node its own IP address. All traffic flows through a central relay node. When a network is created or changed, the pipelines each node needs are generated from the network's blueprints and deployed automatically. Use this service to create and change networks and to follow their changes and logs. Networks are stored on the connected node that has networks enabled, and calls wait until that node is connected.

Get network​

Get a single network.

GET/v1/networks/{id}
Path parameters
  • idstring

    The ID of the network to fetch.

Example
import { NanopingClient } from "@nanoping/api";

const client = new NanopingClient({ baseUrl: "http://127.0.0.1:10565" });

const response = await client.networks.getNetwork({
id: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"
});
Response
  • idstring

    The ID of the network.

  • networkNetwork

    The network.

Get networks​

Get all networks.

GET/v1/networks
Example
import { NanopingClient } from "@nanoping/api";

const client = new NanopingClient({ baseUrl: "http://127.0.0.1:10565" });

const response = await client.networks.getNetworks();
Response
  • networksGetNetworkResponse[]

    The networks with their IDs.

Create network​

Create a network and return it. Every connected node is added to the network automatically and assigned the first free IP address in its subnet, so nodes given in the request are ignored.

POST/v1/networks
Request body
  • namestring

    The name of the network. Must not be empty. Example: Office network

  • subnetCidrstring

    The IPv4 subnet, in CIDR notation, that node IP addresses are assigned from. Example: 100.65.254.0/24

  • blueprintsNetworkBlueprints

    The blueprints used to generate the network's pipelines.

  • parametersstring

    Parameters available to the network's blueprints, as a JSON object. May be empty. Example: { "raft_timeout": 9000, "loss_emulation_percentage": 1 }

  • relayNodeIdstring

    The node ID of the relay node. Must be the node that has networks enabled.

  • nodesNode[]

    The nodes in the network, each with its assigned IP address and carriers.

Example
import { NanopingClient } from "@nanoping/api";

const client = new NanopingClient({ baseUrl: "http://127.0.0.1:10565" });

const response = await client.networks.createNetwork({
network: {
name: "Office network",
subnetCidr: "100.65.254.0/24",
blueprints: {
relayBlueprint: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
relayClientBlueprint: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
clientBlueprint: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"
},
parameters: "{ \"raft_timeout\": 9000, \"loss_emulation_percentage\": 1 }",
relayNodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
nodes: [
{
nodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
nodeIp: "100.65.254.2",
carriers: [
{
address: {
ip: "192.168.1.20",
port: 3425,
externalIp: "203.0.113.10"
},
interface: "eth0",
bandwidthPriority: 0
}
],
type: "NODE_TYPE_CLIENT",
parameters: "{}"
}
]
}
});
Response
  • idstring

    The generated ID of the network.

  • networkNetwork

    The created network.

Update network​

Replace the settings of an existing network and return the updated network. Nodes cannot be added or removed, and their IP address and role cannot be changed.

PUT/v1/networks/{id}
Path parameters
  • idstring

    The ID of the network to update.

Request body
  • namestring

    The name of the network. Must not be empty. Example: Office network

  • subnetCidrstring

    The IPv4 subnet, in CIDR notation, that node IP addresses are assigned from. Example: 100.65.254.0/24

  • blueprintsNetworkBlueprints

    The blueprints used to generate the network's pipelines.

  • parametersstring

    Parameters available to the network's blueprints, as a JSON object. May be empty. Example: { "raft_timeout": 9000, "loss_emulation_percentage": 1 }

  • relayNodeIdstring

    The node ID of the relay node. Must be the node that has networks enabled.

  • nodesNode[]

    The nodes in the network, each with its assigned IP address and carriers.

Example
import { NanopingClient } from "@nanoping/api";

const client = new NanopingClient({ baseUrl: "http://127.0.0.1:10565" });

const response = await client.networks.updateNetwork({
id: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
network: {
name: "Office network",
subnetCidr: "100.65.254.0/24",
blueprints: {
relayBlueprint: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
relayClientBlueprint: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
clientBlueprint: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"
},
parameters: "{ \"raft_timeout\": 9000, \"loss_emulation_percentage\": 1 }",
relayNodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
nodes: [
{
nodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
nodeIp: "100.65.254.2",
carriers: [
{
address: {
ip: "192.168.1.20",
port: 3425,
externalIp: "203.0.113.10"
},
interface: "eth0",
bandwidthPriority: 0
}
],
type: "NODE_TYPE_CLIENT",
parameters: "{}"
}
]
}
});
Response
  • idstring

    The ID of the network.

  • networkNetwork

    The network after the update.

Delete network​

Delete a network.

DELETE/v1/networks/{id}
Path parameters
  • idstring

    The ID of the network to delete.

Example
import { NanopingClient } from "@nanoping/api";

const client = new NanopingClient({ baseUrl: "http://127.0.0.1:10565" });

await client.networks.deleteNetwork({
id: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"
});
Response

No fields.

Stream networks​

Stream changes to networks. Nothing is sent when the stream opens; an event is sent each time a network is created, updated or deleted. The stream ends if the connection to the networks node is lost.

GET/v1/streams/networks

Server-sent events. A : ready comment is sent when the stream is ready, then each message is a data: line holding the response below. A failure after that is an error event.

Example
import { NanopingClient } from "@nanoping/api";

const client = new NanopingClient({ baseUrl: "http://127.0.0.1:10565" });

for await (const response of client.networks.streamNetworks()) {
}
Response messages
  • createStreamNetworksCreateEventone of event

    A network was created.

  • updateStreamNetworksUpdateEventone of event

    A network was updated.

  • deleteStreamNetworksDeleteEventone of event

    A network was deleted.

Open log stream​

Stream the log messages of a network. The requested number of past lines is sent first, then new messages as they are logged, until the connection to the networks node is lost.

GET/v1/streams/networks/{network_id}/logs

Server-sent events. A : ready comment is sent when the stream is ready, then each message is a data: line holding the response below. A failure after that is an error event.

Path parameters
  • network_idstring

    The ID of the network whose log to stream.

Query parameters
  • optionsOptions

    Log stream options, such as how many past lines to send first.

Example
import { NanopingClient } from "@nanoping/api";

const client = new NanopingClient({ baseUrl: "http://127.0.0.1:10565" });

for await (const response of client.networks.openLogStream({
networkId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
options: {
lines: "0"
}
})) {
}
Response messages
  • messagesMessage[]

    The log messages.