mirror of
https://github.com/netbirdio/docs.git
synced 2026-04-16 07:26:35 +00:00
* Update API docs * Update API pages with v0.23.0 --------- Co-authored-by: netbirddev <dev@netbird.io>
1143 lines
23 KiB
Plaintext
1143 lines
23 KiB
Plaintext
export const title = 'Setup Keys'
|
|
|
|
|
|
|
|
## List all Setup Keys {{ tag: 'GET' , label: '/api/setup-keys' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Returns a list of all Setup Keys
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="GET" label="/api/setup-keys">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X GET https://api.netbird.io/api/setup-keys \
|
|
-H 'Accept: application/json' \
|
|
-H 'Authorization: Token <TOKEN>'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
|
|
let config = {
|
|
method: 'get',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/setup-keys',
|
|
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/setup-keys"
|
|
|
|
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/setup-keys"
|
|
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/setup-keys")
|
|
|
|
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/setup-keys")
|
|
.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/setup-keys',
|
|
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": "2531583362",
|
|
"key": "A616097E-FCF0-48FA-9354-CA4A61142761",
|
|
"name": "Default key",
|
|
"expires": "2023-06-01T14:47:22.291057Z",
|
|
"type": "reusable",
|
|
"valid": true,
|
|
"revoked": false,
|
|
"used_times": 2,
|
|
"last_used": "2023-05-05T09:00:35.477782Z",
|
|
"state": "valid",
|
|
"auto_groups": [
|
|
"devs"
|
|
],
|
|
"updated_at": "2023-05-05T09:00:35.477782Z",
|
|
"usage_limit": 0,
|
|
"ephemeral": true
|
|
}
|
|
]
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
[
|
|
{
|
|
"id": "string",
|
|
"key": "string",
|
|
"name": "string",
|
|
"expires": "string",
|
|
"type": "string",
|
|
"valid": "boolean",
|
|
"revoked": "boolean",
|
|
"used_times": "integer",
|
|
"last_used": "string",
|
|
"state": "string",
|
|
"auto_groups": [
|
|
"string"
|
|
],
|
|
"updated_at": "string",
|
|
"usage_limit": "integer",
|
|
"ephemeral": "boolean"
|
|
}
|
|
]
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## Create a Setup Key {{ tag: 'POST' , label: '/api/setup-keys' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Creates a setup key
|
|
|
|
#### Request-Body Parameters
|
|
<Properties>
|
|
|
|
<Property name="name" type="string" required={true}
|
|
|
|
|
|
>
|
|
Setup Key name
|
|
</Property>
|
|
|
|
<Property name="type" type="string" required={true}
|
|
|
|
|
|
>
|
|
Setup key type, one-off for single time usage and reusable
|
|
</Property>
|
|
|
|
<Property name="expires_in" type="integer" required={true}
|
|
|
|
|
|
min={86400}
|
|
|
|
|
|
max={31536000}
|
|
>
|
|
Expiration time in seconds
|
|
</Property>
|
|
|
|
<Property name="revoked" type="boolean" required={true}
|
|
|
|
|
|
>
|
|
Setup key revocation status
|
|
</Property>
|
|
|
|
<Property name="auto_groups" type="string[]" required={true}
|
|
|
|
|
|
>
|
|
List of group IDs to auto-assign to peers registered with this key
|
|
</Property>
|
|
|
|
<Property name="usage_limit" type="integer" required={true}
|
|
|
|
|
|
>
|
|
A number of times this key can be used. The value of 0 indicates the unlimited usage.
|
|
</Property>
|
|
|
|
<Property name="ephemeral" type="boolean" required={false}
|
|
|
|
|
|
>
|
|
Indicate that the peer will be ephemeral or not
|
|
</Property>
|
|
</Properties>
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="POST" label="/api/setup-keys">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X POST https://api.netbird.io/api/setup-keys \
|
|
-H 'Accept: application/json' \
|
|
-H 'Content-Type: application/json' \
|
|
-H 'Authorization: Token <TOKEN>' \
|
|
--data-raw '{
|
|
"name": "Default key",
|
|
"type": "reusable",
|
|
"expires_in": 86400,
|
|
"revoked": false,
|
|
"auto_groups": [
|
|
"devs"
|
|
],
|
|
"usage_limit": 0,
|
|
"ephemeral": true
|
|
}'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
let data = JSON.stringify({
|
|
"name": "Default key",
|
|
"type": "reusable",
|
|
"expires_in": 86400,
|
|
"revoked": false,
|
|
"auto_groups": [
|
|
"devs"
|
|
],
|
|
"usage_limit": 0,
|
|
"ephemeral": true
|
|
});
|
|
let config = {
|
|
method: 'post',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/setup-keys',
|
|
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/setup-keys"
|
|
payload = json.dumps({
|
|
"name": "Default key",
|
|
"type": "reusable",
|
|
"expires_in": 86400,
|
|
"revoked": false,
|
|
"auto_groups": [
|
|
"devs"
|
|
],
|
|
"usage_limit": 0,
|
|
"ephemeral": 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/setup-keys"
|
|
method := "POST"
|
|
|
|
payload := strings.NewReader(`{
|
|
"name": "Default key",
|
|
"type": "reusable",
|
|
"expires_in": 86400,
|
|
"revoked": false,
|
|
"auto_groups": [
|
|
"devs"
|
|
],
|
|
"usage_limit": 0,
|
|
"ephemeral": 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/setup-keys")
|
|
|
|
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": "Default key",
|
|
"type": "reusable",
|
|
"expires_in": 86400,
|
|
"revoked": false,
|
|
"auto_groups": [
|
|
"devs"
|
|
],
|
|
"usage_limit": 0,
|
|
"ephemeral": 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, '{
|
|
"name": "Default key",
|
|
"type": "reusable",
|
|
"expires_in": 86400,
|
|
"revoked": false,
|
|
"auto_groups": [
|
|
"devs"
|
|
],
|
|
"usage_limit": 0,
|
|
"ephemeral": true
|
|
}');
|
|
Request request = new Request.Builder()
|
|
.url("https://api.netbird.io/api/setup-keys")
|
|
.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/setup-keys',
|
|
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": "Default key",
|
|
"type": "reusable",
|
|
"expires_in": 86400,
|
|
"revoked": false,
|
|
"auto_groups": [
|
|
"devs"
|
|
],
|
|
"usage_limit": 0,
|
|
"ephemeral": 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": "2531583362",
|
|
"key": "A616097E-FCF0-48FA-9354-CA4A61142761",
|
|
"name": "Default key",
|
|
"expires": "2023-06-01T14:47:22.291057Z",
|
|
"type": "reusable",
|
|
"valid": true,
|
|
"revoked": false,
|
|
"used_times": 2,
|
|
"last_used": "2023-05-05T09:00:35.477782Z",
|
|
"state": "valid",
|
|
"auto_groups": [
|
|
"devs"
|
|
],
|
|
"updated_at": "2023-05-05T09:00:35.477782Z",
|
|
"usage_limit": 0,
|
|
"ephemeral": true
|
|
}
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
{
|
|
"id": "string",
|
|
"key": "string",
|
|
"name": "string",
|
|
"expires": "string",
|
|
"type": "string",
|
|
"valid": "boolean",
|
|
"revoked": "boolean",
|
|
"used_times": "integer",
|
|
"last_used": "string",
|
|
"state": "string",
|
|
"auto_groups": [
|
|
"string"
|
|
],
|
|
"updated_at": "string",
|
|
"usage_limit": "integer",
|
|
"ephemeral": "boolean"
|
|
}
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## Retrieve a Setup Key {{ tag: 'GET' , label: '/api/setup-keys/{keyId}' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Get information about a setup key
|
|
|
|
#### Path Parameters
|
|
<Properties>
|
|
|
|
<Property name="keyId" type="string" required={true}>
|
|
The unique identifier of a setup key
|
|
</Property>
|
|
</Properties>
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="GET" label="/api/setup-keys/{keyId}">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X GET https://api.netbird.io/api/setup-keys/{keyId} \
|
|
-H 'Accept: application/json' \
|
|
-H 'Authorization: Token <TOKEN>'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
|
|
let config = {
|
|
method: 'get',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/setup-keys/{keyId}',
|
|
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/setup-keys/{keyId}"
|
|
|
|
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/setup-keys/{keyId}"
|
|
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/setup-keys/{keyId}")
|
|
|
|
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/setup-keys/{keyId}")
|
|
.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/setup-keys/{keyId}',
|
|
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": "2531583362",
|
|
"key": "A616097E-FCF0-48FA-9354-CA4A61142761",
|
|
"name": "Default key",
|
|
"expires": "2023-06-01T14:47:22.291057Z",
|
|
"type": "reusable",
|
|
"valid": true,
|
|
"revoked": false,
|
|
"used_times": 2,
|
|
"last_used": "2023-05-05T09:00:35.477782Z",
|
|
"state": "valid",
|
|
"auto_groups": [
|
|
"devs"
|
|
],
|
|
"updated_at": "2023-05-05T09:00:35.477782Z",
|
|
"usage_limit": 0,
|
|
"ephemeral": true
|
|
}
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
{
|
|
"id": "string",
|
|
"key": "string",
|
|
"name": "string",
|
|
"expires": "string",
|
|
"type": "string",
|
|
"valid": "boolean",
|
|
"revoked": "boolean",
|
|
"used_times": "integer",
|
|
"last_used": "string",
|
|
"state": "string",
|
|
"auto_groups": [
|
|
"string"
|
|
],
|
|
"updated_at": "string",
|
|
"usage_limit": "integer",
|
|
"ephemeral": "boolean"
|
|
}
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## Update a Setup Key {{ tag: 'PUT' , label: '/api/setup-keys/{keyId}' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Update information about a setup key
|
|
|
|
#### Path Parameters
|
|
<Properties>
|
|
|
|
<Property name="keyId" type="string" required={true}>
|
|
The unique identifier of a setup key
|
|
</Property>
|
|
</Properties>
|
|
|
|
#### Request-Body Parameters
|
|
<Properties>
|
|
|
|
<Property name="name" type="string" required={true}
|
|
|
|
|
|
>
|
|
Setup Key name
|
|
</Property>
|
|
|
|
<Property name="type" type="string" required={true}
|
|
|
|
|
|
>
|
|
Setup key type, one-off for single time usage and reusable
|
|
</Property>
|
|
|
|
<Property name="expires_in" type="integer" required={true}
|
|
|
|
|
|
min={86400}
|
|
|
|
|
|
max={31536000}
|
|
>
|
|
Expiration time in seconds
|
|
</Property>
|
|
|
|
<Property name="revoked" type="boolean" required={true}
|
|
|
|
|
|
>
|
|
Setup key revocation status
|
|
</Property>
|
|
|
|
<Property name="auto_groups" type="string[]" required={true}
|
|
|
|
|
|
>
|
|
List of group IDs to auto-assign to peers registered with this key
|
|
</Property>
|
|
|
|
<Property name="usage_limit" type="integer" required={true}
|
|
|
|
|
|
>
|
|
A number of times this key can be used. The value of 0 indicates the unlimited usage.
|
|
</Property>
|
|
|
|
<Property name="ephemeral" type="boolean" required={false}
|
|
|
|
|
|
>
|
|
Indicate that the peer will be ephemeral or not
|
|
</Property>
|
|
</Properties>
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="PUT" label="/api/setup-keys/{keyId}">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X PUT https://api.netbird.io/api/setup-keys/{keyId} \
|
|
-H 'Accept: application/json' \
|
|
-H 'Content-Type: application/json' \
|
|
-H 'Authorization: Token <TOKEN>' \
|
|
--data-raw '{
|
|
"name": "Default key",
|
|
"type": "reusable",
|
|
"expires_in": 86400,
|
|
"revoked": false,
|
|
"auto_groups": [
|
|
"devs"
|
|
],
|
|
"usage_limit": 0,
|
|
"ephemeral": true
|
|
}'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
let data = JSON.stringify({
|
|
"name": "Default key",
|
|
"type": "reusable",
|
|
"expires_in": 86400,
|
|
"revoked": false,
|
|
"auto_groups": [
|
|
"devs"
|
|
],
|
|
"usage_limit": 0,
|
|
"ephemeral": true
|
|
});
|
|
let config = {
|
|
method: 'put',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/setup-keys/{keyId}',
|
|
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/setup-keys/{keyId}"
|
|
payload = json.dumps({
|
|
"name": "Default key",
|
|
"type": "reusable",
|
|
"expires_in": 86400,
|
|
"revoked": false,
|
|
"auto_groups": [
|
|
"devs"
|
|
],
|
|
"usage_limit": 0,
|
|
"ephemeral": 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/setup-keys/{keyId}"
|
|
method := "PUT"
|
|
|
|
payload := strings.NewReader(`{
|
|
"name": "Default key",
|
|
"type": "reusable",
|
|
"expires_in": 86400,
|
|
"revoked": false,
|
|
"auto_groups": [
|
|
"devs"
|
|
],
|
|
"usage_limit": 0,
|
|
"ephemeral": 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/setup-keys/{keyId}")
|
|
|
|
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": "Default key",
|
|
"type": "reusable",
|
|
"expires_in": 86400,
|
|
"revoked": false,
|
|
"auto_groups": [
|
|
"devs"
|
|
],
|
|
"usage_limit": 0,
|
|
"ephemeral": 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, '{
|
|
"name": "Default key",
|
|
"type": "reusable",
|
|
"expires_in": 86400,
|
|
"revoked": false,
|
|
"auto_groups": [
|
|
"devs"
|
|
],
|
|
"usage_limit": 0,
|
|
"ephemeral": true
|
|
}');
|
|
Request request = new Request.Builder()
|
|
.url("https://api.netbird.io/api/setup-keys/{keyId}")
|
|
.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/setup-keys/{keyId}',
|
|
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": "Default key",
|
|
"type": "reusable",
|
|
"expires_in": 86400,
|
|
"revoked": false,
|
|
"auto_groups": [
|
|
"devs"
|
|
],
|
|
"usage_limit": 0,
|
|
"ephemeral": 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": "2531583362",
|
|
"key": "A616097E-FCF0-48FA-9354-CA4A61142761",
|
|
"name": "Default key",
|
|
"expires": "2023-06-01T14:47:22.291057Z",
|
|
"type": "reusable",
|
|
"valid": true,
|
|
"revoked": false,
|
|
"used_times": 2,
|
|
"last_used": "2023-05-05T09:00:35.477782Z",
|
|
"state": "valid",
|
|
"auto_groups": [
|
|
"devs"
|
|
],
|
|
"updated_at": "2023-05-05T09:00:35.477782Z",
|
|
"usage_limit": 0,
|
|
"ephemeral": true
|
|
}
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
{
|
|
"id": "string",
|
|
"key": "string",
|
|
"name": "string",
|
|
"expires": "string",
|
|
"type": "string",
|
|
"valid": "boolean",
|
|
"revoked": "boolean",
|
|
"used_times": "integer",
|
|
"last_used": "string",
|
|
"state": "string",
|
|
"auto_groups": [
|
|
"string"
|
|
],
|
|
"updated_at": "string",
|
|
"usage_limit": "integer",
|
|
"ephemeral": "boolean"
|
|
}
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|