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.
- REST
- gRPC
/v1/networks/{id}idstringThe ID of the network to fetch.
- TypeScript
- Python
- curl
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"
});
from nanoping_api import NanopingClient
client = NanopingClient("http://127.0.0.1:10565")
response = client.networks.get_network(id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f")
curl 'http://127.0.0.1:10565/v1/networks/<id>'
idstringThe ID of the network.
networkNetworkThe network.
rpc getNetwork(GetNetworkRequest) returns (GetNetworkResponse)
Method /nanopinggrpc.networks.Networks/getNetwork
idstringThe ID of the network to fetch.
idstringThe ID of the network.
networkNetworkThe network.
- 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.Networks.GetNetwork(ctx, &networks.GetNetworkRequest{
Id: "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.NewNetworksClient(conn)
response, err := stub.GetNetwork(ctx, &networks.GetNetworkRequest{
Id: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
})
Get networks
Get all networks.
- REST
- gRPC
/v1/networks- TypeScript
- Python
- curl
import { NanopingClient } from "@nanoping/api";
const client = new NanopingClient({ baseUrl: "http://127.0.0.1:10565" });
const response = await client.networks.getNetworks();
from nanoping_api import NanopingClient
client = NanopingClient("http://127.0.0.1:10565")
response = client.networks.get_networks()
curl 'http://127.0.0.1:10565/v1/networks'
networksGetNetworkResponse[]The networks with their IDs.
rpc getNetworks(GetNetworksRequest) returns (GetNetworksResponse)
Method /nanopinggrpc.networks.Networks/getNetworks
No fields.
networksGetNetworkResponse[]The networks with their IDs.
- 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.Networks.GetNetworks(ctx, &networks.GetNetworksRequest{})
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.NewNetworksClient(conn)
response, err := stub.GetNetworks(ctx, &networks.GetNetworksRequest{})
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.
- REST
- gRPC
/v1/networksnamestringThe name of the network. Must not be empty. Example:
Office networksubnetCidrstringThe IPv4 subnet, in CIDR notation, that node IP addresses are assigned from. Example:
100.65.254.0/24blueprintsNetworkBlueprintsThe blueprints used to generate the network's pipelines.
parametersstringParameters available to the network's blueprints, as a JSON object. May be empty. Example:
{ "raft_timeout": 9000, "loss_emulation_percentage": 1 }relayNodeIdstringThe 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.
- TypeScript
- Python
- curl
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: "{}"
}
]
}
});
from nanoping_api import (
Address,
Carrier,
NanopingClient,
Network,
NetworkBlueprints,
NetworksNode,
NodeType,
)
client = NanopingClient("http://127.0.0.1:10565")
response = client.networks.create_network(
network=Network(
name="Office network",
subnet_cidr="100.65.254.0/24",
blueprints=NetworkBlueprints(
relay_blueprint="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
relay_client_blueprint="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
client_blueprint="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
),
parameters="{ \"raft_timeout\": 9000, \"loss_emulation_percentage\": 1 }",
relay_node_id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
nodes=[
NetworksNode(
node_id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
node_ip="100.65.254.2",
carriers=[
Carrier(
address=Address(
ip="192.168.1.20",
port=3425,
external_ip="203.0.113.10",
),
interface="eth0",
bandwidth_priority=0,
),
],
type=NodeType.NODE_TYPE_CLIENT,
parameters="{}",
),
],
),
)
curl -X POST 'http://127.0.0.1:10565/v1/networks' \
-H 'Content-Type: application/json' \
-d '{
"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": "{}"
}
]
}'
idstringThe generated ID of the network.
networkNetworkThe created network.
rpc createNetwork(CreateNetworkRequest) returns (CreateNetworkResponse)
Method /nanopinggrpc.networks.Networks/createNetwork
networkNetworkThe network to create. Required.
idstringThe generated ID of the network.
networkNetworkThe created network.
- 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.Networks.CreateNetwork(ctx, &networks.CreateNetworkRequest{
Network: &networks.Network{
Name: "Office network",
SubnetCidr: "100.65.254.0/24",
Blueprints: &networks.NetworkBlueprints{
OptionalRelayBlueprint: &networks.NetworkBlueprints_RelayBlueprint{RelayBlueprint: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
OptionalRelayClientBlueprint: &networks.NetworkBlueprints_RelayClientBlueprint{RelayClientBlueprint: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
OptionalClientBlueprint: &networks.NetworkBlueprints_ClientBlueprint{ClientBlueprint: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
},
Parameters: "{ \"raft_timeout\": 9000, \"loss_emulation_percentage\": 1 }",
RelayNodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
Nodes: []*networks.Node{
&networks.Node{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
NodeIp: "100.65.254.2",
Carriers: []*networks.Carrier{
&networks.Carrier{
OptionalAddress: &networks.Carrier_Address{Address: &networks.Address{
Ip: "192.168.1.20",
Port: 3425,
OptionalExternalIp: &networks.Address_ExternalIp{ExternalIp: "203.0.113.10"},
}},
OptionalInterface: &networks.Carrier_Interface{Interface: "eth0"},
OptionalBandwidthPriority: &networks.Carrier_BandwidthPriority{BandwidthPriority: 0},
},
},
Type: networks.NodeType_NODE_TYPE_CLIENT,
Parameters: "{}",
},
},
},
})
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.NewNetworksClient(conn)
response, err := stub.CreateNetwork(ctx, &networks.CreateNetworkRequest{
Network: &networks.Network{
Name: "Office network",
SubnetCidr: "100.65.254.0/24",
Blueprints: &networks.NetworkBlueprints{
OptionalRelayBlueprint: &networks.NetworkBlueprints_RelayBlueprint{RelayBlueprint: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
OptionalRelayClientBlueprint: &networks.NetworkBlueprints_RelayClientBlueprint{RelayClientBlueprint: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
OptionalClientBlueprint: &networks.NetworkBlueprints_ClientBlueprint{ClientBlueprint: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
},
Parameters: "{ \"raft_timeout\": 9000, \"loss_emulation_percentage\": 1 }",
RelayNodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
Nodes: []*networks.Node{
&networks.Node{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
NodeIp: "100.65.254.2",
Carriers: []*networks.Carrier{
&networks.Carrier{
OptionalAddress: &networks.Carrier_Address{Address: &networks.Address{
Ip: "192.168.1.20",
Port: 3425,
OptionalExternalIp: &networks.Address_ExternalIp{ExternalIp: "203.0.113.10"},
}},
OptionalInterface: &networks.Carrier_Interface{Interface: "eth0"},
OptionalBandwidthPriority: &networks.Carrier_BandwidthPriority{BandwidthPriority: 0},
},
},
Type: networks.NodeType_NODE_TYPE_CLIENT,
Parameters: "{}",
},
},
},
})
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.
- REST
- gRPC
/v1/networks/{id}idstringThe ID of the network to update.
namestringThe name of the network. Must not be empty. Example:
Office networksubnetCidrstringThe IPv4 subnet, in CIDR notation, that node IP addresses are assigned from. Example:
100.65.254.0/24blueprintsNetworkBlueprintsThe blueprints used to generate the network's pipelines.
parametersstringParameters available to the network's blueprints, as a JSON object. May be empty. Example:
{ "raft_timeout": 9000, "loss_emulation_percentage": 1 }relayNodeIdstringThe 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.
- TypeScript
- Python
- curl
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: "{}"
}
]
}
});
from nanoping_api import (
Address,
Carrier,
NanopingClient,
Network,
NetworkBlueprints,
NetworksNode,
NodeType,
)
client = NanopingClient("http://127.0.0.1:10565")
response = client.networks.update_network(
id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
network=Network(
name="Office network",
subnet_cidr="100.65.254.0/24",
blueprints=NetworkBlueprints(
relay_blueprint="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
relay_client_blueprint="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
client_blueprint="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
),
parameters="{ \"raft_timeout\": 9000, \"loss_emulation_percentage\": 1 }",
relay_node_id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
nodes=[
NetworksNode(
node_id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
node_ip="100.65.254.2",
carriers=[
Carrier(
address=Address(
ip="192.168.1.20",
port=3425,
external_ip="203.0.113.10",
),
interface="eth0",
bandwidth_priority=0,
),
],
type=NodeType.NODE_TYPE_CLIENT,
parameters="{}",
),
],
),
)
curl -X PUT 'http://127.0.0.1:10565/v1/networks/<id>' \
-H 'Content-Type: application/json' \
-d '{
"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": "{}"
}
]
}'
idstringThe ID of the network.
networkNetworkThe network after the update.
rpc updateNetwork(UpdateNetworkRequest) returns (UpdateNetworkResponse)
Method /nanopinggrpc.networks.Networks/updateNetwork
idstringThe ID of the network to update.
networkNetworkThe new settings of the network. Required. All fields replace the current values, except
nodes: leave it empty to keep the nodes unchanged, or list every current node to edit their carriers and parameters.
idstringThe ID of the network.
networkNetworkThe network after the update.
- 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.Networks.UpdateNetwork(ctx, &networks.UpdateNetworkRequest{
Id: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
Network: &networks.Network{
Name: "Office network",
SubnetCidr: "100.65.254.0/24",
Blueprints: &networks.NetworkBlueprints{
OptionalRelayBlueprint: &networks.NetworkBlueprints_RelayBlueprint{RelayBlueprint: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
OptionalRelayClientBlueprint: &networks.NetworkBlueprints_RelayClientBlueprint{RelayClientBlueprint: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
OptionalClientBlueprint: &networks.NetworkBlueprints_ClientBlueprint{ClientBlueprint: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
},
Parameters: "{ \"raft_timeout\": 9000, \"loss_emulation_percentage\": 1 }",
RelayNodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
Nodes: []*networks.Node{
&networks.Node{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
NodeIp: "100.65.254.2",
Carriers: []*networks.Carrier{
&networks.Carrier{
OptionalAddress: &networks.Carrier_Address{Address: &networks.Address{
Ip: "192.168.1.20",
Port: 3425,
OptionalExternalIp: &networks.Address_ExternalIp{ExternalIp: "203.0.113.10"},
}},
OptionalInterface: &networks.Carrier_Interface{Interface: "eth0"},
OptionalBandwidthPriority: &networks.Carrier_BandwidthPriority{BandwidthPriority: 0},
},
},
Type: networks.NodeType_NODE_TYPE_CLIENT,
Parameters: "{}",
},
},
},
})
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.NewNetworksClient(conn)
response, err := stub.UpdateNetwork(ctx, &networks.UpdateNetworkRequest{
Id: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
Network: &networks.Network{
Name: "Office network",
SubnetCidr: "100.65.254.0/24",
Blueprints: &networks.NetworkBlueprints{
OptionalRelayBlueprint: &networks.NetworkBlueprints_RelayBlueprint{RelayBlueprint: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
OptionalRelayClientBlueprint: &networks.NetworkBlueprints_RelayClientBlueprint{RelayClientBlueprint: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
OptionalClientBlueprint: &networks.NetworkBlueprints_ClientBlueprint{ClientBlueprint: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"},
},
Parameters: "{ \"raft_timeout\": 9000, \"loss_emulation_percentage\": 1 }",
RelayNodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
Nodes: []*networks.Node{
&networks.Node{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
NodeIp: "100.65.254.2",
Carriers: []*networks.Carrier{
&networks.Carrier{
OptionalAddress: &networks.Carrier_Address{Address: &networks.Address{
Ip: "192.168.1.20",
Port: 3425,
OptionalExternalIp: &networks.Address_ExternalIp{ExternalIp: "203.0.113.10"},
}},
OptionalInterface: &networks.Carrier_Interface{Interface: "eth0"},
OptionalBandwidthPriority: &networks.Carrier_BandwidthPriority{BandwidthPriority: 0},
},
},
Type: networks.NodeType_NODE_TYPE_CLIENT,
Parameters: "{}",
},
},
},
})
Delete network
Delete a network.
- REST
- gRPC
/v1/networks/{id}idstringThe ID of the network to delete.
- TypeScript
- Python
- curl
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"
});
from nanoping_api import NanopingClient
client = NanopingClient("http://127.0.0.1:10565")
client.networks.delete_network(id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f")
curl -X DELETE 'http://127.0.0.1:10565/v1/networks/<id>'
No fields.
rpc deleteNetwork(DeleteNetworkRequest) returns (DeleteNetworkResponse)
Method /nanopinggrpc.networks.Networks/deleteNetwork
idstringThe ID of the network to delete.
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.Networks.DeleteNetwork(ctx, &networks.DeleteNetworkRequest{
Id: "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.NewNetworksClient(conn)
_, err = stub.DeleteNetwork(ctx, &networks.DeleteNetworkRequest{
Id: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
})
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.
- REST
- gRPC
/v1/streams/networksServer-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.
- 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.networks.streamNetworks()) {
}
from nanoping_api import NanopingClient
client = NanopingClient("http://127.0.0.1:10565")
for response in client.networks.stream_networks():
print(response)
curl -N 'http://127.0.0.1:10565/v1/streams/networks'
createStreamNetworksCreateEventone of eventA network was created.
updateStreamNetworksUpdateEventone of eventA network was updated.
deleteStreamNetworksDeleteEventone of eventA network was deleted.
rpc streamNetworks(StreamNetworksRequest) returns (stream StreamNetworksEvent)
Method /nanopinggrpc.networks.Networks/streamNetworks
No fields.
createStreamNetworksCreateEventone of eventA network was created.
updateStreamNetworksUpdateEventone of eventA network was updated.
deleteStreamNetworksDeleteEventone of eventA network 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.Networks.StreamNetworks(ctx, &networks.StreamNetworksRequest{})
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.NewNetworksClient(conn)
stream, err := stub.StreamNetworks(ctx, &networks.StreamNetworksRequest{})
for {
response, err := stream.Recv()
if err != nil {
return err
}
}
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.
- REST
- gRPC
/v1/streams/networks/{network_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.
network_idstringThe ID of the network 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.networks.openLogStream({
networkId: "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.networks.open_log_stream(
network_id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
options=Options(lines=0),
):
print(response)
curl -N 'http://127.0.0.1:10565/v1/streams/networks/<network_id>/logs'
messagesMessage[]The log messages.
rpc openLogStream(OpenNetworkLogStreamRequest) returns (stream NetworkLogStreamMessages)
Method /nanopinggrpc.networks.Networks/openLogStream
network_idstringThe ID of the network 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.Networks.OpenLogStream(ctx, &networks.OpenNetworkLogStreamRequest{
NetworkId: "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.NewNetworksClient(conn)
stream, err := stub.OpenLogStream(ctx, &networks.OpenNetworkLogStreamRequest{
NetworkId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
Options: &logging.Options{
OptionalLines: &logging.Options_Lines{Lines: 0},
},
})
for {
response, err := stream.Recv()
if err != nil {
return err
}
}