From 87997621c703b650f86686e43ba8238a02898795 Mon Sep 17 00:00:00 2001 From: netbirddev Date: Thu, 12 Sep 2024 18:08:44 +0000 Subject: [PATCH] Update API pages with v0.29.2 --- src/pages/ipa/resources/peers.mdx | 252 +++++++++++++++++++++++++----- 1 file changed, 212 insertions(+), 40 deletions(-) diff --git a/src/pages/ipa/resources/peers.mdx b/src/pages/ipa/resources/peers.mdx index 5e75ab58..49a9dda7 100644 --- a/src/pages/ipa/resources/peers.mdx +++ b/src/pages/ipa/resources/peers.mdx @@ -438,16 +438,7 @@ echo $response; "approval_required": true, "country_code": "DE", "city_name": "Berlin", - "serial_number": "C02XJ0J0JGH7", - "accessible_peers": [ - { - "id": "chacbco6lnnbn6cg5s90", - "name": "stage-host-1", - "ip": "10.64.0.1", - "dns_label": "stage-host-1.netbird.cloud", - "user_id": "google-oauth2|277474792786460067937" - } - ] + "serial_number": "C02XJ0J0JGH7" } ``` ```json {{ title: 'Schema' }} @@ -481,16 +472,7 @@ echo $response; "approval_required": "boolean", "country_code": "string", "city_name": "string", - "serial_number": "string", - "accessible_peers": [ - { - "id": "string", - "name": "string", - "ip": "string", - "dns_label": "string", - "user_id": "string" - } - ] + "serial_number": "string" } ``` @@ -772,16 +754,7 @@ echo $response; "approval_required": true, "country_code": "DE", "city_name": "Berlin", - "serial_number": "C02XJ0J0JGH7", - "accessible_peers": [ - { - "id": "chacbco6lnnbn6cg5s90", - "name": "stage-host-1", - "ip": "10.64.0.1", - "dns_label": "stage-host-1.netbird.cloud", - "user_id": "google-oauth2|277474792786460067937" - } - ] + "serial_number": "C02XJ0J0JGH7" } ``` ```json {{ title: 'Schema' }} @@ -815,16 +788,7 @@ echo $response; "approval_required": "boolean", "country_code": "string", "city_name": "string", - "serial_number": "string", - "accessible_peers": [ - { - "id": "string", - "name": "string", - "ip": "string", - "dns_label": "string", - "user_id": "string" - } - ] + "serial_number": "string" } ``` @@ -998,3 +962,211 @@ echo $response; --- + + +## List accessible Peers {{ tag: 'GET' , label: '/api/peers/{peerId}/accessible-peers' }} + + + + Returns a list of peers that the specified peer can connect to within the network. + + #### Path Parameters + + + + The unique identifier of a peer + + + + + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/peers/{peerId}/accessible-peers \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' +``` + +```js +const axios = require('axios'); + +let config = { + method: 'get', + maxBodyLength: Infinity, + url: '/api/peers/{peerId}/accessible-peers', + headers: { + 'Accept': 'application/json', + 'Authorization': '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/peers/{peerId}/accessible-peers" + +headers = { + 'Accept': 'application/json', + 'Authorization': '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/peers/{peerId}/accessible-peers" + 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 ") + + 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/peers/{peerId}/accessible-peers") + +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 " + +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/peers/{peerId}/accessible-peers") + .method("GET") + .addHeader("Accept", "application/json") + .addHeader("Authorization: Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/peers/{peerId}/accessible-peers', + 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 ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` + + + + + +```json {{ title: 'Example' }} +[ + { + "id": "chacbco6lnnbn6cg5s90", + "name": "stage-host-1", + "ip": "10.64.0.1", + "dns_label": "stage-host-1.netbird.cloud", + "user_id": "google-oauth2|277474792786460067937", + "os": "linux", + "country_code": "DE", + "city_name": "Berlin", + "geoname_id": 2643743, + "connected": true, + "last_seen": "2023-05-05T10:05:26.420578Z" + } +] +``` +```json {{ title: 'Schema' }} +[ + { + "id": "string", + "name": "string", + "ip": "string", + "dns_label": "string", + "user_id": "string", + "os": "string", + "country_code": "string", + "city_name": "string", + "geoname_id": "integer", + "connected": "boolean", + "last_seen": "string" + } +] +``` + + + + + + +---