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.
- REST
- gRPC
/v1/nodes/{node_id}/network-instancesnode_idstringThe ID of the node to fetch network instances from.
- TypeScript
- Python
- curl
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"
});
from nanoping_api import NanopingClient
client = NanopingClient("http://127.0.0.1:10565")
response = client.network_instances.get_network_instances(
node_id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
)
curl 'http://127.0.0.1:10565/v1/nodes/<node_id>/network-instances'
networkInstancesNetworkInstance[]The network instances of the node.
rpc getNetworkInstances(GetNetworkInstancesRequest) returns (GetNetworkInstancesResponse)
Method /nanopinggrpc.networks.NetworkInstances/getNetworkInstances
node_idstringThe ID of the node to fetch network instances from.
network_instancesNetworkInstance[]The network instances of the node.
- Go
- Go (generated gRPC)
import (
client "github.com/nanoping-labs/nanoping-api-go/v11"
"github.com/nanoping-labs/nanoping-api-go/v11/networks"
)
c, err := client.Connect("127.0.0.1:10432")
defer c.Close()
response, err := c.NetworkInstances.GetNetworkInstances(ctx, &networks.GetNetworkInstancesRequest{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
})
import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"github.com/nanoping-labs/nanoping-api-go/v11/networks"
)
conn, err := grpc.NewClient("127.0.0.1:10432", grpc.WithTransportCredentials(insecure.NewCredentials()))
defer conn.Close()
stub := networks.NewNetworkInstancesClient(conn)
response, err := stub.GetNetworkInstances(ctx, &networks.GetNetworkInstancesRequest{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
})
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.
- REST
- gRPC
/v1/streams/nodes/{node_id}/network-instancesServer-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.
node_idstringThe ID of the node to stream network instances from.
- TypeScript
- Python
- curl
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"
})) {
}
from nanoping_api import NanopingClient
client = NanopingClient("http://127.0.0.1:10565")
for response in client.network_instances.stream_network_instances(
node_id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
):
print(response)
curl -N 'http://127.0.0.1:10565/v1/streams/nodes/<node_id>/network-instances'
createStreamNetworkInstanceCreateEventone of eventA network instance was created.
updateStreamNetworkInstanceUpdateEventone of eventA network instance was updated.
deleteStreamNetworkInstanceDeleteEventone of eventA network instance was deleted.
rpc streamNetworkInstances(StreamNetworkInstancesRequest) returns (stream StreamNetworkInstanceEvent)
Method /nanopinggrpc.networks.NetworkInstances/streamNetworkInstances
node_idstringThe ID of the node to stream network instances from.
createStreamNetworkInstanceCreateEventone of eventA network instance was created.
updateStreamNetworkInstanceUpdateEventone of eventA network instance was updated.
deleteStreamNetworkInstanceDeleteEventone of eventA network instance was deleted.
- Go
- Go (generated gRPC)
import (
client "github.com/nanoping-labs/nanoping-api-go/v11"
"github.com/nanoping-labs/nanoping-api-go/v11/networks"
)
c, err := client.Connect("127.0.0.1:10432")
defer c.Close()
stream, err := c.NetworkInstances.StreamNetworkInstances(ctx, &networks.StreamNetworkInstancesRequest{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
})
for response, err := range client.Receive(stream) {
if err != nil {
return err
}
}
import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"github.com/nanoping-labs/nanoping-api-go/v11/networks"
)
conn, err := grpc.NewClient("127.0.0.1:10432", grpc.WithTransportCredentials(insecure.NewCredentials()))
defer conn.Close()
stub := networks.NewNetworkInstancesClient(conn)
stream, err := stub.StreamNetworkInstances(ctx, &networks.StreamNetworkInstancesRequest{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
})
for {
response, err := stream.Recv()
if err != nil {
return err
}
}
Get network pipelines
Get the network instance pipelines on a node, optionally filtered. A pipeline must match every filter that is set.
- REST
- gRPC
/v1/nodes/{node_id}/network-pipelinesnode_idstringThe ID of the node to fetch network instance pipelines from.
optional_network_idstringone of network_idOnly return pipelines belonging to this network ID.
optional_instance_idstringone of instance_idOnly return pipelines belonging to this network instance ID.
optional_blueprint_idstringone of blueprint_idOnly return pipelines generated from this blueprint ID.
- TypeScript
- Python
- curl
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"
});
from nanoping_api import NanopingClient
client = NanopingClient("http://127.0.0.1:10565")
response = client.network_instances.get_network_pipelines(
node_id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
optional_network_id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
optional_instance_id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
optional_blueprint_id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
)
curl 'http://127.0.0.1:10565/v1/nodes/<node_id>/network-pipelines'
networkPipelinesNetworkPipeline[]The network instance pipelines.
rpc getNetworkPipelines(GetNetworkPipelinesRequest) returns (GetNetworkPipelinesResponse)
Method /nanopinggrpc.networks.NetworkInstances/getNetworkPipelines
node_idstringThe ID of the node to fetch network instance pipelines from.
optional_network_idstringone of network_idOnly return pipelines belonging to this network ID.
optional_instance_idstringone of instance_idOnly return pipelines belonging to this network instance ID.
optional_blueprint_idstringone of blueprint_idOnly return pipelines generated from this blueprint ID.
network_pipelinesNetworkPipeline[]The network instance pipelines.
- Go
- Go (generated gRPC)
import (
client "github.com/nanoping-labs/nanoping-api-go/v11"
"github.com/nanoping-labs/nanoping-api-go/v11/networks"
)
c, err := client.Connect("127.0.0.1:10432")
defer c.Close()
response, err := c.NetworkInstances.GetNetworkPipelines(ctx, &networks.GetNetworkPipelinesRequest{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
NetworkId: &networks.GetNetworkPipelinesRequest_OptionalNetworkId{OptionalNetworkId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
InstanceId: &networks.GetNetworkPipelinesRequest_OptionalInstanceId{OptionalInstanceId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
BlueprintId: &networks.GetNetworkPipelinesRequest_OptionalBlueprintId{OptionalBlueprintId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
})
import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"github.com/nanoping-labs/nanoping-api-go/v11/networks"
)
conn, err := grpc.NewClient("127.0.0.1:10432", grpc.WithTransportCredentials(insecure.NewCredentials()))
defer conn.Close()
stub := networks.NewNetworkInstancesClient(conn)
response, err := stub.GetNetworkPipelines(ctx, &networks.GetNetworkPipelinesRequest{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
NetworkId: &networks.GetNetworkPipelinesRequest_OptionalNetworkId{OptionalNetworkId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
InstanceId: &networks.GetNetworkPipelinesRequest_OptionalInstanceId{OptionalInstanceId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
BlueprintId: &networks.GetNetworkPipelinesRequest_OptionalBlueprintId{OptionalBlueprintId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
})
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.
- REST
- gRPC
/v1/streams/nodes/{node_id}/network-pipelinesServer-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.
node_idstringThe ID of the node to stream network instance pipelines from.
- TypeScript
- Python
- curl
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"
})) {
}
from nanoping_api import NanopingClient
client = NanopingClient("http://127.0.0.1:10565")
for response in client.network_instances.stream_network_pipelines(
node_id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
):
print(response)
curl -N 'http://127.0.0.1:10565/v1/streams/nodes/<node_id>/network-pipelines'
createStreamNetworkPipelineCreateEventone of eventA pipeline was created.
updateStreamNetworkPipelineUpdateEventone of eventA pipeline was updated.
deleteStreamNetworkPipelineDeleteEventone of eventA pipeline was deleted.
rpc streamNetworkPipelines(StreamNetworkPipelinesRequest) returns (stream StreamNetworkPipelineEvent)
Method /nanopinggrpc.networks.NetworkInstances/streamNetworkPipelines
node_idstringThe ID of the node to stream network instance pipelines from.
createStreamNetworkPipelineCreateEventone of eventA pipeline was created.
updateStreamNetworkPipelineUpdateEventone of eventA pipeline was updated.
deleteStreamNetworkPipelineDeleteEventone of eventA pipeline was deleted.
- Go
- Go (generated gRPC)
import (
client "github.com/nanoping-labs/nanoping-api-go/v11"
"github.com/nanoping-labs/nanoping-api-go/v11/networks"
)
c, err := client.Connect("127.0.0.1:10432")
defer c.Close()
stream, err := c.NetworkInstances.StreamNetworkPipelines(ctx, &networks.StreamNetworkPipelinesRequest{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
})
for response, err := range client.Receive(stream) {
if err != nil {
return err
}
}
import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"github.com/nanoping-labs/nanoping-api-go/v11/networks"
)
conn, err := grpc.NewClient("127.0.0.1:10432", grpc.WithTransportCredentials(insecure.NewCredentials()))
defer conn.Close()
stub := networks.NewNetworkInstancesClient(conn)
stream, err := stub.StreamNetworkPipelines(ctx, &networks.StreamNetworkPipelinesRequest{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
})
for {
response, err := stream.Recv()
if err != nil {
return err
}
}
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.
- REST
- gRPC
/v1/nodes/{node_id}/network-pipelines/togglenode_idstringThe ID of the node the pipeline runs on.
optionalPipelineIdstringone of pipeline_idThe pipeline's
pipeline_id.optionalInstancePipelineIdstringone of instance_pipeline_idThe pipeline's
id.
- TypeScript
- Python
- curl
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"
});
from nanoping_api import NanopingClient
client = NanopingClient("http://127.0.0.1:10565")
client.network_instances.toggle_network_pipeline(
node_id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
optional_pipeline_id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
optional_instance_pipeline_id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
)
curl -X POST 'http://127.0.0.1:10565/v1/nodes/<node_id>/network-pipelines/toggle' \
-H 'Content-Type: application/json' \
-d '{
"optionalPipelineId": "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
"optionalInstancePipelineId": "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"
}'
No fields.
rpc toggleNetworkPipeline(ToggleNetworkPipelineRequest) returns (ToggleNetworkPipelineResponse)
Method /nanopinggrpc.networks.NetworkInstances/toggleNetworkPipeline
node_idstringThe ID of the node the pipeline runs on.
optional_pipeline_idstringone of pipeline_idThe pipeline's
pipeline_id.optional_instance_pipeline_idstringone of instance_pipeline_idThe pipeline's
id.
No fields.
- Go
- Go (generated gRPC)
import (
client "github.com/nanoping-labs/nanoping-api-go/v11"
"github.com/nanoping-labs/nanoping-api-go/v11/networks"
)
c, err := client.Connect("127.0.0.1:10432")
defer c.Close()
_, err = c.NetworkInstances.ToggleNetworkPipeline(ctx, &networks.ToggleNetworkPipelineRequest{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
PipelineId: &networks.ToggleNetworkPipelineRequest_OptionalPipelineId{OptionalPipelineId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
InstancePipelineId: &networks.ToggleNetworkPipelineRequest_OptionalInstancePipelineId{OptionalInstancePipelineId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
})
import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"github.com/nanoping-labs/nanoping-api-go/v11/networks"
)
conn, err := grpc.NewClient("127.0.0.1:10432", grpc.WithTransportCredentials(insecure.NewCredentials()))
defer conn.Close()
stub := networks.NewNetworkInstancesClient(conn)
_, err = stub.ToggleNetworkPipeline(ctx, &networks.ToggleNetworkPipelineRequest{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
PipelineId: &networks.ToggleNetworkPipelineRequest_OptionalPipelineId{OptionalPipelineId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
InstancePipelineId: &networks.ToggleNetworkPipelineRequest_OptionalInstancePipelineId{OptionalInstancePipelineId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
})
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.
- REST
- gRPC
/v1/streams/nodes/{node_id}/network-instances/{network_instance_id}/logsServer-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.
node_idstringThe ID of the node the network instance runs on.
network_instance_idstringThe ID of the network instance whose log to stream.
optionsOptionsLog stream options, such as how many past lines to send first.
- TypeScript
- Python
- curl
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"
}
})) {
}
from nanoping_api import NanopingClient, Options
client = NanopingClient("http://127.0.0.1:10565")
for response in client.network_instances.open_log_stream(
node_id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
network_instance_id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
options=Options(lines=0),
):
print(response)
curl -N 'http://127.0.0.1:10565/v1/streams/nodes/<node_id>/network-instances/<network_instance_id>/logs'
messagesMessage[]The log messages.
rpc openLogStream(OpenNetworkInstanceLogStreamRequest) returns (stream NetworkInstanceLogStreamMessages)
Method /nanopinggrpc.networks.NetworkInstances/openLogStream
node_idstringThe ID of the node the network instance runs on.
network_instance_idstringThe ID of the network instance whose log to stream.
optionsOptionsLog stream options, such as how many past lines to send first.
messagesMessage[]The log messages.
- Go
- Go (generated gRPC)
import (
client "github.com/nanoping-labs/nanoping-api-go/v11"
"github.com/nanoping-labs/nanoping-api-go/v11/logging"
"github.com/nanoping-labs/nanoping-api-go/v11/networks"
)
c, err := client.Connect("127.0.0.1:10432")
defer c.Close()
stream, err := c.NetworkInstances.OpenLogStream(ctx, &networks.OpenNetworkInstanceLogStreamRequest{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
NetworkInstanceId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
Options: &logging.Options{
OptionalLines: &logging.Options_Lines{Lines: 0},
},
})
for response, err := range client.Receive(stream) {
if err != nil {
return err
}
}
import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"github.com/nanoping-labs/nanoping-api-go/v11/logging"
"github.com/nanoping-labs/nanoping-api-go/v11/networks"
)
conn, err := grpc.NewClient("127.0.0.1:10432", grpc.WithTransportCredentials(insecure.NewCredentials()))
defer conn.Close()
stub := networks.NewNetworkInstancesClient(conn)
stream, err := stub.OpenLogStream(ctx, &networks.OpenNetworkInstanceLogStreamRequest{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
NetworkInstanceId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
Options: &logging.Options{
OptionalLines: &logging.Options_Lines{Lines: 0},
},
})
for {
response, err := stream.Recv()
if err != nil {
return err
}
}