Skip to main content

Network instances

A network instance is a network's presence on one node: the pipelines generated for that node from the network's blueprints. Instances are created, updated and removed automatically when their network changes, so they cannot be managed directly. Use this service to see which networks a node takes part in, follow its network pipelines, turn them on or off, and read their logs. The node needs pipelines enabled.

Get network instances​

Get all network instances on a node, each with its pipelines.

GET/v1/nodes/{node_id}/network-instances
Path parameters
  • node_idstring

    The ID of the node to fetch network instances from.

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

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

const response = await client.networkInstances.getNetworkInstances({
nodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"
});
Response
  • networkInstancesNetworkInstance[]

    The network instances of the node.

Stream network instances​

Stream changes to the network instances on a node. Nothing is sent when the stream opens; an event is sent each time an instance is created, updated or deleted, and an update is also sent when one of its pipelines changes. The stream ends if the connection to the node is lost.

GET/v1/streams/nodes/{node_id}/network-instances

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
  • node_idstring

    The ID of the node to stream network instances from.

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

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

for await (const response of client.networkInstances.streamNetworkInstances({
nodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"
})) {
}
Response messages
  • createStreamNetworkInstanceCreateEventone of event

    A network instance was created.

  • updateStreamNetworkInstanceUpdateEventone of event

    A network instance was updated.

  • deleteStreamNetworkInstanceDeleteEventone of event

    A network instance was deleted.

Get network pipelines​

Get the network instance pipelines on a node, optionally filtered. A pipeline must match every filter that is set.

GET/v1/nodes/{node_id}/network-pipelines
Path parameters
  • node_idstring

    The ID of the node to fetch network instance pipelines from.

Query parameters
  • optional_network_idstringone of network_id

    Only return pipelines belonging to this network ID.

  • optional_instance_idstringone of instance_id

    Only return pipelines belonging to this network instance ID.

  • optional_blueprint_idstringone of blueprint_id

    Only return pipelines generated from this blueprint ID.

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

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

const response = await client.networkInstances.getNetworkPipelines({
nodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
optionalNetworkId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
optionalInstanceId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
optionalBlueprintId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"
});
Response
  • networkPipelinesNetworkPipeline[]

    The network instance pipelines.

Stream network pipelines​

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

GET/v1/streams/nodes/{node_id}/network-pipelines

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
  • node_idstring

    The ID of the node to stream network instance pipelines from.

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

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

for await (const response of client.networkInstances.streamNetworkPipelines({
nodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"
})) {
}
Response messages
  • createStreamNetworkPipelineCreateEventone of event

    A pipeline was created.

  • updateStreamNetworkPipelineUpdateEventone of event

    A pipeline was updated.

  • deleteStreamNetworkPipelineDeleteEventone of event

    A pipeline was deleted.

Toggle network pipeline​

Enable or disable a network instance pipeline on a node, which starts or stops the pipeline. Each call flips the current state. Fails with a not found error if no matching pipeline exists.

POST/v1/nodes/{node_id}/network-pipelines/toggle
Path parameters
  • node_idstring

    The ID of the node the pipeline runs on.

Request body
  • optionalPipelineIdstringone of pipeline_id

    The pipeline's pipeline_id.

  • optionalInstancePipelineIdstringone of instance_pipeline_id

    The pipeline's id.

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

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

await client.networkInstances.toggleNetworkPipeline({
nodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
optionalPipelineId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
optionalInstancePipelineId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"
});
Response

No fields.

Open log stream​

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

GET/v1/streams/nodes/{node_id}/network-instances/{network_instance_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
  • node_idstring

    The ID of the node the network instance runs on.

  • network_instance_idstring

    The ID of the network instance 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.networkInstances.openLogStream({
nodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
networkInstanceId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
options: {
lines: "0"
}
})) {
}
Response messages
  • messagesMessage[]

    The log messages.