mirror of
https://github.com/netbirdio/docs.git
synced 2026-04-24 11:26:36 +00:00
3423 lines
68 KiB
Plaintext
3423 lines
68 KiB
Plaintext
export const title = 'Networks'
|
|
|
|
|
|
|
|
## List all Networks {{ tag: 'GET' , label: '/api/networks' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Returns a list of all networks
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="GET" label="/api/networks">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X GET https://api.netbird.io/api/networks \
|
|
-H 'Accept: application/json' \
|
|
-H 'Authorization: Token <TOKEN>'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
|
|
let config = {
|
|
method: 'get',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/networks',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
};
|
|
|
|
axios(config)
|
|
.then((response) => {
|
|
console.log(JSON.stringify(response.data));
|
|
})
|
|
.catch((error) => {
|
|
console.log(error);
|
|
});
|
|
```
|
|
|
|
```python
|
|
import requests
|
|
import json
|
|
|
|
url = "https://api.netbird.io/api/networks"
|
|
|
|
headers = {
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
|
|
response = requests.request("GET", url, headers=headers)
|
|
|
|
print(response.text)
|
|
```
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"net/http"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func main() {
|
|
|
|
url := "https://api.netbird.io/api/networks"
|
|
method := "GET"
|
|
|
|
client := &http.Client {
|
|
}
|
|
req, err := http.NewRequest(method, url, nil)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
{
|
|
|
|
req.Header.Add("Accept", "application/json")
|
|
req.Header.Add("Authorization", "Token <TOKEN>")
|
|
|
|
res, err := client.Do(req)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
defer res.Body.Close()
|
|
|
|
body, err := ioutil.ReadAll(res.Body)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(string(body))
|
|
}
|
|
```
|
|
|
|
```ruby
|
|
require "uri"
|
|
require "json"
|
|
require "net/http"
|
|
|
|
url = URI("https://api.netbird.io/api/networks")
|
|
|
|
https = Net::HTTP.new(url.host, url.port)
|
|
https.use_ssl = true
|
|
|
|
request = Net::HTTP::Get.new(url)
|
|
request["Accept"] = "application/json"
|
|
request["Authorization"] = "Token <TOKEN>"
|
|
|
|
response = https.request(request)
|
|
puts response.read_body
|
|
```
|
|
|
|
```java
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
.build();
|
|
|
|
Request request = new Request.Builder()
|
|
.url("https://api.netbird.io/api/networks")
|
|
.method("GET")
|
|
.addHeader("Accept", "application/json")
|
|
.addHeader("Authorization: Token <TOKEN>")
|
|
.build();
|
|
Response response = client.newCall(request).execute();
|
|
```
|
|
|
|
```php
|
|
<?php
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => 'https://api.netbird.io/api/networks',
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'GET',
|
|
CURLOPT_HTTPHEADER => array(
|
|
'Accept: application/json',
|
|
'Authorization: Token <TOKEN>'
|
|
),
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
curl_close($curl);
|
|
echo $response;
|
|
```
|
|
|
|
</CodeGroup>
|
|
|
|
|
|
<CodeGroup title="Response">
|
|
```json {{ title: 'Example' }}
|
|
[
|
|
{
|
|
"id": "chacdk86lnnboviihd7g",
|
|
"routers": [
|
|
"ch8i4ug6lnn4g9hqv7m0"
|
|
],
|
|
"routing_peers_count": 2,
|
|
"resources": [
|
|
"ch8i4ug6lnn4g9hqv7m1"
|
|
],
|
|
"policies": [
|
|
"ch8i4ug6lnn4g9hqv7m2"
|
|
],
|
|
"name": "Remote Network 1",
|
|
"description": "A remote network that needs to be accessed"
|
|
}
|
|
]
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
[
|
|
{
|
|
"id": "string",
|
|
"routers": [
|
|
"string"
|
|
],
|
|
"routing_peers_count": "integer",
|
|
"resources": [
|
|
"string"
|
|
],
|
|
"policies": [
|
|
"string"
|
|
],
|
|
"name": "string",
|
|
"description": "string"
|
|
}
|
|
]
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## Create a Network {{ tag: 'POST' , label: '/api/networks' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Creates a Network
|
|
|
|
#### Request-Body Parameters
|
|
|
|
<Properties><Property name="name" type="string" required={true}>
|
|
|
|
Network name
|
|
|
|
</Property>
|
|
<Property name="description" type="string" required={false}>
|
|
|
|
Network description
|
|
|
|
</Property>
|
|
</Properties>
|
|
|
|
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="POST" label="/api/networks">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X POST https://api.netbird.io/api/networks \
|
|
-H 'Accept: application/json' \
|
|
-H 'Content-Type: application/json' \
|
|
-H 'Authorization: Token <TOKEN>' \
|
|
--data-raw '{
|
|
"name": "Remote Network 1",
|
|
"description": "A remote network that needs to be accessed"
|
|
}'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
let data = JSON.stringify({
|
|
"name": "Remote Network 1",
|
|
"description": "A remote network that needs to be accessed"
|
|
});
|
|
let config = {
|
|
method: 'post',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/networks',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Content-Type': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
},
|
|
data : data
|
|
};
|
|
|
|
axios(config)
|
|
.then((response) => {
|
|
console.log(JSON.stringify(response.data));
|
|
})
|
|
.catch((error) => {
|
|
console.log(error);
|
|
});
|
|
```
|
|
|
|
```python
|
|
import requests
|
|
import json
|
|
|
|
url = "https://api.netbird.io/api/networks"
|
|
payload = json.dumps({
|
|
"name": "Remote Network 1",
|
|
"description": "A remote network that needs to be accessed"
|
|
})
|
|
headers = {
|
|
'Content-Type': 'application/json',
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
|
|
response = requests.request("POST", url, headers=headers, data=payload)
|
|
|
|
print(response.text)
|
|
```
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"net/http"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func main() {
|
|
|
|
url := "https://api.netbird.io/api/networks"
|
|
method := "POST"
|
|
|
|
payload := strings.NewReader(`{
|
|
"name": "Remote Network 1",
|
|
"description": "A remote network that needs to be accessed"
|
|
}`)
|
|
client := &http.Client {
|
|
}
|
|
req, err := http.NewRequest(method, url, payload)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
{
|
|
|
|
req.Header.Add("Content-Type", "application/json")
|
|
req.Header.Add("Accept", "application/json")
|
|
req.Header.Add("Authorization", "Token <TOKEN>")
|
|
|
|
res, err := client.Do(req)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
defer res.Body.Close()
|
|
|
|
body, err := ioutil.ReadAll(res.Body)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(string(body))
|
|
}
|
|
```
|
|
|
|
```ruby
|
|
require "uri"
|
|
require "json"
|
|
require "net/http"
|
|
|
|
url = URI("https://api.netbird.io/api/networks")
|
|
|
|
https = Net::HTTP.new(url.host, url.port)
|
|
https.use_ssl = true
|
|
|
|
request = Net::HTTP::Post.new(url)
|
|
request["Content-Type"] = "application/json"
|
|
request["Accept"] = "application/json"
|
|
request["Authorization"] = "Token <TOKEN>"
|
|
|
|
request.body = JSON.dump({
|
|
"name": "Remote Network 1",
|
|
"description": "A remote network that needs to be accessed"
|
|
})
|
|
response = https.request(request)
|
|
puts response.read_body
|
|
```
|
|
|
|
```java
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
.build();
|
|
MediaType mediaType = MediaType.parse("application/json");
|
|
RequestBody body = RequestBody.create(mediaType, '{
|
|
"name": "Remote Network 1",
|
|
"description": "A remote network that needs to be accessed"
|
|
}');
|
|
Request request = new Request.Builder()
|
|
.url("https://api.netbird.io/api/networks")
|
|
.method("POST", body)
|
|
.addHeader("Content-Type", "application/json")
|
|
.addHeader("Accept", "application/json")
|
|
.addHeader("Authorization: Token <TOKEN>")
|
|
.build();
|
|
Response response = client.newCall(request).execute();
|
|
```
|
|
|
|
```php
|
|
<?php
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => 'https://api.netbird.io/api/networks',
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'POST',
|
|
CURLOPT_POSTFIELDS => '{
|
|
"name": "Remote Network 1",
|
|
"description": "A remote network that needs to be accessed"
|
|
}',
|
|
CURLOPT_HTTPHEADER => array(
|
|
'Content-Type: application/json',
|
|
'Accept: application/json',
|
|
'Authorization: Token <TOKEN>'
|
|
),
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
curl_close($curl);
|
|
echo $response;
|
|
```
|
|
|
|
</CodeGroup>
|
|
|
|
|
|
<CodeGroup title="Response">
|
|
```json {{ title: 'Example' }}
|
|
{
|
|
"id": "chacdk86lnnboviihd7g",
|
|
"routers": [
|
|
"ch8i4ug6lnn4g9hqv7m0"
|
|
],
|
|
"routing_peers_count": 2,
|
|
"resources": [
|
|
"ch8i4ug6lnn4g9hqv7m1"
|
|
],
|
|
"policies": [
|
|
"ch8i4ug6lnn4g9hqv7m2"
|
|
],
|
|
"name": "Remote Network 1",
|
|
"description": "A remote network that needs to be accessed"
|
|
}
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
{
|
|
"id": "string",
|
|
"routers": [
|
|
"string"
|
|
],
|
|
"routing_peers_count": "integer",
|
|
"resources": [
|
|
"string"
|
|
],
|
|
"policies": [
|
|
"string"
|
|
],
|
|
"name": "string",
|
|
"description": "string"
|
|
}
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## Retrieve a Network {{ tag: 'GET' , label: '/api/networks/{networkId}' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Get information about a Network
|
|
|
|
#### Path Parameters
|
|
<Properties>
|
|
|
|
<Property name="networkId" type="string" required={true}>
|
|
The unique identifier of a network
|
|
</Property>
|
|
</Properties>
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="GET" label="/api/networks/{networkId}">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X GET https://api.netbird.io/api/networks/{networkId} \
|
|
-H 'Accept: application/json' \
|
|
-H 'Authorization: Token <TOKEN>'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
|
|
let config = {
|
|
method: 'get',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/networks/{networkId}',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
};
|
|
|
|
axios(config)
|
|
.then((response) => {
|
|
console.log(JSON.stringify(response.data));
|
|
})
|
|
.catch((error) => {
|
|
console.log(error);
|
|
});
|
|
```
|
|
|
|
```python
|
|
import requests
|
|
import json
|
|
|
|
url = "https://api.netbird.io/api/networks/{networkId}"
|
|
|
|
headers = {
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
|
|
response = requests.request("GET", url, headers=headers)
|
|
|
|
print(response.text)
|
|
```
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"net/http"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func main() {
|
|
|
|
url := "https://api.netbird.io/api/networks/{networkId}"
|
|
method := "GET"
|
|
|
|
client := &http.Client {
|
|
}
|
|
req, err := http.NewRequest(method, url, nil)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
{
|
|
|
|
req.Header.Add("Accept", "application/json")
|
|
req.Header.Add("Authorization", "Token <TOKEN>")
|
|
|
|
res, err := client.Do(req)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
defer res.Body.Close()
|
|
|
|
body, err := ioutil.ReadAll(res.Body)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(string(body))
|
|
}
|
|
```
|
|
|
|
```ruby
|
|
require "uri"
|
|
require "json"
|
|
require "net/http"
|
|
|
|
url = URI("https://api.netbird.io/api/networks/{networkId}")
|
|
|
|
https = Net::HTTP.new(url.host, url.port)
|
|
https.use_ssl = true
|
|
|
|
request = Net::HTTP::Get.new(url)
|
|
request["Accept"] = "application/json"
|
|
request["Authorization"] = "Token <TOKEN>"
|
|
|
|
response = https.request(request)
|
|
puts response.read_body
|
|
```
|
|
|
|
```java
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
.build();
|
|
|
|
Request request = new Request.Builder()
|
|
.url("https://api.netbird.io/api/networks/{networkId}")
|
|
.method("GET")
|
|
.addHeader("Accept", "application/json")
|
|
.addHeader("Authorization: Token <TOKEN>")
|
|
.build();
|
|
Response response = client.newCall(request).execute();
|
|
```
|
|
|
|
```php
|
|
<?php
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => 'https://api.netbird.io/api/networks/{networkId}',
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'GET',
|
|
CURLOPT_HTTPHEADER => array(
|
|
'Accept: application/json',
|
|
'Authorization: Token <TOKEN>'
|
|
),
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
curl_close($curl);
|
|
echo $response;
|
|
```
|
|
|
|
</CodeGroup>
|
|
|
|
|
|
<CodeGroup title="Response">
|
|
```json {{ title: 'Example' }}
|
|
{
|
|
"id": "chacdk86lnnboviihd7g",
|
|
"routers": [
|
|
"ch8i4ug6lnn4g9hqv7m0"
|
|
],
|
|
"routing_peers_count": 2,
|
|
"resources": [
|
|
"ch8i4ug6lnn4g9hqv7m1"
|
|
],
|
|
"policies": [
|
|
"ch8i4ug6lnn4g9hqv7m2"
|
|
],
|
|
"name": "Remote Network 1",
|
|
"description": "A remote network that needs to be accessed"
|
|
}
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
{
|
|
"id": "string",
|
|
"routers": [
|
|
"string"
|
|
],
|
|
"routing_peers_count": "integer",
|
|
"resources": [
|
|
"string"
|
|
],
|
|
"policies": [
|
|
"string"
|
|
],
|
|
"name": "string",
|
|
"description": "string"
|
|
}
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## Update a Network {{ tag: 'PUT' , label: '/api/networks/{networkId}' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Update/Replace a Network
|
|
|
|
#### Path Parameters
|
|
<Properties>
|
|
|
|
<Property name="networkId" type="string" required={true}>
|
|
The unique identifier of a network
|
|
</Property>
|
|
</Properties>
|
|
|
|
#### Request-Body Parameters
|
|
|
|
<Properties><Property name="name" type="string" required={true}>
|
|
|
|
Network name
|
|
|
|
</Property>
|
|
<Property name="description" type="string" required={false}>
|
|
|
|
Network description
|
|
|
|
</Property>
|
|
</Properties>
|
|
|
|
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="PUT" label="/api/networks/{networkId}">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X PUT https://api.netbird.io/api/networks/{networkId} \
|
|
-H 'Accept: application/json' \
|
|
-H 'Content-Type: application/json' \
|
|
-H 'Authorization: Token <TOKEN>' \
|
|
--data-raw '{
|
|
"name": "Remote Network 1",
|
|
"description": "A remote network that needs to be accessed"
|
|
}'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
let data = JSON.stringify({
|
|
"name": "Remote Network 1",
|
|
"description": "A remote network that needs to be accessed"
|
|
});
|
|
let config = {
|
|
method: 'put',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/networks/{networkId}',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Content-Type': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
},
|
|
data : data
|
|
};
|
|
|
|
axios(config)
|
|
.then((response) => {
|
|
console.log(JSON.stringify(response.data));
|
|
})
|
|
.catch((error) => {
|
|
console.log(error);
|
|
});
|
|
```
|
|
|
|
```python
|
|
import requests
|
|
import json
|
|
|
|
url = "https://api.netbird.io/api/networks/{networkId}"
|
|
payload = json.dumps({
|
|
"name": "Remote Network 1",
|
|
"description": "A remote network that needs to be accessed"
|
|
})
|
|
headers = {
|
|
'Content-Type': 'application/json',
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
|
|
response = requests.request("PUT", url, headers=headers, data=payload)
|
|
|
|
print(response.text)
|
|
```
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"net/http"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func main() {
|
|
|
|
url := "https://api.netbird.io/api/networks/{networkId}"
|
|
method := "PUT"
|
|
|
|
payload := strings.NewReader(`{
|
|
"name": "Remote Network 1",
|
|
"description": "A remote network that needs to be accessed"
|
|
}`)
|
|
client := &http.Client {
|
|
}
|
|
req, err := http.NewRequest(method, url, payload)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
{
|
|
|
|
req.Header.Add("Content-Type", "application/json")
|
|
req.Header.Add("Accept", "application/json")
|
|
req.Header.Add("Authorization", "Token <TOKEN>")
|
|
|
|
res, err := client.Do(req)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
defer res.Body.Close()
|
|
|
|
body, err := ioutil.ReadAll(res.Body)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(string(body))
|
|
}
|
|
```
|
|
|
|
```ruby
|
|
require "uri"
|
|
require "json"
|
|
require "net/http"
|
|
|
|
url = URI("https://api.netbird.io/api/networks/{networkId}")
|
|
|
|
https = Net::HTTP.new(url.host, url.port)
|
|
https.use_ssl = true
|
|
|
|
request = Net::HTTP::Put.new(url)
|
|
request["Content-Type"] = "application/json"
|
|
request["Accept"] = "application/json"
|
|
request["Authorization"] = "Token <TOKEN>"
|
|
|
|
request.body = JSON.dump({
|
|
"name": "Remote Network 1",
|
|
"description": "A remote network that needs to be accessed"
|
|
})
|
|
response = https.request(request)
|
|
puts response.read_body
|
|
```
|
|
|
|
```java
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
.build();
|
|
MediaType mediaType = MediaType.parse("application/json");
|
|
RequestBody body = RequestBody.create(mediaType, '{
|
|
"name": "Remote Network 1",
|
|
"description": "A remote network that needs to be accessed"
|
|
}');
|
|
Request request = new Request.Builder()
|
|
.url("https://api.netbird.io/api/networks/{networkId}")
|
|
.method("PUT", body)
|
|
.addHeader("Content-Type", "application/json")
|
|
.addHeader("Accept", "application/json")
|
|
.addHeader("Authorization: Token <TOKEN>")
|
|
.build();
|
|
Response response = client.newCall(request).execute();
|
|
```
|
|
|
|
```php
|
|
<?php
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => 'https://api.netbird.io/api/networks/{networkId}',
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'PUT',
|
|
CURLOPT_POSTFIELDS => '{
|
|
"name": "Remote Network 1",
|
|
"description": "A remote network that needs to be accessed"
|
|
}',
|
|
CURLOPT_HTTPHEADER => array(
|
|
'Content-Type: application/json',
|
|
'Accept: application/json',
|
|
'Authorization: Token <TOKEN>'
|
|
),
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
curl_close($curl);
|
|
echo $response;
|
|
```
|
|
|
|
</CodeGroup>
|
|
|
|
|
|
<CodeGroup title="Response">
|
|
```json {{ title: 'Example' }}
|
|
{
|
|
"id": "chacdk86lnnboviihd7g",
|
|
"routers": [
|
|
"ch8i4ug6lnn4g9hqv7m0"
|
|
],
|
|
"routing_peers_count": 2,
|
|
"resources": [
|
|
"ch8i4ug6lnn4g9hqv7m1"
|
|
],
|
|
"policies": [
|
|
"ch8i4ug6lnn4g9hqv7m2"
|
|
],
|
|
"name": "Remote Network 1",
|
|
"description": "A remote network that needs to be accessed"
|
|
}
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
{
|
|
"id": "string",
|
|
"routers": [
|
|
"string"
|
|
],
|
|
"routing_peers_count": "integer",
|
|
"resources": [
|
|
"string"
|
|
],
|
|
"policies": [
|
|
"string"
|
|
],
|
|
"name": "string",
|
|
"description": "string"
|
|
}
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## Delete a Network {{ tag: 'DELETE' , label: '/api/networks/{networkId}' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Delete a network
|
|
|
|
#### Path Parameters
|
|
<Properties>
|
|
|
|
<Property name="networkId" type="string" required={true}>
|
|
The unique identifier of a network
|
|
</Property>
|
|
</Properties>
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="DELETE" label="/api/networks/{networkId}">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X DELETE https://api.netbird.io/api/networks/{networkId} \
|
|
-H 'Authorization: Token <TOKEN>'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
|
|
let config = {
|
|
method: 'delete',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/networks/{networkId}',
|
|
headers: {
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
};
|
|
|
|
axios(config)
|
|
.then((response) => {
|
|
console.log(JSON.stringify(response.data));
|
|
})
|
|
.catch((error) => {
|
|
console.log(error);
|
|
});
|
|
```
|
|
|
|
```python
|
|
import requests
|
|
import json
|
|
|
|
url = "https://api.netbird.io/api/networks/{networkId}"
|
|
|
|
headers = {
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
|
|
response = requests.request("DELETE", url, headers=headers)
|
|
|
|
print(response.text)
|
|
```
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"net/http"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func main() {
|
|
|
|
url := "https://api.netbird.io/api/networks/{networkId}"
|
|
method := "DELETE"
|
|
|
|
client := &http.Client {
|
|
}
|
|
req, err := http.NewRequest(method, url, nil)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
{
|
|
|
|
req.Header.Add("Authorization", "Token <TOKEN>")
|
|
|
|
res, err := client.Do(req)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
defer res.Body.Close()
|
|
|
|
body, err := ioutil.ReadAll(res.Body)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(string(body))
|
|
}
|
|
```
|
|
|
|
```ruby
|
|
require "uri"
|
|
require "json"
|
|
require "net/http"
|
|
|
|
url = URI("https://api.netbird.io/api/networks/{networkId}")
|
|
|
|
https = Net::HTTP.new(url.host, url.port)
|
|
https.use_ssl = true
|
|
|
|
request = Net::HTTP::Delete.new(url)
|
|
request["Authorization"] = "Token <TOKEN>"
|
|
|
|
response = https.request(request)
|
|
puts response.read_body
|
|
```
|
|
|
|
```java
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
.build();
|
|
|
|
Request request = new Request.Builder()
|
|
.url("https://api.netbird.io/api/networks/{networkId}")
|
|
.method("DELETE")
|
|
.addHeader("Authorization: Token <TOKEN>")
|
|
.build();
|
|
Response response = client.newCall(request).execute();
|
|
```
|
|
|
|
```php
|
|
<?php
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => 'https://api.netbird.io/api/networks/{networkId}',
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'DELETE',
|
|
CURLOPT_HTTPHEADER => array(
|
|
'Authorization: Token <TOKEN>'
|
|
),
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
curl_close($curl);
|
|
echo $response;
|
|
```
|
|
|
|
</CodeGroup>
|
|
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## List all Network Resources {{ tag: 'GET' , label: '/api/networks/{networkId}/resources' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Returns a list of all resources in a network
|
|
|
|
#### Path Parameters
|
|
<Properties>
|
|
|
|
<Property name="networkId" type="string" required={true}>
|
|
The unique identifier of a network
|
|
</Property>
|
|
</Properties>
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="GET" label="/api/networks/{networkId}/resources">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X GET https://api.netbird.io/api/networks/{networkId}/resources \
|
|
-H 'Accept: application/json' \
|
|
-H 'Authorization: Token <TOKEN>'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
|
|
let config = {
|
|
method: 'get',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/networks/{networkId}/resources',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
};
|
|
|
|
axios(config)
|
|
.then((response) => {
|
|
console.log(JSON.stringify(response.data));
|
|
})
|
|
.catch((error) => {
|
|
console.log(error);
|
|
});
|
|
```
|
|
|
|
```python
|
|
import requests
|
|
import json
|
|
|
|
url = "https://api.netbird.io/api/networks/{networkId}/resources"
|
|
|
|
headers = {
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
|
|
response = requests.request("GET", url, headers=headers)
|
|
|
|
print(response.text)
|
|
```
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"net/http"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func main() {
|
|
|
|
url := "https://api.netbird.io/api/networks/{networkId}/resources"
|
|
method := "GET"
|
|
|
|
client := &http.Client {
|
|
}
|
|
req, err := http.NewRequest(method, url, nil)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
{
|
|
|
|
req.Header.Add("Accept", "application/json")
|
|
req.Header.Add("Authorization", "Token <TOKEN>")
|
|
|
|
res, err := client.Do(req)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
defer res.Body.Close()
|
|
|
|
body, err := ioutil.ReadAll(res.Body)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(string(body))
|
|
}
|
|
```
|
|
|
|
```ruby
|
|
require "uri"
|
|
require "json"
|
|
require "net/http"
|
|
|
|
url = URI("https://api.netbird.io/api/networks/{networkId}/resources")
|
|
|
|
https = Net::HTTP.new(url.host, url.port)
|
|
https.use_ssl = true
|
|
|
|
request = Net::HTTP::Get.new(url)
|
|
request["Accept"] = "application/json"
|
|
request["Authorization"] = "Token <TOKEN>"
|
|
|
|
response = https.request(request)
|
|
puts response.read_body
|
|
```
|
|
|
|
```java
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
.build();
|
|
|
|
Request request = new Request.Builder()
|
|
.url("https://api.netbird.io/api/networks/{networkId}/resources")
|
|
.method("GET")
|
|
.addHeader("Accept", "application/json")
|
|
.addHeader("Authorization: Token <TOKEN>")
|
|
.build();
|
|
Response response = client.newCall(request).execute();
|
|
```
|
|
|
|
```php
|
|
<?php
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => 'https://api.netbird.io/api/networks/{networkId}/resources',
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'GET',
|
|
CURLOPT_HTTPHEADER => array(
|
|
'Accept: application/json',
|
|
'Authorization: Token <TOKEN>'
|
|
),
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
curl_close($curl);
|
|
echo $response;
|
|
```
|
|
|
|
</CodeGroup>
|
|
|
|
|
|
<CodeGroup title="Response">
|
|
```json {{ title: 'Example' }}
|
|
[
|
|
{
|
|
"id": "chacdk86lnnboviihd7g",
|
|
"type": "host",
|
|
"groups": [
|
|
{
|
|
"id": "ch8i4ug6lnn4g9hqv7m0",
|
|
"name": "devs",
|
|
"peers_count": 2,
|
|
"resources_count": 5,
|
|
"issued": "api"
|
|
}
|
|
],
|
|
"name": "Remote Resource 1",
|
|
"description": "A remote resource inside network 1",
|
|
"address": "1.1.1.1"
|
|
}
|
|
]
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
[
|
|
{
|
|
"id": "string",
|
|
"type": "string",
|
|
"groups": [
|
|
{
|
|
"id": "string",
|
|
"name": "string",
|
|
"peers_count": "integer",
|
|
"resources_count": "integer",
|
|
"issued": "string"
|
|
}
|
|
],
|
|
"name": "string",
|
|
"description": "string",
|
|
"address": "string"
|
|
}
|
|
]
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## Create a Network Resource {{ tag: 'POST' , label: '/api/networks/{networkId}/resources' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Creates a Network Resource
|
|
|
|
#### Path Parameters
|
|
<Properties>
|
|
|
|
<Property name="networkId" type="string" required={true}>
|
|
The unique identifier of a network
|
|
</Property>
|
|
</Properties>
|
|
|
|
#### Request-Body Parameters
|
|
|
|
<Properties><Property name="name" type="string" required={true}>
|
|
|
|
Network resource name
|
|
|
|
</Property>
|
|
<Property name="description" type="string" required={false}>
|
|
|
|
Network resource description
|
|
|
|
</Property>
|
|
<Property name="address" type="string" required={true}>
|
|
|
|
Network resource address (either a direct host like 1.1.1.1 or 1.1.1.1/32, or a subnet like 192.168.178.0/24, or domains like example.com and *.example.com)
|
|
|
|
</Property>
|
|
<Property name="groups" type="string[]" required={true}>
|
|
|
|
Group IDs containing the resource
|
|
|
|
</Property>
|
|
</Properties>
|
|
|
|
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="POST" label="/api/networks/{networkId}/resources">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X POST https://api.netbird.io/api/networks/{networkId}/resources \
|
|
-H 'Accept: application/json' \
|
|
-H 'Content-Type: application/json' \
|
|
-H 'Authorization: Token <TOKEN>' \
|
|
--data-raw '{
|
|
"name": "Remote Resource 1",
|
|
"description": "A remote resource inside network 1",
|
|
"address": "1.1.1.1",
|
|
"groups": [
|
|
"chacdk86lnnboviihd70"
|
|
]
|
|
}'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
let data = JSON.stringify({
|
|
"name": "Remote Resource 1",
|
|
"description": "A remote resource inside network 1",
|
|
"address": "1.1.1.1",
|
|
"groups": [
|
|
"chacdk86lnnboviihd70"
|
|
]
|
|
});
|
|
let config = {
|
|
method: 'post',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/networks/{networkId}/resources',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Content-Type': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
},
|
|
data : data
|
|
};
|
|
|
|
axios(config)
|
|
.then((response) => {
|
|
console.log(JSON.stringify(response.data));
|
|
})
|
|
.catch((error) => {
|
|
console.log(error);
|
|
});
|
|
```
|
|
|
|
```python
|
|
import requests
|
|
import json
|
|
|
|
url = "https://api.netbird.io/api/networks/{networkId}/resources"
|
|
payload = json.dumps({
|
|
"name": "Remote Resource 1",
|
|
"description": "A remote resource inside network 1",
|
|
"address": "1.1.1.1",
|
|
"groups": [
|
|
"chacdk86lnnboviihd70"
|
|
]
|
|
})
|
|
headers = {
|
|
'Content-Type': 'application/json',
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
|
|
response = requests.request("POST", url, headers=headers, data=payload)
|
|
|
|
print(response.text)
|
|
```
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"net/http"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func main() {
|
|
|
|
url := "https://api.netbird.io/api/networks/{networkId}/resources"
|
|
method := "POST"
|
|
|
|
payload := strings.NewReader(`{
|
|
"name": "Remote Resource 1",
|
|
"description": "A remote resource inside network 1",
|
|
"address": "1.1.1.1",
|
|
"groups": [
|
|
"chacdk86lnnboviihd70"
|
|
]
|
|
}`)
|
|
client := &http.Client {
|
|
}
|
|
req, err := http.NewRequest(method, url, payload)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
{
|
|
|
|
req.Header.Add("Content-Type", "application/json")
|
|
req.Header.Add("Accept", "application/json")
|
|
req.Header.Add("Authorization", "Token <TOKEN>")
|
|
|
|
res, err := client.Do(req)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
defer res.Body.Close()
|
|
|
|
body, err := ioutil.ReadAll(res.Body)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(string(body))
|
|
}
|
|
```
|
|
|
|
```ruby
|
|
require "uri"
|
|
require "json"
|
|
require "net/http"
|
|
|
|
url = URI("https://api.netbird.io/api/networks/{networkId}/resources")
|
|
|
|
https = Net::HTTP.new(url.host, url.port)
|
|
https.use_ssl = true
|
|
|
|
request = Net::HTTP::Post.new(url)
|
|
request["Content-Type"] = "application/json"
|
|
request["Accept"] = "application/json"
|
|
request["Authorization"] = "Token <TOKEN>"
|
|
|
|
request.body = JSON.dump({
|
|
"name": "Remote Resource 1",
|
|
"description": "A remote resource inside network 1",
|
|
"address": "1.1.1.1",
|
|
"groups": [
|
|
"chacdk86lnnboviihd70"
|
|
]
|
|
})
|
|
response = https.request(request)
|
|
puts response.read_body
|
|
```
|
|
|
|
```java
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
.build();
|
|
MediaType mediaType = MediaType.parse("application/json");
|
|
RequestBody body = RequestBody.create(mediaType, '{
|
|
"name": "Remote Resource 1",
|
|
"description": "A remote resource inside network 1",
|
|
"address": "1.1.1.1",
|
|
"groups": [
|
|
"chacdk86lnnboviihd70"
|
|
]
|
|
}');
|
|
Request request = new Request.Builder()
|
|
.url("https://api.netbird.io/api/networks/{networkId}/resources")
|
|
.method("POST", body)
|
|
.addHeader("Content-Type", "application/json")
|
|
.addHeader("Accept", "application/json")
|
|
.addHeader("Authorization: Token <TOKEN>")
|
|
.build();
|
|
Response response = client.newCall(request).execute();
|
|
```
|
|
|
|
```php
|
|
<?php
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => 'https://api.netbird.io/api/networks/{networkId}/resources',
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'POST',
|
|
CURLOPT_POSTFIELDS => '{
|
|
"name": "Remote Resource 1",
|
|
"description": "A remote resource inside network 1",
|
|
"address": "1.1.1.1",
|
|
"groups": [
|
|
"chacdk86lnnboviihd70"
|
|
]
|
|
}',
|
|
CURLOPT_HTTPHEADER => array(
|
|
'Content-Type: application/json',
|
|
'Accept: application/json',
|
|
'Authorization: Token <TOKEN>'
|
|
),
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
curl_close($curl);
|
|
echo $response;
|
|
```
|
|
|
|
</CodeGroup>
|
|
|
|
|
|
<CodeGroup title="Response">
|
|
```json {{ title: 'Example' }}
|
|
{
|
|
"id": "chacdk86lnnboviihd7g",
|
|
"type": "host",
|
|
"groups": [
|
|
{
|
|
"id": "ch8i4ug6lnn4g9hqv7m0",
|
|
"name": "devs",
|
|
"peers_count": 2,
|
|
"resources_count": 5,
|
|
"issued": "api"
|
|
}
|
|
],
|
|
"name": "Remote Resource 1",
|
|
"description": "A remote resource inside network 1",
|
|
"address": "1.1.1.1"
|
|
}
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
{
|
|
"id": "string",
|
|
"type": "string",
|
|
"groups": [
|
|
{
|
|
"id": "string",
|
|
"name": "string",
|
|
"peers_count": "integer",
|
|
"resources_count": "integer",
|
|
"issued": "string"
|
|
}
|
|
],
|
|
"name": "string",
|
|
"description": "string",
|
|
"address": "string"
|
|
}
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## Retrieve a Network Resource {{ tag: 'GET' , label: '/api/networks/{networkId}/resources/{resourceId}' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Get information about a Network Resource
|
|
|
|
#### Path Parameters
|
|
<Properties>
|
|
|
|
<Property name="networkId" type="string" required={true}>
|
|
The unique identifier of a network
|
|
</Property>
|
|
|
|
<Property name="resourceId" type="string" required={true}>
|
|
The unique identifier of a network resource
|
|
</Property>
|
|
</Properties>
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="GET" label="/api/networks/{networkId}/resources/{resourceId}">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X GET https://api.netbird.io/api/networks/{networkId}/resources/{resourceId} \
|
|
-H 'Accept: application/json' \
|
|
-H 'Authorization: Token <TOKEN>'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
|
|
let config = {
|
|
method: 'get',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/networks/{networkId}/resources/{resourceId}',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
};
|
|
|
|
axios(config)
|
|
.then((response) => {
|
|
console.log(JSON.stringify(response.data));
|
|
})
|
|
.catch((error) => {
|
|
console.log(error);
|
|
});
|
|
```
|
|
|
|
```python
|
|
import requests
|
|
import json
|
|
|
|
url = "https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}"
|
|
|
|
headers = {
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
|
|
response = requests.request("GET", url, headers=headers)
|
|
|
|
print(response.text)
|
|
```
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"net/http"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func main() {
|
|
|
|
url := "https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}"
|
|
method := "GET"
|
|
|
|
client := &http.Client {
|
|
}
|
|
req, err := http.NewRequest(method, url, nil)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
{
|
|
|
|
req.Header.Add("Accept", "application/json")
|
|
req.Header.Add("Authorization", "Token <TOKEN>")
|
|
|
|
res, err := client.Do(req)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
defer res.Body.Close()
|
|
|
|
body, err := ioutil.ReadAll(res.Body)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(string(body))
|
|
}
|
|
```
|
|
|
|
```ruby
|
|
require "uri"
|
|
require "json"
|
|
require "net/http"
|
|
|
|
url = URI("https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}")
|
|
|
|
https = Net::HTTP.new(url.host, url.port)
|
|
https.use_ssl = true
|
|
|
|
request = Net::HTTP::Get.new(url)
|
|
request["Accept"] = "application/json"
|
|
request["Authorization"] = "Token <TOKEN>"
|
|
|
|
response = https.request(request)
|
|
puts response.read_body
|
|
```
|
|
|
|
```java
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
.build();
|
|
|
|
Request request = new Request.Builder()
|
|
.url("https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}")
|
|
.method("GET")
|
|
.addHeader("Accept", "application/json")
|
|
.addHeader("Authorization: Token <TOKEN>")
|
|
.build();
|
|
Response response = client.newCall(request).execute();
|
|
```
|
|
|
|
```php
|
|
<?php
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => 'https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}',
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'GET',
|
|
CURLOPT_HTTPHEADER => array(
|
|
'Accept: application/json',
|
|
'Authorization: Token <TOKEN>'
|
|
),
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
curl_close($curl);
|
|
echo $response;
|
|
```
|
|
|
|
</CodeGroup>
|
|
|
|
|
|
<CodeGroup title="Response">
|
|
```json {{ title: 'Example' }}
|
|
{
|
|
"id": "chacdk86lnnboviihd7g",
|
|
"type": "host",
|
|
"groups": [
|
|
{
|
|
"id": "ch8i4ug6lnn4g9hqv7m0",
|
|
"name": "devs",
|
|
"peers_count": 2,
|
|
"resources_count": 5,
|
|
"issued": "api"
|
|
}
|
|
],
|
|
"name": "Remote Resource 1",
|
|
"description": "A remote resource inside network 1",
|
|
"address": "1.1.1.1"
|
|
}
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
{
|
|
"id": "string",
|
|
"type": "string",
|
|
"groups": [
|
|
{
|
|
"id": "string",
|
|
"name": "string",
|
|
"peers_count": "integer",
|
|
"resources_count": "integer",
|
|
"issued": "string"
|
|
}
|
|
],
|
|
"name": "string",
|
|
"description": "string",
|
|
"address": "string"
|
|
}
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## Update a Network Resource {{ tag: 'PUT' , label: '/api/networks/{networkId}/resources/{resourceId}' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Update a Network Resource
|
|
|
|
#### Path Parameters
|
|
<Properties>
|
|
|
|
<Property name="networkId" type="string" required={true}>
|
|
The unique identifier of a network
|
|
</Property>
|
|
|
|
<Property name="resourceId" type="string" required={true}>
|
|
The unique identifier of a resource
|
|
</Property>
|
|
</Properties>
|
|
|
|
#### Request-Body Parameters
|
|
|
|
<Properties><Property name="name" type="string" required={true}>
|
|
|
|
Network resource name
|
|
|
|
</Property>
|
|
<Property name="description" type="string" required={false}>
|
|
|
|
Network resource description
|
|
|
|
</Property>
|
|
<Property name="address" type="string" required={true}>
|
|
|
|
Network resource address (either a direct host like 1.1.1.1 or 1.1.1.1/32, or a subnet like 192.168.178.0/24, or domains like example.com and *.example.com)
|
|
|
|
</Property>
|
|
<Property name="groups" type="string[]" required={true}>
|
|
|
|
Group IDs containing the resource
|
|
|
|
</Property>
|
|
</Properties>
|
|
|
|
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="PUT" label="/api/networks/{networkId}/resources/{resourceId}">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X PUT https://api.netbird.io/api/networks/{networkId}/resources/{resourceId} \
|
|
-H 'Accept: application/json' \
|
|
-H 'Content-Type: application/json' \
|
|
-H 'Authorization: Token <TOKEN>' \
|
|
--data-raw '{
|
|
"name": "Remote Resource 1",
|
|
"description": "A remote resource inside network 1",
|
|
"address": "1.1.1.1",
|
|
"groups": [
|
|
"chacdk86lnnboviihd70"
|
|
]
|
|
}'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
let data = JSON.stringify({
|
|
"name": "Remote Resource 1",
|
|
"description": "A remote resource inside network 1",
|
|
"address": "1.1.1.1",
|
|
"groups": [
|
|
"chacdk86lnnboviihd70"
|
|
]
|
|
});
|
|
let config = {
|
|
method: 'put',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/networks/{networkId}/resources/{resourceId}',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Content-Type': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
},
|
|
data : data
|
|
};
|
|
|
|
axios(config)
|
|
.then((response) => {
|
|
console.log(JSON.stringify(response.data));
|
|
})
|
|
.catch((error) => {
|
|
console.log(error);
|
|
});
|
|
```
|
|
|
|
```python
|
|
import requests
|
|
import json
|
|
|
|
url = "https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}"
|
|
payload = json.dumps({
|
|
"name": "Remote Resource 1",
|
|
"description": "A remote resource inside network 1",
|
|
"address": "1.1.1.1",
|
|
"groups": [
|
|
"chacdk86lnnboviihd70"
|
|
]
|
|
})
|
|
headers = {
|
|
'Content-Type': 'application/json',
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
|
|
response = requests.request("PUT", url, headers=headers, data=payload)
|
|
|
|
print(response.text)
|
|
```
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"net/http"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func main() {
|
|
|
|
url := "https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}"
|
|
method := "PUT"
|
|
|
|
payload := strings.NewReader(`{
|
|
"name": "Remote Resource 1",
|
|
"description": "A remote resource inside network 1",
|
|
"address": "1.1.1.1",
|
|
"groups": [
|
|
"chacdk86lnnboviihd70"
|
|
]
|
|
}`)
|
|
client := &http.Client {
|
|
}
|
|
req, err := http.NewRequest(method, url, payload)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
{
|
|
|
|
req.Header.Add("Content-Type", "application/json")
|
|
req.Header.Add("Accept", "application/json")
|
|
req.Header.Add("Authorization", "Token <TOKEN>")
|
|
|
|
res, err := client.Do(req)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
defer res.Body.Close()
|
|
|
|
body, err := ioutil.ReadAll(res.Body)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(string(body))
|
|
}
|
|
```
|
|
|
|
```ruby
|
|
require "uri"
|
|
require "json"
|
|
require "net/http"
|
|
|
|
url = URI("https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}")
|
|
|
|
https = Net::HTTP.new(url.host, url.port)
|
|
https.use_ssl = true
|
|
|
|
request = Net::HTTP::Put.new(url)
|
|
request["Content-Type"] = "application/json"
|
|
request["Accept"] = "application/json"
|
|
request["Authorization"] = "Token <TOKEN>"
|
|
|
|
request.body = JSON.dump({
|
|
"name": "Remote Resource 1",
|
|
"description": "A remote resource inside network 1",
|
|
"address": "1.1.1.1",
|
|
"groups": [
|
|
"chacdk86lnnboviihd70"
|
|
]
|
|
})
|
|
response = https.request(request)
|
|
puts response.read_body
|
|
```
|
|
|
|
```java
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
.build();
|
|
MediaType mediaType = MediaType.parse("application/json");
|
|
RequestBody body = RequestBody.create(mediaType, '{
|
|
"name": "Remote Resource 1",
|
|
"description": "A remote resource inside network 1",
|
|
"address": "1.1.1.1",
|
|
"groups": [
|
|
"chacdk86lnnboviihd70"
|
|
]
|
|
}');
|
|
Request request = new Request.Builder()
|
|
.url("https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}")
|
|
.method("PUT", body)
|
|
.addHeader("Content-Type", "application/json")
|
|
.addHeader("Accept", "application/json")
|
|
.addHeader("Authorization: Token <TOKEN>")
|
|
.build();
|
|
Response response = client.newCall(request).execute();
|
|
```
|
|
|
|
```php
|
|
<?php
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => 'https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}',
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'PUT',
|
|
CURLOPT_POSTFIELDS => '{
|
|
"name": "Remote Resource 1",
|
|
"description": "A remote resource inside network 1",
|
|
"address": "1.1.1.1",
|
|
"groups": [
|
|
"chacdk86lnnboviihd70"
|
|
]
|
|
}',
|
|
CURLOPT_HTTPHEADER => array(
|
|
'Content-Type: application/json',
|
|
'Accept: application/json',
|
|
'Authorization: Token <TOKEN>'
|
|
),
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
curl_close($curl);
|
|
echo $response;
|
|
```
|
|
|
|
</CodeGroup>
|
|
|
|
|
|
<CodeGroup title="Response">
|
|
```json {{ title: 'Example' }}
|
|
{
|
|
"id": "chacdk86lnnboviihd7g",
|
|
"type": "host",
|
|
"groups": [
|
|
{
|
|
"id": "ch8i4ug6lnn4g9hqv7m0",
|
|
"name": "devs",
|
|
"peers_count": 2,
|
|
"resources_count": 5,
|
|
"issued": "api"
|
|
}
|
|
],
|
|
"name": "Remote Resource 1",
|
|
"description": "A remote resource inside network 1",
|
|
"address": "1.1.1.1"
|
|
}
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
{
|
|
"id": "string",
|
|
"type": "string",
|
|
"groups": [
|
|
{
|
|
"id": "string",
|
|
"name": "string",
|
|
"peers_count": "integer",
|
|
"resources_count": "integer",
|
|
"issued": "string"
|
|
}
|
|
],
|
|
"name": "string",
|
|
"description": "string",
|
|
"address": "string"
|
|
}
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## Delete a Network Resource {{ tag: 'DELETE' , label: '/api/networks/{networkId}/resources/{resourceId}' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Delete a network resource
|
|
|
|
#### Path Parameters
|
|
<Properties>
|
|
|
|
<Property name="networkId" type="string" required={true}>
|
|
|
|
</Property>
|
|
|
|
<Property name="resourceId" type="string" required={true}>
|
|
|
|
</Property>
|
|
</Properties>
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="DELETE" label="/api/networks/{networkId}/resources/{resourceId}">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X DELETE https://api.netbird.io/api/networks/{networkId}/resources/{resourceId} \
|
|
-H 'Authorization: Token <TOKEN>'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
|
|
let config = {
|
|
method: 'delete',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/networks/{networkId}/resources/{resourceId}',
|
|
headers: {
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
};
|
|
|
|
axios(config)
|
|
.then((response) => {
|
|
console.log(JSON.stringify(response.data));
|
|
})
|
|
.catch((error) => {
|
|
console.log(error);
|
|
});
|
|
```
|
|
|
|
```python
|
|
import requests
|
|
import json
|
|
|
|
url = "https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}"
|
|
|
|
headers = {
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
|
|
response = requests.request("DELETE", url, headers=headers)
|
|
|
|
print(response.text)
|
|
```
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"net/http"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func main() {
|
|
|
|
url := "https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}"
|
|
method := "DELETE"
|
|
|
|
client := &http.Client {
|
|
}
|
|
req, err := http.NewRequest(method, url, nil)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
{
|
|
|
|
req.Header.Add("Authorization", "Token <TOKEN>")
|
|
|
|
res, err := client.Do(req)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
defer res.Body.Close()
|
|
|
|
body, err := ioutil.ReadAll(res.Body)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(string(body))
|
|
}
|
|
```
|
|
|
|
```ruby
|
|
require "uri"
|
|
require "json"
|
|
require "net/http"
|
|
|
|
url = URI("https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}")
|
|
|
|
https = Net::HTTP.new(url.host, url.port)
|
|
https.use_ssl = true
|
|
|
|
request = Net::HTTP::Delete.new(url)
|
|
request["Authorization"] = "Token <TOKEN>"
|
|
|
|
response = https.request(request)
|
|
puts response.read_body
|
|
```
|
|
|
|
```java
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
.build();
|
|
|
|
Request request = new Request.Builder()
|
|
.url("https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}")
|
|
.method("DELETE")
|
|
.addHeader("Authorization: Token <TOKEN>")
|
|
.build();
|
|
Response response = client.newCall(request).execute();
|
|
```
|
|
|
|
```php
|
|
<?php
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => 'https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}',
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'DELETE',
|
|
CURLOPT_HTTPHEADER => array(
|
|
'Authorization: Token <TOKEN>'
|
|
),
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
curl_close($curl);
|
|
echo $response;
|
|
```
|
|
|
|
</CodeGroup>
|
|
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## List all Network Routers {{ tag: 'GET' , label: '/api/networks/{networkId}/routers' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Returns a list of all routers in a network
|
|
|
|
#### Path Parameters
|
|
<Properties>
|
|
|
|
<Property name="networkId" type="string" required={true}>
|
|
The unique identifier of a network
|
|
</Property>
|
|
</Properties>
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="GET" label="/api/networks/{networkId}/routers">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X GET https://api.netbird.io/api/networks/{networkId}/routers \
|
|
-H 'Accept: application/json' \
|
|
-H 'Authorization: Token <TOKEN>'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
|
|
let config = {
|
|
method: 'get',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/networks/{networkId}/routers',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
};
|
|
|
|
axios(config)
|
|
.then((response) => {
|
|
console.log(JSON.stringify(response.data));
|
|
})
|
|
.catch((error) => {
|
|
console.log(error);
|
|
});
|
|
```
|
|
|
|
```python
|
|
import requests
|
|
import json
|
|
|
|
url = "https://api.netbird.io/api/networks/{networkId}/routers"
|
|
|
|
headers = {
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
|
|
response = requests.request("GET", url, headers=headers)
|
|
|
|
print(response.text)
|
|
```
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"net/http"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func main() {
|
|
|
|
url := "https://api.netbird.io/api/networks/{networkId}/routers"
|
|
method := "GET"
|
|
|
|
client := &http.Client {
|
|
}
|
|
req, err := http.NewRequest(method, url, nil)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
{
|
|
|
|
req.Header.Add("Accept", "application/json")
|
|
req.Header.Add("Authorization", "Token <TOKEN>")
|
|
|
|
res, err := client.Do(req)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
defer res.Body.Close()
|
|
|
|
body, err := ioutil.ReadAll(res.Body)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(string(body))
|
|
}
|
|
```
|
|
|
|
```ruby
|
|
require "uri"
|
|
require "json"
|
|
require "net/http"
|
|
|
|
url = URI("https://api.netbird.io/api/networks/{networkId}/routers")
|
|
|
|
https = Net::HTTP.new(url.host, url.port)
|
|
https.use_ssl = true
|
|
|
|
request = Net::HTTP::Get.new(url)
|
|
request["Accept"] = "application/json"
|
|
request["Authorization"] = "Token <TOKEN>"
|
|
|
|
response = https.request(request)
|
|
puts response.read_body
|
|
```
|
|
|
|
```java
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
.build();
|
|
|
|
Request request = new Request.Builder()
|
|
.url("https://api.netbird.io/api/networks/{networkId}/routers")
|
|
.method("GET")
|
|
.addHeader("Accept", "application/json")
|
|
.addHeader("Authorization: Token <TOKEN>")
|
|
.build();
|
|
Response response = client.newCall(request).execute();
|
|
```
|
|
|
|
```php
|
|
<?php
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => 'https://api.netbird.io/api/networks/{networkId}/routers',
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'GET',
|
|
CURLOPT_HTTPHEADER => array(
|
|
'Accept: application/json',
|
|
'Authorization: Token <TOKEN>'
|
|
),
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
curl_close($curl);
|
|
echo $response;
|
|
```
|
|
|
|
</CodeGroup>
|
|
|
|
|
|
<CodeGroup title="Response">
|
|
```json {{ title: 'Example' }}
|
|
[
|
|
{
|
|
"id": "chacdk86lnnboviihd7g",
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"peer_groups": [
|
|
"chacbco6lnnbn6cg5s91"
|
|
],
|
|
"metric": 9999,
|
|
"masquerade": true
|
|
}
|
|
]
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
[
|
|
{
|
|
"id": "string",
|
|
"peer": "string",
|
|
"peer_groups": [
|
|
"string"
|
|
],
|
|
"metric": "integer",
|
|
"masquerade": "boolean"
|
|
}
|
|
]
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## Create a Network Router {{ tag: 'POST' , label: '/api/networks/{networkId}/routers' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Creates a Network Router
|
|
|
|
#### Path Parameters
|
|
<Properties>
|
|
|
|
<Property name="networkId" type="string" required={true}>
|
|
The unique identifier of a network
|
|
</Property>
|
|
</Properties>
|
|
|
|
#### Request-Body Parameters
|
|
|
|
<Properties><Property name="peer" type="string" required={false}>
|
|
|
|
Peer Identifier associated with route. This property can not be set together with `peer_groups`
|
|
|
|
</Property>
|
|
<Property name="peer_groups" type="string[]" required={false}>
|
|
|
|
Peers Group Identifier associated with route. This property can not be set together with `peer`
|
|
|
|
</Property>
|
|
<Property name="metric" type="integer" required={true} min={1} max={9999}>
|
|
|
|
Route metric number. Lowest number has higher priority
|
|
|
|
</Property>
|
|
<Property name="masquerade" type="boolean" required={true}>
|
|
|
|
Indicate if peer should masquerade traffic to this route's prefix
|
|
|
|
</Property>
|
|
</Properties>
|
|
|
|
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="POST" label="/api/networks/{networkId}/routers">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X POST https://api.netbird.io/api/networks/{networkId}/routers \
|
|
-H 'Accept: application/json' \
|
|
-H 'Content-Type: application/json' \
|
|
-H 'Authorization: Token <TOKEN>' \
|
|
--data-raw '{
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"peer_groups": [
|
|
"chacbco6lnnbn6cg5s91"
|
|
],
|
|
"metric": 9999,
|
|
"masquerade": true
|
|
}'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
let data = JSON.stringify({
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"peer_groups": [
|
|
"chacbco6lnnbn6cg5s91"
|
|
],
|
|
"metric": 9999,
|
|
"masquerade": true
|
|
});
|
|
let config = {
|
|
method: 'post',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/networks/{networkId}/routers',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Content-Type': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
},
|
|
data : data
|
|
};
|
|
|
|
axios(config)
|
|
.then((response) => {
|
|
console.log(JSON.stringify(response.data));
|
|
})
|
|
.catch((error) => {
|
|
console.log(error);
|
|
});
|
|
```
|
|
|
|
```python
|
|
import requests
|
|
import json
|
|
|
|
url = "https://api.netbird.io/api/networks/{networkId}/routers"
|
|
payload = json.dumps({
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"peer_groups": [
|
|
"chacbco6lnnbn6cg5s91"
|
|
],
|
|
"metric": 9999,
|
|
"masquerade": true
|
|
})
|
|
headers = {
|
|
'Content-Type': 'application/json',
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
|
|
response = requests.request("POST", url, headers=headers, data=payload)
|
|
|
|
print(response.text)
|
|
```
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"net/http"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func main() {
|
|
|
|
url := "https://api.netbird.io/api/networks/{networkId}/routers"
|
|
method := "POST"
|
|
|
|
payload := strings.NewReader(`{
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"peer_groups": [
|
|
"chacbco6lnnbn6cg5s91"
|
|
],
|
|
"metric": 9999,
|
|
"masquerade": true
|
|
}`)
|
|
client := &http.Client {
|
|
}
|
|
req, err := http.NewRequest(method, url, payload)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
{
|
|
|
|
req.Header.Add("Content-Type", "application/json")
|
|
req.Header.Add("Accept", "application/json")
|
|
req.Header.Add("Authorization", "Token <TOKEN>")
|
|
|
|
res, err := client.Do(req)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
defer res.Body.Close()
|
|
|
|
body, err := ioutil.ReadAll(res.Body)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(string(body))
|
|
}
|
|
```
|
|
|
|
```ruby
|
|
require "uri"
|
|
require "json"
|
|
require "net/http"
|
|
|
|
url = URI("https://api.netbird.io/api/networks/{networkId}/routers")
|
|
|
|
https = Net::HTTP.new(url.host, url.port)
|
|
https.use_ssl = true
|
|
|
|
request = Net::HTTP::Post.new(url)
|
|
request["Content-Type"] = "application/json"
|
|
request["Accept"] = "application/json"
|
|
request["Authorization"] = "Token <TOKEN>"
|
|
|
|
request.body = JSON.dump({
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"peer_groups": [
|
|
"chacbco6lnnbn6cg5s91"
|
|
],
|
|
"metric": 9999,
|
|
"masquerade": true
|
|
})
|
|
response = https.request(request)
|
|
puts response.read_body
|
|
```
|
|
|
|
```java
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
.build();
|
|
MediaType mediaType = MediaType.parse("application/json");
|
|
RequestBody body = RequestBody.create(mediaType, '{
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"peer_groups": [
|
|
"chacbco6lnnbn6cg5s91"
|
|
],
|
|
"metric": 9999,
|
|
"masquerade": true
|
|
}');
|
|
Request request = new Request.Builder()
|
|
.url("https://api.netbird.io/api/networks/{networkId}/routers")
|
|
.method("POST", body)
|
|
.addHeader("Content-Type", "application/json")
|
|
.addHeader("Accept", "application/json")
|
|
.addHeader("Authorization: Token <TOKEN>")
|
|
.build();
|
|
Response response = client.newCall(request).execute();
|
|
```
|
|
|
|
```php
|
|
<?php
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => 'https://api.netbird.io/api/networks/{networkId}/routers',
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'POST',
|
|
CURLOPT_POSTFIELDS => '{
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"peer_groups": [
|
|
"chacbco6lnnbn6cg5s91"
|
|
],
|
|
"metric": 9999,
|
|
"masquerade": true
|
|
}',
|
|
CURLOPT_HTTPHEADER => array(
|
|
'Content-Type: application/json',
|
|
'Accept: application/json',
|
|
'Authorization: Token <TOKEN>'
|
|
),
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
curl_close($curl);
|
|
echo $response;
|
|
```
|
|
|
|
</CodeGroup>
|
|
|
|
|
|
<CodeGroup title="Response">
|
|
```json {{ title: 'Example' }}
|
|
{
|
|
"id": "chacdk86lnnboviihd7g",
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"peer_groups": [
|
|
"chacbco6lnnbn6cg5s91"
|
|
],
|
|
"metric": 9999,
|
|
"masquerade": true
|
|
}
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
{
|
|
"id": "string",
|
|
"peer": "string",
|
|
"peer_groups": [
|
|
"string"
|
|
],
|
|
"metric": "integer",
|
|
"masquerade": "boolean"
|
|
}
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## Retrieve a Network Router {{ tag: 'GET' , label: '/api/networks/{networkId}/routers/{routerId}' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Get information about a Network Router
|
|
|
|
#### Path Parameters
|
|
<Properties>
|
|
|
|
<Property name="networkId" type="string" required={true}>
|
|
The unique identifier of a network
|
|
</Property>
|
|
|
|
<Property name="routerId" type="string" required={true}>
|
|
The unique identifier of a router
|
|
</Property>
|
|
</Properties>
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="GET" label="/api/networks/{networkId}/routers/{routerId}">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X GET https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \
|
|
-H 'Accept: application/json' \
|
|
-H 'Authorization: Token <TOKEN>'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
|
|
let config = {
|
|
method: 'get',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/networks/{networkId}/routers/{routerId}',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
};
|
|
|
|
axios(config)
|
|
.then((response) => {
|
|
console.log(JSON.stringify(response.data));
|
|
})
|
|
.catch((error) => {
|
|
console.log(error);
|
|
});
|
|
```
|
|
|
|
```python
|
|
import requests
|
|
import json
|
|
|
|
url = "https://api.netbird.io/api/networks/{networkId}/routers/{routerId}"
|
|
|
|
headers = {
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
|
|
response = requests.request("GET", url, headers=headers)
|
|
|
|
print(response.text)
|
|
```
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"net/http"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func main() {
|
|
|
|
url := "https://api.netbird.io/api/networks/{networkId}/routers/{routerId}"
|
|
method := "GET"
|
|
|
|
client := &http.Client {
|
|
}
|
|
req, err := http.NewRequest(method, url, nil)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
{
|
|
|
|
req.Header.Add("Accept", "application/json")
|
|
req.Header.Add("Authorization", "Token <TOKEN>")
|
|
|
|
res, err := client.Do(req)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
defer res.Body.Close()
|
|
|
|
body, err := ioutil.ReadAll(res.Body)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(string(body))
|
|
}
|
|
```
|
|
|
|
```ruby
|
|
require "uri"
|
|
require "json"
|
|
require "net/http"
|
|
|
|
url = URI("https://api.netbird.io/api/networks/{networkId}/routers/{routerId}")
|
|
|
|
https = Net::HTTP.new(url.host, url.port)
|
|
https.use_ssl = true
|
|
|
|
request = Net::HTTP::Get.new(url)
|
|
request["Accept"] = "application/json"
|
|
request["Authorization"] = "Token <TOKEN>"
|
|
|
|
response = https.request(request)
|
|
puts response.read_body
|
|
```
|
|
|
|
```java
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
.build();
|
|
|
|
Request request = new Request.Builder()
|
|
.url("https://api.netbird.io/api/networks/{networkId}/routers/{routerId}")
|
|
.method("GET")
|
|
.addHeader("Accept", "application/json")
|
|
.addHeader("Authorization: Token <TOKEN>")
|
|
.build();
|
|
Response response = client.newCall(request).execute();
|
|
```
|
|
|
|
```php
|
|
<?php
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => 'https://api.netbird.io/api/networks/{networkId}/routers/{routerId}',
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'GET',
|
|
CURLOPT_HTTPHEADER => array(
|
|
'Accept: application/json',
|
|
'Authorization: Token <TOKEN>'
|
|
),
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
curl_close($curl);
|
|
echo $response;
|
|
```
|
|
|
|
</CodeGroup>
|
|
|
|
|
|
<CodeGroup title="Response">
|
|
```json {{ title: 'Example' }}
|
|
{
|
|
"id": "chacdk86lnnboviihd7g",
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"peer_groups": [
|
|
"chacbco6lnnbn6cg5s91"
|
|
],
|
|
"metric": 9999,
|
|
"masquerade": true
|
|
}
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
{
|
|
"id": "string",
|
|
"peer": "string",
|
|
"peer_groups": [
|
|
"string"
|
|
],
|
|
"metric": "integer",
|
|
"masquerade": "boolean"
|
|
}
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## Update a Network Router {{ tag: 'PUT' , label: '/api/networks/{networkId}/routers/{routerId}' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Update a Network Router
|
|
|
|
#### Path Parameters
|
|
<Properties>
|
|
|
|
<Property name="networkId" type="string" required={true}>
|
|
The unique identifier of a network
|
|
</Property>
|
|
|
|
<Property name="routerId" type="string" required={true}>
|
|
The unique identifier of a router
|
|
</Property>
|
|
</Properties>
|
|
|
|
#### Request-Body Parameters
|
|
|
|
<Properties><Property name="peer" type="string" required={false}>
|
|
|
|
Peer Identifier associated with route. This property can not be set together with `peer_groups`
|
|
|
|
</Property>
|
|
<Property name="peer_groups" type="string[]" required={false}>
|
|
|
|
Peers Group Identifier associated with route. This property can not be set together with `peer`
|
|
|
|
</Property>
|
|
<Property name="metric" type="integer" required={true} min={1} max={9999}>
|
|
|
|
Route metric number. Lowest number has higher priority
|
|
|
|
</Property>
|
|
<Property name="masquerade" type="boolean" required={true}>
|
|
|
|
Indicate if peer should masquerade traffic to this route's prefix
|
|
|
|
</Property>
|
|
</Properties>
|
|
|
|
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="PUT" label="/api/networks/{networkId}/routers/{routerId}">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X PUT https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \
|
|
-H 'Accept: application/json' \
|
|
-H 'Content-Type: application/json' \
|
|
-H 'Authorization: Token <TOKEN>' \
|
|
--data-raw '{
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"peer_groups": [
|
|
"chacbco6lnnbn6cg5s91"
|
|
],
|
|
"metric": 9999,
|
|
"masquerade": true
|
|
}'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
let data = JSON.stringify({
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"peer_groups": [
|
|
"chacbco6lnnbn6cg5s91"
|
|
],
|
|
"metric": 9999,
|
|
"masquerade": true
|
|
});
|
|
let config = {
|
|
method: 'put',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/networks/{networkId}/routers/{routerId}',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Content-Type': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
},
|
|
data : data
|
|
};
|
|
|
|
axios(config)
|
|
.then((response) => {
|
|
console.log(JSON.stringify(response.data));
|
|
})
|
|
.catch((error) => {
|
|
console.log(error);
|
|
});
|
|
```
|
|
|
|
```python
|
|
import requests
|
|
import json
|
|
|
|
url = "https://api.netbird.io/api/networks/{networkId}/routers/{routerId}"
|
|
payload = json.dumps({
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"peer_groups": [
|
|
"chacbco6lnnbn6cg5s91"
|
|
],
|
|
"metric": 9999,
|
|
"masquerade": true
|
|
})
|
|
headers = {
|
|
'Content-Type': 'application/json',
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
|
|
response = requests.request("PUT", url, headers=headers, data=payload)
|
|
|
|
print(response.text)
|
|
```
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"net/http"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func main() {
|
|
|
|
url := "https://api.netbird.io/api/networks/{networkId}/routers/{routerId}"
|
|
method := "PUT"
|
|
|
|
payload := strings.NewReader(`{
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"peer_groups": [
|
|
"chacbco6lnnbn6cg5s91"
|
|
],
|
|
"metric": 9999,
|
|
"masquerade": true
|
|
}`)
|
|
client := &http.Client {
|
|
}
|
|
req, err := http.NewRequest(method, url, payload)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
{
|
|
|
|
req.Header.Add("Content-Type", "application/json")
|
|
req.Header.Add("Accept", "application/json")
|
|
req.Header.Add("Authorization", "Token <TOKEN>")
|
|
|
|
res, err := client.Do(req)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
defer res.Body.Close()
|
|
|
|
body, err := ioutil.ReadAll(res.Body)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(string(body))
|
|
}
|
|
```
|
|
|
|
```ruby
|
|
require "uri"
|
|
require "json"
|
|
require "net/http"
|
|
|
|
url = URI("https://api.netbird.io/api/networks/{networkId}/routers/{routerId}")
|
|
|
|
https = Net::HTTP.new(url.host, url.port)
|
|
https.use_ssl = true
|
|
|
|
request = Net::HTTP::Put.new(url)
|
|
request["Content-Type"] = "application/json"
|
|
request["Accept"] = "application/json"
|
|
request["Authorization"] = "Token <TOKEN>"
|
|
|
|
request.body = JSON.dump({
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"peer_groups": [
|
|
"chacbco6lnnbn6cg5s91"
|
|
],
|
|
"metric": 9999,
|
|
"masquerade": true
|
|
})
|
|
response = https.request(request)
|
|
puts response.read_body
|
|
```
|
|
|
|
```java
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
.build();
|
|
MediaType mediaType = MediaType.parse("application/json");
|
|
RequestBody body = RequestBody.create(mediaType, '{
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"peer_groups": [
|
|
"chacbco6lnnbn6cg5s91"
|
|
],
|
|
"metric": 9999,
|
|
"masquerade": true
|
|
}');
|
|
Request request = new Request.Builder()
|
|
.url("https://api.netbird.io/api/networks/{networkId}/routers/{routerId}")
|
|
.method("PUT", body)
|
|
.addHeader("Content-Type", "application/json")
|
|
.addHeader("Accept", "application/json")
|
|
.addHeader("Authorization: Token <TOKEN>")
|
|
.build();
|
|
Response response = client.newCall(request).execute();
|
|
```
|
|
|
|
```php
|
|
<?php
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => 'https://api.netbird.io/api/networks/{networkId}/routers/{routerId}',
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'PUT',
|
|
CURLOPT_POSTFIELDS => '{
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"peer_groups": [
|
|
"chacbco6lnnbn6cg5s91"
|
|
],
|
|
"metric": 9999,
|
|
"masquerade": true
|
|
}',
|
|
CURLOPT_HTTPHEADER => array(
|
|
'Content-Type: application/json',
|
|
'Accept: application/json',
|
|
'Authorization: Token <TOKEN>'
|
|
),
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
curl_close($curl);
|
|
echo $response;
|
|
```
|
|
|
|
</CodeGroup>
|
|
|
|
|
|
<CodeGroup title="Response">
|
|
```json {{ title: 'Example' }}
|
|
{
|
|
"id": "chacdk86lnnboviihd7g",
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"peer_groups": [
|
|
"chacbco6lnnbn6cg5s91"
|
|
],
|
|
"metric": 9999,
|
|
"masquerade": true
|
|
}
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
{
|
|
"id": "string",
|
|
"peer": "string",
|
|
"peer_groups": [
|
|
"string"
|
|
],
|
|
"metric": "integer",
|
|
"masquerade": "boolean"
|
|
}
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## Delete a Network Router {{ tag: 'DELETE' , label: '/api/networks/{networkId}/routers/{routerId}' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Delete a network router
|
|
|
|
#### Path Parameters
|
|
<Properties>
|
|
|
|
<Property name="networkId" type="string" required={true}>
|
|
|
|
</Property>
|
|
|
|
<Property name="routerId" type="string" required={true}>
|
|
|
|
</Property>
|
|
</Properties>
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="DELETE" label="/api/networks/{networkId}/routers/{routerId}">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X DELETE https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \
|
|
-H 'Authorization: Token <TOKEN>'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
|
|
let config = {
|
|
method: 'delete',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/networks/{networkId}/routers/{routerId}',
|
|
headers: {
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
};
|
|
|
|
axios(config)
|
|
.then((response) => {
|
|
console.log(JSON.stringify(response.data));
|
|
})
|
|
.catch((error) => {
|
|
console.log(error);
|
|
});
|
|
```
|
|
|
|
```python
|
|
import requests
|
|
import json
|
|
|
|
url = "https://api.netbird.io/api/networks/{networkId}/routers/{routerId}"
|
|
|
|
headers = {
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
|
|
response = requests.request("DELETE", url, headers=headers)
|
|
|
|
print(response.text)
|
|
```
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"net/http"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func main() {
|
|
|
|
url := "https://api.netbird.io/api/networks/{networkId}/routers/{routerId}"
|
|
method := "DELETE"
|
|
|
|
client := &http.Client {
|
|
}
|
|
req, err := http.NewRequest(method, url, nil)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
{
|
|
|
|
req.Header.Add("Authorization", "Token <TOKEN>")
|
|
|
|
res, err := client.Do(req)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
defer res.Body.Close()
|
|
|
|
body, err := ioutil.ReadAll(res.Body)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(string(body))
|
|
}
|
|
```
|
|
|
|
```ruby
|
|
require "uri"
|
|
require "json"
|
|
require "net/http"
|
|
|
|
url = URI("https://api.netbird.io/api/networks/{networkId}/routers/{routerId}")
|
|
|
|
https = Net::HTTP.new(url.host, url.port)
|
|
https.use_ssl = true
|
|
|
|
request = Net::HTTP::Delete.new(url)
|
|
request["Authorization"] = "Token <TOKEN>"
|
|
|
|
response = https.request(request)
|
|
puts response.read_body
|
|
```
|
|
|
|
```java
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
.build();
|
|
|
|
Request request = new Request.Builder()
|
|
.url("https://api.netbird.io/api/networks/{networkId}/routers/{routerId}")
|
|
.method("DELETE")
|
|
.addHeader("Authorization: Token <TOKEN>")
|
|
.build();
|
|
Response response = client.newCall(request).execute();
|
|
```
|
|
|
|
```php
|
|
<?php
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => 'https://api.netbird.io/api/networks/{networkId}/routers/{routerId}',
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'DELETE',
|
|
CURLOPT_HTTPHEADER => array(
|
|
'Authorization: Token <TOKEN>'
|
|
),
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
curl_close($curl);
|
|
echo $response;
|
|
```
|
|
|
|
</CodeGroup>
|
|
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|