mirror of
https://github.com/netbirdio/docs.git
synced 2026-04-16 15:36:36 +00:00
bring back API pages (#400)
This commit is contained in:
968
src/pages/ipa/resources/accounts.mdx
Normal file
968
src/pages/ipa/resources/accounts.mdx
Normal file
@@ -0,0 +1,968 @@
|
||||
export const title = 'Accounts'
|
||||
|
||||
|
||||
|
||||
## List all Accounts {{ tag: 'GET' , label: '/api/accounts' }}
|
||||
|
||||
<Row>
|
||||
<Col>
|
||||
Returns a list of accounts of a user. Always returns a list of one account.
|
||||
</Col>
|
||||
|
||||
<Col sticky>
|
||||
<CodeGroup title="Request" tag="GET" label="/api/accounts">
|
||||
```bash {{ title: 'cURL' }}
|
||||
curl -X GET https://api.netbird.io/api/accounts \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Authorization: Token <TOKEN>'
|
||||
```
|
||||
|
||||
```js
|
||||
const axios = require('axios');
|
||||
|
||||
let config = {
|
||||
method: 'get',
|
||||
maxBodyLength: Infinity,
|
||||
url: '/api/accounts',
|
||||
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/accounts"
|
||||
|
||||
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/accounts"
|
||||
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/accounts")
|
||||
|
||||
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/accounts")
|
||||
.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/accounts',
|
||||
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": "ch8i4ug6lnn4g9hqv7l0",
|
||||
"settings": {
|
||||
"peer_login_expiration_enabled": true,
|
||||
"peer_login_expiration": 43200,
|
||||
"peer_inactivity_expiration_enabled": true,
|
||||
"peer_inactivity_expiration": 43200,
|
||||
"regular_users_view_blocked": true,
|
||||
"groups_propagation_enabled": true,
|
||||
"jwt_groups_enabled": true,
|
||||
"jwt_groups_claim_name": "roles",
|
||||
"jwt_allow_groups": [
|
||||
"Administrators"
|
||||
],
|
||||
"routing_peer_dns_resolution_enabled": true,
|
||||
"dns_domain": "my-organization.org",
|
||||
"extra": {
|
||||
"peer_approval_enabled": true,
|
||||
"network_traffic_logs_enabled": true,
|
||||
"network_traffic_packet_counter_enabled": true
|
||||
},
|
||||
"lazy_connection_enabled": true
|
||||
},
|
||||
"domain": "netbird.io",
|
||||
"domain_category": "private",
|
||||
"created_at": "2023-05-05T09:00:35.477782Z",
|
||||
"created_by": "google-oauth2|277474792786460067937",
|
||||
"onboarding": {
|
||||
"signup_form_pending": true,
|
||||
"onboarding_flow_pending": false
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
```json {{ title: 'Schema' }}
|
||||
[
|
||||
{
|
||||
"id": "string",
|
||||
"settings": {
|
||||
"peer_login_expiration_enabled": "boolean",
|
||||
"peer_login_expiration": "integer",
|
||||
"peer_inactivity_expiration_enabled": "boolean",
|
||||
"peer_inactivity_expiration": "integer",
|
||||
"regular_users_view_blocked": "boolean",
|
||||
"groups_propagation_enabled": "boolean",
|
||||
"jwt_groups_enabled": "boolean",
|
||||
"jwt_groups_claim_name": "string",
|
||||
"jwt_allow_groups": [
|
||||
"string"
|
||||
],
|
||||
"routing_peer_dns_resolution_enabled": "boolean",
|
||||
"dns_domain": "string",
|
||||
"extra": {
|
||||
"peer_approval_enabled": "boolean",
|
||||
"network_traffic_logs_enabled": "boolean",
|
||||
"network_traffic_packet_counter_enabled": "boolean"
|
||||
},
|
||||
"lazy_connection_enabled": "boolean"
|
||||
},
|
||||
"domain": "string",
|
||||
"domain_category": "string",
|
||||
"created_at": "string",
|
||||
"created_by": "string",
|
||||
"onboarding": {
|
||||
"signup_form_pending": "boolean",
|
||||
"onboarding_flow_pending": "boolean"
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Delete an Account {{ tag: 'DELETE' , label: '/api/accounts/{accountId}' }}
|
||||
|
||||
<Row>
|
||||
<Col>
|
||||
Deletes an account and all its resources. Only account owners can delete accounts.
|
||||
|
||||
### Path Parameters
|
||||
<Properties>
|
||||
|
||||
<Property name="accountId" type="string" required={true}>
|
||||
The unique identifier of an account
|
||||
</Property>
|
||||
</Properties>
|
||||
</Col>
|
||||
|
||||
<Col sticky>
|
||||
<CodeGroup title="Request" tag="DELETE" label="/api/accounts/{accountId}">
|
||||
```bash {{ title: 'cURL' }}
|
||||
curl -X DELETE https://api.netbird.io/api/accounts/{accountId} \
|
||||
-H 'Authorization: Token <TOKEN>'
|
||||
```
|
||||
|
||||
```js
|
||||
const axios = require('axios');
|
||||
|
||||
let config = {
|
||||
method: 'delete',
|
||||
maxBodyLength: Infinity,
|
||||
url: '/api/accounts/{accountId}',
|
||||
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/accounts/{accountId}"
|
||||
|
||||
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/accounts/{accountId}"
|
||||
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/accounts/{accountId}")
|
||||
|
||||
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/accounts/{accountId}")
|
||||
.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/accounts/{accountId}',
|
||||
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>
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Update an Account {{ tag: 'PUT' , label: '/api/accounts/{accountId}' }}
|
||||
|
||||
<Row>
|
||||
<Col>
|
||||
Update information about an account
|
||||
|
||||
### Path Parameters
|
||||
<Properties>
|
||||
|
||||
<Property name="accountId" type="string" required={true}>
|
||||
The unique identifier of an account
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
### Request-Body Parameters
|
||||
|
||||
<Properties><Property name="settings" type="object" required={true}>
|
||||
|
||||
<details class="custom-details" open>
|
||||
<summary>More Information</summary>
|
||||
<Properties>
|
||||
|
||||
<Properties><Property name="peer_login_expiration_enabled" type="boolean" required={true}>
|
||||
|
||||
Enables or disables peer login expiration globally. After peer's login has expired the user has to log in (authenticate). Applies only to peers that were added by a user (interactive SSO login).
|
||||
|
||||
</Property>
|
||||
<Property name="peer_login_expiration" type="integer" required={true}>
|
||||
|
||||
Period of time after which peer login expires (seconds).
|
||||
|
||||
</Property>
|
||||
<Property name="peer_inactivity_expiration_enabled" type="boolean" required={true}>
|
||||
|
||||
Enables or disables peer inactivity expiration globally. After peer's session has expired the user has to log in (authenticate). Applies only to peers that were added by a user (interactive SSO login).
|
||||
|
||||
</Property>
|
||||
<Property name="peer_inactivity_expiration" type="integer" required={true}>
|
||||
|
||||
Period of time of inactivity after which peer session expires (seconds).
|
||||
|
||||
</Property>
|
||||
<Property name="regular_users_view_blocked" type="boolean" required={true}>
|
||||
|
||||
Allows blocking regular users from viewing parts of the system.
|
||||
|
||||
</Property>
|
||||
<Property name="groups_propagation_enabled" type="boolean" required={false}>
|
||||
|
||||
Allows propagate the new user auto groups to peers that belongs to the user
|
||||
|
||||
</Property>
|
||||
<Property name="jwt_groups_enabled" type="boolean" required={false}>
|
||||
|
||||
Allows extract groups from JWT claim and add it to account groups.
|
||||
|
||||
</Property>
|
||||
<Property name="jwt_groups_claim_name" type="string" required={false}>
|
||||
|
||||
Name of the claim from which we extract groups names to add it to account groups.
|
||||
|
||||
</Property>
|
||||
<Property name="jwt_allow_groups" type="string[]" required={false}>
|
||||
|
||||
List of groups to which users are allowed access
|
||||
|
||||
</Property>
|
||||
<Property name="routing_peer_dns_resolution_enabled" type="boolean" required={false}>
|
||||
|
||||
Enables or disables DNS resolution on the routing peers
|
||||
|
||||
</Property>
|
||||
<Property name="dns_domain" type="string" required={false}>
|
||||
|
||||
Allows to define a custom dns domain for the account
|
||||
|
||||
</Property>
|
||||
<Property name="extra" type="object" required={false}>
|
||||
|
||||
<details class="custom-details" open>
|
||||
<summary>More Information</summary>
|
||||
<Properties>
|
||||
|
||||
<Properties><Property name="peer_approval_enabled" type="boolean" required={true}>
|
||||
|
||||
(Cloud only) Enables or disables peer approval globally. If enabled, all peers added will be in pending state until approved by an admin.
|
||||
|
||||
</Property>
|
||||
<Property name="network_traffic_logs_enabled" type="boolean" required={true}>
|
||||
|
||||
Enables or disables network traffic logging. If enabled, all network traffic events from peers will be stored.
|
||||
|
||||
</Property>
|
||||
<Property name="network_traffic_packet_counter_enabled" type="boolean" required={true}>
|
||||
|
||||
Enables or disables network traffic packet counter. If enabled, network packets and their size will be counted and reported. (This can have an slight impact on performance)
|
||||
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
</Properties>
|
||||
</details>
|
||||
|
||||
</Property>
|
||||
<Property name="lazy_connection_enabled" type="boolean" required={false}>
|
||||
|
||||
Enables or disables experimental lazy connection
|
||||
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
</Properties>
|
||||
</details>
|
||||
|
||||
</Property>
|
||||
<Property name="onboarding" type="object" required={false}>
|
||||
|
||||
<details class="custom-details" open>
|
||||
<summary>More Information</summary>
|
||||
<Properties>
|
||||
|
||||
<Properties><Property name="signup_form_pending" type="boolean" required={true}>
|
||||
|
||||
Indicates whether the account signup form is pending
|
||||
|
||||
</Property>
|
||||
<Property name="onboarding_flow_pending" type="boolean" required={true}>
|
||||
|
||||
Indicates whether the account onboarding flow is pending
|
||||
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
</Properties>
|
||||
</details>
|
||||
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
|
||||
</Col>
|
||||
|
||||
<Col sticky>
|
||||
<CodeGroup title="Request" tag="PUT" label="/api/accounts/{accountId}">
|
||||
```bash {{ title: 'cURL' }}
|
||||
curl -X PUT https://api.netbird.io/api/accounts/{accountId} \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Authorization: Token <TOKEN>' \
|
||||
--data-raw '{
|
||||
"settings": {
|
||||
"peer_login_expiration_enabled": true,
|
||||
"peer_login_expiration": 43200,
|
||||
"peer_inactivity_expiration_enabled": true,
|
||||
"peer_inactivity_expiration": 43200,
|
||||
"regular_users_view_blocked": true,
|
||||
"groups_propagation_enabled": true,
|
||||
"jwt_groups_enabled": true,
|
||||
"jwt_groups_claim_name": "roles",
|
||||
"jwt_allow_groups": [
|
||||
"Administrators"
|
||||
],
|
||||
"routing_peer_dns_resolution_enabled": true,
|
||||
"dns_domain": "my-organization.org",
|
||||
"extra": {
|
||||
"peer_approval_enabled": true,
|
||||
"network_traffic_logs_enabled": true,
|
||||
"network_traffic_packet_counter_enabled": true
|
||||
},
|
||||
"lazy_connection_enabled": true
|
||||
},
|
||||
"onboarding": {
|
||||
"signup_form_pending": true,
|
||||
"onboarding_flow_pending": false
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
```js
|
||||
const axios = require('axios');
|
||||
let data = JSON.stringify({
|
||||
"settings": {
|
||||
"peer_login_expiration_enabled": true,
|
||||
"peer_login_expiration": 43200,
|
||||
"peer_inactivity_expiration_enabled": true,
|
||||
"peer_inactivity_expiration": 43200,
|
||||
"regular_users_view_blocked": true,
|
||||
"groups_propagation_enabled": true,
|
||||
"jwt_groups_enabled": true,
|
||||
"jwt_groups_claim_name": "roles",
|
||||
"jwt_allow_groups": [
|
||||
"Administrators"
|
||||
],
|
||||
"routing_peer_dns_resolution_enabled": true,
|
||||
"dns_domain": "my-organization.org",
|
||||
"extra": {
|
||||
"peer_approval_enabled": true,
|
||||
"network_traffic_logs_enabled": true,
|
||||
"network_traffic_packet_counter_enabled": true
|
||||
},
|
||||
"lazy_connection_enabled": true
|
||||
},
|
||||
"onboarding": {
|
||||
"signup_form_pending": true,
|
||||
"onboarding_flow_pending": false
|
||||
}
|
||||
});
|
||||
let config = {
|
||||
method: 'put',
|
||||
maxBodyLength: Infinity,
|
||||
url: '/api/accounts/{accountId}',
|
||||
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/accounts/{accountId}"
|
||||
payload = json.dumps({
|
||||
"settings": {
|
||||
"peer_login_expiration_enabled": true,
|
||||
"peer_login_expiration": 43200,
|
||||
"peer_inactivity_expiration_enabled": true,
|
||||
"peer_inactivity_expiration": 43200,
|
||||
"regular_users_view_blocked": true,
|
||||
"groups_propagation_enabled": true,
|
||||
"jwt_groups_enabled": true,
|
||||
"jwt_groups_claim_name": "roles",
|
||||
"jwt_allow_groups": [
|
||||
"Administrators"
|
||||
],
|
||||
"routing_peer_dns_resolution_enabled": true,
|
||||
"dns_domain": "my-organization.org",
|
||||
"extra": {
|
||||
"peer_approval_enabled": true,
|
||||
"network_traffic_logs_enabled": true,
|
||||
"network_traffic_packet_counter_enabled": true
|
||||
},
|
||||
"lazy_connection_enabled": true
|
||||
},
|
||||
"onboarding": {
|
||||
"signup_form_pending": true,
|
||||
"onboarding_flow_pending": false
|
||||
}
|
||||
})
|
||||
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/accounts/{accountId}"
|
||||
method := "PUT"
|
||||
|
||||
payload := strings.NewReader(`{
|
||||
"settings": {
|
||||
"peer_login_expiration_enabled": true,
|
||||
"peer_login_expiration": 43200,
|
||||
"peer_inactivity_expiration_enabled": true,
|
||||
"peer_inactivity_expiration": 43200,
|
||||
"regular_users_view_blocked": true,
|
||||
"groups_propagation_enabled": true,
|
||||
"jwt_groups_enabled": true,
|
||||
"jwt_groups_claim_name": "roles",
|
||||
"jwt_allow_groups": [
|
||||
"Administrators"
|
||||
],
|
||||
"routing_peer_dns_resolution_enabled": true,
|
||||
"dns_domain": "my-organization.org",
|
||||
"extra": {
|
||||
"peer_approval_enabled": true,
|
||||
"network_traffic_logs_enabled": true,
|
||||
"network_traffic_packet_counter_enabled": true
|
||||
},
|
||||
"lazy_connection_enabled": true
|
||||
},
|
||||
"onboarding": {
|
||||
"signup_form_pending": true,
|
||||
"onboarding_flow_pending": false
|
||||
}
|
||||
}`)
|
||||
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/accounts/{accountId}")
|
||||
|
||||
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({
|
||||
"settings": {
|
||||
"peer_login_expiration_enabled": true,
|
||||
"peer_login_expiration": 43200,
|
||||
"peer_inactivity_expiration_enabled": true,
|
||||
"peer_inactivity_expiration": 43200,
|
||||
"regular_users_view_blocked": true,
|
||||
"groups_propagation_enabled": true,
|
||||
"jwt_groups_enabled": true,
|
||||
"jwt_groups_claim_name": "roles",
|
||||
"jwt_allow_groups": [
|
||||
"Administrators"
|
||||
],
|
||||
"routing_peer_dns_resolution_enabled": true,
|
||||
"dns_domain": "my-organization.org",
|
||||
"extra": {
|
||||
"peer_approval_enabled": true,
|
||||
"network_traffic_logs_enabled": true,
|
||||
"network_traffic_packet_counter_enabled": true
|
||||
},
|
||||
"lazy_connection_enabled": true
|
||||
},
|
||||
"onboarding": {
|
||||
"signup_form_pending": true,
|
||||
"onboarding_flow_pending": false
|
||||
}
|
||||
})
|
||||
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, '{
|
||||
"settings": {
|
||||
"peer_login_expiration_enabled": true,
|
||||
"peer_login_expiration": 43200,
|
||||
"peer_inactivity_expiration_enabled": true,
|
||||
"peer_inactivity_expiration": 43200,
|
||||
"regular_users_view_blocked": true,
|
||||
"groups_propagation_enabled": true,
|
||||
"jwt_groups_enabled": true,
|
||||
"jwt_groups_claim_name": "roles",
|
||||
"jwt_allow_groups": [
|
||||
"Administrators"
|
||||
],
|
||||
"routing_peer_dns_resolution_enabled": true,
|
||||
"dns_domain": "my-organization.org",
|
||||
"extra": {
|
||||
"peer_approval_enabled": true,
|
||||
"network_traffic_logs_enabled": true,
|
||||
"network_traffic_packet_counter_enabled": true
|
||||
},
|
||||
"lazy_connection_enabled": true
|
||||
},
|
||||
"onboarding": {
|
||||
"signup_form_pending": true,
|
||||
"onboarding_flow_pending": false
|
||||
}
|
||||
}');
|
||||
Request request = new Request.Builder()
|
||||
.url("https://api.netbird.io/api/accounts/{accountId}")
|
||||
.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/accounts/{accountId}',
|
||||
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 => '{
|
||||
"settings": {
|
||||
"peer_login_expiration_enabled": true,
|
||||
"peer_login_expiration": 43200,
|
||||
"peer_inactivity_expiration_enabled": true,
|
||||
"peer_inactivity_expiration": 43200,
|
||||
"regular_users_view_blocked": true,
|
||||
"groups_propagation_enabled": true,
|
||||
"jwt_groups_enabled": true,
|
||||
"jwt_groups_claim_name": "roles",
|
||||
"jwt_allow_groups": [
|
||||
"Administrators"
|
||||
],
|
||||
"routing_peer_dns_resolution_enabled": true,
|
||||
"dns_domain": "my-organization.org",
|
||||
"extra": {
|
||||
"peer_approval_enabled": true,
|
||||
"network_traffic_logs_enabled": true,
|
||||
"network_traffic_packet_counter_enabled": true
|
||||
},
|
||||
"lazy_connection_enabled": true
|
||||
},
|
||||
"onboarding": {
|
||||
"signup_form_pending": true,
|
||||
"onboarding_flow_pending": false
|
||||
}
|
||||
}',
|
||||
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": "ch8i4ug6lnn4g9hqv7l0",
|
||||
"settings": {
|
||||
"peer_login_expiration_enabled": true,
|
||||
"peer_login_expiration": 43200,
|
||||
"peer_inactivity_expiration_enabled": true,
|
||||
"peer_inactivity_expiration": 43200,
|
||||
"regular_users_view_blocked": true,
|
||||
"groups_propagation_enabled": true,
|
||||
"jwt_groups_enabled": true,
|
||||
"jwt_groups_claim_name": "roles",
|
||||
"jwt_allow_groups": [
|
||||
"Administrators"
|
||||
],
|
||||
"routing_peer_dns_resolution_enabled": true,
|
||||
"dns_domain": "my-organization.org",
|
||||
"extra": {
|
||||
"peer_approval_enabled": true,
|
||||
"network_traffic_logs_enabled": true,
|
||||
"network_traffic_packet_counter_enabled": true
|
||||
},
|
||||
"lazy_connection_enabled": true
|
||||
},
|
||||
"domain": "netbird.io",
|
||||
"domain_category": "private",
|
||||
"created_at": "2023-05-05T09:00:35.477782Z",
|
||||
"created_by": "google-oauth2|277474792786460067937",
|
||||
"onboarding": {
|
||||
"signup_form_pending": true,
|
||||
"onboarding_flow_pending": false
|
||||
}
|
||||
}
|
||||
```
|
||||
```json {{ title: 'Schema' }}
|
||||
{
|
||||
"id": "string",
|
||||
"settings": {
|
||||
"peer_login_expiration_enabled": "boolean",
|
||||
"peer_login_expiration": "integer",
|
||||
"peer_inactivity_expiration_enabled": "boolean",
|
||||
"peer_inactivity_expiration": "integer",
|
||||
"regular_users_view_blocked": "boolean",
|
||||
"groups_propagation_enabled": "boolean",
|
||||
"jwt_groups_enabled": "boolean",
|
||||
"jwt_groups_claim_name": "string",
|
||||
"jwt_allow_groups": [
|
||||
"string"
|
||||
],
|
||||
"routing_peer_dns_resolution_enabled": "boolean",
|
||||
"dns_domain": "string",
|
||||
"extra": {
|
||||
"peer_approval_enabled": "boolean",
|
||||
"network_traffic_logs_enabled": "boolean",
|
||||
"network_traffic_packet_counter_enabled": "boolean"
|
||||
},
|
||||
"lazy_connection_enabled": "boolean"
|
||||
},
|
||||
"domain": "string",
|
||||
"domain_category": "string",
|
||||
"created_at": "string",
|
||||
"created_by": "string",
|
||||
"onboarding": {
|
||||
"signup_form_pending": "boolean",
|
||||
"onboarding_flow_pending": "boolean"
|
||||
}
|
||||
}
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
---
|
||||
1878
src/pages/ipa/resources/dns.mdx
Normal file
1878
src/pages/ipa/resources/dns.mdx
Normal file
File diff suppressed because it is too large
Load Diff
563
src/pages/ipa/resources/events.mdx
Normal file
563
src/pages/ipa/resources/events.mdx
Normal file
@@ -0,0 +1,563 @@
|
||||
export const title = 'Events'
|
||||
|
||||
|
||||
|
||||
## List all Audit Events {{ tag: 'GET' , label: '/api/events/audit' }}
|
||||
|
||||
<Row>
|
||||
<Col>
|
||||
Returns a list of all audit events
|
||||
</Col>
|
||||
|
||||
<Col sticky>
|
||||
<CodeGroup title="Request" tag="GET" label="/api/events/audit">
|
||||
```bash {{ title: 'cURL' }}
|
||||
curl -X GET https://api.netbird.io/api/events/audit \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Authorization: Token <TOKEN>'
|
||||
```
|
||||
|
||||
```js
|
||||
const axios = require('axios');
|
||||
|
||||
let config = {
|
||||
method: 'get',
|
||||
maxBodyLength: Infinity,
|
||||
url: '/api/events/audit',
|
||||
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/events/audit"
|
||||
|
||||
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/events/audit"
|
||||
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/events/audit")
|
||||
|
||||
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/events/audit")
|
||||
.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/events/audit',
|
||||
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": 10,
|
||||
"timestamp": "2023-05-05T10:04:37.473542Z",
|
||||
"activity": "Route created",
|
||||
"activity_code": "route.add",
|
||||
"initiator_id": "google-oauth2|123456789012345678901",
|
||||
"initiator_name": "John Doe",
|
||||
"initiator_email": "demo@netbird.io",
|
||||
"target_id": "chad9d86lnnc59g18ou0",
|
||||
"meta": {
|
||||
"name": "my route",
|
||||
"network_range": "10.64.0.0/24",
|
||||
"peer_id": "chacbco6lnnbn6cg5s91"
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
```json {{ title: 'Schema' }}
|
||||
[
|
||||
{
|
||||
"id": "string",
|
||||
"timestamp": "string",
|
||||
"activity": "string",
|
||||
"activity_code": "string",
|
||||
"initiator_id": "string",
|
||||
"initiator_name": "string",
|
||||
"initiator_email": "string",
|
||||
"target_id": "string",
|
||||
"meta": {
|
||||
"description": "The metadata of the event",
|
||||
"type": "object",
|
||||
"additionalProperties": "string",
|
||||
"example": {
|
||||
"name": "my route",
|
||||
"network_range": "10.64.0.0/24",
|
||||
"peer_id": "chacbco6lnnbn6cg5s91"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
---
|
||||
|
||||
|
||||
## List all Traffic Events <Badge status="cloud-only" text="cloud-only" hoverText="This feature is only available in the cloud version of NetBird." /> <Badge status="experimental" text="experimental" hoverText="This feature is experimental. The endpoint will likely change and we do not guarantee backwards compatibility." /> {{ tag: 'GET' , label: '/api/events/network-traffic' }}
|
||||
|
||||
<Row>
|
||||
<Col>
|
||||
Returns a list of all network traffic events
|
||||
|
||||
### Query Parameters
|
||||
<Properties>
|
||||
|
||||
<Property name="page" type="integer" required={false}>
|
||||
Page number
|
||||
</Property>
|
||||
|
||||
<Property name="page_size" type="integer" required={false}>
|
||||
Number of items per page
|
||||
</Property>
|
||||
|
||||
<Property name="user_id" type="string" required={false}>
|
||||
Filter by user ID
|
||||
</Property>
|
||||
|
||||
<Property name="reporter_id" type="string" required={false}>
|
||||
Filter by reporter ID
|
||||
</Property>
|
||||
|
||||
<Property name="protocol" type="integer" required={false}>
|
||||
Filter by protocol
|
||||
</Property>
|
||||
|
||||
<Property name="type" type="string" required={false}>
|
||||
Filter by event type
|
||||
</Property>
|
||||
|
||||
<Property name="connection_type" type="string" required={false}>
|
||||
Filter by connection type
|
||||
</Property>
|
||||
|
||||
<Property name="direction" type="string" required={false}>
|
||||
Filter by direction
|
||||
</Property>
|
||||
|
||||
<Property name="search" type="string" required={false}>
|
||||
Case-insensitive partial match on user email, source/destination names, and source/destination addresses
|
||||
</Property>
|
||||
|
||||
<Property name="start_date" type="string" required={false}>
|
||||
Start date for filtering events (ISO 8601 format, e.g., 2024-01-01T00:00:00Z).
|
||||
</Property>
|
||||
|
||||
<Property name="end_date" type="string" required={false}>
|
||||
End date for filtering events (ISO 8601 format, e.g., 2024-01-31T23:59:59Z).
|
||||
</Property>
|
||||
</Properties>
|
||||
</Col>
|
||||
|
||||
<Col sticky>
|
||||
<CodeGroup title="Request" tag="GET" label="/api/events/network-traffic">
|
||||
```bash {{ title: 'cURL' }}
|
||||
curl -X GET https://api.netbird.io/api/events/network-traffic \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Authorization: Token <TOKEN>'
|
||||
```
|
||||
|
||||
```js
|
||||
const axios = require('axios');
|
||||
|
||||
let config = {
|
||||
method: 'get',
|
||||
maxBodyLength: Infinity,
|
||||
url: '/api/events/network-traffic',
|
||||
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/events/network-traffic"
|
||||
|
||||
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/events/network-traffic"
|
||||
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/events/network-traffic")
|
||||
|
||||
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/events/network-traffic")
|
||||
.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/events/network-traffic',
|
||||
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' }}
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"flow_id": "61092452-b17c-4b14-b7cf-a2158c549826",
|
||||
"reporter_id": "ch8i4ug6lnn4g9hqv7m0",
|
||||
"source": {
|
||||
"id": "ch8i4ug6lnn4g9hqv7m0",
|
||||
"type": "PEER",
|
||||
"name": "My Peer",
|
||||
"geo_location": {
|
||||
"city_name": "Berlin",
|
||||
"country_code": "DE"
|
||||
},
|
||||
"os": "Linux",
|
||||
"address": "100.64.0.10:51820",
|
||||
"dns_label": "*.mydomain.com"
|
||||
},
|
||||
"destination": {
|
||||
"id": "ch8i4ug6lnn4g9hqv7m0",
|
||||
"type": "PEER",
|
||||
"name": "My Peer",
|
||||
"geo_location": {
|
||||
"city_name": "Berlin",
|
||||
"country_code": "DE"
|
||||
},
|
||||
"os": "Linux",
|
||||
"address": "100.64.0.10:51820",
|
||||
"dns_label": "*.mydomain.com"
|
||||
},
|
||||
"user": {
|
||||
"id": "google-oauth2|123456789012345678901",
|
||||
"email": "alice@netbird.io",
|
||||
"name": "Alice Smith"
|
||||
},
|
||||
"policy": {
|
||||
"id": "ch8i4ug6lnn4g9hqv7m0",
|
||||
"name": "All to All"
|
||||
},
|
||||
"icmp": {
|
||||
"type": 8,
|
||||
"code": 0
|
||||
},
|
||||
"protocol": 6,
|
||||
"direction": "INGRESS",
|
||||
"rx_bytes": 1234,
|
||||
"rx_packets": 5,
|
||||
"tx_bytes": 1234,
|
||||
"tx_packets": 5,
|
||||
"events": [
|
||||
{
|
||||
"type": "TYPE_START",
|
||||
"timestamp": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"page": {
|
||||
"type": "integer",
|
||||
"description": "Current page number"
|
||||
},
|
||||
"page_size": {
|
||||
"type": "integer",
|
||||
"description": "Number of items per page"
|
||||
},
|
||||
"total_records": {
|
||||
"type": "integer",
|
||||
"description": "Total number of event records available"
|
||||
},
|
||||
"total_pages": {
|
||||
"type": "integer",
|
||||
"description": "Total number of pages available"
|
||||
}
|
||||
}
|
||||
```
|
||||
```json {{ title: 'Schema' }}
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"flow_id": "string",
|
||||
"reporter_id": "string",
|
||||
"source": {
|
||||
"id": "string",
|
||||
"type": "string",
|
||||
"name": "string",
|
||||
"geo_location": {
|
||||
"city_name": "string",
|
||||
"country_code": "string"
|
||||
},
|
||||
"os": "string",
|
||||
"address": "string",
|
||||
"dns_label": "string"
|
||||
},
|
||||
"destination": {
|
||||
"id": "string",
|
||||
"type": "string",
|
||||
"name": "string",
|
||||
"geo_location": {
|
||||
"city_name": "string",
|
||||
"country_code": "string"
|
||||
},
|
||||
"os": "string",
|
||||
"address": "string",
|
||||
"dns_label": "string"
|
||||
},
|
||||
"user": {
|
||||
"id": "string",
|
||||
"email": "string",
|
||||
"name": "string"
|
||||
},
|
||||
"policy": {
|
||||
"id": "string",
|
||||
"name": "string"
|
||||
},
|
||||
"icmp": {
|
||||
"type": "integer",
|
||||
"code": "integer"
|
||||
},
|
||||
"protocol": "integer",
|
||||
"direction": "string",
|
||||
"rx_bytes": "integer",
|
||||
"rx_packets": "integer",
|
||||
"tx_bytes": "integer",
|
||||
"tx_packets": "integer",
|
||||
"events": [
|
||||
{
|
||||
"type": "string",
|
||||
"timestamp": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"page": "integer",
|
||||
"page_size": "integer",
|
||||
"total_records": "integer",
|
||||
"total_pages": "integer"
|
||||
}
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
---
|
||||
364
src/pages/ipa/resources/geo-locations.mdx
Normal file
364
src/pages/ipa/resources/geo-locations.mdx
Normal file
@@ -0,0 +1,364 @@
|
||||
export const title = 'Geo Locations'
|
||||
|
||||
|
||||
|
||||
## List all country codes {{ tag: 'GET' , label: '/api/locations/countries' }}
|
||||
|
||||
<Row>
|
||||
<Col>
|
||||
Get list of all country in 2-letter ISO 3166-1 alpha-2 codes
|
||||
</Col>
|
||||
|
||||
<Col sticky>
|
||||
<CodeGroup title="Request" tag="GET" label="/api/locations/countries">
|
||||
```bash {{ title: 'cURL' }}
|
||||
curl -X GET https://api.netbird.io/api/locations/countries \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Authorization: Token <TOKEN>'
|
||||
```
|
||||
|
||||
```js
|
||||
const axios = require('axios');
|
||||
|
||||
let config = {
|
||||
method: 'get',
|
||||
maxBodyLength: Infinity,
|
||||
url: '/api/locations/countries',
|
||||
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/locations/countries"
|
||||
|
||||
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/locations/countries"
|
||||
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/locations/countries")
|
||||
|
||||
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/locations/countries")
|
||||
.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/locations/countries',
|
||||
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' }}
|
||||
[
|
||||
"DE"
|
||||
]
|
||||
```
|
||||
```json {{ title: 'Schema' }}
|
||||
[
|
||||
"string"
|
||||
]
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
---
|
||||
|
||||
|
||||
## List all city names by country {{ tag: 'GET' , label: '/api/locations/countries/{country}/cities' }}
|
||||
|
||||
<Row>
|
||||
<Col>
|
||||
Get a list of all English city names for a given country code
|
||||
|
||||
### Path Parameters
|
||||
<Properties>
|
||||
|
||||
<Property name="country" type="string" required={true}>
|
||||
|
||||
</Property>
|
||||
</Properties>
|
||||
</Col>
|
||||
|
||||
<Col sticky>
|
||||
<CodeGroup title="Request" tag="GET" label="/api/locations/countries/{country}/cities">
|
||||
```bash {{ title: 'cURL' }}
|
||||
curl -X GET https://api.netbird.io/api/locations/countries/{country}/cities \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Authorization: Token <TOKEN>'
|
||||
```
|
||||
|
||||
```js
|
||||
const axios = require('axios');
|
||||
|
||||
let config = {
|
||||
method: 'get',
|
||||
maxBodyLength: Infinity,
|
||||
url: '/api/locations/countries/{country}/cities',
|
||||
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/locations/countries/{country}/cities"
|
||||
|
||||
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/locations/countries/{country}/cities"
|
||||
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/locations/countries/{country}/cities")
|
||||
|
||||
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/locations/countries/{country}/cities")
|
||||
.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/locations/countries/{country}/cities',
|
||||
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' }}
|
||||
{
|
||||
"geoname_id": 2950158,
|
||||
"city_name": "Berlin"
|
||||
}
|
||||
```
|
||||
```json {{ title: 'Schema' }}
|
||||
{
|
||||
"geoname_id": "integer",
|
||||
"city_name": "string"
|
||||
}
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
---
|
||||
1274
src/pages/ipa/resources/groups.mdx
Normal file
1274
src/pages/ipa/resources/groups.mdx
Normal file
File diff suppressed because it is too large
Load Diff
2470
src/pages/ipa/resources/ingress-ports.mdx
Normal file
2470
src/pages/ipa/resources/ingress-ports.mdx
Normal file
File diff suppressed because it is too large
Load Diff
3680
src/pages/ipa/resources/networks.mdx
Normal file
3680
src/pages/ipa/resources/networks.mdx
Normal file
File diff suppressed because it is too large
Load Diff
1232
src/pages/ipa/resources/peers.mdx
Normal file
1232
src/pages/ipa/resources/peers.mdx
Normal file
File diff suppressed because it is too large
Load Diff
2214
src/pages/ipa/resources/policies.mdx
Normal file
2214
src/pages/ipa/resources/policies.mdx
Normal file
File diff suppressed because it is too large
Load Diff
2506
src/pages/ipa/resources/posture-checks.mdx
Normal file
2506
src/pages/ipa/resources/posture-checks.mdx
Normal file
File diff suppressed because it is too large
Load Diff
1510
src/pages/ipa/resources/routes.mdx
Normal file
1510
src/pages/ipa/resources/routes.mdx
Normal file
File diff suppressed because it is too large
Load Diff
1206
src/pages/ipa/resources/setup-keys.mdx
Normal file
1206
src/pages/ipa/resources/setup-keys.mdx
Normal file
File diff suppressed because it is too large
Load Diff
816
src/pages/ipa/resources/tokens.mdx
Normal file
816
src/pages/ipa/resources/tokens.mdx
Normal file
@@ -0,0 +1,816 @@
|
||||
export const title = 'Tokens'
|
||||
|
||||
|
||||
|
||||
## List all Tokens {{ tag: 'GET' , label: '/api/users/{userId}/tokens' }}
|
||||
|
||||
<Row>
|
||||
<Col>
|
||||
Returns a list of all tokens for a user
|
||||
|
||||
### Path Parameters
|
||||
<Properties>
|
||||
|
||||
<Property name="userId" type="string" required={true}>
|
||||
The unique identifier of a user
|
||||
</Property>
|
||||
</Properties>
|
||||
</Col>
|
||||
|
||||
<Col sticky>
|
||||
<CodeGroup title="Request" tag="GET" label="/api/users/{userId}/tokens">
|
||||
```bash {{ title: 'cURL' }}
|
||||
curl -X GET https://api.netbird.io/api/users/{userId}/tokens \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Authorization: Token <TOKEN>'
|
||||
```
|
||||
|
||||
```js
|
||||
const axios = require('axios');
|
||||
|
||||
let config = {
|
||||
method: 'get',
|
||||
maxBodyLength: Infinity,
|
||||
url: '/api/users/{userId}/tokens',
|
||||
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/users/{userId}/tokens"
|
||||
|
||||
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/users/{userId}/tokens"
|
||||
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/users/{userId}/tokens")
|
||||
|
||||
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/users/{userId}/tokens")
|
||||
.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/users/{userId}/tokens',
|
||||
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": "ch8i54g6lnn4g9hqv7n0",
|
||||
"name": "My first token",
|
||||
"expiration_date": "2023-05-05T14:38:28.977616Z",
|
||||
"created_by": "google-oauth2|277474792786460067937",
|
||||
"created_at": "2023-05-02T14:48:20.465209Z",
|
||||
"last_used": "2023-05-04T12:45:25.9723616Z"
|
||||
}
|
||||
]
|
||||
```
|
||||
```json {{ title: 'Schema' }}
|
||||
[
|
||||
{
|
||||
"id": "string",
|
||||
"name": "string",
|
||||
"expiration_date": "string",
|
||||
"created_by": "string",
|
||||
"created_at": "string",
|
||||
"last_used": "string"
|
||||
}
|
||||
]
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Create a Token {{ tag: 'POST' , label: '/api/users/{userId}/tokens' }}
|
||||
|
||||
<Row>
|
||||
<Col>
|
||||
Create a new token for a user
|
||||
|
||||
### Path Parameters
|
||||
<Properties>
|
||||
|
||||
<Property name="userId" type="string" required={true}>
|
||||
The unique identifier of a user
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
### Request-Body Parameters
|
||||
|
||||
<Properties><Property name="name" type="string" required={true}>
|
||||
|
||||
Name of the token
|
||||
|
||||
</Property>
|
||||
<Property name="expires_in" type="integer" required={true} min={1} max={365}>
|
||||
|
||||
Expiration in days
|
||||
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
|
||||
</Col>
|
||||
|
||||
<Col sticky>
|
||||
<CodeGroup title="Request" tag="POST" label="/api/users/{userId}/tokens">
|
||||
```bash {{ title: 'cURL' }}
|
||||
curl -X POST https://api.netbird.io/api/users/{userId}/tokens \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Authorization: Token <TOKEN>' \
|
||||
--data-raw '{
|
||||
"name": "My first token",
|
||||
"expires_in": 30
|
||||
}'
|
||||
```
|
||||
|
||||
```js
|
||||
const axios = require('axios');
|
||||
let data = JSON.stringify({
|
||||
"name": "My first token",
|
||||
"expires_in": 30
|
||||
});
|
||||
let config = {
|
||||
method: 'post',
|
||||
maxBodyLength: Infinity,
|
||||
url: '/api/users/{userId}/tokens',
|
||||
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/users/{userId}/tokens"
|
||||
payload = json.dumps({
|
||||
"name": "My first token",
|
||||
"expires_in": 30
|
||||
})
|
||||
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/users/{userId}/tokens"
|
||||
method := "POST"
|
||||
|
||||
payload := strings.NewReader(`{
|
||||
"name": "My first token",
|
||||
"expires_in": 30
|
||||
}`)
|
||||
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/users/{userId}/tokens")
|
||||
|
||||
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": "My first token",
|
||||
"expires_in": 30
|
||||
})
|
||||
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": "My first token",
|
||||
"expires_in": 30
|
||||
}');
|
||||
Request request = new Request.Builder()
|
||||
.url("https://api.netbird.io/api/users/{userId}/tokens")
|
||||
.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/users/{userId}/tokens',
|
||||
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": "My first token",
|
||||
"expires_in": 30
|
||||
}',
|
||||
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' }}
|
||||
{
|
||||
"plain_token": {},
|
||||
"personal_access_token": {
|
||||
"id": "ch8i54g6lnn4g9hqv7n0",
|
||||
"name": "My first token",
|
||||
"expiration_date": "2023-05-05T14:38:28.977616Z",
|
||||
"created_by": "google-oauth2|277474792786460067937",
|
||||
"created_at": "2023-05-02T14:48:20.465209Z",
|
||||
"last_used": "2023-05-04T12:45:25.9723616Z"
|
||||
}
|
||||
}
|
||||
```
|
||||
```json {{ title: 'Schema' }}
|
||||
{
|
||||
"plain_token": "string",
|
||||
"personal_access_token": {
|
||||
"id": "string",
|
||||
"name": "string",
|
||||
"expiration_date": "string",
|
||||
"created_by": "string",
|
||||
"created_at": "string",
|
||||
"last_used": "string"
|
||||
}
|
||||
}
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Retrieve a Token {{ tag: 'GET' , label: '/api/users/{userId}/tokens/{tokenId}' }}
|
||||
|
||||
<Row>
|
||||
<Col>
|
||||
Returns a specific token for a user
|
||||
|
||||
### Path Parameters
|
||||
<Properties>
|
||||
|
||||
<Property name="userId" type="string" required={true}>
|
||||
The unique identifier of a user
|
||||
</Property>
|
||||
|
||||
<Property name="tokenId" type="string" required={true}>
|
||||
The unique identifier of a token
|
||||
</Property>
|
||||
</Properties>
|
||||
</Col>
|
||||
|
||||
<Col sticky>
|
||||
<CodeGroup title="Request" tag="GET" label="/api/users/{userId}/tokens/{tokenId}">
|
||||
```bash {{ title: 'cURL' }}
|
||||
curl -X GET https://api.netbird.io/api/users/{userId}/tokens/{tokenId} \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Authorization: Token <TOKEN>'
|
||||
```
|
||||
|
||||
```js
|
||||
const axios = require('axios');
|
||||
|
||||
let config = {
|
||||
method: 'get',
|
||||
maxBodyLength: Infinity,
|
||||
url: '/api/users/{userId}/tokens/{tokenId}',
|
||||
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/users/{userId}/tokens/{tokenId}"
|
||||
|
||||
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/users/{userId}/tokens/{tokenId}"
|
||||
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/users/{userId}/tokens/{tokenId}")
|
||||
|
||||
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/users/{userId}/tokens/{tokenId}")
|
||||
.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/users/{userId}/tokens/{tokenId}',
|
||||
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": "ch8i54g6lnn4g9hqv7n0",
|
||||
"name": "My first token",
|
||||
"expiration_date": "2023-05-05T14:38:28.977616Z",
|
||||
"created_by": "google-oauth2|277474792786460067937",
|
||||
"created_at": "2023-05-02T14:48:20.465209Z",
|
||||
"last_used": "2023-05-04T12:45:25.9723616Z"
|
||||
}
|
||||
```
|
||||
```json {{ title: 'Schema' }}
|
||||
{
|
||||
"id": "string",
|
||||
"name": "string",
|
||||
"expiration_date": "string",
|
||||
"created_by": "string",
|
||||
"created_at": "string",
|
||||
"last_used": "string"
|
||||
}
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Delete a Token {{ tag: 'DELETE' , label: '/api/users/{userId}/tokens/{tokenId}' }}
|
||||
|
||||
<Row>
|
||||
<Col>
|
||||
Delete a token for a user
|
||||
|
||||
### Path Parameters
|
||||
<Properties>
|
||||
|
||||
<Property name="userId" type="string" required={true}>
|
||||
The unique identifier of a user
|
||||
</Property>
|
||||
|
||||
<Property name="tokenId" type="string" required={true}>
|
||||
The unique identifier of a token
|
||||
</Property>
|
||||
</Properties>
|
||||
</Col>
|
||||
|
||||
<Col sticky>
|
||||
<CodeGroup title="Request" tag="DELETE" label="/api/users/{userId}/tokens/{tokenId}">
|
||||
```bash {{ title: 'cURL' }}
|
||||
curl -X DELETE https://api.netbird.io/api/users/{userId}/tokens/{tokenId} \
|
||||
-H 'Authorization: Token <TOKEN>'
|
||||
```
|
||||
|
||||
```js
|
||||
const axios = require('axios');
|
||||
|
||||
let config = {
|
||||
method: 'delete',
|
||||
maxBodyLength: Infinity,
|
||||
url: '/api/users/{userId}/tokens/{tokenId}',
|
||||
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/users/{userId}/tokens/{tokenId}"
|
||||
|
||||
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/users/{userId}/tokens/{tokenId}"
|
||||
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/users/{userId}/tokens/{tokenId}")
|
||||
|
||||
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/users/{userId}/tokens/{tokenId}")
|
||||
.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/users/{userId}/tokens/{tokenId}',
|
||||
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>
|
||||
|
||||
---
|
||||
1510
src/pages/ipa/resources/users.mdx
Normal file
1510
src/pages/ipa/resources/users.mdx
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user