diff --git a/openapi-gen/index.ts b/openapi-gen/index.ts new file mode 100644 index 00000000..85e88a42 --- /dev/null +++ b/openapi-gen/index.ts @@ -0,0 +1,70 @@ +import path from 'path'; +import YAML from 'yaml'; +import { OpenAPIV3_1 } from 'openapi-types' +import { Endpoint, extractSpec } from './tsxParser/openapi-extractor'; +import React from 'react'; +import { ApiTemplate } from './templates/ApiTemplate'; +import { renderToMDX } from './tsxParser/renderToMDX'; +import { mkdir, writeFile } from "fs/promises" + +(async function main() { + const inputUrl = process.argv[2] + if (!inputUrl) { + console.error('Usage: ts-node index.ts '); + process.exit(1); + } + const outputDir = process.argv[3] || path.join('src', 'pages', 'ipa', 'resources'); + try { + const yml = await readYaml(inputUrl) + + const mdxFile: Record = {} + const customFlags: string[] = [] + const endpoints = extractSpec(yml) + + endpoints.forEach(endpoint => { + if (!endpoint.tag) { + console.error('No tag for this endpoint:', endpoint.path) + return + } + + if (!mdxFile[endpoint.tag]) { + mdxFile[endpoint.tag] = [] + } + + mdxFile[endpoint.tag].push(endpoint) + const ymlTag = yml.tags.find(tag => tag.name == endpoint.tag) + + if (!ymlTag) return; + if (!customFlags[endpoint.tag]) { + customFlags[endpoint.tag] = [] + } + for (let flag in ymlTag) { + if (flag.startsWith('x-') && ymlTag[flag] && !customFlags[endpoint.tag].includes(flag)) { + customFlags[endpoint.tag].push(flag) + } + } + }) + + for (let tag in mdxFile) { + const element = React.createElement(ApiTemplate, { tag: tag, endpoints: mdxFile[tag], customFlags: customFlags[tag] }); + const component = renderToMDX(element) + const fileName = path.join(outputDir, tag.toLowerCase().replace(" ", "-") + ".mdx") + const dir = path.dirname(fileName) + await mkdir(dir, { recursive: true }) + await writeFile(fileName, component) + } + } catch (error) { + console.error(error); + } +})() + +async function readYaml(url: string) { + const res = await fetch(url); + if (!res.ok) throw new Error(`Failed to fetch ${url}: ${res.statusText}`); + const text = await res.text(); + const parsed = YAML.parse(text) as OpenAPIV3_1.Document; + if (parsed.openapi != "3.1.0") { + throw new Error('Unsupported OpenAPI version: ' + parsed.openapi); + } + return parsed; +} diff --git a/openapi-gen/templates/ApiTemplate.tsx b/openapi-gen/templates/ApiTemplate.tsx new file mode 100644 index 00000000..23d48d61 --- /dev/null +++ b/openapi-gen/templates/ApiTemplate.tsx @@ -0,0 +1,173 @@ +import { Endpoint, Parameter, Request } from "../tsxParser/openapi-extractor" +import { CodeGroup, Col, Row, Stringify, Property, Properties, Details, Summary, Badge } from "../tsxParser/components" + +export type ApiTemplateProps = { + tag: string, + endpoints: Endpoint[] + customFlags?: string[] +} + +export const ApiTemplate = ({ tag, endpoints, customFlags }: ApiTemplateProps) => { + return ( + <> + + + {endpoints.map((end, index) => { + const flags = customFlags + ? [...new Set([...customFlags, ...end.flags])] + : [...new Set(end.flags)]; + return ( +
+

+ {end.summary} + {flags.length > 0 && flags.map(flag => )} + {` {{ tag: '${end.method.toUpperCase()}', label: '${end.path}' }}`} +

+ + + + {end.description} + + {/* Handle Path Parameters for all methods that might have them */} + {end.parameters && end.parameters.length > 0 && ( + + )} + + {/* Handle Request Body for POST/PUT methods */} + {(end.method === "POST" || end.method === "PUT") && end.request && ( + + )} + + + + + {end.responses["200"]?.schema && + } + {end.responses["201"]?.schema && + } + + + {"\n---"} +
+ ) + })} + + ) +} + +const ParametersApi = ({ parameters }: { parameters: Parameter[] }) => { + const params: Parameter[] = []; + const query: Parameter[] = []; + for (let p of parameters) { + if (p.in === "query") { + query.push(p) + } else { + params.push(p) + } + } + + return ( + <> + {params.length > 0 && <> +

Path Parameters

+ + {params.map((p, index) => { + return ( + + {p.description} + + ) + })} + + } + {query.length > 0 && <> +

Query Parameters

+ + {query.map((p, index) => { + return ( + + {p.description} + + ) + })} + + } + + ) +} + +const PostBodyApi = ({ bodyRequest, path }: { bodyRequest: Request[], path: string }) => { + return ( + <> +

Request-Body Parameters

+ {renderProperties(bodyRequest, path)} + + ) +} + + +const renderProperties = (bodyRequest: Request[], path: string, prefix = "body",) => { + return bodyRequest.map((req, index) => { + const key = `${prefix}-${req.name}-${index}` + + if (req.bodyObj && req.bodyObj.length > 0 && req.type === "object" || req.type === "object[]") { + return ( + +
+ {req.description || "More Information"} + + {req.bodyObj && renderProperties(req.bodyObj, path, `nested-${req.name}`)} + +
+
+ ) + } + + // Primitive type + return ( + + {req.description} + + ) + }) +} + diff --git a/openapi-gen/tsconfig.json b/openapi-gen/tsconfig.json new file mode 100644 index 00000000..d383a84e --- /dev/null +++ b/openapi-gen/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "CommonJS", + "jsx": "react-jsx", + "esModuleInterop": true, + "moduleResolution": "node", + "allowSyntheticDefaultImports": true, + "skipLibCheck": true, + "resolveJsonModule": true, + "noImplicitAny": false, + "baseUrl": ".", + "paths": { + "~/*": [ + "./*" + ] + } + }, + "include": [ + "**/*.ts", + "**/*.tsx" + ], + "exclude": [ + "node_modules" + ] +} diff --git a/openapi-gen/tsxParser/api/requests.ts b/openapi-gen/tsxParser/api/requests.ts new file mode 100644 index 00000000..1805fb49 --- /dev/null +++ b/openapi-gen/tsxParser/api/requests.ts @@ -0,0 +1,674 @@ +import { Endpoint } from "../../tsxParser/openapi-extractor" + + +export const requestCode = (endPoint: Endpoint) => { + const body = getRequestBody(endPoint) + switch (endPoint.method) { + case 'GET': + return getRequestCode(endPoint.path) + case "POST": + return postRequestCode(endPoint.path, body) + case "PUT": + return putRequestCode(endPoint.path, body) + case "DELETE": + return deleteRequestCode(endPoint.path) + } +} + +export const getRequestBody = (endPoint: Endpoint) => { + const body: Record = {}; + + if (!endPoint?.request) return "{}"; + + for (const req of endPoint.request) { + if (req.isOneOf && req.bodyObj?.[0]?.bodyObj) { + body[req.name] = Object.fromEntries( + req.bodyObj[0].bodyObj.map(({ name, example }) => [name, example]) + ); + continue; + } + + if (req.example !== undefined) { + body[req.name] = req.example; + } + } + + return JSON.stringify(body, null, 2); +}; + + +export const deleteRequestCode = (url: string) => { + const snippets: string[] = [] + + // ---------------- cURL ---------------- + snippets.push(`\`\`\`bash {{ title: 'cURL' }} +curl -X DELETE https://api.netbird.io${url} \\ +-H 'Authorization: Token ' +\`\`\``) + + // ---------------- JavaScript (Axios) ---------------- + snippets.push(`\`\`\`js +const axios = require('axios'); + +let config = { + method: 'delete', + maxBodyLength: Infinity, + url: 'https://api.netbird.io${url}', + headers: { + 'Authorization': 'Token ' + } +}; + +axios(config) +.then((response) => { + console.log(JSON.stringify(response.data)); +}) +.catch((error) => { + console.log(error); +}); +\`\`\``) + + // ---------------- Python ---------------- + snippets.push(`\`\`\`python +import requests + +url = "https://api.netbird.io${url}" + +headers = { + 'Authorization': 'Token ' +} + +response = requests.request("DELETE", url, headers=headers) +print(response.text) +\`\`\``) + + // ---------------- Go ---------------- + snippets.push(`\`\`\`go +package main + +import ( + "fmt" + "net/http" + "io/ioutil" +) + +func main() { + url := "https://api.netbird.io${url}" + method := "DELETE" + + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) + if err != nil { + fmt.Println(err) + return + } + + 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 ---------------- + snippets.push(`\`\`\`ruby +require "uri" +require "net/http" + +url = URI("https://api.netbird.io${url}") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Delete.new(url) +request["Authorization"] = "Token " + +response = https.request(request) +puts response.read_body +\`\`\``) + + // ---------------- Java ---------------- + snippets.push(`\`\`\`java +OkHttpClient client = new OkHttpClient().newBuilder().build(); + +Request request = new Request.Builder() + .url("https://api.netbird.io${url}") + .method("DELETE", null) + .addHeader("Authorization", "Token ") + .build(); + +Response response = client.newCall(request).execute(); +\`\`\``) + + // ---------------- PHP ---------------- + snippets.push(`\`\`\`php + 'https://api.netbird.io${url}', + 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 ' + ), +)); + +$response = curl_exec($curl); +curl_close($curl); +echo $response; +\`\`\``) + + return snippets +} + +export const putRequestCode = (url: string, body: string) => { + const langCode: string[] = [] + + // ---------------- cURL ---------------- + const curlLines: string[] = [ + `curl -X PUT https://api.netbird.io${url} \\`, + `-H 'Accept: application/json' \\`, + `-H 'Content-Type: application/json' \\`, + `-H 'Authorization: Token ' \\`, + `--data-raw '${body}'` + ] + langCode.push(`\`\`\`bash {{ title: 'cURL' }}\n${curlLines.join("\n")}\n\`\`\``) + + // ---------------- JavaScript (Axios) ---------------- + langCode.push(`\`\`\`js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify(${body}); +let config = { + method: 'put', + maxBodyLength: Infinity, + url: 'https://api.netbird.io${url}', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': 'Token ' + }, + data : data +}; + +axios(config) +.then((response) => { + console.log(JSON.stringify(response.data)); +}) +.catch((error) => { + console.log(error); +}); +\`\`\``) + + // ---------------- Python ---------------- + langCode.push(`\`\`\`python {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io${url}" +payload = json.dumps(${body}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("PUT", url, headers=headers, data=payload) + +print(response.text) +\`\`\``) + + // ---------------- Go ---------------- + langCode.push(`\`\`\`go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io${url}" + method := "PUT" + + payload := strings.NewReader(${body}) + 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 ") + + res, err := client.Do(req) + if err != nil { + fmt.Println(err) + return + } + defer res.Body.Close() + + resBody, err := ioutil.ReadAll(res.Body) + if err != nil { + fmt.Println(err) + return + } + fmt.Println(string(resBody)) +} +\`\`\``) + + // ---------------- Ruby ---------------- + langCode.push(`\`\`\`ruby {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io${url}") + +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 " + +request.body = JSON.dump(${body}) +response = https.request(request) +puts response.read_body +\`\`\``) + + // ---------------- Java ---------------- + langCode.push(`\`\`\`java {{ title: 'Java' }} +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); +MediaType mediaType = MediaType.parse("application/json"); +RequestBody body = RequestBody.create(mediaType, '${body}'); +Request request = new Request.Builder() + .url("https://api.netbird.io${url}") + .method("PUT", body) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") + .build(); +Response response = client.newCall(request).execute(); +\`\`\``) + + // ---------------- PHP ---------------- + langCode.push(`\`\`\`php {{ title: 'PHP' }} + 'https://api.netbird.io${url}', + 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 => '${body}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +\`\`\``) + + return langCode +} + +const postRequestCode = (url: string, body: string) => { + const langCode: string[] = [] + + // ---------------- cURL ---------------- + const curlLines: string[] = [ + `curl -X POST https://api.netbird.io${url} \\`, + `-H 'Accept: application/json' \\`, + `-H 'Content-Type: application/json' \\`, + `-H 'Authorization: Token ' \\`, + `--data-raw '${body}'` + ] + langCode.push(`\`\`\`bash {{ title: 'cURL' }}\n${curlLines.join("\n")}\n\`\`\``) + + // ---------------- JavaScript (Axios) ---------------- + langCode.push(`\`\`\`js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify(${body}); +let config = { + method: 'post', + maxBodyLength: Infinity, + url: 'https://api.netbird.io${url}', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': 'Token ' + }, + data : data +}; + +axios(config) +.then((response) => { + console.log(JSON.stringify(response.data)); +}) +.catch((error) => { + console.log(error); +}); +\`\`\``) + + // ---------------- Python ---------------- + langCode.push(`\`\`\`python {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io${url}" +payload = json.dumps(${body}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("POST", url, headers=headers, data=payload) + +print(response.text) +\`\`\``) + + // ---------------- Go ---------------- + langCode.push(`\`\`\`go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io${url}" + method := "POST" + + payload := strings.NewReader('${body}') + 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 ") + + res, err := client.Do(req) + if err != nil { + fmt.Println(err) + return + } + defer res.Body.Close() + + resBody, err := ioutil.ReadAll(res.Body) + if err != nil { + fmt.Println(err) + return + } + fmt.Println(string(resBody)) +} +\`\`\``) + + // ---------------- Ruby ---------------- + langCode.push(`\`\`\`ruby {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io${url}") + +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 " + +request.body = JSON.dump(${body}) +response = https.request(request) +puts response.read_body +\`\`\``) + + // ---------------- Java ---------------- + langCode.push(`\`\`\`java {{ title: 'Java' }} +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); +MediaType mediaType = MediaType.parse("application/json"); +RequestBody body = RequestBody.create(mediaType, '${body}'; +Request request = new Request.Builder() + .url("https://api.netbird.io${url}") + .method("POST", body) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") + .build(); +Response response = client.newCall(request).execute(); +\`\`\``) + + // ---------------- PHP ---------------- + langCode.push(`\`\`\`php {{ title: 'PHP' }} + 'https://api.netbird.io${url}', + 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 => '${body}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +\`\`\``) + + return langCode +} + +const getRequestCode = (label: string) => { + const langCode: string[] = [] + + // ---------------- cURL ---------------- + langCode.push(`\`\`\`bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io${label} \\ +-H 'Accept: application/json' \\ +-H 'Authorization: Token ' +\`\`\``) + + // ---------------- JavaScript (Axios) ---------------- + langCode.push(`\`\`\`js {{ title: 'JavaScript' }} +const axios = require('axios'); + +let config = { + method: 'get', + maxBodyLength: Infinity, + url: 'https://api.netbird.io${label}', + headers: { + 'Accept': 'application/json', + 'Authorization': 'Token ' + } +}; + +axios(config) +.then((response) => { + console.log(JSON.stringify(response.data)); +}) +.catch((error) => { + console.log(error); +}); +\`\`\``) + + // ---------------- Python ---------------- + langCode.push(`\`\`\`python {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io${label}" + +headers = { + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("GET", url, headers=headers) + +print(response.text) +\`\`\``) + + // ---------------- Go ---------------- + langCode.push(`\`\`\`go {{ title: 'Go' }} +package main + +import ( + "fmt" + "net/http" + "io/ioutil" +) + +func main() { + url := "https://api.netbird.io${label}" + 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 ---------------- + langCode.push(`\`\`\`ruby {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io${label}") + +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 ---------------- + langCode.push(`\`\`\`java {{ title: 'Java' }} +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); + +Request request = new Request.Builder() + .url("https://api.netbird.io${label}") + .method("GET", null) + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") + .build(); +Response response = client.newCall(request).execute(); +\`\`\``) + + // ---------------- PHP ---------------- + langCode.push(`\`\`\`php {{ title: 'PHP' }} + 'https://api.netbird.io${label}', + 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; +\`\`\``) + + return langCode +} diff --git a/openapi-gen/tsxParser/api/responses.ts b/openapi-gen/tsxParser/api/responses.ts new file mode 100644 index 00000000..377de565 --- /dev/null +++ b/openapi-gen/tsxParser/api/responses.ts @@ -0,0 +1,13 @@ + +export const responseCode = (schema: string, example: string) => { + const langCode = [] + langCode.push(`\`\`\`json {{ title: 'Example' }} +${example} +\`\`\``) + + langCode.push(`\`\`\`json {{ title: 'Schema' }} +${schema} +\`\`\``) + + return langCode +} diff --git a/openapi-gen/tsxParser/components/index.tsx b/openapi-gen/tsxParser/components/index.tsx new file mode 100644 index 00000000..abcdc4cc --- /dev/null +++ b/openapi-gen/tsxParser/components/index.tsx @@ -0,0 +1,147 @@ +import React from "react"; +import { requestCode } from "../api/requests"; +import { responseCode } from "../api/responses"; +import { Endpoint } from "../openapi-extractor"; + +export const Stringify = ({ str }: { str: string }) => <>{str} + +export const Row = ({ children }) => <> + {"\n\n"} + {children} + {"\n\n"} + + +export const Details = ({ children, className, open }: { children: React.ReactNode, className: string, open?: boolean }) => { + let header = ` \n` + const footer = "\n\n" + + return <> + {header} + {children} + {footer} + +} + +export const Summary = ({ children }: { children: React.ReactNode }) => <> + {"\n"} + {children} + {""} + + +export const Col = ({ children, sticky }: { children: React.ReactNode, sticky?: boolean }) => { + let header = " \n` + const footer = "\n\n" + return <> + {header} + {children} + {footer} + +} + +export const Properties = ({ children }) => <> + {"\n\n"} + {children} + {"\n\n"} + + +export const Badge = ({ customFlag }: { customFlag: string }) => { + let component = " + {component} + +} +type PropertyProps = { + name?: string, + type?: string, + required?: boolean, + min?: number, + max?: number, + minLen?: number, + maxLen?: number + enumList?: string[] + children: React.ReactNode, +} + +export const Property = ({ name, type, required, min, max, minLen, maxLen, enumList, children }: PropertyProps) => { + const childNodes = React.Children.toArray(children).map((child) => + typeof child === "string" ? child.trim() : "" + ); + let header = "\n`; + + // join each child code fence with newlines + const content = childNodes.length === 0 ? childNodes.join("\n\n") : children + + return ( + <> + {header} + {content} + {footer} + + ); +} + +type CodeGroupProps = { + title: string; + endPoint: Endpoint +}; + +export const CodeGroup = ({ title, endPoint }: CodeGroupProps) => { + const tag = endPoint.method.toUpperCase() + const label = endPoint.path + const obj = endPoint.responses["200"] ?? endPoint.responses["201"] + const exampleJson = obj?.example ? JSON.stringify(obj.example, null, 2) : "" + const schemaJson = obj?.schema ? JSON.stringify(obj.schema, null, 2) : "" + + let langCode = [] + if (title === "Request") langCode = requestCode(endPoint) + if (title === "Response") langCode = responseCode(schemaJson, exampleJson) + let header = "\n`; + + // join each child code fence with newlines + const content = langCode.join("\n\n"); + + return ( + <> + {header} + {content} + {footer} + + ); +} + diff --git a/openapi-gen/tsxParser/openapi-extractor.ts b/openapi-gen/tsxParser/openapi-extractor.ts new file mode 100644 index 00000000..b40f9f45 --- /dev/null +++ b/openapi-gen/tsxParser/openapi-extractor.ts @@ -0,0 +1,709 @@ +import { OpenAPIV3_1 } from 'openapi-types' + +export type Extracted = { + schema: any | null + example: any | null +} + +export type Parameter = { + name: string + required?: boolean + type?: string + description?: string + in?: string +} + +export type Request = { + name: string + type: string + required: boolean + description?: string + minLength?: number, + maxLength?: number, + minimum?: number + maximum?: number + example?: string + enumList?: any[] + isOneOf?: boolean, + bodyObj?: Request[] +} + +export type Endpoint = { + path: string + method: string + summary?: string + description?: string + parameters?: Parameter[] + responses: Record + request?: Request[] | null + tag: string, + flags: string[] +} + +/* ----------------- main extraction: extractSpec ----------------- */ + +/** + * Walks all paths & methods and extracts: + * - parameters (path/query) + * - request body (application/json) -> Request[] + * - responses -> Extracted { schema, example } (application/json) + */ +export function extractSpec(doc: OpenAPIV3_1.Document): Endpoint[] { + const endpoints: Endpoint[] = [] + const methods = ['get', 'post', 'put', 'delete', 'patch', 'options', 'head'] + + for (const [p, pathItem] of Object.entries(doc.paths || {})) { + for (const method of methods) { + const op: any = (pathItem as any)[method] + if (!op) continue + const flags = [] + for (let o in op) { + if (o.startsWith("x-")) { + flags.push(o) + } + } + + const parameters: Parameter[] = (op.parameters || []).map((param: any) => ({ + name: param.name, + required: !!param.required, + type: param.schema?.type, + description: param.description, + in: param.in, + })) + + const endpoint: Endpoint = { + path: p, + method: method.toUpperCase(), + summary: op.summary, + description: op.description, + parameters, + responses: {}, + request: null, + tag: Array.isArray(op.tags) ? op.tags[0] ?? '' : (op.tags ?? '') as any, + flags: flags + } + + // ---------- Request body ---------- + if (op.requestBody) { + let rb: any = op.requestBody + if (rb.$ref) { + const resolved = resolveRef(rb.$ref, doc) + if (resolved) rb = resolved + } + const reqSchema = rb?.content?.['application/json']?.schema + if (reqSchema) { + const topReqs = schemaNodeToRequests(reqSchema, doc, 'body', reqSchema.required || [], new Set()) + endpoint.request = topReqs.length ? topReqs : null + } else if (rb?.content?.['application/json']?.example !== undefined) { + endpoint.request = [{ + name: 'body', + type: Array.isArray(rb.content['application/json'].example) ? 'array' : typeof rb.content['application/json'].example, + required: true, + description: rb.description || undefined + }] + } else { + endpoint.request = null + } + } + + // ---------- Responses ---------- + for (const [statusCode, resp] of Object.entries(op.responses || {})) { + let respObj: any = resp + + // If response is a $ref to components.responses, resolve it + if (respObj && respObj.$ref) { + const resolvedResp = resolveRef(respObj.$ref, doc) + if (resolvedResp) respObj = resolvedResp + } + + // content['application/json'].schema is the expected place + const contentSchema = respObj?.content?.['application/json']?.schema + if (contentSchema) { + endpoint.responses[statusCode] = extractFromSchema(contentSchema, doc) + continue + } + + // content example fallback (no schema) + const contentExample = respObj?.content?.['application/json']?.example + if (contentExample !== undefined) { + const example = contentExample + const schemaRep = buildSchemaRepresentationFromExample(example) + endpoint.responses[statusCode] = { schema: schemaRep, example } + continue + } + + // Maybe the response object directly references a schema ($ref inside response 'schema' rare) + if (respObj && respObj.schema && respObj.schema.$ref) { + endpoint.responses[statusCode] = extractFromSchema(respObj.schema, doc) + continue + } + + // Another fallback: if respObj has a top-level example + if (respObj && respObj.example !== undefined) { + const example = respObj.example + const schemaRep = buildSchemaRepresentationFromExample(example) + endpoint.responses[statusCode] = { schema: schemaRep, example } + continue + } + + // No useful info + endpoint.responses[statusCode] = null + } + + endpoints.push(endpoint) + } + } + + return endpoints +} + +/** + * Resolve a local JSON Pointer reference (e.g. "#/components/schemas/Foo") + */ +function resolveRef(ref: string | undefined | null, doc: OpenAPIV3_1.Document): any | null { + if (!ref || typeof ref !== 'string') return null + if (!ref.startsWith('#/')) return null + const parts = ref.slice(2).split('/') + let node: any = doc + for (const p of parts) { + if (node == null) return null + const key = p.replace(/~1/g, '/').replace(/~0/g, '~') + node = node[key] + } + return node +} + +/** + * Merge helper for allOf: merges properties, required, other top-level keys. + * Later entries override earlier ones for overlapping property names. + */ +function mergeAllOfParts(parts: any[], doc: OpenAPIV3_1.Document, seenRefs: Set) { + const out: any = {} + out.properties = {} + out.required = [] + for (const part of parts) { + const resolved = dereferenceNode(part, doc, new Set(seenRefs)) + // merge properties + if (resolved.properties && typeof resolved.properties === 'object') { + for (const [k, v] of Object.entries(resolved.properties)) { + out.properties[k] = v + } + } + // merge required + if (Array.isArray(resolved.required)) { + for (const r of resolved.required) { + if (!out.required.includes(r)) out.required.push(r) + } + } + // keep example if present and not set yet + if (resolved.example !== undefined && out.example === undefined) { + out.example = resolved.example + } + // copy other keys when sensical (type, description, additionalProperties) + if (resolved.type && !out.type) out.type = resolved.type + if (resolved.description && !out.description) out.description = resolved.description + if (resolved.additionalProperties && !out.additionalProperties) out.additionalProperties = resolved.additionalProperties + } + + // if no required entries => delete empty array + if (!out.required.length) delete out.required + if (Object.keys(out.properties).length === 0) delete out.properties + + return out +} + +/** + * Dereference & normalize a schema node: + * - resolves $ref (recursively) + * - merges allOf into a single object (resolving contained refs) + * - resolves arrays/items + * - returns a node that no longer contains $ref strings (except unknown external refs we can't resolve) + * + * Uses seenRefs to avoid infinite recursion. + */ +function dereferenceNode(node: any, doc: OpenAPIV3_1.Document, seenRefs = new Set()): any { + if (!node) return node + + // If the node is a string ref "#/..." + if (typeof node === 'string' && node.startsWith('#/')) { + const resolved = resolveRef(node, doc) + return dereferenceNode(resolved, doc, seenRefs) + } + + // If $ref object + if (node.$ref) { + const ref = node.$ref as string + if (seenRefs.has(ref)) { + // circular -> stop and return an empty placeholder + return {} + } + seenRefs.add(ref) + const resolved = resolveRef(ref, doc) + if (!resolved) { + // unresolved external ref -> return empty placeholder + return {} + } + return dereferenceNode(resolved, doc, seenRefs) + } + + // allOf: merge parts + if (Array.isArray(node.allOf)) { + return mergeAllOfParts(node.allOf, doc, seenRefs) + } + + // anyOf: return array of resolved options (keep as oneOf structure) + if (Array.isArray(node.oneOf)) { + return { oneOf: node.oneOf.map((opt: any) => dereferenceNode(opt, doc, new Set(seenRefs))) } + } + + // arrays: dereference items + if (node.type === 'array' || node.items) { + const items = node.items ?? {} + const derefItems = dereferenceNode(items, doc, new Set(seenRefs)) + // return normalized array node + const arr: any = { type: 'array', items: derefItems } + if (node.minLength !== undefined) arr.minLength = node.minLength + if (node.maxLength !== undefined) arr.maxLength = node.maxLength + if (node.description) arr.description = node.description + if (node.example !== undefined) arr.example = node.example + return arr + } + + // object with properties/additionalProperties -> dereference children + if (node.type === 'object' || node.properties || node.additionalProperties) { + const out: any = {} + if (node.type) out.type = node.type + if (node.description) out.description = node.description + if (node.example !== undefined) out.example = node.example + + if (node.properties && typeof node.properties === 'object') { + out.properties = {} + for (const [k, v] of Object.entries(node.properties)) { + out.properties[k] = dereferenceNode(v, doc, new Set(seenRefs)) + } + } + if (node.required) out.required = Array.isArray(node.required) ? [...node.required] : [] + if (node.additionalProperties) { + out.additionalProperties = node.additionalProperties === true ? true : dereferenceNode(node.additionalProperties, doc, new Set(seenRefs)) + } + return out + } + + // primitives (string/boolean/number...), keep example/enum if present + if (node.type && ['string', 'integer', 'number', 'boolean'].includes(node.type)) { + const p: any = { type: node.type } + if (node.example !== undefined) p.example = node.example + if (node.enum) p.enum = node.enum + if (node.format) p.format = node.format + if (node.description) p.description = node.description + if (node.minimum !== undefined) p.minimum = node.minimum + if (node.maximum !== undefined) p.maximum = node.maximum + if (node.minLength !== undefined) p.minLength = node.minLength + if (node.maxLength !== undefined) p.maxLength = node.maxLength + return p + } + + // fallback: return shallow copy but dereference any child objects + if (typeof node === 'object') { + const out: any = {} + for (const [k, v] of Object.entries(node)) { + if (k === 'examples') { + out[k] = v + } else { + out[k] = dereferenceNode(v, doc, new Set(seenRefs)) + } + } + return out + } + + return node +} + +/** + * Build a simplified schema representation from a (dereferenced) node. + * The node is expected to have no $ref strings (dereferenceNode must be used first). + */ +function buildSchemaRepresentation(node: any, doc: OpenAPIV3_1.Document, seenRefs: Set = new Set()): any { + if (!node) return null + + // If the node still contains a $ref (shouldn't after dereference), attempt to resolve + if (node.$ref) { + const resolved = resolveRef(node.$ref, doc) + return buildSchemaRepresentation(dereferenceNode(resolved, doc, seenRefs), doc, seenRefs) + } + + // oneOf (already dereferenced to actual nodes) + if (node.oneOf) { + return { oneOf: node.oneOf.map((o: any) => buildSchemaRepresentation(o, doc, new Set(seenRefs))) } + } + + // array + if (node.type === 'array' || node.items) { + const items = node.items ?? {} + return [buildSchemaRepresentation(items, doc, new Set(seenRefs))] + } + + // primitive type + if (node.type && ['string', 'integer', 'number', 'boolean'].includes(node.type)) { + return node.type + } + + // object with properties + if (node.type === 'object' || node.properties || node.additionalProperties) { + if (node.properties && typeof node.properties === 'object') { + const out: any = {} + for (const [k, v] of Object.entries(node.properties)) { + out[k] = buildSchemaRepresentation(v as any, doc, new Set(seenRefs)) + } + return out + } + + if (node.additionalProperties) { + const add = node.additionalProperties === true ? true : buildSchemaRepresentation(node.additionalProperties, doc, new Set(seenRefs)) + const rep: any = { type: 'object', additionalProperties: add } + if (node.propertyNames) rep.propertyNames = node.propertyNames + if (node.example !== undefined) rep.example = node.example + return rep + } + + return { type: 'object' } + } + + if (node.enum) return { enum: node.enum } + + // fallback + return node +} + +/** + * Extract schema representation and example from node AFTER dereferencing. + * This ensures schema doesn't include $ref strings or allOf wrappers. + */ +function extractFromSchema(node: any, doc: OpenAPIV3_1.Document, seenRefs = new Set()): Extracted { + if (!node) return { schema: null, example: null } + + // Always dereference first so we operate on normalized node. + const deref = dereferenceNode(node, doc, seenRefs) + + // If it's a oneOf structure + if (deref.oneOf) { + const options = deref.oneOf.map((opt: any) => extractFromSchema(opt, doc, new Set(seenRefs))) + const firstExample = options.find(o => o.example !== undefined && o.example !== null)?.example ?? null + return { schema: { oneOf: options.map(o => o.schema) }, example: firstExample } + } + + // Arrays + if (deref.type === 'array' || deref.items) { + const items = deref.items ?? {} + const itemExtract = extractFromSchema(items, doc, new Set(seenRefs)) + const schema = [itemExtract.schema] + const example = deref.example !== undefined ? deref.example : (itemExtract.example !== null ? [itemExtract.example] : null) + return { schema, example } + } + + // Objects + if (deref.type === 'object' || deref.properties || deref.additionalProperties) { + const schemaRep = buildSchemaRepresentation(deref, doc, seenRefs) + + // If explicit example provided at this level, use it + if (deref.example !== undefined && deref.example !== null) { + return { schema: schemaRep, example: deref.example } + } + + // Build example by iterating properties + const ex: any = {} + if (deref.properties) { + for (const [propName, propSchema] of Object.entries(deref.properties)) { + const sub = extractFromSchema(propSchema as any, doc, new Set(seenRefs)) + if (sub.example !== undefined && sub.example !== null) ex[propName] = sub.example + else ex[propName] = defaultForSchema(sub.schema) + } + } + + // additionalProperties: add a sample value using its example if present + if (deref.additionalProperties && typeof deref.additionalProperties === 'object') { + const add = extractFromSchema(deref.additionalProperties as any, doc, new Set(seenRefs)) + if (add.example !== undefined && add.example !== null) { + const sampleKey = Object.keys(ex)[0] ?? 'key' + ex[sampleKey] = add.example + } + } + + return { schema: schemaRep, example: Object.keys(ex).length ? ex : null } + } + + // Primitive + if (deref.type && ['string', 'integer', 'number', 'boolean'].includes(deref.type)) { + const t = deref.type + const example = deref.example !== undefined ? deref.example : defaultForPrimitive(t) + return { schema: t, example } + } + + // enum + if (deref.enum) { + return { schema: { enum: deref.enum }, example: Array.isArray(deref.enum) ? deref.enum[0] : null } + } + + // Fallback: if there is an example field return it, else return nulls + if (deref.example !== undefined) { + const schemaRep = buildSchemaRepresentation(deref, doc, seenRefs) + return { schema: schemaRep, example: deref.example } + } + + return { schema: null, example: null } +} + +/** + * Helper: produce a default for a whole schema if examples aren't present + */ +function defaultForSchema(schemaRep: any) { + if (schemaRep == null) return null + if (Array.isArray(schemaRep)) { + return [defaultForSchema(schemaRep[0])] + } + if (typeof schemaRep === 'string') { + return defaultForPrimitive(schemaRep) + } + if (typeof schemaRep === 'object') { + const out: any = {} + for (const k of Object.keys(schemaRep)) { + out[k] = defaultForSchema(schemaRep[k]) + } + return out + } + return null +} + +/** + * Helper: produce a default example for a primitive schema type + */ +function defaultForPrimitive(t: string) { + switch (t) { + case 'string': return 'string' + case 'integer': return 0 + case 'number': return 0 + case 'boolean': return false + default: return null + } +} + +/** + * Small best-effort function to build a schema representation from a concrete example. + * This is only used as a fallback when a schema is missing but an example exists. + */ +function buildSchemaRepresentationFromExample(example: any): any { + if (example === null || example === undefined) return null + if (Array.isArray(example)) { + return [buildSchemaRepresentationFromExample(example[0])] + } + if (typeof example === 'object') { + const out: any = {} + for (const [k, v] of Object.entries(example)) { + out[k] = buildSchemaRepresentationFromExample(v) + } + return out + } + const t = typeof example + if (t === 'string') return 'string' + if (t === 'number') return Number.isInteger(example as number) ? 'integer' : 'number' + if (t === 'boolean') return 'boolean' + return null +} + +/** + * Convert a schema node into an array of Request entries. + * - node: the schema object (can be ReferenceObject, SchemaObject) + * - nameForRoot: name to use when the node isn't an object with properties (eg 'body') + * - requiredNames: array of required property names (only used when node.properties exists) + */ +function schemaNodeToRequests( + node: any, + doc: OpenAPIV3_1.Document, + nameForRoot = 'body', + requiredNames: string[] = [], + seenRefs = new Set() +): Request[] { + if (!node) return [] + + // Normalize & dereference first (this resolves $ref, merges allOf, derefs children) + const normalized = dereferenceNode(node, doc, seenRefs) ?? node + + // If normalized ended up being a reference string (unlikely after deref), resolve + if (typeof normalized === 'string' && normalized.startsWith('#/')) { + const resolved = resolveRef(normalized, doc) + return schemaNodeToRequests(resolved, doc, nameForRoot, requiredNames, seenRefs) + } + + // Object handling (properties or additionalProperties) + if ((normalized as any).type === 'object' || (normalized as any).properties || (normalized as any).additionalProperties) { + const n = normalized as any + + // If we have explicit properties -> enumerate them + if (n.properties && typeof n.properties === 'object') { + const out: Request[] = [] + const reqArr: string[] = Array.isArray(n.required) ? n.required : requiredNames || [] + for (const [propName, propSchema] of Object.entries(n.properties)) { + // ensure property is normalized + const prop = dereferenceNode(propSchema, doc, new Set(seenRefs)) ?? propSchema + if (Array.isArray((prop as any).oneOf)) { + + + const options: Request[] = (prop.oneOf as any[]).map((opt, idx) => { + const propNode = dereferenceNode(opt, doc, new Set(seenRefs)) ?? opt + const optReqs = schemaNodeToRequests(propNode, doc, `option_${idx + 1}`, [], new Set(seenRefs)) + return { + name: `Option ${idx + 1}`, + type: 'object', + required: false, + example: opt.example, + bodyObj: optReqs + + } + }) + out.push({ + name: propName, + type: 'object', + required: true, + description: "One of", + bodyObj: options, + isOneOf: true, + }) + continue + } + // array property + if (prop.type === 'array' || prop.items) { + const items = prop.items ?? {} + const itemsNorm = dereferenceNode(items, doc, new Set(seenRefs)) ?? items + if (itemsNorm.type === 'object' || itemsNorm.properties) { + const nested = schemaNodeToRequests(itemsNorm, doc, propName, itemsNorm.required || [], new Set(seenRefs)) + out.push({ + name: propName, + type: 'object[]', + example: prop.example ?? (nested.length + ? [Object.fromEntries( + nested.map(nr => [nr.name, nr.example ?? defaultForSchema(nr.type ?? nr)]) + )] + : undefined), + required: reqArr.includes(propName), + maxLength: prop.maxLength, + minLength: prop.minLength, + description: prop.description || undefined, + bodyObj: nested + }) + } else { + out.push({ + name: propName, + type: `${itemsNorm.type || 'any'}[]`, + example: prop.example ?? (itemsNorm.example !== undefined ? [itemsNorm.example] : undefined), + required: reqArr.includes(propName), + description: prop.description || undefined, + maxLength: prop.maxLength, + minLength: prop.minLength, + enumList: itemsNorm.enum + }) + } + continue + } + + // nested object property + if (prop.type === 'object' || prop.properties || prop.additionalProperties) { + const nested = schemaNodeToRequests(prop, doc, propName, prop.required || [], new Set(seenRefs)) + out.push({ + name: propName, + type: 'object', + example: prop.example ?? (nested.length ? nested.reduce((acc, it) => { + if (it.name) acc[it.name] = it.example ?? defaultForSchema(it.type ?? it) + return acc + }, {} as any) : undefined), + required: reqArr.includes(propName), + description: prop.description || undefined, + bodyObj: nested + }) + continue + } + + // primitive property (string/number/boolean/enum) + const primType = prop.type || (prop.enum ? 'string' : 'any') + const r: Request = { + name: propName, + type: primType, + required: reqArr.includes(propName), + example: prop.example !== undefined ? prop.example : defaultForPrimitive(primType), + description: prop.description || undefined + } + if (prop.minimum !== undefined) r.minimum = prop.minimum + if (prop.maximum !== undefined) r.maximum = prop.maximum + if (prop.minLength !== undefined) r.minLength = prop.minLength + if (prop.maxLength !== undefined) r.maxLength = prop.maxLength + if (prop.enum) r.enumList = Array.isArray(prop.enum) ? prop.enum : undefined + out.push(r) + } + + return out + } + + // additionalProperties (map-like object) + if ((n as any).additionalProperties) { + const add = (n as any).additionalProperties === true ? { type: 'any' } : (n as any).additionalProperties + const addNorm = dereferenceNode(add, doc, new Set(seenRefs)) ?? add + const nested = schemaNodeToRequests(addNorm, doc, 'value', addNorm.required || [], new Set(seenRefs)) + return [{ + name: nameForRoot, + type: 'object', + example: n.example ?? (nested.length ? nested[0].example : undefined), + required: requiredNames.includes(nameForRoot), + description: n.description || undefined, + bodyObj: nested.length ? nested : undefined + }] + } + + // empty object + return [{ + name: nameForRoot, + type: 'object', + example: (normalized as any).example ?? undefined, + required: requiredNames.includes(nameForRoot), + description: (normalized as any).description || undefined + }] + } + + // Primitive at root (string/number/boolean/etc) + if (typeof (normalized as any).type === 'string') { + const t = (normalized as any).type + const r: Request = { + name: nameForRoot, + type: t, + example: (normalized as any).example !== undefined ? (normalized as any).example : defaultForPrimitive(t), + required: requiredNames.includes(nameForRoot), + description: (normalized as any).description || undefined + } + if ((normalized as any).minLength !== undefined) r.minLength = (normalized as any).minLength + if ((normalized as any).maxLength !== undefined) r.maxLength = (normalized as any).maxLength + if ((normalized as any).minimum !== undefined) r.minimum = (normalized as any).minimum + if ((normalized as any).maximum !== undefined) r.maximum = (normalized as any).maximum + + if ((normalized as any).enum) r.enumList = (normalized as any).enum + return [r] + } + + // enum fallback + if ((normalized as any).enum) { + return [{ + name: nameForRoot, + type: 'string', + example: (normalized as any).example !== undefined ? (normalized as any).example : ((normalized as any).enum ? (normalized as any).enum[0] : undefined), + required: requiredNames.includes(nameForRoot), + enumList: Array.isArray((normalized as any).enum) ? (normalized as any).enum : undefined, + description: (normalized as any).description || undefined + }] + } + + // fallback generic + return [{ + name: nameForRoot, + example: (normalized as any).example, + type: typeof normalized === 'object' ? 'object' : 'any', + required: requiredNames.includes(nameForRoot), + description: (normalized as any)?.description || undefined + }] +} diff --git a/openapi-gen/tsxParser/renderToMDX.ts b/openapi-gen/tsxParser/renderToMDX.ts new file mode 100644 index 00000000..34da5ea1 --- /dev/null +++ b/openapi-gen/tsxParser/renderToMDX.ts @@ -0,0 +1,103 @@ +import React from "react"; + +/** heading map */ +const headingMap: Record = { + h1: "#", + h2: "##", + h3: "###", + h4: "####", + h5: "#####", + h6: "######", +}; + +type ElementShape = { + type: string | Function | symbol; + props?: { + children?: React.ReactNode; + [key: string]: any; + }; + $$typeof?: symbol; +}; + +/** Main renderer: accepts any React node (element, string, number, array, fragment) */ +export function renderToMDX(node: React.ReactNode): string { + function renderNode(n: React.ReactNode): string { + if (n === null || n === undefined) return ""; + + // primitives + if (typeof n === "string" || typeof n === "number") { + return String(n); + } + + // arrays + if (Array.isArray(n)) { + return n.map(renderNode).join(""); + } + + // React element object + if (isReactElementObject(n)) { + const el = n as ElementShape; + + // Fragment handling: render children directly + if (el.type === React.Fragment) { + return renderNode((el.props && el.props.children) ?? ""); + } + + // Functional component: call it and continue rendering result + if (typeof el.type === "function") { + // call component with props (some components expect no args, but usually props) + // TypeScript: we don't know the exact return type, but renderNode handles it + const res = (el.type as Function)(el.props ?? {}); + return renderNode(res); + } + + // Native HTML tag: render children and map headings + if (typeof el.type === "string") { + const children = renderNode((el.props && el.props.children) ?? ""); + if (el.type in headingMap) { + // ensure blank lines around headings + return `\n\n${headingMap[el.type]} ${children}\n\n`; + } + // block elements add spacing (a conservative approach) + // you can refine which tags are blocks vs inline if needed + const blockTags = new Set([ + "p", + "div", + "section", + "article", + "header", + "footer", + "main", + "nav", + "ul", + "ol", + "li", + ]); + if (blockTags.has(el.type)) { + return `\n${children}\n`; + } + + // inline/small tags: just return children + return children; + } + + // If el.type is symbol or unknown, fallback to children + return renderNode((el.props && el.props.children) ?? ""); + } + + // Unknown object (possible Polymorphic returns) -> attempt to stringify + return ""; + } + + return renderNode(node); +} + +/** Detect a React element object (the $$typeof check) */ +function isReactElementObject(obj: unknown): obj is React.ReactElement { + return ( + typeof obj === "object" && + obj !== null && + // Symbol.for('react.element') is the canonical marker + (obj as any).$$typeof === Symbol.for("react.element") + ); +} diff --git a/package.json b/package.json index d6527a3e..4381f748 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "build": "next build", "gen": "swagger-codegen generate -i https://raw.githubusercontent.com/netbirdio/netbird/main/management/server/http/api/openapi.yml -l openapi -o generator/openapi && npx ts-node generator/index.ts gen --input generator/openapi/openapi.json --output src/pages/ipa/resources", "start": "next start", - "lint": "next lint" + "lint": "next lint", + "api-gen": "npx ts-node openapi-gen/index.ts https://raw.githubusercontent.com/netbirdio/netbird/main/shared/management/http/api/openapi.yml" }, "browserslist": { "production": [ diff --git a/src/pages/ipa/resources/accounts.mdx b/src/pages/ipa/resources/accounts.mdx index 86eb8cb5..a40a8716 100644 --- a/src/pages/ipa/resources/accounts.mdx +++ b/src/pages/ipa/resources/accounts.mdx @@ -1,29 +1,28 @@ export const title = 'Accounts' +## List all Accounts {{ tag: 'GET', label: '/api/accounts' }} -## List all Accounts {{ tag: 'GET' , label: '/api/accounts' }} - - Returns a list of accounts of a user. Always returns a list of one account. - - - - + +Returns a list of accounts of a user. Always returns a list of one account. + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/accounts \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/accounts', + url: 'https://api.netbird.io/api/accounts', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -39,7 +38,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -55,30 +54,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/accounts" method := "GET" - client := &http.Client { - } + 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 ") @@ -98,7 +94,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -116,20 +112,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/accounts") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} [ { @@ -180,6 +173,7 @@ echo $response; "network_range": "100.64.0.0/16", "extra": { "peer_approval_enabled": true, + "user_approval_required": false, "network_traffic_logs_enabled": true, "network_traffic_logs_groups": [ "ch8i4ug6lnn4g9hqv7m0" @@ -199,6 +193,7 @@ echo $response; } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -220,6 +215,7 @@ echo $response; "network_range": "string", "extra": { "peer_approval_enabled": "boolean", + "user_approval_required": "boolean", "network_traffic_logs_enabled": "boolean", "network_traffic_logs_groups": [ "string" @@ -239,333 +235,137 @@ echo $response; } ] ``` - - - - - - ---- - - -## Delete an Account {{ tag: 'DELETE' , label: '/api/accounts/{accountId}' }} - - - - Deletes an account and all its resources. Only account owners can delete accounts. - - ### Path Parameters - - - - The unique identifier of an account - - - - - - -```bash {{ title: 'cURL' }} -curl -X DELETE https://api.netbird.io/api/accounts/{accountId} \ --H 'Authorization: Token ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'delete', - maxBodyLength: Infinity, - url: '/api/accounts/{accountId}', - headers: { - '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/accounts/{accountId}" - -headers = { - 'Authorization': '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 ") - - 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 " - -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 ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - '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 ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` - - - - - - --- -## Update an Account {{ tag: 'PUT' , label: '/api/accounts/{accountId}' }} + +## Update an Account {{ tag: 'PUT', label: '/api/accounts/{accountId}' }} + - - Update information about an account - - ### Path Parameters - - - - The unique identifier of an account - - - - ### Request-Body Parameters - - - -
- More Information - - - - - 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). - - - - - Period of time after which peer login expires (seconds). - - - - - 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). - - - - - Period of time of inactivity after which peer session expires (seconds). - - - - - Allows blocking regular users from viewing parts of the system. - - - - - Allows propagate the new user auto groups to peers that belongs to the user - - - - - Allows extract groups from JWT claim and add it to account groups. - - - - - Name of the claim from which we extract groups names to add it to account groups. - - - - - List of groups to which users are allowed access - - - - - Enables or disables DNS resolution on the routing peers - - - - - Allows to define a custom dns domain for the account - - - - - Allows to define a custom network range for the account in CIDR format - - - - -
- More Information - - - - - (Cloud only) Enables or disables peer approval globally. If enabled, all peers added will be in pending state until approved by an admin. - - - - - Enables or disables network traffic logging. If enabled, all network traffic events from peers will be stored. - - - - - Limits traffic logging to these groups. If unset all peers are enabled. - - - - - 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) - - - - - -
- -
- - - Enables or disables experimental lazy connection - - -
- -
-
- -
- - -
- More Information - - - - - Indicates whether the account signup form is pending - - - - - Indicates whether the account onboarding flow is pending - - - - - -
- -
-
- - - - - - + +Update information about an account + +### Path Parameters + + + + +The unique identifier of an account + + + + + +### Request-Body Parameters + + + + +
+ +More Information + + +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). + + +Period of time after which peer login expires (seconds). + + +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). + + +Period of time of inactivity after which peer session expires (seconds). + + +Allows blocking regular users from viewing parts of the system. + + +Allows propagate the new user auto groups to peers that belongs to the user + + +Allows extract groups from JWT claim and add it to account groups. + + +Name of the claim from which we extract groups names to add it to account groups. + + +List of groups to which users are allowed access + + +Enables or disables DNS resolution on the routing peers + + +Allows to define a custom dns domain for the account + + +Allows to define a custom network range for the account in CIDR format + + +
+ +More Information + + +(Cloud only) Enables or disables peer approval globally. If enabled, all peers added will be in pending state until approved by an admin. + + +Enables manual approval for new users joining via domain matching. When enabled, users are blocked with pending approval status until explicitly approved by an admin. + + +Enables or disables network traffic logging. If enabled, all network traffic events from peers will be stored. + + +Limits traffic logging to these groups. If unset all peers are enabled. + + +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) + + + + +
+ +
+ +Enables or disables experimental lazy connection + + +
+ +
+ +
+ +
+ +More Information + + +Indicates whether the account signup form is pending + + +Indicates whether the account onboarding flow is pending + + + + +
+ +
+ +
+ + + + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/accounts/{accountId} \ -H 'Accept: application/json' \ @@ -589,6 +389,7 @@ curl -X PUT https://api.netbird.io/api/accounts/{accountId} \ "network_range": "100.64.0.0/16", "extra": { "peer_approval_enabled": true, + "user_approval_required": false, "network_traffic_logs_enabled": true, "network_traffic_logs_groups": [ "ch8i4ug6lnn4g9hqv7m0" @@ -604,7 +405,7 @@ curl -X PUT https://api.netbird.io/api/accounts/{accountId} \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "settings": { @@ -624,6 +425,7 @@ let data = JSON.stringify({ "network_range": "100.64.0.0/16", "extra": { "peer_approval_enabled": true, + "user_approval_required": false, "network_traffic_logs_enabled": true, "network_traffic_logs_groups": [ "ch8i4ug6lnn4g9hqv7m0" @@ -640,7 +442,7 @@ let data = JSON.stringify({ let config = { method: 'put', maxBodyLength: Infinity, - url: '/api/accounts/{accountId}', + url: 'https://api.netbird.io/api/accounts/{accountId}', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -658,7 +460,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -681,6 +483,7 @@ payload = json.dumps({ "network_range": "100.64.0.0/16", "extra": { "peer_approval_enabled": true, + "user_approval_required": false, "network_traffic_logs_enabled": true, "network_traffic_logs_groups": [ "ch8i4ug6lnn4g9hqv7m0" @@ -705,7 +508,7 @@ response = requests.request("PUT", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -720,7 +523,7 @@ func main() { url := "https://api.netbird.io/api/accounts/{accountId}" method := "PUT" - payload := strings.NewReader(`{ + payload := strings.NewReader({ "settings": { "peer_login_expiration_enabled": true, "peer_login_expiration": 43200, @@ -738,6 +541,7 @@ func main() { "network_range": "100.64.0.0/16", "extra": { "peer_approval_enabled": true, + "user_approval_required": false, "network_traffic_logs_enabled": true, "network_traffic_logs_groups": [ "ch8i4ug6lnn4g9hqv7m0" @@ -750,15 +554,14 @@ func main() { "signup_form_pending": true, "onboarding_flow_pending": false } -}`) - client := &http.Client { - } +}) + 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") @@ -771,16 +574,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -813,6 +616,7 @@ request.body = JSON.dump({ "network_range": "100.64.0.0/16", "extra": { "peer_approval_enabled": true, + "user_approval_required": false, "network_traffic_logs_enabled": true, "network_traffic_logs_groups": [ "ch8i4ug6lnn4g9hqv7m0" @@ -830,7 +634,7 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); @@ -852,6 +656,7 @@ RequestBody body = RequestBody.create(mediaType, '{ "network_range": "100.64.0.0/16", "extra": { "peer_approval_enabled": true, + "user_approval_required": false, "network_traffic_logs_enabled": true, "network_traffic_logs_groups": [ "ch8i4ug6lnn4g9hqv7m0" @@ -870,12 +675,12 @@ Request request = new Request.Builder() .method("PUT", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7l0", @@ -957,6 +760,7 @@ echo $response; "network_range": "100.64.0.0/16", "extra": { "peer_approval_enabled": true, + "user_approval_required": false, "network_traffic_logs_enabled": true, "network_traffic_logs_groups": [ "ch8i4ug6lnn4g9hqv7m0" @@ -975,6 +779,7 @@ echo $response; } } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -995,6 +800,7 @@ echo $response; "network_range": "string", "extra": { "peer_approval_enabled": "boolean", + "user_approval_required": "boolean", "network_traffic_logs_enabled": "boolean", "network_traffic_logs_groups": [ "string" @@ -1013,10 +819,168 @@ echo $response; } } ``` - - - - + + + + +
+ +--- + + + +## Delete an Account {{ tag: 'DELETE', label: '/api/accounts/{accountId}' }} + + + + +Deletes an account and all its resources. Only account owners can delete accounts. + +### Path Parameters + + + + +The unique identifier of an account + + + + + + + +```bash {{ title: 'cURL' }} +curl -X DELETE https://api.netbird.io/api/accounts/{accountId} \ +-H 'Authorization: Token ' +``` + +```js +const axios = require('axios'); + +let config = { + method: 'delete', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/accounts/{accountId}', + headers: { + 'Authorization': 'Token ' + } +}; + +axios(config) +.then((response) => { + console.log(JSON.stringify(response.data)); +}) +.catch((error) => { + console.log(error); +}); +``` + +```python +import requests + +url = "https://api.netbird.io/api/accounts/{accountId}" + +headers = { + 'Authorization': 'Token ' +} + +response = requests.request("DELETE", url, headers=headers) +print(response.text) +``` + +```go +package main + +import ( + "fmt" + "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 ") + + 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 "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 " + +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", null) + .addHeader("Authorization", "Token ") + .build(); + +Response response = client.newCall(request).execute(); +``` + +```php + '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 ' + ), +)); + +$response = curl_exec($curl); +curl_close($curl); +echo $response; +``` + + + + --- diff --git a/src/pages/ipa/resources/dns.mdx b/src/pages/ipa/resources/dns.mdx index 8ca013e2..10dadf8e 100644 --- a/src/pages/ipa/resources/dns.mdx +++ b/src/pages/ipa/resources/dns.mdx @@ -1,29 +1,28 @@ export const title = 'DNS' +## List all Nameserver Groups {{ tag: 'GET', label: '/api/dns/nameservers' }} -## List all Nameserver Groups {{ tag: 'GET' , label: '/api/dns/nameservers' }} - - Returns a list of all Nameserver Groups - - - - + +Returns a list of all Nameserver Groups + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/dns/nameservers \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/dns/nameservers', + url: 'https://api.netbird.io/api/dns/nameservers', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -39,7 +38,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -55,30 +54,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/dns/nameservers" method := "GET" - client := &http.Client { - } + 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 ") @@ -98,7 +94,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -116,20 +112,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/dns/nameservers") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} [ { @@ -184,6 +177,7 @@ echo $response; } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -209,92 +203,74 @@ echo $response; } ] ``` - - - - + + + + --- -## Create a Nameserver Group {{ tag: 'POST' , label: '/api/dns/nameservers' }} + +## Create a Nameserver Group {{ tag: 'POST', label: '/api/dns/nameservers' }} + - - Creates a Nameserver Group - - ### Request-Body Parameters - - - - Name of nameserver group name - - - - - Description of the nameserver group - - - - -
- Nameserver list - - - - - Nameserver IP - - - - - Nameserver Type - - - - - Nameserver Port - - - - - -
- -
- - - Nameserver group status - - - - - Distribution group IDs that defines group of peers that will use this nameserver group - - - - - Defines if a nameserver group is primary that resolves all domains. It should be true only if domains list is empty. - - - - - Match domain list. It should be empty only if primary is true. - - - - - Search domain status for match domains. It should be true only if domains list is not empty. - - -
- - - - - - + +Creates a Nameserver Group + +### Request-Body Parameters + + + + +Name of nameserver group name + + +Description of the nameserver group + + +
+ +Nameserver list + + +Nameserver IP + + +Nameserver Type + + +Nameserver Port + + + + +
+ +
+ +Nameserver group status + + +Distribution group IDs that defines group of peers that will use this nameserver group + + +Defines if a nameserver group is primary that resolves all domains. It should be true only if domains list is empty. + + +Match domain list. It should be empty only if primary is true. + + +Search domain status for match domains. It should be true only if domains list is not empty. + + +
+ + + + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/dns/nameservers \ -H 'Accept: application/json' \ @@ -322,7 +298,7 @@ curl -X POST https://api.netbird.io/api/dns/nameservers \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "name": "Google DNS", @@ -347,7 +323,7 @@ let data = JSON.stringify({ let config = { method: 'post', maxBodyLength: Infinity, - url: '/api/dns/nameservers', + url: 'https://api.netbird.io/api/dns/nameservers', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -365,7 +341,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -401,7 +377,7 @@ response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -436,14 +412,13 @@ func main() { ], "search_domains_enabled": true }`) - client := &http.Client { - } + 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") @@ -456,16 +431,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -504,41 +479,41 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "name": "Google DNS", - "description": "Google DNS servers", - "nameservers": [ +RequestBody body = RequestBody.create(mediaType, "{ + \"name\": \"Google DNS\", + \"description\": \"Google DNS servers\", + \"nameservers\": [ { - "ip": "8.8.8.8", - "ns_type": "udp", - "port": 53 + \"ip\": \"8.8.8.8\", + \"ns_type\": \"udp\", + \"port\": 53 } ], - "enabled": true, - "groups": [ - "ch8i4ug6lnn4g9hqv7m0" + \"enabled\": true, + \"groups\": [ + \"ch8i4ug6lnn4g9hqv7m0\" ], - "primary": true, - "domains": [ - "example.com" + \"primary\": true, + \"domains\": [ + \"example.com\" ], - "search_domains_enabled": true -}'); + \"search_domains_enabled\": true +}"); Request request = new Request.Builder() .url("https://api.netbird.io/api/dns/nameservers") .method("POST", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7m0", @@ -612,6 +584,7 @@ echo $response; "search_domains_enabled": true } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -635,45 +608,49 @@ echo $response; "search_domains_enabled": "boolean" } ``` - - - - + + + +
--- -## Retrieve a Nameserver Group {{ tag: 'GET' , label: '/api/dns/nameservers/{nsgroupId}' }} + +## Retrieve a Nameserver Group {{ tag: 'GET', label: '/api/dns/nameservers/{nsgroupId}' }} + - - Get information about a Nameserver Groups - - ### Path Parameters - - - - The unique identifier of a Nameserver Group - - - - - - + +Get information about a Nameserver Groups + +### Path Parameters + + + + +The unique identifier of a Nameserver Group + + + + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/dns/nameservers/{nsgroupId}', + url: 'https://api.netbird.io/api/dns/nameservers/{nsgroupId}', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -689,7 +666,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -705,30 +682,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/dns/nameservers/{nsgroupId}" method := "GET" - client := &http.Client { - } + 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 ") @@ -748,7 +722,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -766,20 +740,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/dns/nameservers/{nsgroupId}") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7m0", @@ -832,6 +803,7 @@ echo $response; "search_domains_enabled": true } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -855,100 +827,85 @@ echo $response; "search_domains_enabled": "boolean" } ``` - - - - + + + + --- -## Update a Nameserver Group {{ tag: 'PUT' , label: '/api/dns/nameservers/{nsgroupId}' }} + +## Update a Nameserver Group {{ tag: 'PUT', label: '/api/dns/nameservers/{nsgroupId}' }} + - - Update/Replace a Nameserver Group - - ### Path Parameters - - - - The unique identifier of a Nameserver Group - - - - ### Request-Body Parameters - - - - Name of nameserver group name - - - - - Description of the nameserver group - - - - -
- Nameserver list - - - - - Nameserver IP - - - - - Nameserver Type - - - - - Nameserver Port - - - - - -
- -
- - - Nameserver group status - - - - - Distribution group IDs that defines group of peers that will use this nameserver group - - - - - Defines if a nameserver group is primary that resolves all domains. It should be true only if domains list is empty. - - - - - Match domain list. It should be empty only if primary is true. - - - - - Search domain status for match domains. It should be true only if domains list is not empty. - - -
- - - - - - + +Update/Replace a Nameserver Group + +### Path Parameters + + + + +The unique identifier of a Nameserver Group + + + + + +### Request-Body Parameters + + + + +Name of nameserver group name + + +Description of the nameserver group + + +
+ +Nameserver list + + +Nameserver IP + + +Nameserver Type + + +Nameserver Port + + + + +
+ +
+ +Nameserver group status + + +Distribution group IDs that defines group of peers that will use this nameserver group + + +Defines if a nameserver group is primary that resolves all domains. It should be true only if domains list is empty. + + +Match domain list. It should be empty only if primary is true. + + +Search domain status for match domains. It should be true only if domains list is not empty. + + +
+ + + + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ -H 'Accept: application/json' \ @@ -976,7 +933,7 @@ curl -X PUT https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "name": "Google DNS", @@ -1001,7 +958,7 @@ let data = JSON.stringify({ let config = { method: 'put', maxBodyLength: Infinity, - url: '/api/dns/nameservers/{nsgroupId}', + url: 'https://api.netbird.io/api/dns/nameservers/{nsgroupId}', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -1019,7 +976,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -1055,7 +1012,7 @@ response = requests.request("PUT", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -1070,7 +1027,7 @@ func main() { url := "https://api.netbird.io/api/dns/nameservers/{nsgroupId}" method := "PUT" - payload := strings.NewReader(`{ + payload := strings.NewReader({ "name": "Google DNS", "description": "Google DNS servers", "nameservers": [ @@ -1089,15 +1046,14 @@ func main() { "example.com" ], "search_domains_enabled": true -}`) - client := &http.Client { - } +}) + 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") @@ -1110,16 +1066,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -1158,7 +1114,7 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); @@ -1187,12 +1143,12 @@ Request request = new Request.Builder() .method("PUT", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7m0", @@ -1266,6 +1219,7 @@ echo $response; "search_domains_enabled": true } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -1289,35 +1243,39 @@ echo $response; "search_domains_enabled": "boolean" } ``` - - - - + + + +
--- -## Delete a Nameserver Group {{ tag: 'DELETE' , label: '/api/dns/nameservers/{nsgroupId}' }} + +## Delete a Nameserver Group {{ tag: 'DELETE', label: '/api/dns/nameservers/{nsgroupId}' }} + - - Delete a Nameserver Group - - ### Path Parameters - - - - The unique identifier of a Nameserver Group - - - - - - + +Delete a Nameserver Group + +### Path Parameters + + + + +The unique identifier of a Nameserver Group + + + + + + + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ --H 'Authorization: Token ' +-H 'Authorization: Token ' ``` ```js @@ -1326,10 +1284,10 @@ const axios = require('axios'); let config = { method: 'delete', maxBodyLength: Infinity, - url: '/api/dns/nameservers/{nsgroupId}', - headers: { + url: 'https://api.netbird.io/api/dns/nameservers/{nsgroupId}', + headers: { 'Authorization': 'Token ' - } + } }; axios(config) @@ -1343,16 +1301,14 @@ axios(config) ```python import requests -import json url = "https://api.netbird.io/api/dns/nameservers/{nsgroupId}" -headers = { +headers = { 'Authorization': 'Token ' } response = requests.request("DELETE", url, headers=headers) - print(response.text) ``` @@ -1361,25 +1317,21 @@ package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/dns/nameservers/{nsgroupId}" method := "DELETE" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return - { - + } + req.Header.Add("Authorization", "Token ") res, err := client.Do(req) @@ -1400,7 +1352,6 @@ func main() { ```ruby require "uri" -require "json" require "net/http" url = URI("https://api.netbird.io/api/dns/nameservers/{nsgroupId}") @@ -1416,14 +1367,14 @@ puts response.read_body ``` ```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); +OkHttpClient client = new OkHttpClient().newBuilder().build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/dns/nameservers/{nsgroupId}") - .method("DELETE") - .addHeader("Authorization: Token ") + .method("DELETE", null) + .addHeader("Authorization", "Token ") .build(); + Response response = client.newCall(request).execute(); ``` @@ -1440,50 +1391,48 @@ curl_setopt_array($curl, array( CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'DELETE', - CURLOPT_HTTPHEADER => array( + CURLOPT_CUSTOMREQUEST => 'DELETE', + CURLOPT_HTTPHEADER => array( 'Authorization: Token ' ), )); $response = curl_exec($curl); - curl_close($curl); echo $response; ``` + + + - - - - - --- -## Retrieve DNS settings {{ tag: 'GET' , label: '/api/dns/settings' }} - - - Returns a DNS settings object - +## Retrieve DNS settings {{ tag: 'GET', label: '/api/dns/settings' }} + - - + + +Returns a DNS settings object + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/dns/settings \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/dns/settings', + url: 'https://api.netbird.io/api/dns/settings', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -1499,7 +1448,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -1515,30 +1464,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/dns/settings" method := "GET" - client := &http.Client { - } + 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 ") @@ -1558,7 +1504,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -1576,20 +1522,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/dns/settings") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} -{ - "items": { +[ + { "disabled_management_groups": [ "ch8i4ug6lnn4g9hqv7m0" ] } -} +] ``` + ```json {{ title: 'Schema' }} -{ - "items": { +[ + { "disabled_management_groups": [ "string" ] } -} +] ``` - - - - + + + + --- -## Update DNS Settings {{ tag: 'PUT' , label: '/api/dns/settings' }} + +## Update DNS Settings {{ tag: 'PUT', label: '/api/dns/settings' }} + - - Updates a DNS settings object - - ### Request-Body Parameters - - - - Groups whose DNS management is disabled - - - - - - - - - + +Updates a DNS settings object + +### Request-Body Parameters + + + + +Groups whose DNS management is disabled + + + + + + + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/dns/settings \ -H 'Accept: application/json' \ @@ -1678,7 +1623,7 @@ curl -X PUT https://api.netbird.io/api/dns/settings \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "disabled_management_groups": [ @@ -1688,7 +1633,7 @@ let data = JSON.stringify({ let config = { method: 'put', maxBodyLength: Infinity, - url: '/api/dns/settings', + url: 'https://api.netbird.io/api/dns/settings', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -1706,7 +1651,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -1727,7 +1672,7 @@ response = requests.request("PUT", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -1742,19 +1687,18 @@ func main() { url := "https://api.netbird.io/api/dns/settings" method := "PUT" - payload := strings.NewReader(`{ + payload := strings.NewReader({ "disabled_management_groups": [ "ch8i4ug6lnn4g9hqv7m0" ] -}`) - client := &http.Client { - } +}) + 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") @@ -1767,16 +1711,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -1800,7 +1744,7 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); @@ -1814,12 +1758,12 @@ Request request = new Request.Builder() .method("PUT", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "disabled_management_groups": [ @@ -1862,6 +1803,7 @@ echo $response; ] } ``` + ```json {{ title: 'Schema' }} { "disabled_management_groups": [ @@ -1869,10 +1811,10 @@ echo $response; ] } ``` - - - - + + + + --- diff --git a/src/pages/ipa/resources/events.mdx b/src/pages/ipa/resources/events.mdx index 18cd79d6..c5004afc 100644 --- a/src/pages/ipa/resources/events.mdx +++ b/src/pages/ipa/resources/events.mdx @@ -1,29 +1,28 @@ export const title = 'Events' +## List all Audit Events {{ tag: 'GET', label: '/api/events/audit' }} -## List all Audit Events {{ tag: 'GET' , label: '/api/events/audit' }} - - Returns a list of all audit events - - - - + +Returns a list of all audit events + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/events/audit \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/events/audit', + url: 'https://api.netbird.io/api/events/audit', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -39,7 +38,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -55,30 +54,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: '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 { - } + 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 ") @@ -98,7 +94,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -116,20 +112,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/events/audit") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} [ { @@ -178,6 +171,7 @@ echo $response; } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -190,7 +184,6 @@ echo $response; "initiator_email": "string", "target_id": "string", "meta": { - "description": "The metadata of the event", "type": "object", "additionalProperties": "string", "example": { @@ -202,85 +195,79 @@ echo $response; } ] ``` - - - - + + + + --- -## List all Traffic Events {{ tag: 'GET' , label: '/api/events/network-traffic' }} + +## List all Traffic Events {{ tag: 'GET', label: '/api/events/network-traffic' }} + - - Returns a list of all network traffic events - - ### Query Parameters - - - - Page number - - - - Number of items per page - - - - Filter by user ID - - - - Filter by reporter ID - - - - Filter by protocol - - - - Filter by event type - - - - Filter by connection type - - - - Filter by direction - - - - Case-insensitive partial match on user email, source/destination names, and source/destination addresses - - - - Start date for filtering events (ISO 8601 format, e.g., 2024-01-01T00:00:00Z). - - - - End date for filtering events (ISO 8601 format, e.g., 2024-01-31T23:59:59Z). - - - - - - + +Returns a list of all network traffic events + +### Query Parameters + + + + +Page number + + +Number of items per page + + +Filter by user ID + + +Filter by reporter ID + + +Filter by protocol + + +Filter by event type + + +Filter by connection type + + +Filter by direction + + +Case-insensitive partial match on user email, source/destination names, and source/destination addresses + + +Start date for filtering events (ISO 8601 format, e.g., 2024-01-01T00:00:00Z). + + +End date for filtering events (ISO 8601 format, e.g., 2024-01-31T23:59:59Z). + + + + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/events/network-traffic \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/events/network-traffic', + url: 'https://api.netbird.io/api/events/network-traffic', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -296,7 +283,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -312,30 +299,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: '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 { - } + 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 ") @@ -355,7 +339,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -373,20 +357,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/events/network-traffic") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "data": [ @@ -468,29 +449,18 @@ echo $response; "events": [ { "type": "TYPE_START", - "timestamp": {} + "timestamp": "2025-03-20T16:23:58.125397Z" } ] } ], - "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" - } + "page": 0, + "page_size": 0, + "total_records": 0, + "total_pages": 0 } ``` + ```json {{ title: 'Schema' }} { "data": [ @@ -554,10 +524,10 @@ echo $response; "total_pages": "integer" } ``` - - - - + + + + --- diff --git a/src/pages/ipa/resources/geo-locations.mdx b/src/pages/ipa/resources/geo-locations.mdx index b5b87842..c2151c0c 100644 --- a/src/pages/ipa/resources/geo-locations.mdx +++ b/src/pages/ipa/resources/geo-locations.mdx @@ -1,29 +1,28 @@ export const title = 'Geo Locations' +## List all country codes {{ tag: 'GET', label: '/api/locations/countries' }} -## List all country codes {{ tag: 'GET' , label: '/api/locations/countries' }} - - Get list of all country in 2-letter ISO 3166-1 alpha-2 codes - - - - + +Get list of all country in 2-letter ISO 3166-1 alpha-2 codes + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/locations/countries \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/locations/countries', + url: 'https://api.netbird.io/api/locations/countries', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -39,7 +38,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -55,30 +54,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: '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 { - } + 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 ") @@ -98,7 +94,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -116,20 +112,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/locations/countries") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} [ "DE" ] ``` + ```json {{ title: 'Schema' }} [ "string" ] ``` - - - - + + + + --- -## List all city names by country {{ tag: 'GET' , label: '/api/locations/countries/{country}/cities' }} + +## List all city names by country {{ tag: 'GET', label: '/api/locations/countries/{country}/cities' }} + - - Get a list of all English city names for a given country code - - ### Path Parameters - - - - - - - - - - + +Get a list of all English city names for a given country code + +### Path Parameters + + + + + + + + + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/locations/countries/{country}/cities \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/locations/countries/{country}/cities', + url: 'https://api.netbird.io/api/locations/countries/{country}/cities', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -223,7 +221,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -239,30 +237,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: '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 { - } + 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 ") @@ -282,7 +277,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -300,20 +295,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/locations/countries/{country}/cities") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "geoname_id": 2950158, "city_name": "Berlin" } ``` + ```json {{ title: 'Schema' }} { "geoname_id": "integer", "city_name": "string" } ``` - - - - + + + + --- diff --git a/src/pages/ipa/resources/groups.mdx b/src/pages/ipa/resources/groups.mdx index 4d0cab6f..8c79652a 100644 --- a/src/pages/ipa/resources/groups.mdx +++ b/src/pages/ipa/resources/groups.mdx @@ -1,29 +1,28 @@ export const title = 'Groups' +## List all Groups {{ tag: 'GET', label: '/api/groups' }} -## List all Groups {{ tag: 'GET' , label: '/api/groups' }} - - Returns a list of all groups - - - - + +Returns a list of all groups + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/groups \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/groups', + url: 'https://api.netbird.io/api/groups', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -39,7 +38,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -55,30 +54,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/groups" method := "GET" - client := &http.Client { - } + 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 ") @@ -98,7 +94,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -116,20 +112,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/groups") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} [ { @@ -182,6 +175,7 @@ echo $response; } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -205,62 +199,56 @@ echo $response; } ] ``` - - - - + + + + --- -## Create a Group {{ tag: 'POST' , label: '/api/groups' }} + +## Create a Group {{ tag: 'POST', label: '/api/groups' }} + - - Creates a group - - ### Request-Body Parameters - - - - Group name identifier - - - - - List of peers ids - - - - -
- More Information - - - - - ID of the resource - - - - - Network resource type based of the address - - - - - -
- -
-
- - - - - - + +Creates a group + +### Request-Body Parameters + + + + +Group name identifier + + +List of peers ids + + +
+ +More Information + + +ID of the resource + + +Network resource type based of the address + + + + +
+ +
+ +
+ + + + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/groups \ -H 'Accept: application/json' \ @@ -280,7 +268,7 @@ curl -X POST https://api.netbird.io/api/groups \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "name": "devs", @@ -297,7 +285,7 @@ let data = JSON.stringify({ let config = { method: 'post', maxBodyLength: Infinity, - url: '/api/groups', + url: 'https://api.netbird.io/api/groups', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -315,7 +303,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -343,7 +331,7 @@ response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -370,14 +358,13 @@ func main() { } ] }`) - client := &http.Client { - } + 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") @@ -390,16 +377,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -430,33 +417,33 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "name": "devs", - "peers": [ - "ch8i4ug6lnn4g9hqv7m1" +RequestBody body = RequestBody.create(mediaType, "{ + \"name\": \"devs\", + \"peers\": [ + \"ch8i4ug6lnn4g9hqv7m1\" ], - "resources": [ + \"resources\": [ { - "id": "chacdk86lnnboviihd7g", - "type": "host" + \"id\": \"chacdk86lnnboviihd7g\", + \"type\": \"host\" } ] -}'); +}"); Request request = new Request.Builder() .url("https://api.netbird.io/api/groups") .method("POST", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7m0", @@ -520,6 +504,7 @@ echo $response; ] } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -541,45 +526,49 @@ echo $response; ] } ``` - - - - + + + +
--- -## Retrieve a Group {{ tag: 'GET' , label: '/api/groups/{groupId}' }} + +## Retrieve a Group {{ tag: 'GET', label: '/api/groups/{groupId}' }} + - - Get information about a group - - ### Path Parameters - - - - The unique identifier of a group - - - - - - + +Get information about a group + +### Path Parameters + + + + +The unique identifier of a group + + + + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/groups/{groupId} \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/groups/{groupId}', + url: 'https://api.netbird.io/api/groups/{groupId}', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -595,7 +584,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -611,30 +600,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/groups/{groupId}" method := "GET" - client := &http.Client { - } + 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 ") @@ -654,7 +640,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -672,20 +658,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/groups/{groupId}") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7m0", @@ -736,6 +719,7 @@ echo $response; ] } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -757,70 +741,67 @@ echo $response; ] } ``` - - - - + + + + --- -## Update a Group {{ tag: 'PUT' , label: '/api/groups/{groupId}' }} + +## Update a Group {{ tag: 'PUT', label: '/api/groups/{groupId}' }} + - - Update/Replace a group - - ### Path Parameters - - - - The unique identifier of a group - - - - ### Request-Body Parameters - - - - Group name identifier - - - - - List of peers ids - - - - -
- More Information - - - - - ID of the resource - - - - - Network resource type based of the address - - - - - -
- -
-
- - - - - - + +Update/Replace a group + +### Path Parameters + + + + +The unique identifier of a group + + + + + +### Request-Body Parameters + + + + +Group name identifier + + +List of peers ids + + +
+ +More Information + + +ID of the resource + + +Network resource type based of the address + + + + +
+ +
+ +
+ + + + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/groups/{groupId} \ -H 'Accept: application/json' \ @@ -840,7 +821,7 @@ curl -X PUT https://api.netbird.io/api/groups/{groupId} \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "name": "devs", @@ -857,7 +838,7 @@ let data = JSON.stringify({ let config = { method: 'put', maxBodyLength: Infinity, - url: '/api/groups/{groupId}', + url: 'https://api.netbird.io/api/groups/{groupId}', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -875,7 +856,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -903,7 +884,7 @@ response = requests.request("PUT", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -918,7 +899,7 @@ func main() { url := "https://api.netbird.io/api/groups/{groupId}" method := "PUT" - payload := strings.NewReader(`{ + payload := strings.NewReader({ "name": "devs", "peers": [ "ch8i4ug6lnn4g9hqv7m1" @@ -929,15 +910,14 @@ func main() { "type": "host" } ] -}`) - client := &http.Client { - } +}) + 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") @@ -950,16 +930,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -990,7 +970,7 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); @@ -1011,12 +991,12 @@ Request request = new Request.Builder() .method("PUT", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7m0", @@ -1080,6 +1057,7 @@ echo $response; ] } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -1101,35 +1079,39 @@ echo $response; ] } ``` - - - - + + + +
--- -## Delete a Group {{ tag: 'DELETE' , label: '/api/groups/{groupId}' }} + +## Delete a Group {{ tag: 'DELETE', label: '/api/groups/{groupId}' }} + - - Delete a group - - ### Path Parameters - - - - The unique identifier of a group - - - - - - + +Delete a group + +### Path Parameters + + + + +The unique identifier of a group + + + + + + + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/groups/{groupId} \ --H 'Authorization: Token ' +-H 'Authorization: Token ' ``` ```js @@ -1138,10 +1120,10 @@ const axios = require('axios'); let config = { method: 'delete', maxBodyLength: Infinity, - url: '/api/groups/{groupId}', - headers: { + url: 'https://api.netbird.io/api/groups/{groupId}', + headers: { 'Authorization': 'Token ' - } + } }; axios(config) @@ -1155,16 +1137,14 @@ axios(config) ```python import requests -import json url = "https://api.netbird.io/api/groups/{groupId}" -headers = { +headers = { 'Authorization': 'Token ' } response = requests.request("DELETE", url, headers=headers) - print(response.text) ``` @@ -1173,25 +1153,21 @@ package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/groups/{groupId}" method := "DELETE" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return - { - + } + req.Header.Add("Authorization", "Token ") res, err := client.Do(req) @@ -1212,7 +1188,6 @@ func main() { ```ruby require "uri" -require "json" require "net/http" url = URI("https://api.netbird.io/api/groups/{groupId}") @@ -1228,14 +1203,14 @@ puts response.read_body ``` ```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); +OkHttpClient client = new OkHttpClient().newBuilder().build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/groups/{groupId}") - .method("DELETE") - .addHeader("Authorization: Token ") + .method("DELETE", null) + .addHeader("Authorization", "Token ") .build(); + Response response = client.newCall(request).execute(); ``` @@ -1252,23 +1227,20 @@ curl_setopt_array($curl, array( CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'DELETE', - CURLOPT_HTTPHEADER => array( + CURLOPT_CUSTOMREQUEST => 'DELETE', + CURLOPT_HTTPHEADER => array( 'Authorization: Token ' ), )); $response = curl_exec($curl); - curl_close($curl); echo $response; ``` + + + - - - - - --- diff --git a/src/pages/ipa/resources/ingress-ports.mdx b/src/pages/ipa/resources/ingress-ports.mdx index e9c19ce5..a2245d53 100644 --- a/src/pages/ipa/resources/ingress-ports.mdx +++ b/src/pages/ipa/resources/ingress-ports.mdx @@ -1,45 +1,50 @@ export const title = 'Ingress Ports' +## List all Port Allocations {{ tag: 'GET', label: '/api/peers/{peerId}/ingress/ports' }} -## List all Port Allocations {{ tag: 'GET' , label: '/api/peers/{peerId}/ingress/ports' }} - - Returns a list of all ingress port allocations for a peer - - ### Path Parameters - - - - The unique identifier of a peer - - - - ### Query Parameters - - - - Filters ingress port allocations by name - - - - - - + +Returns a list of all ingress port allocations for a peer + +### Path Parameters + + + + +The unique identifier of a peer + + + + + +### Query Parameters + + + + +Filters ingress port allocations by name + + + + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/peers/{peerId}/ingress/ports \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/peers/{peerId}/ingress/ports', + url: 'https://api.netbird.io/api/peers/{peerId}/ingress/ports', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -55,7 +60,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -71,30 +76,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/peers/{peerId}/ingress/ports" method := "GET" - client := &http.Client { - } + 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 ") @@ -114,7 +116,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -132,20 +134,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/peers/{peerId}/ingress/ports") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} [ { @@ -196,6 +195,7 @@ echo $response; } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -217,97 +217,87 @@ echo $response; } ] ``` - - - - + + + + --- -## Create a Port Allocation {{ tag: 'POST' , label: '/api/peers/{peerId}/ingress/ports' }} + +## Create a Port Allocation {{ tag: 'POST', label: '/api/peers/{peerId}/ingress/ports' }} + - - Creates a new ingress port allocation for a peer - - ### Path Parameters - - - - The unique identifier of a peer - - - - ### Request-Body Parameters - - - - Name of the ingress port allocation - - - - - Indicates if an ingress port allocation is enabled - - - - -
- List of port ranges that are forwarded by the ingress peer - - - - - The starting port of the range of forwarded ports - - - - - The ending port of the range of forwarded ports - - - - - The protocol accepted by the port range - - - - - -
- -
- - -
- More Information - - - - - The number of ports to be forwarded - - - - - The protocol accepted by the port - - - - - -
- -
-
- - - - - - + +Creates a new ingress port allocation for a peer + +### Path Parameters + + + + +The unique identifier of a peer + + + + + +### Request-Body Parameters + + + + +Name of the ingress port allocation + + +Indicates if an ingress port allocation is enabled + + +
+ +List of port ranges that are forwarded by the ingress peer + + +The starting port of the range of forwarded ports + + +The ending port of the range of forwarded ports + + +The protocol accepted by the port range + + + + +
+ +
+ +
+ +More Information + + +The number of ports to be forwarded + + +The protocol accepted by the port + + + + +
+ +
+ +
+ + + + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/peers/{peerId}/ingress/ports \ -H 'Accept: application/json' \ @@ -330,7 +320,7 @@ curl -X POST https://api.netbird.io/api/peers/{peerId}/ingress/ports \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "name": "Ingress Port Allocation 1", @@ -350,7 +340,7 @@ let data = JSON.stringify({ let config = { method: 'post', maxBodyLength: Infinity, - url: '/api/peers/{peerId}/ingress/ports', + url: 'https://api.netbird.io/api/peers/{peerId}/ingress/ports', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -368,7 +358,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -399,7 +389,7 @@ response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -429,14 +419,13 @@ func main() { "protocol": "udp" } }`) - client := &http.Client { - } + 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") @@ -449,16 +438,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -492,36 +481,36 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "name": "Ingress Port Allocation 1", - "enabled": true, - "port_ranges": [ +RequestBody body = RequestBody.create(mediaType, "{ + \"name\": \"Ingress Port Allocation 1\", + \"enabled\": true, + \"port_ranges\": [ { - "start": 80, - "end": 320, - "protocol": "tcp" + \"start\": 80, + \"end\": 320, + \"protocol\": \"tcp\" } ], - "direct_port": { - "count": 5, - "protocol": "udp" + \"direct_port\": { + \"count\": 5, + \"protocol\": \"udp\" } -}'); +}"); Request request = new Request.Builder() .url("https://api.netbird.io/api/peers/{peerId}/ingress/ports") .method("POST", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7m0", @@ -586,6 +572,7 @@ echo $response; ] } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -605,49 +592,52 @@ echo $response; ] } ``` - - - - + + + +
--- -## Retrieve a Port Allocation {{ tag: 'GET' , label: '/api/peers/{peerId}/ingress/ports/{allocationId}' }} + +## Retrieve a Port Allocation {{ tag: 'GET', label: '/api/peers/{peerId}/ingress/ports/{allocationId}' }} + - - Get information about an ingress port allocation - - ### Path Parameters - - - - The unique identifier of a peer - - - - The unique identifier of an ingress port allocation - - - - - - + +Get information about an ingress port allocation + +### Path Parameters + + + + +The unique identifier of a peer + + +The unique identifier of an ingress port allocation + + + + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId} \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/peers/{peerId}/ingress/ports/{allocationId}', + url: 'https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -663,7 +653,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -679,30 +669,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}" method := "GET" - client := &http.Client { - } + 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 ") @@ -722,7 +709,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -740,20 +727,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7m0", @@ -802,6 +786,7 @@ echo $response; ] } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -821,101 +806,90 @@ echo $response; ] } ``` - - - - + + + + --- -## Update a Port Allocation {{ tag: 'PUT' , label: '/api/peers/{peerId}/ingress/ports/{allocationId}' }} + +## Update a Port Allocation {{ tag: 'PUT', label: '/api/peers/{peerId}/ingress/ports/{allocationId}' }} + - - Update information about an ingress port allocation - - ### Path Parameters - - - - The unique identifier of a peer - - - - The unique identifier of an ingress port allocation - - - - ### Request-Body Parameters - - - - Name of the ingress port allocation - - - - - Indicates if an ingress port allocation is enabled - - - - -
- List of port ranges that are forwarded by the ingress peer - - - - - The starting port of the range of forwarded ports - - - - - The ending port of the range of forwarded ports - - - - - The protocol accepted by the port range - - - - - -
- -
- - -
- More Information - - - - - The number of ports to be forwarded - - - - - The protocol accepted by the port - - - - - -
- -
-
- - - - - - + +Update information about an ingress port allocation + +### Path Parameters + + + + +The unique identifier of a peer + + +The unique identifier of an ingress port allocation + + + + + +### Request-Body Parameters + + + + +Name of the ingress port allocation + + +Indicates if an ingress port allocation is enabled + + +
+ +List of port ranges that are forwarded by the ingress peer + + +The starting port of the range of forwarded ports + + +The ending port of the range of forwarded ports + + +The protocol accepted by the port range + + + + +
+ +
+ +
+ +More Information + + +The number of ports to be forwarded + + +The protocol accepted by the port + + + + +
+ +
+ +
+ + + + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId} \ -H 'Accept: application/json' \ @@ -938,7 +912,7 @@ curl -X PUT https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationI }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "name": "Ingress Port Allocation 1", @@ -958,7 +932,7 @@ let data = JSON.stringify({ let config = { method: 'put', maxBodyLength: Infinity, - url: '/api/peers/{peerId}/ingress/ports/{allocationId}', + url: 'https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -976,7 +950,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -1007,7 +981,7 @@ response = requests.request("PUT", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -1022,7 +996,7 @@ func main() { url := "https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}" method := "PUT" - payload := strings.NewReader(`{ + payload := strings.NewReader({ "name": "Ingress Port Allocation 1", "enabled": true, "port_ranges": [ @@ -1036,15 +1010,14 @@ func main() { "count": 5, "protocol": "udp" } -}`) - client := &http.Client { - } +}) + 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") @@ -1057,16 +1030,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -1100,7 +1073,7 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); @@ -1124,12 +1097,12 @@ Request request = new Request.Builder() .method("PUT", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7m0", @@ -1194,6 +1164,7 @@ echo $response; ] } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -1213,39 +1184,42 @@ echo $response; ] } ``` - - - - + + + +
--- -## Delete a Port Allocation {{ tag: 'DELETE' , label: '/api/peers/{peerId}/ingress/ports/{allocationId}' }} + +## Delete a Port Allocation {{ tag: 'DELETE', label: '/api/peers/{peerId}/ingress/ports/{allocationId}' }} + - - Delete an ingress port allocation - - ### Path Parameters - - - - The unique identifier of a peer - - - - The unique identifier of an ingress port allocation - - - - - - + +Delete an ingress port allocation + +### Path Parameters + + + + +The unique identifier of a peer + + +The unique identifier of an ingress port allocation + + + + + + + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId} \ --H 'Authorization: Token ' +-H 'Authorization: Token ' ``` ```js @@ -1254,10 +1228,10 @@ const axios = require('axios'); let config = { method: 'delete', maxBodyLength: Infinity, - url: '/api/peers/{peerId}/ingress/ports/{allocationId}', - headers: { + url: 'https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}', + headers: { 'Authorization': 'Token ' - } + } }; axios(config) @@ -1271,16 +1245,14 @@ axios(config) ```python import requests -import json url = "https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}" -headers = { +headers = { 'Authorization': 'Token ' } response = requests.request("DELETE", url, headers=headers) - print(response.text) ``` @@ -1289,25 +1261,21 @@ package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}" method := "DELETE" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return - { - + } + req.Header.Add("Authorization", "Token ") res, err := client.Do(req) @@ -1328,7 +1296,6 @@ func main() { ```ruby require "uri" -require "json" require "net/http" url = URI("https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}") @@ -1344,14 +1311,14 @@ puts response.read_body ``` ```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); +OkHttpClient client = new OkHttpClient().newBuilder().build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}") - .method("DELETE") - .addHeader("Authorization: Token ") + .method("DELETE", null) + .addHeader("Authorization", "Token ") .build(); + Response response = client.newCall(request).execute(); ``` @@ -1368,50 +1335,48 @@ curl_setopt_array($curl, array( CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'DELETE', - CURLOPT_HTTPHEADER => array( + CURLOPT_CUSTOMREQUEST => 'DELETE', + CURLOPT_HTTPHEADER => array( 'Authorization: Token ' ), )); $response = curl_exec($curl); - curl_close($curl); echo $response; ``` + + + - - - - - --- -## List all Ingress Peers {{ tag: 'GET' , label: '/api/ingress/peers' }} - - - Returns a list of all ingress peers - +## List all Ingress Peers {{ tag: 'GET', label: '/api/ingress/peers' }} - - + + + +Returns a list of all ingress peers + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/ingress/peers \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/ingress/peers', + url: 'https://api.netbird.io/api/ingress/peers', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -1427,7 +1392,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -1443,30 +1408,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/ingress/peers" method := "GET" - client := &http.Client { - } + 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 ") @@ -1486,7 +1448,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -1504,20 +1466,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/ingress/peers") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} [ { @@ -1564,6 +1523,7 @@ echo $response; } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -1581,45 +1541,42 @@ echo $response; } ] ``` - - - - + + + + --- -## Create a Ingress Peer {{ tag: 'POST' , label: '/api/ingress/peers' }} + +## Create a Ingress Peer {{ tag: 'POST', label: '/api/ingress/peers' }} + - - Creates a new ingress peer - - ### Request-Body Parameters - - - - ID of the peer that is used as an ingress peer - - - - - Defines if an ingress peer is enabled - - - - - Defines if an ingress peer can be used as a fallback if no ingress peer can be found in the region of the forwarded peer - - - - - - - - - + +Creates a new ingress peer + +### Request-Body Parameters + + + + +ID of the peer that is used as an ingress peer + + +Defines if an ingress peer is enabled + + +Defines if an ingress peer can be used as a fallback if no ingress peer can be found in the region of the forwarded peer + + + + + + + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/ingress/peers \ -H 'Accept: application/json' \ @@ -1632,7 +1589,7 @@ curl -X POST https://api.netbird.io/api/ingress/peers \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "peer_id": "ch8i4ug6lnn4g9hqv7m0", @@ -1642,7 +1599,7 @@ let data = JSON.stringify({ let config = { method: 'post', maxBodyLength: Infinity, - url: '/api/ingress/peers', + url: 'https://api.netbird.io/api/ingress/peers', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -1660,7 +1617,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -1681,7 +1638,7 @@ response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -1701,14 +1658,13 @@ func main() { "enabled": true, "fallback": true }`) - client := &http.Client { - } + 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") @@ -1721,16 +1677,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -1754,26 +1710,26 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "peer_id": "ch8i4ug6lnn4g9hqv7m0", - "enabled": true, - "fallback": true -}'); +RequestBody body = RequestBody.create(mediaType, "{ + \"peer_id\": \"ch8i4ug6lnn4g9hqv7m0\", + \"enabled\": true, + \"fallback\": true +}"); Request request = new Request.Builder() .url("https://api.netbird.io/api/ingress/peers") .method("POST", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7m0", @@ -1824,6 +1777,7 @@ echo $response; "region": "germany" } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -1839,45 +1793,49 @@ echo $response; "region": "string" } ``` - - - - + + + + --- -## Retrieve a Ingress Peer {{ tag: 'GET' , label: '/api/ingress/peers/{ingressPeerId}' }} + +## Retrieve a Ingress Peer {{ tag: 'GET', label: '/api/ingress/peers/{ingressPeerId}' }} + - - Get information about an ingress peer - - ### Path Parameters - - - - The unique identifier of an ingress peer - - - - - - + +Get information about an ingress peer + +### Path Parameters + + + + +The unique identifier of an ingress peer + + + + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/ingress/peers/{ingressPeerId}', + url: 'https://api.netbird.io/api/ingress/peers/{ingressPeerId}', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -1893,7 +1851,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -1909,30 +1867,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/ingress/peers/{ingressPeerId}" method := "GET" - client := &http.Client { - } + 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 ") @@ -1952,7 +1907,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -1970,20 +1925,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/ingress/peers/{ingressPeerId}") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7m0", @@ -2028,6 +1980,7 @@ echo $response; "region": "germany" } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -2043,48 +1996,50 @@ echo $response; "region": "string" } ``` - - - - + + + + --- -## Update a Ingress Peer {{ tag: 'PUT' , label: '/api/ingress/peers/{ingressPeerId}' }} + +## Update a Ingress Peer {{ tag: 'PUT', label: '/api/ingress/peers/{ingressPeerId}' }} + - - Update information about an ingress peer - - ### Path Parameters - - - - The unique identifier of an ingress peer - - - - ### Request-Body Parameters - - - - Defines if an ingress peer is enabled - - - - - Defines if an ingress peer can be used as a fallback if no ingress peer can be found in the region of the forwarded peer - - - - - - - - - + +Update information about an ingress peer + +### Path Parameters + + + + +The unique identifier of an ingress peer + + + + + +### Request-Body Parameters + + + + +Defines if an ingress peer is enabled + + +Defines if an ingress peer can be used as a fallback if no ingress peer can be found in the region of the forwarded peer + + + + + + + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ -H 'Accept: application/json' \ @@ -2096,7 +2051,7 @@ curl -X PUT https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "enabled": true, @@ -2105,7 +2060,7 @@ let data = JSON.stringify({ let config = { method: 'put', maxBodyLength: Infinity, - url: '/api/ingress/peers/{ingressPeerId}', + url: 'https://api.netbird.io/api/ingress/peers/{ingressPeerId}', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -2123,7 +2078,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -2143,7 +2098,7 @@ response = requests.request("PUT", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -2158,18 +2113,17 @@ func main() { url := "https://api.netbird.io/api/ingress/peers/{ingressPeerId}" method := "PUT" - payload := strings.NewReader(`{ + payload := strings.NewReader({ "enabled": true, "fallback": true -}`) - client := &http.Client { - } +}) + 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") @@ -2182,16 +2136,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -2214,7 +2168,7 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); @@ -2227,12 +2181,12 @@ Request request = new Request.Builder() .method("PUT", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7m0", @@ -2282,6 +2233,7 @@ echo $response; "region": "germany" } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -2297,35 +2249,39 @@ echo $response; "region": "string" } ``` - - - - + + + + --- -## Delete a Ingress Peer {{ tag: 'DELETE' , label: '/api/ingress/peers/{ingressPeerId}' }} + +## Delete a Ingress Peer {{ tag: 'DELETE', label: '/api/ingress/peers/{ingressPeerId}' }} + - - Delete an ingress peer - - ### Path Parameters - - - - The unique identifier of an ingress peer - - - - - - + +Delete an ingress peer + +### Path Parameters + + + + +The unique identifier of an ingress peer + + + + + + + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ --H 'Authorization: Token ' +-H 'Authorization: Token ' ``` ```js @@ -2334,10 +2290,10 @@ const axios = require('axios'); let config = { method: 'delete', maxBodyLength: Infinity, - url: '/api/ingress/peers/{ingressPeerId}', - headers: { + url: 'https://api.netbird.io/api/ingress/peers/{ingressPeerId}', + headers: { 'Authorization': 'Token ' - } + } }; axios(config) @@ -2351,16 +2307,14 @@ axios(config) ```python import requests -import json url = "https://api.netbird.io/api/ingress/peers/{ingressPeerId}" -headers = { +headers = { 'Authorization': 'Token ' } response = requests.request("DELETE", url, headers=headers) - print(response.text) ``` @@ -2369,25 +2323,21 @@ package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/ingress/peers/{ingressPeerId}" method := "DELETE" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return - { - + } + req.Header.Add("Authorization", "Token ") res, err := client.Do(req) @@ -2408,7 +2358,6 @@ func main() { ```ruby require "uri" -require "json" require "net/http" url = URI("https://api.netbird.io/api/ingress/peers/{ingressPeerId}") @@ -2424,14 +2373,14 @@ puts response.read_body ``` ```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); +OkHttpClient client = new OkHttpClient().newBuilder().build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/ingress/peers/{ingressPeerId}") - .method("DELETE") - .addHeader("Authorization: Token ") + .method("DELETE", null) + .addHeader("Authorization", "Token ") .build(); + Response response = client.newCall(request).execute(); ``` @@ -2448,23 +2397,20 @@ curl_setopt_array($curl, array( CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'DELETE', - CURLOPT_HTTPHEADER => array( + CURLOPT_CUSTOMREQUEST => 'DELETE', + CURLOPT_HTTPHEADER => array( 'Authorization: Token ' ), )); $response = curl_exec($curl); - curl_close($curl); echo $response; ``` + + + - - - - - --- diff --git a/src/pages/ipa/resources/networks.mdx b/src/pages/ipa/resources/networks.mdx index d0c19c67..912f56d8 100644 --- a/src/pages/ipa/resources/networks.mdx +++ b/src/pages/ipa/resources/networks.mdx @@ -1,29 +1,28 @@ export const title = 'Networks' +## List all Networks {{ tag: 'GET', label: '/api/networks' }} -## List all Networks {{ tag: 'GET' , label: '/api/networks' }} - - Returns a list of all networks - - - - + +Returns a list of all networks + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/networks \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/networks', + url: 'https://api.netbird.io/api/networks', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -39,7 +38,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -55,30 +54,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/networks" method := "GET" - client := &http.Client { - } + 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 ") @@ -98,7 +94,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -116,20 +112,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/networks") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} [ { @@ -178,6 +171,7 @@ echo $response; } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -197,40 +191,39 @@ echo $response; } ] ``` - - - - + + + + --- -## Create a Network {{ tag: 'POST' , label: '/api/networks' }} + +## Create a Network {{ tag: 'POST', label: '/api/networks' }} + - - Creates a Network - - ### Request-Body Parameters - - - - Network name - - - - - Network description - - - - - - - - - + +Creates a Network + +### Request-Body Parameters + + + + +Network name + + +Network description + + + + + + + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/networks \ -H 'Accept: application/json' \ @@ -242,7 +235,7 @@ curl -X POST https://api.netbird.io/api/networks \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "name": "Remote Network 1", @@ -251,7 +244,7 @@ let data = JSON.stringify({ let config = { method: 'post', maxBodyLength: Infinity, - url: '/api/networks', + url: 'https://api.netbird.io/api/networks', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -269,7 +262,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -289,7 +282,7 @@ response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -308,14 +301,13 @@ func main() { "name": "Remote Network 1", "description": "A remote network that needs to be accessed" }`) - client := &http.Client { - } + 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") @@ -328,16 +320,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -360,25 +352,25 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "name": "Remote Network 1", - "description": "A remote network that needs to be accessed" -}'); +RequestBody body = RequestBody.create(mediaType, "{ + \"name\": \"Remote Network 1\", + \"description\": \"A remote network that needs to be accessed\" +}"); Request request = new Request.Builder() .url("https://api.netbird.io/api/networks") .method("POST", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "chacdk86lnnboviihd7g", @@ -430,6 +419,7 @@ echo $response; "description": "A remote network that needs to be accessed" } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -447,45 +437,49 @@ echo $response; "description": "string" } ``` - - - - + + + + --- -## Retrieve a Network {{ tag: 'GET' , label: '/api/networks/{networkId}' }} + +## Retrieve a Network {{ tag: 'GET', label: '/api/networks/{networkId}' }} + - - Get information about a Network - - ### Path Parameters - - - - The unique identifier of a network - - - - - - + +Get information about a Network + +### Path Parameters + + + + +The unique identifier of a network + + + + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/networks/{networkId} \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/networks/{networkId}', + url: 'https://api.netbird.io/api/networks/{networkId}', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -501,7 +495,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -517,30 +511,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/networks/{networkId}" method := "GET" - client := &http.Client { - } + 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 ") @@ -560,7 +551,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -578,20 +569,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/networks/{networkId}") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "chacdk86lnnboviihd7g", @@ -638,6 +626,7 @@ echo $response; "description": "A remote network that needs to be accessed" } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -655,48 +644,50 @@ echo $response; "description": "string" } ``` - - - - + + + + --- -## Update a Network {{ tag: 'PUT' , label: '/api/networks/{networkId}' }} + +## Update a Network {{ tag: 'PUT', label: '/api/networks/{networkId}' }} + - - Update/Replace a Network - - ### Path Parameters - - - - The unique identifier of a network - - - - ### Request-Body Parameters - - - - Network name - - - - - Network description - - - - - - - - - + +Update/Replace a Network + +### Path Parameters + + + + +The unique identifier of a network + + + + + +### Request-Body Parameters + + + + +Network name + + +Network description + + + + + + + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/networks/{networkId} \ -H 'Accept: application/json' \ @@ -708,7 +699,7 @@ curl -X PUT https://api.netbird.io/api/networks/{networkId} \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "name": "Remote Network 1", @@ -717,7 +708,7 @@ let data = JSON.stringify({ let config = { method: 'put', maxBodyLength: Infinity, - url: '/api/networks/{networkId}', + url: 'https://api.netbird.io/api/networks/{networkId}', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -735,7 +726,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -755,7 +746,7 @@ response = requests.request("PUT", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -770,18 +761,17 @@ func main() { url := "https://api.netbird.io/api/networks/{networkId}" method := "PUT" - payload := strings.NewReader(`{ + payload := strings.NewReader({ "name": "Remote Network 1", "description": "A remote network that needs to be accessed" -}`) - client := &http.Client { - } +}) + 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") @@ -794,16 +784,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -826,7 +816,7 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); @@ -839,12 +829,12 @@ Request request = new Request.Builder() .method("PUT", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "chacdk86lnnboviihd7g", @@ -896,6 +883,7 @@ echo $response; "description": "A remote network that needs to be accessed" } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -913,35 +901,39 @@ echo $response; "description": "string" } ``` - - - - + + + + --- -## Delete a Network {{ tag: 'DELETE' , label: '/api/networks/{networkId}' }} + +## Delete a Network {{ tag: 'DELETE', label: '/api/networks/{networkId}' }} + - - Delete a network - - ### Path Parameters - - - - The unique identifier of a network - - - - - - + +Delete a network + +### Path Parameters + + + + +The unique identifier of a network + + + + + + + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/networks/{networkId} \ --H 'Authorization: Token ' +-H 'Authorization: Token ' ``` ```js @@ -950,10 +942,10 @@ const axios = require('axios'); let config = { method: 'delete', maxBodyLength: Infinity, - url: '/api/networks/{networkId}', - headers: { + url: 'https://api.netbird.io/api/networks/{networkId}', + headers: { 'Authorization': 'Token ' - } + } }; axios(config) @@ -967,16 +959,14 @@ axios(config) ```python import requests -import json url = "https://api.netbird.io/api/networks/{networkId}" -headers = { +headers = { 'Authorization': 'Token ' } response = requests.request("DELETE", url, headers=headers) - print(response.text) ``` @@ -985,25 +975,21 @@ package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/networks/{networkId}" method := "DELETE" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return - { - + } + req.Header.Add("Authorization", "Token ") res, err := client.Do(req) @@ -1024,7 +1010,6 @@ func main() { ```ruby require "uri" -require "json" require "net/http" url = URI("https://api.netbird.io/api/networks/{networkId}") @@ -1040,14 +1025,14 @@ puts response.read_body ``` ```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); +OkHttpClient client = new OkHttpClient().newBuilder().build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/networks/{networkId}") - .method("DELETE") - .addHeader("Authorization: Token ") + .method("DELETE", null) + .addHeader("Authorization", "Token ") .build(); + Response response = client.newCall(request).execute(); ``` @@ -1064,58 +1049,59 @@ curl_setopt_array($curl, array( CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'DELETE', - CURLOPT_HTTPHEADER => array( + CURLOPT_CUSTOMREQUEST => 'DELETE', + CURLOPT_HTTPHEADER => array( 'Authorization: Token ' ), )); $response = curl_exec($curl); - curl_close($curl); echo $response; ``` + + + - - - - - --- -## List all Network Resources {{ tag: 'GET' , label: '/api/networks/{networkId}/resources' }} + +## List all Network Resources {{ tag: 'GET', label: '/api/networks/{networkId}/resources' }} + - - Returns a list of all resources in a network - - ### Path Parameters - - - - The unique identifier of a network - - - - - - + +Returns a list of all resources in a network + +### Path Parameters + + + + +The unique identifier of a network + + + + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/networks/{networkId}/resources \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/networks/{networkId}/resources', + url: 'https://api.netbird.io/api/networks/{networkId}/resources', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -1131,7 +1117,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -1147,30 +1133,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/networks/{networkId}/resources" method := "GET" - client := &http.Client { - } + 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 ") @@ -1190,7 +1173,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -1208,20 +1191,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/networks/{networkId}/resources") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} [ { @@ -1272,6 +1252,7 @@ echo $response; } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -1293,63 +1274,59 @@ echo $response; } ] ``` - - - - + + + + --- -## Create a Network Resource {{ tag: 'POST' , label: '/api/networks/{networkId}/resources' }} + +## Create a Network Resource {{ tag: 'POST', label: '/api/networks/{networkId}/resources' }} + - - Creates a Network Resource - - ### Path Parameters - - - - The unique identifier of a network - - - - ### Request-Body Parameters - - - - Network resource name - - - - - Network resource description - - - - - Network resource address (either a direct host like 1.1.1.1 or 1.1.1.1/32, or a subnet like 192.168.178.0/24, or domains like example.com and *.example.com) - - - - - Network resource status - - - - - Group IDs containing the resource - - - - - - - - - + +Creates a Network Resource + +### Path Parameters + + + + +The unique identifier of a network + + + + + +### Request-Body Parameters + + + + +Network resource name + + +Network resource description + + +Network resource address (either a direct host like 1.1.1.1 or 1.1.1.1/32, or a subnet like 192.168.178.0/24, or domains like example.com and *.example.com) + + +Network resource status + + +Group IDs containing the resource + + + + + + + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/networks/{networkId}/resources \ -H 'Accept: application/json' \ @@ -1366,7 +1343,7 @@ curl -X POST https://api.netbird.io/api/networks/{networkId}/resources \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "name": "Remote Resource 1", @@ -1380,7 +1357,7 @@ let data = JSON.stringify({ let config = { method: 'post', maxBodyLength: Infinity, - url: '/api/networks/{networkId}/resources', + url: 'https://api.netbird.io/api/networks/{networkId}/resources', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -1398,7 +1375,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -1423,7 +1400,7 @@ response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -1447,14 +1424,13 @@ func main() { "chacdk86lnnboviihd70" ] }`) - client := &http.Client { - } + 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") @@ -1467,16 +1443,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -1504,30 +1480,30 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "name": "Remote Resource 1", - "description": "A remote resource inside network 1", - "address": "1.1.1.1", - "enabled": true, - "groups": [ - "chacdk86lnnboviihd70" +RequestBody body = RequestBody.create(mediaType, "{ + \"name\": \"Remote Resource 1\", + \"description\": \"A remote resource inside network 1\", + \"address\": \"1.1.1.1\", + \"enabled\": true, + \"groups\": [ + \"chacdk86lnnboviihd70\" ] -}'); +}"); Request request = new Request.Builder() .url("https://api.netbird.io/api/networks/{networkId}/resources") .method("POST", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "chacdk86lnnboviihd7g", @@ -1586,6 +1559,7 @@ echo $response; "enabled": true } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -1605,49 +1579,52 @@ echo $response; "enabled": "boolean" } ``` - - - - + + + + --- -## Retrieve a Network Resource {{ tag: 'GET' , label: '/api/networks/{networkId}/resources/{resourceId}' }} + +## Retrieve a Network Resource {{ tag: 'GET', label: '/api/networks/{networkId}/resources/{resourceId}' }} + - - Get information about a Network Resource - - ### Path Parameters - - - - The unique identifier of a network - - - - The unique identifier of a network resource - - - - - - + +Get information about a Network Resource + +### Path Parameters + + + + +The unique identifier of a network + + +The unique identifier of a network resource + + + + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/networks/{networkId}/resources/{resourceId} \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/networks/{networkId}/resources/{resourceId}', + url: 'https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -1663,7 +1640,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -1679,30 +1656,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}" method := "GET" - client := &http.Client { - } + 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 ") @@ -1722,7 +1696,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -1740,20 +1714,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "chacdk86lnnboviihd7g", @@ -1802,6 +1773,7 @@ echo $response; "enabled": true } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -1821,67 +1793,62 @@ echo $response; "enabled": "boolean" } ``` - - - - + + + + --- -## Update a Network Resource {{ tag: 'PUT' , label: '/api/networks/{networkId}/resources/{resourceId}' }} + +## Update a Network Resource {{ tag: 'PUT', label: '/api/networks/{networkId}/resources/{resourceId}' }} + - - Update a Network Resource - - ### Path Parameters - - - - The unique identifier of a network - - - - The unique identifier of a resource - - - - ### Request-Body Parameters - - - - Network resource name - - - - - Network resource description - - - - - Network resource address (either a direct host like 1.1.1.1 or 1.1.1.1/32, or a subnet like 192.168.178.0/24, or domains like example.com and *.example.com) - - - - - Network resource status - - - - - Group IDs containing the resource - - - - - - - - - + +Update a Network Resource + +### Path Parameters + + + + +The unique identifier of a network + + +The unique identifier of a resource + + + + + +### Request-Body Parameters + + + + +Network resource name + + +Network resource description + + +Network resource address (either a direct host like 1.1.1.1 or 1.1.1.1/32, or a subnet like 192.168.178.0/24, or domains like example.com and *.example.com) + + +Network resource status + + +Group IDs containing the resource + + + + + + + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/networks/{networkId}/resources/{resourceId} \ -H 'Accept: application/json' \ @@ -1898,7 +1865,7 @@ curl -X PUT https://api.netbird.io/api/networks/{networkId}/resources/{resourceI }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "name": "Remote Resource 1", @@ -1912,7 +1879,7 @@ let data = JSON.stringify({ let config = { method: 'put', maxBodyLength: Infinity, - url: '/api/networks/{networkId}/resources/{resourceId}', + url: 'https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -1930,7 +1897,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -1955,7 +1922,7 @@ response = requests.request("PUT", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -1970,7 +1937,7 @@ func main() { url := "https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}" method := "PUT" - payload := strings.NewReader(`{ + payload := strings.NewReader({ "name": "Remote Resource 1", "description": "A remote resource inside network 1", "address": "1.1.1.1", @@ -1978,15 +1945,14 @@ func main() { "groups": [ "chacdk86lnnboviihd70" ] -}`) - client := &http.Client { - } +}) + 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") @@ -1999,16 +1965,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -2036,7 +2002,7 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); @@ -2054,12 +2020,12 @@ Request request = new Request.Builder() .method("PUT", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "chacdk86lnnboviihd7g", @@ -2118,6 +2081,7 @@ echo $response; "enabled": true } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -2137,39 +2101,42 @@ echo $response; "enabled": "boolean" } ``` - - - - + + + + --- -## Delete a Network Resource {{ tag: 'DELETE' , label: '/api/networks/{networkId}/resources/{resourceId}' }} + +## Delete a Network Resource {{ tag: 'DELETE', label: '/api/networks/{networkId}/resources/{resourceId}' }} + - - Delete a network resource - - ### Path Parameters - - - - - - - - - - - - - - + +Delete a network resource + +### Path Parameters + + + + + + + + + + + + + + + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/networks/{networkId}/resources/{resourceId} \ --H 'Authorization: Token ' +-H 'Authorization: Token ' ``` ```js @@ -2178,10 +2145,10 @@ const axios = require('axios'); let config = { method: 'delete', maxBodyLength: Infinity, - url: '/api/networks/{networkId}/resources/{resourceId}', - headers: { + url: 'https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}', + headers: { 'Authorization': 'Token ' - } + } }; axios(config) @@ -2195,16 +2162,14 @@ axios(config) ```python import requests -import json url = "https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}" -headers = { +headers = { 'Authorization': 'Token ' } response = requests.request("DELETE", url, headers=headers) - print(response.text) ``` @@ -2213,25 +2178,21 @@ package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}" method := "DELETE" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return - { - + } + req.Header.Add("Authorization", "Token ") res, err := client.Do(req) @@ -2252,7 +2213,6 @@ func main() { ```ruby require "uri" -require "json" require "net/http" url = URI("https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}") @@ -2268,14 +2228,14 @@ puts response.read_body ``` ```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); +OkHttpClient client = new OkHttpClient().newBuilder().build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}") - .method("DELETE") - .addHeader("Authorization: Token ") + .method("DELETE", null) + .addHeader("Authorization", "Token ") .build(); + Response response = client.newCall(request).execute(); ``` @@ -2292,58 +2252,59 @@ curl_setopt_array($curl, array( CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'DELETE', - CURLOPT_HTTPHEADER => array( + CURLOPT_CUSTOMREQUEST => 'DELETE', + CURLOPT_HTTPHEADER => array( 'Authorization: Token ' ), )); $response = curl_exec($curl); - curl_close($curl); echo $response; ``` + + + - - - - - --- -## List all Network Routers {{ tag: 'GET' , label: '/api/networks/{networkId}/routers' }} + +## List all Network Routers {{ tag: 'GET', label: '/api/networks/{networkId}/routers' }} + - - Returns a list of all routers in a network - - ### Path Parameters - - - - The unique identifier of a network - - - - - - + +Returns a list of all routers in a network + +### Path Parameters + + + + +The unique identifier of a network + + + + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/networks/{networkId}/routers \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/networks/{networkId}/routers', + url: 'https://api.netbird.io/api/networks/{networkId}/routers', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -2359,7 +2320,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -2375,30 +2336,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/networks/{networkId}/routers" method := "GET" - client := &http.Client { - } + 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 ") @@ -2418,7 +2376,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -2436,20 +2394,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/networks/{networkId}/routers") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} [ { @@ -2493,6 +2448,7 @@ echo $response; } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -2507,63 +2463,59 @@ echo $response; } ] ``` - - - - + + + + --- -## Create a Network Router {{ tag: 'POST' , label: '/api/networks/{networkId}/routers' }} + +## Create a Network Router {{ tag: 'POST', label: '/api/networks/{networkId}/routers' }} + - - Creates a Network Router - - ### Path Parameters - - - - The unique identifier of a network - - - - ### Request-Body Parameters - - - - Peer Identifier associated with route. This property can not be set together with `peer_groups` - - - - - Peers Group Identifier associated with route. This property can not be set together with `peer` - - - - - Route metric number. Lowest number has higher priority - - - - - Indicate if peer should masquerade traffic to this route's prefix - - - - - Network router status - - - - - - - - - + +Creates a Network Router + +### Path Parameters + + + + +The unique identifier of a network + + + + + +### Request-Body Parameters + + + + +Peer Identifier associated with route. This property can not be set together with `peer_groups` + + +Peers Group Identifier associated with route. This property can not be set together with `peer` + + +Route metric number. Lowest number has higher priority + + +Indicate if peer should masquerade traffic to this route's prefix + + +Network router status + + + + + + + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/networks/{networkId}/routers \ -H 'Accept: application/json' \ @@ -2580,7 +2532,7 @@ curl -X POST https://api.netbird.io/api/networks/{networkId}/routers \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "peer": "chacbco6lnnbn6cg5s91", @@ -2594,7 +2546,7 @@ let data = JSON.stringify({ let config = { method: 'post', maxBodyLength: Infinity, - url: '/api/networks/{networkId}/routers', + url: 'https://api.netbird.io/api/networks/{networkId}/routers', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -2612,7 +2564,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -2637,7 +2589,7 @@ response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -2661,14 +2613,13 @@ func main() { "masquerade": true, "enabled": true }`) - client := &http.Client { - } + 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") @@ -2681,16 +2632,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -2718,30 +2669,30 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" +RequestBody body = RequestBody.create(mediaType, "{ + \"peer\": \"chacbco6lnnbn6cg5s91\", + \"peer_groups\": [ + \"chacbco6lnnbn6cg5s91\" ], - "metric": 9999, - "masquerade": true, - "enabled": true -}'); + \"metric\": 9999, + \"masquerade\": true, + \"enabled\": true +}"); Request request = new Request.Builder() .url("https://api.netbird.io/api/networks/{networkId}/routers") .method("POST", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "chacdk86lnnboviihd7g", @@ -2793,6 +2741,7 @@ echo $response; "enabled": true } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -2805,49 +2754,52 @@ echo $response; "enabled": "boolean" } ``` - - - - + + + + --- -## Retrieve a Network Router {{ tag: 'GET' , label: '/api/networks/{networkId}/routers/{routerId}' }} + +## Retrieve a Network Router {{ tag: 'GET', label: '/api/networks/{networkId}/routers/{routerId}' }} + - - Get information about a Network Router - - ### Path Parameters - - - - The unique identifier of a network - - - - The unique identifier of a router - - - - - - + +Get information about a Network Router + +### Path Parameters + + + + +The unique identifier of a network + + +The unique identifier of a router + + + + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/networks/{networkId}/routers/{routerId}', + url: 'https://api.netbird.io/api/networks/{networkId}/routers/{routerId}', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -2863,7 +2815,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -2879,30 +2831,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/networks/{networkId}/routers/{routerId}" method := "GET" - client := &http.Client { - } + 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 ") @@ -2922,7 +2871,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -2940,20 +2889,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/networks/{networkId}/routers/{routerId}") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "chacdk86lnnboviihd7g", @@ -2995,6 +2941,7 @@ echo $response; "enabled": true } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -3007,67 +2954,62 @@ echo $response; "enabled": "boolean" } ``` - - - - + + + + --- -## Update a Network Router {{ tag: 'PUT' , label: '/api/networks/{networkId}/routers/{routerId}' }} + +## Update a Network Router {{ tag: 'PUT', label: '/api/networks/{networkId}/routers/{routerId}' }} + - - Update a Network Router - - ### Path Parameters - - - - The unique identifier of a network - - - - The unique identifier of a router - - - - ### Request-Body Parameters - - - - Peer Identifier associated with route. This property can not be set together with `peer_groups` - - - - - Peers Group Identifier associated with route. This property can not be set together with `peer` - - - - - Route metric number. Lowest number has higher priority - - - - - Indicate if peer should masquerade traffic to this route's prefix - - - - - Network router status - - - - - - - - - + +Update a Network Router + +### Path Parameters + + + + +The unique identifier of a network + + +The unique identifier of a router + + + + + +### Request-Body Parameters + + + + +Peer Identifier associated with route. This property can not be set together with `peer_groups` + + +Peers Group Identifier associated with route. This property can not be set together with `peer` + + +Route metric number. Lowest number has higher priority + + +Indicate if peer should masquerade traffic to this route's prefix + + +Network router status + + + + + + + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ -H 'Accept: application/json' \ @@ -3084,7 +3026,7 @@ curl -X PUT https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "peer": "chacbco6lnnbn6cg5s91", @@ -3098,7 +3040,7 @@ let data = JSON.stringify({ let config = { method: 'put', maxBodyLength: Infinity, - url: '/api/networks/{networkId}/routers/{routerId}', + url: 'https://api.netbird.io/api/networks/{networkId}/routers/{routerId}', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -3116,7 +3058,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -3141,7 +3083,7 @@ response = requests.request("PUT", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -3156,7 +3098,7 @@ func main() { url := "https://api.netbird.io/api/networks/{networkId}/routers/{routerId}" method := "PUT" - payload := strings.NewReader(`{ + payload := strings.NewReader({ "peer": "chacbco6lnnbn6cg5s91", "peer_groups": [ "chacbco6lnnbn6cg5s91" @@ -3164,15 +3106,14 @@ func main() { "metric": 9999, "masquerade": true, "enabled": true -}`) - client := &http.Client { - } +}) + 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") @@ -3185,16 +3126,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -3222,7 +3163,7 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); @@ -3240,12 +3181,12 @@ Request request = new Request.Builder() .method("PUT", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "chacdk86lnnboviihd7g", @@ -3297,6 +3235,7 @@ echo $response; "enabled": true } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -3309,39 +3248,42 @@ echo $response; "enabled": "boolean" } ``` - - - - + + + + --- -## Delete a Network Router {{ tag: 'DELETE' , label: '/api/networks/{networkId}/routers/{routerId}' }} + +## Delete a Network Router {{ tag: 'DELETE', label: '/api/networks/{networkId}/routers/{routerId}' }} + - - Delete a network router - - ### Path Parameters - - - - - - - - - - - - - - + +Delete a network router + +### Path Parameters + + + + + + + + + + + + + + + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ --H 'Authorization: Token ' +-H 'Authorization: Token ' ``` ```js @@ -3350,10 +3292,10 @@ const axios = require('axios'); let config = { method: 'delete', maxBodyLength: Infinity, - url: '/api/networks/{networkId}/routers/{routerId}', - headers: { + url: 'https://api.netbird.io/api/networks/{networkId}/routers/{routerId}', + headers: { 'Authorization': 'Token ' - } + } }; axios(config) @@ -3367,16 +3309,14 @@ axios(config) ```python import requests -import json url = "https://api.netbird.io/api/networks/{networkId}/routers/{routerId}" -headers = { +headers = { 'Authorization': 'Token ' } response = requests.request("DELETE", url, headers=headers) - print(response.text) ``` @@ -3385,25 +3325,21 @@ package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/networks/{networkId}/routers/{routerId}" method := "DELETE" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return - { - + } + req.Header.Add("Authorization", "Token ") res, err := client.Do(req) @@ -3424,7 +3360,6 @@ func main() { ```ruby require "uri" -require "json" require "net/http" url = URI("https://api.netbird.io/api/networks/{networkId}/routers/{routerId}") @@ -3440,14 +3375,14 @@ puts response.read_body ``` ```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); +OkHttpClient client = new OkHttpClient().newBuilder().build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/networks/{networkId}/routers/{routerId}") - .method("DELETE") - .addHeader("Authorization: Token ") + .method("DELETE", null) + .addHeader("Authorization", "Token ") .build(); + Response response = client.newCall(request).execute(); ``` @@ -3464,50 +3399,48 @@ curl_setopt_array($curl, array( CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'DELETE', - CURLOPT_HTTPHEADER => array( + CURLOPT_CUSTOMREQUEST => 'DELETE', + CURLOPT_HTTPHEADER => array( 'Authorization: Token ' ), )); $response = curl_exec($curl); - curl_close($curl); echo $response; ``` + + + - - - - - --- -## List all Network Routers {{ tag: 'GET' , label: '/api/networks/routers' }} - - - Returns a list of all routers in a network - +## List all Network Routers {{ tag: 'GET', label: '/api/networks/routers' }} + - - + + +Returns a list of all routers in a network + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/networks/routers \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/networks/routers', + url: 'https://api.netbird.io/api/networks/routers', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -3523,7 +3456,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -3539,30 +3472,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/networks/routers" method := "GET" - client := &http.Client { - } + 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 ") @@ -3582,7 +3512,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -3600,20 +3530,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/networks/routers") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} [ { @@ -3657,6 +3584,7 @@ echo $response; } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -3671,10 +3599,10 @@ echo $response; } ] ``` - - - - + + + + --- diff --git a/src/pages/ipa/resources/peers.mdx b/src/pages/ipa/resources/peers.mdx index 5c0f98f7..bb12e57c 100644 --- a/src/pages/ipa/resources/peers.mdx +++ b/src/pages/ipa/resources/peers.mdx @@ -1,41 +1,42 @@ export const title = 'Peers' +## List all Peers {{ tag: 'GET', label: '/api/peers' }} -## List all Peers {{ tag: 'GET' , label: '/api/peers' }} - - Returns a list of all peers - - ### Query Parameters - - - - Filter peers by name - - - - Filter peers by IP address - - - - - - + +Returns a list of all peers + +### Query Parameters + + + + +Filter peers by name + + +Filter peers by IP address + + + + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/peers \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/peers', + url: 'https://api.netbird.io/api/peers', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -51,7 +52,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -67,30 +68,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/peers" method := "GET" - client := &http.Client { - } + 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 ") @@ -110,7 +108,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -128,20 +126,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/peers") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} [ { "id": "chacbco6lnnbn6cg5s90", "name": "stage-host-1", + "created_at": "2023-05-05T09:00:35.477782Z", "ip": "10.64.0.1", "connection_ip": "35.64.0.1", "connected": true, @@ -214,11 +210,13 @@ echo $response; } ] ``` + ```json {{ title: 'Schema' }} [ { "id": "string", "name": "string", + "created_at": "string", "ip": "string", "connection_ip": "string", "connected": "boolean", @@ -257,45 +255,49 @@ echo $response; } ] ``` - - - - + + + + --- -## Retrieve a Peer {{ tag: 'GET' , label: '/api/peers/{peerId}' }} + +## Retrieve a Peer {{ tag: 'GET', label: '/api/peers/{peerId}' }} + - - Get information about a peer - - ### Path Parameters - - - - The unique identifier of a peer - - - - - - + +Get information about a peer + +### Path Parameters + + + + +The unique identifier of a peer + + + + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/peers/{peerId} \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/peers/{peerId}', + url: 'https://api.netbird.io/api/peers/{peerId}', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -311,7 +313,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -327,30 +329,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/peers/{peerId}" method := "GET" - client := &http.Client { - } + 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 ") @@ -370,7 +369,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -388,20 +387,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/peers/{peerId}") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "chacbco6lnnbn6cg5s90", "name": "stage-host-1", + "created_at": "2023-05-05T09:00:35.477782Z", "ip": "10.64.0.1", "connection_ip": "35.64.0.1", "connected": true, @@ -471,10 +468,12 @@ echo $response; "ephemeral": false } ``` + ```json {{ title: 'Schema' }} { "id": "string", "name": "string", + "created_at": "string", "ip": "string", "connection_ip": "string", "connected": "boolean", @@ -511,68 +510,62 @@ echo $response; "ephemeral": "boolean" } ``` - - - - + + + + --- -## Update a Peer {{ tag: 'PUT' , label: '/api/peers/{peerId}' }} + +## Update a Peer {{ tag: 'PUT', label: '/api/peers/{peerId}' }} + - - Update information about a peer - - ### Path Parameters - - - - The unique identifier of a peer - - - - ### Request-Body Parameters - - - - - - - - - - - - - - - - - - - - - - - - (Cloud only) Indicates whether peer needs approval - - - - - Peer's IP address - - - - - - - - - + +Update information about a peer + +### Path Parameters + + + + +The unique identifier of a peer + + + + + +### Request-Body Parameters + + + + + + + + + + + + + + + + +(Cloud only) Indicates whether peer needs approval + + +Peer's IP address + + + + + + + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/peers/{peerId} \ -H 'Accept: application/json' \ @@ -588,7 +581,7 @@ curl -X PUT https://api.netbird.io/api/peers/{peerId} \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "name": "stage-host-1", @@ -601,7 +594,7 @@ let data = JSON.stringify({ let config = { method: 'put', maxBodyLength: Infinity, - url: '/api/peers/{peerId}', + url: 'https://api.netbird.io/api/peers/{peerId}', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -619,7 +612,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -643,7 +636,7 @@ response = requests.request("PUT", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -658,22 +651,21 @@ func main() { url := "https://api.netbird.io/api/peers/{peerId}" method := "PUT" - payload := strings.NewReader(`{ + payload := strings.NewReader({ "name": "stage-host-1", "ssh_enabled": true, "login_expiration_enabled": false, "inactivity_expiration_enabled": false, "approval_required": true, "ip": "100.64.0.15" -}`) - client := &http.Client { - } +}) + 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") @@ -686,16 +678,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -722,7 +714,7 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); @@ -739,12 +731,12 @@ Request request = new Request.Builder() .method("PUT", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "chacbco6lnnbn6cg5s90", "name": "stage-host-1", + "created_at": "2023-05-05T09:00:35.477782Z", "ip": "10.64.0.1", "connection_ip": "35.64.0.1", "connected": true, @@ -823,10 +813,12 @@ echo $response; "ephemeral": false } ``` + ```json {{ title: 'Schema' }} { "id": "string", "name": "string", + "created_at": "string", "ip": "string", "connection_ip": "string", "connected": "boolean", @@ -863,35 +855,39 @@ echo $response; "ephemeral": "boolean" } ``` - - - - + + + + --- -## Delete a Peer {{ tag: 'DELETE' , label: '/api/peers/{peerId}' }} + +## Delete a Peer {{ tag: 'DELETE', label: '/api/peers/{peerId}' }} + - - Delete a peer - - ### Path Parameters - - - - The unique identifier of a peer - - - - - - + +Delete a peer + +### Path Parameters + + + + +The unique identifier of a peer + + + + + + + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/peers/{peerId} \ --H 'Authorization: Token ' +-H 'Authorization: Token ' ``` ```js @@ -900,10 +896,10 @@ const axios = require('axios'); let config = { method: 'delete', maxBodyLength: Infinity, - url: '/api/peers/{peerId}', - headers: { + url: 'https://api.netbird.io/api/peers/{peerId}', + headers: { 'Authorization': 'Token ' - } + } }; axios(config) @@ -917,16 +913,14 @@ axios(config) ```python import requests -import json url = "https://api.netbird.io/api/peers/{peerId}" -headers = { +headers = { 'Authorization': 'Token ' } response = requests.request("DELETE", url, headers=headers) - print(response.text) ``` @@ -935,25 +929,21 @@ package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/peers/{peerId}" method := "DELETE" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return - { - + } + req.Header.Add("Authorization", "Token ") res, err := client.Do(req) @@ -974,7 +964,6 @@ func main() { ```ruby require "uri" -require "json" require "net/http" url = URI("https://api.netbird.io/api/peers/{peerId}") @@ -990,14 +979,14 @@ puts response.read_body ``` ```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); +OkHttpClient client = new OkHttpClient().newBuilder().build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/peers/{peerId}") - .method("DELETE") - .addHeader("Authorization: Token ") + .method("DELETE", null) + .addHeader("Authorization", "Token ") .build(); + Response response = client.newCall(request).execute(); ``` @@ -1014,58 +1003,59 @@ curl_setopt_array($curl, array( CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'DELETE', - CURLOPT_HTTPHEADER => array( + CURLOPT_CUSTOMREQUEST => 'DELETE', + CURLOPT_HTTPHEADER => array( 'Authorization: Token ' ), )); $response = curl_exec($curl); - curl_close($curl); echo $response; ``` + + + - - - - - --- -## List accessible Peers {{ tag: 'GET' , label: '/api/peers/{peerId}/accessible-peers' }} + +## 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 - - - - - - + +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 +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/peers/{peerId}/accessible-peers', + url: 'https://api.netbird.io/api/peers/{peerId}/accessible-peers', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -1081,7 +1071,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -1097,30 +1087,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: '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 { - } + 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 ") @@ -1140,7 +1127,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -1158,20 +1145,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/peers/{peerId}/accessible-peers") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} [ { @@ -1218,6 +1202,7 @@ echo $response; } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -1235,10 +1220,10 @@ echo $response; } ] ``` - - - - + + + + --- diff --git a/src/pages/ipa/resources/policies.mdx b/src/pages/ipa/resources/policies.mdx index 7ee56d83..8ebbdb5d 100644 --- a/src/pages/ipa/resources/policies.mdx +++ b/src/pages/ipa/resources/policies.mdx @@ -1,29 +1,28 @@ export const title = 'Policies' +## List all Policies {{ tag: 'GET', label: '/api/policies' }} -## List all Policies {{ tag: 'GET' , label: '/api/policies' }} - - Returns a list of all policies - - - - + +Returns a list of all policies + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/policies \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/policies', + url: 'https://api.netbird.io/api/policies', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -39,7 +38,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -55,30 +54,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/policies" method := "GET" - client := &http.Client { - } + 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 ") @@ -98,7 +94,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -116,20 +112,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/policies") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} [ { @@ -218,6 +211,7 @@ echo $response; } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -277,178 +271,137 @@ echo $response; } ] ``` - - - - + + + + --- -## Create a Policy {{ tag: 'POST' , label: '/api/policies' }} + +## Create a Policy {{ tag: 'POST', label: '/api/policies' }} + - - Creates a policy - - ### Request-Body Parameters - - - - Policy name identifier - - - - - Policy friendly description - - - - - Policy status - - - - - Posture checks ID's applied to policy source groups - - - - -
- Policy rule object for policy UI editor - - - - - Policy rule name identifier - - - - - Policy rule friendly description - - - - - Policy rule status - - - - - Policy rule accept or drops packets - - - - - Define if the rule is applicable in both directions, sources, and destinations. - - - - - Policy rule type of the traffic - - - - - Policy rule affected ports - - - - -
- Policy rule affected ports ranges list - - - - - The starting port of the range - - - - - The ending port of the range - - - - - -
- -
- - - Policy rule ID - - - - - Policy rule source group IDs - - - - -
- More Information - - - - - ID of the resource - - - - - Network resource type based of the address - - - - - -
- -
- - - Policy rule destination group IDs - - - - -
- More Information - - - - - ID of the resource - - - - - Network resource type based of the address - - - - - -
- -
-
- -
-
- -
-
- - - - - - + +Creates a policy + +### Request-Body Parameters + + + + +Policy name identifier + + +Policy friendly description + + +Policy status + + +Posture checks ID's applied to policy source groups + + +
+ +Policy rule object for policy UI editor + + +Policy rule name identifier + + +Policy rule friendly description + + +Policy rule status + + +Policy rule accept or drops packets + + +Define if the rule is applicable in both directions, sources, and destinations. + + +Policy rule type of the traffic + + +Policy rule affected ports + + +
+ +Policy rule affected ports ranges list + + +The starting port of the range + + +The ending port of the range + + + + +
+ +
+ +Policy rule ID + + +Policy rule source group IDs + + +
+ +More Information + + +ID of the resource + + +Network resource type based of the address + + + + +
+ +
+ +Policy rule destination group IDs + + +
+ +More Information + + +ID of the resource + + +Network resource type based of the address + + + + +
+ +
+ +
+ +
+ +
+ +
+ + + + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/policies \ -H 'Accept: application/json' \ @@ -498,7 +451,7 @@ curl -X POST https://api.netbird.io/api/policies \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "name": "ch8i4ug6lnn4g9hqv7mg", @@ -545,7 +498,7 @@ let data = JSON.stringify({ let config = { method: 'post', maxBodyLength: Infinity, - url: '/api/policies', + url: 'https://api.netbird.io/api/policies', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -563,7 +516,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -621,7 +574,7 @@ response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -678,14 +631,13 @@ func main() { } ] }`) - client := &http.Client { - } + 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") @@ -698,16 +650,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -768,63 +720,63 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "name": "ch8i4ug6lnn4g9hqv7mg", - "description": "This is a default policy that allows connections between all the resources", - "enabled": true, - "source_posture_checks": [ - "chacdk86lnnboviihd70" +RequestBody body = RequestBody.create(mediaType, "{ + \"name\": \"ch8i4ug6lnn4g9hqv7mg\", + \"description\": \"This is a default policy that allows connections between all the resources\", + \"enabled\": true, + \"source_posture_checks\": [ + \"chacdk86lnnboviihd70\" ], - "rules": [ + \"rules\": [ { - "name": "Default", - "description": "This is a default rule that allows connections between all the resources", - "enabled": true, - "action": "accept", - "bidirectional": true, - "protocol": "tcp", - "ports": [ - "80" - ], - "port_ranges": [ + \"name\": \"Default\", + \"description\": \"This is a default rule that allows connections between all the resources\", + \"enabled\": true, + \"action\": \"accept\", + \"bidirectional\": true, + \"protocol\": \"tcp\", + \"ports\": [ + \"80\" + ], + \"port_ranges\": [ { - "start": 80, - "end": 320 + \"start\": 80, + \"end\": 320 } ], - "id": "ch8i4ug6lnn4g9hqv7mg", - "sources": [ - "ch8i4ug6lnn4g9hqv797" + \"id\": \"ch8i4ug6lnn4g9hqv7mg\", + \"sources\": [ + \"ch8i4ug6lnn4g9hqv797\" ], - "sourceResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" + \"sourceResource\": { + \"id\": \"chacdk86lnnboviihd7g\", + \"type\": \"host\" }, - "destinations": [ - "ch8i4ug6lnn4g9h7v7m0" + \"destinations\": [ + \"ch8i4ug6lnn4g9h7v7m0\" ], - "destinationResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" + \"destinationResource\": { + \"id\": \"chacdk86lnnboviihd7g\", + \"type\": \"host\" } } ] -}'); +}"); Request request = new Request.Builder() .url("https://api.netbird.io/api/policies") .method("POST", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "name": "ch8i4ug6lnn4g9hqv7mg", @@ -954,6 +903,7 @@ echo $response; ] } ``` + ```json {{ title: 'Schema' }} { "name": "string", @@ -1011,45 +961,49 @@ echo $response; ] } ``` - - - - + + + +
--- -## Retrieve a Policy {{ tag: 'GET' , label: '/api/policies/{policyId}' }} + +## Retrieve a Policy {{ tag: 'GET', label: '/api/policies/{policyId}' }} + - - Get information about a Policies - - ### Path Parameters - - - - The unique identifier of a policy - - - - - - + +Get information about a Policies + +### Path Parameters + + + + +The unique identifier of a policy + + + + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/policies/{policyId} \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/policies/{policyId}', + url: 'https://api.netbird.io/api/policies/{policyId}', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -1065,7 +1019,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -1081,30 +1035,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/policies/{policyId}" method := "GET" - client := &http.Client { - } + 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 ") @@ -1124,7 +1075,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -1142,20 +1093,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/policies/{policyId}") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "name": "ch8i4ug6lnn4g9hqv7mg", @@ -1242,6 +1190,7 @@ echo $response; ] } ``` + ```json {{ title: 'Schema' }} { "name": "string", @@ -1299,186 +1248,148 @@ echo $response; ] } ``` - - - - + + + + --- -## Update a Policy {{ tag: 'PUT' , label: '/api/policies/{policyId}' }} + +## Update a Policy {{ tag: 'PUT', label: '/api/policies/{policyId}' }} + - - Update/Replace a Policy - - ### Path Parameters - - - - The unique identifier of a policy - - - - ### Request-Body Parameters - - - - Policy name identifier - - - - - Policy friendly description - - - - - Policy status - - - - - Posture checks ID's applied to policy source groups - - - - -
- Policy rule object for policy UI editor - - - - - Policy rule name identifier - - - - - Policy rule friendly description - - - - - Policy rule status - - - - - Policy rule accept or drops packets - - - - - Define if the rule is applicable in both directions, sources, and destinations. - - - - - Policy rule type of the traffic - - - - - Policy rule affected ports - - - - -
- Policy rule affected ports ranges list - - - - - The starting port of the range - - - - - The ending port of the range - - - - - -
- -
- - - Policy rule ID - - - - - Policy rule source group IDs - - - - -
- More Information - - - - - ID of the resource - - - - - Network resource type based of the address - - - - - -
- -
- - - Policy rule destination group IDs - - - - -
- More Information - - - - - ID of the resource - - - - - Network resource type based of the address - - - - - -
- -
-
- -
-
- -
-
- - - - - - + +Update/Replace a Policy + +### Path Parameters + + + + +The unique identifier of a policy + + + + + +### Request-Body Parameters + + + + +Policy name identifier + + +Policy friendly description + + +Policy status + + +Posture checks ID's applied to policy source groups + + +
+ +Policy rule object for policy UI editor + + +Policy rule name identifier + + +Policy rule friendly description + + +Policy rule status + + +Policy rule accept or drops packets + + +Define if the rule is applicable in both directions, sources, and destinations. + + +Policy rule type of the traffic + + +Policy rule affected ports + + +
+ +Policy rule affected ports ranges list + + +The starting port of the range + + +The ending port of the range + + + + +
+ +
+ +Policy rule ID + + +Policy rule source group IDs + + +
+ +More Information + + +ID of the resource + + +Network resource type based of the address + + + + +
+ +
+ +Policy rule destination group IDs + + +
+ +More Information + + +ID of the resource + + +Network resource type based of the address + + + + +
+ +
+ +
+ +
+ +
+ +
+ + + + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/policies/{policyId} \ -H 'Accept: application/json' \ @@ -1528,7 +1439,7 @@ curl -X PUT https://api.netbird.io/api/policies/{policyId} \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "name": "ch8i4ug6lnn4g9hqv7mg", @@ -1575,7 +1486,7 @@ let data = JSON.stringify({ let config = { method: 'put', maxBodyLength: Infinity, - url: '/api/policies/{policyId}', + url: 'https://api.netbird.io/api/policies/{policyId}', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -1593,7 +1504,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -1651,7 +1562,7 @@ response = requests.request("PUT", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -1666,7 +1577,7 @@ func main() { url := "https://api.netbird.io/api/policies/{policyId}" method := "PUT" - payload := strings.NewReader(`{ + payload := strings.NewReader({ "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, @@ -1707,15 +1618,14 @@ func main() { } } ] -}`) - client := &http.Client { - } +}) + 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") @@ -1728,16 +1638,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -1798,7 +1708,7 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); @@ -1849,12 +1759,12 @@ Request request = new Request.Builder() .method("PUT", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "name": "ch8i4ug6lnn4g9hqv7mg", @@ -1984,6 +1891,7 @@ echo $response; ] } ``` + ```json {{ title: 'Schema' }} { "name": "string", @@ -2041,35 +1949,39 @@ echo $response; ] } ``` - - - - + + + +
--- -## Delete a Policy {{ tag: 'DELETE' , label: '/api/policies/{policyId}' }} + +## Delete a Policy {{ tag: 'DELETE', label: '/api/policies/{policyId}' }} + - - Delete a policy - - ### Path Parameters - - - - The unique identifier of a policy - - - - - - + +Delete a policy + +### Path Parameters + + + + +The unique identifier of a policy + + + + + + + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/policies/{policyId} \ --H 'Authorization: Token ' +-H 'Authorization: Token ' ``` ```js @@ -2078,10 +1990,10 @@ const axios = require('axios'); let config = { method: 'delete', maxBodyLength: Infinity, - url: '/api/policies/{policyId}', - headers: { + url: 'https://api.netbird.io/api/policies/{policyId}', + headers: { 'Authorization': 'Token ' - } + } }; axios(config) @@ -2095,16 +2007,14 @@ axios(config) ```python import requests -import json url = "https://api.netbird.io/api/policies/{policyId}" -headers = { +headers = { 'Authorization': 'Token ' } response = requests.request("DELETE", url, headers=headers) - print(response.text) ``` @@ -2113,25 +2023,21 @@ package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/policies/{policyId}" method := "DELETE" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return - { - + } + req.Header.Add("Authorization", "Token ") res, err := client.Do(req) @@ -2152,7 +2058,6 @@ func main() { ```ruby require "uri" -require "json" require "net/http" url = URI("https://api.netbird.io/api/policies/{policyId}") @@ -2168,14 +2073,14 @@ puts response.read_body ``` ```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); +OkHttpClient client = new OkHttpClient().newBuilder().build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/policies/{policyId}") - .method("DELETE") - .addHeader("Authorization: Token ") + .method("DELETE", null) + .addHeader("Authorization", "Token ") .build(); + Response response = client.newCall(request).execute(); ``` @@ -2192,23 +2097,20 @@ curl_setopt_array($curl, array( CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'DELETE', - CURLOPT_HTTPHEADER => array( + CURLOPT_CUSTOMREQUEST => 'DELETE', + CURLOPT_HTTPHEADER => array( 'Authorization: Token ' ), )); $response = curl_exec($curl); - curl_close($curl); echo $response; ``` + + + - - - - - --- diff --git a/src/pages/ipa/resources/posture-checks.mdx b/src/pages/ipa/resources/posture-checks.mdx index 1b6a314a..249f03b0 100644 --- a/src/pages/ipa/resources/posture-checks.mdx +++ b/src/pages/ipa/resources/posture-checks.mdx @@ -1,29 +1,28 @@ export const title = 'Posture Checks' +## List all Posture Checks {{ tag: 'GET', label: '/api/posture-checks' }} -## List all Posture Checks {{ tag: 'GET' , label: '/api/posture-checks' }} - - Returns a list of all posture checks - - - - + +Returns a list of all posture checks + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/posture-checks \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/posture-checks', + url: 'https://api.netbird.io/api/posture-checks', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -39,7 +38,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -55,30 +54,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/posture-checks" method := "GET" - client := &http.Client { - } + 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 ") @@ -98,7 +94,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -116,20 +112,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/posture-checks") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} [ { @@ -216,6 +209,7 @@ echo $response; } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -228,19 +222,19 @@ echo $response; }, "os_version_check": { "android": { - "min_version": "13" - }, - "ios": { - "min_version": "17.3.1" + "min_version": "string" }, "darwin": { - "min_version": "14.2.1" + "min_version": "string" + }, + "ios": { + "min_version": "string" }, "linux": { - "min_kernel_version": "5.3.3" + "min_kernel_version": "string" }, "windows": { - "min_kernel_version": "10.0.1234" + "min_kernel_version": "string" } }, "geo_location_check": { @@ -271,266 +265,224 @@ echo $response; } ] ``` - - - - + + + + --- -## Create a Posture Check {{ tag: 'POST' , label: '/api/posture-checks' }} + +## Create a Posture Check {{ tag: 'POST', label: '/api/posture-checks' }} + - - Creates a posture check - - ### Request-Body Parameters - - - - Posture check name identifier - - - - - Posture check friendly description - - - - -
- List of objects that perform the actual checks - - - - -
- Posture check for the version of operating system - - - - - Minimum acceptable version - - - - - -
- -
- - -
- Posture check for the version of operating system - - - - -
- Posture check for the version of operating system - - - - - Minimum acceptable version - - - - - -
- -
- - -
- Posture check for the version of operating system - - - - - Minimum acceptable version - - - - - -
- -
- - -
- Posture check for the version of operating system - - - - - Minimum acceptable version - - - - - -
- -
- - -
- Posture check with the kernel version - - - - - Minimum acceptable version - - - - - -
- -
- - -
- Posture check with the kernel version - - - - - Minimum acceptable version - - - - - -
- -
-
- -
-
- -
- - -
- Posture check for geo location - - - - -
- List of geo locations to which the policy applies - - - - - 2-letter ISO 3166-1 alpha-2 code that represents the country - - - - - Commonly used English name of the city - - - - - -
- -
- - - Action to take upon policy match - - -
- -
-
- -
- - -
- Posture check for allow or deny access based on peer local network addresses - - - - - List of peer network ranges in CIDR notation - - - - - Action to take upon policy match - - - - - -
- -
- - -
- Posture Check for binaries exist and are running in the peer’s system - - - - -
- More Information - - - - - Path to the process executable file in a Linux operating system - - - - - Path to the process executable file in a Mac operating system - - - - - Path to the process executable file in a Windows operating system - - - - - -
- -
-
- -
-
- -
-
- -
-
- -
-
- - - - - - + +Creates a posture check + +### Request-Body Parameters + + + + +Posture check name identifier + + +Posture check friendly description + + +
+ +List of objects that perform the actual checks + + +
+ +Posture check for the version of operating system + + +Minimum acceptable version + + + + +
+ +
+ +
+ +Posture check for the version of operating system + + +
+ +Posture check for the version of operating system + + +Minimum acceptable version + + + + +
+ +
+ +
+ +Posture check for the version of operating system + + +Minimum acceptable version + + + + +
+ +
+ +
+ +Posture check for the version of operating system + + +Minimum acceptable version + + + + +
+ +
+ +
+ +Posture check with the kernel version + + +Minimum acceptable version + + + + +
+ +
+ +
+ +Posture check with the kernel version + + +Minimum acceptable version + + + + +
+ +
+ +
+ +
+ +
+ +
+ +Posture check for geo location + + +
+ +List of geo locations to which the policy applies + + +2-letter ISO 3166-1 alpha-2 code that represents the country + + +Commonly used English name of the city + + + + +
+ +
+ +Action to take upon policy match + + +
+ +
+ +
+ +
+ +Posture check for allow or deny access based on peer local network addresses + + +List of peer network ranges in CIDR notation + + +Action to take upon policy match + + + + +
+ +
+ +
+ +Posture Check for binaries exist and are running in the peer’s system + + +
+ +More Information + + +Path to the process executable file in a Linux operating system + + +Path to the process executable file in a Mac operating system + + +Path to the process executable file in a Windows operating system + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + + + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/posture-checks \ -H 'Accept: application/json' \ @@ -590,7 +542,7 @@ curl -X POST https://api.netbird.io/api/posture-checks \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "name": "Default", @@ -647,7 +599,7 @@ let data = JSON.stringify({ let config = { method: 'post', maxBodyLength: Infinity, - url: '/api/posture-checks', + url: 'https://api.netbird.io/api/posture-checks', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -665,7 +617,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -733,7 +685,7 @@ response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -800,14 +752,13 @@ func main() { } } }`) - client := &http.Client { - } + 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") @@ -820,16 +771,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -900,73 +851,73 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "name": "Default", - "description": "This checks if the peer is running required NetBird's version", - "checks": { - "nb_version_check": { - "min_version": "14.3" +RequestBody body = RequestBody.create(mediaType, "{ + \"name\": \"Default\", + \"description\": \"This checks if the peer is running required NetBird's version\", + \"checks\": { + \"nb_version_check\": { + \"min_version\": \"14.3\" }, - "os_version_check": { - "android": { - "min_version": "13" + \"os_version_check\": { + \"android\": { + \"min_version\": \"13\" }, - "ios": { - "min_version": "17.3.1" + \"ios\": { + \"min_version\": \"17.3.1\" }, - "darwin": { - "min_version": "14.2.1" + \"darwin\": { + \"min_version\": \"14.2.1\" }, - "linux": { - "min_kernel_version": "5.3.3" + \"linux\": { + \"min_kernel_version\": \"5.3.3\" }, - "windows": { - "min_kernel_version": "10.0.1234" + \"windows\": { + \"min_kernel_version\": \"10.0.1234\" } }, - "geo_location_check": { - "locations": [ + \"geo_location_check\": { + \"locations\": [ { - "country_code": "DE", - "city_name": "Berlin" + \"country_code\": \"DE\", + \"city_name\": \"Berlin\" } ], - "action": "allow" + \"action\": \"allow\" }, - "peer_network_range_check": { - "ranges": [ - "192.168.1.0/24", - "10.0.0.0/8", - "2001:db8:1234:1a00::/56" + \"peer_network_range_check\": { + \"ranges\": [ + \"192.168.1.0/24\", + \"10.0.0.0/8\", + \"2001:db8:1234:1a00::/56\" ], - "action": "allow" + \"action\": \"allow\" }, - "process_check": { - "processes": [ + \"process_check\": { + \"processes\": [ { - "linux_path": "/usr/local/bin/netbird", - "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", - "windows_path": "C:
rogramData…etBird\netbird.exe" + \"linux_path\": \"/usr/local/bin/netbird\", + \"mac_path\": \"/Applications/NetBird.app/Contents/MacOS/netbird\", + \"windows_path\": \"C:
rogramData…etBird\netbird.exe\" } ] } } -}'); +}"); Request request = new Request.Builder() .url("https://api.netbird.io/api/posture-checks") .method("POST", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -1104,6 +1052,7 @@ echo $response; } } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -1115,19 +1064,19 @@ echo $response; }, "os_version_check": { "android": { - "min_version": "13" - }, - "ios": { - "min_version": "17.3.1" + "min_version": "string" }, "darwin": { - "min_version": "14.2.1" + "min_version": "string" + }, + "ios": { + "min_version": "string" }, "linux": { - "min_kernel_version": "5.3.3" + "min_kernel_version": "string" }, "windows": { - "min_kernel_version": "10.0.1234" + "min_kernel_version": "string" } }, "geo_location_check": { @@ -1157,45 +1106,49 @@ echo $response; } } ``` - - - - + + + +
--- -## Retrieve a Posture Check {{ tag: 'GET' , label: '/api/posture-checks/{postureCheckId}' }} + +## Retrieve a Posture Check {{ tag: 'GET', label: '/api/posture-checks/{postureCheckId}' }} + - - Get information about a posture check - - ### Path Parameters - - - - The unique identifier of a posture check - - - - - - + +Get information about a posture check + +### Path Parameters + + + + +The unique identifier of a posture check + + + + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/posture-checks/{postureCheckId} \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/posture-checks/{postureCheckId}', + url: 'https://api.netbird.io/api/posture-checks/{postureCheckId}', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -1211,7 +1164,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -1227,30 +1180,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/posture-checks/{postureCheckId}" method := "GET" - client := &http.Client { - } + 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 ") @@ -1270,7 +1220,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -1288,20 +1238,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/posture-checks/{postureCheckId}") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -1386,6 +1333,7 @@ echo $response; } } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -1397,19 +1345,19 @@ echo $response; }, "os_version_check": { "android": { - "min_version": "13" - }, - "ios": { - "min_version": "17.3.1" + "min_version": "string" }, "darwin": { - "min_version": "14.2.1" + "min_version": "string" + }, + "ios": { + "min_version": "string" }, "linux": { - "min_kernel_version": "5.3.3" + "min_kernel_version": "string" }, "windows": { - "min_kernel_version": "10.0.1234" + "min_kernel_version": "string" } }, "geo_location_check": { @@ -1439,274 +1387,235 @@ echo $response; } } ``` - - - - + + + + --- -## Update a Posture Check {{ tag: 'PUT' , label: '/api/posture-checks/{postureCheckId}' }} + +## Update a Posture Check {{ tag: 'PUT', label: '/api/posture-checks/{postureCheckId}' }} + - - Update/Replace a posture check - - ### Path Parameters - - - - The unique identifier of a posture check - - - - ### Request-Body Parameters - - - - Posture check name identifier - - - - - Posture check friendly description - - - - -
- List of objects that perform the actual checks - - - - -
- Posture check for the version of operating system - - - - - Minimum acceptable version - - - - - -
- -
- - -
- Posture check for the version of operating system - - - - -
- Posture check for the version of operating system - - - - - Minimum acceptable version - - - - - -
- -
- - -
- Posture check for the version of operating system - - - - - Minimum acceptable version - - - - - -
- -
- - -
- Posture check for the version of operating system - - - - - Minimum acceptable version - - - - - -
- -
- - -
- Posture check with the kernel version - - - - - Minimum acceptable version - - - - - -
- -
- - -
- Posture check with the kernel version - - - - - Minimum acceptable version - - - - - -
- -
-
- -
-
- -
- - -
- Posture check for geo location - - - - -
- List of geo locations to which the policy applies - - - - - 2-letter ISO 3166-1 alpha-2 code that represents the country - - - - - Commonly used English name of the city - - - - - -
- -
- - - Action to take upon policy match - - -
- -
-
- -
- - -
- Posture check for allow or deny access based on peer local network addresses - - - - - List of peer network ranges in CIDR notation - - - - - Action to take upon policy match - - - - - -
- -
- - -
- Posture Check for binaries exist and are running in the peer’s system - - - - -
- More Information - - - - - Path to the process executable file in a Linux operating system - - - - - Path to the process executable file in a Mac operating system - - - - - Path to the process executable file in a Windows operating system - - - - - -
- -
-
- -
-
- -
-
- -
-
- -
-
- - - - - - + +Update/Replace a posture check + +### Path Parameters + + + + +The unique identifier of a posture check + + + + + +### Request-Body Parameters + + + + +Posture check name identifier + + +Posture check friendly description + + +
+ +List of objects that perform the actual checks + + +
+ +Posture check for the version of operating system + + +Minimum acceptable version + + + + +
+ +
+ +
+ +Posture check for the version of operating system + + +
+ +Posture check for the version of operating system + + +Minimum acceptable version + + + + +
+ +
+ +
+ +Posture check for the version of operating system + + +Minimum acceptable version + + + + +
+ +
+ +
+ +Posture check for the version of operating system + + +Minimum acceptable version + + + + +
+ +
+ +
+ +Posture check with the kernel version + + +Minimum acceptable version + + + + +
+ +
+ +
+ +Posture check with the kernel version + + +Minimum acceptable version + + + + +
+ +
+ +
+ +
+ +
+ +
+ +Posture check for geo location + + +
+ +List of geo locations to which the policy applies + + +2-letter ISO 3166-1 alpha-2 code that represents the country + + +Commonly used English name of the city + + + + +
+ +
+ +Action to take upon policy match + + +
+ +
+ +
+ +
+ +Posture check for allow or deny access based on peer local network addresses + + +List of peer network ranges in CIDR notation + + +Action to take upon policy match + + + + +
+ +
+ +
+ +Posture Check for binaries exist and are running in the peer’s system + + +
+ +More Information + + +Path to the process executable file in a Linux operating system + + +Path to the process executable file in a Mac operating system + + +Path to the process executable file in a Windows operating system + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + + + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/posture-checks/{postureCheckId} \ -H 'Accept: application/json' \ @@ -1766,7 +1675,7 @@ curl -X PUT https://api.netbird.io/api/posture-checks/{postureCheckId} \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "name": "Default", @@ -1823,7 +1732,7 @@ let data = JSON.stringify({ let config = { method: 'put', maxBodyLength: Infinity, - url: '/api/posture-checks/{postureCheckId}', + url: 'https://api.netbird.io/api/posture-checks/{postureCheckId}', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -1841,7 +1750,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -1909,7 +1818,7 @@ response = requests.request("PUT", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -1924,7 +1833,7 @@ func main() { url := "https://api.netbird.io/api/posture-checks/{postureCheckId}" method := "PUT" - payload := strings.NewReader(`{ + payload := strings.NewReader({ "name": "Default", "description": "This checks if the peer is running required NetBird's version", "checks": { @@ -1975,15 +1884,14 @@ func main() { ] } } -}`) - client := &http.Client { - } +}) + 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") @@ -1996,16 +1904,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -2076,7 +1984,7 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); @@ -2137,12 +2045,12 @@ Request request = new Request.Builder() .method("PUT", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -2280,6 +2185,7 @@ echo $response; } } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -2291,19 +2197,19 @@ echo $response; }, "os_version_check": { "android": { - "min_version": "13" - }, - "ios": { - "min_version": "17.3.1" + "min_version": "string" }, "darwin": { - "min_version": "14.2.1" + "min_version": "string" + }, + "ios": { + "min_version": "string" }, "linux": { - "min_kernel_version": "5.3.3" + "min_kernel_version": "string" }, "windows": { - "min_kernel_version": "10.0.1234" + "min_kernel_version": "string" } }, "geo_location_check": { @@ -2333,35 +2239,39 @@ echo $response; } } ``` - - - - + + + +
--- -## Delete a Posture Check {{ tag: 'DELETE' , label: '/api/posture-checks/{postureCheckId}' }} + +## Delete a Posture Check {{ tag: 'DELETE', label: '/api/posture-checks/{postureCheckId}' }} + - - Delete a posture check - - ### Path Parameters - - - - The unique identifier of a posture check - - - - - - + +Delete a posture check + +### Path Parameters + + + + +The unique identifier of a posture check + + + + + + + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/posture-checks/{postureCheckId} \ --H 'Authorization: Token ' +-H 'Authorization: Token ' ``` ```js @@ -2370,10 +2280,10 @@ const axios = require('axios'); let config = { method: 'delete', maxBodyLength: Infinity, - url: '/api/posture-checks/{postureCheckId}', - headers: { + url: 'https://api.netbird.io/api/posture-checks/{postureCheckId}', + headers: { 'Authorization': 'Token ' - } + } }; axios(config) @@ -2387,16 +2297,14 @@ axios(config) ```python import requests -import json url = "https://api.netbird.io/api/posture-checks/{postureCheckId}" -headers = { +headers = { 'Authorization': 'Token ' } response = requests.request("DELETE", url, headers=headers) - print(response.text) ``` @@ -2405,25 +2313,21 @@ package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/posture-checks/{postureCheckId}" method := "DELETE" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return - { - + } + req.Header.Add("Authorization", "Token ") res, err := client.Do(req) @@ -2444,7 +2348,6 @@ func main() { ```ruby require "uri" -require "json" require "net/http" url = URI("https://api.netbird.io/api/posture-checks/{postureCheckId}") @@ -2460,14 +2363,14 @@ puts response.read_body ``` ```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); +OkHttpClient client = new OkHttpClient().newBuilder().build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/posture-checks/{postureCheckId}") - .method("DELETE") - .addHeader("Authorization: Token ") + .method("DELETE", null) + .addHeader("Authorization", "Token ") .build(); + Response response = client.newCall(request).execute(); ``` @@ -2484,23 +2387,20 @@ curl_setopt_array($curl, array( CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'DELETE', - CURLOPT_HTTPHEADER => array( + CURLOPT_CUSTOMREQUEST => 'DELETE', + CURLOPT_HTTPHEADER => array( 'Authorization: Token ' ), )); $response = curl_exec($curl); - curl_close($curl); echo $response; ``` + + + - - - - - --- diff --git a/src/pages/ipa/resources/routes.mdx b/src/pages/ipa/resources/routes.mdx index 9dfeb45a..61b9e0da 100644 --- a/src/pages/ipa/resources/routes.mdx +++ b/src/pages/ipa/resources/routes.mdx @@ -1,29 +1,28 @@ export const title = 'Routes' +## List all Routes {{ tag: 'GET', label: '/api/routes' }} -## List all Routes {{ tag: 'GET' , label: '/api/routes' }} - - Returns a list of all routes - - - - + +Returns a list of all routes + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/routes \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/routes', + url: 'https://api.netbird.io/api/routes', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -39,7 +38,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -55,30 +54,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/routes" method := "GET" - client := &http.Client { - } + 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 ") @@ -98,7 +94,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -116,20 +112,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/routes") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} [ { @@ -183,10 +176,12 @@ echo $response; "keep_route": true, "access_control_groups": [ "chacbco6lnnbn6cg5s91" - ] + ], + "skip_auto_apply": false } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -211,94 +206,77 @@ echo $response; "keep_route": "boolean", "access_control_groups": [ "string" - ] + ], + "skip_auto_apply": "boolean" } ] ``` - - - - + + + + --- -## Create a Route {{ tag: 'POST' , label: '/api/routes' }} + +## Create a Route {{ tag: 'POST', label: '/api/routes' }} + - - Creates a Route - - ### Request-Body Parameters - - - - Route description - - - - - Route network identifier, to group HA routes - - - - - Route status - - - - - Peer Identifier associated with route. This property can not be set together with `peer_groups` - - - - - Peers Group Identifier associated with route. This property can not be set together with `peer` - - - - - Network range in CIDR format, Conflicts with domains - - - - - Domain list to be dynamically resolved. Max of 32 domains can be added per route configuration. Conflicts with network - - - - - Route metric number. Lowest number has higher priority - - - - - Indicate if peer should masquerade traffic to this route's prefix - - - - - Group IDs containing routing peers - - - - - Indicate if the route should be kept after a domain doesn't resolve that IP anymore - - - - - Access control group identifier associated with route. - - - - - - - - - + +Creates a Route + +### Request-Body Parameters + + + + +Route description + + +Route network identifier, to group HA routes + + +Route status + + +Peer Identifier associated with route. This property can not be set together with `peer_groups` + + +Peers Group Identifier associated with route. This property can not be set together with `peer` + + +Network range in CIDR format, Conflicts with domains + + +Domain list to be dynamically resolved. Max of 32 domains can be added per route configuration. Conflicts with network + + +Route metric number. Lowest number has higher priority + + +Indicate if peer should masquerade traffic to this route's prefix + + +Group IDs containing routing peers + + +Indicate if the route should be kept after a domain doesn't resolve that IP anymore + + +Access control group identifier associated with route. + + +Indicate if this exit node route (0.0.0.0/0) should skip auto-application for client routing + + + + + + + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/routes \ -H 'Accept: application/json' \ @@ -324,11 +302,12 @@ curl -X POST https://api.netbird.io/api/routes \ "keep_route": true, "access_control_groups": [ "chacbco6lnnbn6cg5s91" - ] + ], + "skip_auto_apply": false }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "description": "My first route", @@ -350,12 +329,13 @@ let data = JSON.stringify({ "keep_route": true, "access_control_groups": [ "chacbco6lnnbn6cg5s91" - ] + ], + "skip_auto_apply": false }); let config = { method: 'post', maxBodyLength: Infinity, - url: '/api/routes', + url: 'https://api.netbird.io/api/routes', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -373,7 +353,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -398,7 +378,8 @@ payload = json.dumps({ "keep_route": true, "access_control_groups": [ "chacbco6lnnbn6cg5s91" - ] + ], + "skip_auto_apply": false }) headers = { 'Content-Type': 'application/json', @@ -411,7 +392,7 @@ response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -446,16 +427,16 @@ func main() { "keep_route": true, "access_control_groups": [ "chacbco6lnnbn6cg5s91" - ] + ], + "skip_auto_apply": false }`) - client := &http.Client { - } + 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") @@ -468,16 +449,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -512,49 +493,51 @@ request.body = JSON.dump({ "keep_route": true, "access_control_groups": [ "chacbco6lnnbn6cg5s91" - ] + ], + "skip_auto_apply": false }) response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "description": "My first route", - "network_id": "Route 1", - "enabled": true, - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" +RequestBody body = RequestBody.create(mediaType, "{ + \"description\": \"My first route\", + \"network_id\": \"Route 1\", + \"enabled\": true, + \"peer\": \"chacbco6lnnbn6cg5s91\", + \"peer_groups\": [ + \"chacbco6lnnbn6cg5s91\" ], - "network": "10.64.0.0/24", - "domains": [ - "example.com" + \"network\": \"10.64.0.0/24\", + \"domains\": [ + \"example.com\" ], - "metric": 9999, - "masquerade": true, - "groups": [ - "chacdk86lnnboviihd70" + \"metric\": 9999, + \"masquerade\": true, + \"groups\": [ + \"chacdk86lnnboviihd70\" ], - "keep_route": true, - "access_control_groups": [ - "chacbco6lnnbn6cg5s91" - ] -}'); + \"keep_route\": true, + \"access_control_groups\": [ + \"chacbco6lnnbn6cg5s91\" + ], + \"skip_auto_apply\": false +}"); Request request = new Request.Builder() .url("https://api.netbird.io/api/routes") .method("POST", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} array( 'Content-Type: application/json', @@ -602,11 +586,8 @@ $response = curl_exec($curl); curl_close($curl); echo $response; ``` - - - - - + + ```json {{ title: 'Example' }} { "id": "chacdk86lnnboviihd7g", @@ -630,9 +611,11 @@ echo $response; "keep_route": true, "access_control_groups": [ "chacbco6lnnbn6cg5s91" - ] + ], + "skip_auto_apply": false } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -656,48 +639,53 @@ echo $response; "keep_route": "boolean", "access_control_groups": [ "string" - ] + ], + "skip_auto_apply": "boolean" } ``` - - - - + + + + --- -## Retrieve a Route {{ tag: 'GET' , label: '/api/routes/{routeId}' }} + +## Retrieve a Route {{ tag: 'GET', label: '/api/routes/{routeId}' }} + - - Get information about a Routes - - ### Path Parameters - - - - The unique identifier of a route - - - - - - + +Get information about a Routes + +### Path Parameters + + + + +The unique identifier of a route + + + + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/routes/{routeId} \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/routes/{routeId}', + url: 'https://api.netbird.io/api/routes/{routeId}', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -713,7 +701,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -729,30 +717,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/routes/{routeId}" method := "GET" - client := &http.Client { - } + 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 ") @@ -772,7 +757,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -790,20 +775,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/routes/{routeId}") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "chacdk86lnnboviihd7g", @@ -856,9 +838,11 @@ echo $response; "keep_route": true, "access_control_groups": [ "chacbco6lnnbn6cg5s91" - ] + ], + "skip_auto_apply": false } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -882,101 +866,87 @@ echo $response; "keep_route": "boolean", "access_control_groups": [ "string" - ] + ], + "skip_auto_apply": "boolean" } ``` - - - - + + + + --- -## Update a Route {{ tag: 'PUT' , label: '/api/routes/{routeId}' }} + +## Update a Route {{ tag: 'PUT', label: '/api/routes/{routeId}' }} + - - Update/Replace a Route - - ### Path Parameters - - - - The unique identifier of a route - - - - ### Request-Body Parameters - - - - Route description - - - - - Route network identifier, to group HA routes - - - - - Route status - - - - - Peer Identifier associated with route. This property can not be set together with `peer_groups` - - - - - Peers Group Identifier associated with route. This property can not be set together with `peer` - - - - - Network range in CIDR format, Conflicts with domains - - - - - Domain list to be dynamically resolved. Max of 32 domains can be added per route configuration. Conflicts with network - - - - - Route metric number. Lowest number has higher priority - - - - - Indicate if peer should masquerade traffic to this route's prefix - - - - - Group IDs containing routing peers - - - - - Indicate if the route should be kept after a domain doesn't resolve that IP anymore - - - - - Access control group identifier associated with route. - - - - - - - - - + +Update/Replace a Route + +### Path Parameters + + + + +The unique identifier of a route + + + + + +### Request-Body Parameters + + + + +Route description + + +Route network identifier, to group HA routes + + +Route status + + +Peer Identifier associated with route. This property can not be set together with `peer_groups` + + +Peers Group Identifier associated with route. This property can not be set together with `peer` + + +Network range in CIDR format, Conflicts with domains + + +Domain list to be dynamically resolved. Max of 32 domains can be added per route configuration. Conflicts with network + + +Route metric number. Lowest number has higher priority + + +Indicate if peer should masquerade traffic to this route's prefix + + +Group IDs containing routing peers + + +Indicate if the route should be kept after a domain doesn't resolve that IP anymore + + +Access control group identifier associated with route. + + +Indicate if this exit node route (0.0.0.0/0) should skip auto-application for client routing + + + + + + + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/routes/{routeId} \ -H 'Accept: application/json' \ @@ -1002,11 +972,12 @@ curl -X PUT https://api.netbird.io/api/routes/{routeId} \ "keep_route": true, "access_control_groups": [ "chacbco6lnnbn6cg5s91" - ] + ], + "skip_auto_apply": false }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "description": "My first route", @@ -1028,12 +999,13 @@ let data = JSON.stringify({ "keep_route": true, "access_control_groups": [ "chacbco6lnnbn6cg5s91" - ] + ], + "skip_auto_apply": false }); let config = { method: 'put', maxBodyLength: Infinity, - url: '/api/routes/{routeId}', + url: 'https://api.netbird.io/api/routes/{routeId}', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -1051,7 +1023,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -1076,7 +1048,8 @@ payload = json.dumps({ "keep_route": true, "access_control_groups": [ "chacbco6lnnbn6cg5s91" - ] + ], + "skip_auto_apply": false }) headers = { 'Content-Type': 'application/json', @@ -1089,7 +1062,7 @@ response = requests.request("PUT", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -1104,7 +1077,7 @@ func main() { url := "https://api.netbird.io/api/routes/{routeId}" method := "PUT" - payload := strings.NewReader(`{ + payload := strings.NewReader({ "description": "My first route", "network_id": "Route 1", "enabled": true, @@ -1124,16 +1097,16 @@ func main() { "keep_route": true, "access_control_groups": [ "chacbco6lnnbn6cg5s91" - ] -}`) - client := &http.Client { - } + ], + "skip_auto_apply": 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") @@ -1146,16 +1119,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -1190,13 +1163,14 @@ request.body = JSON.dump({ "keep_route": true, "access_control_groups": [ "chacbco6lnnbn6cg5s91" - ] + ], + "skip_auto_apply": false }) response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); @@ -1220,19 +1194,20 @@ RequestBody body = RequestBody.create(mediaType, '{ "keep_route": true, "access_control_groups": [ "chacbco6lnnbn6cg5s91" - ] + ], + "skip_auto_apply": false }'); Request request = new Request.Builder() .url("https://api.netbird.io/api/routes/{routeId}") .method("PUT", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} array( 'Content-Type: application/json', @@ -1280,11 +1256,8 @@ $response = curl_exec($curl); curl_close($curl); echo $response; ``` - - - - - + + ```json {{ title: 'Example' }} { "id": "chacdk86lnnboviihd7g", @@ -1308,9 +1281,11 @@ echo $response; "keep_route": true, "access_control_groups": [ "chacbco6lnnbn6cg5s91" - ] + ], + "skip_auto_apply": false } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -1334,38 +1309,43 @@ echo $response; "keep_route": "boolean", "access_control_groups": [ "string" - ] + ], + "skip_auto_apply": "boolean" } ``` - - - - + + + + --- -## Delete a Route {{ tag: 'DELETE' , label: '/api/routes/{routeId}' }} + +## Delete a Route {{ tag: 'DELETE', label: '/api/routes/{routeId}' }} + - - Delete a route - - ### Path Parameters - - - - The unique identifier of a route - - - - - - + +Delete a route + +### Path Parameters + + + + +The unique identifier of a route + + + + + + + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/routes/{routeId} \ --H 'Authorization: Token ' +-H 'Authorization: Token ' ``` ```js @@ -1374,10 +1354,10 @@ const axios = require('axios'); let config = { method: 'delete', maxBodyLength: Infinity, - url: '/api/routes/{routeId}', - headers: { + url: 'https://api.netbird.io/api/routes/{routeId}', + headers: { 'Authorization': 'Token ' - } + } }; axios(config) @@ -1391,16 +1371,14 @@ axios(config) ```python import requests -import json url = "https://api.netbird.io/api/routes/{routeId}" -headers = { +headers = { 'Authorization': 'Token ' } response = requests.request("DELETE", url, headers=headers) - print(response.text) ``` @@ -1409,25 +1387,21 @@ package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/routes/{routeId}" method := "DELETE" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return - { - + } + req.Header.Add("Authorization", "Token ") res, err := client.Do(req) @@ -1448,7 +1422,6 @@ func main() { ```ruby require "uri" -require "json" require "net/http" url = URI("https://api.netbird.io/api/routes/{routeId}") @@ -1464,14 +1437,14 @@ puts response.read_body ``` ```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); +OkHttpClient client = new OkHttpClient().newBuilder().build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/routes/{routeId}") - .method("DELETE") - .addHeader("Authorization: Token ") + .method("DELETE", null) + .addHeader("Authorization", "Token ") .build(); + Response response = client.newCall(request).execute(); ``` @@ -1488,23 +1461,20 @@ curl_setopt_array($curl, array( CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'DELETE', - CURLOPT_HTTPHEADER => array( + CURLOPT_CUSTOMREQUEST => 'DELETE', + CURLOPT_HTTPHEADER => array( 'Authorization: Token ' ), )); $response = curl_exec($curl); - curl_close($curl); echo $response; ``` + + + - - - - - --- diff --git a/src/pages/ipa/resources/setup-keys.mdx b/src/pages/ipa/resources/setup-keys.mdx index a8698eb8..84c71b93 100644 --- a/src/pages/ipa/resources/setup-keys.mdx +++ b/src/pages/ipa/resources/setup-keys.mdx @@ -1,29 +1,28 @@ export const title = 'Setup Keys' +## List all Setup Keys {{ tag: 'GET', label: '/api/setup-keys' }} -## List all Setup Keys {{ tag: 'GET' , label: '/api/setup-keys' }} - - Returns a list of all Setup Keys - - - - + +Returns a list of all Setup Keys + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/setup-keys \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/setup-keys', + url: 'https://api.netbird.io/api/setup-keys', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -39,7 +38,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -55,30 +54,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: '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 { - } + 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 ") @@ -98,7 +94,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -116,20 +112,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/setup-keys") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} [ { @@ -182,6 +175,7 @@ echo $response; } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -205,65 +199,54 @@ echo $response; } ] ``` - - - - + + + + --- -## Create a Setup Key {{ tag: 'POST' , label: '/api/setup-keys' }} + +## Create a Setup Key {{ tag: 'POST', label: '/api/setup-keys' }} + - - Creates a setup key - - ### Request-Body Parameters - - - - Setup Key name - - - - - Setup key type, one-off for single time usage and reusable - - - - - Expiration time in seconds - - - - - List of group IDs to auto-assign to peers registered with this key - - - - - A number of times this key can be used. The value of 0 indicates the unlimited usage. - - - - - Indicate that the peer will be ephemeral or not - - - - - Allow extra DNS labels to be added to the peer - - - - - - - - - + +Creates a setup key + +### Request-Body Parameters + + + + +Setup Key name + + +Setup key type, one-off for single time usage and reusable + + +Expiration time in seconds + + +List of group IDs to auto-assign to peers registered with this key + + +A number of times this key can be used. The value of 0 indicates the unlimited usage. + + +Indicate that the peer will be ephemeral or not + + +Allow extra DNS labels to be added to the peer + + + + + + + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/setup-keys \ -H 'Accept: application/json' \ @@ -282,7 +265,7 @@ curl -X POST https://api.netbird.io/api/setup-keys \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "name": "Default key", @@ -298,7 +281,7 @@ let data = JSON.stringify({ let config = { method: 'post', maxBodyLength: Infinity, - url: '/api/setup-keys', + url: 'https://api.netbird.io/api/setup-keys', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -316,7 +299,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -343,7 +326,7 @@ response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -369,14 +352,13 @@ func main() { "ephemeral": true, "allow_extra_dns_labels": true }`) - client := &http.Client { - } + 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") @@ -389,16 +371,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -428,32 +410,32 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: '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, - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" +RequestBody body = RequestBody.create(mediaType, "{ + \"name\": \"Default key\", + \"type\": \"reusable\", + \"expires_in\": 86400, + \"auto_groups\": [ + \"ch8i4ug6lnn4g9hqv7m0\" ], - "usage_limit": 0, - "ephemeral": true, - "allow_extra_dns_labels": true -}'); + \"usage_limit\": 0, + \"ephemeral\": true, + \"allow_extra_dns_labels\": 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 ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": 2531583362, @@ -516,6 +495,7 @@ echo $response; "key": "A616097E-FCF0-48FA-9354-CA4A61142761" } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -537,45 +517,49 @@ echo $response; "key": "string" } ``` - - - - + + + + --- -## Retrieve a Setup Key {{ tag: 'GET' , label: '/api/setup-keys/{keyId}' }} + +## Retrieve a Setup Key {{ tag: 'GET', label: '/api/setup-keys/{keyId}' }} + - - Get information about a setup key - - ### Path Parameters - - - - The unique identifier of a setup key - - - - - - + +Get information about a setup key + +### Path Parameters + + + + +The unique identifier of a setup key + + + + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/setup-keys/{keyId} \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/setup-keys/{keyId}', + url: 'https://api.netbird.io/api/setup-keys/{keyId}', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -591,7 +575,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -607,30 +591,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: '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 { - } + 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 ") @@ -650,7 +631,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -668,20 +649,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/setup-keys/{keyId}") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": 2531583362, @@ -732,6 +710,7 @@ echo $response; "key": "A6160****" } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -753,48 +732,50 @@ echo $response; "key": "string" } ``` - - - - + + + + --- -## Update a Setup Key {{ tag: 'PUT' , label: '/api/setup-keys/{keyId}' }} + +## Update a Setup Key {{ tag: 'PUT', label: '/api/setup-keys/{keyId}' }} + - - Update information about a setup key - - ### Path Parameters - - - - The unique identifier of a setup key - - - - ### Request-Body Parameters - - - - Setup key revocation status - - - - - List of group IDs to auto-assign to peers registered with this key - - - - - - - - - + +Update information about a setup key + +### Path Parameters + + + + +The unique identifier of a setup key + + + + + +### Request-Body Parameters + + + + +Setup key revocation status + + +List of group IDs to auto-assign to peers registered with this key + + + + + + + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/setup-keys/{keyId} \ -H 'Accept: application/json' \ @@ -808,7 +789,7 @@ curl -X PUT https://api.netbird.io/api/setup-keys/{keyId} \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "revoked": false, @@ -819,7 +800,7 @@ let data = JSON.stringify({ let config = { method: 'put', maxBodyLength: Infinity, - url: '/api/setup-keys/{keyId}', + url: 'https://api.netbird.io/api/setup-keys/{keyId}', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -837,7 +818,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -859,7 +840,7 @@ response = requests.request("PUT", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -874,20 +855,19 @@ func main() { url := "https://api.netbird.io/api/setup-keys/{keyId}" method := "PUT" - payload := strings.NewReader(`{ + payload := strings.NewReader({ "revoked": false, "auto_groups": [ "ch8i4ug6lnn4g9hqv7m0" ] -}`) - client := &http.Client { - } +}) + 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") @@ -900,16 +880,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -934,7 +914,7 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); @@ -949,12 +929,12 @@ Request request = new Request.Builder() .method("PUT", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": 2531583362, @@ -1012,6 +989,7 @@ echo $response; "key": "A6160****" } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -1033,35 +1011,39 @@ echo $response; "key": "string" } ``` - - - - + + + + --- -## Delete a Setup Key {{ tag: 'DELETE' , label: '/api/setup-keys/{keyId}' }} + +## Delete a Setup Key {{ tag: 'DELETE', label: '/api/setup-keys/{keyId}' }} + - - Delete a Setup Key - - ### Path Parameters - - - - The unique identifier of a setup key - - - - - - + +Delete a Setup Key + +### Path Parameters + + + + +The unique identifier of a setup key + + + + + + + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/setup-keys/{keyId} \ --H 'Authorization: Token ' +-H 'Authorization: Token ' ``` ```js @@ -1070,10 +1052,10 @@ const axios = require('axios'); let config = { method: 'delete', maxBodyLength: Infinity, - url: '/api/setup-keys/{keyId}', - headers: { + url: 'https://api.netbird.io/api/setup-keys/{keyId}', + headers: { 'Authorization': 'Token ' - } + } }; axios(config) @@ -1087,16 +1069,14 @@ axios(config) ```python import requests -import json url = "https://api.netbird.io/api/setup-keys/{keyId}" -headers = { +headers = { 'Authorization': 'Token ' } response = requests.request("DELETE", url, headers=headers) - print(response.text) ``` @@ -1105,25 +1085,21 @@ package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/setup-keys/{keyId}" method := "DELETE" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return - { - + } + req.Header.Add("Authorization", "Token ") res, err := client.Do(req) @@ -1144,7 +1120,6 @@ func main() { ```ruby require "uri" -require "json" require "net/http" url = URI("https://api.netbird.io/api/setup-keys/{keyId}") @@ -1160,14 +1135,14 @@ puts response.read_body ``` ```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); +OkHttpClient client = new OkHttpClient().newBuilder().build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/setup-keys/{keyId}") - .method("DELETE") - .addHeader("Authorization: Token ") + .method("DELETE", null) + .addHeader("Authorization", "Token ") .build(); + Response response = client.newCall(request).execute(); ``` @@ -1184,23 +1159,20 @@ curl_setopt_array($curl, array( CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'DELETE', - CURLOPT_HTTPHEADER => array( + CURLOPT_CUSTOMREQUEST => 'DELETE', + CURLOPT_HTTPHEADER => array( 'Authorization: Token ' ), )); $response = curl_exec($curl); - curl_close($curl); echo $response; ``` + + + - - - - - --- diff --git a/src/pages/ipa/resources/tokens.mdx b/src/pages/ipa/resources/tokens.mdx index 5cd0a7bc..4dbb3e6d 100644 --- a/src/pages/ipa/resources/tokens.mdx +++ b/src/pages/ipa/resources/tokens.mdx @@ -1,37 +1,39 @@ export const title = 'Tokens' +## List all Tokens {{ tag: 'GET', label: '/api/users/{userId}/tokens' }} -## List all Tokens {{ tag: 'GET' , label: '/api/users/{userId}/tokens' }} - - Returns a list of all tokens for a user - - ### Path Parameters - - - - The unique identifier of a user - - - - - - + +Returns a list of all tokens for a user + +### Path Parameters + + + + +The unique identifier of a user + + + + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/users/{userId}/tokens \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/users/{userId}/tokens', + url: 'https://api.netbird.io/api/users/{userId}/tokens', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -47,7 +49,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -63,30 +65,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: '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 { - } + 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 ") @@ -106,7 +105,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -124,20 +123,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/users/{userId}/tokens") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} [ { @@ -179,6 +175,7 @@ echo $response; } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -191,48 +188,50 @@ echo $response; } ] ``` - - - - + + + + --- -## Create a Token {{ tag: 'POST' , label: '/api/users/{userId}/tokens' }} + +## Create a Token {{ tag: 'POST', label: '/api/users/{userId}/tokens' }} + - - Create a new token for a user - - ### Path Parameters - - - - The unique identifier of a user - - - - ### Request-Body Parameters - - - - Name of the token - - - - - Expiration in days - - - - - - - - - + +Create a new token for a user + +### Path Parameters + + + + +The unique identifier of a user + + + + + +### Request-Body Parameters + + + + +Name of the token + + +Expiration in days + + + + + + + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/users/{userId}/tokens \ -H 'Accept: application/json' \ @@ -244,7 +243,7 @@ curl -X POST https://api.netbird.io/api/users/{userId}/tokens \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "name": "My first token", @@ -253,7 +252,7 @@ let data = JSON.stringify({ let config = { method: 'post', maxBodyLength: Infinity, - url: '/api/users/{userId}/tokens', + url: 'https://api.netbird.io/api/users/{userId}/tokens', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -271,7 +270,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -291,7 +290,7 @@ response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -310,14 +309,13 @@ func main() { "name": "My first token", "expires_in": 30 }`) - client := &http.Client { - } + 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") @@ -330,16 +328,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -362,25 +360,25 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: '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 -}'); +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 ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { - "plain_token": {}, + "plain_token": "2023-05-02T14:48:20.465209Z", "personal_access_token": { "id": "ch8i54g6lnn4g9hqv7n0", "name": "My first token", @@ -428,6 +423,7 @@ echo $response; } } ``` + ```json {{ title: 'Schema' }} { "plain_token": "string", @@ -441,49 +437,52 @@ echo $response; } } ``` - - - - + + + + --- -## Retrieve a Token {{ tag: 'GET' , label: '/api/users/{userId}/tokens/{tokenId}' }} + +## Retrieve a Token {{ tag: 'GET', label: '/api/users/{userId}/tokens/{tokenId}' }} + - - Returns a specific token for a user - - ### Path Parameters - - - - The unique identifier of a user - - - - The unique identifier of a token - - - - - - + +Returns a specific token for a user + +### Path Parameters + + + + +The unique identifier of a user + + +The unique identifier of a token + + + + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/users/{userId}/tokens/{tokenId} \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/users/{userId}/tokens/{tokenId}', + url: 'https://api.netbird.io/api/users/{userId}/tokens/{tokenId}', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -499,7 +498,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -515,30 +514,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: '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 { - } + 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 ") @@ -558,7 +554,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -576,20 +572,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/users/{userId}/tokens/{tokenId}") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "ch8i54g6lnn4g9hqv7n0", @@ -629,6 +622,7 @@ echo $response; "last_used": "2023-05-04T12:45:25.9723616Z" } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -639,39 +633,42 @@ echo $response; "last_used": "string" } ``` - - - - + + + + --- -## Delete a Token {{ tag: 'DELETE' , label: '/api/users/{userId}/tokens/{tokenId}' }} + +## Delete a Token {{ tag: 'DELETE', label: '/api/users/{userId}/tokens/{tokenId}' }} + - - Delete a token for a user - - ### Path Parameters - - - - The unique identifier of a user - - - - The unique identifier of a token - - - - - - + +Delete a token for a user + +### Path Parameters + + + + +The unique identifier of a user + + +The unique identifier of a token + + + + + + + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/users/{userId}/tokens/{tokenId} \ --H 'Authorization: Token ' +-H 'Authorization: Token ' ``` ```js @@ -680,10 +677,10 @@ const axios = require('axios'); let config = { method: 'delete', maxBodyLength: Infinity, - url: '/api/users/{userId}/tokens/{tokenId}', - headers: { + url: 'https://api.netbird.io/api/users/{userId}/tokens/{tokenId}', + headers: { 'Authorization': 'Token ' - } + } }; axios(config) @@ -697,16 +694,14 @@ axios(config) ```python import requests -import json url = "https://api.netbird.io/api/users/{userId}/tokens/{tokenId}" -headers = { +headers = { 'Authorization': 'Token ' } response = requests.request("DELETE", url, headers=headers) - print(response.text) ``` @@ -715,25 +710,21 @@ 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) + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return - { - + } + req.Header.Add("Authorization", "Token ") res, err := client.Do(req) @@ -754,7 +745,6 @@ func main() { ```ruby require "uri" -require "json" require "net/http" url = URI("https://api.netbird.io/api/users/{userId}/tokens/{tokenId}") @@ -770,14 +760,14 @@ puts response.read_body ``` ```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); +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 ") + .method("DELETE", null) + .addHeader("Authorization", "Token ") .build(); + Response response = client.newCall(request).execute(); ``` @@ -794,23 +784,20 @@ curl_setopt_array($curl, array( CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'DELETE', - CURLOPT_HTTPHEADER => array( + CURLOPT_CUSTOMREQUEST => 'DELETE', + CURLOPT_HTTPHEADER => array( 'Authorization: Token ' ), )); $response = curl_exec($curl); - curl_close($curl); echo $response; ``` + + + - - - - - --- diff --git a/src/pages/ipa/resources/users.mdx b/src/pages/ipa/resources/users.mdx index ffd30a46..900beb0d 100644 --- a/src/pages/ipa/resources/users.mdx +++ b/src/pages/ipa/resources/users.mdx @@ -1,37 +1,39 @@ export const title = 'Users' +## List all Users {{ tag: 'GET', label: '/api/users' }} -## List all Users {{ tag: 'GET' , label: '/api/users' }} - - Returns a list of all users - - ### Query Parameters - - - - Filters users and returns either regular users or service users - - - - - - + +Returns a list of all users + +### Query Parameters + + + + +Filters users and returns either regular users or service users + + + + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/users \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let config = { method: 'get', maxBodyLength: Infinity, - url: '/api/users', + url: 'https://api.netbird.io/api/users', headers: { 'Accept': 'application/json', 'Authorization': 'Token ' @@ -47,7 +49,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -63,30 +65,27 @@ response = requests.request("GET", url, headers=headers) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/users" method := "GET" - client := &http.Client { - } + 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 ") @@ -106,7 +105,7 @@ func main() { } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -124,20 +123,20 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/users") - .method("GET") + .method("GET", null) .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} [ { @@ -182,12 +178,10 @@ echo $response; "is_current": true, "is_service_user": false, "is_blocked": false, + "pending_approval": false, "issued": "api", "permissions": { - "is_restricted": { - "type": "boolean", - "description": "Indicates whether this User's Peers view is restricted" - }, + "is_restricted": false, "modules": { "networks": { "read": true, @@ -206,6 +200,7 @@ echo $response; } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -221,6 +216,7 @@ echo $response; "is_current": "boolean", "is_service_user": "boolean", "is_blocked": "boolean", + "pending_approval": "boolean", "issued": "string", "permissions": { "is_restricted": "boolean", @@ -228,10 +224,8 @@ echo $response; "type": "object", "additionalProperties": { "type": "object", - "additionalProperties": "boolean", - "propertyNames": "string" + "additionalProperties": "boolean" }, - "propertyNames": "string", "example": { "networks": { "read": true, @@ -251,55 +245,48 @@ echo $response; } ] ``` - - - - + + + + --- -## Create a User {{ tag: 'POST' , label: '/api/users' }} + +## Create a User {{ tag: 'POST', label: '/api/users' }} + - - Creates a new service user or sends an invite to a regular user - - ### Request-Body Parameters - - - - User's Email to send invite to - - - - - User's full name - - - - - User's NetBird account role - - - - - Group IDs to auto-assign to peers registered by this user - - - - - Is true if this user is a service user - - - - - - - - - + +Creates a new service user or sends an invite to a regular user + +### Request-Body Parameters + + + + +User's Email to send invite to + + +User's full name + + +User's NetBird account role + + +Group IDs to auto-assign to peers registered by this user + + +Is true if this user is a service user + + + + + + + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/users \ -H 'Accept: application/json' \ @@ -316,7 +303,7 @@ curl -X POST https://api.netbird.io/api/users \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "email": "demo@netbird.io", @@ -330,7 +317,7 @@ let data = JSON.stringify({ let config = { method: 'post', maxBodyLength: Infinity, - url: '/api/users', + url: 'https://api.netbird.io/api/users', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -348,7 +335,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -373,7 +360,7 @@ response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -397,14 +384,13 @@ func main() { ], "is_service_user": false }`) - client := &http.Client { - } + 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") @@ -417,16 +403,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -454,30 +440,30 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "email": "demo@netbird.io", - "name": "Tom Schulz", - "role": "admin", - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" +RequestBody body = RequestBody.create(mediaType, "{ + \"email\": \"demo@netbird.io\", + \"name\": \"Tom Schulz\", + \"role\": \"admin\", + \"auto_groups\": [ + \"ch8i4ug6lnn4g9hqv7m0\" ], - "is_service_user": false -}'); + \"is_service_user\": false +}"); Request request = new Request.Builder() .url("https://api.netbird.io/api/users") .method("POST", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "google-oauth2|277474792786460067937", @@ -531,12 +514,10 @@ echo $response; "is_current": true, "is_service_user": false, "is_blocked": false, + "pending_approval": false, "issued": "api", "permissions": { - "is_restricted": { - "type": "boolean", - "description": "Indicates whether this User's Peers view is restricted" - }, + "is_restricted": false, "modules": { "networks": { "read": true, @@ -554,6 +535,7 @@ echo $response; } } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -568,6 +550,7 @@ echo $response; "is_current": "boolean", "is_service_user": "boolean", "is_blocked": "boolean", + "pending_approval": "boolean", "issued": "string", "permissions": { "is_restricted": "boolean", @@ -575,10 +558,8 @@ echo $response; "type": "object", "additionalProperties": { "type": "object", - "additionalProperties": "boolean", - "propertyNames": "string" + "additionalProperties": "boolean" }, - "propertyNames": "string", "example": { "networks": { "read": true, @@ -597,53 +578,53 @@ echo $response; } } ``` - - - - + + + + --- -## Update a User {{ tag: 'PUT' , label: '/api/users/{userId}' }} + +## Update a User {{ tag: 'PUT', label: '/api/users/{userId}' }} + - - Update information about a User - - ### Path Parameters - - - - The unique identifier of a user - - - - ### Request-Body Parameters - - - - User's NetBird account role - - - - - Group IDs to auto-assign to peers registered by this user - - - - - If set to true then user is blocked and can't use the system - - - - - - - - - + +Update information about a User + +### Path Parameters + + + + +The unique identifier of a user + + + + + +### Request-Body Parameters + + + + +User's NetBird account role + + +Group IDs to auto-assign to peers registered by this user + + +If set to true then user is blocked and can't use the system + + + + + + + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/users/{userId} \ -H 'Accept: application/json' \ @@ -658,7 +639,7 @@ curl -X PUT https://api.netbird.io/api/users/{userId} \ }' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); let data = JSON.stringify({ "role": "admin", @@ -670,7 +651,7 @@ let data = JSON.stringify({ let config = { method: 'put', maxBodyLength: Infinity, - url: '/api/users/{userId}', + url: 'https://api.netbird.io/api/users/{userId}', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -688,7 +669,7 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json @@ -711,7 +692,7 @@ response = requests.request("PUT", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -726,21 +707,20 @@ func main() { url := "https://api.netbird.io/api/users/{userId}" method := "PUT" - payload := strings.NewReader(`{ + payload := strings.NewReader({ "role": "admin", "auto_groups": [ "ch8i4ug6lnn4g9hqv7m0" ], "is_blocked": false -}`) - client := &http.Client { - } +}) + 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") @@ -753,16 +733,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -788,7 +768,7 @@ response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); @@ -804,12 +784,12 @@ Request request = new Request.Builder() .method("PUT", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} - - - + + ```json {{ title: 'Example' }} { "id": "google-oauth2|277474792786460067937", @@ -861,12 +838,10 @@ echo $response; "is_current": true, "is_service_user": false, "is_blocked": false, + "pending_approval": false, "issued": "api", "permissions": { - "is_restricted": { - "type": "boolean", - "description": "Indicates whether this User's Peers view is restricted" - }, + "is_restricted": false, "modules": { "networks": { "read": true, @@ -884,6 +859,7 @@ echo $response; } } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -898,6 +874,7 @@ echo $response; "is_current": "boolean", "is_service_user": "boolean", "is_blocked": "boolean", + "pending_approval": "boolean", "issued": "string", "permissions": { "is_restricted": "boolean", @@ -905,10 +882,8 @@ echo $response; "type": "object", "additionalProperties": { "type": "object", - "additionalProperties": "boolean", - "propertyNames": "string" + "additionalProperties": "boolean" }, - "propertyNames": "string", "example": { "networks": { "read": true, @@ -927,35 +902,39 @@ echo $response; } } ``` - - - - + + + + --- -## Delete a User {{ tag: 'DELETE' , label: '/api/users/{userId}' }} + +## Delete a User {{ tag: 'DELETE', label: '/api/users/{userId}' }} + - - This method removes a user from accessing the system. For this leaves the IDP user intact unless the `--user-delete-from-idp` is passed to management startup. - - ### Path Parameters - - - - The unique identifier of a user - - - - - - + +This method removes a user from accessing the system. For this leaves the IDP user intact unless the `--user-delete-from-idp` is passed to management startup. + +### Path Parameters + + + + +The unique identifier of a user + + + + + + + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/users/{userId} \ --H 'Authorization: Token ' +-H 'Authorization: Token ' ``` ```js @@ -964,10 +943,10 @@ const axios = require('axios'); let config = { method: 'delete', maxBodyLength: Infinity, - url: '/api/users/{userId}', - headers: { + url: 'https://api.netbird.io/api/users/{userId}', + headers: { 'Authorization': 'Token ' - } + } }; axios(config) @@ -981,16 +960,14 @@ axios(config) ```python import requests -import json url = "https://api.netbird.io/api/users/{userId}" -headers = { +headers = { 'Authorization': 'Token ' } response = requests.request("DELETE", url, headers=headers) - print(response.text) ``` @@ -999,25 +976,21 @@ package main import ( "fmt" - "strings" "net/http" "io/ioutil" ) func main() { - url := "https://api.netbird.io/api/users/{userId}" method := "DELETE" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return - { - + } + req.Header.Add("Authorization", "Token ") res, err := client.Do(req) @@ -1038,7 +1011,6 @@ func main() { ```ruby require "uri" -require "json" require "net/http" url = URI("https://api.netbird.io/api/users/{userId}") @@ -1054,14 +1026,14 @@ puts response.read_body ``` ```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); +OkHttpClient client = new OkHttpClient().newBuilder().build(); Request request = new Request.Builder() .url("https://api.netbird.io/api/users/{userId}") - .method("DELETE") - .addHeader("Authorization: Token ") + .method("DELETE", null) + .addHeader("Authorization", "Token ") .build(); + Response response = client.newCall(request).execute(); ``` @@ -1078,60 +1050,67 @@ curl_setopt_array($curl, array( CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'DELETE', - CURLOPT_HTTPHEADER => array( + CURLOPT_CUSTOMREQUEST => 'DELETE', + CURLOPT_HTTPHEADER => array( 'Authorization: Token ' ), )); $response = curl_exec($curl); - curl_close($curl); echo $response; ``` + + + - - - - - --- -## Resend user invitation {{ tag: 'POST' , label: '/api/users/{userId}/invite' }} + +## Resend user invitation {{ tag: 'POST', label: '/api/users/{userId}/invite' }} + - - Resend user invitation - - ### Path Parameters - - - - The unique identifier of a user - - - - - - + +Resend user invitation + +### Path Parameters + + + + +The unique identifier of a user + + + + + + + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/users/{userId}/invite \ --H 'Authorization: Token ' +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{}' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); - +let data = JSON.stringify({}); let config = { method: 'post', maxBodyLength: Infinity, - url: '/api/users/{userId}/invite', - headers: { + url: 'https://api.netbird.io/api/users/{userId}/invite', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', 'Authorization': 'Token ' - } + }, + data : data }; axios(config) @@ -1143,22 +1122,24 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json url = "https://api.netbird.io/api/users/{userId}/invite" - -headers = { +payload = json.dumps({}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', 'Authorization': 'Token ' } -response = requests.request("POST", url, headers=headers) +response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -1173,15 +1154,17 @@ func main() { url := "https://api.netbird.io/api/users/{userId}/invite" method := "POST" - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) + payload := strings.NewReader(`{}`) + 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 ") res, err := client.Do(req) @@ -1191,16 +1174,16 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" @@ -1211,25 +1194,31 @@ 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 " +request.body = JSON.dump({}) response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); - +MediaType mediaType = MediaType.parse("application/json"); +RequestBody body = RequestBody.create(mediaType, "{}"); Request request = new Request.Builder() .url("https://api.netbird.io/api/users/{userId}/invite") - .method("POST") - .addHeader("Authorization: Token ") + .method("POST", body) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', - CURLOPT_HTTPHEADER => array( + CURLOPT_POSTFIELDS => '{}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', 'Authorization: Token ' ), )); @@ -1253,43 +1245,57 @@ $response = curl_exec($curl); curl_close($curl); echo $response; ``` + + + - - - - - --- -## Retrieve current user {{ tag: 'GET' , label: '/api/users/current' }} + +## Approve user {{ tag: 'POST', label: '/api/users/{userId}/approve' }} + - - Get information about the current user - + +Approve a user that is pending approval + +### Path Parameters - - + + + +The unique identifier of a user + + + + + + + ```bash {{ title: 'cURL' }} -curl -X GET https://api.netbird.io/api/users/current \ +curl -X POST https://api.netbird.io/api/users/{userId}/approve \ -H 'Accept: application/json' \ --H 'Authorization: Token ' +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{}' ``` -```js +```js {{ title: 'JavaScript' }} const axios = require('axios'); - +let data = JSON.stringify({}); let config = { - method: 'get', + method: 'post', maxBodyLength: Infinity, - url: '/api/users/current', + url: 'https://api.netbird.io/api/users/{userId}/approve', headers: { 'Accept': 'application/json', + 'Content-Type': 'application/json', 'Authorization': 'Token ' - } + }, + data : data }; axios(config) @@ -1301,23 +1307,24 @@ axios(config) }); ``` -```python +```python {{ title: 'Python' }} import requests import json -url = "https://api.netbird.io/api/users/current" - -headers = { +url = "https://api.netbird.io/api/users/{userId}/approve" +payload = json.dumps({}) +headers = { + 'Content-Type': 'application/json', 'Accept': 'application/json', 'Authorization': 'Token ' } -response = requests.request("GET", url, headers=headers) +response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` -```go +```go {{ title: 'Go' }} package main import ( @@ -1329,18 +1336,19 @@ import ( func main() { - url := "https://api.netbird.io/api/users/current" - method := "GET" + url := "https://api.netbird.io/api/users/{userId}/approve" + method := "POST" - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) + payload := strings.NewReader(`{}`) + 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 ") @@ -1351,61 +1359,67 @@ func main() { } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + resBody, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } - fmt.Println(string(body)) + fmt.Println(string(resBody)) } ``` -```ruby +```ruby {{ title: 'Ruby' }} require "uri" require "json" require "net/http" -url = URI("https://api.netbird.io/api/users/current") +url = URI("https://api.netbird.io/api/users/{userId}/approve") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true -request = Net::HTTP::Get.new(url) +request = Net::HTTP::Post.new(url) +request["Content-Type"] = "application/json" request["Accept"] = "application/json" request["Authorization"] = "Token " +request.body = JSON.dump({}) response = https.request(request) puts response.read_body ``` -```java +```java {{ title: 'Java' }} OkHttpClient client = new OkHttpClient().newBuilder() .build(); - +MediaType mediaType = MediaType.parse("application/json"); +RequestBody body = RequestBody.create(mediaType, "{}"); Request request = new Request.Builder() - .url("https://api.netbird.io/api/users/current") - .method("GET") + .url("https://api.netbird.io/api/users/{userId}/approve") + .method("POST", body) + .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") + .addHeader("Authorization", "Token ") .build(); Response response = client.newCall(request).execute(); ``` -```php +```php {{ title: 'PHP' }} 'https://api.netbird.io/api/users/current', + CURLOPT_URL => 'https://api.netbird.io/api/users/{userId}/approve', 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( + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS => '{}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', 'Accept: application/json', 'Authorization: Token ' ), @@ -1416,11 +1430,8 @@ $response = curl_exec($curl); curl_close($curl); echo $response; ``` - - - - - + + ```json {{ title: 'Example' }} { "id": "google-oauth2|277474792786460067937", @@ -1435,12 +1446,10 @@ echo $response; "is_current": true, "is_service_user": false, "is_blocked": false, + "pending_approval": false, "issued": "api", "permissions": { - "is_restricted": { - "type": "boolean", - "description": "Indicates whether this User's Peers view is restricted" - }, + "is_restricted": false, "modules": { "networks": { "read": true, @@ -1458,6 +1467,7 @@ echo $response; } } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -1472,6 +1482,7 @@ echo $response; "is_current": "boolean", "is_service_user": "boolean", "is_blocked": "boolean", + "pending_approval": "boolean", "issued": "string", "permissions": { "is_restricted": "boolean", @@ -1479,10 +1490,8 @@ echo $response; "type": "object", "additionalProperties": { "type": "object", - "additionalProperties": "boolean", - "propertyNames": "string" + "additionalProperties": "boolean" }, - "propertyNames": "string", "example": { "networks": { "read": true, @@ -1501,10 +1510,407 @@ echo $response; } } ``` - - - - + + + + + + +--- + + + +## Reject user {{ tag: 'DELETE', label: '/api/users/{userId}/reject' }} + + + + +Reject a user that is pending approval by removing them from the account + +### Path Parameters + + + + +The unique identifier of a user + + + + + + + +```bash {{ title: 'cURL' }} +curl -X DELETE https://api.netbird.io/api/users/{userId}/reject \ +-H 'Authorization: Token ' +``` + +```js +const axios = require('axios'); + +let config = { + method: 'delete', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/users/{userId}/reject', + headers: { + 'Authorization': 'Token ' + } +}; + +axios(config) +.then((response) => { + console.log(JSON.stringify(response.data)); +}) +.catch((error) => { + console.log(error); +}); +``` + +```python +import requests + +url = "https://api.netbird.io/api/users/{userId}/reject" + +headers = { + 'Authorization': 'Token ' +} + +response = requests.request("DELETE", url, headers=headers) +print(response.text) +``` + +```go +package main + +import ( + "fmt" + "net/http" + "io/ioutil" +) + +func main() { + url := "https://api.netbird.io/api/users/{userId}/reject" + method := "DELETE" + + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) + if err != nil { + fmt.Println(err) + return + } + + 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 "net/http" + +url = URI("https://api.netbird.io/api/users/{userId}/reject") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Delete.new(url) +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/users/{userId}/reject") + .method("DELETE", null) + .addHeader("Authorization", "Token ") + .build(); + +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/users/{userId}/reject', + 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 ' + ), +)); + +$response = curl_exec($curl); +curl_close($curl); +echo $response; +``` + + + + + + +--- + + + +## Retrieve current user {{ tag: 'GET', label: '/api/users/current' }} + + + + +Get information about the current user + + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/users/current \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' +``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); + +let config = { + method: 'get', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/users/current', + headers: { + 'Accept': 'application/json', + 'Authorization': 'Token ' + } +}; + +axios(config) +.then((response) => { + console.log(JSON.stringify(response.data)); +}) +.catch((error) => { + console.log(error); +}); +``` + +```python {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/users/current" + +headers = { + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("GET", url, headers=headers) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "net/http" + "io/ioutil" +) + +func main() { + url := "https://api.netbird.io/api/users/current" + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/users/current") + +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 {{ title: 'Java' }} +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); + +Request request = new Request.Builder() + .url("https://api.netbird.io/api/users/current") + .method("GET", null) + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/users/current', + 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": "google-oauth2|277474792786460067937", + "email": "demo@netbird.io", + "name": "Tom Schulz", + "role": "admin", + "status": "active", + "last_login": "2023-05-05T09:00:35.477782Z", + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "is_current": true, + "is_service_user": false, + "is_blocked": false, + "pending_approval": false, + "issued": "api", + "permissions": { + "is_restricted": false, + "modules": { + "networks": { + "read": true, + "create": false, + "update": false, + "delete": false + }, + "peers": { + "read": false, + "create": false, + "update": false, + "delete": false + } + } + } +} +``` + +```json {{ title: 'Schema' }} +{ + "id": "string", + "email": "string", + "name": "string", + "role": "string", + "status": "string", + "last_login": "string", + "auto_groups": [ + "string" + ], + "is_current": "boolean", + "is_service_user": "boolean", + "is_blocked": "boolean", + "pending_approval": "boolean", + "issued": "string", + "permissions": { + "is_restricted": "boolean", + "modules": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": "boolean" + }, + "example": { + "networks": { + "read": true, + "create": false, + "update": false, + "delete": false + }, + "peers": { + "read": false, + "create": false, + "update": false, + "delete": false + } + } + } + } +} +``` + + + + ---