mirror of
https://github.com/netbirdio/docs.git
synced 2026-04-19 17:06:36 +00:00
1355 lines
26 KiB
Plaintext
1355 lines
26 KiB
Plaintext
import {HeroPattern} from "@/components/HeroPattern"; import {Note} from "@/components/mdx";
|
|
|
|
<HeroPattern />
|
|
|
|
export const title = 'Routes'
|
|
|
|
|
|
|
|
## List all Routes {{ tag: 'GET' , label: '/api/routes' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Returns a list of all routes
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="GET" label="/api/routes">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X GET https://api.netbird.io/api/routes \
|
|
-H "Authorization: Token <TOKEN>" \
|
|
-H 'Accept: application/json' \
|
|
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
|
|
let config = {
|
|
method: 'get',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/routes',
|
|
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/routes"
|
|
|
|
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/routes"
|
|
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/routes")
|
|
|
|
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/routes")
|
|
.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/routes',
|
|
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",
|
|
"network_type": "IPv4",
|
|
"description": "My first route",
|
|
"network_id": "Route 1",
|
|
"enabled": true,
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"network": "10.64.0.0/24",
|
|
"metric": 9999,
|
|
"masquerade": true,
|
|
"groups": [
|
|
"chacdk86lnnboviihd70"
|
|
]
|
|
}
|
|
]
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
[
|
|
{
|
|
"id": "string",
|
|
"network_type": "string",
|
|
"description": "string",
|
|
"network_id": "string",
|
|
"enabled": "boolean",
|
|
"peer": "string",
|
|
"network": "string",
|
|
"metric": "integer",
|
|
"masquerade": "boolean",
|
|
"groups": [
|
|
"string"
|
|
]
|
|
}
|
|
]
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## Create a Route {{ tag: 'POST' , label: '/api/routes' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Creates a Route
|
|
|
|
#### Request-Body Parameters
|
|
<Properties>
|
|
|
|
<Property name="description" type="string" required={true}
|
|
|
|
|
|
>
|
|
Route description
|
|
</Property>
|
|
|
|
<Property name="network_id" type="string" required={true}
|
|
|
|
|
|
|
|
minLen={1}
|
|
|
|
maxLen={40}
|
|
>
|
|
Route network identifier, to group HA routes
|
|
</Property>
|
|
|
|
<Property name="enabled" type="boolean" required={true}
|
|
|
|
|
|
>
|
|
Route status
|
|
</Property>
|
|
|
|
<Property name="peer" type="string" required={true}
|
|
|
|
|
|
>
|
|
Peer Identifier associated with route
|
|
</Property>
|
|
|
|
<Property name="network" type="string" required={true}
|
|
|
|
|
|
>
|
|
Network range in CIDR format
|
|
</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>
|
|
|
|
<Property name="groups" type="string[]" required={true}
|
|
|
|
|
|
>
|
|
Route group tag groups
|
|
</Property>
|
|
</Properties>
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="POST" label="/api/routes">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X POST https://api.netbird.io/api/routes \
|
|
-H "Authorization: Token <TOKEN>" \
|
|
-H 'Accept: application/json' \
|
|
-H 'Content-Type: application/json' \
|
|
--data-raw '{
|
|
"description": "string",
|
|
"network_id": "string",
|
|
"enabled": "boolean",
|
|
"peer": "string",
|
|
"network": "string",
|
|
"metric": "integer",
|
|
"masquerade": "boolean",
|
|
"groups": [
|
|
"string"
|
|
]
|
|
}'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
let data = JSON.stringify({
|
|
"description": "string",
|
|
"network_id": "string",
|
|
"enabled": "boolean",
|
|
"peer": "string",
|
|
"network": "string",
|
|
"metric": "integer",
|
|
"masquerade": "boolean",
|
|
"groups": [
|
|
"string"
|
|
]
|
|
});
|
|
let config = {
|
|
method: 'post',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/routes',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Accept': '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/routes"
|
|
payload = json.dumps({
|
|
"description": "string",
|
|
"network_id": "string",
|
|
"enabled": "boolean",
|
|
"peer": "string",
|
|
"network": "string",
|
|
"metric": "integer",
|
|
"masquerade": "boolean",
|
|
"groups": [
|
|
"string"
|
|
]
|
|
})
|
|
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/routes"
|
|
method := "POST"
|
|
|
|
payload := strings.NewReader(`{
|
|
"description": "string",
|
|
"network_id": "string",
|
|
"enabled": "boolean",
|
|
"peer": "string",
|
|
"network": "string",
|
|
"metric": "integer",
|
|
"masquerade": "boolean",
|
|
"groups": [
|
|
"string"
|
|
]
|
|
}`)
|
|
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/routes")
|
|
|
|
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({
|
|
"description": "string",
|
|
"network_id": "string",
|
|
"enabled": "boolean",
|
|
"peer": "string",
|
|
"network": "string",
|
|
"metric": "integer",
|
|
"masquerade": "boolean",
|
|
"groups": [
|
|
"string"
|
|
]
|
|
})
|
|
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, '{
|
|
"description": "string",
|
|
"network_id": "string",
|
|
"enabled": "boolean",
|
|
"peer": "string",
|
|
"network": "string",
|
|
"metric": "integer",
|
|
"masquerade": "boolean",
|
|
"groups": [
|
|
"string"
|
|
]
|
|
}');
|
|
Request request = new Request.Builder()
|
|
.url("https://api.netbird.io/api/routes")
|
|
.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/routes',
|
|
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 =>'{
|
|
"description": "string",
|
|
"network_id": "string",
|
|
"enabled": "boolean",
|
|
"peer": "string",
|
|
"network": "string",
|
|
"metric": "integer",
|
|
"masquerade": "boolean",
|
|
"groups": [
|
|
"string"
|
|
]
|
|
}',
|
|
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",
|
|
"network_type": "IPv4",
|
|
"description": "My first route",
|
|
"network_id": "Route 1",
|
|
"enabled": true,
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"network": "10.64.0.0/24",
|
|
"metric": 9999,
|
|
"masquerade": true,
|
|
"groups": [
|
|
"chacdk86lnnboviihd70"
|
|
]
|
|
}
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
{
|
|
"id": "string",
|
|
"network_type": "string",
|
|
"description": "string",
|
|
"network_id": "string",
|
|
"enabled": "boolean",
|
|
"peer": "string",
|
|
"network": "string",
|
|
"metric": "integer",
|
|
"masquerade": "boolean",
|
|
"groups": [
|
|
"string"
|
|
]
|
|
}
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## Retrieve a Route {{ tag: 'GET' , label: '/api/routes/{routeId}' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Get information about a Routes
|
|
|
|
#### Path Parameters
|
|
<Properties>
|
|
|
|
<Property name="routeId" type="string" required={true}>
|
|
The unique identifier of a route
|
|
</Property>
|
|
</Properties>
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="GET" label="/api/routes/{routeId}">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X GET https://api.netbird.io/api/routes/{routeId} \
|
|
-H "Authorization: Token <TOKEN>" \
|
|
-H 'Accept: application/json' \
|
|
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
|
|
let config = {
|
|
method: 'get',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/routes/{routeId}',
|
|
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/routes/{routeId}"
|
|
|
|
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/routes/{routeId}"
|
|
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/routes/{routeId}")
|
|
|
|
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/routes/{routeId}")
|
|
.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/routes/{routeId}',
|
|
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",
|
|
"network_type": "IPv4",
|
|
"description": "My first route",
|
|
"network_id": "Route 1",
|
|
"enabled": true,
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"network": "10.64.0.0/24",
|
|
"metric": 9999,
|
|
"masquerade": true,
|
|
"groups": [
|
|
"chacdk86lnnboviihd70"
|
|
]
|
|
}
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
{
|
|
"id": "string",
|
|
"network_type": "string",
|
|
"description": "string",
|
|
"network_id": "string",
|
|
"enabled": "boolean",
|
|
"peer": "string",
|
|
"network": "string",
|
|
"metric": "integer",
|
|
"masquerade": "boolean",
|
|
"groups": [
|
|
"string"
|
|
]
|
|
}
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## Update a Route {{ tag: 'PUT' , label: '/api/routes/{routeId}' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Update/Replace a Route
|
|
|
|
#### Path Parameters
|
|
<Properties>
|
|
|
|
<Property name="routeId" type="string" required={true}>
|
|
The unique identifier of a route
|
|
</Property>
|
|
</Properties>
|
|
|
|
#### Request-Body Parameters
|
|
<Properties>
|
|
|
|
<Property name="description" type="string" required={true}
|
|
|
|
|
|
>
|
|
Route description
|
|
</Property>
|
|
|
|
<Property name="network_id" type="string" required={true}
|
|
|
|
|
|
|
|
minLen={1}
|
|
|
|
maxLen={40}
|
|
>
|
|
Route network identifier, to group HA routes
|
|
</Property>
|
|
|
|
<Property name="enabled" type="boolean" required={true}
|
|
|
|
|
|
>
|
|
Route status
|
|
</Property>
|
|
|
|
<Property name="peer" type="string" required={true}
|
|
|
|
|
|
>
|
|
Peer Identifier associated with route
|
|
</Property>
|
|
|
|
<Property name="network" type="string" required={true}
|
|
|
|
|
|
>
|
|
Network range in CIDR format
|
|
</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>
|
|
|
|
<Property name="groups" type="string[]" required={true}
|
|
|
|
|
|
>
|
|
Route group tag groups
|
|
</Property>
|
|
</Properties>
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="PUT" label="/api/routes/{routeId}">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X PUT https://api.netbird.io/api/routes/{routeId} \
|
|
-H "Authorization: Token <TOKEN>" \
|
|
-H 'Accept: application/json' \
|
|
-H 'Content-Type: application/json' \
|
|
--data-raw '{
|
|
"description": "string",
|
|
"network_id": "string",
|
|
"enabled": "boolean",
|
|
"peer": "string",
|
|
"network": "string",
|
|
"metric": "integer",
|
|
"masquerade": "boolean",
|
|
"groups": [
|
|
"string"
|
|
]
|
|
}'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
let data = JSON.stringify({
|
|
"description": "string",
|
|
"network_id": "string",
|
|
"enabled": "boolean",
|
|
"peer": "string",
|
|
"network": "string",
|
|
"metric": "integer",
|
|
"masquerade": "boolean",
|
|
"groups": [
|
|
"string"
|
|
]
|
|
});
|
|
let config = {
|
|
method: 'put',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/routes/{routeId}',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Accept': '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/routes/{routeId}"
|
|
payload = json.dumps({
|
|
"description": "string",
|
|
"network_id": "string",
|
|
"enabled": "boolean",
|
|
"peer": "string",
|
|
"network": "string",
|
|
"metric": "integer",
|
|
"masquerade": "boolean",
|
|
"groups": [
|
|
"string"
|
|
]
|
|
})
|
|
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/routes/{routeId}"
|
|
method := "PUT"
|
|
|
|
payload := strings.NewReader(`{
|
|
"description": "string",
|
|
"network_id": "string",
|
|
"enabled": "boolean",
|
|
"peer": "string",
|
|
"network": "string",
|
|
"metric": "integer",
|
|
"masquerade": "boolean",
|
|
"groups": [
|
|
"string"
|
|
]
|
|
}`)
|
|
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/routes/{routeId}")
|
|
|
|
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({
|
|
"description": "string",
|
|
"network_id": "string",
|
|
"enabled": "boolean",
|
|
"peer": "string",
|
|
"network": "string",
|
|
"metric": "integer",
|
|
"masquerade": "boolean",
|
|
"groups": [
|
|
"string"
|
|
]
|
|
})
|
|
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, '{
|
|
"description": "string",
|
|
"network_id": "string",
|
|
"enabled": "boolean",
|
|
"peer": "string",
|
|
"network": "string",
|
|
"metric": "integer",
|
|
"masquerade": "boolean",
|
|
"groups": [
|
|
"string"
|
|
]
|
|
}');
|
|
Request request = new Request.Builder()
|
|
.url("https://api.netbird.io/api/routes/{routeId}")
|
|
.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/routes/{routeId}',
|
|
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 =>'{
|
|
"description": "string",
|
|
"network_id": "string",
|
|
"enabled": "boolean",
|
|
"peer": "string",
|
|
"network": "string",
|
|
"metric": "integer",
|
|
"masquerade": "boolean",
|
|
"groups": [
|
|
"string"
|
|
]
|
|
}',
|
|
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",
|
|
"network_type": "IPv4",
|
|
"description": "My first route",
|
|
"network_id": "Route 1",
|
|
"enabled": true,
|
|
"peer": "chacbco6lnnbn6cg5s91",
|
|
"network": "10.64.0.0/24",
|
|
"metric": 9999,
|
|
"masquerade": true,
|
|
"groups": [
|
|
"chacdk86lnnboviihd70"
|
|
]
|
|
}
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
{
|
|
"id": "string",
|
|
"network_type": "string",
|
|
"description": "string",
|
|
"network_id": "string",
|
|
"enabled": "boolean",
|
|
"peer": "string",
|
|
"network": "string",
|
|
"metric": "integer",
|
|
"masquerade": "boolean",
|
|
"groups": [
|
|
"string"
|
|
]
|
|
}
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## Delete a Route {{ tag: 'DELETE' , label: '/api/routes/{routeId}' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Delete a Route
|
|
|
|
#### Path Parameters
|
|
<Properties>
|
|
|
|
<Property name="routeId" type="string" required={true}>
|
|
The unique identifier of a route
|
|
</Property>
|
|
</Properties>
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="DELETE" label="/api/routes/{routeId}">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X DELETE https://api.netbird.io/api/routes/{routeId} \
|
|
-H "Authorization: Token <TOKEN>" \
|
|
|
|
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
|
|
let config = {
|
|
method: 'delete',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/routes/{routeId}',
|
|
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/routes/{routeId}"
|
|
|
|
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/routes/{routeId}"
|
|
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/routes/{routeId}")
|
|
|
|
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/routes/{routeId}")
|
|
.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/routes/{routeId}',
|
|
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>
|
|
|
|
---
|