From 98c8a5bb9091d9523c55b5e9f9209ec9c1a19457 Mon Sep 17 00:00:00 2001 From: aliamerj Date: Fri, 19 Sep 2025 21:34:52 +0300 Subject: [PATCH 1/5] new api parser just drop out --- openapi-gen/index.ts | 57 + openapi-gen/templates/ApiTemplate.tsx | 145 + openapi-gen/tsconfig.json | 27 + openapi-gen/tsxParser/api/requests.ts | 65 + openapi-gen/tsxParser/api/responses.ts | 13 + openapi-gen/tsxParser/components/index.tsx | 112 + openapi-gen/tsxParser/openapi-extractor.ts | 740 ++++ openapi-gen/tsxParser/renderToMDX.ts | 104 + package.json | 3 +- src/components/NavigationAPI.jsx | 1 + src/components/Resources.jsx | 11 + src/pages/ipa/resources/accounts.mdx | 1067 ++---- src/pages/ipa/resources/dns.mdx | 1860 ++-------- src/pages/ipa/resources/events.mdx | 540 +-- src/pages/ipa/resources/geo-locations.mdx | 355 +- src/pages/ipa/resources/groups.mdx | 1229 ++----- src/pages/ipa/resources/ingress-ports.mdx | 2531 +++----------- src/pages/ipa/resources/networks.mdx | 3629 ++++---------------- src/pages/ipa/resources/peers.mdx | 1204 ++----- src/pages/ipa/resources/policies.mdx | 2023 ++--------- src/pages/ipa/resources/posture-checks.mdx | 2357 ++----------- src/pages/ipa/resources/routes.mdx | 1557 ++------- src/pages/ipa/resources/setup-keys.mdx | 1200 ++----- src/pages/ipa/resources/tokens.mdx | 826 +---- src/pages/ipa/resources/users.mdx | 1463 ++------ 25 files changed, 5002 insertions(+), 18117 deletions(-) create mode 100644 openapi-gen/index.ts create mode 100644 openapi-gen/templates/ApiTemplate.tsx create mode 100644 openapi-gen/tsconfig.json create mode 100644 openapi-gen/tsxParser/api/requests.ts create mode 100644 openapi-gen/tsxParser/api/responses.ts create mode 100644 openapi-gen/tsxParser/components/index.tsx create mode 100644 openapi-gen/tsxParser/openapi-extractor.ts create mode 100644 openapi-gen/tsxParser/renderToMDX.ts diff --git a/openapi-gen/index.ts b/openapi-gen/index.ts new file mode 100644 index 00000000..7e6011fd --- /dev/null +++ b/openapi-gen/index.ts @@ -0,0 +1,57 @@ +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'); + const yml = await readYaml(inputUrl) + const mdxFile: Record = {} + + 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) + }) + + for (let tag in mdxFile) { + const element = React.createElement(ApiTemplate, { tag: tag, endpoints: mdxFile[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) + } + +})() + + +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..8a235483 --- /dev/null +++ b/openapi-gen/templates/ApiTemplate.tsx @@ -0,0 +1,145 @@ +import { Endpoint, Parameter, Request } from "../tsxParser/openapi-extractor" +import { CodeGroup, Col, Row, Stringify, Property, Properties, Details, Summary } from "../tsxParser/components" + +export type ApiTemplateProps = { + tag: string, + endpoints: Endpoint[] +} + +export const ApiTemplate = ({ tag, endpoints}: ApiTemplateProps) => { + return ( + <> + + + {endpoints.map((ap, index) => { + return ( +
+

+ {ap.summary} + {` {{ tag: '${ap.method.toUpperCase()}', label: '${ap.path}' }}`} +

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

Path Parameters

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

Request-Body Parameters

+ + {bodyRequest.map((req, index) => { + if (req.type === "object[]" || req.type === "object") { + return ( + +
+ {req.description || "Object list"} + + + {req?.bodyObj?.map((ob, objIndex) => { + return ( + + {ob.description} + + ) + })} + + +
+
+ ) + } else { + // Handle regular properties (not object arrays) + return ( + + {req.description} + + ) + } + })} +
+ + ) +} diff --git a/openapi-gen/tsconfig.json b/openapi-gen/tsconfig.json new file mode 100644 index 00000000..ed71152f --- /dev/null +++ b/openapi-gen/tsconfig.json @@ -0,0 +1,27 @@ +// generator files need their own tsconfig.json because they don't like "module": "esnext" setting that nextjs requires in the main tsconfig +{ + "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..73e3b6ad --- /dev/null +++ b/openapi-gen/tsxParser/api/requests.ts @@ -0,0 +1,65 @@ +export const requestCode = (method: string, url: string, body: string) => { + switch (method) { + case 'GET': + return getRequestCode(url) + case "POST": + return postRequestCode(url, body) + case "PUT": + return putRequestCode(url, body) + case "DELETE": + return deleteRequestCode(url) + } +} + +const deleteRequestCode = (url:string) => { + const langCode = [] + langCode.push(`\`\`\`bash {{ title: 'cURL' }} +curl -X DELETE https://api.netbird.io${url} \\ +-H 'Authorization: Token ' \\ +\`\`\``) + + return langCode +} + +const putRequestCode = (url:string, body:string) => { + const langCode = [] + langCode.push(`\`\`\`bash {{ title: 'cURL' }} +curl -X PUT https://api.netbird.io${url} \\ +-H 'Accept: application/json' \\ +-H 'Content-Type: application/json' \\ +-H 'Authorization: Token ' \\ +--data-raw '${body}' +\`\`\``) + + return langCode +} + + + +const postRequestCode = (url: string, body: string) => { + const langCode = [] + langCode.push(`\`\`\`bash {{ title: 'cURL' }} +curl -X POST https://api.netbird.io${url} \\ +-H 'Accept: application/json' \\ +-H 'Content-Type: application/json' \\ +-H 'Authorization: Token ' \\ +--data-raw '${body}' +\`\`\``) + + return langCode +} + + + + +const getRequestCode = (label: string) => { + const langCode = [] + langCode.push(`\`\`\`bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io${label} \\ +-H 'Accept: application/json' \\ +-H 'Authorization: Token ' +\`\`\``) + + 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..d4619d8b --- /dev/null +++ b/openapi-gen/tsxParser/components/index.tsx @@ -0,0 +1,112 @@ +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<"}Row{">\n"} + {children} + {"\n"} + + +export const Details = ({ children, className, open }: { children: React.ReactNode, className: string, open?: boolean }) => <> + {"\n<"}details{className ? ` class="${className}" ` : ""}{open ? "open " : ""}{">\n"} + {children} + {"\n"} + + +export const Summary = ({ children }: { children: React.ReactNode }) => <> + {"\n<"}summary{">"} + {children} + {""} + + + + + +export const Col = ({ children, sticky }: { children: React.ReactNode, sticky?: boolean }) => <> + {"\n<"}Col{sticky ? ' sticky' : ""}{">\n"} + {children} + {"\n\n"} + + +export const Properties = ({ children }) => <> + {"\n<"}Properties{">\n"} + {children} + {"\n\n"} + + +type PropertyProps = { + name?: string, + type?: string, + required?: boolean, + minLen?: number, + maxLen?: number, + enumList?: string[] + children: React.ReactNode, +} + +export const Property = ({ name, type, required, 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(tag, label, exampleJson) + if (title === "Response") langCode = responseCode(schemaJson, schemaJson) + 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..357748a5 --- /dev/null +++ b/openapi-gen/tsxParser/openapi-extractor.ts @@ -0,0 +1,740 @@ +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 + minLen?: number + maxLen?: number + minimum?: number + maximum?: number + enumList?: any[] + bodyObj?: Request[] +} + +export type Endpoint = { + path: string + method: string + summary?: string + description?: string + parameters?: Parameter[] + responses: Record + request?: Request[] | null + tag: string +} + + +/** + * 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/oneOf: return array of resolved options (keep as oneOf/anyOf structure) + if (Array.isArray(node.oneOf)) { + return { oneOf: node.oneOf.map((opt: any) => dereferenceNode(opt, doc, new Set(seenRefs))) } + } + if (Array.isArray(node.anyOf)) { + return { anyOf: node.anyOf.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.minItems !== undefined) arr.minItems = node.minItems + if (node.maxItems !== undefined) arr.maxItems = node.maxItems + 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/anyOf (already dereferenced to actual nodes) + if (node.oneOf) { + return { oneOf: node.oneOf.map((o: any) => buildSchemaRepresentation(o, doc, new Set(seenRefs))) } + } + if (node.anyOf) { + return { anyOf: node.anyOf.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 } + } + if (deref.anyOf) { + const options = deref.anyOf.map((opt: any) => extractFromSchema(opt, doc, new Set(seenRefs))) + const firstExample = options.find(o => o.example !== undefined && o.example !== null)?.example ?? null + return { schema: { anyOf: 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 } +} + + + +/* ----------------- helpers ----------------- */ + +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 + } +} + +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 +} + +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 +} + +function schemaNodeToRequests( + node: any, + doc: OpenAPIV3_1.Document, + nameForRoot = 'body', + requiredNames: string[] = [], + seenRefs = new Set() +): Request[] { + if (!node) return [] + + // If node is a string ref like '#/components/...' -> resolve and recurse + if (typeof node === 'string' && node.startsWith('#/')) { + const resolved = resolveRef(node, doc) + return schemaNodeToRequests(resolved, doc, nameForRoot, requiredNames, seenRefs) + } + + // If it's a $ref object, resolve (avoid infinite loop) + if (node.$ref) { + const ref = node.$ref as string + if (seenRefs.has(ref)) { + // circular: return a placeholder + return [{ name: nameForRoot, type: ref, required: requiredNames.includes(nameForRoot) }] + } + seenRefs.add(ref) + const resolved = resolveRef(ref, doc) + if (!resolved) return [{ name: nameForRoot, type: ref, required: requiredNames.includes(nameForRoot) }] + return schemaNodeToRequests(resolved, doc, nameForRoot, requiredNames, seenRefs) + } + + // If oneOf -> produce one Request entry with type 'oneOf' and bodyObj containing options + if (Array.isArray(node.oneOf)) { + const options: Request[] = node.oneOf.map((opt: any, idx: number) => { + const optReqs = schemaNodeToRequests(opt, doc, `option_${idx+1}`, [], new Set(seenRefs)) + if (optReqs.length === 1 && optReqs[0].type === 'object' && optReqs[0].bodyObj) { + return { + name: `Option ${idx+1}`, + type: 'object', + required: true, + description: opt.description || undefined, + bodyObj: optReqs[0].bodyObj + } + } + return { + name: `Option ${idx+1}`, + type: 'object', + required: true, + bodyObj: optReqs + } + }) + return [{ + name: nameForRoot, + type: 'oneOf', + required: true, + description: node.description || undefined, + bodyObj: options + }] + } + + // If array -> create a single Request describing the array + if (node.type === 'array' || node.items) { + const items = node.items ?? {} + // object[] case + if ((items.type === 'object') || items.properties || items.$ref || items.oneOf) { + const nested = schemaNodeToRequests(items, doc, 'item', items.required || [], new Set(seenRefs)) + return [{ + name: nameForRoot, + type: 'object[]', + required: requiredNames.includes(nameForRoot), + description: node.description || undefined, + bodyObj: nested + }] + } else { + const itemType = items.type || 'any' + return [{ + name: nameForRoot, + type: `${itemType}[]`, + required: requiredNames.includes(nameForRoot), + description: node.description || undefined, + minLen: node.minItems, + maxLen: node.maxItems, + }] + } + } + + // If object with properties -> map each property to Request + if (node.type === 'object' || node.properties || node.additionalProperties) { + if (node.properties && typeof node.properties === 'object') { + const out: Request[] = [] + const reqArr: string[] = Array.isArray(node.required) ? node.required : requiredNames || [] + for (const [propName, propSchema] of Object.entries(node.properties)) { + const prop = propSchema as any + + // $ref property + if (prop.$ref) { + const resolved = resolveRef(prop.$ref, doc) + const nestedReqs = schemaNodeToRequests(resolved, doc, propName, resolved?.required || [], new Set(seenRefs)) + if (nestedReqs.length === 1 && nestedReqs[0].type === 'object' && nestedReqs[0].bodyObj) { + out.push({ + name: propName, + type: 'object', + required: reqArr.includes(propName), + description: prop.description || undefined, + bodyObj: nestedReqs[0].bodyObj + }) + continue + } else { + out.push({ + name: propName, + type: 'object', + required: reqArr.includes(propName), + description: prop.description || undefined, + bodyObj: nestedReqs + }) + continue + } + } + + // array property + if (prop.type === 'array' || prop.items) { + const items = prop.items ?? {} + if ((items.type === 'object') || items.properties || items.$ref || items.oneOf) { + const nested = schemaNodeToRequests(items, doc, propName, items.required || [], new Set(seenRefs)) + out.push({ + name: propName, + type: 'object[]', + required: reqArr.includes(propName), + description: prop.description || undefined, + minLen: prop.minItems, + maxLen: prop.maxItems, + bodyObj: nested + }) + } else { + out.push({ + name: propName, + type: `${items.type || 'any'}[]`, + required: reqArr.includes(propName), + description: prop.description || undefined, + minLen: prop.minItems, + maxLen: prop.maxItems, + enumList: items.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', + required: reqArr.includes(propName), + description: prop.description || undefined, + bodyObj: nested + }) + continue + } + + // primitive property + const r: Request = { + name: propName, + type: prop.type || (prop.enum ? 'string' : 'any'), + required: reqArr.includes(propName), + description: prop.description || undefined + } + if (prop.minLength !== undefined) r.minLen = prop.minLength + if (prop.maxLength !== undefined) r.maxLen = prop.maxLength + if (prop.minimum !== undefined) r.minimum = prop.minimum + if (prop.maximum !== undefined) r.maximum = prop.maximum + if (prop.enum) r.enumList = Array.isArray(prop.enum) ? prop.enum : undefined + out.push(r) + } + return out + } + + // additionalProperties (map) + if (node.additionalProperties) { + const add = node.additionalProperties === true ? { type: 'any' } : node.additionalProperties + const nested = schemaNodeToRequests(add, doc, 'value', add?.required || [], new Set(seenRefs)) + return [{ + name: nameForRoot, + type: 'object', + required: requiredNames.includes(nameForRoot), + description: node.description || undefined, + bodyObj: nested.length ? nested : undefined + }] + } + + // empty object + return [{ + name: nameForRoot, + type: 'object', + required: requiredNames.includes(nameForRoot), + description: node.description || undefined + }] + } + + // primitive at root + if (typeof node.type === 'string') { + const r: Request = { + name: nameForRoot, + type: node.type, + required: requiredNames.includes(nameForRoot), + description: node.description || undefined + } + if (node.minLength !== undefined) r.minLen = node.minLength + if (node.maxLength !== undefined) r.maxLen = node.maxLength + if (node.minimum !== undefined) r.minimum = node.minimum + if (node.maximum !== undefined) r.maximum = node.maximum + if (node.enum) r.enumList = node.enum + return [r] + } + + // enum fallback + if (node.enum) { + return [{ + name: nameForRoot, + type: 'string', + required: requiredNames.includes(nameForRoot), + enumList: Array.isArray(node.enum) ? node.enum : undefined, + description: node.description || undefined + }] + } + + // fallback + return [{ + name: nameForRoot, + type: typeof node === 'object' ? 'object' : 'any', + required: requiredNames.includes(nameForRoot), + description: node?.description || undefined + }] +} + +/* ----------------- 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): { endpoints: 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 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, + } + + // ---------- 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 } +} + diff --git a/openapi-gen/tsxParser/renderToMDX.ts b/openapi-gen/tsxParser/renderToMDX.ts new file mode 100644 index 00000000..884371ba --- /dev/null +++ b/openapi-gen/tsxParser/renderToMDX.ts @@ -0,0 +1,104 @@ +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; +}; + +/** 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") + ); +} + +/** 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); +} + 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/components/NavigationAPI.jsx b/src/components/NavigationAPI.jsx index 269b8126..80328ebf 100644 --- a/src/components/NavigationAPI.jsx +++ b/src/components/NavigationAPI.jsx @@ -35,6 +35,7 @@ export const apiNavigation = [ { title: 'Networks', href: '/api/resources/networks' }, { title: 'DNS', href: '/api/resources/dns' }, { title: 'Events', href: '/api/resources/events' }, + { title: 'Jobs', href: '/api/resources/jobs' }, ], }, ] diff --git a/src/components/Resources.jsx b/src/components/Resources.jsx index 721e0b6e..b7b3f8fc 100644 --- a/src/components/Resources.jsx +++ b/src/components/Resources.jsx @@ -142,6 +142,17 @@ const resources = [ squares: [[0, 1]], }, }, + { + href: '/api/resources/jobs', + name: 'Jobs', + description: + 'Learn about how to list jobs.', + icon: UsersIcon, + pattern: { + y: 22, + squares: [[0, 1]], + }, + }, ] function ResourceIcon({ icon: Icon }) { diff --git a/src/pages/ipa/resources/accounts.mdx b/src/pages/ipa/resources/accounts.mdx index 86eb8cb5..7f064636 100644 --- a/src/pages/ipa/resources/accounts.mdx +++ b/src/pages/ipa/resources/accounts.mdx @@ -1,204 +1,65 @@ 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 -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/accounts', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/accounts" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/accounts" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` - -```ruby -require "uri" -require "json" -require "net/http" - -url = URI("https://api.netbird.io/api/accounts") - -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true - -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/accounts") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/accounts', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'GET', - CURLOPT_HTTPHEADER => array( - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` - - - - - + + ```json {{ title: 'Example' }} [ { - "id": "ch8i4ug6lnn4g9hqv7l0", + "id": "string", "settings": { - "peer_login_expiration_enabled": true, - "peer_login_expiration": 43200, - "peer_inactivity_expiration_enabled": true, - "peer_inactivity_expiration": 43200, - "regular_users_view_blocked": true, - "groups_propagation_enabled": true, - "jwt_groups_enabled": true, - "jwt_groups_claim_name": "roles", + "peer_login_expiration_enabled": "boolean", + "peer_login_expiration": "integer", + "peer_inactivity_expiration_enabled": "boolean", + "peer_inactivity_expiration": "integer", + "regular_users_view_blocked": "boolean", + "groups_propagation_enabled": "boolean", + "jwt_groups_enabled": "boolean", + "jwt_groups_claim_name": "string", "jwt_allow_groups": [ - "Administrators" + "string" ], - "routing_peer_dns_resolution_enabled": true, - "dns_domain": "my-organization.org", - "network_range": "100.64.0.0/16", + "routing_peer_dns_resolution_enabled": "boolean", + "dns_domain": "string", + "network_range": "string", "extra": { - "peer_approval_enabled": true, - "network_traffic_logs_enabled": true, + "peer_approval_enabled": "boolean", + "network_traffic_logs_enabled": "boolean", "network_traffic_logs_groups": [ - "ch8i4ug6lnn4g9hqv7m0" + "string" ], - "network_traffic_packet_counter_enabled": true + "network_traffic_packet_counter_enabled": "boolean" }, - "lazy_connection_enabled": true + "lazy_connection_enabled": "boolean" }, - "domain": "netbird.io", - "domain_category": "private", - "created_at": "2023-05-05T09:00:35.477782Z", - "created_by": "google-oauth2|277474792786460067937", + "domain": "string", + "domain_category": "string", + "created_at": "string", + "created_by": "string", "onboarding": { - "signup_form_pending": true, - "onboarding_flow_pending": false + "signup_form_pending": "boolean", + "onboarding_flow_pending": "boolean" } } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -239,339 +100,130 @@ 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 + + + + + +
+ +Object list + + + + +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 + + + + + +Enables or disables experimental lazy connection + + + + + + +
+
+ + +
+ +Object list + + + + +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' \ -H 'Content-Type: application/json' \ -H 'Authorization: Token ' \ --data-raw '{ + "id": "ch8i4ug6lnn4g9hqv7l0", "settings": { "peer_login_expiration_enabled": true, "peer_login_expiration": 43200, @@ -597,384 +249,57 @@ curl -X PUT https://api.netbird.io/api/accounts/{accountId} \ }, "lazy_connection_enabled": true }, + "domain": "netbird.io", + "domain_category": "private", + "created_at": "2023-05-05T09:00:35.477782Z", + "created_by": "google-oauth2|277474792786460067937", "onboarding": { "signup_form_pending": true, "onboarding_flow_pending": false } }' ``` - -```js -const axios = require('axios'); -let data = JSON.stringify({ - "settings": { - "peer_login_expiration_enabled": true, - "peer_login_expiration": 43200, - "peer_inactivity_expiration_enabled": true, - "peer_inactivity_expiration": 43200, - "regular_users_view_blocked": true, - "groups_propagation_enabled": true, - "jwt_groups_enabled": true, - "jwt_groups_claim_name": "roles", - "jwt_allow_groups": [ - "Administrators" - ], - "routing_peer_dns_resolution_enabled": true, - "dns_domain": "my-organization.org", - "network_range": "100.64.0.0/16", - "extra": { - "peer_approval_enabled": true, - "network_traffic_logs_enabled": true, - "network_traffic_logs_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "network_traffic_packet_counter_enabled": true - }, - "lazy_connection_enabled": true - }, - "onboarding": { - "signup_form_pending": true, - "onboarding_flow_pending": false - } -}); -let config = { - method: 'put', - maxBodyLength: Infinity, - url: '/api/accounts/{accountId}', - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': 'Token ' - }, - data : data -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/accounts/{accountId}" -payload = json.dumps({ - "settings": { - "peer_login_expiration_enabled": true, - "peer_login_expiration": 43200, - "peer_inactivity_expiration_enabled": true, - "peer_inactivity_expiration": 43200, - "regular_users_view_blocked": true, - "groups_propagation_enabled": true, - "jwt_groups_enabled": true, - "jwt_groups_claim_name": "roles", - "jwt_allow_groups": [ - "Administrators" - ], - "routing_peer_dns_resolution_enabled": true, - "dns_domain": "my-organization.org", - "network_range": "100.64.0.0/16", - "extra": { - "peer_approval_enabled": true, - "network_traffic_logs_enabled": true, - "network_traffic_logs_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "network_traffic_packet_counter_enabled": true - }, - "lazy_connection_enabled": true - }, - "onboarding": { - "signup_form_pending": true, - "onboarding_flow_pending": false - } -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("PUT", url, headers=headers, data=payload) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/accounts/{accountId}" - method := "PUT" - - payload := strings.NewReader(`{ - "settings": { - "peer_login_expiration_enabled": true, - "peer_login_expiration": 43200, - "peer_inactivity_expiration_enabled": true, - "peer_inactivity_expiration": 43200, - "regular_users_view_blocked": true, - "groups_propagation_enabled": true, - "jwt_groups_enabled": true, - "jwt_groups_claim_name": "roles", - "jwt_allow_groups": [ - "Administrators" - ], - "routing_peer_dns_resolution_enabled": true, - "dns_domain": "my-organization.org", - "network_range": "100.64.0.0/16", - "extra": { - "peer_approval_enabled": true, - "network_traffic_logs_enabled": true, - "network_traffic_logs_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "network_traffic_packet_counter_enabled": true - }, - "lazy_connection_enabled": true - }, - "onboarding": { - "signup_form_pending": true, - "onboarding_flow_pending": false - } -}`) - client := &http.Client { - } - req, err := http.NewRequest(method, url, payload) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Content-Type", "application/json") - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` - -```ruby -require "uri" -require "json" -require "net/http" - -url = URI("https://api.netbird.io/api/accounts/{accountId}") - -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true - -request = Net::HTTP::Put.new(url) -request["Content-Type"] = "application/json" -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -request.body = JSON.dump({ - "settings": { - "peer_login_expiration_enabled": true, - "peer_login_expiration": 43200, - "peer_inactivity_expiration_enabled": true, - "peer_inactivity_expiration": 43200, - "regular_users_view_blocked": true, - "groups_propagation_enabled": true, - "jwt_groups_enabled": true, - "jwt_groups_claim_name": "roles", - "jwt_allow_groups": [ - "Administrators" - ], - "routing_peer_dns_resolution_enabled": true, - "dns_domain": "my-organization.org", - "network_range": "100.64.0.0/16", - "extra": { - "peer_approval_enabled": true, - "network_traffic_logs_enabled": true, - "network_traffic_logs_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "network_traffic_packet_counter_enabled": true - }, - "lazy_connection_enabled": true - }, - "onboarding": { - "signup_form_pending": true, - "onboarding_flow_pending": false - } -}) -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "settings": { - "peer_login_expiration_enabled": true, - "peer_login_expiration": 43200, - "peer_inactivity_expiration_enabled": true, - "peer_inactivity_expiration": 43200, - "regular_users_view_blocked": true, - "groups_propagation_enabled": true, - "jwt_groups_enabled": true, - "jwt_groups_claim_name": "roles", - "jwt_allow_groups": [ - "Administrators" - ], - "routing_peer_dns_resolution_enabled": true, - "dns_domain": "my-organization.org", - "network_range": "100.64.0.0/16", - "extra": { - "peer_approval_enabled": true, - "network_traffic_logs_enabled": true, - "network_traffic_logs_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "network_traffic_packet_counter_enabled": true - }, - "lazy_connection_enabled": true - }, - "onboarding": { - "signup_form_pending": true, - "onboarding_flow_pending": false - } -}'); -Request request = new Request.Builder() - .url("https://api.netbird.io/api/accounts/{accountId}") - .method("PUT", body) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .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 => 'PUT', - CURLOPT_POSTFIELDS => '{ - "settings": { - "peer_login_expiration_enabled": true, - "peer_login_expiration": 43200, - "peer_inactivity_expiration_enabled": true, - "peer_inactivity_expiration": 43200, - "regular_users_view_blocked": true, - "groups_propagation_enabled": true, - "jwt_groups_enabled": true, - "jwt_groups_claim_name": "roles", - "jwt_allow_groups": [ - "Administrators" - ], - "routing_peer_dns_resolution_enabled": true, - "dns_domain": "my-organization.org", - "network_range": "100.64.0.0/16", - "extra": { - "peer_approval_enabled": true, - "network_traffic_logs_enabled": true, - "network_traffic_logs_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "network_traffic_packet_counter_enabled": true - }, - "lazy_connection_enabled": true - }, - "onboarding": { - "signup_form_pending": true, - "onboarding_flow_pending": false - } -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` - - - - - + + ```json {{ title: 'Example' }} { - "id": "ch8i4ug6lnn4g9hqv7l0", + "id": "string", "settings": { - "peer_login_expiration_enabled": true, - "peer_login_expiration": 43200, - "peer_inactivity_expiration_enabled": true, - "peer_inactivity_expiration": 43200, - "regular_users_view_blocked": true, - "groups_propagation_enabled": true, - "jwt_groups_enabled": true, - "jwt_groups_claim_name": "roles", + "peer_login_expiration_enabled": "boolean", + "peer_login_expiration": "integer", + "peer_inactivity_expiration_enabled": "boolean", + "peer_inactivity_expiration": "integer", + "regular_users_view_blocked": "boolean", + "groups_propagation_enabled": "boolean", + "jwt_groups_enabled": "boolean", + "jwt_groups_claim_name": "string", "jwt_allow_groups": [ - "Administrators" + "string" ], - "routing_peer_dns_resolution_enabled": true, - "dns_domain": "my-organization.org", - "network_range": "100.64.0.0/16", + "routing_peer_dns_resolution_enabled": "boolean", + "dns_domain": "string", + "network_range": "string", "extra": { - "peer_approval_enabled": true, - "network_traffic_logs_enabled": true, + "peer_approval_enabled": "boolean", + "network_traffic_logs_enabled": "boolean", "network_traffic_logs_groups": [ - "ch8i4ug6lnn4g9hqv7m0" + "string" ], - "network_traffic_packet_counter_enabled": true + "network_traffic_packet_counter_enabled": "boolean" }, - "lazy_connection_enabled": true + "lazy_connection_enabled": "boolean" }, - "domain": "netbird.io", - "domain_category": "private", - "created_at": "2023-05-05T09:00:35.477782Z", - "created_by": "google-oauth2|277474792786460067937", + "domain": "string", + "domain_category": "string", + "created_at": "string", + "created_by": "string", "onboarding": { - "signup_form_pending": true, - "onboarding_flow_pending": false + "signup_form_pending": "boolean", + "onboarding_flow_pending": "boolean" } } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -1013,10 +338,44 @@ 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 ' \ +``` + + + + + --- diff --git a/src/pages/ipa/resources/dns.mdx b/src/pages/ipa/resources/dns.mdx index 8ca013e2..7279ba62 100644 --- a/src/pages/ipa/resources/dns.mdx +++ b/src/pages/ipa/resources/dns.mdx @@ -1,189 +1,50 @@ 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 -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/dns/nameservers', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/dns/nameservers" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/dns/nameservers" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` - -```ruby -require "uri" -require "json" -require "net/http" - -url = URI("https://api.netbird.io/api/dns/nameservers") - -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true - -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/dns/nameservers") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/dns/nameservers', - 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": "ch8i4ug6lnn4g9hqv7m0", - "name": "Google DNS", - "description": "Google DNS servers", + "id": "string", + "name": "string", + "description": "string", "nameservers": [ { - "ip": "8.8.8.8", - "ns_type": "udp", - "port": 53 + "ip": "string", + "ns_type": "string", + "port": "integer" } ], - "enabled": true, + "enabled": "boolean", "groups": [ - "ch8i4ug6lnn4g9hqv7m0" + "string" ], - "primary": true, + "primary": "boolean", "domains": [ - "example.com" + "string" ], - "search_domains_enabled": true + "search_domains_enabled": "boolean" } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -209,98 +70,86 @@ 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' \ -H 'Content-Type: application/json' \ -H 'Authorization: Token ' \ --data-raw '{ + "id": "ch8i4ug6lnn4g9hqv7m0", "name": "Google DNS", "description": "Google DNS servers", "nameservers": [ @@ -321,297 +170,117 @@ curl -X POST https://api.netbird.io/api/dns/nameservers \ "search_domains_enabled": true }' ``` - -```js -const axios = require('axios'); -let data = JSON.stringify({ - "name": "Google DNS", - "description": "Google DNS servers", + + +```json {{ title: 'Example' }} +{ + "id": "string", + "name": "string", + "description": "string", "nameservers": [ { - "ip": "8.8.8.8", - "ns_type": "udp", - "port": 53 + "ip": "string", + "ns_type": "string", + "port": "integer" } ], - "enabled": true, + "enabled": "boolean", "groups": [ - "ch8i4ug6lnn4g9hqv7m0" + "string" ], - "primary": true, + "primary": "boolean", "domains": [ - "example.com" + "string" ], - "search_domains_enabled": true -}); -let config = { - method: 'post', - maxBodyLength: Infinity, - url: '/api/dns/nameservers', - 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); -}); + "search_domains_enabled": "boolean" +} ``` -```python -import requests -import json - -url = "https://api.netbird.io/api/dns/nameservers" -payload = json.dumps({ - "name": "Google DNS", - "description": "Google DNS servers", +```json {{ title: 'Schema' }} +{ + "id": "string", + "name": "string", + "description": "string", "nameservers": [ { - "ip": "8.8.8.8", - "ns_type": "udp", - "port": 53 + "ip": "string", + "ns_type": "string", + "port": "integer" } ], - "enabled": true, + "enabled": "boolean", "groups": [ - "ch8i4ug6lnn4g9hqv7m0" + "string" ], - "primary": true, + "primary": "boolean", "domains": [ - "example.com" + "string" ], - "search_domains_enabled": true -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' + "search_domains_enabled": "boolean" } +``` + -response = requests.request("POST", url, headers=headers, data=payload) + -print(response.text) -``` +
+--- -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) -func main() { +## Retrieve a Nameserver Group {{ tag: 'GET', label: '/api/dns/nameservers/{nsgroupId}' }} - url := "https://api.netbird.io/api/dns/nameservers" - method := "POST" - - payload := strings.NewReader(`{ - "name": "Google DNS", - "description": "Google DNS servers", - "nameservers": [ - { - "ip": "8.8.8.8", - "ns_type": "udp", - "port": 53 - } - ], - "enabled": true, - "groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "primary": true, - "domains": [ - "example.com" - ], - "search_domains_enabled": true -}`) - client := &http.Client { - } - req, err := http.NewRequest(method, url, payload) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Content-Type", "application/json") - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - 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" + +Get information about a Nameserver Groups -url = URI("https://api.netbird.io/api/dns/nameservers") +### Path Parameters -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 " + + +The unique identifier of a Nameserver Group + -request.body = JSON.dump({ - "name": "Google DNS", - "description": "Google DNS servers", - "nameservers": [ - { - "ip": "8.8.8.8", - "ns_type": "udp", - "port": 53 - } - ], - "enabled": true, - "groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "primary": true, - "domains": [ - "example.com" - ], - "search_domains_enabled": true -}) -response = https.request(request) -puts response.read_body -``` + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "name": "Google DNS", - "description": "Google DNS servers", - "nameservers": [ - { - "ip": "8.8.8.8", - "ns_type": "udp", - "port": 53 - } - ], - "enabled": true, - "groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "primary": true, - "domains": [ - "example.com" - ], - "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 ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/dns/nameservers', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'POST', - CURLOPT_POSTFIELDS => '{ - "name": "Google DNS", - "description": "Google DNS servers", - "nameservers": [ - { - "ip": "8.8.8.8", - "ns_type": "udp", - "port": 53 - } - ], - "enabled": true, - "groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "primary": true, - "domains": [ - "example.com" - ], - "search_domains_enabled": true -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' ``` - - - - - + + ```json {{ title: 'Example' }} { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "Google DNS", - "description": "Google DNS servers", + "id": "string", + "name": "string", + "description": "string", "nameservers": [ { - "ip": "8.8.8.8", - "ns_type": "udp", - "port": 53 + "ip": "string", + "ns_type": "string", + "port": "integer" } ], - "enabled": true, + "enabled": "boolean", "groups": [ - "ch8i4ug6lnn4g9hqv7m0" + "string" ], - "primary": true, + "primary": "boolean", "domains": [ - "example.com" + "string" ], - "search_domains_enabled": true + "search_domains_enabled": "boolean" } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -635,182 +304,96 @@ echo $response; "search_domains_enabled": "boolean" } ``` - - - - - + + + + --- -## 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 - - - - - - -```bash {{ title: 'cURL' }} -curl -X GET https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ --H 'Accept: application/json' \ --H 'Authorization: Token ' -``` +## Update a Nameserver Group {{ tag: 'PUT', label: '/api/dns/nameservers/{nsgroupId}' }} -```js -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/dns/nameservers/{nsgroupId}', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` -```python -import requests -import json + -url = "https://api.netbird.io/api/dns/nameservers/{nsgroupId}" + +Update/Replace a Nameserver Group -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} +### Path Parameters -response = requests.request("GET", url, headers=headers) -print(response.text) -``` + + +The unique identifier of a Nameserver Group + -```go -package main + -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) -func main() { +### Request-Body Parameters - url := "https://api.netbird.io/api/dns/nameservers/{nsgroupId}" - 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)) -} -``` + + +Name of nameserver group name + + +Description of the nameserver group + + -```ruby -require "uri" -require "json" -require "net/http" +
-url = URI("https://api.netbird.io/api/dns/nameservers/{nsgroupId}") +Nameserver list + -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true + + +Nameserver IP + + +Nameserver Type + + +Nameserver Port + -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " + -response = https.request(request) -puts response.read_body -``` + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/dns/nameservers/{nsgroupId}") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` +
+
+ +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. + -```php - 'https://api.netbird.io/api/dns/nameservers/{nsgroupId}', - 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' }} -{ + + + + +```bash {{ title: 'cURL' }} +curl -X PUT https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ "id": "ch8i4ug6lnn4g9hqv7m0", "name": "Google DNS", "description": "Google DNS servers", @@ -830,9 +413,11 @@ echo $response; "example.com" ], "search_domains_enabled": true -} +}' ``` -```json {{ title: 'Schema' }} + + +```json {{ title: 'Example' }} { "id": "string", "name": "string", @@ -855,417 +440,7 @@ echo $response; "search_domains_enabled": "boolean" } ``` - - - - -
- ---- - -## 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. - - -
- - - - - - -```bash {{ title: 'cURL' }} -curl -X PUT https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "name": "Google DNS", - "description": "Google DNS servers", - "nameservers": [ - { - "ip": "8.8.8.8", - "ns_type": "udp", - "port": 53 - } - ], - "enabled": true, - "groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "primary": true, - "domains": [ - "example.com" - ], - "search_domains_enabled": true -}' -``` - -```js -const axios = require('axios'); -let data = JSON.stringify({ - "name": "Google DNS", - "description": "Google DNS servers", - "nameservers": [ - { - "ip": "8.8.8.8", - "ns_type": "udp", - "port": 53 - } - ], - "enabled": true, - "groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "primary": true, - "domains": [ - "example.com" - ], - "search_domains_enabled": true -}); -let config = { - method: 'put', - maxBodyLength: Infinity, - url: '/api/dns/nameservers/{nsgroupId}', - 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 -import requests -import json - -url = "https://api.netbird.io/api/dns/nameservers/{nsgroupId}" -payload = json.dumps({ - "name": "Google DNS", - "description": "Google DNS servers", - "nameservers": [ - { - "ip": "8.8.8.8", - "ns_type": "udp", - "port": 53 - } - ], - "enabled": true, - "groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "primary": true, - "domains": [ - "example.com" - ], - "search_domains_enabled": true -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("PUT", url, headers=headers, data=payload) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/dns/nameservers/{nsgroupId}" - method := "PUT" - - payload := strings.NewReader(`{ - "name": "Google DNS", - "description": "Google DNS servers", - "nameservers": [ - { - "ip": "8.8.8.8", - "ns_type": "udp", - "port": 53 - } - ], - "enabled": true, - "groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "primary": true, - "domains": [ - "example.com" - ], - "search_domains_enabled": true -}`) - client := &http.Client { - } - req, err := http.NewRequest(method, url, payload) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Content-Type", "application/json") - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - 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/dns/nameservers/{nsgroupId}") - -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({ - "name": "Google DNS", - "description": "Google DNS servers", - "nameservers": [ - { - "ip": "8.8.8.8", - "ns_type": "udp", - "port": 53 - } - ], - "enabled": true, - "groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "primary": true, - "domains": [ - "example.com" - ], - "search_domains_enabled": true -}) -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "name": "Google DNS", - "description": "Google DNS servers", - "nameservers": [ - { - "ip": "8.8.8.8", - "ns_type": "udp", - "port": 53 - } - ], - "enabled": true, - "groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "primary": true, - "domains": [ - "example.com" - ], - "search_domains_enabled": true -}'); -Request request = new Request.Builder() - .url("https://api.netbird.io/api/dns/nameservers/{nsgroupId}") - .method("PUT", body) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/dns/nameservers/{nsgroupId}', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'PUT', - CURLOPT_POSTFIELDS => '{ - "name": "Google DNS", - "description": "Google DNS servers", - "nameservers": [ - { - "ip": "8.8.8.8", - "ns_type": "udp", - "port": 53 - } - ], - "enabled": true, - "groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "primary": true, - "domains": [ - "example.com" - ], - "search_domains_enabled": true -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` - - - - - -```json {{ title: 'Example' }} -{ - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "Google DNS", - "description": "Google DNS servers", - "nameservers": [ - { - "ip": "8.8.8.8", - "ns_type": "udp", - "port": 53 - } - ], - "enabled": true, - "groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "primary": true, - "domains": [ - "example.com" - ], - "search_domains_enabled": true -} -``` ```json {{ title: 'Schema' }} { "id": "string", @@ -1289,579 +464,139 @@ echo $response; "search_domains_enabled": "boolean" } ``` - - - - -
- ---- - - -## Delete a Nameserver Group {{ tag: 'DELETE' , label: '/api/dns/nameservers/{nsgroupId}' }} - - - - 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 ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'delete', - maxBodyLength: Infinity, - url: '/api/dns/nameservers/{nsgroupId}', - 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/dns/nameservers/{nsgroupId}" + -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() { +## Delete a Nameserver Group {{ tag: 'DELETE', label: '/api/dns/nameservers/{nsgroupId}' }} - url := "https://api.netbird.io/api/dns/nameservers/{nsgroupId}" - 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" + +Delete a Nameserver Group -url = URI("https://api.netbird.io/api/dns/nameservers/{nsgroupId}") +### Path Parameters -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true -request = Net::HTTP::Delete.new(url) -request["Authorization"] = "Token " + + +The unique identifier of a Nameserver Group + -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/dns/nameservers/{nsgroupId}") - .method("DELETE") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); + + +```bash {{ title: 'cURL' }} +curl -X DELETE https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ +-H 'Authorization: Token ' \ ``` + -```php - 'https://api.netbird.io/api/dns/nameservers/{nsgroupId}', - 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 DNS settings {{ tag: 'GET' , label: '/api/dns/settings' }} + +## Retrieve DNS settings {{ tag: 'GET', label: '/api/dns/settings' }} + - - Returns a DNS settings object - - - + +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 -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/dns/settings', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/dns/settings" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/dns/settings" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` - -```ruby -require "uri" -require "json" -require "net/http" - -url = URI("https://api.netbird.io/api/dns/settings") - -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true - -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/dns/settings") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/dns/settings', - 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' }} -{ - "items": { +[ + { "disabled_management_groups": [ - "ch8i4ug6lnn4g9hqv7m0" + "string" ] } -} +] ``` + ```json {{ title: 'Schema' }} -{ - "items": { +[ + { "disabled_management_groups": [ "string" ] } -} -``` - - - - - - ---- - - -## Update DNS Settings {{ tag: 'PUT' , label: '/api/dns/settings' }} - - - - 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' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "disabled_management_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ] -}' -``` - -```js -const axios = require('axios'); -let data = JSON.stringify({ - "disabled_management_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ] -}); -let config = { - method: 'put', - maxBodyLength: Infinity, - url: '/api/dns/settings', - 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 -import requests -import json + -url = "https://api.netbird.io/api/dns/settings" -payload = json.dumps({ - "disabled_management_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ] -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("PUT", url, headers=headers, data=payload) - -print(response.text) -``` + +--- -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) -func main() { +## Update DNS Settings {{ tag: 'PUT', label: '/api/dns/settings' }} - url := "https://api.netbird.io/api/dns/settings" - method := "PUT" - - payload := strings.NewReader(`{ - "disabled_management_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ] -}`) - 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() - 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" + +Updates a DNS settings object -url = URI("https://api.netbird.io/api/dns/settings") +### Request-Body Parameters -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 " + + +Groups whose DNS management is disabled + -request.body = JSON.dump({ - "disabled_management_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ] -}) -response = https.request(request) -puts response.read_body -``` + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "disabled_management_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ] -}'); -Request request = new Request.Builder() - .url("https://api.netbird.io/api/dns/settings") - .method("PUT", body) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/dns/settings', - 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 => '{ + + +```bash {{ title: 'cURL' }} +curl -X PUT https://api.netbird.io/api/dns/settings \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ "disabled_management_groups": [ "ch8i4ug6lnn4g9hqv7m0" ] -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; +}' ``` - - - - - + + ```json {{ title: 'Example' }} { "disabled_management_groups": [ - "ch8i4ug6lnn4g9hqv7m0" + "string" ] } ``` + ```json {{ title: 'Schema' }} { "disabled_management_groups": [ @@ -1869,10 +604,9 @@ echo $response; ] } ``` - - - - - + + + + --- diff --git a/src/pages/ipa/resources/events.mdx b/src/pages/ipa/resources/events.mdx index 18cd79d6..e9554e5c 100644 --- a/src/pages/ipa/resources/events.mdx +++ b/src/pages/ipa/resources/events.mdx @@ -1,183 +1,48 @@ 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 -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/events/audit', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/events/audit" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/events/audit" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` - -```ruby -require "uri" -require "json" -require "net/http" - -url = URI("https://api.netbird.io/api/events/audit") - -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true - -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/events/audit") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/events/audit', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'GET', - CURLOPT_HTTPHEADER => array( - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` - - - - - + + ```json {{ title: 'Example' }} [ { - "id": 10, - "timestamp": "2023-05-05T10:04:37.473542Z", - "activity": "Route created", - "activity_code": "route.add", - "initiator_id": "google-oauth2|123456789012345678901", - "initiator_name": "John Doe", - "initiator_email": "demo@netbird.io", - "target_id": "chad9d86lnnc59g18ou0", + "id": "string", + "timestamp": "string", + "activity": "string", + "activity_code": "string", + "initiator_id": "string", + "initiator_name": "string", + "initiator_email": "string", + "target_id": "string", "meta": { - "name": "my route", - "network_range": "10.64.0.0/24", - "peer_id": "chacbco6lnnbn6cg5s91" + "type": "object", + "additionalProperties": "string", + "example": { + "name": "my route", + "network_range": "10.64.0.0/24", + "peer_id": "chacbco6lnnbn6cg5s91" + } } } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -190,7 +55,6 @@ echo $response; "initiator_email": "string", "target_id": "string", "meta": { - "description": "The metadata of the event", "type": "object", "additionalProperties": "string", "example": { @@ -202,295 +66,138 @@ 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 + +### Path 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 -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/events/network-traffic', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/events/network-traffic" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/events/network-traffic" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` - -```ruby -require "uri" -require "json" -require "net/http" - -url = URI("https://api.netbird.io/api/events/network-traffic") - -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true - -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/events/network-traffic") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/events/network-traffic', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'GET', - CURLOPT_HTTPHEADER => array( - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` - - - - - + + ```json {{ title: 'Example' }} { "data": [ { - "flow_id": "61092452-b17c-4b14-b7cf-a2158c549826", - "reporter_id": "ch8i4ug6lnn4g9hqv7m0", + "flow_id": "string", + "reporter_id": "string", "source": { - "id": "ch8i4ug6lnn4g9hqv7m0", - "type": "PEER", - "name": "My Peer", + "id": "string", + "type": "string", + "name": "string", "geo_location": { - "city_name": "Berlin", - "country_code": "DE" + "city_name": "string", + "country_code": "string" }, - "os": "Linux", - "address": "100.64.0.10:51820", - "dns_label": "*.mydomain.com" + "os": "string", + "address": "string", + "dns_label": "string" }, "destination": { - "id": "ch8i4ug6lnn4g9hqv7m0", - "type": "PEER", - "name": "My Peer", + "id": "string", + "type": "string", + "name": "string", "geo_location": { - "city_name": "Berlin", - "country_code": "DE" + "city_name": "string", + "country_code": "string" }, - "os": "Linux", - "address": "100.64.0.10:51820", - "dns_label": "*.mydomain.com" + "os": "string", + "address": "string", + "dns_label": "string" }, "user": { - "id": "google-oauth2|123456789012345678901", - "email": "alice@netbird.io", - "name": "Alice Smith" + "id": "string", + "email": "string", + "name": "string" }, "policy": { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "All to All" + "id": "string", + "name": "string" }, "icmp": { - "type": 8, - "code": 0 + "type": "integer", + "code": "integer" }, - "protocol": 6, - "direction": "INGRESS", - "rx_bytes": 1234, - "rx_packets": 5, - "tx_bytes": 1234, - "tx_packets": 5, + "protocol": "integer", + "direction": "string", + "rx_bytes": "integer", + "rx_packets": "integer", + "tx_bytes": "integer", + "tx_packets": "integer", "events": [ { - "type": "TYPE_START", - "timestamp": {} + "type": "string", + "timestamp": "string" } ] } ], - "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": "integer", + "page_size": "integer", + "total_records": "integer", + "total_pages": "integer" } ``` + ```json {{ title: 'Schema' }} { "data": [ @@ -554,10 +261,9 @@ 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..eff158ff 100644 --- a/src/pages/ipa/resources/geo-locations.mdx +++ b/src/pages/ipa/resources/geo-locations.mdx @@ -1,364 +1,89 @@ 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 -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/locations/countries', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/locations/countries" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/locations/countries" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` - -```ruby -require "uri" -require "json" -require "net/http" - -url = URI("https://api.netbird.io/api/locations/countries") - -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true - -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/locations/countries") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/locations/countries', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'GET', - CURLOPT_HTTPHEADER => array( - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` - - - - - + + ```json {{ title: 'Example' }} [ - "DE" + "string" ] ``` + ```json {{ title: 'Schema' }} [ "string" ] ``` - - - - - - ---- - + -## 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 - - - - - - - - - - -```bash {{ title: 'cURL' }} -curl -X GET https://api.netbird.io/api/locations/countries/{country}/cities \ --H 'Accept: application/json' \ --H 'Authorization: Token ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/locations/countries/{country}/cities', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/locations/countries/{country}/cities" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/locations/countries/{country}/cities" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") + +--- - 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" +## List all city names by country {{ tag: 'GET', label: '/api/locations/countries/{country}/cities' }} -url = URI("https://api.netbird.io/api/locations/countries/{country}/cities") -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true + -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " + +Get a list of all English city names for a given country code -response = https.request(request) -puts response.read_body -``` +### Path Parameters -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -Request request = new Request.Builder() - .url("https://api.netbird.io/api/locations/countries/{country}/cities") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + + -```php - -$curl = curl_init(); + -curl_setopt_array($curl, array( - CURLOPT_URL => 'https://api.netbird.io/api/locations/countries/{country}/cities', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'GET', - CURLOPT_HTTPHEADER => array( - 'Accept: application/json', - 'Authorization: Token ' - ), -)); + -$response = curl_exec($curl); - -curl_close($curl); -echo $response; + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/locations/countries/{country}/cities \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' ``` - - - - - + + ```json {{ title: 'Example' }} { - "geoname_id": 2950158, - "city_name": "Berlin" + "geoname_id": "integer", + "city_name": "string" } ``` + ```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..aff952c5 100644 --- a/src/pages/ipa/resources/groups.mdx +++ b/src/pages/ipa/resources/groups.mdx @@ -1,187 +1,48 @@ 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 -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/groups', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/groups" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/groups" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` - -```ruby -require "uri" -require "json" -require "net/http" - -url = URI("https://api.netbird.io/api/groups") - -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true - -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/groups") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/groups', - 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": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api", + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string", "peers": [ { - "id": "chacbco6lnnbn6cg5s90", - "name": "stage-host-1" + "id": "string", + "name": "string" } ], "resources": [ { - "id": "chacdk86lnnboviihd7g", - "type": "host" + "id": "string", + "type": "string" } ] } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -205,275 +66,77 @@ echo $response; } ] ``` - - - - - + ---- + + +--- -## 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 - - - - - -
- -
-
- - - - - - -```bash {{ title: 'cURL' }} -curl -X POST https://api.netbird.io/api/groups \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "name": "devs", - "peers": [ - "ch8i4ug6lnn4g9hqv7m1" - ], - "resources": [ - { - "id": "chacdk86lnnboviihd7g", - "type": "host" - } - ] -}' -``` -```js -const axios = require('axios'); -let data = JSON.stringify({ - "name": "devs", - "peers": [ - "ch8i4ug6lnn4g9hqv7m1" - ], - "resources": [ - { - "id": "chacdk86lnnboviihd7g", - "type": "host" - } - ] -}); -let config = { - method: 'post', - maxBodyLength: Infinity, - url: '/api/groups', - 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); -}); -``` +## Create a Group {{ tag: 'POST', label: '/api/groups' }} -```python -import requests -import json -url = "https://api.netbird.io/api/groups" -payload = json.dumps({ - "name": "devs", - "peers": [ - "ch8i4ug6lnn4g9hqv7m1" - ], - "resources": [ - { - "id": "chacdk86lnnboviihd7g", - "type": "host" - } - ] -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} + -response = requests.request("POST", url, headers=headers, data=payload) + +Creates a group -print(response.text) -``` +### Request-Body Parameters -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) + + +Group name identifier + + +List of peers ids + + -func main() { +
- url := "https://api.netbird.io/api/groups" - method := "POST" - - payload := strings.NewReader(`{ - "name": "devs", - "peers": [ - "ch8i4ug6lnn4g9hqv7m1" - ], - "resources": [ - { - "id": "chacdk86lnnboviihd7g", - "type": "host" - } - ] -}`) - 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() +Object list + - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` + + +ID of the resource + + +Type of the resource + -```ruby -require "uri" -require "json" -require "net/http" + -url = URI("https://api.netbird.io/api/groups") + -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({ - "name": "devs", - "peers": [ - "ch8i4ug6lnn4g9hqv7m1" - ], - "resources": [ - { - "id": "chacdk86lnnboviihd7g", - "type": "host" - } - ] -}) -response = https.request(request) -puts response.read_body -``` + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ + + +```bash {{ title: 'cURL' }} +curl -X POST https://api.netbird.io/api/groups \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ + "id": "ch8i4ug6lnn4g9hqv7m0", "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api", "peers": [ - "ch8i4ug6lnn4g9hqv7m1" - ], - "resources": [ { - "id": "chacdk86lnnboviihd7g", - "type": "host" + "id": "chacbco6lnnbn6cg5s90", + "name": "stage-host-1" } - ] -}'); -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 ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/groups', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'POST', - CURLOPT_POSTFIELDS => '{ - "name": "devs", - "peers": [ - "ch8i4ug6lnn4g9hqv7m1" ], "resources": [ { @@ -481,45 +144,32 @@ curl_setopt_array($curl, array( "type": "host" } ] -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; +}' ``` - - - - - + + ```json {{ title: 'Example' }} { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api", + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string", "peers": [ { - "id": "chacbco6lnnbn6cg5s90", - "name": "stage-host-1" + "id": "string", + "name": "string" } ], "resources": [ { - "id": "chacdk86lnnboviihd7g", - "type": "host" + "id": "string", + "type": "string" } ] } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -541,201 +191,66 @@ echo $response; ] } ``` - - - - -
+
---- + +
+--- -## Retrieve a Group {{ tag: 'GET' , label: '/api/groups/{groupId}' }} - - - - 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 -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/groups/{groupId}', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/groups/{groupId}" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` - -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) -func main() { +## Retrieve a Group {{ tag: 'GET', label: '/api/groups/{groupId}' }} - url := "https://api.netbird.io/api/groups/{groupId}" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` + -```ruby -require "uri" -require "json" -require "net/http" + +Get information about a group -url = URI("https://api.netbird.io/api/groups/{groupId}") +### Path Parameters -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 " + + +The unique identifier of a group + -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/groups/{groupId}") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/groups/{groupId}', - 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; + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/groups/{groupId} \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' ``` - - - - - + + ```json {{ title: 'Example' }} { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api", + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string", "peers": [ { - "id": "chacbco6lnnbn6cg5s90", - "name": "stage-host-1" + "id": "string", + "name": "string" } ], "resources": [ { - "id": "chacdk86lnnboviihd7g", - "type": "host" + "id": "string", + "type": "string" } ] } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -757,283 +272,88 @@ 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 - - - - - -
- -
-
- - - - - - -```bash {{ title: 'cURL' }} -curl -X PUT https://api.netbird.io/api/groups/{groupId} \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "name": "devs", - "peers": [ - "ch8i4ug6lnn4g9hqv7m1" - ], - "resources": [ - { - "id": "chacdk86lnnboviihd7g", - "type": "host" - } - ] -}' -``` -```js -const axios = require('axios'); -let data = JSON.stringify({ - "name": "devs", - "peers": [ - "ch8i4ug6lnn4g9hqv7m1" - ], - "resources": [ - { - "id": "chacdk86lnnboviihd7g", - "type": "host" - } - ] -}); -let config = { - method: 'put', - maxBodyLength: Infinity, - url: '/api/groups/{groupId}', - 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); -}); -``` + +Update/Replace a group -```python -import requests -import json +### Path Parameters -url = "https://api.netbird.io/api/groups/{groupId}" -payload = json.dumps({ - "name": "devs", - "peers": [ - "ch8i4ug6lnn4g9hqv7m1" - ], - "resources": [ - { - "id": "chacdk86lnnboviihd7g", - "type": "host" - } - ] -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} -response = requests.request("PUT", url, headers=headers, data=payload) + + +The unique identifier of a group + -print(response.text) -``` + -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) +### Request-Body Parameters -func main() { - url := "https://api.netbird.io/api/groups/{groupId}" - method := "PUT" - - payload := strings.NewReader(`{ - "name": "devs", - "peers": [ - "ch8i4ug6lnn4g9hqv7m1" - ], - "resources": [ - { - "id": "chacdk86lnnboviihd7g", - "type": "host" - } - ] -}`) - 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() + + +Group name identifier + + +List of peers ids + + - 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" +Object list + -url = URI("https://api.netbird.io/api/groups/{groupId}") + + +ID of the resource + + +Type of the resource + -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({ - "name": "devs", - "peers": [ - "ch8i4ug6lnn4g9hqv7m1" - ], - "resources": [ - { - "id": "chacdk86lnnboviihd7g", - "type": "host" - } - ] -}) -response = https.request(request) -puts response.read_body -``` +
+
+ +
-```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ + + + + +```bash {{ title: 'cURL' }} +curl -X PUT https://api.netbird.io/api/groups/{groupId} \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ + "id": "ch8i4ug6lnn4g9hqv7m0", "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api", "peers": [ - "ch8i4ug6lnn4g9hqv7m1" - ], - "resources": [ { - "id": "chacdk86lnnboviihd7g", - "type": "host" + "id": "chacbco6lnnbn6cg5s90", + "name": "stage-host-1" } - ] -}'); -Request request = new Request.Builder() - .url("https://api.netbird.io/api/groups/{groupId}") - .method("PUT", body) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/groups/{groupId}', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'PUT', - CURLOPT_POSTFIELDS => '{ - "name": "devs", - "peers": [ - "ch8i4ug6lnn4g9hqv7m1" ], "resources": [ { @@ -1041,45 +361,32 @@ curl_setopt_array($curl, array( "type": "host" } ] -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; +}' ``` - - - - - + + ```json {{ title: 'Example' }} { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api", + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string", "peers": [ { - "id": "chacbco6lnnbn6cg5s90", - "name": "stage-host-1" + "id": "string", + "name": "string" } ], "resources": [ { - "id": "chacdk86lnnboviihd7g", - "type": "host" + "id": "string", + "type": "string" } ] } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -1101,174 +408,44 @@ echo $response; ] } ``` - - - - -
- ---- + + -## Delete a Group {{ tag: 'DELETE' , label: '/api/groups/{groupId}' }} - - - - 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 ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'delete', - maxBodyLength: Infinity, - url: '/api/groups/{groupId}', - 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/groups/{groupId}" - -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() { +## Delete a Group {{ tag: 'DELETE', label: '/api/groups/{groupId}' }} - url := "https://api.netbird.io/api/groups/{groupId}" - 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" + +Delete a group -url = URI("https://api.netbird.io/api/groups/{groupId}") +### Path Parameters -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true -request = Net::HTTP::Delete.new(url) -request["Authorization"] = "Token " + + +The unique identifier of a group + -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/groups/{groupId}") - .method("DELETE") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); + + +```bash {{ title: 'cURL' }} +curl -X DELETE https://api.netbird.io/api/groups/{groupId} \ +-H 'Authorization: Token ' \ ``` + -```php - 'https://api.netbird.io/api/groups/{groupId}', - 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/ingress-ports.mdx b/src/pages/ipa/resources/ingress-ports.mdx index e9c19ce5..593bbb98 100644 --- a/src/pages/ipa/resources/ingress-ports.mdx +++ b/src/pages/ipa/resources/ingress-ports.mdx @@ -1,201 +1,60 @@ 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 - - - - - - -```bash {{ title: 'cURL' }} -curl -X GET https://api.netbird.io/api/peers/{peerId}/ingress/ports \ --H 'Accept: application/json' \ --H 'Authorization: Token ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/peers/{peerId}/ingress/ports', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/peers/{peerId}/ingress/ports" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/peers/{peerId}/ingress/ports" - 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)) -} -``` + +Returns a list of all ingress port allocations for a peer -```ruby -require "uri" -require "json" -require "net/http" +### Path Parameters -url = URI("https://api.netbird.io/api/peers/{peerId}/ingress/ports") -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true + + +The unique identifier of a peer + + +Filters ingress port allocations by name + -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -response = https.request(request) -puts response.read_body -``` + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/peers/{peerId}/ingress/ports") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/peers/{peerId}/ingress/ports', - 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; + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/peers/{peerId}/ingress/ports \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' ``` - - - - - + + ```json {{ title: 'Example' }} [ { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "Ingress Peer Allocation 1", - "ingress_peer_id": "x7p3kqf2rdd8j5zxw4n9", - "region": "germany", - "enabled": true, - "ingress_ip": "192.34.0.123", + "id": "string", + "name": "string", + "ingress_peer_id": "string", + "region": "string", + "enabled": "boolean", + "ingress_ip": "string", "port_range_mappings": [ { - "translated_start": 80, - "translated_end": 320, - "ingress_start": 1080, - "ingress_end": 1320, - "protocol": "tcp" + "translated_start": "integer", + "translated_end": "integer", + "ingress_start": "integer", + "ingress_end": "integer", + "protocol": "string" } ] } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -217,358 +76,102 @@ 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 - - - - - -
- -
-
- - - - - - -```bash {{ title: 'cURL' }} -curl -X POST https://api.netbird.io/api/peers/{peerId}/ingress/ports \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "name": "Ingress Port Allocation 1", - "enabled": true, - "port_ranges": [ - { - "start": 80, - "end": 320, - "protocol": "tcp" - } - ], - "direct_port": { - "count": 5, - "protocol": "udp" - } -}' -``` -```js -const axios = require('axios'); -let data = JSON.stringify({ - "name": "Ingress Port Allocation 1", - "enabled": true, - "port_ranges": [ - { - "start": 80, - "end": 320, - "protocol": "tcp" - } - ], - "direct_port": { - "count": 5, - "protocol": "udp" - } -}); -let config = { - method: 'post', - maxBodyLength: Infinity, - url: '/api/peers/{peerId}/ingress/ports', - 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); -}); -``` + +Creates a new ingress port allocation for a peer -```python -import requests -import json +### Path Parameters -url = "https://api.netbird.io/api/peers/{peerId}/ingress/ports" -payload = json.dumps({ - "name": "Ingress Port Allocation 1", - "enabled": true, - "port_ranges": [ - { - "start": 80, - "end": 320, - "protocol": "tcp" - } - ], - "direct_port": { - "count": 5, - "protocol": "udp" - } -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} -response = requests.request("POST", url, headers=headers, data=payload) + + +The unique identifier of a peer + -print(response.text) -``` + -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) +### Request-Body Parameters -func main() { - url := "https://api.netbird.io/api/peers/{peerId}/ingress/ports" - method := "POST" - - payload := strings.NewReader(`{ - "name": "Ingress Port Allocation 1", - "enabled": true, - "port_ranges": [ - { - "start": 80, - "end": 320, - "protocol": "tcp" - } - ], - "direct_port": { - "count": 5, - "protocol": "udp" - } -}`) - 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() + + +Name of the ingress port allocation + + +Indicates if an ingress port allocation is enabled + + - 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" +List of port ranges that are forwarded by the ingress peer + -url = URI("https://api.netbird.io/api/peers/{peerId}/ingress/ports") + + +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 + -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({ - "name": "Ingress Port Allocation 1", - "enabled": true, - "port_ranges": [ - { - "start": 80, - "end": 320, - "protocol": "tcp" - } - ], - "direct_port": { - "count": 5, - "protocol": "udp" - } -}) -response = https.request(request) -puts response.read_body -``` +
+
+ -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "name": "Ingress Port Allocation 1", - "enabled": true, - "port_ranges": [ - { - "start": 80, - "end": 320, - "protocol": "tcp" - } - ], - "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 ") - .build(); -Response response = client.newCall(request).execute(); -``` +
-```php - 'https://api.netbird.io/api/peers/{peerId}/ingress/ports', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'POST', - CURLOPT_POSTFIELDS => '{ - "name": "Ingress Port Allocation 1", - "enabled": true, - "port_ranges": [ - { - "start": 80, - "end": 320, - "protocol": "tcp" - } - ], - "direct_port": { - "count": 5, - "protocol": "udp" - } -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` +Direct port allocation + - - - - -```json {{ title: 'Example' }} -{ + + +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' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ "id": "ch8i4ug6lnn4g9hqv7m0", "name": "Ingress Peer Allocation 1", "ingress_peer_id": "x7p3kqf2rdd8j5zxw4n9", @@ -584,9 +187,11 @@ echo $response; "protocol": "tcp" } ] -} +}' ``` -```json {{ title: 'Schema' }} + + +```json {{ title: 'Example' }} { "id": "string", "name": "string", @@ -605,203 +210,87 @@ echo $response; ] } ``` - - - - -
- ---- - - -## 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 - - - - - - -```bash {{ title: 'cURL' }} -curl -X GET https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId} \ --H 'Accept: application/json' \ --H 'Authorization: Token ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/peers/{peerId}/ingress/ports/{allocationId}', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json -url = "https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' +```json {{ title: 'Schema' }} +{ + "id": "string", + "name": "string", + "ingress_peer_id": "string", + "region": "string", + "enabled": "boolean", + "ingress_ip": "string", + "port_range_mappings": [ + { + "translated_start": "integer", + "translated_end": "integer", + "ingress_start": "integer", + "ingress_end": "integer", + "protocol": "string" + } + ] } +``` + -response = requests.request("GET", url, headers=headers) + -print(response.text) -``` + +--- -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) -func main() { +## Retrieve a Port Allocation {{ tag: 'GET', label: '/api/peers/{peerId}/ingress/ports/{allocationId}' }} - url := "https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` + -```ruby -require "uri" -require "json" -require "net/http" + +Get information about an ingress port allocation -url = URI("https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}") +### Path Parameters -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 " + + +The unique identifier of a peer + + +The unique identifier of an ingress port allocation + -response = https.request(request) -puts response.read_body -``` + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}', - 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; + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId} \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' ``` - - - - - + + ```json {{ title: 'Example' }} { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "Ingress Peer Allocation 1", - "ingress_peer_id": "x7p3kqf2rdd8j5zxw4n9", - "region": "germany", - "enabled": true, - "ingress_ip": "192.34.0.123", + "id": "string", + "name": "string", + "ingress_peer_id": "string", + "region": "string", + "enabled": "boolean", + "ingress_ip": "string", "port_range_mappings": [ { - "translated_start": 80, - "translated_end": 320, - "ingress_start": 1080, - "ingress_end": 1320, - "protocol": "tcp" + "translated_start": "integer", + "translated_end": "integer", + "ingress_start": "integer", + "ingress_end": "integer", + "protocol": "string" } ] } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -821,362 +310,105 @@ 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 - - - - - -
- -
-
- - - - - - -```bash {{ title: 'cURL' }} -curl -X PUT https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId} \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "name": "Ingress Port Allocation 1", - "enabled": true, - "port_ranges": [ - { - "start": 80, - "end": 320, - "protocol": "tcp" - } - ], - "direct_port": { - "count": 5, - "protocol": "udp" - } -}' -``` -```js -const axios = require('axios'); -let data = JSON.stringify({ - "name": "Ingress Port Allocation 1", - "enabled": true, - "port_ranges": [ - { - "start": 80, - "end": 320, - "protocol": "tcp" - } - ], - "direct_port": { - "count": 5, - "protocol": "udp" - } -}); -let config = { - method: 'put', - maxBodyLength: Infinity, - url: '/api/peers/{peerId}/ingress/ports/{allocationId}', - 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); -}); -``` + +Update information about an ingress port allocation -```python -import requests -import json +### Path Parameters -url = "https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}" -payload = json.dumps({ - "name": "Ingress Port Allocation 1", - "enabled": true, - "port_ranges": [ - { - "start": 80, - "end": 320, - "protocol": "tcp" - } - ], - "direct_port": { - "count": 5, - "protocol": "udp" - } -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} -response = requests.request("PUT", url, headers=headers, data=payload) + + +The unique identifier of a peer + + +The unique identifier of an ingress port allocation + -print(response.text) -``` + -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) +### Request-Body Parameters -func main() { - url := "https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}" - method := "PUT" - - payload := strings.NewReader(`{ - "name": "Ingress Port Allocation 1", - "enabled": true, - "port_ranges": [ - { - "start": 80, - "end": 320, - "protocol": "tcp" - } - ], - "direct_port": { - "count": 5, - "protocol": "udp" - } -}`) - 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() + + +Name of the ingress port allocation + + +Indicates if an ingress port allocation is enabled + + - 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" +List of port ranges that are forwarded by the ingress peer + -url = URI("https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}") + + +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 + -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({ - "name": "Ingress Port Allocation 1", - "enabled": true, - "port_ranges": [ - { - "start": 80, - "end": 320, - "protocol": "tcp" - } - ], - "direct_port": { - "count": 5, - "protocol": "udp" - } -}) -response = https.request(request) -puts response.read_body -``` +
+
+ -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "name": "Ingress Port Allocation 1", - "enabled": true, - "port_ranges": [ - { - "start": 80, - "end": 320, - "protocol": "tcp" - } - ], - "direct_port": { - "count": 5, - "protocol": "udp" - } -}'); -Request request = new Request.Builder() - .url("https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}") - .method("PUT", body) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` +
-```php - 'https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'PUT', - CURLOPT_POSTFIELDS => '{ - "name": "Ingress Port Allocation 1", - "enabled": true, - "port_ranges": [ - { - "start": 80, - "end": 320, - "protocol": "tcp" - } - ], - "direct_port": { - "count": 5, - "protocol": "udp" - } -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` +Direct port allocation + - - - - -```json {{ title: 'Example' }} -{ + + +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' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ "id": "ch8i4ug6lnn4g9hqv7m0", "name": "Ingress Peer Allocation 1", "ingress_peer_id": "x7p3kqf2rdd8j5zxw4n9", @@ -1192,9 +424,11 @@ echo $response; "protocol": "tcp" } ] -} +}' ``` -```json {{ title: 'Schema' }} + + +```json {{ title: 'Example' }} { "id": "string", "name": "string", @@ -1213,357 +447,109 @@ echo $response; ] } ``` - - - - -
- ---- - - -## 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 - - - - - - -```bash {{ title: 'cURL' }} -curl -X DELETE https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId} \ --H 'Authorization: Token ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'delete', - maxBodyLength: Infinity, - url: '/api/peers/{peerId}/ingress/ports/{allocationId}', - 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/peers/{peerId}/ingress/ports/{allocationId}" - -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/peers/{peerId}/ingress/ports/{allocationId}" - 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/peers/{peerId}/ingress/ports/{allocationId}") - -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/peers/{peerId}/ingress/ports/{allocationId}") - .method("DELETE") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); +```json {{ title: 'Schema' }} +{ + "id": "string", + "name": "string", + "ingress_peer_id": "string", + "region": "string", + "enabled": "boolean", + "ingress_ip": "string", + "port_range_mappings": [ + { + "translated_start": "integer", + "translated_end": "integer", + "ingress_start": "integer", + "ingress_end": "integer", + "protocol": "string" + } + ] +} ``` + -```php - 'https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}', - 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; -``` + - - - - - - --- -## 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 ' -``` +## Delete a Port Allocation {{ tag: 'DELETE', label: '/api/peers/{peerId}/ingress/ports/{allocationId}' }} -```js -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/ingress/peers', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` -```python -import requests -import json + -url = "https://api.netbird.io/api/ingress/peers" + +Delete an ingress port allocation -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} +### Path Parameters -response = requests.request("GET", url, headers=headers) -print(response.text) -``` + + +The unique identifier of a peer + + +The unique identifier of an ingress port allocation + -```go -package main + -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) + -func main() { + + +```bash {{ title: 'cURL' }} +curl -X DELETE https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId} \ +-H 'Authorization: Token ' \ +``` + - url := "https://api.netbird.io/api/ingress/peers" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() + - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` + +--- -```ruby -require "uri" -require "json" -require "net/http" -url = URI("https://api.netbird.io/api/ingress/peers") -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true +## List all Ingress Peers {{ tag: 'GET', label: '/api/ingress/peers' }} -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " -response = https.request(request) -puts response.read_body -``` + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/ingress/peers") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + +Returns a list of all ingress peers + -```php - 'https://api.netbird.io/api/ingress/peers', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'GET', - CURLOPT_HTTPHEADER => array( - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/ingress/peers \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' ``` - - - - - + + ```json {{ title: 'Example' }} [ { - "id": "ch8i4ug6lnn4g9hqv7m0", - "peer_id": "x7p3kqf2rdd8j5zxw4n9", - "ingress_ip": "192.34.0.123", + "id": "string", + "peer_id": "string", + "ingress_ip": "string", "available_ports": { - "tcp": 45765, - "udp": 50000 + "tcp": "integer", + "udp": "integer" }, - "enabled": true, - "connected": true, - "fallback": true, - "region": "germany" + "enabled": "boolean", + "connected": "boolean", + "fallback": "boolean", + "region": "string" } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -1581,236 +567,49 @@ echo $response; } ] ``` - - - - - - ---- - - -## 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 - - - - - - - - - -```bash {{ title: 'cURL' }} -curl -X POST https://api.netbird.io/api/ingress/peers \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "peer_id": "ch8i4ug6lnn4g9hqv7m0", - "enabled": true, - "fallback": true -}' -``` + -```js -const axios = require('axios'); -let data = JSON.stringify({ - "peer_id": "ch8i4ug6lnn4g9hqv7m0", - "enabled": true, - "fallback": true -}); -let config = { - method: 'post', - maxBodyLength: Infinity, - url: '/api/ingress/peers', - 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 -import requests -import json - -url = "https://api.netbird.io/api/ingress/peers" -payload = json.dumps({ - "peer_id": "ch8i4ug6lnn4g9hqv7m0", - "enabled": true, - "fallback": true -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("POST", url, headers=headers, data=payload) - -print(response.text) -``` + -```go -package main + +--- -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) -func main() { - url := "https://api.netbird.io/api/ingress/peers" - method := "POST" - - payload := strings.NewReader(`{ - "peer_id": "ch8i4ug6lnn4g9hqv7m0", - "enabled": true, - "fallback": true -}`) - client := &http.Client { - } - req, err := http.NewRequest(method, url, payload) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Content-Type", "application/json") - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() +## Create a Ingress Peer {{ tag: 'POST', label: '/api/ingress/peers' }} - 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/ingress/peers") + +Creates a new ingress peer -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true +### Request-Body Parameters -request = Net::HTTP::Post.new(url) -request["Content-Type"] = "application/json" -request["Accept"] = "application/json" -request["Authorization"] = "Token " -request.body = JSON.dump({ - "peer_id": "ch8i4ug6lnn4g9hqv7m0", - "enabled": true, - "fallback": true -}) -response = https.request(request) -puts response.read_body -``` + + +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 + -```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 -}'); -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 ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/ingress/peers', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'POST', - CURLOPT_POSTFIELDS => '{ - "peer_id": "ch8i4ug6lnn4g9hqv7m0", - "enabled": true, - "fallback": true -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` + - - - - -```json {{ title: 'Example' }} -{ + + +```bash {{ title: 'cURL' }} +curl -X POST https://api.netbird.io/api/ingress/peers \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ "id": "ch8i4ug6lnn4g9hqv7m0", "peer_id": "x7p3kqf2rdd8j5zxw4n9", "ingress_ip": "192.34.0.123", @@ -1822,9 +621,11 @@ echo $response; "connected": true, "fallback": true, "region": "germany" -} +}' ``` -```json {{ title: 'Schema' }} + + +```json {{ title: 'Example' }} { "id": "string", "peer_id": "string", @@ -1838,196 +639,77 @@ echo $response; "fallback": "boolean", "region": "string" } -``` - - - - - - ---- - - -## 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 - - - - - - -```bash {{ title: 'cURL' }} -curl -X GET https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ --H 'Accept: application/json' \ --H 'Authorization: Token ' ``` -```js -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/ingress/peers/{ingressPeerId}', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/ingress/peers/{ingressPeerId}" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' +```json {{ title: 'Schema' }} +{ + "id": "string", + "peer_id": "string", + "ingress_ip": "string", + "available_ports": { + "tcp": "integer", + "udp": "integer" + }, + "enabled": "boolean", + "connected": "boolean", + "fallback": "boolean", + "region": "string" } +``` + -response = requests.request("GET", url, headers=headers) + -print(response.text) -``` + +--- -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) -func main() { +## Retrieve a Ingress Peer {{ tag: 'GET', label: '/api/ingress/peers/{ingressPeerId}' }} - url := "https://api.netbird.io/api/ingress/peers/{ingressPeerId}" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` + -```ruby -require "uri" -require "json" -require "net/http" + +Get information about an ingress peer -url = URI("https://api.netbird.io/api/ingress/peers/{ingressPeerId}") +### Path Parameters -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 " + + +The unique identifier of an ingress peer + -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/ingress/peers/{ingressPeerId}") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/ingress/peers/{ingressPeerId}', - 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; + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' ``` - - - - - + + ```json {{ title: 'Example' }} { - "id": "ch8i4ug6lnn4g9hqv7m0", - "peer_id": "x7p3kqf2rdd8j5zxw4n9", - "ingress_ip": "192.34.0.123", + "id": "string", + "peer_id": "string", + "ingress_ip": "string", "available_ports": { - "tcp": 45765, - "udp": 50000 + "tcp": "integer", + "udp": "integer" }, - "enabled": true, - "connected": true, - "fallback": true, - "region": "germany" + "enabled": "boolean", + "connected": "boolean", + "fallback": "boolean", + "region": "string" } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -2043,232 +725,57 @@ echo $response; "region": "string" } ``` - - - - - - ---- + + -## 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 - - - - - - - - - -```bash {{ title: 'cURL' }} -curl -X PUT https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "enabled": true, - "fallback": true -}' -``` - -```js -const axios = require('axios'); -let data = JSON.stringify({ - "enabled": true, - "fallback": true -}); -let config = { - method: 'put', - maxBodyLength: Infinity, - url: '/api/ingress/peers/{ingressPeerId}', - 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 -import requests -import json -url = "https://api.netbird.io/api/ingress/peers/{ingressPeerId}" -payload = json.dumps({ - "enabled": true, - "fallback": true -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} -response = requests.request("PUT", url, headers=headers, data=payload) +## Update a Ingress Peer {{ tag: 'PUT', label: '/api/ingress/peers/{ingressPeerId}' }} -print(response.text) -``` -```go -package main + -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) + +Update information about an ingress peer -func main() { +### Path Parameters - url := "https://api.netbird.io/api/ingress/peers/{ingressPeerId}" - method := "PUT" - - payload := strings.NewReader(`{ - "enabled": true, - "fallback": true -}`) - client := &http.Client { - } - req, err := http.NewRequest(method, url, payload) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Content-Type", "application/json") - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - 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)) -} -``` + + +The unique identifier of an ingress peer + -```ruby -require "uri" -require "json" -require "net/http" + -url = URI("https://api.netbird.io/api/ingress/peers/{ingressPeerId}") -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true +### Request-Body Parameters -request = Net::HTTP::Put.new(url) -request["Content-Type"] = "application/json" -request["Accept"] = "application/json" -request["Authorization"] = "Token " -request.body = JSON.dump({ - "enabled": true, - "fallback": true -}) -response = https.request(request) -puts response.read_body -``` + + +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 + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "enabled": true, - "fallback": true -}'); -Request request = new Request.Builder() - .url("https://api.netbird.io/api/ingress/peers/{ingressPeerId}") - .method("PUT", body) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/ingress/peers/{ingressPeerId}', - 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 => '{ - "enabled": true, - "fallback": true -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` + - - - - -```json {{ title: 'Example' }} -{ + + +```bash {{ title: 'cURL' }} +curl -X PUT https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ "id": "ch8i4ug6lnn4g9hqv7m0", "peer_id": "x7p3kqf2rdd8j5zxw4n9", "ingress_ip": "192.34.0.123", @@ -2280,9 +787,11 @@ echo $response; "connected": true, "fallback": true, "region": "germany" -} +}' ``` -```json {{ title: 'Schema' }} + + +```json {{ title: 'Example' }} { "id": "string", "peer_id": "string", @@ -2297,174 +806,60 @@ echo $response; "region": "string" } ``` - - - - - - ---- - - -## Delete a Ingress Peer {{ tag: 'DELETE' , label: '/api/ingress/peers/{ingressPeerId}' }} - - - - 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 ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'delete', - maxBodyLength: Infinity, - url: '/api/ingress/peers/{ingressPeerId}', - 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/ingress/peers/{ingressPeerId}" - -headers = { - 'Authorization': 'Token ' +```json {{ title: 'Schema' }} +{ + "id": "string", + "peer_id": "string", + "ingress_ip": "string", + "available_ports": { + "tcp": "integer", + "udp": "integer" + }, + "enabled": "boolean", + "connected": "boolean", + "fallback": "boolean", + "region": "string" } +``` + -response = requests.request("DELETE", url, headers=headers) + -print(response.text) -``` + +--- -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) -func main() { +## Delete a Ingress Peer {{ tag: 'DELETE', label: '/api/ingress/peers/{ingressPeerId}' }} - url := "https://api.netbird.io/api/ingress/peers/{ingressPeerId}" - 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" + +Delete an ingress peer -url = URI("https://api.netbird.io/api/ingress/peers/{ingressPeerId}") +### Path Parameters -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true -request = Net::HTTP::Delete.new(url) -request["Authorization"] = "Token " + + +The unique identifier of an ingress peer + -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/ingress/peers/{ingressPeerId}") - .method("DELETE") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); + + +```bash {{ title: 'cURL' }} +curl -X DELETE https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ +-H 'Authorization: Token ' \ ``` + -```php - 'https://api.netbird.io/api/ingress/peers/{ingressPeerId}', - 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/networks.mdx b/src/pages/ipa/resources/networks.mdx index d0c19c67..0be1099f 100644 --- a/src/pages/ipa/resources/networks.mdx +++ b/src/pages/ipa/resources/networks.mdx @@ -1,183 +1,44 @@ 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 -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/networks', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/networks" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/networks" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` - -```ruby -require "uri" -require "json" -require "net/http" - -url = URI("https://api.netbird.io/api/networks") - -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true - -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/networks") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/networks', - 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": "chacdk86lnnboviihd7g", + "id": "string", "routers": [ - "ch8i4ug6lnn4g9hqv7m0" + "string" ], - "routing_peers_count": 2, + "routing_peers_count": "integer", "resources": [ - "ch8i4ug6lnn4g9hqv7m1" + "string" ], "policies": [ - "ch8i4ug6lnn4g9hqv7m2" + "string" ], - "name": "Remote Network 1", - "description": "A remote network that needs to be accessed" + "name": "string", + "description": "string" } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -197,224 +58,46 @@ echo $response; } ] ``` - - - - - - ---- - - -## Create a Network {{ tag: 'POST' , label: '/api/networks' }} - - - - 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' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "name": "Remote Network 1", - "description": "A remote network that needs to be accessed" -}' -``` - -```js -const axios = require('axios'); -let data = JSON.stringify({ - "name": "Remote Network 1", - "description": "A remote network that needs to be accessed" -}); -let config = { - method: 'post', - maxBodyLength: Infinity, - url: '/api/networks', - 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 -import requests -import json - -url = "https://api.netbird.io/api/networks" -payload = json.dumps({ - "name": "Remote Network 1", - "description": "A remote network that needs to be accessed" -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("POST", url, headers=headers, data=payload) + -print(response.text) -``` + -```go -package main + +--- -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) -func main() { - url := "https://api.netbird.io/api/networks" - method := "POST" - - payload := strings.NewReader(`{ - "name": "Remote Network 1", - "description": "A remote network that needs to be accessed" -}`) - 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() +## Create a Network {{ tag: 'POST', label: '/api/networks' }} - 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/networks") + +Creates a Network -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true +### Request-Body Parameters -request = Net::HTTP::Post.new(url) -request["Content-Type"] = "application/json" -request["Accept"] = "application/json" -request["Authorization"] = "Token " -request.body = JSON.dump({ - "name": "Remote Network 1", - "description": "A remote network that needs to be accessed" -}) -response = https.request(request) -puts response.read_body -``` + + +Network name + + +Network description + -```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" -}'); -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 ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/networks', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'POST', - CURLOPT_POSTFIELDS => '{ - "name": "Remote Network 1", - "description": "A remote network that needs to be accessed" -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` + - - - - -```json {{ title: 'Example' }} -{ + + +```bash {{ title: 'cURL' }} +curl -X POST https://api.netbird.io/api/networks \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ "id": "chacdk86lnnboviihd7g", "routers": [ "ch8i4ug6lnn4g9hqv7m0" @@ -428,9 +111,11 @@ echo $response; ], "name": "Remote Network 1", "description": "A remote network that needs to be accessed" -} +}' ``` -```json {{ title: 'Schema' }} + + +```json {{ title: 'Example' }} { "id": "string", "routers": [ @@ -446,198 +131,81 @@ echo $response; "name": "string", "description": "string" } -``` - - - - - - ---- - - -## Retrieve a Network {{ tag: 'GET' , label: '/api/networks/{networkId}' }} - - - - 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 -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/networks/{networkId}', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); ``` -```python -import requests -import json - -url = "https://api.netbird.io/api/networks/{networkId}" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' +```json {{ title: 'Schema' }} +{ + "id": "string", + "routers": [ + "string" + ], + "routing_peers_count": "integer", + "resources": [ + "string" + ], + "policies": [ + "string" + ], + "name": "string", + "description": "string" } +``` + -response = requests.request("GET", url, headers=headers) + -print(response.text) -``` + +--- -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) -func main() { +## Retrieve a Network {{ tag: 'GET', label: '/api/networks/{networkId}' }} - url := "https://api.netbird.io/api/networks/{networkId}" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` + -```ruby -require "uri" -require "json" -require "net/http" + +Get information about a Network -url = URI("https://api.netbird.io/api/networks/{networkId}") +### Path Parameters -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 " + + +The unique identifier of a network + -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/networks/{networkId}") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/networks/{networkId}', - 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; + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/networks/{networkId} \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' ``` - - - - - + + ```json {{ title: 'Example' }} { - "id": "chacdk86lnnboviihd7g", + "id": "string", "routers": [ - "ch8i4ug6lnn4g9hqv7m0" + "string" ], - "routing_peers_count": 2, + "routing_peers_count": "integer", "resources": [ - "ch8i4ug6lnn4g9hqv7m1" + "string" ], "policies": [ - "ch8i4ug6lnn4g9hqv7m2" + "string" ], - "name": "Remote Network 1", - "description": "A remote network that needs to be accessed" + "name": "string", + "description": "string" } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -655,232 +223,57 @@ echo $response; "description": "string" } ``` - - - - - - ---- + + -## 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 - - - - - - - - - -```bash {{ title: 'cURL' }} -curl -X PUT https://api.netbird.io/api/networks/{networkId} \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "name": "Remote Network 1", - "description": "A remote network that needs to be accessed" -}' -``` - -```js -const axios = require('axios'); -let data = JSON.stringify({ - "name": "Remote Network 1", - "description": "A remote network that needs to be accessed" -}); -let config = { - method: 'put', - maxBodyLength: Infinity, - url: '/api/networks/{networkId}', - 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 -import requests -import json -url = "https://api.netbird.io/api/networks/{networkId}" -payload = json.dumps({ - "name": "Remote Network 1", - "description": "A remote network that needs to be accessed" -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} -response = requests.request("PUT", url, headers=headers, data=payload) +## Update a Network {{ tag: 'PUT', label: '/api/networks/{networkId}' }} -print(response.text) -``` -```go -package main + -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) + +Update/Replace a Network -func main() { +### Path Parameters - url := "https://api.netbird.io/api/networks/{networkId}" - method := "PUT" - - payload := strings.NewReader(`{ - "name": "Remote Network 1", - "description": "A remote network that needs to be accessed" -}`) - 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() - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` + + +The unique identifier of a network + -```ruby -require "uri" -require "json" -require "net/http" + -url = URI("https://api.netbird.io/api/networks/{networkId}") -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true +### Request-Body Parameters -request = Net::HTTP::Put.new(url) -request["Content-Type"] = "application/json" -request["Accept"] = "application/json" -request["Authorization"] = "Token " -request.body = JSON.dump({ - "name": "Remote Network 1", - "description": "A remote network that needs to be accessed" -}) -response = https.request(request) -puts response.read_body -``` + + +Network name + + +Network description + -```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" -}'); -Request request = new Request.Builder() - .url("https://api.netbird.io/api/networks/{networkId}") - .method("PUT", body) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/networks/{networkId}', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'PUT', - CURLOPT_POSTFIELDS => '{ - "name": "Remote Network 1", - "description": "A remote network that needs to be accessed" -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` + - - - - -```json {{ title: 'Example' }} -{ + + +```bash {{ title: 'cURL' }} +curl -X PUT https://api.netbird.io/api/networks/{networkId} \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ "id": "chacdk86lnnboviihd7g", "routers": [ "ch8i4ug6lnn4g9hqv7m0" @@ -894,8 +287,28 @@ echo $response; ], "name": "Remote Network 1", "description": "A remote network that needs to be accessed" +}' +``` + + +```json {{ title: 'Example' }} +{ + "id": "string", + "routers": [ + "string" + ], + "routing_peers_count": "integer", + "resources": [ + "string" + ], + "policies": [ + "string" + ], + "name": "string", + "description": "string" } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -913,365 +326,101 @@ 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 - - - - - - -```bash {{ title: 'cURL' }} -curl -X DELETE https://api.netbird.io/api/networks/{networkId} \ --H 'Authorization: Token ' -``` -```js -const axios = require('axios'); - -let config = { - method: 'delete', - maxBodyLength: Infinity, - url: '/api/networks/{networkId}', - headers: { - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` + +Delete a network -```python -import requests -import json +### Path Parameters -url = "https://api.netbird.io/api/networks/{networkId}" -headers = { - 'Authorization': 'Token ' -} + + +The unique identifier of a network + -response = requests.request("DELETE", url, headers=headers) + -print(response.text) + + + + +```bash {{ title: 'cURL' }} +curl -X DELETE https://api.netbird.io/api/networks/{networkId} \ +-H 'Authorization: Token ' \ ``` + -```go -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) - - 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)) -} -``` +## List all Network Resources {{ tag: 'GET', label: '/api/networks/{networkId}/resources' }} -```ruby -require "uri" -require "json" -require "net/http" -url = URI("https://api.netbird.io/api/networks/{networkId}") + -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true + +Returns a list of all resources in a network -request = Net::HTTP::Delete.new(url) -request["Authorization"] = "Token " +### Path Parameters -response = https.request(request) -puts response.read_body -``` -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); + + +The unique identifier of a network + -Request request = new Request.Builder() - .url("https://api.netbird.io/api/networks/{networkId}") - .method("DELETE") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/networks/{networkId}', - 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; -``` + - - - - - - - ---- - - -## 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 - - - - - - + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/networks/{networkId}/resources \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` - -```js -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/networks/{networkId}/resources', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/networks/{networkId}/resources" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/networks/{networkId}/resources" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` - -```ruby -require "uri" -require "json" -require "net/http" - -url = URI("https://api.netbird.io/api/networks/{networkId}/resources") - -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true - -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/networks/{networkId}/resources") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/networks/{networkId}/resources', - 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": "chacdk86lnnboviihd7g", - "type": "host", + "id": "string", + "type": "string", "groups": [ { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api" + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string" } ], - "name": "Remote Resource 1", - "description": "A remote resource inside network 1", - "address": "1.1.1.1", - "enabled": true + "name": "string", + "description": "string", + "address": "string", + "enabled": "boolean" } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -1293,282 +442,66 @@ 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 - - - - - - - - - -```bash {{ title: 'cURL' }} -curl -X POST https://api.netbird.io/api/networks/{networkId}/resources \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "name": "Remote Resource 1", - "description": "A remote resource inside network 1", - "address": "1.1.1.1", - "enabled": true, - "groups": [ - "chacdk86lnnboviihd70" - ] -}' -``` -```js -const axios = require('axios'); -let data = JSON.stringify({ - "name": "Remote Resource 1", - "description": "A remote resource inside network 1", - "address": "1.1.1.1", - "enabled": true, - "groups": [ - "chacdk86lnnboviihd70" - ] -}); -let config = { - method: 'post', - maxBodyLength: Infinity, - url: '/api/networks/{networkId}/resources', - 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); -}); -``` + +Creates a Network Resource -```python -import requests -import json +### Path Parameters -url = "https://api.netbird.io/api/networks/{networkId}/resources" -payload = json.dumps({ - "name": "Remote Resource 1", - "description": "A remote resource inside network 1", - "address": "1.1.1.1", - "enabled": true, - "groups": [ - "chacdk86lnnboviihd70" - ] -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} -response = requests.request("POST", url, headers=headers, data=payload) + + +The unique identifier of a network + -print(response.text) -``` + -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) +### Request-Body Parameters -func main() { - url := "https://api.netbird.io/api/networks/{networkId}/resources" - method := "POST" - - payload := strings.NewReader(`{ - "name": "Remote Resource 1", - "description": "A remote resource inside network 1", - "address": "1.1.1.1", - "enabled": true, - "groups": [ - "chacdk86lnnboviihd70" - ] -}`) - 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() + + - 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" +Object list + -url = URI("https://api.netbird.io/api/networks/{networkId}/resources") + -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({ - "name": "Remote Resource 1", - "description": "A remote resource inside network 1", - "address": "1.1.1.1", - "enabled": true, - "groups": [ - "chacdk86lnnboviihd70" - ] -}) -response = https.request(request) -puts response.read_body -``` +
+
-```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "name": "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 ") - .build(); -Response response = client.newCall(request).execute(); -``` +
-```php - 'https://api.netbird.io/api/networks/{networkId}/resources', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'POST', - CURLOPT_POSTFIELDS => '{ - "name": "Remote Resource 1", - "description": "A remote resource inside network 1", - "address": "1.1.1.1", - "enabled": true, - "groups": [ - "chacdk86lnnboviihd70" - ] -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` + -
- - - -```json {{ title: 'Example' }} -{ + + +```bash {{ title: 'cURL' }} +curl -X POST https://api.netbird.io/api/networks/{networkId}/resources \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ "id": "chacdk86lnnboviihd7g", "type": "host", "groups": [ @@ -1584,9 +517,11 @@ echo $response; "description": "A remote resource inside network 1", "address": "1.1.1.1", "enabled": true -} +}' ``` -```json {{ title: 'Schema' }} + + +```json {{ title: 'Example' }} { "id": "string", "type": "string", @@ -1605,203 +540,87 @@ echo $response; "enabled": "boolean" } ``` - - - - -
- ---- - - -## 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 - - - - - - -```bash {{ title: 'cURL' }} -curl -X GET https://api.netbird.io/api/networks/{networkId}/resources/{resourceId} \ --H 'Accept: application/json' \ --H 'Authorization: Token ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/networks/{networkId}/resources/{resourceId}', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}" -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' +```json {{ title: 'Schema' }} +{ + "id": "string", + "type": "string", + "groups": [ + { + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string" + } + ], + "name": "string", + "description": "string", + "address": "string", + "enabled": "boolean" } +``` + -response = requests.request("GET", url, headers=headers) + -print(response.text) -``` + +--- -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) -func main() { +## Retrieve a Network Resource {{ tag: 'GET', label: '/api/networks/{networkId}/resources/{resourceId}' }} - url := "https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` + -```ruby -require "uri" -require "json" -require "net/http" + +Get information about a Network Resource -url = URI("https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}") +### Path Parameters -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 " + + +The unique identifier of a network + + +The unique identifier of a network resource + -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/networks/{networkId}/resources/{resourceId}") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}', - 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; + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/networks/{networkId}/resources/{resourceId} \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' ``` - - - - - + + ```json {{ title: 'Example' }} { - "id": "chacdk86lnnboviihd7g", - "type": "host", + "id": "string", + "type": "string", "groups": [ { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api" + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string" } ], - "name": "Remote Resource 1", - "description": "A remote resource inside network 1", - "address": "1.1.1.1", - "enabled": true + "name": "string", + "description": "string", + "address": "string", + "enabled": "boolean" } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -1821,286 +640,69 @@ 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 - - - - - - - - - -```bash {{ title: 'cURL' }} -curl -X PUT https://api.netbird.io/api/networks/{networkId}/resources/{resourceId} \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "name": "Remote Resource 1", - "description": "A remote resource inside network 1", - "address": "1.1.1.1", - "enabled": true, - "groups": [ - "chacdk86lnnboviihd70" - ] -}' -``` -```js -const axios = require('axios'); -let data = JSON.stringify({ - "name": "Remote Resource 1", - "description": "A remote resource inside network 1", - "address": "1.1.1.1", - "enabled": true, - "groups": [ - "chacdk86lnnboviihd70" - ] -}); -let config = { - method: 'put', - maxBodyLength: Infinity, - url: '/api/networks/{networkId}/resources/{resourceId}', - 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); -}); -``` + +Update a Network Resource -```python -import requests -import json +### Path Parameters -url = "https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}" -payload = json.dumps({ - "name": "Remote Resource 1", - "description": "A remote resource inside network 1", - "address": "1.1.1.1", - "enabled": true, - "groups": [ - "chacdk86lnnboviihd70" - ] -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} -response = requests.request("PUT", url, headers=headers, data=payload) + + +The unique identifier of a network + + +The unique identifier of a resource + -print(response.text) -``` + -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) +### Request-Body Parameters -func main() { - url := "https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}" - method := "PUT" - - payload := strings.NewReader(`{ - "name": "Remote Resource 1", - "description": "A remote resource inside network 1", - "address": "1.1.1.1", - "enabled": true, - "groups": [ - "chacdk86lnnboviihd70" - ] -}`) - 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() + + - 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" +Object list + -url = URI("https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}") + -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({ - "name": "Remote Resource 1", - "description": "A remote resource inside network 1", - "address": "1.1.1.1", - "enabled": true, - "groups": [ - "chacdk86lnnboviihd70" - ] -}) -response = https.request(request) -puts response.read_body -``` +
+
-```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "name": "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/{resourceId}") - .method("PUT", body) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` +
-```php - 'https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'PUT', - CURLOPT_POSTFIELDS => '{ - "name": "Remote Resource 1", - "description": "A remote resource inside network 1", - "address": "1.1.1.1", - "enabled": true, - "groups": [ - "chacdk86lnnboviihd70" - ] -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` + -
- - - -```json {{ title: 'Example' }} -{ + + +```bash {{ title: 'cURL' }} +curl -X PUT https://api.netbird.io/api/networks/{networkId}/resources/{resourceId} \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ "id": "chacdk86lnnboviihd7g", "type": "host", "groups": [ @@ -2116,9 +718,11 @@ echo $response; "description": "A remote resource inside network 1", "address": "1.1.1.1", "enabled": true -} +}' ``` -```json {{ title: 'Schema' }} + + +```json {{ title: 'Example' }} { "id": "string", "type": "string", @@ -2137,362 +741,117 @@ echo $response; "enabled": "boolean" } ``` - - - - -
- ---- - -## Delete a Network Resource {{ tag: 'DELETE' , label: '/api/networks/{networkId}/resources/{resourceId}' }} - - - - Delete a network resource - - ### Path Parameters - - - - - - - - - - - - - - -```bash {{ title: 'cURL' }} -curl -X DELETE https://api.netbird.io/api/networks/{networkId}/resources/{resourceId} \ --H 'Authorization: Token ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'delete', - maxBodyLength: Infinity, - url: '/api/networks/{networkId}/resources/{resourceId}', - 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/networks/{networkId}/resources/{resourceId}" - -headers = { - 'Authorization': 'Token ' +```json {{ title: 'Schema' }} +{ + "id": "string", + "type": "string", + "groups": [ + { + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string" + } + ], + "name": "string", + "description": "string", + "address": "string", + "enabled": "boolean" } - -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/networks/{networkId}/resources/{resourceId}" - 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/networks/{networkId}/resources/{resourceId}") +## Delete a Network Resource {{ tag: 'DELETE', label: '/api/networks/{networkId}/resources/{resourceId}' }} -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 -``` + +Delete a network resource -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); +### Path Parameters -Request request = new Request.Builder() - .url("https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}") - .method("DELETE") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` -```php - 'https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}', - 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; -``` + + - - - - - - +
+ ---- + + -## 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 - - - - - - + + ```bash {{ title: 'cURL' }} -curl -X GET https://api.netbird.io/api/networks/{networkId}/routers \ --H 'Accept: application/json' \ --H 'Authorization: Token ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/networks/{networkId}/routers', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); +curl -X DELETE https://api.netbird.io/api/networks/{networkId}/resources/{resourceId} \ +-H 'Authorization: Token ' \ ``` + -```python -import requests -import json - -url = "https://api.netbird.io/api/networks/{networkId}/routers" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) + -print(response.text) -``` + +--- -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) -func main() { +## List all Network Routers {{ tag: 'GET', label: '/api/networks/{networkId}/routers' }} - url := "https://api.netbird.io/api/networks/{networkId}/routers" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` + -```ruby -require "uri" -require "json" -require "net/http" + +Returns a list of all routers in a network -url = URI("https://api.netbird.io/api/networks/{networkId}/routers") +### Path Parameters -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 " + + +The unique identifier of a network + -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/networks/{networkId}/routers") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/networks/{networkId}/routers', - 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; + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/networks/{networkId}/routers \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' ``` - - - - - + + ```json {{ title: 'Example' }} [ { - "id": "chacdk86lnnboviihd7g", - "peer": "chacbco6lnnbn6cg5s91", + "id": "string", + "peer": "string", "peer_groups": [ - "chacbco6lnnbn6cg5s91" + "string" ], - "metric": 9999, - "masquerade": true, - "enabled": true + "metric": "integer", + "masquerade": "boolean", + "enabled": "boolean" } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -2507,255 +866,67 @@ echo $response; } ] ``` - - - - - + ---- - - -## 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 - - - - - - - - - -```bash {{ title: 'cURL' }} -curl -X POST https://api.netbird.io/api/networks/{networkId}/routers \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "metric": 9999, - "masquerade": true, - "enabled": true -}' -``` + +--- -```js -const axios = require('axios'); -let data = JSON.stringify({ - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "metric": 9999, - "masquerade": true, - "enabled": true -}); -let config = { - method: 'post', - maxBodyLength: Infinity, - url: '/api/networks/{networkId}/routers', - 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 -import requests -import json -url = "https://api.netbird.io/api/networks/{networkId}/routers" -payload = json.dumps({ - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "metric": 9999, - "masquerade": true, - "enabled": true -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} +## Create a Network Router {{ tag: 'POST', label: '/api/networks/{networkId}/routers' }} -response = requests.request("POST", url, headers=headers, data=payload) -print(response.text) -``` + -```go -package main + +Creates a Network Router -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) +### Path Parameters -func main() { - url := "https://api.netbird.io/api/networks/{networkId}/routers" - method := "POST" - - payload := strings.NewReader(`{ - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "metric": 9999, - "masquerade": true, - "enabled": true -}`) - client := &http.Client { - } - req, err := http.NewRequest(method, url, payload) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Content-Type", "application/json") - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() + + +The unique identifier of a network + - 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/networks/{networkId}/routers") +### Request-Body Parameters -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 " + + +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 + -request.body = JSON.dump({ - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "metric": 9999, - "masquerade": true, - "enabled": true -}) -response = https.request(request) -puts response.read_body -``` + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "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 ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/networks/{networkId}/routers', - 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 => '{ + + +```bash {{ title: 'cURL' }} +curl -X POST https://api.netbird.io/api/networks/{networkId}/routers \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ + "id": "chacdk86lnnboviihd7g", "peer": "chacbco6lnnbn6cg5s91", "peer_groups": [ "chacbco6lnnbn6cg5s91" @@ -2763,36 +934,23 @@ curl_setopt_array($curl, array( "metric": 9999, "masquerade": true, "enabled": true -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; +}' ``` - - - - - + + ```json {{ title: 'Example' }} { - "id": "chacdk86lnnboviihd7g", - "peer": "chacbco6lnnbn6cg5s91", + "id": "string", + "peer": "string", "peer_groups": [ - "chacbco6lnnbn6cg5s91" + "string" ], - "metric": 9999, - "masquerade": true, - "enabled": true + "metric": "integer", + "masquerade": "boolean", + "enabled": "boolean" } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -2805,196 +963,60 @@ echo $response; "enabled": "boolean" } ``` - - - - - - ---- - - -## 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 - - - - - - -```bash {{ title: 'cURL' }} -curl -X GET https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ --H 'Accept: application/json' \ --H 'Authorization: Token ' -``` + -```js -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/networks/{networkId}/routers/{routerId}', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/networks/{networkId}/routers/{routerId}" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) + +--- -print(response.text) -``` -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) +## Retrieve a Network Router {{ tag: 'GET', label: '/api/networks/{networkId}/routers/{routerId}' }} -func main() { - url := "https://api.netbird.io/api/networks/{networkId}/routers/{routerId}" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` + -```ruby -require "uri" -require "json" -require "net/http" + +Get information about a Network Router -url = URI("https://api.netbird.io/api/networks/{networkId}/routers/{routerId}") +### Path Parameters -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 " + + +The unique identifier of a network + + +The unique identifier of a router + -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/networks/{networkId}/routers/{routerId}") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/networks/{networkId}/routers/{routerId}', - 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; + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' ``` - - - - - + + ```json {{ title: 'Example' }} { - "id": "chacdk86lnnboviihd7g", - "peer": "chacbco6lnnbn6cg5s91", + "id": "string", + "peer": "string", "peer_groups": [ - "chacbco6lnnbn6cg5s91" + "string" ], - "metric": 9999, - "masquerade": true, - "enabled": true + "metric": "integer", + "masquerade": "boolean", + "enabled": "boolean" } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -3007,259 +1029,70 @@ echo $response; "enabled": "boolean" } ``` - - - - - - ---- - + -## 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 - - - - - - - - - -```bash {{ title: 'cURL' }} -curl -X PUT https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "metric": 9999, - "masquerade": true, - "enabled": true -}' -``` + +--- -```js -const axios = require('axios'); -let data = JSON.stringify({ - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "metric": 9999, - "masquerade": true, - "enabled": true -}); -let config = { - method: 'put', - maxBodyLength: Infinity, - url: '/api/networks/{networkId}/routers/{routerId}', - 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 -import requests -import json -url = "https://api.netbird.io/api/networks/{networkId}/routers/{routerId}" -payload = json.dumps({ - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "metric": 9999, - "masquerade": true, - "enabled": true -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} +## Update a Network Router {{ tag: 'PUT', label: '/api/networks/{networkId}/routers/{routerId}' }} -response = requests.request("PUT", url, headers=headers, data=payload) -print(response.text) -``` + -```go -package main + +Update a Network Router -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) +### Path Parameters -func main() { - url := "https://api.netbird.io/api/networks/{networkId}/routers/{routerId}" - method := "PUT" - - payload := strings.NewReader(`{ - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "metric": 9999, - "masquerade": true, - "enabled": true -}`) - client := &http.Client { - } - req, err := http.NewRequest(method, url, payload) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Content-Type", "application/json") - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() + + +The unique identifier of a network + + +The unique identifier of a router + - 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/networks/{networkId}/routers/{routerId}") +### Request-Body Parameters -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 " + + +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 + -request.body = JSON.dump({ - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "metric": 9999, - "masquerade": true, - "enabled": true -}) -response = https.request(request) -puts response.read_body -``` + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "metric": 9999, - "masquerade": true, - "enabled": true -}'); -Request request = new Request.Builder() - .url("https://api.netbird.io/api/networks/{networkId}/routers/{routerId}") - .method("PUT", body) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/networks/{networkId}/routers/{routerId}', - 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 => '{ + + +```bash {{ title: 'cURL' }} +curl -X PUT https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ + "id": "chacdk86lnnboviihd7g", "peer": "chacbco6lnnbn6cg5s91", "peer_groups": [ "chacbco6lnnbn6cg5s91" @@ -3267,36 +1100,23 @@ curl_setopt_array($curl, array( "metric": 9999, "masquerade": true, "enabled": true -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; +}' ``` - - - - - + + ```json {{ title: 'Example' }} { - "id": "chacdk86lnnboviihd7g", - "peer": "chacbco6lnnbn6cg5s91", + "id": "string", + "peer": "string", "peer_groups": [ - "chacbco6lnnbn6cg5s91" + "string" ], - "metric": 9999, - "masquerade": true, - "enabled": true + "metric": "integer", + "masquerade": "boolean", + "enabled": "boolean" } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -3309,354 +1129,86 @@ echo $response; "enabled": "boolean" } ``` - - - - - - ---- + + -## Delete a Network Router {{ tag: 'DELETE' , label: '/api/networks/{networkId}/routers/{routerId}' }} - - - - Delete a network router - - ### Path Parameters - - - - - - - - - - - - - - -```bash {{ title: 'cURL' }} -curl -X DELETE https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ --H 'Authorization: Token ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'delete', - maxBodyLength: Infinity, - url: '/api/networks/{networkId}/routers/{routerId}', - 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/networks/{networkId}/routers/{routerId}" - -headers = { - 'Authorization': 'Token ' -} + +--- -response = requests.request("DELETE", url, headers=headers) -print(response.text) -``` -```go -package main +## Delete a Network Router {{ tag: 'DELETE', label: '/api/networks/{networkId}/routers/{routerId}' }} -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) - - 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() + +Delete a network router - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` +### Path Parameters -```ruby -require "uri" -require "json" -require "net/http" -url = URI("https://api.netbird.io/api/networks/{networkId}/routers/{routerId}") + + -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/networks/{networkId}/routers/{routerId}") - .method("DELETE") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); + + +```bash {{ title: 'cURL' }} +curl -X DELETE https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ +-H 'Authorization: Token ' \ ``` + -```php - 'https://api.netbird.io/api/networks/{networkId}/routers/{routerId}', - 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; -``` + - - - - - - --- -## List all Network Routers {{ tag: 'GET' , label: '/api/networks/routers' }} + +## List all Network Routers {{ tag: 'GET', label: '/api/networks/routers' }} + - - Returns a list of all routers in a network - - - + +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 -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/networks/routers', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/networks/routers" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/networks/routers" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` - -```ruby -require "uri" -require "json" -require "net/http" - -url = URI("https://api.netbird.io/api/networks/routers") - -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true - -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/networks/routers") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/networks/routers', - 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": "chacdk86lnnboviihd7g", - "peer": "chacbco6lnnbn6cg5s91", + "id": "string", + "peer": "string", "peer_groups": [ - "chacbco6lnnbn6cg5s91" + "string" ], - "metric": 9999, - "masquerade": true, - "enabled": true + "metric": "integer", + "masquerade": "boolean", + "enabled": "boolean" } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -3671,10 +1223,9 @@ echo $response; } ] ``` - - - - - + + + + --- diff --git a/src/pages/ipa/resources/peers.mdx b/src/pages/ipa/resources/peers.mdx index 5c0f98f7..370d4504 100644 --- a/src/pages/ipa/resources/peers.mdx +++ b/src/pages/ipa/resources/peers.mdx @@ -1,224 +1,89 @@ 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 - - - - - - -```bash {{ title: 'cURL' }} -curl -X GET https://api.netbird.io/api/peers \ --H 'Accept: application/json' \ --H 'Authorization: Token ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/peers', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/peers" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} -response = requests.request("GET", url, headers=headers) + +Returns a list of all peers -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/peers" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` +### Path Parameters -```ruby -require "uri" -require "json" -require "net/http" -url = URI("https://api.netbird.io/api/peers") + + +Filter peers by name + + +Filter peers by IP address + -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true + -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " + -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/peers") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/peers', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'GET', - CURLOPT_HTTPHEADER => array( - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/peers \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' ``` - - - - - + + ```json {{ title: 'Example' }} [ { - "id": "chacbco6lnnbn6cg5s90", - "name": "stage-host-1", - "ip": "10.64.0.1", - "connection_ip": "35.64.0.1", - "connected": true, - "last_seen": "2023-05-05T10:05:26.420578Z", - "os": "Darwin 13.2.1", - "kernel_version": "23.2.0", - "geoname_id": 2643743, - "version": "0.14.0", + "id": "string", + "name": "string", + "created_at": "string", + "ip": "string", + "connection_ip": "string", + "connected": "boolean", + "last_seen": "string", + "os": "string", + "kernel_version": "string", + "geoname_id": "integer", + "version": "string", "groups": [ { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api" + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string" } ], - "ssh_enabled": true, - "user_id": "google-oauth2|277474792786460067937", - "hostname": "stage-host-1", - "ui_version": "0.14.0", - "dns_label": "stage-host-1.netbird.cloud", - "login_expiration_enabled": false, - "login_expired": false, - "last_login": "2023-05-05T09:00:35.477782Z", - "inactivity_expiration_enabled": false, - "approval_required": true, - "country_code": "DE", - "city_name": "Berlin", - "serial_number": "C02XJ0J0JGH7", + "ssh_enabled": "boolean", + "user_id": "string", + "hostname": "string", + "ui_version": "string", + "dns_label": "string", + "login_expiration_enabled": "boolean", + "login_expired": "boolean", + "last_login": "string", + "inactivity_expiration_enabled": "boolean", + "approval_required": "boolean", + "country_code": "string", + "city_name": "string", + "serial_number": "string", "extra_dns_labels": [ - "stage-host-1" + "string" ], - "ephemeral": false, - "accessible_peers_count": 5 + "ephemeral": "boolean", + "accessible_peers_count": "integer" } ] ``` + ```json {{ title: 'Schema' }} [ { "id": "string", "name": "string", + "created_at": "string", "ip": "string", "connection_ip": "string", "connected": "boolean", @@ -257,224 +122,91 @@ echo $response; } ] ``` - - - - - + ---- + + +--- -## Retrieve a Peer {{ tag: 'GET' , label: '/api/peers/{peerId}' }} - - - - 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 -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/peers/{peerId}', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/peers/{peerId}" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` - -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) -func main() { +## Retrieve a Peer {{ tag: 'GET', label: '/api/peers/{peerId}' }} - url := "https://api.netbird.io/api/peers/{peerId}" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` + -```ruby -require "uri" -require "json" -require "net/http" + +Get information about a peer -url = URI("https://api.netbird.io/api/peers/{peerId}") +### Path Parameters -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 " + + +The unique identifier of a peer + -response = https.request(request) -puts response.read_body -``` + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/peers/{peerId}") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/peers/{peerId}', - 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; + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/peers/{peerId} \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' ``` - - - - - + + ```json {{ title: 'Example' }} { - "id": "chacbco6lnnbn6cg5s90", - "name": "stage-host-1", - "ip": "10.64.0.1", - "connection_ip": "35.64.0.1", - "connected": true, - "last_seen": "2023-05-05T10:05:26.420578Z", - "os": "Darwin 13.2.1", - "kernel_version": "23.2.0", - "geoname_id": 2643743, - "version": "0.14.0", + "id": "string", + "name": "string", + "created_at": "string", + "ip": "string", + "connection_ip": "string", + "connected": "boolean", + "last_seen": "string", + "os": "string", + "kernel_version": "string", + "geoname_id": "integer", + "version": "string", "groups": [ { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api" + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string" } ], - "ssh_enabled": true, - "user_id": "google-oauth2|277474792786460067937", - "hostname": "stage-host-1", - "ui_version": "0.14.0", - "dns_label": "stage-host-1.netbird.cloud", - "login_expiration_enabled": false, - "login_expired": false, - "last_login": "2023-05-05T09:00:35.477782Z", - "inactivity_expiration_enabled": false, - "approval_required": true, - "country_code": "DE", - "city_name": "Berlin", - "serial_number": "C02XJ0J0JGH7", + "ssh_enabled": "boolean", + "user_id": "string", + "hostname": "string", + "ui_version": "string", + "dns_label": "string", + "login_expiration_enabled": "boolean", + "login_expired": "boolean", + "last_login": "string", + "inactivity_expiration_enabled": "boolean", + "approval_required": "boolean", + "country_code": "string", + "city_name": "string", + "serial_number": "string", "extra_dns_labels": [ - "stage-host-1" + "string" ], - "ephemeral": false + "ephemeral": "boolean" } ``` + ```json {{ title: 'Schema' }} { "id": "string", "name": "string", + "created_at": "string", "ip": "string", "connection_ip": "string", "connected": "boolean", @@ -511,282 +243,72 @@ echo $response; "ephemeral": "boolean" } ``` - - - - - + + + + --- -## 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 - - - - - - - - - -```bash {{ title: 'cURL' }} -curl -X PUT https://api.netbird.io/api/peers/{peerId} \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "name": "stage-host-1", - "ssh_enabled": true, - "login_expiration_enabled": false, - "inactivity_expiration_enabled": false, - "approval_required": true, - "ip": "100.64.0.15" -}' -``` +## Update a Peer {{ tag: 'PUT', label: '/api/peers/{peerId}' }} -```js -const axios = require('axios'); -let data = JSON.stringify({ - "name": "stage-host-1", - "ssh_enabled": true, - "login_expiration_enabled": false, - "inactivity_expiration_enabled": false, - "approval_required": true, - "ip": "100.64.0.15" -}); -let config = { - method: 'put', - maxBodyLength: Infinity, - url: '/api/peers/{peerId}', - 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 -import requests -import json + -url = "https://api.netbird.io/api/peers/{peerId}" -payload = json.dumps({ - "name": "stage-host-1", - "ssh_enabled": true, - "login_expiration_enabled": false, - "inactivity_expiration_enabled": false, - "approval_required": true, - "ip": "100.64.0.15" -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} + +Update information about a peer -response = requests.request("PUT", url, headers=headers, data=payload) +### Path Parameters -print(response.text) -``` -```go -package main + + +The unique identifier of a peer + -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) + -func main() { - url := "https://api.netbird.io/api/peers/{peerId}" - method := "PUT" - - 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 { - } - 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() +### Request-Body Parameters - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` -```ruby -require "uri" -require "json" -require "net/http" + + -url = URI("https://api.netbird.io/api/peers/{peerId}") + + -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({ - "name": "stage-host-1", - "ssh_enabled": true, - "login_expiration_enabled": false, - "inactivity_expiration_enabled": false, - "approval_required": true, - "ip": "100.64.0.15" -}) -response = https.request(request) -puts response.read_body -``` + + +(Cloud only) Indicates whether peer needs approval + + +Peer's IP address + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "name": "stage-host-1", - "ssh_enabled": true, - "login_expiration_enabled": false, - "inactivity_expiration_enabled": false, - "approval_required": true, - "ip": "100.64.0.15" -}'); -Request request = new Request.Builder() - .url("https://api.netbird.io/api/peers/{peerId}") - .method("PUT", body) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/peers/{peerId}', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'PUT', - CURLOPT_POSTFIELDS => '{ - "name": "stage-host-1", - "ssh_enabled": true, - "login_expiration_enabled": false, - "inactivity_expiration_enabled": false, - "approval_required": true, - "ip": "100.64.0.15" -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` + - - - - -```json {{ title: 'Example' }} -{ + + +```bash {{ title: 'cURL' }} +curl -X PUT https://api.netbird.io/api/peers/{peerId} \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ "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, @@ -821,12 +343,57 @@ echo $response; "stage-host-1" ], "ephemeral": false +}' +``` + + +```json {{ title: 'Example' }} +{ + "id": "string", + "name": "string", + "created_at": "string", + "ip": "string", + "connection_ip": "string", + "connected": "boolean", + "last_seen": "string", + "os": "string", + "kernel_version": "string", + "geoname_id": "integer", + "version": "string", + "groups": [ + { + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string" + } + ], + "ssh_enabled": "boolean", + "user_id": "string", + "hostname": "string", + "ui_version": "string", + "dns_label": "string", + "login_expiration_enabled": "boolean", + "login_expired": "boolean", + "last_login": "string", + "inactivity_expiration_enabled": "boolean", + "approval_required": "boolean", + "country_code": "string", + "city_name": "string", + "serial_number": "string", + "extra_dns_labels": [ + "string" + ], + "ephemeral": "boolean" } ``` + ```json {{ title: 'Schema' }} { "id": "string", "name": "string", + "created_at": "string", "ip": "string", "connection_ip": "string", "connected": "boolean", @@ -863,361 +430,97 @@ echo $response; "ephemeral": "boolean" } ``` - - - - - + ---- + + +--- -## Delete a Peer {{ tag: 'DELETE' , label: '/api/peers/{peerId}' }} - - - 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 ' -``` -```js -const axios = require('axios'); - -let config = { - method: 'delete', - maxBodyLength: Infinity, - url: '/api/peers/{peerId}', - headers: { - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` +## Delete a Peer {{ tag: 'DELETE', label: '/api/peers/{peerId}' }} -```python -import requests -import json -url = "https://api.netbird.io/api/peers/{peerId}" + -headers = { - 'Authorization': 'Token ' -} + +Delete a peer -response = requests.request("DELETE", url, headers=headers) +### Path Parameters -print(response.text) -``` -```go -package main + + +The unique identifier of a peer + -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) - - 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)) -} + + +```bash {{ title: 'cURL' }} +curl -X DELETE https://api.netbird.io/api/peers/{peerId} \ +-H 'Authorization: Token ' \ ``` + -```ruby -require "uri" -require "json" -require "net/http" + -url = URI("https://api.netbird.io/api/peers/{peerId}") + +--- -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 -``` +## List accessible Peers {{ tag: 'GET', label: '/api/peers/{peerId}/accessible-peers' }} -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -Request request = new Request.Builder() - .url("https://api.netbird.io/api/peers/{peerId}") - .method("DELETE") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/peers/{peerId}', - 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; -``` + +Returns a list of peers that the specified peer can connect to within the network. - - - - - - +### Path Parameters ---- + + +The unique identifier of a peer + -## List accessible Peers {{ tag: 'GET' , label: '/api/peers/{peerId}/accessible-peers' }} + - - - Returns a list of peers that the specified peer can connect to within the network. - - ### Path Parameters - - - - The unique identifier of a peer - - - - - - + + + + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/peers/{peerId}/accessible-peers \ -H 'Accept: application/json' \ -H 'Authorization: Token ' ``` - -```js -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/peers/{peerId}/accessible-peers', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/peers/{peerId}/accessible-peers" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/peers/{peerId}/accessible-peers" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` - -```ruby -require "uri" -require "json" -require "net/http" - -url = URI("https://api.netbird.io/api/peers/{peerId}/accessible-peers") - -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true - -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/peers/{peerId}/accessible-peers") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/peers/{peerId}/accessible-peers', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'GET', - CURLOPT_HTTPHEADER => array( - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` - - - - - + + ```json {{ title: 'Example' }} [ { - "id": "chacbco6lnnbn6cg5s90", - "name": "stage-host-1", - "ip": "10.64.0.1", - "dns_label": "stage-host-1.netbird.cloud", - "user_id": "google-oauth2|277474792786460067937", - "os": "linux", - "country_code": "DE", - "city_name": "Berlin", - "geoname_id": 2643743, - "connected": true, - "last_seen": "2023-05-05T10:05:26.420578Z" + "id": "string", + "name": "string", + "ip": "string", + "dns_label": "string", + "user_id": "string", + "os": "string", + "country_code": "string", + "city_name": "string", + "geoname_id": "integer", + "connected": "boolean", + "last_seen": "string" } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -1235,10 +538,9 @@ echo $response; } ] ``` - - - - - + + + + --- diff --git a/src/pages/ipa/resources/policies.mdx b/src/pages/ipa/resources/policies.mdx index 7ee56d83..c10ffffd 100644 --- a/src/pages/ipa/resources/policies.mdx +++ b/src/pages/ipa/resources/policies.mdx @@ -1,223 +1,84 @@ 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 -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/policies', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/policies" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/policies" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` - -```ruby -require "uri" -require "json" -require "net/http" - -url = URI("https://api.netbird.io/api/policies") - -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true - -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/policies") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/policies', - 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' }} [ { - "name": "ch8i4ug6lnn4g9hqv7mg", - "description": "This is a default policy that allows connections between all the resources", - "enabled": true, - "id": "ch8i4ug6lnn4g9hqv7mg", + "name": "string", + "description": "string", + "enabled": "boolean", + "id": "string", "source_posture_checks": [ - "chacdk86lnnboviihd70" + "string" ], "rules": [ { - "name": "Default", - "description": "This is a default rule that allows connections between all the resources", - "enabled": true, - "action": "accept", - "bidirectional": true, - "protocol": "tcp", + "name": "string", + "description": "string", + "enabled": "boolean", + "action": "string", + "bidirectional": "boolean", + "protocol": "string", "ports": [ - "80" + "string" ], "port_ranges": [ { - "start": 80, - "end": 320 + "start": "integer", + "end": "integer" } ], - "id": "ch8i4ug6lnn4g9hqv7mg", + "id": "string", "sources": [ { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api" + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string" } ], "sourceResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" + "id": "string", + "type": "string" }, "destinations": [ { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api" + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string" } ], "destinationResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" + "id": "string", + "type": "string" } } ] } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -277,178 +138,49 @@ 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 + + + + + +
+ +Object list + + + + + + + + +
+
+ +
+ + + + + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/policies \ -H 'Accept: application/json' \ @@ -458,6 +190,7 @@ curl -X POST https://api.netbird.io/api/policies \ "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, + "id": "ch8i4ug6lnn4g9hqv7mg", "source_posture_checks": [ "chacdk86lnnboviihd70" ], @@ -480,14 +213,26 @@ curl -X POST https://api.netbird.io/api/policies \ ], "id": "ch8i4ug6lnn4g9hqv7mg", "sources": [ - "ch8i4ug6lnn4g9hqv797" + { + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api" + } ], "sourceResource": { "id": "chacdk86lnnboviihd7g", "type": "host" }, "destinations": [ - "ch8i4ug6lnn4g9h7v7m0" + { + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api" + } ], "destinationResource": { "id": "chacdk86lnnboviihd7g", @@ -497,463 +242,219 @@ curl -X POST https://api.netbird.io/api/policies \ ] }' ``` - -```js -const axios = require('axios'); -let data = JSON.stringify({ - "name": "ch8i4ug6lnn4g9hqv7mg", - "description": "This is a default policy that allows connections between all the resources", - "enabled": true, + + +```json {{ title: 'Example' }} +{ + "name": "string", + "description": "string", + "enabled": "boolean", + "id": "string", "source_posture_checks": [ - "chacdk86lnnboviihd70" + "string" ], "rules": [ { - "name": "Default", - "description": "This is a default rule that allows connections between all the resources", - "enabled": true, - "action": "accept", - "bidirectional": true, - "protocol": "tcp", + "name": "string", + "description": "string", + "enabled": "boolean", + "action": "string", + "bidirectional": "boolean", + "protocol": "string", "ports": [ - "80" + "string" ], "port_ranges": [ { - "start": 80, - "end": 320 + "start": "integer", + "end": "integer" } ], - "id": "ch8i4ug6lnn4g9hqv7mg", + "id": "string", "sources": [ - "ch8i4ug6lnn4g9hqv797" + { + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string" + } ], "sourceResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" + "id": "string", + "type": "string" }, "destinations": [ - "ch8i4ug6lnn4g9h7v7m0" + { + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string" + } ], "destinationResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" + "id": "string", + "type": "string" } } ] -}); -let config = { - method: 'post', - maxBodyLength: Infinity, - url: '/api/policies', - 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 -import requests -import json - -url = "https://api.netbird.io/api/policies" -payload = json.dumps({ - "name": "ch8i4ug6lnn4g9hqv7mg", - "description": "This is a default policy that allows connections between all the resources", - "enabled": true, +```json {{ title: 'Schema' }} +{ + "name": "string", + "description": "string", + "enabled": "boolean", + "id": "string", "source_posture_checks": [ - "chacdk86lnnboviihd70" + "string" ], "rules": [ { - "name": "Default", - "description": "This is a default rule that allows connections between all the resources", - "enabled": true, - "action": "accept", - "bidirectional": true, - "protocol": "tcp", + "name": "string", + "description": "string", + "enabled": "boolean", + "action": "string", + "bidirectional": "boolean", + "protocol": "string", "ports": [ - "80" + "string" ], "port_ranges": [ { - "start": 80, - "end": 320 + "start": "integer", + "end": "integer" } ], - "id": "ch8i4ug6lnn4g9hqv7mg", + "id": "string", "sources": [ - "ch8i4ug6lnn4g9hqv797" + { + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string" + } ], "sourceResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" + "id": "string", + "type": "string" }, "destinations": [ - "ch8i4ug6lnn4g9h7v7m0" + { + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string" + } ], "destinationResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" + "id": "string", + "type": "string" } } ] -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' } +``` + -response = requests.request("POST", url, headers=headers, data=payload) + -print(response.text) -``` +
+--- -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) -func main() { +## Retrieve a Policy {{ tag: 'GET', label: '/api/policies/{policyId}' }} - url := "https://api.netbird.io/api/policies" - method := "POST" - - payload := strings.NewReader(`{ - "name": "ch8i4ug6lnn4g9hqv7mg", - "description": "This is a default policy that allows connections between all the resources", - "enabled": true, + + + + +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 ' +``` + + +```json {{ title: 'Example' }} +{ + "name": "string", + "description": "string", + "enabled": "boolean", + "id": "string", "source_posture_checks": [ - "chacdk86lnnboviihd70" + "string" ], "rules": [ { - "name": "Default", - "description": "This is a default rule that allows connections between all the resources", - "enabled": true, - "action": "accept", - "bidirectional": true, - "protocol": "tcp", + "name": "string", + "description": "string", + "enabled": "boolean", + "action": "string", + "bidirectional": "boolean", + "protocol": "string", "ports": [ - "80" + "string" ], "port_ranges": [ { - "start": 80, - "end": 320 + "start": "integer", + "end": "integer" } ], - "id": "ch8i4ug6lnn4g9hqv7mg", - "sources": [ - "ch8i4ug6lnn4g9hqv797" - ], - "sourceResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - }, - "destinations": [ - "ch8i4ug6lnn4g9h7v7m0" - ], - "destinationResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - } - } - ] -}`) - 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() - - 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/policies") - -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({ - "name": "ch8i4ug6lnn4g9hqv7mg", - "description": "This is a default policy that allows connections between all the resources", - "enabled": true, - "source_posture_checks": [ - "chacdk86lnnboviihd70" - ], - "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": [ - { - "start": 80, - "end": 320 - } - ], - "id": "ch8i4ug6lnn4g9hqv7mg", - "sources": [ - "ch8i4ug6lnn4g9hqv797" - ], - "sourceResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - }, - "destinations": [ - "ch8i4ug6lnn4g9h7v7m0" - ], - "destinationResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - } - } - ] -}) -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "name": "ch8i4ug6lnn4g9hqv7mg", - "description": "This is a default policy that allows connections between all the resources", - "enabled": true, - "source_posture_checks": [ - "chacdk86lnnboviihd70" - ], - "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": [ - { - "start": 80, - "end": 320 - } - ], - "id": "ch8i4ug6lnn4g9hqv7mg", - "sources": [ - "ch8i4ug6lnn4g9hqv797" - ], - "sourceResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - }, - "destinations": [ - "ch8i4ug6lnn4g9h7v7m0" - ], - "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 ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/policies', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'POST', - CURLOPT_POSTFIELDS => '{ - "name": "ch8i4ug6lnn4g9hqv7mg", - "description": "This is a default policy that allows connections between all the resources", - "enabled": true, - "source_posture_checks": [ - "chacdk86lnnboviihd70" - ], - "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": [ - { - "start": 80, - "end": 320 - } - ], - "id": "ch8i4ug6lnn4g9hqv7mg", - "sources": [ - "ch8i4ug6lnn4g9hqv797" - ], - "sourceResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - }, - "destinations": [ - "ch8i4ug6lnn4g9h7v7m0" - ], - "destinationResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - } - } - ] -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` - - - - - -```json {{ title: 'Example' }} -{ - "name": "ch8i4ug6lnn4g9hqv7mg", - "description": "This is a default policy that allows connections between all the resources", - "enabled": true, - "id": "ch8i4ug6lnn4g9hqv7mg", - "source_posture_checks": [ - "chacdk86lnnboviihd70" - ], - "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": [ - { - "start": 80, - "end": 320 - } - ], - "id": "ch8i4ug6lnn4g9hqv7mg", + "id": "string", "sources": [ { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api" + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string" } ], "sourceResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" + "id": "string", + "type": "string" }, "destinations": [ { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api" + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string" } ], "destinationResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" + "id": "string", + "type": "string" } } ] } ``` + ```json {{ title: 'Schema' }} { "name": "string", @@ -1011,182 +512,66 @@ echo $response; ] } ``` - - - - - + + + + --- -## Retrieve a Policy {{ tag: 'GET' , label: '/api/policies/{policyId}' }} - - - 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 ' -``` +## Update a Policy {{ tag: 'PUT', label: '/api/policies/{policyId}' }} -```js -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/policies/{policyId}', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` -```python -import requests -import json + + + +Update/Replace a Policy -url = "https://api.netbird.io/api/policies/{policyId}" +### Path Parameters -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} -response = requests.request("GET", url, headers=headers) + + +The unique identifier of a policy + -print(response.text) -``` + -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) +### Request-Body Parameters -func main() { - url := "https://api.netbird.io/api/policies/{policyId}" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() + + - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` +
-```ruby -require "uri" -require "json" -require "net/http" +Object list + -url = URI("https://api.netbird.io/api/policies/{policyId}") + -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true + -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " + -response = https.request(request) -puts response.read_body -``` +
+
-```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/policies/{policyId}") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` +
-```php - 'https://api.netbird.io/api/policies/{policyId}', - 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' }} -{ + + +```bash {{ title: 'cURL' }} +curl -X PUT https://api.netbird.io/api/policies/{policyId} \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, @@ -1240,9 +625,11 @@ echo $response; } } ] -} +}' ``` -```json {{ title: 'Schema' }} + + +```json {{ title: 'Example' }} { "name": "string", "description": "string", @@ -1299,699 +686,15 @@ echo $response; ] } ``` - - - - -
---- - - -## 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 - - - - - -
- -
-
- -
-
- -
-
- - - - - - -```bash {{ title: 'cURL' }} -curl -X PUT https://api.netbird.io/api/policies/{policyId} \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "name": "ch8i4ug6lnn4g9hqv7mg", - "description": "This is a default policy that allows connections between all the resources", - "enabled": true, +```json {{ title: 'Schema' }} +{ + "name": "string", + "description": "string", + "enabled": "boolean", + "id": "string", "source_posture_checks": [ - "chacdk86lnnboviihd70" - ], - "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": [ - { - "start": 80, - "end": 320 - } - ], - "id": "ch8i4ug6lnn4g9hqv7mg", - "sources": [ - "ch8i4ug6lnn4g9hqv797" - ], - "sourceResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - }, - "destinations": [ - "ch8i4ug6lnn4g9h7v7m0" - ], - "destinationResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - } - } - ] -}' -``` - -```js -const axios = require('axios'); -let data = JSON.stringify({ - "name": "ch8i4ug6lnn4g9hqv7mg", - "description": "This is a default policy that allows connections between all the resources", - "enabled": true, - "source_posture_checks": [ - "chacdk86lnnboviihd70" - ], - "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": [ - { - "start": 80, - "end": 320 - } - ], - "id": "ch8i4ug6lnn4g9hqv7mg", - "sources": [ - "ch8i4ug6lnn4g9hqv797" - ], - "sourceResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - }, - "destinations": [ - "ch8i4ug6lnn4g9h7v7m0" - ], - "destinationResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - } - } - ] -}); -let config = { - method: 'put', - maxBodyLength: Infinity, - url: '/api/policies/{policyId}', - 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 -import requests -import json - -url = "https://api.netbird.io/api/policies/{policyId}" -payload = json.dumps({ - "name": "ch8i4ug6lnn4g9hqv7mg", - "description": "This is a default policy that allows connections between all the resources", - "enabled": true, - "source_posture_checks": [ - "chacdk86lnnboviihd70" - ], - "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": [ - { - "start": 80, - "end": 320 - } - ], - "id": "ch8i4ug6lnn4g9hqv7mg", - "sources": [ - "ch8i4ug6lnn4g9hqv797" - ], - "sourceResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - }, - "destinations": [ - "ch8i4ug6lnn4g9h7v7m0" - ], - "destinationResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - } - } - ] -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("PUT", url, headers=headers, data=payload) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/policies/{policyId}" - method := "PUT" - - payload := strings.NewReader(`{ - "name": "ch8i4ug6lnn4g9hqv7mg", - "description": "This is a default policy that allows connections between all the resources", - "enabled": true, - "source_posture_checks": [ - "chacdk86lnnboviihd70" - ], - "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": [ - { - "start": 80, - "end": 320 - } - ], - "id": "ch8i4ug6lnn4g9hqv7mg", - "sources": [ - "ch8i4ug6lnn4g9hqv797" - ], - "sourceResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - }, - "destinations": [ - "ch8i4ug6lnn4g9h7v7m0" - ], - "destinationResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - } - } - ] -}`) - 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() - - 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/policies/{policyId}") - -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({ - "name": "ch8i4ug6lnn4g9hqv7mg", - "description": "This is a default policy that allows connections between all the resources", - "enabled": true, - "source_posture_checks": [ - "chacdk86lnnboviihd70" - ], - "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": [ - { - "start": 80, - "end": 320 - } - ], - "id": "ch8i4ug6lnn4g9hqv7mg", - "sources": [ - "ch8i4ug6lnn4g9hqv797" - ], - "sourceResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - }, - "destinations": [ - "ch8i4ug6lnn4g9h7v7m0" - ], - "destinationResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - } - } - ] -}) -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "name": "ch8i4ug6lnn4g9hqv7mg", - "description": "This is a default policy that allows connections between all the resources", - "enabled": true, - "source_posture_checks": [ - "chacdk86lnnboviihd70" - ], - "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": [ - { - "start": 80, - "end": 320 - } - ], - "id": "ch8i4ug6lnn4g9hqv7mg", - "sources": [ - "ch8i4ug6lnn4g9hqv797" - ], - "sourceResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - }, - "destinations": [ - "ch8i4ug6lnn4g9h7v7m0" - ], - "destinationResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - } - } - ] -}'); -Request request = new Request.Builder() - .url("https://api.netbird.io/api/policies/{policyId}") - .method("PUT", body) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/policies/{policyId}', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'PUT', - CURLOPT_POSTFIELDS => '{ - "name": "ch8i4ug6lnn4g9hqv7mg", - "description": "This is a default policy that allows connections between all the resources", - "enabled": true, - "source_posture_checks": [ - "chacdk86lnnboviihd70" - ], - "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": [ - { - "start": 80, - "end": 320 - } - ], - "id": "ch8i4ug6lnn4g9hqv7mg", - "sources": [ - "ch8i4ug6lnn4g9hqv797" - ], - "sourceResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - }, - "destinations": [ - "ch8i4ug6lnn4g9h7v7m0" - ], - "destinationResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - } - } - ] -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` - - - - - -```json {{ title: 'Example' }} -{ - "name": "ch8i4ug6lnn4g9hqv7mg", - "description": "This is a default policy that allows connections between all the resources", - "enabled": true, - "id": "ch8i4ug6lnn4g9hqv7mg", - "source_posture_checks": [ - "chacdk86lnnboviihd70" - ], - "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": [ - { - "start": 80, - "end": 320 - } - ], - "id": "ch8i4ug6lnn4g9hqv7mg", - "sources": [ - { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api" - } - ], - "sourceResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - }, - "destinations": [ - { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api" - } - ], - "destinationResource": { - "id": "chacdk86lnnboviihd7g", - "type": "host" - } - } - ] -} -``` -```json {{ title: 'Schema' }} -{ - "name": "string", - "description": "string", - "enabled": "boolean", - "id": "string", - "source_posture_checks": [ - "string" + "string" ], "rules": [ { @@ -2041,174 +744,44 @@ echo $response; ] } ``` - - - - -
- ---- - - -## Delete a Policy {{ tag: 'DELETE' , label: '/api/policies/{policyId}' }} - - - - 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 ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'delete', - maxBodyLength: Infinity, - url: '/api/policies/{policyId}', - 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/policies/{policyId}" + -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() { +## Delete a Policy {{ tag: 'DELETE', label: '/api/policies/{policyId}' }} - url := "https://api.netbird.io/api/policies/{policyId}" - 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" + +Delete a policy -url = URI("https://api.netbird.io/api/policies/{policyId}") +### Path Parameters -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true -request = Net::HTTP::Delete.new(url) -request["Authorization"] = "Token " + + +The unique identifier of a policy + -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/policies/{policyId}") - .method("DELETE") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); + + +```bash {{ title: 'cURL' }} +curl -X DELETE https://api.netbird.io/api/policies/{policyId} \ +-H 'Authorization: Token ' \ ``` + -```php - 'https://api.netbird.io/api/policies/{policyId}', - 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/posture-checks.mdx b/src/pages/ipa/resources/posture-checks.mdx index 1b6a314a..0cd679b1 100644 --- a/src/pages/ipa/resources/posture-checks.mdx +++ b/src/pages/ipa/resources/posture-checks.mdx @@ -1,214 +1,72 @@ 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 -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/posture-checks', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/posture-checks" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/posture-checks" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` - -```ruby -require "uri" -require "json" -require "net/http" - -url = URI("https://api.netbird.io/api/posture-checks") - -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true - -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/posture-checks") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/posture-checks', - 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": "ch8i4ug6lnn4g9hqv7mg", - "name": "Default", - "description": "This checks if the peer is running required NetBird's version", + "id": "string", + "name": "string", + "description": "string", "checks": { "nb_version_check": { - "min_version": "14.3" + "min_version": "string" }, "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": { "locations": [ { - "country_code": "DE", - "city_name": "Berlin" + "country_code": "string", + "city_name": "string" } ], - "action": "allow" + "action": "string" }, "peer_network_range_check": { "ranges": [ - "192.168.1.0/24", - "10.0.0.0/8", - "2001:db8:1234:1a00::/56" + "string" ], - "action": "allow" + "action": "string" }, "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": "string", + "mac_path": "string", + "windows_path": "string" } ] } @@ -216,6 +74,7 @@ echo $response; } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -228,19 +87,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,272 +130,77 @@ 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 + + + +
+ +Object list + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ + + + + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/posture-checks \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ -H 'Authorization: Token ' \ --data-raw '{ + "id": "ch8i4ug6lnn4g9hqv7mg", "name": "Default", "description": "This checks if the peer is running required NetBird's version", "checks": { @@ -589,561 +253,247 @@ curl -X POST https://api.netbird.io/api/posture-checks \ } }' ``` - -```js -const axios = require('axios'); -let data = JSON.stringify({ - "name": "Default", - "description": "This checks if the peer is running required NetBird's version", + + +```json {{ title: 'Example' }} +{ + "id": "string", + "name": "string", + "description": "string", "checks": { "nb_version_check": { - "min_version": "14.3" + "min_version": "string" }, "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": { "locations": [ { - "country_code": "DE", - "city_name": "Berlin" + "country_code": "string", + "city_name": "string" } ], - "action": "allow" + "action": "string" }, "peer_network_range_check": { "ranges": [ - "192.168.1.0/24", - "10.0.0.0/8", - "2001:db8:1234:1a00::/56" + "string" ], - "action": "allow" + "action": "string" }, "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": "string", + "mac_path": "string", + "windows_path": "string" } ] } } -}); -let config = { - method: 'post', - maxBodyLength: Infinity, - url: '/api/posture-checks', - 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 -import requests -import json - -url = "https://api.netbird.io/api/posture-checks" -payload = json.dumps({ - "name": "Default", - "description": "This checks if the peer is running required NetBird's version", +```json {{ title: 'Schema' }} +{ + "id": "string", + "name": "string", + "description": "string", "checks": { "nb_version_check": { - "min_version": "14.3" + "min_version": "string" }, "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": { "locations": [ { - "country_code": "DE", - "city_name": "Berlin" + "country_code": "string", + "city_name": "string" } ], - "action": "allow" + "action": "string" }, "peer_network_range_check": { "ranges": [ - "192.168.1.0/24", - "10.0.0.0/8", - "2001:db8:1234:1a00::/56" + "string" ], - "action": "allow" + "action": "string" }, "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": "string", + "mac_path": "string", + "windows_path": "string" } ] } } -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' } +``` + -response = requests.request("POST", url, headers=headers, data=payload) + -print(response.text) -``` +
+--- -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) -func main() { +## Retrieve a Posture Check {{ tag: 'GET', label: '/api/posture-checks/{postureCheckId}' }} - url := "https://api.netbird.io/api/posture-checks" - method := "POST" - - payload := strings.NewReader(`{ - "name": "Default", - "description": "This checks if the peer is running required NetBird's version", + + + + +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 ' +``` + + +```json {{ title: 'Example' }} +{ + "id": "string", + "name": "string", + "description": "string", "checks": { "nb_version_check": { - "min_version": "14.3" + "min_version": "string" }, "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": { "locations": [ { - "country_code": "DE", - "city_name": "Berlin" + "country_code": "string", + "city_name": "string" } ], - "action": "allow" + "action": "string" }, "peer_network_range_check": { "ranges": [ - "192.168.1.0/24", - "10.0.0.0/8", - "2001:db8:1234:1a00::/56" + "string" ], - "action": "allow" + "action": "string" }, "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": "string", + "mac_path": "string", + "windows_path": "string" } ] } } -}`) - client := &http.Client { - } - req, err := http.NewRequest(method, url, payload) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Content-Type", "application/json") - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - 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/posture-checks") - -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({ - "name": "Default", - "description": "This checks if the peer is running required NetBird's version", +```json {{ title: 'Schema' }} +{ + "id": "string", + "name": "string", + "description": "string", "checks": { "nb_version_check": { - "min_version": "14.3" + "min_version": "string" }, "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": { "locations": [ { - "country_code": "DE", - "city_name": "Berlin" + "country_code": "string", + "city_name": "string" } ], - "action": "allow" + "action": "string" }, "peer_network_range_check": { "ranges": [ - "192.168.1.0/24", - "10.0.0.0/8", - "2001:db8:1234:1a00::/56" + "string" ], - "action": "allow" - }, - "process_check": { - "processes": [ - { - "linux_path": "/usr/local/bin/netbird", - "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", - "windows_path": "C:
rogramData…etBird\netbird.exe" - } - ] - } - } -}) -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "name": "Default", - "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" - }, - "ios": { - "min_version": "17.3.1" - }, - "darwin": { - "min_version": "14.2.1" - }, - "linux": { - "min_kernel_version": "5.3.3" - }, - "windows": { - "min_kernel_version": "10.0.1234" - } - }, - "geo_location_check": { - "locations": [ - { - "country_code": "DE", - "city_name": "Berlin" - } - ], - "action": "allow" - }, - "peer_network_range_check": { - "ranges": [ - "192.168.1.0/24", - "10.0.0.0/8", - "2001:db8:1234:1a00::/56" - ], - "action": "allow" - }, - "process_check": { - "processes": [ - { - "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 ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/posture-checks', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'POST', - CURLOPT_POSTFIELDS => '{ - "name": "Default", - "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" - }, - "ios": { - "min_version": "17.3.1" - }, - "darwin": { - "min_version": "14.2.1" - }, - "linux": { - "min_kernel_version": "5.3.3" - }, - "windows": { - "min_kernel_version": "10.0.1234" - } - }, - "geo_location_check": { - "locations": [ - { - "country_code": "DE", - "city_name": "Berlin" - } - ], - "action": "allow" - }, - "peer_network_range_check": { - "ranges": [ - "192.168.1.0/24", - "10.0.0.0/8", - "2001:db8:1234:1a00::/56" - ], - "action": "allow" - }, - "process_check": { - "processes": [ - { - "linux_path": "/usr/local/bin/netbird", - "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", - "windows_path": "C:
rogramData…etBird\netbird.exe" - } - ] - } - } -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` - - - - - -```json {{ title: 'Example' }} -{ - "id": "ch8i4ug6lnn4g9hqv7mg", - "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" - }, - "ios": { - "min_version": "17.3.1" - }, - "darwin": { - "min_version": "14.2.1" - }, - "linux": { - "min_kernel_version": "5.3.3" - }, - "windows": { - "min_kernel_version": "10.0.1234" - } - }, - "geo_location_check": { - "locations": [ - { - "country_code": "DE", - "city_name": "Berlin" - } - ], - "action": "allow" - }, - "peer_network_range_check": { - "ranges": [ - "192.168.1.0/24", - "10.0.0.0/8", - "2001:db8:1234:1a00::/56" - ], - "action": "allow" - }, - "process_check": { - "processes": [ - { - "linux_path": "/usr/local/bin/netbird", - "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", - "windows_path": "C:
rogramData…etBird\netbird.exe" - } - ] - } - } -} -``` -```json {{ title: 'Schema' }} -{ - "id": "string", - "name": "string", - "description": "string", - "checks": { - "nb_version_check": { - "min_version": "string" - }, - "os_version_check": { - "android": { - "min_version": "13" - }, - "ios": { - "min_version": "17.3.1" - }, - "darwin": { - "min_version": "14.2.1" - }, - "linux": { - "min_kernel_version": "5.3.3" - }, - "windows": { - "min_kernel_version": "10.0.1234" - } - }, - "geo_location_check": { - "locations": [ - { - "country_code": "string", - "city_name": "string" - } - ], - "action": "string" - }, - "peer_network_range_check": { - "ranges": [ - "string" - ], - "action": "string" + "action": "string" }, "process_check": { "processes": [ @@ -1157,1006 +507,88 @@ echo $response; } } ``` - - - - - - ---- - - -## 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 - - - - - - -```bash {{ title: 'cURL' }} -curl -X GET https://api.netbird.io/api/posture-checks/{postureCheckId} \ --H 'Accept: application/json' \ --H 'Authorization: Token ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/posture-checks/{postureCheckId}', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/posture-checks/{postureCheckId}" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` + -```go -package main + -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/posture-checks/{postureCheckId}" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` + +--- -```ruby -require "uri" -require "json" -require "net/http" -url = URI("https://api.netbird.io/api/posture-checks/{postureCheckId}") -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true +## Update a Posture Check {{ tag: 'PUT', label: '/api/posture-checks/{postureCheckId}' }} -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " -response = https.request(request) -puts response.read_body -``` + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/posture-checks/{postureCheckId}") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + +Update/Replace a posture check -```php - 'https://api.netbird.io/api/posture-checks/{postureCheckId}', - 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; -``` +### Path Parameters - - - - -```json {{ title: 'Example' }} -{ - "id": "ch8i4ug6lnn4g9hqv7mg", - "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" - }, - "ios": { - "min_version": "17.3.1" - }, - "darwin": { - "min_version": "14.2.1" - }, - "linux": { - "min_kernel_version": "5.3.3" - }, - "windows": { - "min_kernel_version": "10.0.1234" - } - }, - "geo_location_check": { - "locations": [ - { - "country_code": "DE", - "city_name": "Berlin" - } - ], - "action": "allow" - }, - "peer_network_range_check": { - "ranges": [ - "192.168.1.0/24", - "10.0.0.0/8", - "2001:db8:1234:1a00::/56" - ], - "action": "allow" - }, - "process_check": { - "processes": [ - { - "linux_path": "/usr/local/bin/netbird", - "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", - "windows_path": "C:
rogramData…etBird\netbird.exe" - } - ] - } - } -} -``` -```json {{ title: 'Schema' }} -{ - "id": "string", - "name": "string", - "description": "string", - "checks": { - "nb_version_check": { - "min_version": "string" - }, - "os_version_check": { - "android": { - "min_version": "13" - }, - "ios": { - "min_version": "17.3.1" - }, - "darwin": { - "min_version": "14.2.1" - }, - "linux": { - "min_kernel_version": "5.3.3" - }, - "windows": { - "min_kernel_version": "10.0.1234" - } - }, - "geo_location_check": { - "locations": [ - { - "country_code": "string", - "city_name": "string" - } - ], - "action": "string" - }, - "peer_network_range_check": { - "ranges": [ - "string" - ], - "action": "string" - }, - "process_check": { - "processes": [ - { - "linux_path": "string", - "mac_path": "string", - "windows_path": "string" - } - ] - } - } -} -``` - - - - - - ---- - - -## 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 - - - - - -
- -
-
- -
-
- -
-
- -
-
- -
-
- - - - - - -```bash {{ title: 'cURL' }} -curl -X PUT https://api.netbird.io/api/posture-checks/{postureCheckId} \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "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" - }, - "ios": { - "min_version": "17.3.1" - }, - "darwin": { - "min_version": "14.2.1" - }, - "linux": { - "min_kernel_version": "5.3.3" - }, - "windows": { - "min_kernel_version": "10.0.1234" - } - }, - "geo_location_check": { - "locations": [ - { - "country_code": "DE", - "city_name": "Berlin" - } - ], - "action": "allow" - }, - "peer_network_range_check": { - "ranges": [ - "192.168.1.0/24", - "10.0.0.0/8", - "2001:db8:1234:1a00::/56" - ], - "action": "allow" - }, - "process_check": { - "processes": [ - { - "linux_path": "/usr/local/bin/netbird", - "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", - "windows_path": "C:
rogramData…etBird\netbird.exe" - } - ] - } - } -}' -``` - -```js -const axios = require('axios'); -let data = JSON.stringify({ - "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" - }, - "ios": { - "min_version": "17.3.1" - }, - "darwin": { - "min_version": "14.2.1" - }, - "linux": { - "min_kernel_version": "5.3.3" - }, - "windows": { - "min_kernel_version": "10.0.1234" - } - }, - "geo_location_check": { - "locations": [ - { - "country_code": "DE", - "city_name": "Berlin" - } - ], - "action": "allow" - }, - "peer_network_range_check": { - "ranges": [ - "192.168.1.0/24", - "10.0.0.0/8", - "2001:db8:1234:1a00::/56" - ], - "action": "allow" - }, - "process_check": { - "processes": [ - { - "linux_path": "/usr/local/bin/netbird", - "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", - "windows_path": "C:
rogramData…etBird\netbird.exe" - } - ] - } - } -}); -let config = { - method: 'put', - maxBodyLength: Infinity, - url: '/api/posture-checks/{postureCheckId}', - 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 -import requests -import json - -url = "https://api.netbird.io/api/posture-checks/{postureCheckId}" -payload = json.dumps({ - "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" - }, - "ios": { - "min_version": "17.3.1" - }, - "darwin": { - "min_version": "14.2.1" - }, - "linux": { - "min_kernel_version": "5.3.3" - }, - "windows": { - "min_kernel_version": "10.0.1234" - } - }, - "geo_location_check": { - "locations": [ - { - "country_code": "DE", - "city_name": "Berlin" - } - ], - "action": "allow" - }, - "peer_network_range_check": { - "ranges": [ - "192.168.1.0/24", - "10.0.0.0/8", - "2001:db8:1234:1a00::/56" - ], - "action": "allow" - }, - "process_check": { - "processes": [ - { - "linux_path": "/usr/local/bin/netbird", - "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", - "windows_path": "C:
rogramData…etBird\netbird.exe" - } - ] - } - } -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} -response = requests.request("PUT", url, headers=headers, data=payload) + + +The unique identifier of a posture check + -print(response.text) -``` + -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) +### Request-Body Parameters -func main() { - url := "https://api.netbird.io/api/posture-checks/{postureCheckId}" - method := "PUT" - - payload := strings.NewReader(`{ - "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" - }, - "ios": { - "min_version": "17.3.1" - }, - "darwin": { - "min_version": "14.2.1" - }, - "linux": { - "min_kernel_version": "5.3.3" - }, - "windows": { - "min_kernel_version": "10.0.1234" - } - }, - "geo_location_check": { - "locations": [ - { - "country_code": "DE", - "city_name": "Berlin" - } - ], - "action": "allow" - }, - "peer_network_range_check": { - "ranges": [ - "192.168.1.0/24", - "10.0.0.0/8", - "2001:db8:1234:1a00::/56" - ], - "action": "allow" - }, - "process_check": { - "processes": [ - { - "linux_path": "/usr/local/bin/netbird", - "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", - "windows_path": "C:
rogramData…etBird\netbird.exe" - } - ] - } - } -}`) - 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() + + +Posture check name identifier + + +Posture check friendly description + + - 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" +Object list + -url = URI("https://api.netbird.io/api/posture-checks/{postureCheckId}") + + -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({ - "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" - }, - "ios": { - "min_version": "17.3.1" - }, - "darwin": { - "min_version": "14.2.1" - }, - "linux": { - "min_kernel_version": "5.3.3" - }, - "windows": { - "min_kernel_version": "10.0.1234" - } - }, - "geo_location_check": { - "locations": [ - { - "country_code": "DE", - "city_name": "Berlin" - } - ], - "action": "allow" - }, - "peer_network_range_check": { - "ranges": [ - "192.168.1.0/24", - "10.0.0.0/8", - "2001:db8:1234:1a00::/56" - ], - "action": "allow" - }, - "process_check": { - "processes": [ - { - "linux_path": "/usr/local/bin/netbird", - "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", - "windows_path": "C:
rogramData…etBird\netbird.exe" - } - ] - } - } -}) -response = https.request(request) -puts response.read_body -``` + + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "name": "Default", - "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" - }, - "ios": { - "min_version": "17.3.1" - }, - "darwin": { - "min_version": "14.2.1" - }, - "linux": { - "min_kernel_version": "5.3.3" - }, - "windows": { - "min_kernel_version": "10.0.1234" - } - }, - "geo_location_check": { - "locations": [ - { - "country_code": "DE", - "city_name": "Berlin" - } - ], - "action": "allow" - }, - "peer_network_range_check": { - "ranges": [ - "192.168.1.0/24", - "10.0.0.0/8", - "2001:db8:1234:1a00::/56" - ], - "action": "allow" - }, - "process_check": { - "processes": [ - { - "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/{postureCheckId}") - .method("PUT", body) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + + + + + + -```php - 'https://api.netbird.io/api/posture-checks/{postureCheckId}', - 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 => '{ + + +
+
+ +
+ + + + + +```bash {{ title: 'cURL' }} +curl -X PUT https://api.netbird.io/api/posture-checks/{postureCheckId} \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ + "id": "ch8i4ug6lnn4g9hqv7mg", "name": "Default", "description": "This checks if the peer is running required NetBird's version", "checks": { @@ -2207,79 +639,64 @@ curl_setopt_array($curl, array( ] } } -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; +}' ``` - - - - - + + ```json {{ title: 'Example' }} { - "id": "ch8i4ug6lnn4g9hqv7mg", - "name": "Default", - "description": "This checks if the peer is running required NetBird's version", + "id": "string", + "name": "string", + "description": "string", "checks": { "nb_version_check": { - "min_version": "14.3" + "min_version": "string" }, "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": { "locations": [ { - "country_code": "DE", - "city_name": "Berlin" + "country_code": "string", + "city_name": "string" } ], - "action": "allow" + "action": "string" }, "peer_network_range_check": { "ranges": [ - "192.168.1.0/24", - "10.0.0.0/8", - "2001:db8:1234:1a00::/56" + "string" ], - "action": "allow" + "action": "string" }, "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": "string", + "mac_path": "string", + "windows_path": "string" } ] } } } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -2291,19 +708,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,174 +750,44 @@ echo $response; } } ``` - - - - -
- ---- - - -## Delete a Posture Check {{ tag: 'DELETE' , label: '/api/posture-checks/{postureCheckId}' }} - - - - 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 ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'delete', - maxBodyLength: Infinity, - url: '/api/posture-checks/{postureCheckId}', - 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/posture-checks/{postureCheckId}" - -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() { +## Delete a Posture Check {{ tag: 'DELETE', label: '/api/posture-checks/{postureCheckId}' }} - url := "https://api.netbird.io/api/posture-checks/{postureCheckId}" - 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" + +Delete a posture check -url = URI("https://api.netbird.io/api/posture-checks/{postureCheckId}") +### Path Parameters -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true -request = Net::HTTP::Delete.new(url) -request["Authorization"] = "Token " + + +The unique identifier of a posture check + -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/posture-checks/{postureCheckId}") - .method("DELETE") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); + + +```bash {{ title: 'cURL' }} +curl -X DELETE https://api.netbird.io/api/posture-checks/{postureCheckId} \ +-H 'Authorization: Token ' \ ``` + -```php - 'https://api.netbird.io/api/posture-checks/{postureCheckId}', - 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/routes.mdx b/src/pages/ipa/resources/routes.mdx index 9dfeb45a..84cef09f 100644 --- a/src/pages/ipa/resources/routes.mdx +++ b/src/pages/ipa/resources/routes.mdx @@ -1,192 +1,53 @@ 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 -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/routes', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/routes" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/routes" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` - -```ruby -require "uri" -require "json" -require "net/http" - -url = URI("https://api.netbird.io/api/routes") - -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true - -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/routes") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/routes', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'GET', - CURLOPT_HTTPHEADER => array( - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` - - - - - + + ```json {{ title: 'Example' }} [ { - "id": "chacdk86lnnboviihd7g", - "network_type": "IPv4", - "description": "My first route", - "network_id": "Route 1", - "enabled": true, - "peer": "chacbco6lnnbn6cg5s91", + "id": "string", + "network_type": "string", + "description": "string", + "network_id": "string", + "enabled": "boolean", + "peer": "string", "peer_groups": [ - "chacbco6lnnbn6cg5s91" + "string" ], - "network": "10.64.0.0/24", + "network": "string", "domains": [ - "example.com" + "string" ], - "metric": 9999, - "masquerade": true, + "metric": "integer", + "masquerade": "boolean", "groups": [ - "chacdk86lnnboviihd70" + "string" ], - "keep_route": true, + "keep_route": "boolean", "access_control_groups": [ - "chacbco6lnnbn6cg5s91" + "string" ] } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -215,96 +76,78 @@ echo $response; } ] ``` - - - - - + + + + --- -## 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. + + + + + + + + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/routes \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ -H 'Authorization: Token ' \ --data-raw '{ + "id": "chacdk86lnnboviihd7g", + "network_type": "IPv4", "description": "My first route", "network_id": "Route 1", "enabled": true, @@ -327,288 +170,233 @@ curl -X POST https://api.netbird.io/api/routes \ ] }' ``` - -```js -const axios = require('axios'); -let data = JSON.stringify({ - "description": "My first route", - "network_id": "Route 1", - "enabled": true, - "peer": "chacbco6lnnbn6cg5s91", + + +```json {{ title: 'Example' }} +{ + "id": "string", + "network_type": "string", + "description": "string", + "network_id": "string", + "enabled": "boolean", + "peer": "string", "peer_groups": [ - "chacbco6lnnbn6cg5s91" + "string" ], - "network": "10.64.0.0/24", + "network": "string", "domains": [ - "example.com" + "string" ], - "metric": 9999, - "masquerade": true, + "metric": "integer", + "masquerade": "boolean", "groups": [ - "chacdk86lnnboviihd70" + "string" ], - "keep_route": true, + "keep_route": "boolean", "access_control_groups": [ - "chacbco6lnnbn6cg5s91" + "string" ] -}); -let config = { - method: 'post', - maxBodyLength: Infinity, - url: '/api/routes', - 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 -import requests -import json - -url = "https://api.netbird.io/api/routes" -payload = json.dumps({ - "description": "My first route", - "network_id": "Route 1", - "enabled": true, - "peer": "chacbco6lnnbn6cg5s91", +```json {{ title: 'Schema' }} +{ + "id": "string", + "network_type": "string", + "description": "string", + "network_id": "string", + "enabled": "boolean", + "peer": "string", "peer_groups": [ - "chacbco6lnnbn6cg5s91" + "string" ], - "network": "10.64.0.0/24", + "network": "string", "domains": [ - "example.com" + "string" ], - "metric": 9999, - "masquerade": true, + "metric": "integer", + "masquerade": "boolean", "groups": [ - "chacdk86lnnboviihd70" + "string" ], - "keep_route": true, + "keep_route": "boolean", "access_control_groups": [ - "chacbco6lnnbn6cg5s91" + "string" ] -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' } +``` + -response = requests.request("POST", url, headers=headers, data=payload) + -print(response.text) -``` + +--- -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) -func main() { +## Retrieve a Route {{ tag: 'GET', label: '/api/routes/{routeId}' }} - url := "https://api.netbird.io/api/routes" - method := "POST" - - payload := strings.NewReader(`{ - "description": "My first route", - "network_id": "Route 1", - "enabled": true, - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "network": "10.64.0.0/24", - "domains": [ - "example.com" - ], - "metric": 9999, - "masquerade": true, - "groups": [ - "chacdk86lnnboviihd70" - ], - "keep_route": true, - "access_control_groups": [ - "chacbco6lnnbn6cg5s91" - ] -}`) - 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() - 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" + +Get information about a Routes -url = URI("https://api.netbird.io/api/routes") +### Path Parameters -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 " + + +The unique identifier of a route + -request.body = JSON.dump({ - "description": "My first route", - "network_id": "Route 1", - "enabled": true, - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "network": "10.64.0.0/24", - "domains": [ - "example.com" - ], - "metric": 9999, - "masquerade": true, - "groups": [ - "chacdk86lnnboviihd70" - ], - "keep_route": true, - "access_control_groups": [ - "chacbco6lnnbn6cg5s91" - ] -}) -response = https.request(request) -puts response.read_body -``` + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "description": "My first route", - "network_id": "Route 1", - "enabled": true, - "peer": "chacbco6lnnbn6cg5s91", + + + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/routes/{routeId} \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' +``` + + +```json {{ title: 'Example' }} +{ + "id": "string", + "network_type": "string", + "description": "string", + "network_id": "string", + "enabled": "boolean", + "peer": "string", "peer_groups": [ - "chacbco6lnnbn6cg5s91" + "string" ], - "network": "10.64.0.0/24", + "network": "string", "domains": [ - "example.com" + "string" ], - "metric": 9999, - "masquerade": true, + "metric": "integer", + "masquerade": "boolean", "groups": [ - "chacdk86lnnboviihd70" + "string" ], - "keep_route": true, + "keep_route": "boolean", "access_control_groups": [ - "chacbco6lnnbn6cg5s91" + "string" ] -}'); -Request request = new Request.Builder() - .url("https://api.netbird.io/api/routes") - .method("POST", body) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); +} ``` -```php - 'https://api.netbird.io/api/routes', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'POST', - CURLOPT_POSTFIELDS => '{ - "description": "My first route", - "network_id": "Route 1", - "enabled": true, - "peer": "chacbco6lnnbn6cg5s91", +```json {{ title: 'Schema' }} +{ + "id": "string", + "network_type": "string", + "description": "string", + "network_id": "string", + "enabled": "boolean", + "peer": "string", "peer_groups": [ - "chacbco6lnnbn6cg5s91" + "string" ], - "network": "10.64.0.0/24", + "network": "string", "domains": [ - "example.com" + "string" ], - "metric": 9999, - "masquerade": true, + "metric": "integer", + "masquerade": "boolean", "groups": [ - "chacdk86lnnboviihd70" + "string" ], - "keep_route": true, + "keep_route": "boolean", "access_control_groups": [ - "chacbco6lnnbn6cg5s91" + "string" ] -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; +} ``` + - - - - -```json {{ title: 'Example' }} -{ + + + +--- + + + +## 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. + + + + + + + + +```bash {{ title: 'cURL' }} +curl -X PUT https://api.netbird.io/api/routes/{routeId} \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ "id": "chacdk86lnnboviihd7g", "network_type": "IPv4", "description": "My first route", @@ -631,9 +419,11 @@ echo $response; "access_control_groups": [ "chacbco6lnnbn6cg5s91" ] -} +}' ``` -```json {{ title: 'Schema' }} + + +```json {{ title: 'Example' }} { "id": "string", "network_type": "string", @@ -659,206 +449,7 @@ echo $response; ] } ``` - - - - - - ---- - -## Retrieve a Route {{ tag: 'GET' , label: '/api/routes/{routeId}' }} - - - - 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 -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/routes/{routeId}', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/routes/{routeId}" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/routes/{routeId}" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` - -```ruby -require "uri" -require "json" -require "net/http" - -url = URI("https://api.netbird.io/api/routes/{routeId}") - -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true - -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/routes/{routeId}") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/routes/{routeId}', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'GET', - CURLOPT_HTTPHEADER => array( - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` - - - - - -```json {{ title: 'Example' }} -{ - "id": "chacdk86lnnboviihd7g", - "network_type": "IPv4", - "description": "My first route", - "network_id": "Route 1", - "enabled": true, - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "network": "10.64.0.0/24", - "domains": [ - "example.com" - ], - "metric": 9999, - "masquerade": true, - "groups": [ - "chacdk86lnnboviihd70" - ], - "keep_route": true, - "access_control_groups": [ - "chacbco6lnnbn6cg5s91" - ] -} -``` ```json {{ title: 'Schema' }} { "id": "string", @@ -885,626 +476,44 @@ echo $response; ] } ``` - - - - - + ---- - - -## 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. - - - - - - - - - -```bash {{ title: 'cURL' }} -curl -X PUT https://api.netbird.io/api/routes/{routeId} \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "description": "My first route", - "network_id": "Route 1", - "enabled": true, - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "network": "10.64.0.0/24", - "domains": [ - "example.com" - ], - "metric": 9999, - "masquerade": true, - "groups": [ - "chacdk86lnnboviihd70" - ], - "keep_route": true, - "access_control_groups": [ - "chacbco6lnnbn6cg5s91" - ] -}' -``` - -```js -const axios = require('axios'); -let data = JSON.stringify({ - "description": "My first route", - "network_id": "Route 1", - "enabled": true, - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "network": "10.64.0.0/24", - "domains": [ - "example.com" - ], - "metric": 9999, - "masquerade": true, - "groups": [ - "chacdk86lnnboviihd70" - ], - "keep_route": true, - "access_control_groups": [ - "chacbco6lnnbn6cg5s91" - ] -}); -let config = { - method: 'put', - maxBodyLength: Infinity, - url: '/api/routes/{routeId}', - 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 -import requests -import json - -url = "https://api.netbird.io/api/routes/{routeId}" -payload = json.dumps({ - "description": "My first route", - "network_id": "Route 1", - "enabled": true, - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "network": "10.64.0.0/24", - "domains": [ - "example.com" - ], - "metric": 9999, - "masquerade": true, - "groups": [ - "chacdk86lnnboviihd70" - ], - "keep_route": true, - "access_control_groups": [ - "chacbco6lnnbn6cg5s91" - ] -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("PUT", url, headers=headers, data=payload) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/routes/{routeId}" - method := "PUT" - - payload := strings.NewReader(`{ - "description": "My first route", - "network_id": "Route 1", - "enabled": true, - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "network": "10.64.0.0/24", - "domains": [ - "example.com" - ], - "metric": 9999, - "masquerade": true, - "groups": [ - "chacdk86lnnboviihd70" - ], - "keep_route": true, - "access_control_groups": [ - "chacbco6lnnbn6cg5s91" - ] -}`) - 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() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` - -```ruby -require "uri" -require "json" -require "net/http" - -url = URI("https://api.netbird.io/api/routes/{routeId}") - -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true - -request = Net::HTTP::Put.new(url) -request["Content-Type"] = "application/json" -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -request.body = JSON.dump({ - "description": "My first route", - "network_id": "Route 1", - "enabled": true, - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "network": "10.64.0.0/24", - "domains": [ - "example.com" - ], - "metric": 9999, - "masquerade": true, - "groups": [ - "chacdk86lnnboviihd70" - ], - "keep_route": true, - "access_control_groups": [ - "chacbco6lnnbn6cg5s91" - ] -}) -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "description": "My first route", - "network_id": "Route 1", - "enabled": true, - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "network": "10.64.0.0/24", - "domains": [ - "example.com" - ], - "metric": 9999, - "masquerade": true, - "groups": [ - "chacdk86lnnboviihd70" - ], - "keep_route": true, - "access_control_groups": [ - "chacbco6lnnbn6cg5s91" - ] -}'); -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 ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/routes/{routeId}', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'PUT', - CURLOPT_POSTFIELDS => '{ - "description": "My first route", - "network_id": "Route 1", - "enabled": true, - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "network": "10.64.0.0/24", - "domains": [ - "example.com" - ], - "metric": 9999, - "masquerade": true, - "groups": [ - "chacdk86lnnboviihd70" - ], - "keep_route": true, - "access_control_groups": [ - "chacbco6lnnbn6cg5s91" - ] -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` - - - - - -```json {{ title: 'Example' }} -{ - "id": "chacdk86lnnboviihd7g", - "network_type": "IPv4", - "description": "My first route", - "network_id": "Route 1", - "enabled": true, - "peer": "chacbco6lnnbn6cg5s91", - "peer_groups": [ - "chacbco6lnnbn6cg5s91" - ], - "network": "10.64.0.0/24", - "domains": [ - "example.com" - ], - "metric": 9999, - "masquerade": true, - "groups": [ - "chacdk86lnnboviihd70" - ], - "keep_route": true, - "access_control_groups": [ - "chacbco6lnnbn6cg5s91" - ] -} -``` -```json {{ title: 'Schema' }} -{ - "id": "string", - "network_type": "string", - "description": "string", - "network_id": "string", - "enabled": "boolean", - "peer": "string", - "peer_groups": [ - "string" - ], - "network": "string", - "domains": [ - "string" - ], - "metric": "integer", - "masquerade": "boolean", - "groups": [ - "string" - ], - "keep_route": "boolean", - "access_control_groups": [ - "string" - ] -} -``` - - - - - --- -## Delete a Route {{ tag: 'DELETE' , label: '/api/routes/{routeId}' }} - - - - 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 ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'delete', - maxBodyLength: Infinity, - url: '/api/routes/{routeId}', - 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/routes/{routeId}" - -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() { +## Delete a Route {{ tag: 'DELETE', label: '/api/routes/{routeId}' }} - url := "https://api.netbird.io/api/routes/{routeId}" - method := "DELETE" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Authorization", "Token ") - - 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" + +Delete a route -url = URI("https://api.netbird.io/api/routes/{routeId}") +### Path Parameters -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true -request = Net::HTTP::Delete.new(url) -request["Authorization"] = "Token " + + +The unique identifier of a route + -response = https.request(request) -puts response.read_body -``` + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); + -Request request = new Request.Builder() - .url("https://api.netbird.io/api/routes/{routeId}") - .method("DELETE") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); + + +```bash {{ title: 'cURL' }} +curl -X DELETE https://api.netbird.io/api/routes/{routeId} \ +-H 'Authorization: Token ' \ ``` + -```php - 'https://api.netbird.io/api/routes/{routeId}', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'DELETE', - CURLOPT_HTTPHEADER => array( - 'Authorization: Token ' - ), -)); - -$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..df83c292 100644 --- a/src/pages/ipa/resources/setup-keys.mdx +++ b/src/pages/ipa/resources/setup-keys.mdx @@ -1,187 +1,48 @@ 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 -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/setup-keys', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/setup-keys" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/setup-keys" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` - -```ruby -require "uri" -require "json" -require "net/http" - -url = URI("https://api.netbird.io/api/setup-keys") - -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true - -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/setup-keys") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/setup-keys', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'GET', - CURLOPT_HTTPHEADER => array( - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` - - - - - + + ```json {{ title: 'Example' }} [ { - "id": 2531583362, - "name": "Default key", - "expires": "2023-06-01T14:47:22.291057Z", - "type": "reusable", - "valid": true, - "revoked": false, - "used_times": 2, - "last_used": "2023-05-05T09:00:35.477782Z", - "state": "valid", + "id": "string", + "name": "string", + "expires": "string", + "type": "string", + "valid": "boolean", + "revoked": "boolean", + "used_times": "integer", + "last_used": "string", + "state": "string", "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" + "string" ], - "updated_at": "2023-05-05T09:00:35.477782Z", - "usage_limit": 0, - "ephemeral": true, - "allow_extra_dns_labels": true, - "key": "A6160****" + "updated_at": "string", + "usage_limit": "integer", + "ephemeral": "boolean", + "allow_extra_dns_labels": "boolean", + "key": "string" } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -205,298 +66,61 @@ 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' \ -H 'Content-Type: application/json' \ -H 'Authorization: Token ' \ --data-raw '{ - "name": "Default key", - "type": "reusable", - "expires_in": 86400, - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "usage_limit": 0, - "ephemeral": true, - "allow_extra_dns_labels": true -}' -``` - -```js -const axios = require('axios'); -let data = JSON.stringify({ - "name": "Default key", - "type": "reusable", - "expires_in": 86400, - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "usage_limit": 0, - "ephemeral": true, - "allow_extra_dns_labels": true -}); -let config = { - method: 'post', - maxBodyLength: Infinity, - url: '/api/setup-keys', - 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 -import requests -import json - -url = "https://api.netbird.io/api/setup-keys" -payload = json.dumps({ - "name": "Default key", - "type": "reusable", - "expires_in": 86400, - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "usage_limit": 0, - "ephemeral": true, - "allow_extra_dns_labels": true -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("POST", url, headers=headers, data=payload) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/setup-keys" - method := "POST" - - payload := strings.NewReader(`{ - "name": "Default key", - "type": "reusable", - "expires_in": 86400, - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "usage_limit": 0, - "ephemeral": true, - "allow_extra_dns_labels": true -}`) - client := &http.Client { - } - req, err := http.NewRequest(method, url, payload) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Content-Type", "application/json") - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` - -```ruby -require "uri" -require "json" -require "net/http" - -url = URI("https://api.netbird.io/api/setup-keys") - -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true - -request = Net::HTTP::Post.new(url) -request["Content-Type"] = "application/json" -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -request.body = JSON.dump({ - "name": "Default key", - "type": "reusable", - "expires_in": 86400, - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "usage_limit": 0, - "ephemeral": true, - "allow_extra_dns_labels": true -}) -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "name": "Default key", - "type": "reusable", - "expires_in": 86400, - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "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 ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/setup-keys', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'POST', - CURLOPT_POSTFIELDS => '{ - "name": "Default key", - "type": "reusable", - "expires_in": 86400, - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "usage_limit": 0, - "ephemeral": true, - "allow_extra_dns_labels": true -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` - - - - - -```json {{ title: 'Example' }} -{ "id": 2531583362, "name": "Default key", "expires": "2023-06-01T14:47:22.291057Z", @@ -514,9 +138,11 @@ echo $response; "ephemeral": true, "allow_extra_dns_labels": true, "key": "A616097E-FCF0-48FA-9354-CA4A61142761" -} +}' ``` -```json {{ title: 'Schema' }} + + +```json {{ title: 'Example' }} { "id": "string", "name": "string", @@ -537,201 +163,88 @@ echo $response; "key": "string" } ``` - - - - - - ---- - -## 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 - - - - - - -```bash {{ title: 'cURL' }} -curl -X GET https://api.netbird.io/api/setup-keys/{keyId} \ --H 'Accept: application/json' \ --H 'Authorization: Token ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/setup-keys/{keyId}', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/setup-keys/{keyId}" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' +```json {{ title: 'Schema' }} +{ + "id": "string", + "name": "string", + "expires": "string", + "type": "string", + "valid": "boolean", + "revoked": "boolean", + "used_times": "integer", + "last_used": "string", + "state": "string", + "auto_groups": [ + "string" + ], + "updated_at": "string", + "usage_limit": "integer", + "ephemeral": "boolean", + "allow_extra_dns_labels": "boolean", + "key": "string" } +``` + -response = requests.request("GET", url, headers=headers) + -print(response.text) -``` + +--- -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) -func main() { +## Retrieve a Setup Key {{ tag: 'GET', label: '/api/setup-keys/{keyId}' }} - url := "https://api.netbird.io/api/setup-keys/{keyId}" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - 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" + +Get information about a setup key -url = URI("https://api.netbird.io/api/setup-keys/{keyId}") +### Path Parameters -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 " + + +The unique identifier of a setup key + -response = https.request(request) -puts response.read_body -``` + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/setup-keys/{keyId}") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/setup-keys/{keyId}', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'GET', - CURLOPT_HTTPHEADER => array( - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/setup-keys/{keyId} \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' ``` - - - - - + + ```json {{ title: 'Example' }} { - "id": 2531583362, - "name": "Default key", - "expires": "2023-06-01T14:47:22.291057Z", - "type": "reusable", - "valid": true, - "revoked": false, - "used_times": 2, - "last_used": "2023-05-05T09:00:35.477782Z", - "state": "valid", + "id": "string", + "name": "string", + "expires": "string", + "type": "string", + "valid": "boolean", + "revoked": "boolean", + "used_times": "integer", + "last_used": "string", + "state": "string", "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" + "string" ], - "updated_at": "2023-05-05T09:00:35.477782Z", - "usage_limit": 0, - "ephemeral": true, - "allow_extra_dns_labels": true, - "key": "A6160****" + "updated_at": "string", + "usage_limit": "integer", + "ephemeral": "boolean", + "allow_extra_dns_labels": "boolean", + "key": "string" } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -753,246 +266,57 @@ echo $response; "key": "string" } ``` - - - - - - ---- + + -## 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 - - - - - - - - - -```bash {{ title: 'cURL' }} -curl -X PUT https://api.netbird.io/api/setup-keys/{keyId} \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "revoked": false, - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ] -}' -``` - -```js -const axios = require('axios'); -let data = JSON.stringify({ - "revoked": false, - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ] -}); -let config = { - method: 'put', - maxBodyLength: Infinity, - url: '/api/setup-keys/{keyId}', - 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 -import requests -import json -url = "https://api.netbird.io/api/setup-keys/{keyId}" -payload = json.dumps({ - "revoked": false, - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ] -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} -response = requests.request("PUT", url, headers=headers, data=payload) +## Update a Setup Key {{ tag: 'PUT', label: '/api/setup-keys/{keyId}' }} -print(response.text) -``` -```go -package main + -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) + +Update information about a setup key -func main() { +### Path Parameters - url := "https://api.netbird.io/api/setup-keys/{keyId}" - method := "PUT" - - payload := strings.NewReader(`{ - "revoked": false, - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ] -}`) - 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() - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` + + +The unique identifier of a setup key + -```ruby -require "uri" -require "json" -require "net/http" + -url = URI("https://api.netbird.io/api/setup-keys/{keyId}") -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true +### Request-Body Parameters -request = Net::HTTP::Put.new(url) -request["Content-Type"] = "application/json" -request["Accept"] = "application/json" -request["Authorization"] = "Token " -request.body = JSON.dump({ - "revoked": false, - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ] -}) -response = https.request(request) -puts response.read_body -``` + + +Setup key revocation status + + +List of group IDs to auto-assign to peers registered with this key + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "revoked": false, - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ] -}'); -Request request = new Request.Builder() - .url("https://api.netbird.io/api/setup-keys/{keyId}") - .method("PUT", body) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/setup-keys/{keyId}', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'PUT', - CURLOPT_POSTFIELDS => '{ - "revoked": false, - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ] -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` + - - - - -```json {{ title: 'Example' }} -{ + + +```bash {{ title: 'cURL' }} +curl -X PUT https://api.netbird.io/api/setup-keys/{keyId} \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ "id": 2531583362, "name": "Default key", "expires": "2023-06-01T14:47:22.291057Z", @@ -1010,9 +334,11 @@ echo $response; "ephemeral": true, "allow_extra_dns_labels": true, "key": "A6160****" -} +}' ``` -```json {{ title: 'Schema' }} + + +```json {{ title: 'Example' }} { "id": "string", "name": "string", @@ -1033,174 +359,66 @@ echo $response; "key": "string" } ``` - - - - - - ---- - -## Delete a Setup Key {{ tag: 'DELETE' , label: '/api/setup-keys/{keyId}' }} - - - - 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 ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'delete', - maxBodyLength: Infinity, - url: '/api/setup-keys/{keyId}', - 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/setup-keys/{keyId}" - -headers = { - 'Authorization': 'Token ' +```json {{ title: 'Schema' }} +{ + "id": "string", + "name": "string", + "expires": "string", + "type": "string", + "valid": "boolean", + "revoked": "boolean", + "used_times": "integer", + "last_used": "string", + "state": "string", + "auto_groups": [ + "string" + ], + "updated_at": "string", + "usage_limit": "integer", + "ephemeral": "boolean", + "allow_extra_dns_labels": "boolean", + "key": "string" } +``` + -response = requests.request("DELETE", url, headers=headers) + -print(response.text) -``` + +--- -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) -func main() { +## Delete a Setup Key {{ tag: 'DELETE', label: '/api/setup-keys/{keyId}' }} - url := "https://api.netbird.io/api/setup-keys/{keyId}" - 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" + +Delete a Setup Key -url = URI("https://api.netbird.io/api/setup-keys/{keyId}") +### Path Parameters -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true -request = Net::HTTP::Delete.new(url) -request["Authorization"] = "Token " + + +The unique identifier of a setup key + -response = https.request(request) -puts response.read_body -``` + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); + -Request request = new Request.Builder() - .url("https://api.netbird.io/api/setup-keys/{keyId}") - .method("DELETE") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); + + +```bash {{ title: 'cURL' }} +curl -X DELETE https://api.netbird.io/api/setup-keys/{keyId} \ +-H 'Authorization: Token ' \ ``` + -```php - 'https://api.netbird.io/api/setup-keys/{keyId}', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => '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..826d375e 100644 --- a/src/pages/ipa/resources/tokens.mdx +++ b/src/pages/ipa/resources/tokens.mdx @@ -1,184 +1,48 @@ 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 - - - - - - -```bash {{ title: 'cURL' }} -curl -X GET https://api.netbird.io/api/users/{userId}/tokens \ --H 'Accept: application/json' \ --H 'Authorization: Token ' -``` -```js -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/users/{userId}/tokens', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` + +Returns a list of all tokens for a user -```python -import requests -import json +### Path Parameters -url = "https://api.netbird.io/api/users/{userId}/tokens" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` - -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/users/{userId}/tokens" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - 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" + + +The unique identifier of a user + -url = URI("https://api.netbird.io/api/users/{userId}/tokens") + -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true + -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/users/{userId}/tokens") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/users/{userId}/tokens', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'GET', - CURLOPT_HTTPHEADER => array( - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/users/{userId}/tokens \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' ``` - - - - - + + ```json {{ title: 'Example' }} [ { - "id": "ch8i54g6lnn4g9hqv7n0", - "name": "My first token", - "expiration_date": "2023-05-05T14:38:28.977616Z", - "created_by": "google-oauth2|277474792786460067937", - "created_at": "2023-05-02T14:48:20.465209Z", - "last_used": "2023-05-04T12:45:25.9723616Z" + "id": "string", + "name": "string", + "expiration_date": "string", + "created_by": "string", + "created_at": "string", + "last_used": "string" } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -191,233 +55,58 @@ echo $response; } ] ``` - - - - - + + + + --- -## 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 - - - - - - - - - -```bash {{ title: 'cURL' }} -curl -X POST https://api.netbird.io/api/users/{userId}/tokens \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "name": "My first token", - "expires_in": 30 -}' -``` +## Create a Token {{ tag: 'POST', label: '/api/users/{userId}/tokens' }} -```js -const axios = require('axios'); -let data = JSON.stringify({ - "name": "My first token", - "expires_in": 30 -}); -let config = { - method: 'post', - maxBodyLength: Infinity, - url: '/api/users/{userId}/tokens', - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': 'Token ' - }, - data : data -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` -```python -import requests -import json - -url = "https://api.netbird.io/api/users/{userId}/tokens" -payload = json.dumps({ - "name": "My first token", - "expires_in": 30 -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} + -response = requests.request("POST", url, headers=headers, data=payload) + +Create a new token for a user -print(response.text) -``` +### Path Parameters -```go -package main - -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) - -func main() { - - url := "https://api.netbird.io/api/users/{userId}/tokens" - method := "POST" - - payload := strings.NewReader(`{ - "name": "My first token", - "expires_in": 30 -}`) - client := &http.Client { - } - req, err := http.NewRequest(method, url, payload) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Content-Type", "application/json") - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - 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)) -} -``` + + +The unique identifier of a user + -```ruby -require "uri" -require "json" -require "net/http" + -url = URI("https://api.netbird.io/api/users/{userId}/tokens") -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true +### Request-Body Parameters -request = Net::HTTP::Post.new(url) -request["Content-Type"] = "application/json" -request["Accept"] = "application/json" -request["Authorization"] = "Token " -request.body = JSON.dump({ - "name": "My first token", - "expires_in": 30 -}) -response = https.request(request) -puts response.read_body -``` + + +Name of the token + + +Expiration in days + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "name": "My first token", - "expires_in": 30 -}'); -Request request = new Request.Builder() - .url("https://api.netbird.io/api/users/{userId}/tokens") - .method("POST", body) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/users/{userId}/tokens', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'POST', - CURLOPT_POSTFIELDS => '{ - "name": "My first token", - "expires_in": 30 -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` + - - - - -```json {{ title: 'Example' }} -{ - "plain_token": {}, + + +```bash {{ title: 'cURL' }} +curl -X POST https://api.netbird.io/api/users/{userId}/tokens \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ + "plain_token": "2023-05-02T14:48:20.465209Z", "personal_access_token": { "id": "ch8i54g6lnn4g9hqv7n0", "name": "My first token", @@ -426,9 +115,11 @@ echo $response; "created_at": "2023-05-02T14:48:20.465209Z", "last_used": "2023-05-04T12:45:25.9723616Z" } -} +}' ``` -```json {{ title: 'Schema' }} + + +```json {{ title: 'Example' }} { "plain_token": "string", "personal_access_token": { @@ -441,194 +132,72 @@ echo $response; } } ``` - - - - - ---- - - -## 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 - - - - - - -```bash {{ title: 'cURL' }} -curl -X GET https://api.netbird.io/api/users/{userId}/tokens/{tokenId} \ --H 'Accept: application/json' \ --H 'Authorization: Token ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/users/{userId}/tokens/{tokenId}', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/users/{userId}/tokens/{tokenId}" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' +```json {{ title: 'Schema' }} +{ + "plain_token": "string", + "personal_access_token": { + "id": "string", + "name": "string", + "expiration_date": "string", + "created_by": "string", + "created_at": "string", + "last_used": "string" + } } +``` + -response = requests.request("GET", url, headers=headers) + -print(response.text) -``` + +--- -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) -func main() { +## Retrieve a Token {{ tag: 'GET', label: '/api/users/{userId}/tokens/{tokenId}' }} - url := "https://api.netbird.io/api/users/{userId}/tokens/{tokenId}" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - 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" + +Returns a specific token for a user -url = URI("https://api.netbird.io/api/users/{userId}/tokens/{tokenId}") +### Path Parameters -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 " + + +The unique identifier of a user + + +The unique identifier of a token + -response = https.request(request) -puts response.read_body -``` + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/users/{userId}/tokens/{tokenId}") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/users/{userId}/tokens/{tokenId}', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'GET', - CURLOPT_HTTPHEADER => array( - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/users/{userId}/tokens/{tokenId} \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' ``` - - - - - + + ```json {{ title: 'Example' }} { - "id": "ch8i54g6lnn4g9hqv7n0", - "name": "My first token", - "expiration_date": "2023-05-05T14:38:28.977616Z", - "created_by": "google-oauth2|277474792786460067937", - "created_at": "2023-05-02T14:48:20.465209Z", - "last_used": "2023-05-04T12:45:25.9723616Z" + "id": "string", + "name": "string", + "expiration_date": "string", + "created_by": "string", + "created_at": "string", + "last_used": "string" } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -639,178 +208,47 @@ echo $response; "last_used": "string" } ``` - - - - - - ---- - - -## 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 - - - - - - -```bash {{ title: 'cURL' }} -curl -X DELETE https://api.netbird.io/api/users/{userId}/tokens/{tokenId} \ --H 'Authorization: Token ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'delete', - maxBodyLength: Infinity, - url: '/api/users/{userId}/tokens/{tokenId}', - 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/users/{userId}/tokens/{tokenId}" - -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() { +## Delete a Token {{ tag: 'DELETE', label: '/api/users/{userId}/tokens/{tokenId}' }} - url := "https://api.netbird.io/api/users/{userId}/tokens/{tokenId}" - method := "DELETE" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Authorization", "Token ") - - 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" + +Delete a token for a user -url = URI("https://api.netbird.io/api/users/{userId}/tokens/{tokenId}") +### Path Parameters -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true -request = Net::HTTP::Delete.new(url) -request["Authorization"] = "Token " + + +The unique identifier of a user + + +The unique identifier of a token + -response = https.request(request) -puts response.read_body -``` + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); + -Request request = new Request.Builder() - .url("https://api.netbird.io/api/users/{userId}/tokens/{tokenId}") - .method("DELETE") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); + + +```bash {{ title: 'cURL' }} +curl -X DELETE https://api.netbird.io/api/users/{userId}/tokens/{tokenId} \ +-H 'Authorization: Token ' \ ``` + -```php - 'https://api.netbird.io/api/users/{userId}/tokens/{tokenId}', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => '', - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 0, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => 'DELETE', - CURLOPT_HTTPHEADER => array( - 'Authorization: Token ' - ), -)); - -$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..9275fe62 100644 --- a/src/pages/ipa/resources/users.mdx +++ b/src/pages/ipa/resources/users.mdx @@ -1,211 +1,79 @@ 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 - - - - - - -```bash {{ title: 'cURL' }} -curl -X GET https://api.netbird.io/api/users \ --H 'Accept: application/json' \ --H 'Authorization: Token ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/api/users', - headers: { - 'Accept': 'application/json', - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json - -url = "https://api.netbird.io/api/users" - -headers = { - 'Accept': 'application/json', - 'Authorization': 'Token ' -} - -response = requests.request("GET", url, headers=headers) - -print(response.text) -``` -```go -package main + +Returns a list of all users -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) +### Path Parameters -func main() { - url := "https://api.netbird.io/api/users" - method := "GET" - - client := &http.Client { - } - req, err := http.NewRequest(method, url, nil) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` - -```ruby -require "uri" -require "json" -require "net/http" + + +Filters users and returns either regular users or service users + -url = URI("https://api.netbird.io/api/users") + -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true + -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " - -response = https.request(request) -puts response.read_body -``` - -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/users") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` - -```php - 'https://api.netbird.io/api/users', - 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; + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/users \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' ``` - - - - - + + ```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", + "id": "string", + "email": "string", + "name": "string", + "role": "string", + "status": "string", + "last_login": "string", "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" + "string" ], - "is_current": true, - "is_service_user": false, - "is_blocked": false, - "issued": "api", + "is_current": "boolean", + "is_service_user": "boolean", + "is_blocked": "boolean", + "issued": "string", "permissions": { - "is_restricted": { - "type": "boolean", - "description": "Indicates whether this User's Peers view is restricted" - }, + "is_restricted": "boolean", "modules": { - "networks": { - "read": true, - "create": false, - "update": false, - "delete": false + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": "boolean" }, - "peers": { - "read": false, - "create": false, - "update": false, - "delete": false + "example": { + "networks": { + "read": true, + "create": false, + "update": false, + "delete": false + }, + "peers": { + "read": false, + "create": false, + "update": false, + "delete": false + } } } } } ] ``` + ```json {{ title: 'Schema' }} [ { @@ -228,10 +96,8 @@ echo $response; "type": "object", "additionalProperties": { "type": "object", - "additionalProperties": "boolean", - "propertyNames": "string" + "additionalProperties": "boolean" }, - "propertyNames": "string", "example": { "networks": { "read": true, @@ -251,274 +117,55 @@ echo $response; } ] ``` - - - - - - ---- - - -## 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 - - - - - - - - - -```bash {{ title: 'cURL' }} -curl -X POST https://api.netbird.io/api/users \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "email": "demo@netbird.io", - "name": "Tom Schulz", - "role": "admin", - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "is_service_user": false -}' -``` - -```js -const axios = require('axios'); -let data = JSON.stringify({ - "email": "demo@netbird.io", - "name": "Tom Schulz", - "role": "admin", - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "is_service_user": false -}); -let config = { - method: 'post', - maxBodyLength: Infinity, - url: '/api/users', - 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 -import requests -import json - -url = "https://api.netbird.io/api/users" -payload = json.dumps({ - "email": "demo@netbird.io", - "name": "Tom Schulz", - "role": "admin", - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "is_service_user": false -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} + -response = requests.request("POST", url, headers=headers, data=payload) + -print(response.text) -``` - -```go -package main + +--- -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) -func main() { - url := "https://api.netbird.io/api/users" - method := "POST" - - payload := strings.NewReader(`{ - "email": "demo@netbird.io", - "name": "Tom Schulz", - "role": "admin", - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "is_service_user": false -}`) - client := &http.Client { - } - req, err := http.NewRequest(method, url, payload) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Content-Type", "application/json") - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() +## Create a User {{ tag: 'POST', label: '/api/users' }} - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return - } - fmt.Println(string(body)) -} -``` -```ruby -require "uri" -require "json" -require "net/http" + -url = URI("https://api.netbird.io/api/users") + +Creates a new service user or sends an invite to a regular user -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true +### Request-Body Parameters -request = Net::HTTP::Post.new(url) -request["Content-Type"] = "application/json" -request["Accept"] = "application/json" -request["Authorization"] = "Token " -request.body = JSON.dump({ - "email": "demo@netbird.io", - "name": "Tom Schulz", - "role": "admin", - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "is_service_user": false -}) -response = https.request(request) -puts response.read_body -``` + + +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 + -```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" - ], - "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 ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/users', - 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 => '{ - "email": "demo@netbird.io", - "name": "Tom Schulz", - "role": "admin", - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "is_service_user": false -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` + - - - - -```json {{ title: 'Example' }} -{ + + +```bash {{ title: 'cURL' }} +curl -X POST https://api.netbird.io/api/users \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ "id": "google-oauth2|277474792786460067937", "email": "demo@netbird.io", "name": "Tom Schulz", @@ -533,10 +180,7 @@ echo $response; "is_blocked": 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, @@ -552,9 +196,11 @@ echo $response; } } } -} +}' ``` -```json {{ title: 'Schema' }} + + +```json {{ title: 'Example' }} { "id": "string", "email": "string", @@ -575,10 +221,8 @@ echo $response; "type": "object", "additionalProperties": { "type": "object", - "additionalProperties": "boolean", - "propertyNames": "string" + "additionalProperties": "boolean" }, - "propertyNames": "string", "example": { "networks": { "read": true, @@ -597,258 +241,102 @@ echo $response; } } ``` - - - - - - ---- - -## 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 - - - - - - - - - -```bash {{ title: 'cURL' }} -curl -X PUT https://api.netbird.io/api/users/{userId} \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ ---data-raw '{ - "role": "admin", +```json {{ title: 'Schema' }} +{ + "id": "string", + "email": "string", + "name": "string", + "role": "string", + "status": "string", + "last_login": "string", "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" + "string" ], - "is_blocked": false -}' + "is_current": "boolean", + "is_service_user": "boolean", + "is_blocked": "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 + } + } + } + } +} ``` + -```js -const axios = require('axios'); -let data = JSON.stringify({ - "role": "admin", - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "is_blocked": false -}); -let config = { - method: 'put', - maxBodyLength: Infinity, - url: '/api/users/{userId}', - 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 -import requests -import json + +--- -url = "https://api.netbird.io/api/users/{userId}" -payload = json.dumps({ - "role": "admin", - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "is_blocked": false -}) -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': 'Token ' -} -response = requests.request("PUT", url, headers=headers, data=payload) -print(response.text) -``` +## Update a User {{ tag: 'PUT', label: '/api/users/{userId}' }} -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) + -func main() { + +Update information about a User - url := "https://api.netbird.io/api/users/{userId}" - method := "PUT" - - payload := strings.NewReader(`{ - "role": "admin", - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "is_blocked": false -}`) - client := &http.Client { - } - req, err := http.NewRequest(method, url, payload) - - if err != nil { - fmt.Println(err) - return - { - - req.Header.Add("Content-Type", "application/json") - req.Header.Add("Accept", "application/json") - req.Header.Add("Authorization", "Token ") - - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return - } - defer res.Body.Close() +### Path Parameters - 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" + + +The unique identifier of a user + -url = URI("https://api.netbird.io/api/users/{userId}") + -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 Parameters -request.body = JSON.dump({ - "role": "admin", - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "is_blocked": false -}) -response = https.request(request) -puts response.read_body -``` -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, '{ - "role": "admin", - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "is_blocked": false -}'); -Request request = new Request.Builder() - .url("https://api.netbird.io/api/users/{userId}") - .method("PUT", body) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + + +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 + -```php - 'https://api.netbird.io/api/users/{userId}', - 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 => '{ - "role": "admin", - "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "is_blocked": false -}', - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/json', - 'Accept: application/json', - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` + - - - - -```json {{ title: 'Example' }} -{ + + + + +```bash {{ title: 'cURL' }} +curl -X PUT https://api.netbird.io/api/users/{userId} \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ "id": "google-oauth2|277474792786460067937", "email": "demo@netbird.io", "name": "Tom Schulz", @@ -863,10 +351,7 @@ echo $response; "is_blocked": 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, @@ -882,9 +367,11 @@ echo $response; } } } -} +}' ``` -```json {{ title: 'Schema' }} + + +```json {{ title: 'Example' }} { "id": "string", "email": "string", @@ -905,10 +392,8 @@ echo $response; "type": "object", "additionalProperties": { "type": "object", - "additionalProperties": "boolean", - "propertyNames": "string" + "additionalProperties": "boolean" }, - "propertyNames": "string", "example": { "networks": { "read": true, @@ -927,537 +412,190 @@ echo $response; } } ``` - - - - - - ---- - - -## 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 - - - - - - -```bash {{ title: 'cURL' }} -curl -X DELETE https://api.netbird.io/api/users/{userId} \ --H 'Authorization: Token ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'delete', - maxBodyLength: Infinity, - url: '/api/users/{userId}', - 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/users/{userId}" - -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/users/{userId}" - 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 +```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", + "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 + } + } + } } - fmt.Println(string(body)) } ``` + -```ruby -require "uri" -require "json" -require "net/http" - -url = URI("https://api.netbird.io/api/users/{userId}") - -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}") - .method("DELETE") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/users/{userId}', - 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; -``` - - - - - - - --- -## Resend user invitation {{ tag: 'POST' , label: '/api/users/{userId}/invite' }} - - - 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 ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'post', - maxBodyLength: Infinity, - url: '/api/users/{userId}/invite', - headers: { - 'Authorization': 'Token ' - } -}; - -axios(config) -.then((response) => { - console.log(JSON.stringify(response.data)); -}) -.catch((error) => { - console.log(error); -}); -``` - -```python -import requests -import json +## Delete a User {{ tag: 'DELETE', label: '/api/users/{userId}' }} -url = "https://api.netbird.io/api/users/{userId}/invite" -headers = { - 'Authorization': 'Token ' -} + -response = requests.request("POST", url, headers=headers) + +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. -print(response.text) -``` +### Path Parameters -```go -package main -import ( - "fmt" - "strings" - "net/http" - "io/ioutil" -) + + +The unique identifier of a user + -func main() { + - url := "https://api.netbird.io/api/users/{userId}/invite" - method := "POST" - - 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)) -} + + +```bash {{ title: 'cURL' }} +curl -X DELETE https://api.netbird.io/api/users/{userId} \ +-H 'Authorization: Token ' \ ``` + -```ruby -require "uri" -require "json" -require "net/http" + -url = URI("https://api.netbird.io/api/users/{userId}/invite") + +--- -https = Net::HTTP.new(url.host, url.port) -https.use_ssl = true -request = Net::HTTP::Post.new(url) -request["Authorization"] = "Token " -response = https.request(request) -puts response.read_body -``` +## Resend user invitation {{ tag: 'POST', label: '/api/users/{userId}/invite' }} -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); -Request request = new Request.Builder() - .url("https://api.netbird.io/api/users/{userId}/invite") - .method("POST") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + -```php - 'https://api.netbird.io/api/users/{userId}/invite', - 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_HTTPHEADER => array( - 'Authorization: Token ' - ), -)); - -$response = curl_exec($curl); - -curl_close($curl); -echo $response; -``` + +Resend user invitation - - - - - - +### Path Parameters ---- + + +The unique identifier of a user + -## 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 \ +curl -X POST https://api.netbird.io/api/users/{userId}/invite \ -H 'Accept: application/json' \ --H 'Authorization: Token ' -``` - -```js -const axios = require('axios'); - -let config = { - method: 'get', - maxBodyLength: Infinity, - url: '/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 -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) +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '' ``` + -```go -package main - -import ( - "fmt" - "strings" - "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 -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 +## Retrieve current user {{ tag: 'GET', label: '/api/users/current' }} -request = Net::HTTP::Get.new(url) -request["Accept"] = "application/json" -request["Authorization"] = "Token " -response = https.request(request) -puts response.read_body -``` + -```java -OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - -Request request = new Request.Builder() - .url("https://api.netbird.io/api/users/current") - .method("GET") - .addHeader("Accept", "application/json") - .addHeader("Authorization: Token ") - .build(); -Response response = client.newCall(request).execute(); -``` + +Get information about the current user + -```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; + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/users/current \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' ``` - - - - - + + ```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", + "id": "string", + "email": "string", + "name": "string", + "role": "string", + "status": "string", + "last_login": "string", "auto_groups": [ - "ch8i4ug6lnn4g9hqv7m0" + "string" ], - "is_current": true, - "is_service_user": false, - "is_blocked": false, - "issued": "api", + "is_current": "boolean", + "is_service_user": "boolean", + "is_blocked": "boolean", + "issued": "string", "permissions": { - "is_restricted": { - "type": "boolean", - "description": "Indicates whether this User's Peers view is restricted" - }, + "is_restricted": "boolean", "modules": { - "networks": { - "read": true, - "create": false, - "update": false, - "delete": false + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": "boolean" }, - "peers": { - "read": false, - "create": false, - "update": false, - "delete": false + "example": { + "networks": { + "read": true, + "create": false, + "update": false, + "delete": false + }, + "peers": { + "read": false, + "create": false, + "update": false, + "delete": false + } } } } } ``` + ```json {{ title: 'Schema' }} { "id": "string", @@ -1479,10 +617,8 @@ echo $response; "type": "object", "additionalProperties": { "type": "object", - "additionalProperties": "boolean", - "propertyNames": "string" + "additionalProperties": "boolean" }, - "propertyNames": "string", "example": { "networks": { "read": true, @@ -1501,10 +637,9 @@ echo $response; } } ``` - - - - - + + + + --- From d807625cce99c347dd9b22ec81c47bac42f77c1f Mon Sep 17 00:00:00 2001 From: aliamerj Date: Sat, 20 Sep 2025 20:54:54 +0300 Subject: [PATCH 2/5] fix bugs && complete the parser --- openapi-gen/index.ts | 59 ++- openapi-gen/templates/ApiTemplate.tsx | 192 ++++---- openapi-gen/tsconfig.json | 1 - openapi-gen/tsxParser/api/requests.ts | 67 ++- openapi-gen/tsxParser/components/index.tsx | 44 +- openapi-gen/tsxParser/openapi-extractor.ts | 502 ++++++++++----------- openapi-gen/tsxParser/renderToMDX.ts | 19 +- src/components/NavigationAPI.jsx | 1 - src/components/Resources.jsx | 11 - src/pages/ipa/resources/accounts.mdx | 147 +++--- src/pages/ipa/resources/dns.mdx | 124 +++-- src/pages/ipa/resources/events.mdx | 108 +++-- src/pages/ipa/resources/geo-locations.mdx | 10 +- src/pages/ipa/resources/groups.mdx | 122 ++--- src/pages/ipa/resources/ingress-ports.mdx | 275 +++++------ src/pages/ipa/resources/networks.mdx | 346 +++++++------- src/pages/ipa/resources/peers.mdx | 213 ++++----- src/pages/ipa/resources/policies.mdx | 464 ++++++++++++------- src/pages/ipa/resources/posture-checks.mdx | 492 ++++++++++++++++---- src/pages/ipa/resources/routes.mdx | 168 +++---- src/pages/ipa/resources/setup-keys.mdx | 141 +++--- src/pages/ipa/resources/tokens.mdx | 55 +-- src/pages/ipa/resources/users.mdx | 337 ++++++++------ 23 files changed, 2172 insertions(+), 1726 deletions(-) diff --git a/openapi-gen/index.ts b/openapi-gen/index.ts index 7e6011fd..45bd89f5 100644 --- a/openapi-gen/index.ts +++ b/openapi-gen/index.ts @@ -13,36 +13,47 @@ import { mkdir, writeFile } from "fs/promises" console.error('Usage: ts-node index.ts '); process.exit(1); } - const outputDir = process.argv[3] || path.join('..', 'src', 'pages', 'ipa', 'resources'); - const yml = await readYaml(inputUrl) - const mdxFile: Record = {} + const outputDir = process.argv[3] || path.join('src', 'pages', 'ipa', 'resources'); + try { + const yml = await readYaml(inputUrl) - const { endpoints } = extractSpec(yml) - endpoints.forEach(endpoint => { - if (!endpoint.tag) { - console.error('No tag for this endpoint:', endpoint.path) - return - } + const mdxFile: Record = {} + const customFlags: string[] = [] + const endpoints = extractSpec(yml) - if (!mdxFile[endpoint.tag]) { - mdxFile[endpoint.tag] = [] - } + endpoints.forEach(endpoint => { + if (!endpoint.tag) { + console.error('No tag for this endpoint:', endpoint.path) + return + } - mdxFile[endpoint.tag].push(endpoint) - }) + if (!mdxFile[endpoint.tag]) { + mdxFile[endpoint.tag] = [] + } - for (let tag in mdxFile) { - const element = React.createElement(ApiTemplate, { tag: tag, endpoints: mdxFile[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) - } + mdxFile[endpoint.tag].push(endpoint) + const ymlTag = yml.tags.find(tag => tag.name == endpoint.tag) + if (!ymlTag) return; + for (let flag in ymlTag) { + if (flag.startsWith('x-') && ymlTag[flag]) { + customFlags.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}`); @@ -53,5 +64,3 @@ async function readYaml(url: string) { } return parsed; } - - diff --git a/openapi-gen/templates/ApiTemplate.tsx b/openapi-gen/templates/ApiTemplate.tsx index 8a235483..b150c7b3 100644 --- a/openapi-gen/templates/ApiTemplate.tsx +++ b/openapi-gen/templates/ApiTemplate.tsx @@ -1,53 +1,56 @@ import { Endpoint, Parameter, Request } from "../tsxParser/openapi-extractor" -import { CodeGroup, Col, Row, Stringify, Property, Properties, Details, Summary } from "../tsxParser/components" +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}: ApiTemplateProps) => { +export const ApiTemplate = ({ tag, endpoints, customFlags }: ApiTemplateProps) => { return ( <> - {endpoints.map((ap, index) => { + {endpoints.map((end, index) => { + const flags = customFlags ? [...customFlags, ...end.flags] : end.flags return ( -
+

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

- {ap.description} + {end.description} {/* Handle Path Parameters for all methods that might have them */} - {ap.parameters && ap.parameters.length > 0 && ( - + {end.parameters && end.parameters.length > 0 && ( + )} {/* Handle Request Body for POST/PUT methods */} - {(ap.method === "POST" || ap.method === "PUT") && ap.request && ( - + {(end.method === "POST" || end.method === "PUT") && end.request && ( + )} - {ap.responses["200"]?.schema && + {end.responses["200"]?.schema && } - {ap.responses["201"]?.schema && + {end.responses["201"]?.schema && } @@ -60,86 +63,109 @@ export const ApiTemplate = ({ tag, endpoints}: ApiTemplateProps) => { } const ParametersApi = ({ parameters }: { parameters: Parameter[] }) => { - return ( - <> -

Path Parameters

- - {parameters.map((p, index) => { - return ( - - {p.description} - - ) - })} - - - ) -} + const params: Parameter[] = []; + const query: Parameter[] = []; + for (let p of parameters) { + if (p.in === "query") { + query.push(p) + } else { + params.push(p) + } + } -const PostBodyApi = ({ bodyRequest }: { bodyRequest: Request[] }) => { return ( <> -

Request-Body Parameters

- - {bodyRequest.map((req, index) => { - if (req.type === "object[]" || req.type === "object") { + {params.length > 0 && <> +

Path Parameters

+ + {params.map((p, index) => { return ( -
- {req.description || "Object list"} - - - {req?.bodyObj?.map((ob, objIndex) => { - return ( - - {ob.description} - - ) - })} - - -
+ {p.description}
) - } else { - // Handle regular properties (not object arrays) + })} +
+ } + {query.length > 0 && <> +

Query Parameters

+ + {query.map((p, index) => { return ( - {req.description} + {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 index ed71152f..d383a84e 100644 --- a/openapi-gen/tsconfig.json +++ b/openapi-gen/tsconfig.json @@ -1,4 +1,3 @@ -// generator files need their own tsconfig.json because they don't like "module": "esnext" setting that nextjs requires in the main tsconfig { "compilerOptions": { "target": "ES2020", diff --git a/openapi-gen/tsxParser/api/requests.ts b/openapi-gen/tsxParser/api/requests.ts index 73e3b6ad..59572825 100644 --- a/openapi-gen/tsxParser/api/requests.ts +++ b/openapi-gen/tsxParser/api/requests.ts @@ -1,17 +1,29 @@ -export const requestCode = (method: string, url: string, body: string) => { - switch (method) { +import { Endpoint } from "../../tsxParser/openapi-extractor" + + +export const requestCode = (endPoint: Endpoint) => { + const body = {}; + endPoint?.request?.map(req => { + if (req.example !== undefined) { + body[req.name] = req.example + } + }) + + const bodyJson = JSON.stringify(body, null, 2) + + switch (endPoint.method) { case 'GET': - return getRequestCode(url) + return getRequestCode(endPoint.path) case "POST": - return postRequestCode(url, body) + return postRequestCode(endPoint.path, bodyJson) case "PUT": - return putRequestCode(url, body) + return putRequestCode(endPoint.path, bodyJson) case "DELETE": - return deleteRequestCode(url) + return deleteRequestCode(endPoint.path) } } -const deleteRequestCode = (url:string) => { +const deleteRequestCode = (url: string) => { const langCode = [] langCode.push(`\`\`\`bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io${url} \\ @@ -21,30 +33,39 @@ curl -X DELETE https://api.netbird.io${url} \\ return langCode } -const putRequestCode = (url:string, body:string) => { +const putRequestCode = (url: string, body: string | null) => { const langCode = [] - langCode.push(`\`\`\`bash {{ title: 'cURL' }} -curl -X PUT https://api.netbird.io${url} \\ --H 'Accept: application/json' \\ --H 'Content-Type: application/json' \\ --H 'Authorization: Token ' \\ ---data-raw '${body}' -\`\`\``) + const lines: string[] = [ + `curl -X PUT https://api.netbird.io${url} \\`, + `-H 'Authorization: Token ' \\`, + ] + if (body && body !== "{}") { + lines.push(`-H 'Accept: application/json' \\`) + lines.push(`-H 'Content-Type: application/json' \\`) + lines.push(`--data-raw '${body}'`) + } + + langCode.push(`\`\`\`bash {{ title: 'cURL' }}\n${lines.join("\n")}\n\`\`\``) return langCode } -const postRequestCode = (url: string, body: string) => { +const postRequestCode = (url: string, body: string | null) => { const langCode = [] - langCode.push(`\`\`\`bash {{ title: 'cURL' }} -curl -X POST https://api.netbird.io${url} \\ --H 'Accept: application/json' \\ --H 'Content-Type: application/json' \\ --H 'Authorization: Token ' \\ ---data-raw '${body}' -\`\`\``) + const lines: string[] = [ + `curl -X POST https://api.netbird.io${url} \\`, + `-H 'Authorization: Token ' \\`, + ] + + if (body && body !== "{}") { + lines.push(`-H 'Accept: application/json' \\`) + lines.push(`-H 'Content-Type: application/json' \\`) + lines.push(`--data-raw '${body}'`) + } + + langCode.push(`\`\`\`bash {{ title: 'cURL' }}\n${lines.join("\n")}\n\`\`\``) return langCode } diff --git a/openapi-gen/tsxParser/components/index.tsx b/openapi-gen/tsxParser/components/index.tsx index d4619d8b..dff49122 100644 --- a/openapi-gen/tsxParser/components/index.tsx +++ b/openapi-gen/tsxParser/components/index.tsx @@ -24,8 +24,6 @@ export const Summary = ({ children }: { children: React.ReactNode }) => <> - - export const Col = ({ children, sticky }: { children: React.ReactNode, sticky?: boolean }) => <> {"\n<"}Col{sticky ? ' sticky' : ""}{">\n"} {children} @@ -38,17 +36,41 @@ export const Properties = ({ 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, + maxLen?: number enumList?: string[] + children: React.ReactNode, } -export const Property = ({ name, type, required, minLen, maxLen, enumList, children }: PropertyProps) => { +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() : "" ); @@ -56,8 +78,10 @@ export const Property = ({ name, type, required, minLen, maxLen, enumList, child if (name) header += `name="${name}"` if (type) header += ` type="${type}"` if (required) header += ` required={${required}}` - if (minLen) header += ` minLen={${minLen}}` - if (maxLen) header += ` maxLen={${maxLen}}` + if (min != undefined) header += ` min={${min}}` + if (max != undefined) header += ` max={${max}}` + if (minLen != undefined) header += ` minLen={${minLen}}` + if (maxLen != undefined) header += ` maxLen={${maxLen}}` if (enumList && enumList.length === 0) header += `enumList={[${enumList.join(",")}]}` header += " >\n" @@ -88,12 +112,12 @@ export const CodeGroup = ({ title, endPoint }: CodeGroupProps) => { const schemaJson = obj?.schema ? JSON.stringify(obj.schema, null, 2) : "" let langCode = [] - if (title === "Request") langCode = requestCode(tag, label, exampleJson) - if (title === "Response") langCode = responseCode(schemaJson, schemaJson) + if (title === "Request") langCode = requestCode(endPoint) + if (title === "Response") langCode = responseCode(schemaJson, exampleJson) let header = "\n`; diff --git a/openapi-gen/tsxParser/openapi-extractor.ts b/openapi-gen/tsxParser/openapi-extractor.ts index 357748a5..cb509195 100644 --- a/openapi-gen/tsxParser/openapi-extractor.ts +++ b/openapi-gen/tsxParser/openapi-extractor.ts @@ -18,10 +18,11 @@ export type Request = { type: string required: boolean description?: string - minLen?: number - maxLen?: number + minLength?: number, + maxLength?: number, minimum?: number maximum?: number + example?: string enumList?: any[] bodyObj?: Request[] } @@ -34,9 +35,126 @@ export type Endpoint = { parameters?: Parameter[] responses: Record request?: Request[] | null - tag: string + 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") @@ -132,13 +250,10 @@ function dereferenceNode(node: any, doc: OpenAPIV3_1.Document, seenRefs = new Se return mergeAllOfParts(node.allOf, doc, seenRefs) } - // anyOf/oneOf: return array of resolved options (keep as oneOf/anyOf structure) + // 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))) } } - if (Array.isArray(node.anyOf)) { - return { anyOf: node.anyOf.map((opt: any) => dereferenceNode(opt, doc, new Set(seenRefs))) } - } // arrays: dereference items if (node.type === 'array' || node.items) { @@ -146,8 +261,8 @@ function dereferenceNode(node: any, doc: OpenAPIV3_1.Document, seenRefs = new Se const derefItems = dereferenceNode(items, doc, new Set(seenRefs)) // return normalized array node const arr: any = { type: 'array', items: derefItems } - if (node.minItems !== undefined) arr.minItems = node.minItems - if (node.maxItems !== undefined) arr.maxItems = node.maxItems + 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 @@ -345,20 +460,9 @@ function extractFromSchema(node: any, doc: OpenAPIV3_1.Document, seenRefs = new return { schema: null, example: null } } - - -/* ----------------- helpers ----------------- */ - -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 - } -} - +/** + * 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)) { @@ -377,6 +481,23 @@ function defaultForSchema(schemaRep: any) { 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)) { @@ -396,6 +517,12 @@ function buildSchemaRepresentationFromExample(example: any): any { 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, @@ -405,136 +532,75 @@ function schemaNodeToRequests( ): Request[] { if (!node) return [] - // If node is a string ref like '#/components/...' -> resolve and recurse - if (typeof node === 'string' && node.startsWith('#/')) { - const resolved = resolveRef(node, doc) - return schemaNodeToRequests(resolved, doc, nameForRoot, requiredNames, seenRefs) - } + // Normalize & dereference first (this resolves $ref, merges allOf, derefs children) + const normalized = dereferenceNode(node, doc, seenRefs) ?? node - // If it's a $ref object, resolve (avoid infinite loop) - if (node.$ref) { - const ref = node.$ref as string - if (seenRefs.has(ref)) { - // circular: return a placeholder - return [{ name: nameForRoot, type: ref, required: requiredNames.includes(nameForRoot) }] - } - seenRefs.add(ref) - const resolved = resolveRef(ref, doc) - if (!resolved) return [{ name: nameForRoot, type: ref, required: requiredNames.includes(nameForRoot) }] + // 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) } - // If oneOf -> produce one Request entry with type 'oneOf' and bodyObj containing options - if (Array.isArray(node.oneOf)) { - const options: Request[] = node.oneOf.map((opt: any, idx: number) => { - const optReqs = schemaNodeToRequests(opt, doc, `option_${idx+1}`, [], new Set(seenRefs)) - if (optReqs.length === 1 && optReqs[0].type === 'object' && optReqs[0].bodyObj) { - return { - name: `Option ${idx+1}`, - type: 'object', - required: true, - description: opt.description || undefined, - bodyObj: optReqs[0].bodyObj - } - } - return { - name: `Option ${idx+1}`, - type: 'object', - required: true, - bodyObj: optReqs - } - }) - return [{ - name: nameForRoot, - type: 'oneOf', - required: true, - description: node.description || undefined, - bodyObj: options - }] - } - - // If array -> create a single Request describing the array - if (node.type === 'array' || node.items) { - const items = node.items ?? {} - // object[] case - if ((items.type === 'object') || items.properties || items.$ref || items.oneOf) { - const nested = schemaNodeToRequests(items, doc, 'item', items.required || [], new Set(seenRefs)) - return [{ - name: nameForRoot, - type: 'object[]', - required: requiredNames.includes(nameForRoot), - description: node.description || undefined, - bodyObj: nested - }] - } else { - const itemType = items.type || 'any' - return [{ - name: nameForRoot, - type: `${itemType}[]`, - required: requiredNames.includes(nameForRoot), - description: node.description || undefined, - minLen: node.minItems, - maxLen: node.maxItems, - }] - } - } + // 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 object with properties -> map each property to Request - if (node.type === 'object' || node.properties || node.additionalProperties) { - if (node.properties && typeof node.properties === 'object') { + // If we have explicit properties -> enumerate them + if (n.properties && typeof n.properties === 'object') { const out: Request[] = [] - const reqArr: string[] = Array.isArray(node.required) ? node.required : requiredNames || [] - for (const [propName, propSchema] of Object.entries(node.properties)) { - const prop = propSchema as any - - // $ref property - if (prop.$ref) { - const resolved = resolveRef(prop.$ref, doc) - const nestedReqs = schemaNodeToRequests(resolved, doc, propName, resolved?.required || [], new Set(seenRefs)) - if (nestedReqs.length === 1 && nestedReqs[0].type === 'object' && nestedReqs[0].bodyObj) { - out.push({ - name: propName, - type: 'object', - required: reqArr.includes(propName), - description: prop.description || undefined, - bodyObj: nestedReqs[0].bodyObj - }) - continue - } else { - out.push({ - name: propName, + 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 optReqs = schemaNodeToRequests(opt, doc, `option_${idx + 1}`, [], new Set(seenRefs)) + return { + name: `Option ${idx + 1}`, type: 'object', - required: reqArr.includes(propName), - description: prop.description || undefined, - bodyObj: nestedReqs - }) - continue - } + required: true, + example: opt.example, + bodyObj: optReqs + } + }) + out.push({ + name: propName, + type: 'object[]', + required: true, + description: prop.description, + bodyObj: options + }) } - // array property if (prop.type === 'array' || prop.items) { const items = prop.items ?? {} - if ((items.type === 'object') || items.properties || items.$ref || items.oneOf) { - const nested = schemaNodeToRequests(items, doc, propName, items.required || [], new Set(seenRefs)) + 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, - minLen: prop.minItems, - maxLen: prop.maxItems, bodyObj: nested }) } else { out.push({ name: propName, - type: `${items.type || 'any'}[]`, + type: `${itemsNorm.type || 'any'}[]`, + example: prop.example ?? (itemsNorm.example !== undefined ? [itemsNorm.example] : undefined), required: reqArr.includes(propName), description: prop.description || undefined, - minLen: prop.minItems, - maxLen: prop.maxItems, - enumList: items.enum + maxLength: prop.maxLength, + minLength: prop.minLength, + enumList: itemsNorm.enum }) } continue @@ -546,6 +612,10 @@ function schemaNodeToRequests( 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 @@ -553,32 +623,37 @@ function schemaNodeToRequests( continue } - // primitive property + // primitive property (string/number/boolean/enum) + const primType = prop.type || (prop.enum ? 'string' : 'any') const r: Request = { name: propName, - type: prop.type || (prop.enum ? 'string' : 'any'), + type: primType, required: reqArr.includes(propName), + example: prop.example !== undefined ? prop.example : defaultForPrimitive(primType), description: prop.description || undefined } - if (prop.minLength !== undefined) r.minLen = prop.minLength - if (prop.maxLength !== undefined) r.maxLen = prop.maxLength 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) - if (node.additionalProperties) { - const add = node.additionalProperties === true ? { type: 'any' } : node.additionalProperties - const nested = schemaNodeToRequests(add, doc, 'value', add?.required || [], new Set(seenRefs)) + // 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: node.description || undefined, + description: n.description || undefined, bodyObj: nested.length ? nested : undefined }] } @@ -587,154 +662,49 @@ function schemaNodeToRequests( return [{ name: nameForRoot, type: 'object', + example: (normalized as any).example ?? undefined, required: requiredNames.includes(nameForRoot), - description: node.description || undefined + description: (normalized as any).description || undefined }] } - // primitive at root - if (typeof node.type === 'string') { + // 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: node.type, + type: t, + example: (normalized as any).example !== undefined ? (normalized as any).example : defaultForPrimitive(t), required: requiredNames.includes(nameForRoot), - description: node.description || undefined + description: (normalized as any).description || undefined } - if (node.minLength !== undefined) r.minLen = node.minLength - if (node.maxLength !== undefined) r.maxLen = node.maxLength - if (node.minimum !== undefined) r.minimum = node.minimum - if (node.maximum !== undefined) r.maximum = node.maximum - if (node.enum) r.enumList = node.enum + 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 (node.enum) { + 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(node.enum) ? node.enum : undefined, - description: node.description || undefined + enumList: Array.isArray((normalized as any).enum) ? (normalized as any).enum : undefined, + description: (normalized as any).description || undefined }] } - // fallback + // fallback generic return [{ name: nameForRoot, - type: typeof node === 'object' ? 'object' : 'any', + example: (normalized as any).example, + type: typeof normalized === 'object' ? 'object' : 'any', required: requiredNames.includes(nameForRoot), - description: node?.description || undefined + description: (normalized as any)?.description || undefined }] } - -/* ----------------- 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): { endpoints: 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 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, - } - - // ---------- 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 } -} - diff --git a/openapi-gen/tsxParser/renderToMDX.ts b/openapi-gen/tsxParser/renderToMDX.ts index 884371ba..34da5ea1 100644 --- a/openapi-gen/tsxParser/renderToMDX.ts +++ b/openapi-gen/tsxParser/renderToMDX.ts @@ -19,16 +19,6 @@ type ElementShape = { $$typeof?: symbol; }; -/** 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") - ); -} - /** Main renderer: accepts any React node (element, string, number, array, fragment) */ export function renderToMDX(node: React.ReactNode): string { function renderNode(n: React.ReactNode): string { @@ -102,3 +92,12 @@ export function renderToMDX(node: React.ReactNode): string { 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/src/components/NavigationAPI.jsx b/src/components/NavigationAPI.jsx index 80328ebf..269b8126 100644 --- a/src/components/NavigationAPI.jsx +++ b/src/components/NavigationAPI.jsx @@ -35,7 +35,6 @@ export const apiNavigation = [ { title: 'Networks', href: '/api/resources/networks' }, { title: 'DNS', href: '/api/resources/dns' }, { title: 'Events', href: '/api/resources/events' }, - { title: 'Jobs', href: '/api/resources/jobs' }, ], }, ] diff --git a/src/components/Resources.jsx b/src/components/Resources.jsx index b7b3f8fc..721e0b6e 100644 --- a/src/components/Resources.jsx +++ b/src/components/Resources.jsx @@ -142,17 +142,6 @@ const resources = [ squares: [[0, 1]], }, }, - { - href: '/api/resources/jobs', - name: 'Jobs', - description: - 'Learn about how to list jobs.', - icon: UsersIcon, - pattern: { - y: 22, - squares: [[0, 1]], - }, - }, ] function ResourceIcon({ icon: Icon }) { diff --git a/src/pages/ipa/resources/accounts.mdx b/src/pages/ipa/resources/accounts.mdx index 7f064636..df63a97e 100644 --- a/src/pages/ipa/resources/accounts.mdx +++ b/src/pages/ipa/resources/accounts.mdx @@ -18,43 +18,44 @@ curl -X GET https://api.netbird.io/api/accounts \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} [ { - "id": "string", + "id": "ch8i4ug6lnn4g9hqv7l0", "settings": { - "peer_login_expiration_enabled": "boolean", - "peer_login_expiration": "integer", - "peer_inactivity_expiration_enabled": "boolean", - "peer_inactivity_expiration": "integer", - "regular_users_view_blocked": "boolean", - "groups_propagation_enabled": "boolean", - "jwt_groups_enabled": "boolean", - "jwt_groups_claim_name": "string", + "peer_login_expiration_enabled": true, + "peer_login_expiration": 43200, + "peer_inactivity_expiration_enabled": true, + "peer_inactivity_expiration": 43200, + "regular_users_view_blocked": true, + "groups_propagation_enabled": true, + "jwt_groups_enabled": true, + "jwt_groups_claim_name": "roles", "jwt_allow_groups": [ - "string" + "Administrators" ], - "routing_peer_dns_resolution_enabled": "boolean", - "dns_domain": "string", - "network_range": "string", + "routing_peer_dns_resolution_enabled": true, + "dns_domain": "my-organization.org", + "network_range": "100.64.0.0/16", "extra": { - "peer_approval_enabled": "boolean", - "network_traffic_logs_enabled": "boolean", + "peer_approval_enabled": true, + "user_approval_required": false, + "network_traffic_logs_enabled": true, "network_traffic_logs_groups": [ - "string" + "ch8i4ug6lnn4g9hqv7m0" ], - "network_traffic_packet_counter_enabled": "boolean" + "network_traffic_packet_counter_enabled": true }, - "lazy_connection_enabled": "boolean" + "lazy_connection_enabled": true }, - "domain": "string", - "domain_category": "string", - "created_at": "string", - "created_by": "string", + "domain": "netbird.io", + "domain_category": "private", + "created_at": "2023-05-05T09:00:35.477782Z", + "created_by": "google-oauth2|277474792786460067937", "onboarding": { - "signup_form_pending": "boolean", - "onboarding_flow_pending": "boolean" + "signup_form_pending": true, + "onboarding_flow_pending": false } } ] @@ -81,6 +82,7 @@ curl -X GET https://api.netbird.io/api/accounts \ "network_range": "string", "extra": { "peer_approval_enabled": "boolean", + "user_approval_required": "boolean", "network_traffic_logs_enabled": "boolean", "network_traffic_logs_groups": [ "string" @@ -136,9 +138,7 @@ The unique identifier of an account
-Object list - - +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). @@ -178,13 +178,34 @@ 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 experimental lazy connection + +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 + +
@@ -193,9 +214,7 @@ Enables or disables experimental lazy connection
-Object list - - +More Information Indicates whether the account signup form is pending @@ -206,8 +225,6 @@ Indicates whether the account onboarding flow is pending - -
@@ -219,11 +236,10 @@ Indicates whether the account onboarding flow is pending ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/accounts/{accountId} \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ - "id": "ch8i4ug6lnn4g9hqv7l0", "settings": { "peer_login_expiration_enabled": true, "peer_login_expiration": 43200, @@ -241,6 +257,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" @@ -249,10 +266,6 @@ curl -X PUT https://api.netbird.io/api/accounts/{accountId} \ }, "lazy_connection_enabled": true }, - "domain": "netbird.io", - "domain_category": "private", - "created_at": "2023-05-05T09:00:35.477782Z", - "created_by": "google-oauth2|277474792786460067937", "onboarding": { "signup_form_pending": true, "onboarding_flow_pending": false @@ -260,42 +273,43 @@ curl -X PUT https://api.netbird.io/api/accounts/{accountId} \ }' ``` - + ```json {{ title: 'Example' }} { - "id": "string", + "id": "ch8i4ug6lnn4g9hqv7l0", "settings": { - "peer_login_expiration_enabled": "boolean", - "peer_login_expiration": "integer", - "peer_inactivity_expiration_enabled": "boolean", - "peer_inactivity_expiration": "integer", - "regular_users_view_blocked": "boolean", - "groups_propagation_enabled": "boolean", - "jwt_groups_enabled": "boolean", - "jwt_groups_claim_name": "string", + "peer_login_expiration_enabled": true, + "peer_login_expiration": 43200, + "peer_inactivity_expiration_enabled": true, + "peer_inactivity_expiration": 43200, + "regular_users_view_blocked": true, + "groups_propagation_enabled": true, + "jwt_groups_enabled": true, + "jwt_groups_claim_name": "roles", "jwt_allow_groups": [ - "string" + "Administrators" ], - "routing_peer_dns_resolution_enabled": "boolean", - "dns_domain": "string", - "network_range": "string", + "routing_peer_dns_resolution_enabled": true, + "dns_domain": "my-organization.org", + "network_range": "100.64.0.0/16", "extra": { - "peer_approval_enabled": "boolean", - "network_traffic_logs_enabled": "boolean", + "peer_approval_enabled": true, + "user_approval_required": false, + "network_traffic_logs_enabled": true, "network_traffic_logs_groups": [ - "string" + "ch8i4ug6lnn4g9hqv7m0" ], - "network_traffic_packet_counter_enabled": "boolean" + "network_traffic_packet_counter_enabled": true }, - "lazy_connection_enabled": "boolean" + "lazy_connection_enabled": true }, - "domain": "string", - "domain_category": "string", - "created_at": "string", - "created_by": "string", + "domain": "netbird.io", + "domain_category": "private", + "created_at": "2023-05-05T09:00:35.477782Z", + "created_by": "google-oauth2|277474792786460067937", "onboarding": { - "signup_form_pending": "boolean", - "onboarding_flow_pending": "boolean" + "signup_form_pending": true, + "onboarding_flow_pending": false } } ``` @@ -320,6 +334,7 @@ curl -X PUT https://api.netbird.io/api/accounts/{accountId} \ "network_range": "string", "extra": { "peer_approval_enabled": "boolean", + "user_approval_required": "boolean", "network_traffic_logs_enabled": "boolean", "network_traffic_logs_groups": [ "string" diff --git a/src/pages/ipa/resources/dns.mdx b/src/pages/ipa/resources/dns.mdx index 7279ba62..bd0dd522 100644 --- a/src/pages/ipa/resources/dns.mdx +++ b/src/pages/ipa/resources/dns.mdx @@ -18,29 +18,29 @@ curl -X GET https://api.netbird.io/api/dns/nameservers \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} [ { - "id": "string", - "name": "string", - "description": "string", + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "Google DNS", + "description": "Google DNS servers", "nameservers": [ { - "ip": "string", - "ns_type": "string", - "port": "integer" + "ip": "8.8.8.8", + "ns_type": "udp", + "port": 53 } ], - "enabled": "boolean", + "enabled": true, "groups": [ - "string" + "ch8i4ug6lnn4g9hqv7m0" ], - "primary": "boolean", + "primary": true, "domains": [ - "string" + "example.com" ], - "search_domains_enabled": "boolean" + "search_domains_enabled": true } ] ``` @@ -97,13 +97,11 @@ Name of nameserver group name Description of the nameserver group - +
Nameserver list - - Nameserver IP @@ -117,8 +115,6 @@ Nameserver Port - -
@@ -145,11 +141,10 @@ Search domain status for match domains. It should be true only if domains list i ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/dns/nameservers \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ - "id": "ch8i4ug6lnn4g9hqv7m0", "name": "Google DNS", "description": "Google DNS servers", "nameservers": [ @@ -171,28 +166,28 @@ curl -X POST https://api.netbird.io/api/dns/nameservers \ }' ``` - + ```json {{ title: 'Example' }} { - "id": "string", - "name": "string", - "description": "string", + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "Google DNS", + "description": "Google DNS servers", "nameservers": [ { - "ip": "string", - "ns_type": "string", - "port": "integer" + "ip": "8.8.8.8", + "ns_type": "udp", + "port": 53 } ], - "enabled": "boolean", + "enabled": true, "groups": [ - "string" + "ch8i4ug6lnn4g9hqv7m0" ], - "primary": "boolean", + "primary": true, "domains": [ - "string" + "example.com" ], - "search_domains_enabled": "boolean" + "search_domains_enabled": true } ``` @@ -256,28 +251,28 @@ curl -X GET https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} { - "id": "string", - "name": "string", - "description": "string", + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "Google DNS", + "description": "Google DNS servers", "nameservers": [ { - "ip": "string", - "ns_type": "string", - "port": "integer" + "ip": "8.8.8.8", + "ns_type": "udp", + "port": 53 } ], - "enabled": "boolean", + "enabled": true, "groups": [ - "string" + "ch8i4ug6lnn4g9hqv7m0" ], - "primary": "boolean", + "primary": true, "domains": [ - "string" + "example.com" ], - "search_domains_enabled": "boolean" + "search_domains_enabled": true } ``` @@ -342,13 +337,11 @@ Name of nameserver group name Description of the nameserver group - +
Nameserver list - - Nameserver IP @@ -362,8 +355,6 @@ Nameserver Port - -
@@ -390,11 +381,10 @@ Search domain status for match domains. It should be true only if domains list i ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ - "id": "ch8i4ug6lnn4g9hqv7m0", "name": "Google DNS", "description": "Google DNS servers", "nameservers": [ @@ -416,28 +406,28 @@ curl -X PUT https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ }' ``` - + ```json {{ title: 'Example' }} { - "id": "string", - "name": "string", - "description": "string", + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "Google DNS", + "description": "Google DNS servers", "nameservers": [ { - "ip": "string", - "ns_type": "string", - "port": "integer" + "ip": "8.8.8.8", + "ns_type": "udp", + "port": 53 } ], - "enabled": "boolean", + "enabled": true, "groups": [ - "string" + "ch8i4ug6lnn4g9hqv7m0" ], - "primary": "boolean", + "primary": true, "domains": [ - "string" + "example.com" ], - "search_domains_enabled": "boolean" + "search_domains_enabled": true } ``` @@ -525,12 +515,12 @@ curl -X GET https://api.netbird.io/api/dns/settings \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} [ { "disabled_management_groups": [ - "string" + "ch8i4ug6lnn4g9hqv7m0" ] } ] @@ -578,9 +568,9 @@ Groups whose DNS management is disabled ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/dns/settings \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ "disabled_management_groups": [ "ch8i4ug6lnn4g9hqv7m0" @@ -588,11 +578,11 @@ curl -X PUT https://api.netbird.io/api/dns/settings \ }' ``` - + ```json {{ title: 'Example' }} { "disabled_management_groups": [ - "string" + "ch8i4ug6lnn4g9hqv7m0" ] } ``` diff --git a/src/pages/ipa/resources/events.mdx b/src/pages/ipa/resources/events.mdx index e9554e5c..0ac94c3f 100644 --- a/src/pages/ipa/resources/events.mdx +++ b/src/pages/ipa/resources/events.mdx @@ -18,26 +18,22 @@ curl -X GET https://api.netbird.io/api/events/audit \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} [ { - "id": "string", - "timestamp": "string", - "activity": "string", - "activity_code": "string", - "initiator_id": "string", - "initiator_name": "string", - "initiator_email": "string", - "target_id": "string", + "id": 10, + "timestamp": "2023-05-05T10:04:37.473542Z", + "activity": "Route created", + "activity_code": "route.add", + "initiator_id": "google-oauth2|123456789012345678901", + "initiator_name": "John Doe", + "initiator_email": "demo@netbird.io", + "target_id": "chad9d86lnnc59g18ou0", "meta": { - "type": "object", - "additionalProperties": "string", - "example": { - "name": "my route", - "network_range": "10.64.0.0/24", - "peer_id": "chacbco6lnnbn6cg5s91" - } + "name": "my route", + "network_range": "10.64.0.0/24", + "peer_id": "chacbco6lnnbn6cg5s91" } } ] @@ -75,7 +71,7 @@ curl -X GET https://api.netbird.io/api/events/audit \ -## List all Traffic Events {{ tag: 'GET', label: '/api/events/network-traffic' }} +## List all Traffic Events {{ tag: 'GET', label: '/api/events/network-traffic' }} @@ -83,7 +79,7 @@ curl -X GET https://api.netbird.io/api/events/audit \ Returns a list of all network traffic events -### Path Parameters +### Query Parameters @@ -133,68 +129,68 @@ curl -X GET https://api.netbird.io/api/events/network-traffic \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} { "data": [ { - "flow_id": "string", - "reporter_id": "string", + "flow_id": "61092452-b17c-4b14-b7cf-a2158c549826", + "reporter_id": "ch8i4ug6lnn4g9hqv7m0", "source": { - "id": "string", - "type": "string", - "name": "string", + "id": "ch8i4ug6lnn4g9hqv7m0", + "type": "PEER", + "name": "My Peer", "geo_location": { - "city_name": "string", - "country_code": "string" + "city_name": "Berlin", + "country_code": "DE" }, - "os": "string", - "address": "string", - "dns_label": "string" + "os": "Linux", + "address": "100.64.0.10:51820", + "dns_label": "*.mydomain.com" }, "destination": { - "id": "string", - "type": "string", - "name": "string", + "id": "ch8i4ug6lnn4g9hqv7m0", + "type": "PEER", + "name": "My Peer", "geo_location": { - "city_name": "string", - "country_code": "string" + "city_name": "Berlin", + "country_code": "DE" }, - "os": "string", - "address": "string", - "dns_label": "string" + "os": "Linux", + "address": "100.64.0.10:51820", + "dns_label": "*.mydomain.com" }, "user": { - "id": "string", - "email": "string", - "name": "string" + "id": "google-oauth2|123456789012345678901", + "email": "alice@netbird.io", + "name": "Alice Smith" }, "policy": { - "id": "string", - "name": "string" + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "All to All" }, "icmp": { - "type": "integer", - "code": "integer" + "type": 8, + "code": 0 }, - "protocol": "integer", - "direction": "string", - "rx_bytes": "integer", - "rx_packets": "integer", - "tx_bytes": "integer", - "tx_packets": "integer", + "protocol": 6, + "direction": "INGRESS", + "rx_bytes": 1234, + "rx_packets": 5, + "tx_bytes": 1234, + "tx_packets": 5, "events": [ { - "type": "string", - "timestamp": "string" + "type": "TYPE_START", + "timestamp": "2025-03-20T16:23:58.125397Z" } ] } ], - "page": "integer", - "page_size": "integer", - "total_records": "integer", - "total_pages": "integer" + "page": 0, + "page_size": 0, + "total_records": 0, + "total_pages": 0 } ``` diff --git a/src/pages/ipa/resources/geo-locations.mdx b/src/pages/ipa/resources/geo-locations.mdx index eff158ff..198a762a 100644 --- a/src/pages/ipa/resources/geo-locations.mdx +++ b/src/pages/ipa/resources/geo-locations.mdx @@ -18,10 +18,10 @@ curl -X GET https://api.netbird.io/api/locations/countries \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} [ - "string" + "DE" ] ``` @@ -67,11 +67,11 @@ curl -X GET https://api.netbird.io/api/locations/countries/{country}/cities \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} { - "geoname_id": "integer", - "city_name": "string" + "geoname_id": 2950158, + "city_name": "Berlin" } ``` diff --git a/src/pages/ipa/resources/groups.mdx b/src/pages/ipa/resources/groups.mdx index aff952c5..6ed1ba1c 100644 --- a/src/pages/ipa/resources/groups.mdx +++ b/src/pages/ipa/resources/groups.mdx @@ -18,25 +18,25 @@ curl -X GET https://api.netbird.io/api/groups \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} [ { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string", + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api", "peers": [ { - "id": "string", - "name": "string" + "id": "chacbco6lnnbn6cg5s90", + "name": "stage-host-1" } ], "resources": [ { - "id": "string", - "type": "string" + "id": "chacdk86lnnboviihd7g", + "type": "host" } ] } @@ -97,21 +97,17 @@ List of peers ids
-Object list - - +More Information ID of the resource - -Type of the resource + +Network resource type based of the address - -
@@ -123,20 +119,13 @@ Type of the resource ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/groups \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ - "id": "ch8i4ug6lnn4g9hqv7m0", "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api", "peers": [ - { - "id": "chacbco6lnnbn6cg5s90", - "name": "stage-host-1" - } + "ch8i4ug6lnn4g9hqv7m1" ], "resources": [ { @@ -147,24 +136,24 @@ curl -X POST https://api.netbird.io/api/groups \ }' ``` - + ```json {{ title: 'Example' }} { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string", + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api", "peers": [ { - "id": "string", - "name": "string" + "id": "chacbco6lnnbn6cg5s90", + "name": "stage-host-1" } ], "resources": [ { - "id": "string", - "type": "string" + "id": "chacdk86lnnboviihd7g", + "type": "host" } ] } @@ -228,24 +217,24 @@ curl -X GET https://api.netbird.io/api/groups/{groupId} \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string", + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api", "peers": [ { - "id": "string", - "name": "string" + "id": "chacbco6lnnbn6cg5s90", + "name": "stage-host-1" } ], "resources": [ { - "id": "string", - "type": "string" + "id": "chacdk86lnnboviihd7g", + "type": "host" } ] } @@ -314,21 +303,17 @@ List of peers ids
-Object list - - +More Information ID of the resource - -Type of the resource + +Network resource type based of the address - -
@@ -340,20 +325,13 @@ Type of the resource ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/groups/{groupId} \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ - "id": "ch8i4ug6lnn4g9hqv7m0", "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api", "peers": [ - { - "id": "chacbco6lnnbn6cg5s90", - "name": "stage-host-1" - } + "ch8i4ug6lnn4g9hqv7m1" ], "resources": [ { @@ -364,24 +342,24 @@ curl -X PUT https://api.netbird.io/api/groups/{groupId} \ }' ``` - + ```json {{ title: 'Example' }} { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string", + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api", "peers": [ { - "id": "string", - "name": "string" + "id": "chacbco6lnnbn6cg5s90", + "name": "stage-host-1" } ], "resources": [ { - "id": "string", - "type": "string" + "id": "chacdk86lnnboviihd7g", + "type": "host" } ] } diff --git a/src/pages/ipa/resources/ingress-ports.mdx b/src/pages/ipa/resources/ingress-ports.mdx index 593bbb98..d2d6ac4a 100644 --- a/src/pages/ipa/resources/ingress-ports.mdx +++ b/src/pages/ipa/resources/ingress-ports.mdx @@ -1,7 +1,7 @@ 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' }} @@ -16,6 +16,14 @@ Returns a list of all ingress port allocations for a peer The unique identifier of a peer + + + + +### Query Parameters + + + Filters ingress port allocations by name @@ -32,23 +40,23 @@ curl -X GET https://api.netbird.io/api/peers/{peerId}/ingress/ports \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} [ { - "id": "string", - "name": "string", - "ingress_peer_id": "string", - "region": "string", - "enabled": "boolean", - "ingress_ip": "string", + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "Ingress Peer Allocation 1", + "ingress_peer_id": "x7p3kqf2rdd8j5zxw4n9", + "region": "germany", + "enabled": true, + "ingress_ip": "192.34.0.123", "port_range_mappings": [ { - "translated_start": "integer", - "translated_end": "integer", - "ingress_start": "integer", - "ingress_end": "integer", - "protocol": "string" + "translated_start": 80, + "translated_end": 320, + "ingress_start": 1080, + "ingress_end": 1320, + "protocol": "tcp" } ] } @@ -85,7 +93,7 @@ curl -X GET https://api.netbird.io/api/peers/{peerId}/ingress/ports \ -## Create a Port Allocation {{ tag: 'POST', label: '/api/peers/{peerId}/ingress/ports' }} +## Create a Port Allocation {{ tag: 'POST', label: '/api/peers/{peerId}/ingress/ports' }} @@ -119,8 +127,6 @@ 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 @@ -134,17 +140,13 @@ The protocol accepted by the port range - -
-Direct port allocation - - +More Information The number of ports to be forwarded @@ -155,8 +157,6 @@ The protocol accepted by the port - -
@@ -168,10 +168,29 @@ The protocol accepted by the port ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/peers/{peerId}/ingress/ports \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ + "name": "Ingress Port Allocation 1", + "enabled": true, + "port_ranges": [ + { + "start": 80, + "end": 320, + "protocol": "tcp" + } + ], + "direct_port": { + "count": 5, + "protocol": "udp" + } +}' +``` + + +```json {{ title: 'Example' }} +{ "id": "ch8i4ug6lnn4g9hqv7m0", "name": "Ingress Peer Allocation 1", "ingress_peer_id": "x7p3kqf2rdd8j5zxw4n9", @@ -187,27 +206,6 @@ curl -X POST https://api.netbird.io/api/peers/{peerId}/ingress/ports \ "protocol": "tcp" } ] -}' -``` - - -```json {{ title: 'Example' }} -{ - "id": "string", - "name": "string", - "ingress_peer_id": "string", - "region": "string", - "enabled": "boolean", - "ingress_ip": "string", - "port_range_mappings": [ - { - "translated_start": "integer", - "translated_end": "integer", - "ingress_start": "integer", - "ingress_end": "integer", - "protocol": "string" - } - ] } ``` @@ -239,7 +237,7 @@ curl -X POST https://api.netbird.io/api/peers/{peerId}/ingress/ports \ -## 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}' }} @@ -270,22 +268,22 @@ curl -X GET https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationI -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} { - "id": "string", - "name": "string", - "ingress_peer_id": "string", - "region": "string", - "enabled": "boolean", - "ingress_ip": "string", + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "Ingress Peer Allocation 1", + "ingress_peer_id": "x7p3kqf2rdd8j5zxw4n9", + "region": "germany", + "enabled": true, + "ingress_ip": "192.34.0.123", "port_range_mappings": [ { - "translated_start": "integer", - "translated_end": "integer", - "ingress_start": "integer", - "ingress_end": "integer", - "protocol": "string" + "translated_start": 80, + "translated_end": 320, + "ingress_start": 1080, + "ingress_end": 1320, + "protocol": "tcp" } ] } @@ -319,7 +317,7 @@ curl -X GET https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationI -## 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}' }} @@ -356,8 +354,6 @@ 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 @@ -371,17 +367,13 @@ The protocol accepted by the port range - -
-Direct port allocation - - +More Information The number of ports to be forwarded @@ -392,8 +384,6 @@ The protocol accepted by the port - -
@@ -405,10 +395,29 @@ The protocol accepted by the port ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId} \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ + "name": "Ingress Port Allocation 1", + "enabled": true, + "port_ranges": [ + { + "start": 80, + "end": 320, + "protocol": "tcp" + } + ], + "direct_port": { + "count": 5, + "protocol": "udp" + } +}' +``` + + +```json {{ title: 'Example' }} +{ "id": "ch8i4ug6lnn4g9hqv7m0", "name": "Ingress Peer Allocation 1", "ingress_peer_id": "x7p3kqf2rdd8j5zxw4n9", @@ -424,27 +433,6 @@ curl -X PUT https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationI "protocol": "tcp" } ] -}' -``` - - -```json {{ title: 'Example' }} -{ - "id": "string", - "name": "string", - "ingress_peer_id": "string", - "region": "string", - "enabled": "boolean", - "ingress_ip": "string", - "port_range_mappings": [ - { - "translated_start": "integer", - "translated_end": "integer", - "ingress_start": "integer", - "ingress_end": "integer", - "protocol": "string" - } - ] } ``` @@ -476,7 +464,7 @@ curl -X PUT https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationI -## 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}' }} @@ -514,7 +502,7 @@ curl -X DELETE https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocati -## List all Ingress Peers {{ tag: 'GET', label: '/api/ingress/peers' }} +## List all Ingress Peers {{ tag: 'GET', label: '/api/ingress/peers' }} @@ -531,21 +519,21 @@ curl -X GET https://api.netbird.io/api/ingress/peers \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} [ { - "id": "string", - "peer_id": "string", - "ingress_ip": "string", + "id": "ch8i4ug6lnn4g9hqv7m0", + "peer_id": "x7p3kqf2rdd8j5zxw4n9", + "ingress_ip": "192.34.0.123", "available_ports": { - "tcp": "integer", - "udp": "integer" + "tcp": 45765, + "udp": 50000 }, - "enabled": "boolean", - "connected": "boolean", - "fallback": "boolean", - "region": "string" + "enabled": true, + "connected": true, + "fallback": true, + "region": "germany" } ] ``` @@ -576,7 +564,7 @@ curl -X GET https://api.netbird.io/api/ingress/peers \ -## Create a Ingress Peer {{ tag: 'POST', label: '/api/ingress/peers' }} +## Create a Ingress Peer {{ tag: 'POST', label: '/api/ingress/peers' }} @@ -606,10 +594,19 @@ Defines if an ingress peer can be used as a fallback if no ingress peer can be f ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/ingress/peers \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ + "peer_id": "ch8i4ug6lnn4g9hqv7m0", + "enabled": true, + "fallback": true +}' +``` + + +```json {{ title: 'Example' }} +{ "id": "ch8i4ug6lnn4g9hqv7m0", "peer_id": "x7p3kqf2rdd8j5zxw4n9", "ingress_ip": "192.34.0.123", @@ -621,23 +618,6 @@ curl -X POST https://api.netbird.io/api/ingress/peers \ "connected": true, "fallback": true, "region": "germany" -}' -``` - - -```json {{ title: 'Example' }} -{ - "id": "string", - "peer_id": "string", - "ingress_ip": "string", - "available_ports": { - "tcp": "integer", - "udp": "integer" - }, - "enabled": "boolean", - "connected": "boolean", - "fallback": "boolean", - "region": "string" } ``` @@ -665,7 +645,7 @@ curl -X POST https://api.netbird.io/api/ingress/peers \ -## Retrieve a Ingress Peer {{ tag: 'GET', label: '/api/ingress/peers/{ingressPeerId}' }} +## Retrieve a Ingress Peer {{ tag: 'GET', label: '/api/ingress/peers/{ingressPeerId}' }} @@ -693,20 +673,20 @@ curl -X GET https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} { - "id": "string", - "peer_id": "string", - "ingress_ip": "string", + "id": "ch8i4ug6lnn4g9hqv7m0", + "peer_id": "x7p3kqf2rdd8j5zxw4n9", + "ingress_ip": "192.34.0.123", "available_ports": { - "tcp": "integer", - "udp": "integer" + "tcp": 45765, + "udp": 50000 }, - "enabled": "boolean", - "connected": "boolean", - "fallback": "boolean", - "region": "string" + "enabled": true, + "connected": true, + "fallback": true, + "region": "germany" } ``` @@ -734,7 +714,7 @@ curl -X GET https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ -## Update a Ingress Peer {{ tag: 'PUT', label: '/api/ingress/peers/{ingressPeerId}' }} +## Update a Ingress Peer {{ tag: 'PUT', label: '/api/ingress/peers/{ingressPeerId}' }} @@ -772,10 +752,18 @@ Defines if an ingress peer can be used as a fallback if no ingress peer can be f ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ + "enabled": true, + "fallback": true +}' +``` + + +```json {{ title: 'Example' }} +{ "id": "ch8i4ug6lnn4g9hqv7m0", "peer_id": "x7p3kqf2rdd8j5zxw4n9", "ingress_ip": "192.34.0.123", @@ -787,23 +775,6 @@ curl -X PUT https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ "connected": true, "fallback": true, "region": "germany" -}' -``` - - -```json {{ title: 'Example' }} -{ - "id": "string", - "peer_id": "string", - "ingress_ip": "string", - "available_ports": { - "tcp": "integer", - "udp": "integer" - }, - "enabled": "boolean", - "connected": "boolean", - "fallback": "boolean", - "region": "string" } ``` @@ -831,7 +802,7 @@ curl -X PUT https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ -## Delete a Ingress Peer {{ tag: 'DELETE', label: '/api/ingress/peers/{ingressPeerId}' }} +## Delete a Ingress Peer {{ tag: 'DELETE', label: '/api/ingress/peers/{ingressPeerId}' }} diff --git a/src/pages/ipa/resources/networks.mdx b/src/pages/ipa/resources/networks.mdx index 0be1099f..40947186 100644 --- a/src/pages/ipa/resources/networks.mdx +++ b/src/pages/ipa/resources/networks.mdx @@ -18,23 +18,23 @@ curl -X GET https://api.netbird.io/api/networks \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} [ { - "id": "string", + "id": "chacdk86lnnboviihd7g", "routers": [ - "string" + "ch8i4ug6lnn4g9hqv7m0" ], - "routing_peers_count": "integer", + "routing_peers_count": 2, "resources": [ - "string" + "ch8i4ug6lnn4g9hqv7m1" ], "policies": [ - "string" + "ch8i4ug6lnn4g9hqv7m2" ], - "name": "string", - "description": "string" + "name": "Remote Network 1", + "description": "A remote network that needs to be accessed" } ] ``` @@ -94,42 +94,31 @@ Network description ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/networks \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ - "id": "chacdk86lnnboviihd7g", - "routers": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "routing_peers_count": 2, - "resources": [ - "ch8i4ug6lnn4g9hqv7m1" - ], - "policies": [ - "ch8i4ug6lnn4g9hqv7m2" - ], "name": "Remote Network 1", "description": "A remote network that needs to be accessed" }' ``` - + ```json {{ title: 'Example' }} { - "id": "string", + "id": "chacdk86lnnboviihd7g", "routers": [ - "string" + "ch8i4ug6lnn4g9hqv7m0" ], - "routing_peers_count": "integer", + "routing_peers_count": 2, "resources": [ - "string" + "ch8i4ug6lnn4g9hqv7m1" ], "policies": [ - "string" + "ch8i4ug6lnn4g9hqv7m2" ], - "name": "string", - "description": "string" + "name": "Remote Network 1", + "description": "A remote network that needs to be accessed" } ``` @@ -187,22 +176,22 @@ curl -X GET https://api.netbird.io/api/networks/{networkId} \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} { - "id": "string", + "id": "chacdk86lnnboviihd7g", "routers": [ - "string" + "ch8i4ug6lnn4g9hqv7m0" ], - "routing_peers_count": "integer", + "routing_peers_count": 2, "resources": [ - "string" + "ch8i4ug6lnn4g9hqv7m1" ], "policies": [ - "string" + "ch8i4ug6lnn4g9hqv7m2" ], - "name": "string", - "description": "string" + "name": "Remote Network 1", + "description": "A remote network that needs to be accessed" } ``` @@ -270,42 +259,31 @@ Network description ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/networks/{networkId} \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ - "id": "chacdk86lnnboviihd7g", - "routers": [ - "ch8i4ug6lnn4g9hqv7m0" - ], - "routing_peers_count": 2, - "resources": [ - "ch8i4ug6lnn4g9hqv7m1" - ], - "policies": [ - "ch8i4ug6lnn4g9hqv7m2" - ], "name": "Remote Network 1", "description": "A remote network that needs to be accessed" }' ``` - + ```json {{ title: 'Example' }} { - "id": "string", + "id": "chacdk86lnnboviihd7g", "routers": [ - "string" + "ch8i4ug6lnn4g9hqv7m0" ], - "routing_peers_count": "integer", + "routing_peers_count": 2, "resources": [ - "string" + "ch8i4ug6lnn4g9hqv7m1" ], "policies": [ - "string" + "ch8i4ug6lnn4g9hqv7m2" ], - "name": "string", - "description": "string" + "name": "Remote Network 1", + "description": "A remote network that needs to be accessed" } ``` @@ -398,25 +376,25 @@ curl -X GET https://api.netbird.io/api/networks/{networkId}/resources \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} [ { - "id": "string", - "type": "string", + "id": "chacdk86lnnboviihd7g", + "type": "host", "groups": [ { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string" + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api" } ], - "name": "string", - "description": "string", - "address": "string", - "enabled": "boolean" + "name": "Remote Resource 1", + "description": "A remote resource inside network 1", + "address": "1.1.1.1", + "enabled": true } ] ``` @@ -474,20 +452,20 @@ The unique identifier of a network - - -
- -Object list - - - - - - - - -
+ +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
@@ -498,10 +476,23 @@ The unique identifier of a network ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/networks/{networkId}/resources \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ + "name": "Remote Resource 1", + "description": "A remote resource inside network 1", + "address": "1.1.1.1", + "enabled": true, + "groups": [ + "chacdk86lnnboviihd70" + ] +}' +``` + + +```json {{ title: 'Example' }} +{ "id": "chacdk86lnnboviihd7g", "type": "host", "groups": [ @@ -517,27 +508,6 @@ curl -X POST https://api.netbird.io/api/networks/{networkId}/resources \ "description": "A remote resource inside network 1", "address": "1.1.1.1", "enabled": true -}' -``` - - -```json {{ title: 'Example' }} -{ - "id": "string", - "type": "string", - "groups": [ - { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string" - } - ], - "name": "string", - "description": "string", - "address": "string", - "enabled": "boolean" } ``` @@ -600,24 +570,24 @@ curl -X GET https://api.netbird.io/api/networks/{networkId}/resources/{resourceI -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} { - "id": "string", - "type": "string", + "id": "chacdk86lnnboviihd7g", + "type": "host", "groups": [ { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string" + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api" } ], - "name": "string", - "description": "string", - "address": "string", - "enabled": "boolean" + "name": "Remote Resource 1", + "description": "A remote resource inside network 1", + "address": "1.1.1.1", + "enabled": true } ``` @@ -675,20 +645,20 @@ The unique identifier of a resource - - -
- -Object list - - - - - - - - -
+ +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
@@ -699,10 +669,23 @@ The unique identifier of a resource ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/networks/{networkId}/resources/{resourceId} \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ + "name": "Remote Resource 1", + "description": "A remote resource inside network 1", + "address": "1.1.1.1", + "enabled": true, + "groups": [ + "chacdk86lnnboviihd70" + ] +}' +``` + + +```json {{ title: 'Example' }} +{ "id": "chacdk86lnnboviihd7g", "type": "host", "groups": [ @@ -718,27 +701,6 @@ curl -X PUT https://api.netbird.io/api/networks/{networkId}/resources/{resourceI "description": "A remote resource inside network 1", "address": "1.1.1.1", "enabled": true -}' -``` - - -```json {{ title: 'Example' }} -{ - "id": "string", - "type": "string", - "groups": [ - { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string" - } - ], - "name": "string", - "description": "string", - "address": "string", - "enabled": "boolean" } ``` @@ -836,18 +798,18 @@ curl -X GET https://api.netbird.io/api/networks/{networkId}/routers \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} [ { - "id": "string", - "peer": "string", + "id": "chacdk86lnnboviihd7g", + "peer": "chacbco6lnnbn6cg5s91", "peer_groups": [ - "string" + "chacbco6lnnbn6cg5s91" ], - "metric": "integer", - "masquerade": "boolean", - "enabled": "boolean" + "metric": 9999, + "masquerade": true, + "enabled": true } ] ``` @@ -904,7 +866,7 @@ Peer Identifier associated with route. This property can not be set together wit Peers Group Identifier associated with route. This property can not be set together with `peer` - + Route metric number. Lowest number has higher priority @@ -922,11 +884,10 @@ Network router status ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/networks/{networkId}/routers \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ - "id": "chacdk86lnnboviihd7g", "peer": "chacbco6lnnbn6cg5s91", "peer_groups": [ "chacbco6lnnbn6cg5s91" @@ -937,17 +898,17 @@ curl -X POST https://api.netbird.io/api/networks/{networkId}/routers \ }' ``` - + ```json {{ title: 'Example' }} { - "id": "string", - "peer": "string", + "id": "chacdk86lnnboviihd7g", + "peer": "chacbco6lnnbn6cg5s91", "peer_groups": [ - "string" + "chacbco6lnnbn6cg5s91" ], - "metric": "integer", - "masquerade": "boolean", - "enabled": "boolean" + "metric": 9999, + "masquerade": true, + "enabled": true } ``` @@ -1003,17 +964,17 @@ curl -X GET https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} { - "id": "string", - "peer": "string", + "id": "chacdk86lnnboviihd7g", + "peer": "chacbco6lnnbn6cg5s91", "peer_groups": [ - "string" + "chacbco6lnnbn6cg5s91" ], - "metric": "integer", - "masquerade": "boolean", - "enabled": "boolean" + "metric": 9999, + "masquerade": true, + "enabled": true } ``` @@ -1070,7 +1031,7 @@ Peer Identifier associated with route. This property can not be set together wit Peers Group Identifier associated with route. This property can not be set together with `peer` - + Route metric number. Lowest number has higher priority @@ -1088,11 +1049,10 @@ Network router status ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ - "id": "chacdk86lnnboviihd7g", "peer": "chacbco6lnnbn6cg5s91", "peer_groups": [ "chacbco6lnnbn6cg5s91" @@ -1103,17 +1063,17 @@ curl -X PUT https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ }' ``` - + ```json {{ title: 'Example' }} { - "id": "string", - "peer": "string", + "id": "chacdk86lnnboviihd7g", + "peer": "chacbco6lnnbn6cg5s91", "peer_groups": [ - "string" + "chacbco6lnnbn6cg5s91" ], - "metric": "integer", - "masquerade": "boolean", - "enabled": "boolean" + "metric": 9999, + "masquerade": true, + "enabled": true } ``` @@ -1193,18 +1153,18 @@ curl -X GET https://api.netbird.io/api/networks/routers \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} [ { - "id": "string", - "peer": "string", + "id": "chacdk86lnnboviihd7g", + "peer": "chacbco6lnnbn6cg5s91", "peer_groups": [ - "string" + "chacbco6lnnbn6cg5s91" ], - "metric": "integer", - "masquerade": "boolean", - "enabled": "boolean" + "metric": 9999, + "masquerade": true, + "enabled": true } ] ``` diff --git a/src/pages/ipa/resources/peers.mdx b/src/pages/ipa/resources/peers.mdx index 370d4504..e1c959a8 100644 --- a/src/pages/ipa/resources/peers.mdx +++ b/src/pages/ipa/resources/peers.mdx @@ -9,7 +9,7 @@ export const title = 'Peers' Returns a list of all peers -### Path Parameters +### Query Parameters @@ -32,48 +32,48 @@ curl -X GET https://api.netbird.io/api/peers \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} [ { - "id": "string", - "name": "string", - "created_at": "string", - "ip": "string", - "connection_ip": "string", - "connected": "boolean", - "last_seen": "string", - "os": "string", - "kernel_version": "string", - "geoname_id": "integer", - "version": "string", + "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, + "last_seen": "2023-05-05T10:05:26.420578Z", + "os": "Darwin 13.2.1", + "kernel_version": "23.2.0", + "geoname_id": 2643743, + "version": "0.14.0", "groups": [ { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string" + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api" } ], - "ssh_enabled": "boolean", - "user_id": "string", - "hostname": "string", - "ui_version": "string", - "dns_label": "string", - "login_expiration_enabled": "boolean", - "login_expired": "boolean", - "last_login": "string", - "inactivity_expiration_enabled": "boolean", - "approval_required": "boolean", - "country_code": "string", - "city_name": "string", - "serial_number": "string", + "ssh_enabled": true, + "user_id": "google-oauth2|277474792786460067937", + "hostname": "stage-host-1", + "ui_version": "0.14.0", + "dns_label": "stage-host-1.netbird.cloud", + "login_expiration_enabled": false, + "login_expired": false, + "last_login": "2023-05-05T09:00:35.477782Z", + "inactivity_expiration_enabled": false, + "approval_required": true, + "country_code": "DE", + "city_name": "Berlin", + "serial_number": "C02XJ0J0JGH7", "extra_dns_labels": [ - "string" + "stage-host-1" ], - "ephemeral": "boolean", - "accessible_peers_count": "integer" + "ephemeral": false, + "accessible_peers_count": 5 } ] ``` @@ -159,46 +159,46 @@ curl -X GET https://api.netbird.io/api/peers/{peerId} \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} { - "id": "string", - "name": "string", - "created_at": "string", - "ip": "string", - "connection_ip": "string", - "connected": "boolean", - "last_seen": "string", - "os": "string", - "kernel_version": "string", - "geoname_id": "integer", - "version": "string", + "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, + "last_seen": "2023-05-05T10:05:26.420578Z", + "os": "Darwin 13.2.1", + "kernel_version": "23.2.0", + "geoname_id": 2643743, + "version": "0.14.0", "groups": [ { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string" + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api" } ], - "ssh_enabled": "boolean", - "user_id": "string", - "hostname": "string", - "ui_version": "string", - "dns_label": "string", - "login_expiration_enabled": "boolean", - "login_expired": "boolean", - "last_login": "string", - "inactivity_expiration_enabled": "boolean", - "approval_required": "boolean", - "country_code": "string", - "city_name": "string", - "serial_number": "string", + "ssh_enabled": true, + "user_id": "google-oauth2|277474792786460067937", + "hostname": "stage-host-1", + "ui_version": "0.14.0", + "dns_label": "stage-host-1.netbird.cloud", + "login_expiration_enabled": false, + "login_expired": false, + "last_login": "2023-05-05T09:00:35.477782Z", + "inactivity_expiration_enabled": false, + "approval_required": true, + "country_code": "DE", + "city_name": "Berlin", + "serial_number": "C02XJ0J0JGH7", "extra_dns_labels": [ - "string" + "stage-host-1" ], - "ephemeral": "boolean" + "ephemeral": false } ``` @@ -302,10 +302,22 @@ Peer's IP address ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/peers/{peerId} \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ + "name": "stage-host-1", + "ssh_enabled": true, + "login_expiration_enabled": false, + "inactivity_expiration_enabled": false, + "approval_required": true, + "ip": "100.64.0.15" +}' +``` + + +```json {{ title: 'Example' }} +{ "id": "chacbco6lnnbn6cg5s90", "name": "stage-host-1", "created_at": "2023-05-05T09:00:35.477782Z", @@ -343,49 +355,6 @@ curl -X PUT https://api.netbird.io/api/peers/{peerId} \ "stage-host-1" ], "ephemeral": false -}' -``` - - -```json {{ title: 'Example' }} -{ - "id": "string", - "name": "string", - "created_at": "string", - "ip": "string", - "connection_ip": "string", - "connected": "boolean", - "last_seen": "string", - "os": "string", - "kernel_version": "string", - "geoname_id": "integer", - "version": "string", - "groups": [ - { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string" - } - ], - "ssh_enabled": "boolean", - "user_id": "string", - "hostname": "string", - "ui_version": "string", - "dns_label": "string", - "login_expiration_enabled": "boolean", - "login_expired": "boolean", - "last_login": "string", - "inactivity_expiration_enabled": "boolean", - "approval_required": "boolean", - "country_code": "string", - "city_name": "string", - "serial_number": "string", - "extra_dns_labels": [ - "string" - ], - "ephemeral": "boolean" } ``` @@ -502,21 +471,21 @@ curl -X GET https://api.netbird.io/api/peers/{peerId}/accessible-peers \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} [ { - "id": "string", - "name": "string", - "ip": "string", - "dns_label": "string", - "user_id": "string", - "os": "string", - "country_code": "string", - "city_name": "string", - "geoname_id": "integer", - "connected": "boolean", - "last_seen": "string" + "id": "chacbco6lnnbn6cg5s90", + "name": "stage-host-1", + "ip": "10.64.0.1", + "dns_label": "stage-host-1.netbird.cloud", + "user_id": "google-oauth2|277474792786460067937", + "os": "linux", + "country_code": "DE", + "city_name": "Berlin", + "geoname_id": 2643743, + "connected": true, + "last_seen": "2023-05-05T10:05:26.420578Z" } ] ``` diff --git a/src/pages/ipa/resources/policies.mdx b/src/pages/ipa/resources/policies.mdx index c10ffffd..254410fb 100644 --- a/src/pages/ipa/resources/policies.mdx +++ b/src/pages/ipa/resources/policies.mdx @@ -18,60 +18,60 @@ curl -X GET https://api.netbird.io/api/policies \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} [ { - "name": "string", - "description": "string", - "enabled": "boolean", - "id": "string", + "name": "ch8i4ug6lnn4g9hqv7mg", + "description": "This is a default policy that allows connections between all the resources", + "enabled": true, + "id": "ch8i4ug6lnn4g9hqv7mg", "source_posture_checks": [ - "string" + "chacdk86lnnboviihd70" ], "rules": [ { - "name": "string", - "description": "string", - "enabled": "boolean", - "action": "string", - "bidirectional": "boolean", - "protocol": "string", + "name": "Default", + "description": "This is a default rule that allows connections between all the resources", + "enabled": true, + "action": "accept", + "bidirectional": true, + "protocol": "tcp", "ports": [ - "string" + "80" ], "port_ranges": [ { - "start": "integer", - "end": "integer" + "start": 80, + "end": 320 } ], - "id": "string", + "id": "ch8i4ug6lnn4g9hqv7mg", "sources": [ { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string" + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api" } ], "sourceResource": { - "id": "string", - "type": "string" + "id": "chacdk86lnnboviihd7g", + "type": "host" }, "destinations": [ { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string" + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api" } ], "destinationResource": { - "id": "string", - "type": "string" + "id": "chacdk86lnnboviihd7g", + "type": "host" } } ] @@ -159,17 +159,106 @@ Creates a policy - + +Policy name identifier + + +Policy friendly description + + +Policy status + + +Posture checks ID's applied to policy source groups + +
-Object list +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 + +
+
+
@@ -183,14 +272,13 @@ Creates a policy ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/policies \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, - "id": "ch8i4ug6lnn4g9hqv7mg", "source_posture_checks": [ "chacdk86lnnboviihd70" ], @@ -213,26 +301,14 @@ curl -X POST https://api.netbird.io/api/policies \ ], "id": "ch8i4ug6lnn4g9hqv7mg", "sources": [ - { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api" - } + "ch8i4ug6lnn4g9hqv797" ], "sourceResource": { "id": "chacdk86lnnboviihd7g", "type": "host" }, "destinations": [ - { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api" - } + "ch8i4ug6lnn4g9h7v7m0" ], "destinationResource": { "id": "chacdk86lnnboviihd7g", @@ -243,59 +319,59 @@ curl -X POST https://api.netbird.io/api/policies \ }' ``` - + ```json {{ title: 'Example' }} { - "name": "string", - "description": "string", - "enabled": "boolean", - "id": "string", + "name": "ch8i4ug6lnn4g9hqv7mg", + "description": "This is a default policy that allows connections between all the resources", + "enabled": true, + "id": "ch8i4ug6lnn4g9hqv7mg", "source_posture_checks": [ - "string" + "chacdk86lnnboviihd70" ], "rules": [ { - "name": "string", - "description": "string", - "enabled": "boolean", - "action": "string", - "bidirectional": "boolean", - "protocol": "string", + "name": "Default", + "description": "This is a default rule that allows connections between all the resources", + "enabled": true, + "action": "accept", + "bidirectional": true, + "protocol": "tcp", "ports": [ - "string" + "80" ], "port_ranges": [ { - "start": "integer", - "end": "integer" + "start": 80, + "end": 320 } ], - "id": "string", + "id": "ch8i4ug6lnn4g9hqv7mg", "sources": [ { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string" + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api" } ], "sourceResource": { - "id": "string", - "type": "string" + "id": "chacdk86lnnboviihd7g", + "type": "host" }, "destinations": [ { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string" + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api" } ], "destinationResource": { - "id": "string", - "type": "string" + "id": "chacdk86lnnboviihd7g", + "type": "host" } } ] @@ -396,59 +472,59 @@ curl -X GET https://api.netbird.io/api/policies/{policyId} \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} { - "name": "string", - "description": "string", - "enabled": "boolean", - "id": "string", + "name": "ch8i4ug6lnn4g9hqv7mg", + "description": "This is a default policy that allows connections between all the resources", + "enabled": true, + "id": "ch8i4ug6lnn4g9hqv7mg", "source_posture_checks": [ - "string" + "chacdk86lnnboviihd70" ], "rules": [ { - "name": "string", - "description": "string", - "enabled": "boolean", - "action": "string", - "bidirectional": "boolean", - "protocol": "string", + "name": "Default", + "description": "This is a default rule that allows connections between all the resources", + "enabled": true, + "action": "accept", + "bidirectional": true, + "protocol": "tcp", "ports": [ - "string" + "80" ], "port_ranges": [ { - "start": "integer", - "end": "integer" + "start": 80, + "end": 320 } ], - "id": "string", + "id": "ch8i4ug6lnn4g9hqv7mg", "sources": [ { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string" + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api" } ], "sourceResource": { - "id": "string", - "type": "string" + "id": "chacdk86lnnboviihd7g", + "type": "host" }, "destinations": [ { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string" + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api" } ], "destinationResource": { - "id": "string", - "type": "string" + "id": "chacdk86lnnboviihd7g", + "type": "host" } } ] @@ -544,17 +620,106 @@ The unique identifier of a policy - + +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 + +
-Object list +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 + + + + +
+
+
@@ -568,14 +733,13 @@ The unique identifier of a policy ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/policies/{policyId} \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, - "id": "ch8i4ug6lnn4g9hqv7mg", "source_posture_checks": [ "chacdk86lnnboviihd70" ], @@ -598,26 +762,14 @@ curl -X PUT https://api.netbird.io/api/policies/{policyId} \ ], "id": "ch8i4ug6lnn4g9hqv7mg", "sources": [ - { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api" - } + "ch8i4ug6lnn4g9hqv797" ], "sourceResource": { "id": "chacdk86lnnboviihd7g", "type": "host" }, "destinations": [ - { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api" - } + "ch8i4ug6lnn4g9h7v7m0" ], "destinationResource": { "id": "chacdk86lnnboviihd7g", @@ -628,59 +780,59 @@ curl -X PUT https://api.netbird.io/api/policies/{policyId} \ }' ``` - + ```json {{ title: 'Example' }} { - "name": "string", - "description": "string", - "enabled": "boolean", - "id": "string", + "name": "ch8i4ug6lnn4g9hqv7mg", + "description": "This is a default policy that allows connections between all the resources", + "enabled": true, + "id": "ch8i4ug6lnn4g9hqv7mg", "source_posture_checks": [ - "string" + "chacdk86lnnboviihd70" ], "rules": [ { - "name": "string", - "description": "string", - "enabled": "boolean", - "action": "string", - "bidirectional": "boolean", - "protocol": "string", + "name": "Default", + "description": "This is a default rule that allows connections between all the resources", + "enabled": true, + "action": "accept", + "bidirectional": true, + "protocol": "tcp", "ports": [ - "string" + "80" ], "port_ranges": [ { - "start": "integer", - "end": "integer" + "start": 80, + "end": 320 } ], - "id": "string", + "id": "ch8i4ug6lnn4g9hqv7mg", "sources": [ { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string" + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api" } ], "sourceResource": { - "id": "string", - "type": "string" + "id": "chacdk86lnnboviihd7g", + "type": "host" }, "destinations": [ { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string" + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api" } ], "destinationResource": { - "id": "string", - "type": "string" + "id": "chacdk86lnnboviihd7g", + "type": "host" } } ] diff --git a/src/pages/ipa/resources/posture-checks.mdx b/src/pages/ipa/resources/posture-checks.mdx index 0cd679b1..191bda8a 100644 --- a/src/pages/ipa/resources/posture-checks.mdx +++ b/src/pages/ipa/resources/posture-checks.mdx @@ -18,55 +18,57 @@ curl -X GET https://api.netbird.io/api/posture-checks \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} [ { - "id": "string", - "name": "string", - "description": "string", + "id": "ch8i4ug6lnn4g9hqv7mg", + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", "checks": { "nb_version_check": { - "min_version": "string" + "min_version": "14.3" }, "os_version_check": { "android": { - "min_version": "string" - }, - "darwin": { - "min_version": "string" + "min_version": "13" }, "ios": { - "min_version": "string" + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" }, "linux": { - "min_kernel_version": "string" + "min_kernel_version": "5.3.3" }, "windows": { - "min_kernel_version": "string" + "min_kernel_version": "10.0.1234" } }, "geo_location_check": { "locations": [ { - "country_code": "string", - "city_name": "string" + "country_code": "DE", + "city_name": "Berlin" } ], - "action": "string" + "action": "allow" }, "peer_network_range_check": { "ranges": [ - "string" + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" ], - "action": "string" + "action": "allow" }, "process_check": { "processes": [ { - "linux_path": "string", - "mac_path": "string", - "windows_path": "string" + "linux_path": "/usr/local/bin/netbird", + "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", + "windows_path": "C:
rogramData…etBird\netbird.exe" } ] } @@ -161,28 +163,183 @@ Posture check friendly description
-Object list +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 +
+
+ +
+ +
+
+
@@ -196,11 +353,10 @@ Posture check friendly description ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/posture-checks \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ - "id": "ch8i4ug6lnn4g9hqv7mg", "name": "Default", "description": "This checks if the peer is running required NetBird's version", "checks": { @@ -254,54 +410,56 @@ curl -X POST https://api.netbird.io/api/posture-checks \ }' ``` - + ```json {{ title: 'Example' }} { - "id": "string", - "name": "string", - "description": "string", + "id": "ch8i4ug6lnn4g9hqv7mg", + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", "checks": { "nb_version_check": { - "min_version": "string" + "min_version": "14.3" }, "os_version_check": { "android": { - "min_version": "string" - }, - "darwin": { - "min_version": "string" + "min_version": "13" }, "ios": { - "min_version": "string" + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" }, "linux": { - "min_kernel_version": "string" + "min_kernel_version": "5.3.3" }, "windows": { - "min_kernel_version": "string" + "min_kernel_version": "10.0.1234" } }, "geo_location_check": { "locations": [ { - "country_code": "string", - "city_name": "string" + "country_code": "DE", + "city_name": "Berlin" } ], - "action": "string" + "action": "allow" }, "peer_network_range_check": { "ranges": [ - "string" + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" ], - "action": "string" + "action": "allow" }, "process_check": { "processes": [ { - "linux_path": "string", - "mac_path": "string", - "windows_path": "string" + "linux_path": "/usr/local/bin/netbird", + "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", + "windows_path": "C:
rogramData…etBird\netbird.exe" } ] } @@ -399,54 +557,56 @@ curl -X GET https://api.netbird.io/api/posture-checks/{postureCheckId} \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} { - "id": "string", - "name": "string", - "description": "string", + "id": "ch8i4ug6lnn4g9hqv7mg", + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", "checks": { "nb_version_check": { - "min_version": "string" + "min_version": "14.3" }, "os_version_check": { "android": { - "min_version": "string" - }, - "darwin": { - "min_version": "string" + "min_version": "13" }, "ios": { - "min_version": "string" + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" }, "linux": { - "min_kernel_version": "string" + "min_kernel_version": "5.3.3" }, "windows": { - "min_kernel_version": "string" + "min_kernel_version": "10.0.1234" } }, "geo_location_check": { "locations": [ { - "country_code": "string", - "city_name": "string" + "country_code": "DE", + "city_name": "Berlin" } ], - "action": "string" + "action": "allow" }, "peer_network_range_check": { "ranges": [ - "string" + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" ], - "action": "string" + "action": "allow" }, "process_check": { "processes": [ { - "linux_path": "string", - "mac_path": "string", - "windows_path": "string" + "linux_path": "/usr/local/bin/netbird", + "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", + "windows_path": "C:
rogramData…etBird\netbird.exe" } ] } @@ -549,28 +709,183 @@ Posture check friendly description
-Object list +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 +
+
+ +
+ +
+
+
@@ -584,11 +899,10 @@ Posture check friendly description ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/posture-checks/{postureCheckId} \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ - "id": "ch8i4ug6lnn4g9hqv7mg", "name": "Default", "description": "This checks if the peer is running required NetBird's version", "checks": { @@ -642,54 +956,56 @@ curl -X PUT https://api.netbird.io/api/posture-checks/{postureCheckId} \ }' ``` - + ```json {{ title: 'Example' }} { - "id": "string", - "name": "string", - "description": "string", + "id": "ch8i4ug6lnn4g9hqv7mg", + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", "checks": { "nb_version_check": { - "min_version": "string" + "min_version": "14.3" }, "os_version_check": { "android": { - "min_version": "string" - }, - "darwin": { - "min_version": "string" + "min_version": "13" }, "ios": { - "min_version": "string" + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" }, "linux": { - "min_kernel_version": "string" + "min_kernel_version": "5.3.3" }, "windows": { - "min_kernel_version": "string" + "min_kernel_version": "10.0.1234" } }, "geo_location_check": { "locations": [ { - "country_code": "string", - "city_name": "string" + "country_code": "DE", + "city_name": "Berlin" } ], - "action": "string" + "action": "allow" }, "peer_network_range_check": { "ranges": [ - "string" + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" ], - "action": "string" + "action": "allow" }, "process_check": { "processes": [ { - "linux_path": "string", - "mac_path": "string", - "windows_path": "string" + "linux_path": "/usr/local/bin/netbird", + "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", + "windows_path": "C:
rogramData…etBird\netbird.exe" } ] } diff --git a/src/pages/ipa/resources/routes.mdx b/src/pages/ipa/resources/routes.mdx index 84cef09f..c39b7136 100644 --- a/src/pages/ipa/resources/routes.mdx +++ b/src/pages/ipa/resources/routes.mdx @@ -18,32 +18,33 @@ curl -X GET https://api.netbird.io/api/routes \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} [ { - "id": "string", - "network_type": "string", - "description": "string", - "network_id": "string", - "enabled": "boolean", - "peer": "string", + "id": "chacdk86lnnboviihd7g", + "network_type": "IPv4", + "description": "My first route", + "network_id": "Route 1", + "enabled": true, + "peer": "chacbco6lnnbn6cg5s91", "peer_groups": [ - "string" + "chacbco6lnnbn6cg5s91" ], - "network": "string", + "network": "10.64.0.0/24", "domains": [ - "string" + "example.com" ], - "metric": "integer", - "masquerade": "boolean", + "metric": 9999, + "masquerade": true, "groups": [ - "string" + "chacdk86lnnboviihd70" ], - "keep_route": "boolean", + "keep_route": true, "access_control_groups": [ - "string" - ] + "chacbco6lnnbn6cg5s91" + ], + "skip_auto_apply": false } ] ``` @@ -72,7 +73,8 @@ curl -X GET https://api.netbird.io/api/routes \ "keep_route": "boolean", "access_control_groups": [ "string" - ] + ], + "skip_auto_apply": "boolean" } ] ``` @@ -118,7 +120,7 @@ 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 @@ -133,6 +135,9 @@ Indicate if the route should be kept after a domain doesn't resolve that IP anym 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 +
@@ -142,12 +147,10 @@ Access control group identifier associated with route. ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/routes \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ - "id": "chacdk86lnnboviihd7g", - "network_type": "IPv4", "description": "My first route", "network_id": "Route 1", "enabled": true, @@ -167,35 +170,37 @@ curl -X POST https://api.netbird.io/api/routes \ "keep_route": true, "access_control_groups": [ "chacbco6lnnbn6cg5s91" - ] + ], + "skip_auto_apply": false }' ``` - + ```json {{ title: 'Example' }} { - "id": "string", - "network_type": "string", - "description": "string", - "network_id": "string", - "enabled": "boolean", - "peer": "string", + "id": "chacdk86lnnboviihd7g", + "network_type": "IPv4", + "description": "My first route", + "network_id": "Route 1", + "enabled": true, + "peer": "chacbco6lnnbn6cg5s91", "peer_groups": [ - "string" + "chacbco6lnnbn6cg5s91" ], - "network": "string", + "network": "10.64.0.0/24", "domains": [ - "string" + "example.com" ], - "metric": "integer", - "masquerade": "boolean", + "metric": 9999, + "masquerade": true, "groups": [ - "string" + "chacdk86lnnboviihd70" ], - "keep_route": "boolean", + "keep_route": true, "access_control_groups": [ - "string" - ] + "chacbco6lnnbn6cg5s91" + ], + "skip_auto_apply": false } ``` @@ -222,7 +227,8 @@ curl -X POST https://api.netbird.io/api/routes \ "keep_route": "boolean", "access_control_groups": [ "string" - ] + ], + "skip_auto_apply": "boolean" } ``` @@ -262,31 +268,32 @@ curl -X GET https://api.netbird.io/api/routes/{routeId} \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} { - "id": "string", - "network_type": "string", - "description": "string", - "network_id": "string", - "enabled": "boolean", - "peer": "string", + "id": "chacdk86lnnboviihd7g", + "network_type": "IPv4", + "description": "My first route", + "network_id": "Route 1", + "enabled": true, + "peer": "chacbco6lnnbn6cg5s91", "peer_groups": [ - "string" + "chacbco6lnnbn6cg5s91" ], - "network": "string", + "network": "10.64.0.0/24", "domains": [ - "string" + "example.com" ], - "metric": "integer", - "masquerade": "boolean", + "metric": 9999, + "masquerade": true, "groups": [ - "string" + "chacdk86lnnboviihd70" ], - "keep_route": "boolean", + "keep_route": true, "access_control_groups": [ - "string" - ] + "chacbco6lnnbn6cg5s91" + ], + "skip_auto_apply": false } ``` @@ -313,7 +320,8 @@ curl -X GET https://api.netbird.io/api/routes/{routeId} \ "keep_route": "boolean", "access_control_groups": [ "string" - ] + ], + "skip_auto_apply": "boolean" } ``` @@ -369,7 +377,7 @@ 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 @@ -384,6 +392,9 @@ Indicate if the route should be kept after a domain doesn't resolve that IP anym 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 +
@@ -393,12 +404,10 @@ Access control group identifier associated with route. ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/routes/{routeId} \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ - "id": "chacdk86lnnboviihd7g", - "network_type": "IPv4", "description": "My first route", "network_id": "Route 1", "enabled": true, @@ -418,35 +427,37 @@ curl -X PUT https://api.netbird.io/api/routes/{routeId} \ "keep_route": true, "access_control_groups": [ "chacbco6lnnbn6cg5s91" - ] + ], + "skip_auto_apply": false }' ``` - + ```json {{ title: 'Example' }} { - "id": "string", - "network_type": "string", - "description": "string", - "network_id": "string", - "enabled": "boolean", - "peer": "string", + "id": "chacdk86lnnboviihd7g", + "network_type": "IPv4", + "description": "My first route", + "network_id": "Route 1", + "enabled": true, + "peer": "chacbco6lnnbn6cg5s91", "peer_groups": [ - "string" + "chacbco6lnnbn6cg5s91" ], - "network": "string", + "network": "10.64.0.0/24", "domains": [ - "string" + "example.com" ], - "metric": "integer", - "masquerade": "boolean", + "metric": 9999, + "masquerade": true, "groups": [ - "string" + "chacdk86lnnboviihd70" ], - "keep_route": "boolean", + "keep_route": true, "access_control_groups": [ - "string" - ] + "chacbco6lnnbn6cg5s91" + ], + "skip_auto_apply": false } ``` @@ -473,7 +484,8 @@ curl -X PUT https://api.netbird.io/api/routes/{routeId} \ "keep_route": "boolean", "access_control_groups": [ "string" - ] + ], + "skip_auto_apply": "boolean" } ``` diff --git a/src/pages/ipa/resources/setup-keys.mdx b/src/pages/ipa/resources/setup-keys.mdx index df83c292..980047c6 100644 --- a/src/pages/ipa/resources/setup-keys.mdx +++ b/src/pages/ipa/resources/setup-keys.mdx @@ -18,27 +18,27 @@ curl -X GET https://api.netbird.io/api/setup-keys \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} [ { - "id": "string", - "name": "string", - "expires": "string", - "type": "string", - "valid": "boolean", - "revoked": "boolean", - "used_times": "integer", - "last_used": "string", - "state": "string", + "id": 2531583362, + "name": "Default key", + "expires": "2023-06-01T14:47:22.291057Z", + "type": "reusable", + "valid": true, + "revoked": false, + "used_times": 2, + "last_used": "2023-05-05T09:00:35.477782Z", + "state": "valid", "auto_groups": [ - "string" + "ch8i4ug6lnn4g9hqv7m0" ], - "updated_at": "string", - "usage_limit": "integer", - "ephemeral": "boolean", - "allow_extra_dns_labels": "boolean", - "key": "string" + "updated_at": "2023-05-05T09:00:35.477782Z", + "usage_limit": 0, + "ephemeral": true, + "allow_extra_dns_labels": true, + "key": "A6160****" } ] ``` @@ -93,7 +93,7 @@ Setup Key name Setup key type, one-off for single time usage and reusable - + Expiration time in seconds @@ -117,10 +117,25 @@ Allow extra DNS labels to be added to the peer ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/setup-keys \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ + "name": "Default key", + "type": "reusable", + "expires_in": 86400, + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "usage_limit": 0, + "ephemeral": true, + "allow_extra_dns_labels": true +}' +``` + + +```json {{ title: 'Example' }} +{ "id": 2531583362, "name": "Default key", "expires": "2023-06-01T14:47:22.291057Z", @@ -138,29 +153,6 @@ curl -X POST https://api.netbird.io/api/setup-keys \ "ephemeral": true, "allow_extra_dns_labels": true, "key": "A616097E-FCF0-48FA-9354-CA4A61142761" -}' -``` - - -```json {{ title: 'Example' }} -{ - "id": "string", - "name": "string", - "expires": "string", - "type": "string", - "valid": "boolean", - "revoked": "boolean", - "used_times": "integer", - "last_used": "string", - "state": "string", - "auto_groups": [ - "string" - ], - "updated_at": "string", - "usage_limit": "integer", - "ephemeral": "boolean", - "allow_extra_dns_labels": "boolean", - "key": "string" } ``` @@ -222,26 +214,26 @@ curl -X GET https://api.netbird.io/api/setup-keys/{keyId} \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} { - "id": "string", - "name": "string", - "expires": "string", - "type": "string", - "valid": "boolean", - "revoked": "boolean", - "used_times": "integer", - "last_used": "string", - "state": "string", + "id": 2531583362, + "name": "Default key", + "expires": "2023-06-01T14:47:22.291057Z", + "type": "reusable", + "valid": true, + "revoked": false, + "used_times": 2, + "last_used": "2023-05-05T09:00:35.477782Z", + "state": "valid", "auto_groups": [ - "string" + "ch8i4ug6lnn4g9hqv7m0" ], - "updated_at": "string", - "usage_limit": "integer", - "ephemeral": "boolean", - "allow_extra_dns_labels": "boolean", - "key": "string" + "updated_at": "2023-05-05T09:00:35.477782Z", + "usage_limit": 0, + "ephemeral": true, + "allow_extra_dns_labels": true, + "key": "A6160****" } ``` @@ -313,10 +305,20 @@ 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 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ + "revoked": false, + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ] +}' +``` + + +```json {{ title: 'Example' }} +{ "id": 2531583362, "name": "Default key", "expires": "2023-06-01T14:47:22.291057Z", @@ -334,29 +336,6 @@ curl -X PUT https://api.netbird.io/api/setup-keys/{keyId} \ "ephemeral": true, "allow_extra_dns_labels": true, "key": "A6160****" -}' -``` - - -```json {{ title: 'Example' }} -{ - "id": "string", - "name": "string", - "expires": "string", - "type": "string", - "valid": "boolean", - "revoked": "boolean", - "used_times": "integer", - "last_used": "string", - "state": "string", - "auto_groups": [ - "string" - ], - "updated_at": "string", - "usage_limit": "integer", - "ephemeral": "boolean", - "allow_extra_dns_labels": "boolean", - "key": "string" } ``` diff --git a/src/pages/ipa/resources/tokens.mdx b/src/pages/ipa/resources/tokens.mdx index 826d375e..00221860 100644 --- a/src/pages/ipa/resources/tokens.mdx +++ b/src/pages/ipa/resources/tokens.mdx @@ -29,16 +29,16 @@ curl -X GET https://api.netbird.io/api/users/{userId}/tokens \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} [ { - "id": "string", - "name": "string", - "expiration_date": "string", - "created_by": "string", - "created_at": "string", - "last_used": "string" + "id": "ch8i54g6lnn4g9hqv7n0", + "name": "My first token", + "expiration_date": "2023-05-05T14:38:28.977616Z", + "created_by": "google-oauth2|277474792786460067937", + "created_at": "2023-05-02T14:48:20.465209Z", + "last_used": "2023-05-04T12:45:25.9723616Z" } ] ``` @@ -90,7 +90,7 @@ The unique identifier of a user Name of the token - + Expiration in days @@ -102,10 +102,18 @@ Expiration in days ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/users/{userId}/tokens \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ + "name": "My first token", + "expires_in": 30 +}' +``` + + +```json {{ title: 'Example' }} +{ "plain_token": "2023-05-02T14:48:20.465209Z", "personal_access_token": { "id": "ch8i54g6lnn4g9hqv7n0", @@ -115,21 +123,6 @@ curl -X POST https://api.netbird.io/api/users/{userId}/tokens \ "created_at": "2023-05-02T14:48:20.465209Z", "last_used": "2023-05-04T12:45:25.9723616Z" } -}' -``` - - -```json {{ title: 'Example' }} -{ - "plain_token": "string", - "personal_access_token": { - "id": "string", - "name": "string", - "expiration_date": "string", - "created_by": "string", - "created_at": "string", - "last_used": "string" - } } ``` @@ -186,15 +179,15 @@ curl -X GET https://api.netbird.io/api/users/{userId}/tokens/{tokenId} \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} { - "id": "string", - "name": "string", - "expiration_date": "string", - "created_by": "string", - "created_at": "string", - "last_used": "string" + "id": "ch8i54g6lnn4g9hqv7n0", + "name": "My first token", + "expiration_date": "2023-05-05T14:38:28.977616Z", + "created_by": "google-oauth2|277474792786460067937", + "created_at": "2023-05-02T14:48:20.465209Z", + "last_used": "2023-05-04T12:45:25.9723616Z" } ``` diff --git a/src/pages/ipa/resources/users.mdx b/src/pages/ipa/resources/users.mdx index 9275fe62..2fea1897 100644 --- a/src/pages/ipa/resources/users.mdx +++ b/src/pages/ipa/resources/users.mdx @@ -9,7 +9,7 @@ export const title = 'Users' Returns a list of all users -### Path Parameters +### Query Parameters @@ -29,44 +29,38 @@ curl -X GET https://api.netbird.io/api/users \ -H 'Authorization: Token ' ``` - + ```json {{ title: 'Example' }} [ { - "id": "string", - "email": "string", - "name": "string", - "role": "string", - "status": "string", - "last_login": "string", + "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": [ - "string" + "ch8i4ug6lnn4g9hqv7m0" ], - "is_current": "boolean", - "is_service_user": "boolean", - "is_blocked": "boolean", - "issued": "string", + "is_current": true, + "is_service_user": false, + "is_blocked": false, + "pending_approval": false, + "issued": "api", "permissions": { - "is_restricted": "boolean", + "is_restricted": false, "modules": { - "type": "object", - "additionalProperties": { - "type": "object", - "additionalProperties": "boolean" + "networks": { + "read": true, + "create": false, + "update": false, + "delete": false }, - "example": { - "networks": { - "read": true, - "create": false, - "update": false, - "delete": false - }, - "peers": { - "read": false, - "create": false, - "update": false, - "delete": false - } + "peers": { + "read": false, + "create": false, + "update": false, + "delete": false } } } @@ -89,6 +83,7 @@ curl -X GET https://api.netbird.io/api/users \ "is_current": "boolean", "is_service_user": "boolean", "is_blocked": "boolean", + "pending_approval": "boolean", "issued": "string", "permissions": { "is_restricted": "boolean", @@ -162,10 +157,23 @@ Is true if this user is a service user ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/users \ +-H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ + "email": "demo@netbird.io", + "name": "Tom Schulz", + "role": "admin", + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "is_service_user": false +}' +``` + + +```json {{ title: 'Example' }} +{ "id": "google-oauth2|277474792786460067937", "email": "demo@netbird.io", "name": "Tom Schulz", @@ -178,6 +186,7 @@ curl -X POST https://api.netbird.io/api/users \ "is_current": true, "is_service_user": false, "is_blocked": false, + "pending_approval": false, "issued": "api", "permissions": { "is_restricted": false, @@ -196,49 +205,6 @@ curl -X POST https://api.netbird.io/api/users \ } } } -}' -``` - - -```json {{ title: 'Example' }} -{ - "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", - "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 - } - } - } - } } ``` @@ -256,6 +222,7 @@ curl -X POST https://api.netbird.io/api/users \ "is_current": "boolean", "is_service_user": "boolean", "is_blocked": "boolean", + "pending_approval": "boolean", "issued": "string", "permissions": { "is_restricted": "boolean", @@ -333,10 +300,21 @@ 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 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --H 'Authorization: Token ' \ --data-raw '{ + "role": "admin", + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "is_blocked": false +}' +``` + + +```json {{ title: 'Example' }} +{ "id": "google-oauth2|277474792786460067937", "email": "demo@netbird.io", "name": "Tom Schulz", @@ -349,6 +327,7 @@ curl -X PUT https://api.netbird.io/api/users/{userId} \ "is_current": true, "is_service_user": false, "is_blocked": false, + "pending_approval": false, "issued": "api", "permissions": { "is_restricted": false, @@ -367,49 +346,6 @@ curl -X PUT https://api.netbird.io/api/users/{userId} \ } } } -}' -``` - - -```json {{ title: 'Example' }} -{ - "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", - "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 - } - } - } - } } ``` @@ -427,6 +363,7 @@ curl -X PUT https://api.netbird.io/api/users/{userId} \ "is_current": "boolean", "is_service_user": "boolean", "is_blocked": "boolean", + "pending_approval": "boolean", "issued": "string", "permissions": { "is_restricted": "boolean", @@ -522,10 +459,7 @@ The unique identifier of a user ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/users/{userId}/invite \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ -H 'Authorization: Token ' \ ---data-raw '' ``` @@ -536,25 +470,71 @@ curl -X POST https://api.netbird.io/api/users/{userId}/invite \ -## 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 \ --H 'Accept: application/json' \ --H 'Authorization: Token ' +curl -X POST https://api.netbird.io/api/users/{userId}/approve \ +-H 'Authorization: Token ' \ ``` - + ```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", @@ -568,6 +548,7 @@ curl -X GET https://api.netbird.io/api/users/current \ "is_current": "boolean", "is_service_user": "boolean", "is_blocked": "boolean", + "pending_approval": "boolean", "issued": "string", "permissions": { "is_restricted": "boolean", @@ -595,6 +576,103 @@ curl -X GET https://api.netbird.io/api/users/current \ } } ``` + + + + + +--- + + + +## 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 ' \ +``` + + + + + +--- + + + +## 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 ' +``` + + +```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' }} { @@ -610,6 +688,7 @@ curl -X GET https://api.netbird.io/api/users/current \ "is_current": "boolean", "is_service_user": "boolean", "is_blocked": "boolean", + "pending_approval": "boolean", "issued": "string", "permissions": { "is_restricted": "boolean", From 19597c1821aefb48639ae036aa345f7c950e6d49 Mon Sep 17 00:00:00 2001 From: aliamerj Date: Tue, 23 Sep 2025 21:28:34 +0300 Subject: [PATCH 3/5] fix bug and fully support oneOf --- openapi-gen/index.ts | 8 +- openapi-gen/templates/ApiTemplate.tsx | 4 +- openapi-gen/tsxParser/api/requests.ts | 35 ++++-- openapi-gen/tsxParser/components/index.tsx | 49 +++++--- openapi-gen/tsxParser/openapi-extractor.ts | 27 ++-- src/pages/ipa/resources/accounts.mdx | 33 +++-- src/pages/ipa/resources/dns.mdx | 57 ++++----- src/pages/ipa/resources/events.mdx | 14 +-- src/pages/ipa/resources/geo-locations.mdx | 14 +-- src/pages/ipa/resources/groups.mdx | 43 +++---- src/pages/ipa/resources/ingress-ports.mdx | 86 ++++++------- src/pages/ipa/resources/networks.mdx | 112 +++++++---------- src/pages/ipa/resources/peers.mdx | 35 +++--- src/pages/ipa/resources/policies.mdx | 67 +++++----- src/pages/ipa/resources/posture-checks.mdx | 139 ++++++++++----------- src/pages/ipa/resources/routes.mdx | 35 +++--- src/pages/ipa/resources/setup-keys.mdx | 35 +++--- src/pages/ipa/resources/tokens.mdx | 28 ++--- src/pages/ipa/resources/users.mdx | 56 ++++----- 19 files changed, 412 insertions(+), 465 deletions(-) diff --git a/openapi-gen/index.ts b/openapi-gen/index.ts index 45bd89f5..85e88a42 100644 --- a/openapi-gen/index.ts +++ b/openapi-gen/index.ts @@ -33,10 +33,14 @@ import { mkdir, writeFile } from "fs/promises" 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.push(flag) + if (flag.startsWith('x-') && ymlTag[flag] && !customFlags[endpoint.tag].includes(flag)) { + customFlags[endpoint.tag].push(flag) } } }) diff --git a/openapi-gen/templates/ApiTemplate.tsx b/openapi-gen/templates/ApiTemplate.tsx index b150c7b3..23d48d61 100644 --- a/openapi-gen/templates/ApiTemplate.tsx +++ b/openapi-gen/templates/ApiTemplate.tsx @@ -13,7 +13,9 @@ export const ApiTemplate = ({ tag, endpoints, customFlags }: ApiTemplateProps) = {endpoints.map((end, index) => { - const flags = customFlags ? [...customFlags, ...end.flags] : end.flags + const flags = customFlags + ? [...new Set([...customFlags, ...end.flags])] + : [...new Set(end.flags)]; return (

diff --git a/openapi-gen/tsxParser/api/requests.ts b/openapi-gen/tsxParser/api/requests.ts index 59572825..a5bcfe42 100644 --- a/openapi-gen/tsxParser/api/requests.ts +++ b/openapi-gen/tsxParser/api/requests.ts @@ -2,27 +2,40 @@ import { Endpoint } from "../../tsxParser/openapi-extractor" export const requestCode = (endPoint: Endpoint) => { - const body = {}; - endPoint?.request?.map(req => { - if (req.example !== undefined) { - body[req.name] = req.example - } - }) - - const bodyJson = JSON.stringify(body, null, 2) - + const body = getRequestBody(endPoint) switch (endPoint.method) { case 'GET': return getRequestCode(endPoint.path) case "POST": - return postRequestCode(endPoint.path, bodyJson) + return postRequestCode(endPoint.path, body) case "PUT": - return putRequestCode(endPoint.path, bodyJson) + 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); +}; + const deleteRequestCode = (url: string) => { const langCode = [] langCode.push(`\`\`\`bash {{ title: 'cURL' }} diff --git a/openapi-gen/tsxParser/components/index.tsx b/openapi-gen/tsxParser/components/index.tsx index dff49122..abcdc4cc 100644 --- a/openapi-gen/tsxParser/components/index.tsx +++ b/openapi-gen/tsxParser/components/index.tsx @@ -6,34 +6,47 @@ import { Endpoint } from "../openapi-extractor"; export const Stringify = ({ str }: { str: string }) => <>{str} export const Row = ({ children }) => <> - {"\n<"}Row{">\n"} + {"\n\n"} {children} - {"\n"} + {"\n\n"} -export const Details = ({ children, className, open }: { children: React.ReactNode, className: string, open?: boolean }) => <> - {"\n<"}details{className ? ` class="${className}" ` : ""}{open ? "open " : ""}{">\n"} - {children} - {"\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<"}summary{">"} + {"\n"} {children} - {""} - + {""} -export const Col = ({ children, sticky }: { children: React.ReactNode, sticky?: boolean }) => <> - {"\n<"}Col{sticky ? ' sticky' : ""}{">\n"} - {children} - {"\n\n"} - +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<"}Properties{">\n"} + {"\n\n"} {children} - {"\n\n"} + {"\n\n"} export const Badge = ({ customFlag }: { customFlag: string }) => { @@ -50,7 +63,6 @@ export const Badge = ({ customFlag }: { customFlag: string }) => { component += ` hoverText="This feature is experimental. The endpoint will likely change and we do not guarantee backwards compatibility."` } - component += " />" return <> @@ -66,7 +78,6 @@ type PropertyProps = { minLen?: number, maxLen?: number enumList?: string[] - children: React.ReactNode, } diff --git a/openapi-gen/tsxParser/openapi-extractor.ts b/openapi-gen/tsxParser/openapi-extractor.ts index cb509195..b40f9f45 100644 --- a/openapi-gen/tsxParser/openapi-extractor.ts +++ b/openapi-gen/tsxParser/openapi-extractor.ts @@ -24,6 +24,7 @@ export type Request = { maximum?: number example?: string enumList?: any[] + isOneOf?: boolean, bodyObj?: Request[] } @@ -331,13 +332,10 @@ function buildSchemaRepresentation(node: any, doc: OpenAPIV3_1.Document, seenRef return buildSchemaRepresentation(dereferenceNode(resolved, doc, seenRefs), doc, seenRefs) } - // oneOf/anyOf (already dereferenced to actual nodes) + // oneOf (already dereferenced to actual nodes) if (node.oneOf) { return { oneOf: node.oneOf.map((o: any) => buildSchemaRepresentation(o, doc, new Set(seenRefs))) } } - if (node.anyOf) { - return { anyOf: node.anyOf.map((o: any) => buildSchemaRepresentation(o, doc, new Set(seenRefs))) } - } // array if (node.type === 'array' || node.items) { @@ -393,11 +391,6 @@ function extractFromSchema(node: any, doc: OpenAPIV3_1.Document, seenRefs = new const firstExample = options.find(o => o.example !== undefined && o.example !== null)?.example ?? null return { schema: { oneOf: options.map(o => o.schema) }, example: firstExample } } - if (deref.anyOf) { - const options = deref.anyOf.map((opt: any) => extractFromSchema(opt, doc, new Set(seenRefs))) - const firstExample = options.find(o => o.example !== undefined && o.example !== null)?.example ?? null - return { schema: { anyOf: options.map(o => o.schema) }, example: firstExample } - } // Arrays if (deref.type === 'array' || deref.items) { @@ -553,23 +546,29 @@ function schemaNodeToRequests( // 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 optReqs = schemaNodeToRequests(opt, doc, `option_${idx + 1}`, [], new Set(seenRefs)) + 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: true, + required: false, example: opt.example, bodyObj: optReqs + } }) out.push({ name: propName, - type: 'object[]', + type: 'object', required: true, - description: prop.description, - bodyObj: options + description: "One of", + bodyObj: options, + isOneOf: true, }) + continue } // array property if (prop.type === 'array' || prop.items) { diff --git a/src/pages/ipa/resources/accounts.mdx b/src/pages/ipa/resources/accounts.mdx index df63a97e..1f7bb469 100644 --- a/src/pages/ipa/resources/accounts.mdx +++ b/src/pages/ipa/resources/accounts.mdx @@ -5,12 +5,10 @@ export const title = 'Accounts' - - + 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 \ @@ -107,6 +105,7 @@ curl -X GET https://api.netbird.io/api/accounts \ + --- @@ -115,8 +114,7 @@ curl -X GET https://api.netbird.io/api/accounts \ - - + Update information about an account ### Path Parameters @@ -135,8 +133,7 @@ The unique identifier of an account - -
+
More Information @@ -177,8 +174,7 @@ 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 @@ -201,6 +197,7 @@ Enables or disables network traffic packet counter. If enabled, network packets
+ Enables or disables experimental lazy connection @@ -209,10 +206,10 @@ Enables or disables experimental lazy connection
+
- -
+
More Information @@ -226,13 +223,13 @@ Indicates whether the account onboarding flow is pending
+ - - + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/accounts/{accountId} \ @@ -358,6 +355,7 @@ curl -X PUT https://api.netbird.io/api/accounts/{accountId} \ + --- @@ -366,8 +364,7 @@ curl -X PUT https://api.netbird.io/api/accounts/{accountId} \ - - + Deletes an account and all its resources. Only account owners can delete accounts. ### Path Parameters @@ -381,8 +378,7 @@ The unique identifier of an account - - + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/accounts/{accountId} \ @@ -393,4 +389,5 @@ curl -X DELETE https://api.netbird.io/api/accounts/{accountId} \ + --- diff --git a/src/pages/ipa/resources/dns.mdx b/src/pages/ipa/resources/dns.mdx index bd0dd522..0f74d541 100644 --- a/src/pages/ipa/resources/dns.mdx +++ b/src/pages/ipa/resources/dns.mdx @@ -5,12 +5,10 @@ export const title = 'DNS' - - + Returns a list of all Nameserver Groups - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/dns/nameservers \ @@ -75,6 +73,7 @@ curl -X GET https://api.netbird.io/api/dns/nameservers \ + --- @@ -83,8 +82,7 @@ curl -X GET https://api.netbird.io/api/dns/nameservers \ - - + Creates a Nameserver Group ### Request-Body Parameters @@ -98,8 +96,7 @@ Name of nameserver group name Description of the nameserver group - -
+
Nameserver list @@ -116,6 +113,7 @@ Nameserver Port
+ Nameserver group status @@ -136,8 +134,7 @@ Search domain status for match domains. It should be true only if domains list i - - + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/dns/nameservers \ @@ -219,6 +216,7 @@ curl -X POST https://api.netbird.io/api/dns/nameservers \ + --- @@ -227,8 +225,7 @@ curl -X POST https://api.netbird.io/api/dns/nameservers \ - - + Get information about a Nameserver Groups ### Path Parameters @@ -242,8 +239,7 @@ The unique identifier of a Nameserver Group - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ @@ -304,6 +300,7 @@ curl -X GET https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ + --- @@ -312,8 +309,7 @@ curl -X GET https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ - - + Update/Replace a Nameserver Group ### Path Parameters @@ -338,8 +334,7 @@ Name of nameserver group name Description of the nameserver group - -
+
Nameserver list @@ -356,6 +351,7 @@ Nameserver Port
+ Nameserver group status @@ -376,8 +372,7 @@ Search domain status for match domains. It should be true only if domains list i - - + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ @@ -459,6 +454,7 @@ curl -X PUT https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ + --- @@ -467,8 +463,7 @@ curl -X PUT https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ - - + Delete a Nameserver Group ### Path Parameters @@ -482,8 +477,7 @@ The unique identifier of a Nameserver Group - - + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ @@ -494,6 +488,7 @@ curl -X DELETE https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ + --- @@ -502,12 +497,10 @@ curl -X DELETE https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ - - + Returns a DNS settings object - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/dns/settings \ @@ -540,6 +533,7 @@ curl -X GET https://api.netbird.io/api/dns/settings \ + --- @@ -548,8 +542,7 @@ curl -X GET https://api.netbird.io/api/dns/settings \ - - + Updates a DNS settings object ### Request-Body Parameters @@ -563,8 +556,7 @@ Groups whose DNS management is disabled - - + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/dns/settings \ @@ -599,4 +591,5 @@ curl -X PUT https://api.netbird.io/api/dns/settings \ + --- diff --git a/src/pages/ipa/resources/events.mdx b/src/pages/ipa/resources/events.mdx index 0ac94c3f..c7acd213 100644 --- a/src/pages/ipa/resources/events.mdx +++ b/src/pages/ipa/resources/events.mdx @@ -5,12 +5,10 @@ export const title = 'Events' - - + Returns a list of all audit events - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/events/audit \ @@ -67,6 +65,7 @@ curl -X GET https://api.netbird.io/api/events/audit \ + --- @@ -75,8 +74,7 @@ curl -X GET https://api.netbird.io/api/events/audit \ - - + Returns a list of all network traffic events ### Query Parameters @@ -120,8 +118,7 @@ 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 \ @@ -262,4 +259,5 @@ curl -X GET https://api.netbird.io/api/events/network-traffic \ + --- diff --git a/src/pages/ipa/resources/geo-locations.mdx b/src/pages/ipa/resources/geo-locations.mdx index 198a762a..f4e02242 100644 --- a/src/pages/ipa/resources/geo-locations.mdx +++ b/src/pages/ipa/resources/geo-locations.mdx @@ -5,12 +5,10 @@ export const title = 'Geo Locations' - - + 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 \ @@ -35,6 +33,7 @@ curl -X GET https://api.netbird.io/api/locations/countries \ + --- @@ -43,8 +42,7 @@ curl -X GET https://api.netbird.io/api/locations/countries \ - - + Get a list of all English city names for a given country code ### Path Parameters @@ -58,8 +56,7 @@ Get a list of all English city names for a given country code - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/locations/countries/{country}/cities \ @@ -86,4 +83,5 @@ curl -X GET https://api.netbird.io/api/locations/countries/{country}/cities \ + --- diff --git a/src/pages/ipa/resources/groups.mdx b/src/pages/ipa/resources/groups.mdx index 6ed1ba1c..27445a3a 100644 --- a/src/pages/ipa/resources/groups.mdx +++ b/src/pages/ipa/resources/groups.mdx @@ -5,12 +5,10 @@ export const title = 'Groups' - - + Returns a list of all groups - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/groups \ @@ -71,6 +69,7 @@ curl -X GET https://api.netbird.io/api/groups \ + --- @@ -79,8 +78,7 @@ curl -X GET https://api.netbird.io/api/groups \ - - + Creates a group ### Request-Body Parameters @@ -94,8 +92,7 @@ Group name identifier List of peers ids - -
+
More Information @@ -109,13 +106,13 @@ Network resource type based of the address
+ - - + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/groups \ @@ -185,6 +182,7 @@ curl -X POST https://api.netbird.io/api/groups \ + --- @@ -193,8 +191,7 @@ curl -X POST https://api.netbird.io/api/groups \ - - + Get information about a group ### Path Parameters @@ -208,8 +205,7 @@ The unique identifier of a group - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/groups/{groupId} \ @@ -266,6 +262,7 @@ curl -X GET https://api.netbird.io/api/groups/{groupId} \ + --- @@ -274,8 +271,7 @@ curl -X GET https://api.netbird.io/api/groups/{groupId} \ - - + Update/Replace a group ### Path Parameters @@ -300,8 +296,7 @@ Group name identifier List of peers ids - -
+
More Information @@ -315,13 +310,13 @@ Network resource type based of the address
+ - - + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/groups/{groupId} \ @@ -391,6 +386,7 @@ curl -X PUT https://api.netbird.io/api/groups/{groupId} \ + --- @@ -399,8 +395,7 @@ curl -X PUT https://api.netbird.io/api/groups/{groupId} \ - - + Delete a group ### Path Parameters @@ -414,8 +409,7 @@ The unique identifier of a group - - + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/groups/{groupId} \ @@ -426,4 +420,5 @@ curl -X DELETE https://api.netbird.io/api/groups/{groupId} \ + --- diff --git a/src/pages/ipa/resources/ingress-ports.mdx b/src/pages/ipa/resources/ingress-ports.mdx index d2d6ac4a..bd29333f 100644 --- a/src/pages/ipa/resources/ingress-ports.mdx +++ b/src/pages/ipa/resources/ingress-ports.mdx @@ -5,8 +5,7 @@ export const title = 'Ingress Ports' - - + Returns a list of all ingress port allocations for a peer ### Path Parameters @@ -31,8 +30,7 @@ Filters ingress port allocations by name - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/peers/{peerId}/ingress/ports \ @@ -89,6 +87,7 @@ curl -X GET https://api.netbird.io/api/peers/{peerId}/ingress/ports \ + --- @@ -97,8 +96,7 @@ curl -X GET https://api.netbird.io/api/peers/{peerId}/ingress/ports \ - - + Creates a new ingress port allocation for a peer ### Path Parameters @@ -123,8 +121,7 @@ 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 @@ -141,10 +138,10 @@ The protocol accepted by the port range
+ - -
+
More Information @@ -158,13 +155,13 @@ The protocol accepted by the port
+ - - + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/peers/{peerId}/ingress/ports \ @@ -233,6 +230,7 @@ curl -X POST https://api.netbird.io/api/peers/{peerId}/ingress/ports \ + --- @@ -241,8 +239,7 @@ curl -X POST https://api.netbird.io/api/peers/{peerId}/ingress/ports \ - - + Get information about an ingress port allocation ### Path Parameters @@ -259,8 +256,7 @@ The unique identifier of an ingress port allocation - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId} \ @@ -313,6 +309,7 @@ curl -X GET https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationI + --- @@ -321,8 +318,7 @@ curl -X GET https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationI - - + Update information about an ingress port allocation ### Path Parameters @@ -350,8 +346,7 @@ 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 @@ -368,10 +363,10 @@ The protocol accepted by the port range
+ - -
+
More Information @@ -385,13 +380,13 @@ The protocol accepted by the port
+ - - + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId} \ @@ -460,6 +455,7 @@ curl -X PUT https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationI + --- @@ -468,8 +464,7 @@ curl -X PUT https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationI - - + Delete an ingress port allocation ### Path Parameters @@ -486,8 +481,7 @@ The unique identifier of an ingress port allocation - - + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId} \ @@ -498,6 +492,7 @@ curl -X DELETE https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocati + --- @@ -506,12 +501,10 @@ curl -X DELETE https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocati - - + Returns a list of all ingress peers - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/ingress/peers \ @@ -560,6 +553,7 @@ curl -X GET https://api.netbird.io/api/ingress/peers \ + --- @@ -568,8 +562,7 @@ curl -X GET https://api.netbird.io/api/ingress/peers \ - - + Creates a new ingress peer ### Request-Body Parameters @@ -589,8 +582,7 @@ Defines if an ingress peer can be used as a fallback if no ingress peer can be f - - + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/ingress/peers \ @@ -641,6 +633,7 @@ curl -X POST https://api.netbird.io/api/ingress/peers \ + --- @@ -649,8 +642,7 @@ curl -X POST https://api.netbird.io/api/ingress/peers \ - - + Get information about an ingress peer ### Path Parameters @@ -664,8 +656,7 @@ The unique identifier of an ingress peer - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ @@ -710,6 +701,7 @@ curl -X GET https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ + --- @@ -718,8 +710,7 @@ curl -X GET https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ - - + Update information about an ingress peer ### Path Parameters @@ -747,8 +738,7 @@ Defines if an ingress peer can be used as a fallback if no ingress peer can be f - - + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ @@ -798,6 +788,7 @@ curl -X PUT https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ + --- @@ -806,8 +797,7 @@ curl -X PUT https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ - - + Delete an ingress peer ### Path Parameters @@ -821,8 +811,7 @@ The unique identifier of an ingress peer - - + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ @@ -833,4 +822,5 @@ curl -X DELETE https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ + --- diff --git a/src/pages/ipa/resources/networks.mdx b/src/pages/ipa/resources/networks.mdx index 40947186..231edb02 100644 --- a/src/pages/ipa/resources/networks.mdx +++ b/src/pages/ipa/resources/networks.mdx @@ -5,12 +5,10 @@ export const title = 'Networks' - - + Returns a list of all networks - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/networks \ @@ -63,6 +61,7 @@ curl -X GET https://api.netbird.io/api/networks \ + --- @@ -71,8 +70,7 @@ curl -X GET https://api.netbird.io/api/networks \ - - + Creates a Network ### Request-Body Parameters @@ -89,8 +87,7 @@ Network description - - + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/networks \ @@ -144,6 +141,7 @@ curl -X POST https://api.netbird.io/api/networks \ + --- @@ -152,8 +150,7 @@ curl -X POST https://api.netbird.io/api/networks \ - - + Get information about a Network ### Path Parameters @@ -167,8 +164,7 @@ The unique identifier of a network - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/networks/{networkId} \ @@ -217,6 +213,7 @@ curl -X GET https://api.netbird.io/api/networks/{networkId} \ + --- @@ -225,8 +222,7 @@ curl -X GET https://api.netbird.io/api/networks/{networkId} \ - - + Update/Replace a Network ### Path Parameters @@ -254,8 +250,7 @@ Network description - - + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/networks/{networkId} \ @@ -309,6 +304,7 @@ curl -X PUT https://api.netbird.io/api/networks/{networkId} \ + --- @@ -317,8 +313,7 @@ curl -X PUT https://api.netbird.io/api/networks/{networkId} \ - - + Delete a network ### Path Parameters @@ -332,8 +327,7 @@ The unique identifier of a network - - + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/networks/{networkId} \ @@ -344,6 +338,7 @@ curl -X DELETE https://api.netbird.io/api/networks/{networkId} \ + --- @@ -352,8 +347,7 @@ curl -X DELETE https://api.netbird.io/api/networks/{networkId} \ - - + Returns a list of all resources in a network ### Path Parameters @@ -367,8 +361,7 @@ The unique identifier of a network - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/networks/{networkId}/resources \ @@ -425,6 +418,7 @@ curl -X GET https://api.netbird.io/api/networks/{networkId}/resources \ + --- @@ -433,8 +427,7 @@ curl -X GET https://api.netbird.io/api/networks/{networkId}/resources \ - - + Creates a Network Resource ### Path Parameters @@ -471,8 +464,7 @@ Group IDs containing the resource - - + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/networks/{networkId}/resources \ @@ -535,6 +527,7 @@ curl -X POST https://api.netbird.io/api/networks/{networkId}/resources \ + --- @@ -543,8 +536,7 @@ curl -X POST https://api.netbird.io/api/networks/{networkId}/resources \ - - + Get information about a Network Resource ### Path Parameters @@ -561,8 +553,7 @@ The unique identifier of a network resource - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/networks/{networkId}/resources/{resourceId} \ @@ -615,6 +606,7 @@ curl -X GET https://api.netbird.io/api/networks/{networkId}/resources/{resourceI + --- @@ -623,8 +615,7 @@ curl -X GET https://api.netbird.io/api/networks/{networkId}/resources/{resourceI - - + Update a Network Resource ### Path Parameters @@ -664,8 +655,7 @@ Group IDs containing the resource - - + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/networks/{networkId}/resources/{resourceId} \ @@ -728,6 +718,7 @@ curl -X PUT https://api.netbird.io/api/networks/{networkId}/resources/{resourceI + --- @@ -736,8 +727,7 @@ curl -X PUT https://api.netbird.io/api/networks/{networkId}/resources/{resourceI - - + Delete a network resource ### Path Parameters @@ -754,8 +744,7 @@ Delete a network resource - - + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/networks/{networkId}/resources/{resourceId} \ @@ -766,6 +755,7 @@ curl -X DELETE https://api.netbird.io/api/networks/{networkId}/resources/{resour + --- @@ -774,8 +764,7 @@ curl -X DELETE https://api.netbird.io/api/networks/{networkId}/resources/{resour - - + Returns a list of all routers in a network ### Path Parameters @@ -789,8 +778,7 @@ The unique identifier of a network - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/networks/{networkId}/routers \ @@ -833,6 +821,7 @@ curl -X GET https://api.netbird.io/api/networks/{networkId}/routers \ + --- @@ -841,8 +830,7 @@ curl -X GET https://api.netbird.io/api/networks/{networkId}/routers \ - - + Creates a Network Router ### Path Parameters @@ -879,8 +867,7 @@ Network router status - - + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/networks/{networkId}/routers \ @@ -929,6 +916,7 @@ curl -X POST https://api.netbird.io/api/networks/{networkId}/routers \ + --- @@ -937,8 +925,7 @@ curl -X POST https://api.netbird.io/api/networks/{networkId}/routers \ - - + Get information about a Network Router ### Path Parameters @@ -955,8 +942,7 @@ The unique identifier of a router - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ @@ -995,6 +981,7 @@ curl -X GET https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ + --- @@ -1003,8 +990,7 @@ curl -X GET https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ - - + Update a Network Router ### Path Parameters @@ -1044,8 +1030,7 @@ Network router status - - + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ @@ -1094,6 +1079,7 @@ curl -X PUT https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ + --- @@ -1102,8 +1088,7 @@ curl -X PUT https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ - - + Delete a network router ### Path Parameters @@ -1120,8 +1105,7 @@ Delete a network router - - + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ @@ -1132,6 +1116,7 @@ curl -X DELETE https://api.netbird.io/api/networks/{networkId}/routers/{routerId + --- @@ -1140,12 +1125,10 @@ curl -X DELETE https://api.netbird.io/api/networks/{networkId}/routers/{routerId - - + Returns a list of all routers in a network - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/networks/routers \ @@ -1188,4 +1171,5 @@ curl -X GET https://api.netbird.io/api/networks/routers \ + --- diff --git a/src/pages/ipa/resources/peers.mdx b/src/pages/ipa/resources/peers.mdx index e1c959a8..10aaec55 100644 --- a/src/pages/ipa/resources/peers.mdx +++ b/src/pages/ipa/resources/peers.mdx @@ -5,8 +5,7 @@ export const title = 'Peers' - - + Returns a list of all peers ### Query Parameters @@ -23,8 +22,7 @@ Filter peers by IP address - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/peers \ @@ -127,6 +125,7 @@ curl -X GET https://api.netbird.io/api/peers \ + --- @@ -135,8 +134,7 @@ curl -X GET https://api.netbird.io/api/peers \ - - + Get information about a peer ### Path Parameters @@ -150,8 +148,7 @@ The unique identifier of a peer - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/peers/{peerId} \ @@ -248,6 +245,7 @@ curl -X GET https://api.netbird.io/api/peers/{peerId} \ + --- @@ -256,8 +254,7 @@ curl -X GET https://api.netbird.io/api/peers/{peerId} \ - - + Update information about a peer ### Path Parameters @@ -297,8 +294,7 @@ Peer's IP address - - + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/peers/{peerId} \ @@ -404,6 +400,7 @@ curl -X PUT https://api.netbird.io/api/peers/{peerId} \ + --- @@ -412,8 +409,7 @@ curl -X PUT https://api.netbird.io/api/peers/{peerId} \ - - + Delete a peer ### Path Parameters @@ -427,8 +423,7 @@ The unique identifier of a peer - - + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/peers/{peerId} \ @@ -439,6 +434,7 @@ curl -X DELETE https://api.netbird.io/api/peers/{peerId} \ + --- @@ -447,8 +443,7 @@ curl -X DELETE https://api.netbird.io/api/peers/{peerId} \ - - + Returns a list of peers that the specified peer can connect to within the network. ### Path Parameters @@ -462,8 +457,7 @@ The unique identifier of a peer - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/peers/{peerId}/accessible-peers \ @@ -512,4 +506,5 @@ curl -X GET https://api.netbird.io/api/peers/{peerId}/accessible-peers \ + --- diff --git a/src/pages/ipa/resources/policies.mdx b/src/pages/ipa/resources/policies.mdx index 254410fb..4515674f 100644 --- a/src/pages/ipa/resources/policies.mdx +++ b/src/pages/ipa/resources/policies.mdx @@ -5,12 +5,10 @@ export const title = 'Policies' - - + Returns a list of all policies - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/policies \ @@ -143,6 +141,7 @@ curl -X GET https://api.netbird.io/api/policies \ + --- @@ -151,8 +150,7 @@ curl -X GET https://api.netbird.io/api/policies \ - - + Creates a policy ### Request-Body Parameters @@ -172,8 +170,7 @@ Policy status Posture checks ID's applied to policy source groups - -
+
Policy rule object for policy UI editor @@ -199,8 +196,7 @@ Policy rule type of the traffic Policy rule affected ports - -
+
Policy rule affected ports ranges list @@ -214,6 +210,7 @@ The ending port of the range
+ Policy rule ID @@ -222,8 +219,7 @@ Policy rule ID Policy rule source group IDs - -
+
More Information @@ -237,13 +233,13 @@ Network resource type based of the address
+ Policy rule destination group IDs - -
+
More Information @@ -257,18 +253,19 @@ Network resource type based of the address
+
+
- - + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/policies \ @@ -440,6 +437,7 @@ curl -X POST https://api.netbird.io/api/policies \ + --- @@ -448,8 +446,7 @@ curl -X POST https://api.netbird.io/api/policies \ - - + Get information about a Policies ### Path Parameters @@ -463,8 +460,7 @@ The unique identifier of a policy - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/policies/{policyId} \ @@ -593,6 +589,7 @@ curl -X GET https://api.netbird.io/api/policies/{policyId} \ + --- @@ -601,8 +598,7 @@ curl -X GET https://api.netbird.io/api/policies/{policyId} \ - - + Update/Replace a Policy ### Path Parameters @@ -633,8 +629,7 @@ Policy status Posture checks ID's applied to policy source groups - -
+
Policy rule object for policy UI editor @@ -660,8 +655,7 @@ Policy rule type of the traffic Policy rule affected ports - -
+
Policy rule affected ports ranges list @@ -675,6 +669,7 @@ The ending port of the range
+ Policy rule ID @@ -683,8 +678,7 @@ Policy rule ID Policy rule source group IDs - -
+
More Information @@ -698,13 +692,13 @@ Network resource type based of the address
+ Policy rule destination group IDs - -
+
More Information @@ -718,18 +712,19 @@ Network resource type based of the address
+
+
- - + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/policies/{policyId} \ @@ -901,6 +896,7 @@ curl -X PUT https://api.netbird.io/api/policies/{policyId} \ + --- @@ -909,8 +905,7 @@ curl -X PUT https://api.netbird.io/api/policies/{policyId} \ - - + Delete a policy ### Path Parameters @@ -924,8 +919,7 @@ The unique identifier of a policy - - + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/policies/{policyId} \ @@ -936,4 +930,5 @@ curl -X DELETE https://api.netbird.io/api/policies/{policyId} \ + --- diff --git a/src/pages/ipa/resources/posture-checks.mdx b/src/pages/ipa/resources/posture-checks.mdx index 191bda8a..ffbdd696 100644 --- a/src/pages/ipa/resources/posture-checks.mdx +++ b/src/pages/ipa/resources/posture-checks.mdx @@ -5,12 +5,10 @@ export const title = 'Posture Checks' - - + Returns a list of all posture checks - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/posture-checks \ @@ -137,6 +135,7 @@ curl -X GET https://api.netbird.io/api/posture-checks \ + --- @@ -145,8 +144,7 @@ curl -X GET https://api.netbird.io/api/posture-checks \ - - + Creates a posture check ### Request-Body Parameters @@ -160,14 +158,12 @@ Posture check name identifier Posture check friendly description - -
+
List of objects that perform the actual checks - -
+
Posture check for the version of operating system @@ -178,16 +174,15 @@ Minimum acceptable version
+ - -
+
Posture check for the version of operating system - -
+
Posture check for the version of operating system @@ -198,10 +193,10 @@ Minimum acceptable version
+ - -
+
Posture check for the version of operating system @@ -212,10 +207,10 @@ Minimum acceptable version
+ - -
+
Posture check for the version of operating system @@ -226,10 +221,10 @@ Minimum acceptable version
+ - -
+
Posture check with the kernel version @@ -240,10 +235,10 @@ Minimum acceptable version
+ - -
+
Posture check with the kernel version @@ -254,21 +249,21 @@ Minimum acceptable version
+
+
- -
+
Posture check for geo location - -
+
List of geo locations to which the policy applies @@ -282,6 +277,7 @@ Commonly used English name of the city
+ Action to take upon policy match @@ -290,10 +286,10 @@ Action to take upon policy match
+
- -
+
Posture check for allow or deny access based on peer local network addresses @@ -307,16 +303,15 @@ Action to take upon policy match
+ - -
+
Posture Check for binaries exist and are running in the peer’s system - -
+
More Information @@ -333,23 +328,25 @@ Path to the process executable file in a Windows operating system
+
+
+ - - + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/posture-checks \ @@ -525,6 +522,7 @@ curl -X POST https://api.netbird.io/api/posture-checks \ + --- @@ -533,8 +531,7 @@ curl -X POST https://api.netbird.io/api/posture-checks \ - - + Get information about a posture check ### Path Parameters @@ -548,8 +545,7 @@ The unique identifier of a posture check - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/posture-checks/{postureCheckId} \ @@ -672,6 +668,7 @@ curl -X GET https://api.netbird.io/api/posture-checks/{postureCheckId} \ + --- @@ -680,8 +677,7 @@ curl -X GET https://api.netbird.io/api/posture-checks/{postureCheckId} \ - - + Update/Replace a posture check ### Path Parameters @@ -706,14 +702,12 @@ Posture check name identifier Posture check friendly description - -
+
List of objects that perform the actual checks - -
+
Posture check for the version of operating system @@ -724,16 +718,15 @@ Minimum acceptable version
+ - -
+
Posture check for the version of operating system - -
+
Posture check for the version of operating system @@ -744,10 +737,10 @@ Minimum acceptable version
+ - -
+
Posture check for the version of operating system @@ -758,10 +751,10 @@ Minimum acceptable version
+ - -
+
Posture check for the version of operating system @@ -772,10 +765,10 @@ Minimum acceptable version
+ - -
+
Posture check with the kernel version @@ -786,10 +779,10 @@ Minimum acceptable version
+ - -
+
Posture check with the kernel version @@ -800,21 +793,21 @@ Minimum acceptable version
+
+
- -
+
Posture check for geo location - -
+
List of geo locations to which the policy applies @@ -828,6 +821,7 @@ Commonly used English name of the city
+ Action to take upon policy match @@ -836,10 +830,10 @@ Action to take upon policy match
+
- -
+
Posture check for allow or deny access based on peer local network addresses @@ -853,16 +847,15 @@ Action to take upon policy match
+ - -
+
Posture Check for binaries exist and are running in the peer’s system - -
+
More Information @@ -879,23 +872,25 @@ 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} \ @@ -1071,6 +1066,7 @@ curl -X PUT https://api.netbird.io/api/posture-checks/{postureCheckId} \ + --- @@ -1079,8 +1075,7 @@ curl -X PUT https://api.netbird.io/api/posture-checks/{postureCheckId} \ - - + Delete a posture check ### Path Parameters @@ -1094,8 +1089,7 @@ The unique identifier of a posture check - - + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/posture-checks/{postureCheckId} \ @@ -1106,4 +1100,5 @@ curl -X DELETE https://api.netbird.io/api/posture-checks/{postureCheckId} \ + --- diff --git a/src/pages/ipa/resources/routes.mdx b/src/pages/ipa/resources/routes.mdx index c39b7136..a760e696 100644 --- a/src/pages/ipa/resources/routes.mdx +++ b/src/pages/ipa/resources/routes.mdx @@ -5,12 +5,10 @@ export const title = 'Routes' - - + Returns a list of all routes - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/routes \ @@ -83,6 +81,7 @@ curl -X GET https://api.netbird.io/api/routes \ + --- @@ -91,8 +90,7 @@ curl -X GET https://api.netbird.io/api/routes \ - - + Creates a Route ### Request-Body Parameters @@ -142,8 +140,7 @@ Indicate if this exit node route (0.0.0.0/0) should skip auto-application for cl - - + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/routes \ @@ -236,6 +233,7 @@ curl -X POST https://api.netbird.io/api/routes \ + --- @@ -244,8 +242,7 @@ curl -X POST https://api.netbird.io/api/routes \ - - + Get information about a Routes ### Path Parameters @@ -259,8 +256,7 @@ The unique identifier of a route - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/routes/{routeId} \ @@ -329,6 +325,7 @@ curl -X GET https://api.netbird.io/api/routes/{routeId} \ + --- @@ -337,8 +334,7 @@ curl -X GET https://api.netbird.io/api/routes/{routeId} \ - - + Update/Replace a Route ### Path Parameters @@ -399,8 +395,7 @@ Indicate if this exit node route (0.0.0.0/0) should skip auto-application for cl - - + ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/routes/{routeId} \ @@ -493,6 +488,7 @@ curl -X PUT https://api.netbird.io/api/routes/{routeId} \ + --- @@ -501,8 +497,7 @@ curl -X PUT https://api.netbird.io/api/routes/{routeId} \ - - + Delete a route ### Path Parameters @@ -516,8 +511,7 @@ The unique identifier of a route - - + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/routes/{routeId} \ @@ -528,4 +522,5 @@ curl -X DELETE https://api.netbird.io/api/routes/{routeId} \ + --- diff --git a/src/pages/ipa/resources/setup-keys.mdx b/src/pages/ipa/resources/setup-keys.mdx index 980047c6..30afba01 100644 --- a/src/pages/ipa/resources/setup-keys.mdx +++ b/src/pages/ipa/resources/setup-keys.mdx @@ -5,12 +5,10 @@ export const title = 'Setup Keys' - - + Returns a list of all Setup Keys - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/setup-keys \ @@ -71,6 +69,7 @@ curl -X GET https://api.netbird.io/api/setup-keys \ + --- @@ -79,8 +78,7 @@ curl -X GET https://api.netbird.io/api/setup-keys \ - - + Creates a setup key ### Request-Body Parameters @@ -112,8 +110,7 @@ Allow extra DNS labels to be added to the peer - - + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/setup-keys \ @@ -182,6 +179,7 @@ curl -X POST https://api.netbird.io/api/setup-keys \ + --- @@ -190,8 +188,7 @@ curl -X POST https://api.netbird.io/api/setup-keys \ - - + Get information about a setup key ### Path Parameters @@ -205,8 +202,7 @@ The unique identifier of a setup key - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/setup-keys/{keyId} \ @@ -263,6 +259,7 @@ curl -X GET https://api.netbird.io/api/setup-keys/{keyId} \ + --- @@ -271,8 +268,7 @@ curl -X GET https://api.netbird.io/api/setup-keys/{keyId} \ - - + Update information about a setup key ### Path Parameters @@ -300,8 +296,7 @@ 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} \ @@ -365,6 +360,7 @@ curl -X PUT https://api.netbird.io/api/setup-keys/{keyId} \ + --- @@ -373,8 +369,7 @@ curl -X PUT https://api.netbird.io/api/setup-keys/{keyId} \ - - + Delete a Setup Key ### Path Parameters @@ -388,8 +383,7 @@ The unique identifier of a setup key - - + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/setup-keys/{keyId} \ @@ -400,4 +394,5 @@ curl -X DELETE https://api.netbird.io/api/setup-keys/{keyId} \ + --- diff --git a/src/pages/ipa/resources/tokens.mdx b/src/pages/ipa/resources/tokens.mdx index 00221860..aa39809b 100644 --- a/src/pages/ipa/resources/tokens.mdx +++ b/src/pages/ipa/resources/tokens.mdx @@ -5,8 +5,7 @@ export const title = 'Tokens' - - + Returns a list of all tokens for a user ### Path Parameters @@ -20,8 +19,7 @@ The unique identifier of a user - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/users/{userId}/tokens \ @@ -60,6 +58,7 @@ curl -X GET https://api.netbird.io/api/users/{userId}/tokens \ + --- @@ -68,8 +67,7 @@ curl -X GET https://api.netbird.io/api/users/{userId}/tokens \ - - + Create a new token for a user ### Path Parameters @@ -97,8 +95,7 @@ Expiration in days - - + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/users/{userId}/tokens \ @@ -144,6 +141,7 @@ curl -X POST https://api.netbird.io/api/users/{userId}/tokens \ + --- @@ -152,8 +150,7 @@ curl -X POST https://api.netbird.io/api/users/{userId}/tokens \ - - + Returns a specific token for a user ### Path Parameters @@ -170,8 +167,7 @@ The unique identifier of a token - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/users/{userId}/tokens/{tokenId} \ @@ -206,6 +202,7 @@ curl -X GET https://api.netbird.io/api/users/{userId}/tokens/{tokenId} \ + --- @@ -214,8 +211,7 @@ curl -X GET https://api.netbird.io/api/users/{userId}/tokens/{tokenId} \ - - + Delete a token for a user ### Path Parameters @@ -232,8 +228,7 @@ The unique identifier of a token - - + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/users/{userId}/tokens/{tokenId} \ @@ -244,4 +239,5 @@ curl -X DELETE https://api.netbird.io/api/users/{userId}/tokens/{tokenId} \ + --- diff --git a/src/pages/ipa/resources/users.mdx b/src/pages/ipa/resources/users.mdx index 2fea1897..db9e6406 100644 --- a/src/pages/ipa/resources/users.mdx +++ b/src/pages/ipa/resources/users.mdx @@ -5,8 +5,7 @@ export const title = 'Users' - - + Returns a list of all users ### Query Parameters @@ -20,8 +19,7 @@ Filters users and returns either regular users or service users - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/users \ @@ -117,6 +115,7 @@ curl -X GET https://api.netbird.io/api/users \ + --- @@ -125,8 +124,7 @@ curl -X GET https://api.netbird.io/api/users \ - - + Creates a new service user or sends an invite to a regular user ### Request-Body Parameters @@ -152,8 +150,7 @@ Is true if this user is a service user - - + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/users \ @@ -255,6 +252,7 @@ curl -X POST https://api.netbird.io/api/users \ + --- @@ -263,8 +261,7 @@ curl -X POST https://api.netbird.io/api/users \ - - + Update information about a User ### Path Parameters @@ -295,8 +292,7 @@ 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} \ @@ -396,6 +392,7 @@ curl -X PUT https://api.netbird.io/api/users/{userId} \ + --- @@ -404,8 +401,7 @@ curl -X PUT https://api.netbird.io/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 @@ -419,8 +415,7 @@ The unique identifier of a user - - + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/users/{userId} \ @@ -431,6 +426,7 @@ curl -X DELETE https://api.netbird.io/api/users/{userId} \ + --- @@ -439,8 +435,7 @@ curl -X DELETE https://api.netbird.io/api/users/{userId} \ - - + Resend user invitation ### Path Parameters @@ -454,8 +449,7 @@ The unique identifier of a user - - + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/users/{userId}/invite \ @@ -466,6 +460,7 @@ curl -X POST https://api.netbird.io/api/users/{userId}/invite \ + --- @@ -474,8 +469,7 @@ curl -X POST https://api.netbird.io/api/users/{userId}/invite \ - - + Approve a user that is pending approval ### Path Parameters @@ -489,8 +483,7 @@ The unique identifier of a user - - + ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/users/{userId}/approve \ @@ -581,6 +574,7 @@ curl -X POST https://api.netbird.io/api/users/{userId}/approve \ + --- @@ -589,8 +583,7 @@ curl -X POST https://api.netbird.io/api/users/{userId}/approve \ - - + Reject a user that is pending approval by removing them from the account ### Path Parameters @@ -604,8 +597,7 @@ The unique identifier of a user - - + ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/users/{userId}/reject \ @@ -616,6 +608,7 @@ curl -X DELETE https://api.netbird.io/api/users/{userId}/reject \ + --- @@ -624,12 +617,10 @@ curl -X DELETE https://api.netbird.io/api/users/{userId}/reject \ - - + Get information about the current user - - + ```bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io/api/users/current \ @@ -721,4 +712,5 @@ curl -X GET https://api.netbird.io/api/users/current \ + --- From 4b97f656e73bc3dc5fb6c364013774fb5f459f77 Mon Sep 17 00:00:00 2001 From: aliamerj Date: Tue, 23 Sep 2025 22:14:33 +0300 Subject: [PATCH 4/5] extend request code example --- openapi-gen/tsxParser/api/requests.ts | 627 ++++- src/pages/ipa/resources/accounts.mdx | 597 ++++- src/pages/ipa/resources/dns.mdx | 1233 +++++++++- src/pages/ipa/resources/events.mdx | 270 +++ src/pages/ipa/resources/geo-locations.mdx | 270 +++ src/pages/ipa/resources/groups.mdx | 828 ++++++- src/pages/ipa/resources/ingress-ports.mdx | 1602 ++++++++++++- src/pages/ipa/resources/networks.mdx | 2531 +++++++++++++++++++- src/pages/ipa/resources/peers.mdx | 723 +++++- src/pages/ipa/resources/policies.mdx | 1612 +++++++++++-- src/pages/ipa/resources/posture-checks.mdx | 1604 +++++++++++-- src/pages/ipa/resources/routes.mdx | 960 +++++++- src/pages/ipa/resources/setup-keys.mdx | 786 +++++- src/pages/ipa/resources/tokens.mdx | 564 ++++- src/pages/ipa/resources/users.mdx | 1208 +++++++++- 15 files changed, 14945 insertions(+), 470 deletions(-) diff --git a/openapi-gen/tsxParser/api/requests.ts b/openapi-gen/tsxParser/api/requests.ts index a5bcfe42..6fbbcca0 100644 --- a/openapi-gen/tsxParser/api/requests.ts +++ b/openapi-gen/tsxParser/api/requests.ts @@ -36,64 +36,639 @@ export const getRequestBody = (endPoint: Endpoint) => { return JSON.stringify(body, null, 2); }; -const deleteRequestCode = (url: string) => { - const langCode = [] - langCode.push(`\`\`\`bash {{ title: 'cURL' }} + +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 ' \\ +-H 'Authorization: Token ' \`\`\``) - return langCode + // ---------------- 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 } -const putRequestCode = (url: string, body: string | null) => { - const langCode = [] - const lines: string[] = [ +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() { - if (body && body !== "{}") { - lines.push(`-H 'Accept: application/json' \\`) - lines.push(`-H 'Content-Type: application/json' \\`) - lines.push(`--data-raw '${body}'`) + 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() - langCode.push(`\`\`\`bash {{ title: 'cURL' }}\n${lines.join("\n")}\n\`\`\``) - return langCode + 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}") -const postRequestCode = (url: string, body: string | null) => { - const langCode = [] - const lines: string[] = [ +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\`\`\``) - if (body && body !== "{}") { - lines.push(`-H 'Accept: application/json' \\`) - lines.push(`-H 'Content-Type: application/json' \\`) - lines.push(`--data-raw '${body}'`) - } + // ---------------- 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); +}); +\`\`\``) - langCode.push(`\`\`\`bash {{ title: 'cURL' }}\n${lines.join("\n")}\n\`\`\``) + // ---------------- Python ---------------- + langCode.push(`\`\`\`python {{ title: 'Python' }} +import requests +import json - return langCode +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.replace(/"/g, '\\"')}"); +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 = [] + const langCode: string[] = [] + + // ---------------- cURL ---------------- langCode.push(`\`\`\`bash {{ title: 'cURL' }} curl -X GET https://api.netbird.io${label} \\ -H 'Accept: application/json' \\ -H 'Authorization: Token ' \`\`\``) - return langCode + // ---------------- 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/src/pages/ipa/resources/accounts.mdx b/src/pages/ipa/resources/accounts.mdx index 1f7bb469..a40a8716 100644 --- a/src/pages/ipa/resources/accounts.mdx +++ b/src/pages/ipa/resources/accounts.mdx @@ -15,6 +15,141 @@ curl -X GET https://api.netbird.io/api/accounts \ -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/accounts', + 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/accounts" + +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/accounts" + method := "GET" + + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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/accounts") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Get.new(url) +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +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/accounts") + .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/accounts', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'GET', + CURLOPT_HTTPHEADER => array( + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -233,9 +368,9 @@ Indicates whether the account onboarding flow is pending ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/accounts/{accountId} \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "settings": { "peer_login_expiration_enabled": true, @@ -269,6 +404,340 @@ curl -X PUT https://api.netbird.io/api/accounts/{accountId} \ } }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "settings": { + "peer_login_expiration_enabled": true, + "peer_login_expiration": 43200, + "peer_inactivity_expiration_enabled": true, + "peer_inactivity_expiration": 43200, + "regular_users_view_blocked": true, + "groups_propagation_enabled": true, + "jwt_groups_enabled": true, + "jwt_groups_claim_name": "roles", + "jwt_allow_groups": [ + "Administrators" + ], + "routing_peer_dns_resolution_enabled": true, + "dns_domain": "my-organization.org", + "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" + ], + "network_traffic_packet_counter_enabled": true + }, + "lazy_connection_enabled": true + }, + "onboarding": { + "signup_form_pending": true, + "onboarding_flow_pending": false + } +}); +let config = { + method: 'put', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/accounts/{accountId}', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/accounts/{accountId}" +payload = json.dumps({ + "settings": { + "peer_login_expiration_enabled": true, + "peer_login_expiration": 43200, + "peer_inactivity_expiration_enabled": true, + "peer_inactivity_expiration": 43200, + "regular_users_view_blocked": true, + "groups_propagation_enabled": true, + "jwt_groups_enabled": true, + "jwt_groups_claim_name": "roles", + "jwt_allow_groups": [ + "Administrators" + ], + "routing_peer_dns_resolution_enabled": true, + "dns_domain": "my-organization.org", + "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" + ], + "network_traffic_packet_counter_enabled": true + }, + "lazy_connection_enabled": true + }, + "onboarding": { + "signup_form_pending": true, + "onboarding_flow_pending": false + } +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("PUT", url, headers=headers, data=payload) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/accounts/{accountId}" + method := "PUT" + + payload := strings.NewReader({ + "settings": { + "peer_login_expiration_enabled": true, + "peer_login_expiration": 43200, + "peer_inactivity_expiration_enabled": true, + "peer_inactivity_expiration": 43200, + "regular_users_view_blocked": true, + "groups_propagation_enabled": true, + "jwt_groups_enabled": true, + "jwt_groups_claim_name": "roles", + "jwt_allow_groups": [ + "Administrators" + ], + "routing_peer_dns_resolution_enabled": true, + "dns_domain": "my-organization.org", + "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" + ], + "network_traffic_packet_counter_enabled": true + }, + "lazy_connection_enabled": true + }, + "onboarding": { + "signup_form_pending": true, + "onboarding_flow_pending": false + } +}) + client := &http.Client{} + req, err := http.NewRequest(method, url, payload) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Content-Type", "application/json") + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/accounts/{accountId}") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Put.new(url) +request["Content-Type"] = "application/json" +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +request.body = JSON.dump({ + "settings": { + "peer_login_expiration_enabled": true, + "peer_login_expiration": 43200, + "peer_inactivity_expiration_enabled": true, + "peer_inactivity_expiration": 43200, + "regular_users_view_blocked": true, + "groups_propagation_enabled": true, + "jwt_groups_enabled": true, + "jwt_groups_claim_name": "roles", + "jwt_allow_groups": [ + "Administrators" + ], + "routing_peer_dns_resolution_enabled": true, + "dns_domain": "my-organization.org", + "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" + ], + "network_traffic_packet_counter_enabled": true + }, + "lazy_connection_enabled": true + }, + "onboarding": { + "signup_form_pending": true, + "onboarding_flow_pending": false + } +}) +response = https.request(request) +puts response.read_body +``` + +```java {{ title: 'Java' }} +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); +MediaType mediaType = MediaType.parse("application/json"); +RequestBody body = RequestBody.create(mediaType, '{ + "settings": { + "peer_login_expiration_enabled": true, + "peer_login_expiration": 43200, + "peer_inactivity_expiration_enabled": true, + "peer_inactivity_expiration": 43200, + "regular_users_view_blocked": true, + "groups_propagation_enabled": true, + "jwt_groups_enabled": true, + "jwt_groups_claim_name": "roles", + "jwt_allow_groups": [ + "Administrators" + ], + "routing_peer_dns_resolution_enabled": true, + "dns_domain": "my-organization.org", + "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" + ], + "network_traffic_packet_counter_enabled": true + }, + "lazy_connection_enabled": true + }, + "onboarding": { + "signup_form_pending": true, + "onboarding_flow_pending": false + } +}'); +Request request = new Request.Builder() + .url("https://api.netbird.io/api/accounts/{accountId}") + .method("PUT", body) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: '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 => 'PUT', + CURLOPT_POSTFIELDS => '{ + "settings": { + "peer_login_expiration_enabled": true, + "peer_login_expiration": 43200, + "peer_inactivity_expiration_enabled": true, + "peer_inactivity_expiration": 43200, + "regular_users_view_blocked": true, + "groups_propagation_enabled": true, + "jwt_groups_enabled": true, + "jwt_groups_claim_name": "roles", + "jwt_allow_groups": [ + "Administrators" + ], + "routing_peer_dns_resolution_enabled": true, + "dns_domain": "my-organization.org", + "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" + ], + "network_traffic_packet_counter_enabled": true + }, + "lazy_connection_enabled": true + }, + "onboarding": { + "signup_form_pending": true, + "onboarding_flow_pending": false + } +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -382,7 +851,131 @@ The unique identifier of an account ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/accounts/{accountId} \ --H 'Authorization: Token ' \ +-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 0f74d541..10dadf8e 100644 --- a/src/pages/ipa/resources/dns.mdx +++ b/src/pages/ipa/resources/dns.mdx @@ -15,6 +15,141 @@ curl -X GET https://api.netbird.io/api/dns/nameservers \ -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/dns/nameservers', + 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/dns/nameservers" + +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/dns/nameservers" + 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/dns/nameservers") + +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/dns/nameservers") + .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/dns/nameservers', + 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' }} @@ -138,9 +273,9 @@ Search domain status for match domains. It should be true only if domains list i ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/dns/nameservers \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "name": "Google DNS", "description": "Google DNS servers", @@ -162,6 +297,268 @@ curl -X POST https://api.netbird.io/api/dns/nameservers \ "search_domains_enabled": true }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "name": "Google DNS", + "description": "Google DNS servers", + "nameservers": [ + { + "ip": "8.8.8.8", + "ns_type": "udp", + "port": 53 + } + ], + "enabled": true, + "groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "primary": true, + "domains": [ + "example.com" + ], + "search_domains_enabled": true +}); +let config = { + method: 'post', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/dns/nameservers', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/dns/nameservers" +payload = json.dumps({ + "name": "Google DNS", + "description": "Google DNS servers", + "nameservers": [ + { + "ip": "8.8.8.8", + "ns_type": "udp", + "port": 53 + } + ], + "enabled": true, + "groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "primary": true, + "domains": [ + "example.com" + ], + "search_domains_enabled": true +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("POST", url, headers=headers, data=payload) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/dns/nameservers" + method := "POST" + + payload := strings.NewReader(`{ + "name": "Google DNS", + "description": "Google DNS servers", + "nameservers": [ + { + "ip": "8.8.8.8", + "ns_type": "udp", + "port": 53 + } + ], + "enabled": true, + "groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "primary": true, + "domains": [ + "example.com" + ], + "search_domains_enabled": true +}`) + client := &http.Client{} + req, err := http.NewRequest(method, url, payload) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Content-Type", "application/json") + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/dns/nameservers") + +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({ + "name": "Google DNS", + "description": "Google DNS servers", + "nameservers": [ + { + "ip": "8.8.8.8", + "ns_type": "udp", + "port": 53 + } + ], + "enabled": true, + "groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "primary": true, + "domains": [ + "example.com" + ], + "search_domains_enabled": true +}) +response = https.request(request) +puts response.read_body +``` + +```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\": [ + { + \"ip\": \"8.8.8.8\", + \"ns_type\": \"udp\", + \"port\": 53 + } + ], + \"enabled\": true, + \"groups\": [ + \"ch8i4ug6lnn4g9hqv7m0\" + ], + \"primary\": true, + \"domains\": [ + \"example.com\" + ], + \"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 ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/dns/nameservers', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS => '{ + "name": "Google DNS", + "description": "Google DNS servers", + "nameservers": [ + { + "ip": "8.8.8.8", + "ns_type": "udp", + "port": 53 + } + ], + "enabled": true, + "groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "primary": true, + "domains": [ + "example.com" + ], + "search_domains_enabled": true +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -246,6 +643,141 @@ curl -X GET https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ -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/dns/nameservers/{nsgroupId}', + 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/dns/nameservers/{nsgroupId}" + +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/dns/nameservers/{nsgroupId}" + 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/dns/nameservers/{nsgroupId}") + +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/dns/nameservers/{nsgroupId}") + .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/dns/nameservers/{nsgroupId}', + 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' }} @@ -376,9 +908,9 @@ Search domain status for match domains. It should be true only if domains list i ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "name": "Google DNS", "description": "Google DNS servers", @@ -400,6 +932,268 @@ curl -X PUT https://api.netbird.io/api/dns/nameservers/{nsgroupId} \ "search_domains_enabled": true }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "name": "Google DNS", + "description": "Google DNS servers", + "nameservers": [ + { + "ip": "8.8.8.8", + "ns_type": "udp", + "port": 53 + } + ], + "enabled": true, + "groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "primary": true, + "domains": [ + "example.com" + ], + "search_domains_enabled": true +}); +let config = { + method: 'put', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/dns/nameservers/{nsgroupId}', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/dns/nameservers/{nsgroupId}" +payload = json.dumps({ + "name": "Google DNS", + "description": "Google DNS servers", + "nameservers": [ + { + "ip": "8.8.8.8", + "ns_type": "udp", + "port": 53 + } + ], + "enabled": true, + "groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "primary": true, + "domains": [ + "example.com" + ], + "search_domains_enabled": true +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("PUT", url, headers=headers, data=payload) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/dns/nameservers/{nsgroupId}" + method := "PUT" + + payload := strings.NewReader({ + "name": "Google DNS", + "description": "Google DNS servers", + "nameservers": [ + { + "ip": "8.8.8.8", + "ns_type": "udp", + "port": 53 + } + ], + "enabled": true, + "groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "primary": true, + "domains": [ + "example.com" + ], + "search_domains_enabled": true +}) + client := &http.Client{} + req, err := http.NewRequest(method, url, payload) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Content-Type", "application/json") + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/dns/nameservers/{nsgroupId}") + +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({ + "name": "Google DNS", + "description": "Google DNS servers", + "nameservers": [ + { + "ip": "8.8.8.8", + "ns_type": "udp", + "port": 53 + } + ], + "enabled": true, + "groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "primary": true, + "domains": [ + "example.com" + ], + "search_domains_enabled": true +}) +response = https.request(request) +puts response.read_body +``` + +```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": [ + { + "ip": "8.8.8.8", + "ns_type": "udp", + "port": 53 + } + ], + "enabled": true, + "groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "primary": true, + "domains": [ + "example.com" + ], + "search_domains_enabled": true +}'); +Request request = new Request.Builder() + .url("https://api.netbird.io/api/dns/nameservers/{nsgroupId}") + .method("PUT", body) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/dns/nameservers/{nsgroupId}', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'PUT', + CURLOPT_POSTFIELDS => '{ + "name": "Google DNS", + "description": "Google DNS servers", + "nameservers": [ + { + "ip": "8.8.8.8", + "ns_type": "udp", + "port": 53 + } + ], + "enabled": true, + "groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "primary": true, + "domains": [ + "example.com" + ], + "search_domains_enabled": true +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -481,7 +1275,131 @@ 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 +const axios = require('axios'); + +let config = { + method: 'delete', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/dns/nameservers/{nsgroupId}', + 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/dns/nameservers/{nsgroupId}" + +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/dns/nameservers/{nsgroupId}" + 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/dns/nameservers/{nsgroupId}") + +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/dns/nameservers/{nsgroupId}") + .method("DELETE", null) + .addHeader("Authorization", "Token ") + .build(); + +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/dns/nameservers/{nsgroupId}', + 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; ``` @@ -507,6 +1425,141 @@ curl -X GET https://api.netbird.io/api/dns/settings \ -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/dns/settings', + 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/dns/settings" + +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/dns/settings" + 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/dns/settings") + +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/dns/settings") + .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/dns/settings', + 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' }} @@ -560,15 +1613,187 @@ Groups whose DNS management is disabled ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/dns/settings \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "disabled_management_groups": [ "ch8i4ug6lnn4g9hqv7m0" ] }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "disabled_management_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ] +}); +let config = { + method: 'put', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/dns/settings', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/dns/settings" +payload = json.dumps({ + "disabled_management_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ] +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("PUT", url, headers=headers, data=payload) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/dns/settings" + method := "PUT" + + payload := strings.NewReader({ + "disabled_management_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ] +}) + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/dns/settings") + +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({ + "disabled_management_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ] +}) +response = https.request(request) +puts response.read_body +``` + +```java {{ title: 'Java' }} +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); +MediaType mediaType = MediaType.parse("application/json"); +RequestBody body = RequestBody.create(mediaType, '{ + "disabled_management_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ] +}'); +Request request = new Request.Builder() + .url("https://api.netbird.io/api/dns/settings") + .method("PUT", body) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/dns/settings', + 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 => '{ + "disabled_management_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ] +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} diff --git a/src/pages/ipa/resources/events.mdx b/src/pages/ipa/resources/events.mdx index c7acd213..c5004afc 100644 --- a/src/pages/ipa/resources/events.mdx +++ b/src/pages/ipa/resources/events.mdx @@ -15,6 +15,141 @@ curl -X GET https://api.netbird.io/api/events/audit \ -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/events/audit', + 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/events/audit" + +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/events/audit" + method := "GET" + + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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/events/audit") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Get.new(url) +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +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/events/audit") + .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/events/audit', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'GET', + CURLOPT_HTTPHEADER => array( + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -125,6 +260,141 @@ curl -X GET https://api.netbird.io/api/events/network-traffic \ -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/events/network-traffic', + 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/events/network-traffic" + +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/events/network-traffic" + method := "GET" + + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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/events/network-traffic") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Get.new(url) +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +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/events/network-traffic") + .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/events/network-traffic', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'GET', + CURLOPT_HTTPHEADER => array( + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} diff --git a/src/pages/ipa/resources/geo-locations.mdx b/src/pages/ipa/resources/geo-locations.mdx index f4e02242..c2151c0c 100644 --- a/src/pages/ipa/resources/geo-locations.mdx +++ b/src/pages/ipa/resources/geo-locations.mdx @@ -15,6 +15,141 @@ curl -X GET https://api.netbird.io/api/locations/countries \ -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/locations/countries', + 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/locations/countries" + +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/locations/countries" + method := "GET" + + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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/locations/countries") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Get.new(url) +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +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/locations/countries") + .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/locations/countries', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'GET', + CURLOPT_HTTPHEADER => array( + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -63,6 +198,141 @@ curl -X GET https://api.netbird.io/api/locations/countries/{country}/cities \ -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/locations/countries/{country}/cities', + 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/locations/countries/{country}/cities" + +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/locations/countries/{country}/cities" + method := "GET" + + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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/locations/countries/{country}/cities") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Get.new(url) +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +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/locations/countries/{country}/cities") + .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/locations/countries/{country}/cities', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'GET', + CURLOPT_HTTPHEADER => array( + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} diff --git a/src/pages/ipa/resources/groups.mdx b/src/pages/ipa/resources/groups.mdx index 27445a3a..8c79652a 100644 --- a/src/pages/ipa/resources/groups.mdx +++ b/src/pages/ipa/resources/groups.mdx @@ -15,6 +15,141 @@ curl -X GET https://api.netbird.io/api/groups \ -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/groups', + 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/groups" + +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/groups" + 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/groups") + +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/groups") + .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/groups', + 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' }} @@ -116,9 +251,9 @@ Network resource type based of the address ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/groups \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "name": "devs", "peers": [ @@ -132,6 +267,220 @@ curl -X POST https://api.netbird.io/api/groups \ ] }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "name": "devs", + "peers": [ + "ch8i4ug6lnn4g9hqv7m1" + ], + "resources": [ + { + "id": "chacdk86lnnboviihd7g", + "type": "host" + } + ] +}); +let config = { + method: 'post', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/groups', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/groups" +payload = json.dumps({ + "name": "devs", + "peers": [ + "ch8i4ug6lnn4g9hqv7m1" + ], + "resources": [ + { + "id": "chacdk86lnnboviihd7g", + "type": "host" + } + ] +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("POST", url, headers=headers, data=payload) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/groups" + method := "POST" + + payload := strings.NewReader(`{ + "name": "devs", + "peers": [ + "ch8i4ug6lnn4g9hqv7m1" + ], + "resources": [ + { + "id": "chacdk86lnnboviihd7g", + "type": "host" + } + ] +}`) + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/groups") + +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({ + "name": "devs", + "peers": [ + "ch8i4ug6lnn4g9hqv7m1" + ], + "resources": [ + { + "id": "chacdk86lnnboviihd7g", + "type": "host" + } + ] +}) +response = https.request(request) +puts response.read_body +``` + +```java {{ title: 'Java' }} +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); +MediaType mediaType = MediaType.parse("application/json"); +RequestBody body = RequestBody.create(mediaType, "{ + \"name\": \"devs\", + \"peers\": [ + \"ch8i4ug6lnn4g9hqv7m1\" + ], + \"resources\": [ + { + \"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 ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/groups', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS => '{ + "name": "devs", + "peers": [ + "ch8i4ug6lnn4g9hqv7m1" + ], + "resources": [ + { + "id": "chacdk86lnnboviihd7g", + "type": "host" + } + ] +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -212,6 +561,141 @@ curl -X GET https://api.netbird.io/api/groups/{groupId} \ -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/groups/{groupId}', + 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/groups/{groupId}" + +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/groups/{groupId}" + 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/groups/{groupId}") + +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/groups/{groupId}") + .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/groups/{groupId}', + 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' }} @@ -320,9 +804,9 @@ Network resource type based of the address ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/groups/{groupId} \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "name": "devs", "peers": [ @@ -336,6 +820,220 @@ curl -X PUT https://api.netbird.io/api/groups/{groupId} \ ] }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "name": "devs", + "peers": [ + "ch8i4ug6lnn4g9hqv7m1" + ], + "resources": [ + { + "id": "chacdk86lnnboviihd7g", + "type": "host" + } + ] +}); +let config = { + method: 'put', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/groups/{groupId}', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/groups/{groupId}" +payload = json.dumps({ + "name": "devs", + "peers": [ + "ch8i4ug6lnn4g9hqv7m1" + ], + "resources": [ + { + "id": "chacdk86lnnboviihd7g", + "type": "host" + } + ] +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("PUT", url, headers=headers, data=payload) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/groups/{groupId}" + method := "PUT" + + payload := strings.NewReader({ + "name": "devs", + "peers": [ + "ch8i4ug6lnn4g9hqv7m1" + ], + "resources": [ + { + "id": "chacdk86lnnboviihd7g", + "type": "host" + } + ] +}) + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/groups/{groupId}") + +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({ + "name": "devs", + "peers": [ + "ch8i4ug6lnn4g9hqv7m1" + ], + "resources": [ + { + "id": "chacdk86lnnboviihd7g", + "type": "host" + } + ] +}) +response = https.request(request) +puts response.read_body +``` + +```java {{ title: 'Java' }} +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); +MediaType mediaType = MediaType.parse("application/json"); +RequestBody body = RequestBody.create(mediaType, '{ + "name": "devs", + "peers": [ + "ch8i4ug6lnn4g9hqv7m1" + ], + "resources": [ + { + "id": "chacdk86lnnboviihd7g", + "type": "host" + } + ] +}'); +Request request = new Request.Builder() + .url("https://api.netbird.io/api/groups/{groupId}") + .method("PUT", body) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/groups/{groupId}', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'PUT', + CURLOPT_POSTFIELDS => '{ + "name": "devs", + "peers": [ + "ch8i4ug6lnn4g9hqv7m1" + ], + "resources": [ + { + "id": "chacdk86lnnboviihd7g", + "type": "host" + } + ] +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -413,7 +1111,131 @@ 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 +const axios = require('axios'); + +let config = { + method: 'delete', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/groups/{groupId}', + 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/groups/{groupId}" + +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/groups/{groupId}" + 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/groups/{groupId}") + +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/groups/{groupId}") + .method("DELETE", null) + .addHeader("Authorization", "Token ") + .build(); + +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/groups/{groupId}', + 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/ingress-ports.mdx b/src/pages/ipa/resources/ingress-ports.mdx index bd29333f..a2245d53 100644 --- a/src/pages/ipa/resources/ingress-ports.mdx +++ b/src/pages/ipa/resources/ingress-ports.mdx @@ -37,6 +37,141 @@ curl -X GET https://api.netbird.io/api/peers/{peerId}/ingress/ports \ -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/peers/{peerId}/ingress/ports', + 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/peers/{peerId}/ingress/ports" + +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/peers/{peerId}/ingress/ports" + 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/peers/{peerId}/ingress/ports") + +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/peers/{peerId}/ingress/ports") + .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/peers/{peerId}/ingress/ports', + 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' }} @@ -165,9 +300,9 @@ The protocol accepted by the port ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/peers/{peerId}/ingress/ports \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "name": "Ingress Port Allocation 1", "enabled": true, @@ -184,6 +319,238 @@ curl -X POST https://api.netbird.io/api/peers/{peerId}/ingress/ports \ } }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "name": "Ingress Port Allocation 1", + "enabled": true, + "port_ranges": [ + { + "start": 80, + "end": 320, + "protocol": "tcp" + } + ], + "direct_port": { + "count": 5, + "protocol": "udp" + } +}); +let config = { + method: 'post', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/peers/{peerId}/ingress/ports', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/peers/{peerId}/ingress/ports" +payload = json.dumps({ + "name": "Ingress Port Allocation 1", + "enabled": true, + "port_ranges": [ + { + "start": 80, + "end": 320, + "protocol": "tcp" + } + ], + "direct_port": { + "count": 5, + "protocol": "udp" + } +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("POST", url, headers=headers, data=payload) + +print(response.text) +``` + +```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 := "POST" + + payload := strings.NewReader(`{ + "name": "Ingress Port Allocation 1", + "enabled": true, + "port_ranges": [ + { + "start": 80, + "end": 320, + "protocol": "tcp" + } + ], + "direct_port": { + "count": 5, + "protocol": "udp" + } +}`) + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/peers/{peerId}/ingress/ports") + +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({ + "name": "Ingress Port Allocation 1", + "enabled": true, + "port_ranges": [ + { + "start": 80, + "end": 320, + "protocol": "tcp" + } + ], + "direct_port": { + "count": 5, + "protocol": "udp" + } +}) +response = https.request(request) +puts response.read_body +``` + +```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\": [ + { + \"start\": 80, + \"end\": 320, + \"protocol\": \"tcp\" + } + ], + \"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 ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/peers/{peerId}/ingress/ports', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS => '{ + "name": "Ingress Port Allocation 1", + "enabled": true, + "port_ranges": [ + { + "start": 80, + "end": 320, + "protocol": "tcp" + } + ], + "direct_port": { + "count": 5, + "protocol": "udp" + } +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -263,6 +630,141 @@ curl -X GET https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationI -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/peers/{peerId}/ingress/ports/{allocationId}', + 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/peers/{peerId}/ingress/ports/{allocationId}" + +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/peers/{peerId}/ingress/ports/{allocationId}" + 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/peers/{peerId}/ingress/ports/{allocationId}") + +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/peers/{peerId}/ingress/ports/{allocationId}") + .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/peers/{peerId}/ingress/ports/{allocationId}', + 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' }} @@ -390,9 +892,9 @@ The protocol accepted by the port ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId} \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "name": "Ingress Port Allocation 1", "enabled": true, @@ -409,6 +911,238 @@ curl -X PUT https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationI } }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "name": "Ingress Port Allocation 1", + "enabled": true, + "port_ranges": [ + { + "start": 80, + "end": 320, + "protocol": "tcp" + } + ], + "direct_port": { + "count": 5, + "protocol": "udp" + } +}); +let config = { + method: 'put', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}" +payload = json.dumps({ + "name": "Ingress Port Allocation 1", + "enabled": true, + "port_ranges": [ + { + "start": 80, + "end": 320, + "protocol": "tcp" + } + ], + "direct_port": { + "count": 5, + "protocol": "udp" + } +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("PUT", url, headers=headers, data=payload) + +print(response.text) +``` + +```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 := "PUT" + + payload := strings.NewReader({ + "name": "Ingress Port Allocation 1", + "enabled": true, + "port_ranges": [ + { + "start": 80, + "end": 320, + "protocol": "tcp" + } + ], + "direct_port": { + "count": 5, + "protocol": "udp" + } +}) + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}") + +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({ + "name": "Ingress Port Allocation 1", + "enabled": true, + "port_ranges": [ + { + "start": 80, + "end": 320, + "protocol": "tcp" + } + ], + "direct_port": { + "count": 5, + "protocol": "udp" + } +}) +response = https.request(request) +puts response.read_body +``` + +```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": [ + { + "start": 80, + "end": 320, + "protocol": "tcp" + } + ], + "direct_port": { + "count": 5, + "protocol": "udp" + } +}'); +Request request = new Request.Builder() + .url("https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}") + .method("PUT", body) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'PUT', + CURLOPT_POSTFIELDS => '{ + "name": "Ingress Port Allocation 1", + "enabled": true, + "port_ranges": [ + { + "start": 80, + "end": 320, + "protocol": "tcp" + } + ], + "direct_port": { + "count": 5, + "protocol": "udp" + } +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -485,7 +1219,131 @@ 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 +const axios = require('axios'); + +let config = { + method: 'delete', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}', + 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/peers/{peerId}/ingress/ports/{allocationId}" + +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/peers/{peerId}/ingress/ports/{allocationId}" + 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/peers/{peerId}/ingress/ports/{allocationId}") + +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/peers/{peerId}/ingress/ports/{allocationId}") + .method("DELETE", null) + .addHeader("Authorization", "Token ") + .build(); + +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/peers/{peerId}/ingress/ports/{allocationId}', + 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; ``` @@ -511,6 +1369,141 @@ curl -X GET https://api.netbird.io/api/ingress/peers \ -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/ingress/peers', + 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/ingress/peers" + +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/ingress/peers" + method := "GET" + + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + res, err := client.Do(req) + if err != nil { + fmt.Println(err) + return + } + defer res.Body.Close() + + body, err := ioutil.ReadAll(res.Body) + if err != nil { + fmt.Println(err) + return + } + fmt.Println(string(body)) +} +``` + +```ruby {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/ingress/peers") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Get.new(url) +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +response = https.request(request) +puts response.read_body +``` + +```java {{ title: 'Java' }} +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); + +Request request = new Request.Builder() + .url("https://api.netbird.io/api/ingress/peers") + .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/ingress/peers', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'GET', + CURLOPT_HTTPHEADER => array( + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -586,15 +1579,187 @@ Defines if an ingress peer can be used as a fallback if no ingress peer can be f ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/ingress/peers \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "peer_id": "ch8i4ug6lnn4g9hqv7m0", "enabled": true, "fallback": true }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "peer_id": "ch8i4ug6lnn4g9hqv7m0", + "enabled": true, + "fallback": true +}); +let config = { + method: 'post', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/ingress/peers', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/ingress/peers" +payload = json.dumps({ + "peer_id": "ch8i4ug6lnn4g9hqv7m0", + "enabled": true, + "fallback": true +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("POST", url, headers=headers, data=payload) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/ingress/peers" + method := "POST" + + payload := strings.NewReader(`{ + "peer_id": "ch8i4ug6lnn4g9hqv7m0", + "enabled": true, + "fallback": true +}`) + client := &http.Client{} + req, err := http.NewRequest(method, url, payload) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Content-Type", "application/json") + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/ingress/peers") + +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({ + "peer_id": "ch8i4ug6lnn4g9hqv7m0", + "enabled": true, + "fallback": true +}) +response = https.request(request) +puts response.read_body +``` + +```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 +}"); +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 ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/ingress/peers', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS => '{ + "peer_id": "ch8i4ug6lnn4g9hqv7m0", + "enabled": true, + "fallback": true +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -663,6 +1828,141 @@ curl -X GET https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ -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/ingress/peers/{ingressPeerId}', + 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/ingress/peers/{ingressPeerId}" + +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/ingress/peers/{ingressPeerId}" + 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/ingress/peers/{ingressPeerId}") + +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/ingress/peers/{ingressPeerId}") + .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/ingress/peers/{ingressPeerId}', + 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' }} @@ -742,14 +2042,180 @@ Defines if an ingress peer can be used as a fallback if no ingress peer can be f ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/ingress/peers/{ingressPeerId} \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "enabled": true, "fallback": true }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "enabled": true, + "fallback": true +}); +let config = { + method: 'put', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/ingress/peers/{ingressPeerId}', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/ingress/peers/{ingressPeerId}" +payload = json.dumps({ + "enabled": true, + "fallback": true +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("PUT", url, headers=headers, data=payload) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/ingress/peers/{ingressPeerId}" + method := "PUT" + + payload := strings.NewReader({ + "enabled": true, + "fallback": true +}) + client := &http.Client{} + req, err := http.NewRequest(method, url, payload) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Content-Type", "application/json") + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/ingress/peers/{ingressPeerId}") + +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({ + "enabled": true, + "fallback": true +}) +response = https.request(request) +puts response.read_body +``` + +```java {{ title: 'Java' }} +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); +MediaType mediaType = MediaType.parse("application/json"); +RequestBody body = RequestBody.create(mediaType, '{ + "enabled": true, + "fallback": true +}'); +Request request = new Request.Builder() + .url("https://api.netbird.io/api/ingress/peers/{ingressPeerId}") + .method("PUT", body) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/ingress/peers/{ingressPeerId}', + 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 => '{ + "enabled": true, + "fallback": true +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -815,7 +2281,131 @@ 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 +const axios = require('axios'); + +let config = { + method: 'delete', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/ingress/peers/{ingressPeerId}', + 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/ingress/peers/{ingressPeerId}" + +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/ingress/peers/{ingressPeerId}" + 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/ingress/peers/{ingressPeerId}") + +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/ingress/peers/{ingressPeerId}") + .method("DELETE", null) + .addHeader("Authorization", "Token ") + .build(); + +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/ingress/peers/{ingressPeerId}', + 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/networks.mdx b/src/pages/ipa/resources/networks.mdx index 231edb02..912f56d8 100644 --- a/src/pages/ipa/resources/networks.mdx +++ b/src/pages/ipa/resources/networks.mdx @@ -15,6 +15,141 @@ curl -X GET https://api.netbird.io/api/networks \ -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/networks', + 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/networks" + +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/networks" + 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/networks") + +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/networks") + .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/networks', + 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' }} @@ -91,14 +226,180 @@ Network description ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/networks \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "name": "Remote Network 1", "description": "A remote network that needs to be accessed" }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "name": "Remote Network 1", + "description": "A remote network that needs to be accessed" +}); +let config = { + method: 'post', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/networks', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/networks" +payload = json.dumps({ + "name": "Remote Network 1", + "description": "A remote network that needs to be accessed" +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("POST", url, headers=headers, data=payload) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/networks" + method := "POST" + + payload := strings.NewReader(`{ + "name": "Remote Network 1", + "description": "A remote network that needs to be accessed" +}`) + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/networks") + +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({ + "name": "Remote Network 1", + "description": "A remote network that needs to be accessed" +}) +response = https.request(request) +puts response.read_body +``` + +```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\" +}"); +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 ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/networks', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS => '{ + "name": "Remote Network 1", + "description": "A remote network that needs to be accessed" +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -171,6 +472,141 @@ curl -X GET https://api.netbird.io/api/networks/{networkId} \ -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/networks/{networkId}', + 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/networks/{networkId}" + +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/networks/{networkId}" + 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/networks/{networkId}") + +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/networks/{networkId}") + .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/networks/{networkId}', + 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' }} @@ -254,14 +690,180 @@ Network description ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/networks/{networkId} \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "name": "Remote Network 1", "description": "A remote network that needs to be accessed" }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "name": "Remote Network 1", + "description": "A remote network that needs to be accessed" +}); +let config = { + method: 'put', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/networks/{networkId}', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/networks/{networkId}" +payload = json.dumps({ + "name": "Remote Network 1", + "description": "A remote network that needs to be accessed" +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("PUT", url, headers=headers, data=payload) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/networks/{networkId}" + method := "PUT" + + payload := strings.NewReader({ + "name": "Remote Network 1", + "description": "A remote network that needs to be accessed" +}) + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/networks/{networkId}") + +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({ + "name": "Remote Network 1", + "description": "A remote network that needs to be accessed" +}) +response = https.request(request) +puts response.read_body +``` + +```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" +}'); +Request request = new Request.Builder() + .url("https://api.netbird.io/api/networks/{networkId}") + .method("PUT", body) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/networks/{networkId}', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'PUT', + CURLOPT_POSTFIELDS => '{ + "name": "Remote Network 1", + "description": "A remote network that needs to be accessed" +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -331,7 +933,131 @@ 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 +const axios = require('axios'); + +let config = { + method: 'delete', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/networks/{networkId}', + 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/networks/{networkId}" + +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/networks/{networkId}" + 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/networks/{networkId}") + +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/networks/{networkId}") + .method("DELETE", null) + .addHeader("Authorization", "Token ") + .build(); + +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/networks/{networkId}', + 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; ``` @@ -368,6 +1094,141 @@ curl -X GET https://api.netbird.io/api/networks/{networkId}/resources \ -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/networks/{networkId}/resources', + 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/networks/{networkId}/resources" + +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/networks/{networkId}/resources" + 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/networks/{networkId}/resources") + +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/networks/{networkId}/resources") + .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/networks/{networkId}/resources', + 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' }} @@ -468,9 +1329,9 @@ Group IDs containing the resource ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/networks/{networkId}/resources \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "name": "Remote Resource 1", "description": "A remote resource inside network 1", @@ -481,58 +1342,254 @@ curl -X POST https://api.netbird.io/api/networks/{networkId}/resources \ ] }' ``` - - -```json {{ title: 'Example' }} -{ - "id": "chacdk86lnnboviihd7g", - "type": "host", - "groups": [ - { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api" - } - ], + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ "name": "Remote Resource 1", "description": "A remote resource inside network 1", "address": "1.1.1.1", - "enabled": true -} + "enabled": true, + "groups": [ + "chacdk86lnnboviihd70" + ] +}); +let config = { + method: 'post', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/networks/{networkId}/resources', + 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); +}); ``` -```json {{ title: 'Schema' }} -{ - "id": "string", - "type": "string", +```python {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/networks/{networkId}/resources" +payload = json.dumps({ + "name": "Remote Resource 1", + "description": "A remote resource inside network 1", + "address": "1.1.1.1", + "enabled": true, "groups": [ - { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string" - } - ], - "name": "string", - "description": "string", - "address": "string", - "enabled": "boolean" + "chacdk86lnnboviihd70" + ] +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' } -``` - - - - +response = requests.request("POST", url, headers=headers, data=payload) ---- +print(response.text) +``` +```go {{ title: 'Go' }} +package main +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) -## Retrieve a Network Resource {{ tag: 'GET', label: '/api/networks/{networkId}/resources/{resourceId}' }} +func main() { + + url := "https://api.netbird.io/api/networks/{networkId}/resources" + method := "POST" + + payload := strings.NewReader(`{ + "name": "Remote Resource 1", + "description": "A remote resource inside network 1", + "address": "1.1.1.1", + "enabled": true, + "groups": [ + "chacdk86lnnboviihd70" + ] +}`) + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/networks/{networkId}/resources") + +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({ + "name": "Remote Resource 1", + "description": "A remote resource inside network 1", + "address": "1.1.1.1", + "enabled": true, + "groups": [ + "chacdk86lnnboviihd70" + ] +}) +response = https.request(request) +puts response.read_body +``` + +```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\" + ] +}"); +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 ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/networks/{networkId}/resources', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS => '{ + "name": "Remote Resource 1", + "description": "A remote resource inside network 1", + "address": "1.1.1.1", + "enabled": true, + "groups": [ + "chacdk86lnnboviihd70" + ] +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` + + +```json {{ title: 'Example' }} +{ + "id": "chacdk86lnnboviihd7g", + "type": "host", + "groups": [ + { + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api" + } + ], + "name": "Remote Resource 1", + "description": "A remote resource inside network 1", + "address": "1.1.1.1", + "enabled": true +} +``` + +```json {{ title: 'Schema' }} +{ + "id": "string", + "type": "string", + "groups": [ + { + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string" + } + ], + "name": "string", + "description": "string", + "address": "string", + "enabled": "boolean" +} +``` + + + + + + +--- + + + +## Retrieve a Network Resource {{ tag: 'GET', label: '/api/networks/{networkId}/resources/{resourceId}' }} @@ -560,6 +1617,141 @@ curl -X GET https://api.netbird.io/api/networks/{networkId}/resources/{resourceI -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/networks/{networkId}/resources/{resourceId}', + 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/networks/{networkId}/resources/{resourceId}" + +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/networks/{networkId}/resources/{resourceId}" + 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/networks/{networkId}/resources/{resourceId}") + +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/networks/{networkId}/resources/{resourceId}") + .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/networks/{networkId}/resources/{resourceId}', + 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' }} @@ -659,9 +1851,9 @@ Group IDs containing the resource ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/networks/{networkId}/resources/{resourceId} \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "name": "Remote Resource 1", "description": "A remote resource inside network 1", @@ -672,6 +1864,202 @@ curl -X PUT https://api.netbird.io/api/networks/{networkId}/resources/{resourceI ] }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "name": "Remote Resource 1", + "description": "A remote resource inside network 1", + "address": "1.1.1.1", + "enabled": true, + "groups": [ + "chacdk86lnnboviihd70" + ] +}); +let config = { + method: 'put', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}" +payload = json.dumps({ + "name": "Remote Resource 1", + "description": "A remote resource inside network 1", + "address": "1.1.1.1", + "enabled": true, + "groups": [ + "chacdk86lnnboviihd70" + ] +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("PUT", url, headers=headers, data=payload) + +print(response.text) +``` + +```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 := "PUT" + + payload := strings.NewReader({ + "name": "Remote Resource 1", + "description": "A remote resource inside network 1", + "address": "1.1.1.1", + "enabled": true, + "groups": [ + "chacdk86lnnboviihd70" + ] +}) + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}") + +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({ + "name": "Remote Resource 1", + "description": "A remote resource inside network 1", + "address": "1.1.1.1", + "enabled": true, + "groups": [ + "chacdk86lnnboviihd70" + ] +}) +response = https.request(request) +puts response.read_body +``` + +```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" + ] +}'); +Request request = new Request.Builder() + .url("https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}") + .method("PUT", body) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'PUT', + CURLOPT_POSTFIELDS => '{ + "name": "Remote Resource 1", + "description": "A remote resource inside network 1", + "address": "1.1.1.1", + "enabled": true, + "groups": [ + "chacdk86lnnboviihd70" + ] +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -748,7 +2136,131 @@ Delete a network resource ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/networks/{networkId}/resources/{resourceId} \ --H 'Authorization: Token ' \ +-H 'Authorization: Token ' +``` + +```js +const axios = require('axios'); + +let config = { + method: 'delete', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}', + 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/networks/{networkId}/resources/{resourceId}" + +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/networks/{networkId}/resources/{resourceId}" + 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/networks/{networkId}/resources/{resourceId}") + +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/networks/{networkId}/resources/{resourceId}") + .method("DELETE", null) + .addHeader("Authorization", "Token ") + .build(); + +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/networks/{networkId}/resources/{resourceId}', + 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; ``` @@ -785,6 +2297,141 @@ curl -X GET https://api.netbird.io/api/networks/{networkId}/routers \ -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/networks/{networkId}/routers', + 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/networks/{networkId}/routers" + +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/networks/{networkId}/routers" + 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/networks/{networkId}/routers") + +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/networks/{networkId}/routers") + .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/networks/{networkId}/routers', + 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' }} @@ -871,9 +2518,9 @@ Network router status ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/networks/{networkId}/routers \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "peer": "chacbco6lnnbn6cg5s91", "peer_groups": [ @@ -884,6 +2531,202 @@ curl -X POST https://api.netbird.io/api/networks/{networkId}/routers \ "enabled": true }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "peer": "chacbco6lnnbn6cg5s91", + "peer_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "metric": 9999, + "masquerade": true, + "enabled": true +}); +let config = { + method: 'post', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/networks/{networkId}/routers', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/networks/{networkId}/routers" +payload = json.dumps({ + "peer": "chacbco6lnnbn6cg5s91", + "peer_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "metric": 9999, + "masquerade": true, + "enabled": true +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("POST", url, headers=headers, data=payload) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/networks/{networkId}/routers" + method := "POST" + + payload := strings.NewReader(`{ + "peer": "chacbco6lnnbn6cg5s91", + "peer_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "metric": 9999, + "masquerade": true, + "enabled": true +}`) + client := &http.Client{} + req, err := http.NewRequest(method, url, payload) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Content-Type", "application/json") + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/networks/{networkId}/routers") + +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({ + "peer": "chacbco6lnnbn6cg5s91", + "peer_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "metric": 9999, + "masquerade": true, + "enabled": true +}) +response = https.request(request) +puts response.read_body +``` + +```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\" + ], + \"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 ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/networks/{networkId}/routers', + 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 => '{ + "peer": "chacbco6lnnbn6cg5s91", + "peer_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "metric": 9999, + "masquerade": true, + "enabled": true +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -949,6 +2792,141 @@ curl -X GET https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ -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/networks/{networkId}/routers/{routerId}', + 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/networks/{networkId}/routers/{routerId}" + +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/networks/{networkId}/routers/{routerId}" + 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/networks/{networkId}/routers/{routerId}") + +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/networks/{networkId}/routers/{routerId}") + .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/networks/{networkId}/routers/{routerId}', + 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' }} @@ -1034,9 +3012,9 @@ Network router status ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "peer": "chacbco6lnnbn6cg5s91", "peer_groups": [ @@ -1047,6 +3025,202 @@ curl -X PUT https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ "enabled": true }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "peer": "chacbco6lnnbn6cg5s91", + "peer_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "metric": 9999, + "masquerade": true, + "enabled": true +}); +let config = { + method: 'put', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/networks/{networkId}/routers/{routerId}', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/networks/{networkId}/routers/{routerId}" +payload = json.dumps({ + "peer": "chacbco6lnnbn6cg5s91", + "peer_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "metric": 9999, + "masquerade": true, + "enabled": true +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("PUT", url, headers=headers, data=payload) + +print(response.text) +``` + +```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 := "PUT" + + payload := strings.NewReader({ + "peer": "chacbco6lnnbn6cg5s91", + "peer_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "metric": 9999, + "masquerade": true, + "enabled": true +}) + client := &http.Client{} + req, err := http.NewRequest(method, url, payload) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Content-Type", "application/json") + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/networks/{networkId}/routers/{routerId}") + +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({ + "peer": "chacbco6lnnbn6cg5s91", + "peer_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "metric": 9999, + "masquerade": true, + "enabled": true +}) +response = https.request(request) +puts response.read_body +``` + +```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" + ], + "metric": 9999, + "masquerade": true, + "enabled": true +}'); +Request request = new Request.Builder() + .url("https://api.netbird.io/api/networks/{networkId}/routers/{routerId}") + .method("PUT", body) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/networks/{networkId}/routers/{routerId}', + 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 => '{ + "peer": "chacbco6lnnbn6cg5s91", + "peer_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "metric": 9999, + "masquerade": true, + "enabled": true +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -1109,7 +3283,131 @@ Delete a network router ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/networks/{networkId}/routers/{routerId} \ --H 'Authorization: Token ' \ +-H 'Authorization: Token ' +``` + +```js +const axios = require('axios'); + +let config = { + method: 'delete', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/networks/{networkId}/routers/{routerId}', + 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/networks/{networkId}/routers/{routerId}" + +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/networks/{networkId}/routers/{routerId}" + 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/networks/{networkId}/routers/{routerId}") + +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/networks/{networkId}/routers/{routerId}") + .method("DELETE", null) + .addHeader("Authorization", "Token ") + .build(); + +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/networks/{networkId}/routers/{routerId}', + 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; ``` @@ -1135,6 +3433,141 @@ curl -X GET https://api.netbird.io/api/networks/routers \ -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/networks/routers', + 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/networks/routers" + +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/networks/routers" + 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/networks/routers") + +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/networks/routers") + .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/networks/routers', + 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' }} diff --git a/src/pages/ipa/resources/peers.mdx b/src/pages/ipa/resources/peers.mdx index 10aaec55..bb12e57c 100644 --- a/src/pages/ipa/resources/peers.mdx +++ b/src/pages/ipa/resources/peers.mdx @@ -29,6 +29,141 @@ curl -X GET https://api.netbird.io/api/peers \ -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/peers', + 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/peers" + +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/peers" + method := "GET" + + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + res, err := client.Do(req) + if err != nil { + fmt.Println(err) + return + } + defer res.Body.Close() + + body, err := ioutil.ReadAll(res.Body) + if err != nil { + fmt.Println(err) + return + } + fmt.Println(string(body)) +} +``` + +```ruby {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/peers") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Get.new(url) +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +response = https.request(request) +puts response.read_body +``` + +```java {{ title: 'Java' }} +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); + +Request request = new Request.Builder() + .url("https://api.netbird.io/api/peers") + .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/peers', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'GET', + CURLOPT_HTTPHEADER => array( + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -155,6 +290,141 @@ curl -X GET https://api.netbird.io/api/peers/{peerId} \ -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/peers/{peerId}', + 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/peers/{peerId}" + +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/peers/{peerId}" + 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/peers/{peerId}") + +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/peers/{peerId}") + .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/peers/{peerId}', + 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' }} @@ -298,9 +568,9 @@ Peer's IP address ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/peers/{peerId} \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "name": "stage-host-1", "ssh_enabled": true, @@ -310,6 +580,196 @@ curl -X PUT https://api.netbird.io/api/peers/{peerId} \ "ip": "100.64.0.15" }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "name": "stage-host-1", + "ssh_enabled": true, + "login_expiration_enabled": false, + "inactivity_expiration_enabled": false, + "approval_required": true, + "ip": "100.64.0.15" +}); +let config = { + method: 'put', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/peers/{peerId}', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/peers/{peerId}" +payload = json.dumps({ + "name": "stage-host-1", + "ssh_enabled": true, + "login_expiration_enabled": false, + "inactivity_expiration_enabled": false, + "approval_required": true, + "ip": "100.64.0.15" +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("PUT", url, headers=headers, data=payload) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/peers/{peerId}" + method := "PUT" + + 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{} + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/peers/{peerId}") + +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({ + "name": "stage-host-1", + "ssh_enabled": true, + "login_expiration_enabled": false, + "inactivity_expiration_enabled": false, + "approval_required": true, + "ip": "100.64.0.15" +}) +response = https.request(request) +puts response.read_body +``` + +```java {{ title: 'Java' }} +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); +MediaType mediaType = MediaType.parse("application/json"); +RequestBody body = RequestBody.create(mediaType, '{ + "name": "stage-host-1", + "ssh_enabled": true, + "login_expiration_enabled": false, + "inactivity_expiration_enabled": false, + "approval_required": true, + "ip": "100.64.0.15" +}'); +Request request = new Request.Builder() + .url("https://api.netbird.io/api/peers/{peerId}") + .method("PUT", body) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/peers/{peerId}', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'PUT', + CURLOPT_POSTFIELDS => '{ + "name": "stage-host-1", + "ssh_enabled": true, + "login_expiration_enabled": false, + "inactivity_expiration_enabled": false, + "approval_required": true, + "ip": "100.64.0.15" +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -427,7 +887,131 @@ 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 +const axios = require('axios'); + +let config = { + method: 'delete', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/peers/{peerId}', + 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/peers/{peerId}" + +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/peers/{peerId}" + 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/peers/{peerId}") + +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/peers/{peerId}") + .method("DELETE", null) + .addHeader("Authorization", "Token ") + .build(); + +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/peers/{peerId}', + 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; ``` @@ -464,6 +1048,141 @@ curl -X GET https://api.netbird.io/api/peers/{peerId}/accessible-peers \ -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/peers/{peerId}/accessible-peers', + headers: { + 'Accept': 'application/json', + 'Authorization': 'Token ' + } +}; + +axios(config) +.then((response) => { + console.log(JSON.stringify(response.data)); +}) +.catch((error) => { + console.log(error); +}); +``` + +```python {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/peers/{peerId}/accessible-peers" + +headers = { + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("GET", url, headers=headers) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "net/http" + "io/ioutil" +) + +func main() { + url := "https://api.netbird.io/api/peers/{peerId}/accessible-peers" + method := "GET" + + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + res, err := client.Do(req) + if err != nil { + fmt.Println(err) + return + } + defer res.Body.Close() + + body, err := ioutil.ReadAll(res.Body) + if err != nil { + fmt.Println(err) + return + } + fmt.Println(string(body)) +} +``` + +```ruby {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/peers/{peerId}/accessible-peers") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Get.new(url) +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +response = https.request(request) +puts response.read_body +``` + +```java {{ 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", null) + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/peers/{peerId}/accessible-peers', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'GET', + CURLOPT_HTTPHEADER => array( + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} diff --git a/src/pages/ipa/resources/policies.mdx b/src/pages/ipa/resources/policies.mdx index 4515674f..8ebbdb5d 100644 --- a/src/pages/ipa/resources/policies.mdx +++ b/src/pages/ipa/resources/policies.mdx @@ -15,6 +15,141 @@ curl -X GET https://api.netbird.io/api/policies \ -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/policies', + 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/policies" + +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/policies" + 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/policies") + +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/policies") + .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/policies', + 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' }} @@ -269,9 +404,9 @@ Network resource type based of the address ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/policies \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", @@ -315,14 +450,13 @@ curl -X POST https://api.netbird.io/api/policies \ ] }' ``` - - -```json {{ title: 'Example' }} -{ + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, - "id": "ch8i4ug6lnn4g9hqv7mg", "source_posture_checks": [ "chacdk86lnnboviihd70" ], @@ -345,26 +479,14 @@ curl -X POST https://api.netbird.io/api/policies \ ], "id": "ch8i4ug6lnn4g9hqv7mg", "sources": [ - { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api" - } + "ch8i4ug6lnn4g9hqv797" ], "sourceResource": { "id": "chacdk86lnnboviihd7g", "type": "host" }, "destinations": [ - { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api" - } + "ch8i4ug6lnn4g9h7v7m0" ], "destinationResource": { "id": "chacdk86lnnboviihd7g", @@ -372,109 +494,105 @@ curl -X POST https://api.netbird.io/api/policies \ } } ] -} +}); +let config = { + method: 'post', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/policies', + 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); +}); ``` -```json {{ title: 'Schema' }} -{ - "name": "string", - "description": "string", - "enabled": "boolean", - "id": "string", +```python {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/policies" +payload = json.dumps({ + "name": "ch8i4ug6lnn4g9hqv7mg", + "description": "This is a default policy that allows connections between all the resources", + "enabled": true, "source_posture_checks": [ - "string" + "chacdk86lnnboviihd70" ], "rules": [ { - "name": "string", - "description": "string", - "enabled": "boolean", - "action": "string", - "bidirectional": "boolean", - "protocol": "string", + "name": "Default", + "description": "This is a default rule that allows connections between all the resources", + "enabled": true, + "action": "accept", + "bidirectional": true, + "protocol": "tcp", "ports": [ - "string" + "80" ], "port_ranges": [ { - "start": "integer", - "end": "integer" + "start": 80, + "end": 320 } ], - "id": "string", + "id": "ch8i4ug6lnn4g9hqv7mg", "sources": [ - { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string" - } + "ch8i4ug6lnn4g9hqv797" ], "sourceResource": { - "id": "string", - "type": "string" + "id": "chacdk86lnnboviihd7g", + "type": "host" }, "destinations": [ - { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string" - } + "ch8i4ug6lnn4g9h7v7m0" ], "destinationResource": { - "id": "string", - "type": "string" + "id": "chacdk86lnnboviihd7g", + "type": "host" } } ] +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' } -``` - - - - - - ---- - - - -## Retrieve a Policy {{ tag: 'GET', label: '/api/policies/{policyId}' }} - - - -Get information about a Policies +response = requests.request("POST", url, headers=headers, data=payload) -### Path Parameters +print(response.text) +``` +```go {{ title: 'Go' }} +package main - - -The unique identifier of a policy - +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) - +func main() { - - - -```bash {{ title: 'cURL' }} -curl -X GET https://api.netbird.io/api/policies/{policyId} \ --H 'Accept: application/json' \ --H 'Authorization: Token ' -``` - - -```json {{ title: 'Example' }} -{ + url := "https://api.netbird.io/api/policies" + method := "POST" + + payload := strings.NewReader(`{ "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, - "id": "ch8i4ug6lnn4g9hqv7mg", "source_posture_checks": [ "chacdk86lnnboviihd70" ], @@ -497,26 +615,14 @@ curl -X GET https://api.netbird.io/api/policies/{policyId} \ ], "id": "ch8i4ug6lnn4g9hqv7mg", "sources": [ - { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api" - } + "ch8i4ug6lnn4g9hqv797" ], "sourceResource": { "id": "chacdk86lnnboviihd7g", "type": "host" }, "destinations": [ - { - "id": "ch8i4ug6lnn4g9hqv7m0", - "name": "devs", - "peers_count": 2, - "resources_count": 5, - "issued": "api" - } + "ch8i4ug6lnn4g9h7v7m0" ], "destinationResource": { "id": "chacdk86lnnboviihd7g", @@ -524,89 +630,647 @@ curl -X GET https://api.netbird.io/api/policies/{policyId} \ } } ] +}`) + 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)) } ``` -```json {{ title: 'Schema' }} -{ - "name": "string", - "description": "string", - "enabled": "boolean", - "id": "string", +```ruby {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/policies") + +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({ + "name": "ch8i4ug6lnn4g9hqv7mg", + "description": "This is a default policy that allows connections between all the resources", + "enabled": true, "source_posture_checks": [ - "string" + "chacdk86lnnboviihd70" ], "rules": [ { - "name": "string", - "description": "string", - "enabled": "boolean", - "action": "string", - "bidirectional": "boolean", - "protocol": "string", + "name": "Default", + "description": "This is a default rule that allows connections between all the resources", + "enabled": true, + "action": "accept", + "bidirectional": true, + "protocol": "tcp", "ports": [ - "string" + "80" ], "port_ranges": [ { - "start": "integer", - "end": "integer" + "start": 80, + "end": 320 } ], - "id": "string", + "id": "ch8i4ug6lnn4g9hqv7mg", "sources": [ - { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string" - } + "ch8i4ug6lnn4g9hqv797" ], "sourceResource": { - "id": "string", - "type": "string" + "id": "chacdk86lnnboviihd7g", + "type": "host" }, "destinations": [ - { - "id": "string", - "name": "string", - "peers_count": "integer", - "resources_count": "integer", - "issued": "string" - } + "ch8i4ug6lnn4g9h7v7m0" ], "destinationResource": { - "id": "string", - "type": "string" + "id": "chacdk86lnnboviihd7g", + "type": "host" } } ] -} +}) +response = https.request(request) +puts response.read_body ``` - - - - - - ---- - - - -## Update a Policy {{ tag: 'PUT', label: '/api/policies/{policyId}' }} - - - - -Update/Replace a Policy - -### Path Parameters +```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\" + ], + \"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\": [ + { + \"start\": 80, + \"end\": 320 + } + ], + \"id\": \"ch8i4ug6lnn4g9hqv7mg\", + \"sources\": [ + \"ch8i4ug6lnn4g9hqv797\" + ], + \"sourceResource\": { + \"id\": \"chacdk86lnnboviihd7g\", + \"type\": \"host\" + }, + \"destinations\": [ + \"ch8i4ug6lnn4g9h7v7m0\" + ], + \"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 ") + .build(); +Response response = client.newCall(request).execute(); +``` - - -The unique identifier of a policy +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/policies', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS => '{ + "name": "ch8i4ug6lnn4g9hqv7mg", + "description": "This is a default policy that allows connections between all the resources", + "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], + "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": [ + { + "start": 80, + "end": 320 + } + ], + "id": "ch8i4ug6lnn4g9hqv7mg", + "sources": [ + "ch8i4ug6lnn4g9hqv797" + ], + "sourceResource": { + "id": "chacdk86lnnboviihd7g", + "type": "host" + }, + "destinations": [ + "ch8i4ug6lnn4g9h7v7m0" + ], + "destinationResource": { + "id": "chacdk86lnnboviihd7g", + "type": "host" + } + } + ] +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` + + +```json {{ title: 'Example' }} +{ + "name": "ch8i4ug6lnn4g9hqv7mg", + "description": "This is a default policy that allows connections between all the resources", + "enabled": true, + "id": "ch8i4ug6lnn4g9hqv7mg", + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], + "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": [ + { + "start": 80, + "end": 320 + } + ], + "id": "ch8i4ug6lnn4g9hqv7mg", + "sources": [ + { + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api" + } + ], + "sourceResource": { + "id": "chacdk86lnnboviihd7g", + "type": "host" + }, + "destinations": [ + { + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api" + } + ], + "destinationResource": { + "id": "chacdk86lnnboviihd7g", + "type": "host" + } + } + ] +} +``` + +```json {{ title: 'Schema' }} +{ + "name": "string", + "description": "string", + "enabled": "boolean", + "id": "string", + "source_posture_checks": [ + "string" + ], + "rules": [ + { + "name": "string", + "description": "string", + "enabled": "boolean", + "action": "string", + "bidirectional": "boolean", + "protocol": "string", + "ports": [ + "string" + ], + "port_ranges": [ + { + "start": "integer", + "end": "integer" + } + ], + "id": "string", + "sources": [ + { + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string" + } + ], + "sourceResource": { + "id": "string", + "type": "string" + }, + "destinations": [ + { + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string" + } + ], + "destinationResource": { + "id": "string", + "type": "string" + } + } + ] +} +``` + + + + + + +--- + + + +## Retrieve a Policy {{ tag: 'GET', label: '/api/policies/{policyId}' }} + + + + +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 {{ title: 'JavaScript' }} +const axios = require('axios'); + +let config = { + method: 'get', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/policies/{policyId}', + 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/policies/{policyId}" + +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/policies/{policyId}" + 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/policies/{policyId}") + +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/policies/{policyId}") + .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/policies/{policyId}', + 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' }} +{ + "name": "ch8i4ug6lnn4g9hqv7mg", + "description": "This is a default policy that allows connections between all the resources", + "enabled": true, + "id": "ch8i4ug6lnn4g9hqv7mg", + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], + "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": [ + { + "start": 80, + "end": 320 + } + ], + "id": "ch8i4ug6lnn4g9hqv7mg", + "sources": [ + { + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api" + } + ], + "sourceResource": { + "id": "chacdk86lnnboviihd7g", + "type": "host" + }, + "destinations": [ + { + "id": "ch8i4ug6lnn4g9hqv7m0", + "name": "devs", + "peers_count": 2, + "resources_count": 5, + "issued": "api" + } + ], + "destinationResource": { + "id": "chacdk86lnnboviihd7g", + "type": "host" + } + } + ] +} +``` + +```json {{ title: 'Schema' }} +{ + "name": "string", + "description": "string", + "enabled": "boolean", + "id": "string", + "source_posture_checks": [ + "string" + ], + "rules": [ + { + "name": "string", + "description": "string", + "enabled": "boolean", + "action": "string", + "bidirectional": "boolean", + "protocol": "string", + "ports": [ + "string" + ], + "port_ranges": [ + { + "start": "integer", + "end": "integer" + } + ], + "id": "string", + "sources": [ + { + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string" + } + ], + "sourceResource": { + "id": "string", + "type": "string" + }, + "destinations": [ + { + "id": "string", + "name": "string", + "peers_count": "integer", + "resources_count": "integer", + "issued": "string" + } + ], + "destinationResource": { + "id": "string", + "type": "string" + } + } + ] +} +``` + + + + + + +--- + + + +## Update a Policy {{ tag: 'PUT', label: '/api/policies/{policyId}' }} + + + + +Update/Replace a Policy + +### Path Parameters + + + + +The unique identifier of a policy @@ -666,72 +1330,455 @@ 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' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ + "name": "ch8i4ug6lnn4g9hqv7mg", + "description": "This is a default policy that allows connections between all the resources", + "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], + "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": [ + { + "start": 80, + "end": 320 + } + ], + "id": "ch8i4ug6lnn4g9hqv7mg", + "sources": [ + "ch8i4ug6lnn4g9hqv797" + ], + "sourceResource": { + "id": "chacdk86lnnboviihd7g", + "type": "host" + }, + "destinations": [ + "ch8i4ug6lnn4g9h7v7m0" + ], + "destinationResource": { + "id": "chacdk86lnnboviihd7g", + "type": "host" + } + } + ] +}' +``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "name": "ch8i4ug6lnn4g9hqv7mg", + "description": "This is a default policy that allows connections between all the resources", + "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], + "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": [ + { + "start": 80, + "end": 320 + } + ], + "id": "ch8i4ug6lnn4g9hqv7mg", + "sources": [ + "ch8i4ug6lnn4g9hqv797" + ], + "sourceResource": { + "id": "chacdk86lnnboviihd7g", + "type": "host" + }, + "destinations": [ + "ch8i4ug6lnn4g9h7v7m0" + ], + "destinationResource": { + "id": "chacdk86lnnboviihd7g", + "type": "host" + } + } + ] +}); +let config = { + method: 'put', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/policies/{policyId}', + 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 {{ title: 'Python' }} +import requests +import json -
+url = "https://api.netbird.io/api/policies/{policyId}" +payload = json.dumps({ + "name": "ch8i4ug6lnn4g9hqv7mg", + "description": "This is a default policy that allows connections between all the resources", + "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], + "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": [ + { + "start": 80, + "end": 320 + } + ], + "id": "ch8i4ug6lnn4g9hqv7mg", + "sources": [ + "ch8i4ug6lnn4g9hqv797" + ], + "sourceResource": { + "id": "chacdk86lnnboviihd7g", + "type": "host" + }, + "destinations": [ + "ch8i4ug6lnn4g9h7v7m0" + ], + "destinationResource": { + "id": "chacdk86lnnboviihd7g", + "type": "host" + } + } + ] +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} - - -Policy rule ID - - -Policy rule source group IDs - - -
+response = requests.request("PUT", url, headers=headers, data=payload) -More Information - - -ID of the resource - - -Network resource type based of the address - +print(response.text) +``` - +```go {{ title: 'Go' }} +package main -
+import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) -
- -Policy rule destination group IDs - - -
+func main() { -More Information - - -ID of the resource - - -Network resource type based of the address - + url := "https://api.netbird.io/api/policies/{policyId}" + method := "PUT" + + payload := strings.NewReader({ + "name": "ch8i4ug6lnn4g9hqv7mg", + "description": "This is a default policy that allows connections between all the resources", + "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], + "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": [ + { + "start": 80, + "end": 320 + } + ], + "id": "ch8i4ug6lnn4g9hqv7mg", + "sources": [ + "ch8i4ug6lnn4g9hqv797" + ], + "sourceResource": { + "id": "chacdk86lnnboviihd7g", + "type": "host" + }, + "destinations": [ + "ch8i4ug6lnn4g9h7v7m0" + ], + "destinationResource": { + "id": "chacdk86lnnboviihd7g", + "type": "host" + } + } + ] +}) + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" -
+url = URI("https://api.netbird.io/api/policies/{policyId}") - +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({ + "name": "ch8i4ug6lnn4g9hqv7mg", + "description": "This is a default policy that allows connections between all the resources", + "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], + "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": [ + { + "start": 80, + "end": 320 + } + ], + "id": "ch8i4ug6lnn4g9hqv7mg", + "sources": [ + "ch8i4ug6lnn4g9hqv797" + ], + "sourceResource": { + "id": "chacdk86lnnboviihd7g", + "type": "host" + }, + "destinations": [ + "ch8i4ug6lnn4g9h7v7m0" + ], + "destinationResource": { + "id": "chacdk86lnnboviihd7g", + "type": "host" + } + } + ] +}) +response = https.request(request) +puts response.read_body +``` - +```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" + ], + "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": [ + { + "start": 80, + "end": 320 + } + ], + "id": "ch8i4ug6lnn4g9hqv7mg", + "sources": [ + "ch8i4ug6lnn4g9hqv797" + ], + "sourceResource": { + "id": "chacdk86lnnboviihd7g", + "type": "host" + }, + "destinations": [ + "ch8i4ug6lnn4g9h7v7m0" + ], + "destinationResource": { + "id": "chacdk86lnnboviihd7g", + "type": "host" + } + } + ] +}'); +Request request = new Request.Builder() + .url("https://api.netbird.io/api/policies/{policyId}") + .method("PUT", body) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") + .build(); +Response response = client.newCall(request).execute(); +``` - - - -```bash {{ title: 'cURL' }} -curl -X PUT https://api.netbird.io/api/policies/{policyId} \ --H 'Authorization: Token ' \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ ---data-raw '{ +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/policies/{policyId}', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'PUT', + CURLOPT_POSTFIELDS => '{ "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, @@ -772,7 +1819,18 @@ curl -X PUT https://api.netbird.io/api/policies/{policyId} \ } } ] -}' +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; ``` @@ -923,7 +1981,131 @@ 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 +const axios = require('axios'); + +let config = { + method: 'delete', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/policies/{policyId}', + 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/policies/{policyId}" + +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/policies/{policyId}" + 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/policies/{policyId}") + +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/policies/{policyId}") + .method("DELETE", null) + .addHeader("Authorization", "Token ") + .build(); + +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/policies/{policyId}', + 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/posture-checks.mdx b/src/pages/ipa/resources/posture-checks.mdx index ffbdd696..249f03b0 100644 --- a/src/pages/ipa/resources/posture-checks.mdx +++ b/src/pages/ipa/resources/posture-checks.mdx @@ -15,6 +15,141 @@ curl -X GET https://api.netbird.io/api/posture-checks \ -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/posture-checks', + 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/posture-checks" + +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/posture-checks" + 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/posture-checks") + +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/posture-checks") + .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/posture-checks', + 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' }} @@ -350,9 +485,9 @@ 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 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "name": "Default", "description": "This checks if the peer is running required NetBird's version", @@ -406,11 +541,10 @@ curl -X POST https://api.netbird.io/api/posture-checks \ } }' ``` - - -```json {{ title: 'Example' }} -{ - "id": "ch8i4ug6lnn4g9hqv7mg", + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ "name": "Default", "description": "This checks if the peer is running required NetBird's version", "checks": { @@ -461,102 +595,207 @@ curl -X POST https://api.netbird.io/api/posture-checks \ ] } } -} +}); +let config = { + method: 'post', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/posture-checks', + 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); +}); ``` -```json {{ title: 'Schema' }} -{ - "id": "string", - "name": "string", - "description": "string", +```python {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/posture-checks" +payload = json.dumps({ + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", "checks": { "nb_version_check": { - "min_version": "string" + "min_version": "14.3" }, "os_version_check": { "android": { - "min_version": "string" - }, - "darwin": { - "min_version": "string" + "min_version": "13" }, "ios": { - "min_version": "string" + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" }, "linux": { - "min_kernel_version": "string" + "min_kernel_version": "5.3.3" }, "windows": { - "min_kernel_version": "string" + "min_kernel_version": "10.0.1234" } }, "geo_location_check": { "locations": [ { - "country_code": "string", - "city_name": "string" + "country_code": "DE", + "city_name": "Berlin" } ], - "action": "string" + "action": "allow" }, "peer_network_range_check": { "ranges": [ - "string" + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" ], - "action": "string" + "action": "allow" }, "process_check": { "processes": [ { - "linux_path": "string", - "mac_path": "string", - "windows_path": "string" + "linux_path": "/usr/local/bin/netbird", + "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", + "windows_path": "C:
rogramData…etBird\netbird.exe" } ] } } +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' } -``` - - - - +response = requests.request("POST", url, headers=headers, data=payload) ---- +print(response.text) +``` +```go {{ title: 'Go' }} +package main +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) -## Retrieve a Posture Check {{ tag: 'GET', label: '/api/posture-checks/{postureCheckId}' }} +func main() { + url := "https://api.netbird.io/api/posture-checks" + method := "POST" + + payload := strings.NewReader(`{ + "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" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ], + "action": "allow" + }, + "process_check": { + "processes": [ + { + "linux_path": "/usr/local/bin/netbird", + "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", + "windows_path": "C:
rogramData…etBird\netbird.exe" + } + ] + } + } +}`) + 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() - - -Get information about a posture check + resBody, err := ioutil.ReadAll(res.Body) + if err != nil { + fmt.Println(err) + return + } + fmt.Println(string(resBody)) +} +``` -### Path Parameters +```ruby {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" +url = URI("https://api.netbird.io/api/posture-checks") - - -The unique identifier of a posture check - +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 " - - - -```bash {{ title: 'cURL' }} -curl -X GET https://api.netbird.io/api/posture-checks/{postureCheckId} \ --H 'Accept: application/json' \ --H 'Authorization: Token ' -``` - - -```json {{ title: 'Example' }} -{ - "id": "ch8i4ug6lnn4g9hqv7mg", +request.body = JSON.dump({ "name": "Default", "description": "This checks if the peer is running required NetBird's version", "checks": { @@ -607,95 +846,580 @@ curl -X GET https://api.netbird.io/api/posture-checks/{postureCheckId} \ ] } } -} +}) +response = https.request(request) +puts response.read_body ``` -```json {{ title: 'Schema' }} -{ - "id": "string", - "name": "string", - "description": "string", +```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\" + }, + \"os_version_check\": { + \"android\": { + \"min_version\": \"13\" + }, + \"ios\": { + \"min_version\": \"17.3.1\" + }, + \"darwin\": { + \"min_version\": \"14.2.1\" + }, + \"linux\": { + \"min_kernel_version\": \"5.3.3\" + }, + \"windows\": { + \"min_kernel_version\": \"10.0.1234\" + } + }, + \"geo_location_check\": { + \"locations\": [ + { + \"country_code\": \"DE\", + \"city_name\": \"Berlin\" + } + ], + \"action\": \"allow\" + }, + \"peer_network_range_check\": { + \"ranges\": [ + \"192.168.1.0/24\", + \"10.0.0.0/8\", + \"2001:db8:1234:1a00::/56\" + ], + \"action\": \"allow\" + }, + \"process_check\": { + \"processes\": [ + { + \"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 ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/posture-checks', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS => '{ + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", "checks": { "nb_version_check": { - "min_version": "string" + "min_version": "14.3" }, "os_version_check": { "android": { - "min_version": "string" - }, - "darwin": { - "min_version": "string" + "min_version": "13" }, "ios": { - "min_version": "string" + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" }, "linux": { - "min_kernel_version": "string" + "min_kernel_version": "5.3.3" }, "windows": { - "min_kernel_version": "string" + "min_kernel_version": "10.0.1234" } }, "geo_location_check": { "locations": [ { - "country_code": "string", - "city_name": "string" + "country_code": "DE", + "city_name": "Berlin" } ], - "action": "string" + "action": "allow" }, "peer_network_range_check": { "ranges": [ - "string" + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" ], - "action": "string" + "action": "allow" }, "process_check": { "processes": [ { - "linux_path": "string", - "mac_path": "string", - "windows_path": "string" + "linux_path": "/usr/local/bin/netbird", + "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", + "windows_path": "C:
rogramData…etBird\netbird.exe" } ] } } -} +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; ``` - - - - - ---- - - - -## 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 - - - - + +```json {{ title: 'Example' }} +{ + "id": "ch8i4ug6lnn4g9hqv7mg", + "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" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ], + "action": "allow" + }, + "process_check": { + "processes": [ + { + "linux_path": "/usr/local/bin/netbird", + "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", + "windows_path": "C:
rogramData…etBird\netbird.exe" + } + ] + } + } +} +``` + +```json {{ title: 'Schema' }} +{ + "id": "string", + "name": "string", + "description": "string", + "checks": { + "nb_version_check": { + "min_version": "string" + }, + "os_version_check": { + "android": { + "min_version": "string" + }, + "darwin": { + "min_version": "string" + }, + "ios": { + "min_version": "string" + }, + "linux": { + "min_kernel_version": "string" + }, + "windows": { + "min_kernel_version": "string" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "string", + "city_name": "string" + } + ], + "action": "string" + }, + "peer_network_range_check": { + "ranges": [ + "string" + ], + "action": "string" + }, + "process_check": { + "processes": [ + { + "linux_path": "string", + "mac_path": "string", + "windows_path": "string" + } + ] + } + } +} +``` + + + + + + +--- + + + +## 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 + + + + + + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/posture-checks/{postureCheckId} \ +-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/posture-checks/{postureCheckId}', + 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/posture-checks/{postureCheckId}" + +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/posture-checks/{postureCheckId}" + 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/posture-checks/{postureCheckId}") + +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/posture-checks/{postureCheckId}") + .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/posture-checks/{postureCheckId}', + 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": "ch8i4ug6lnn4g9hqv7mg", + "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" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ], + "action": "allow" + }, + "process_check": { + "processes": [ + { + "linux_path": "/usr/local/bin/netbird", + "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", + "windows_path": "C:
rogramData…etBird\netbird.exe" + } + ] + } + } +} +``` + +```json {{ title: 'Schema' }} +{ + "id": "string", + "name": "string", + "description": "string", + "checks": { + "nb_version_check": { + "min_version": "string" + }, + "os_version_check": { + "android": { + "min_version": "string" + }, + "darwin": { + "min_version": "string" + }, + "ios": { + "min_version": "string" + }, + "linux": { + "min_kernel_version": "string" + }, + "windows": { + "min_kernel_version": "string" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "string", + "city_name": "string" + } + ], + "action": "string" + }, + "peer_network_range_check": { + "ranges": [ + "string" + ], + "action": "string" + }, + "process_check": { + "processes": [ + { + "linux_path": "string", + "mac_path": "string", + "windows_path": "string" + } + ] + } + } +} +``` + + + + + + +--- + + + +## 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 @@ -848,56 +1572,499 @@ 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' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ + "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" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ], + "action": "allow" + }, + "process_check": { + "processes": [ + { + "linux_path": "/usr/local/bin/netbird", + "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", + "windows_path": "C:
rogramData…etBird\netbird.exe" + } + ] + } + } +}' +``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "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" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ], + "action": "allow" + }, + "process_check": { + "processes": [ + { + "linux_path": "/usr/local/bin/netbird", + "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", + "windows_path": "C:
rogramData…etBird\netbird.exe" + } + ] + } + } +}); +let config = { + method: 'put', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/posture-checks/{postureCheckId}', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/posture-checks/{postureCheckId}" +payload = json.dumps({ + "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" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ], + "action": "allow" + }, + "process_check": { + "processes": [ + { + "linux_path": "/usr/local/bin/netbird", + "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", + "windows_path": "C:
rogramData…etBird\netbird.exe" + } + ] + } + } +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("PUT", url, headers=headers, data=payload) -Posture Check for binaries exist and are running in the peer’s system - - -
+print(response.text) +``` -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 - +```go {{ title: 'Go' }} +package main - +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) -
+func main() { -
+ url := "https://api.netbird.io/api/posture-checks/{postureCheckId}" + method := "PUT" + + payload := strings.NewReader({ + "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" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ], + "action": "allow" + }, + "process_check": { + "processes": [ + { + "linux_path": "/usr/local/bin/netbird", + "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", + "windows_path": "C:
rogramData…etBird\netbird.exe" + } + ] + } + } +}) + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" -
+url = URI("https://api.netbird.io/api/posture-checks/{postureCheckId}") - +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({ + "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" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ], + "action": "allow" + }, + "process_check": { + "processes": [ + { + "linux_path": "/usr/local/bin/netbird", + "mac_path": "/Applications/NetBird.app/Contents/MacOS/netbird", + "windows_path": "C:
rogramData…etBird\netbird.exe" + } + ] + } + } +}) +response = https.request(request) +puts response.read_body +``` - +```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" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ], + "action": "allow" + }, + "process_check": { + "processes": [ + { + "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/{postureCheckId}") + .method("PUT", body) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") + .build(); +Response response = client.newCall(request).execute(); +``` - - - -```bash {{ title: 'cURL' }} -curl -X PUT https://api.netbird.io/api/posture-checks/{postureCheckId} \ --H 'Authorization: Token ' \ --H 'Accept: application/json' \ --H 'Content-Type: application/json' \ ---data-raw '{ +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/posture-checks/{postureCheckId}', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'PUT', + CURLOPT_POSTFIELDS => '{ "name": "Default", "description": "This checks if the peer is running required NetBird's version", "checks": { @@ -948,7 +2115,18 @@ curl -X PUT https://api.netbird.io/api/posture-checks/{postureCheckId} \ ] } } -}' +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; ``` @@ -1093,7 +2271,131 @@ 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 +const axios = require('axios'); + +let config = { + method: 'delete', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/posture-checks/{postureCheckId}', + 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/posture-checks/{postureCheckId}" + +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/posture-checks/{postureCheckId}" + 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/posture-checks/{postureCheckId}") + +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/posture-checks/{postureCheckId}") + .method("DELETE", null) + .addHeader("Authorization", "Token ") + .build(); + +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/posture-checks/{postureCheckId}', + 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/routes.mdx b/src/pages/ipa/resources/routes.mdx index a760e696..61b9e0da 100644 --- a/src/pages/ipa/resources/routes.mdx +++ b/src/pages/ipa/resources/routes.mdx @@ -15,6 +15,141 @@ curl -X GET https://api.netbird.io/api/routes \ -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/routes', + 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/routes" + +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/routes" + method := "GET" + + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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/routes") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Get.new(url) +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +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/routes") + .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/routes', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'GET', + CURLOPT_HTTPHEADER => array( + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -144,9 +279,9 @@ Indicate if this exit node route (0.0.0.0/0) should skip auto-application for cl ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/routes \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "description": "My first route", "network_id": "Route 1", @@ -171,6 +306,286 @@ curl -X POST https://api.netbird.io/api/routes \ "skip_auto_apply": false }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "description": "My first route", + "network_id": "Route 1", + "enabled": true, + "peer": "chacbco6lnnbn6cg5s91", + "peer_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "network": "10.64.0.0/24", + "domains": [ + "example.com" + ], + "metric": 9999, + "masquerade": true, + "groups": [ + "chacdk86lnnboviihd70" + ], + "keep_route": true, + "access_control_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "skip_auto_apply": false +}); +let config = { + method: 'post', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/routes', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/routes" +payload = json.dumps({ + "description": "My first route", + "network_id": "Route 1", + "enabled": true, + "peer": "chacbco6lnnbn6cg5s91", + "peer_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "network": "10.64.0.0/24", + "domains": [ + "example.com" + ], + "metric": 9999, + "masquerade": true, + "groups": [ + "chacdk86lnnboviihd70" + ], + "keep_route": true, + "access_control_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "skip_auto_apply": false +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("POST", url, headers=headers, data=payload) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/routes" + method := "POST" + + payload := strings.NewReader(`{ + "description": "My first route", + "network_id": "Route 1", + "enabled": true, + "peer": "chacbco6lnnbn6cg5s91", + "peer_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "network": "10.64.0.0/24", + "domains": [ + "example.com" + ], + "metric": 9999, + "masquerade": true, + "groups": [ + "chacdk86lnnboviihd70" + ], + "keep_route": true, + "access_control_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "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") + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/routes") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Post.new(url) +request["Content-Type"] = "application/json" +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +request.body = JSON.dump({ + "description": "My first route", + "network_id": "Route 1", + "enabled": true, + "peer": "chacbco6lnnbn6cg5s91", + "peer_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "network": "10.64.0.0/24", + "domains": [ + "example.com" + ], + "metric": 9999, + "masquerade": true, + "groups": [ + "chacdk86lnnboviihd70" + ], + "keep_route": true, + "access_control_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "skip_auto_apply": false +}) +response = https.request(request) +puts response.read_body +``` + +```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\" + ], + \"network\": \"10.64.0.0/24\", + \"domains\": [ + \"example.com\" + ], + \"metric\": 9999, + \"masquerade\": true, + \"groups\": [ + \"chacdk86lnnboviihd70\" + ], + \"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 ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/routes', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS => '{ + "description": "My first route", + "network_id": "Route 1", + "enabled": true, + "peer": "chacbco6lnnbn6cg5s91", + "peer_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "network": "10.64.0.0/24", + "domains": [ + "example.com" + ], + "metric": 9999, + "masquerade": true, + "groups": [ + "chacdk86lnnboviihd70" + ], + "keep_route": true, + "access_control_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "skip_auto_apply": false +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -263,6 +678,141 @@ curl -X GET https://api.netbird.io/api/routes/{routeId} \ -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/routes/{routeId}', + 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/routes/{routeId}" + +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/routes/{routeId}" + method := "GET" + + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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/routes/{routeId}") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Get.new(url) +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +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/routes/{routeId}") + .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/routes/{routeId}', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'GET', + CURLOPT_HTTPHEADER => array( + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -399,9 +949,9 @@ Indicate if this exit node route (0.0.0.0/0) should skip auto-application for cl ```bash {{ title: 'cURL' }} curl -X PUT https://api.netbird.io/api/routes/{routeId} \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "description": "My first route", "network_id": "Route 1", @@ -426,6 +976,286 @@ curl -X PUT https://api.netbird.io/api/routes/{routeId} \ "skip_auto_apply": false }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "description": "My first route", + "network_id": "Route 1", + "enabled": true, + "peer": "chacbco6lnnbn6cg5s91", + "peer_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "network": "10.64.0.0/24", + "domains": [ + "example.com" + ], + "metric": 9999, + "masquerade": true, + "groups": [ + "chacdk86lnnboviihd70" + ], + "keep_route": true, + "access_control_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "skip_auto_apply": false +}); +let config = { + method: 'put', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/routes/{routeId}', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/routes/{routeId}" +payload = json.dumps({ + "description": "My first route", + "network_id": "Route 1", + "enabled": true, + "peer": "chacbco6lnnbn6cg5s91", + "peer_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "network": "10.64.0.0/24", + "domains": [ + "example.com" + ], + "metric": 9999, + "masquerade": true, + "groups": [ + "chacdk86lnnboviihd70" + ], + "keep_route": true, + "access_control_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "skip_auto_apply": false +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("PUT", url, headers=headers, data=payload) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/routes/{routeId}" + method := "PUT" + + payload := strings.NewReader({ + "description": "My first route", + "network_id": "Route 1", + "enabled": true, + "peer": "chacbco6lnnbn6cg5s91", + "peer_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "network": "10.64.0.0/24", + "domains": [ + "example.com" + ], + "metric": 9999, + "masquerade": true, + "groups": [ + "chacdk86lnnboviihd70" + ], + "keep_route": true, + "access_control_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "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") + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/routes/{routeId}") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Put.new(url) +request["Content-Type"] = "application/json" +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +request.body = JSON.dump({ + "description": "My first route", + "network_id": "Route 1", + "enabled": true, + "peer": "chacbco6lnnbn6cg5s91", + "peer_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "network": "10.64.0.0/24", + "domains": [ + "example.com" + ], + "metric": 9999, + "masquerade": true, + "groups": [ + "chacdk86lnnboviihd70" + ], + "keep_route": true, + "access_control_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "skip_auto_apply": false +}) +response = https.request(request) +puts response.read_body +``` + +```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" + ], + "network": "10.64.0.0/24", + "domains": [ + "example.com" + ], + "metric": 9999, + "masquerade": true, + "groups": [ + "chacdk86lnnboviihd70" + ], + "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 ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/routes/{routeId}', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'PUT', + CURLOPT_POSTFIELDS => '{ + "description": "My first route", + "network_id": "Route 1", + "enabled": true, + "peer": "chacbco6lnnbn6cg5s91", + "peer_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "network": "10.64.0.0/24", + "domains": [ + "example.com" + ], + "metric": 9999, + "masquerade": true, + "groups": [ + "chacdk86lnnboviihd70" + ], + "keep_route": true, + "access_control_groups": [ + "chacbco6lnnbn6cg5s91" + ], + "skip_auto_apply": false +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -515,7 +1345,131 @@ 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 +const axios = require('axios'); + +let config = { + method: 'delete', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/routes/{routeId}', + 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/routes/{routeId}" + +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/routes/{routeId}" + method := "DELETE" + + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Authorization", "Token ") + + 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/routes/{routeId}") + +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/routes/{routeId}") + .method("DELETE", null) + .addHeader("Authorization", "Token ") + .build(); + +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/routes/{routeId}', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'DELETE', + CURLOPT_HTTPHEADER => array( + 'Authorization: Token ' + ), +)); + +$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 30afba01..84c71b93 100644 --- a/src/pages/ipa/resources/setup-keys.mdx +++ b/src/pages/ipa/resources/setup-keys.mdx @@ -15,6 +15,141 @@ curl -X GET https://api.netbird.io/api/setup-keys \ -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/setup-keys', + 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/setup-keys" + +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/setup-keys" + method := "GET" + + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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/setup-keys") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Get.new(url) +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +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/setup-keys") + .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/setup-keys', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'GET', + CURLOPT_HTTPHEADER => array( + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -114,9 +249,9 @@ Allow extra DNS labels to be added to the peer ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/setup-keys \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "name": "Default key", "type": "reusable", @@ -129,6 +264,214 @@ curl -X POST https://api.netbird.io/api/setup-keys \ "allow_extra_dns_labels": true }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "name": "Default key", + "type": "reusable", + "expires_in": 86400, + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "usage_limit": 0, + "ephemeral": true, + "allow_extra_dns_labels": true +}); +let config = { + method: 'post', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/setup-keys', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/setup-keys" +payload = json.dumps({ + "name": "Default key", + "type": "reusable", + "expires_in": 86400, + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "usage_limit": 0, + "ephemeral": true, + "allow_extra_dns_labels": true +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("POST", url, headers=headers, data=payload) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/setup-keys" + method := "POST" + + payload := strings.NewReader(`{ + "name": "Default key", + "type": "reusable", + "expires_in": 86400, + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "usage_limit": 0, + "ephemeral": true, + "allow_extra_dns_labels": true +}`) + client := &http.Client{} + req, err := http.NewRequest(method, url, payload) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Content-Type", "application/json") + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/setup-keys") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Post.new(url) +request["Content-Type"] = "application/json" +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +request.body = JSON.dump({ + "name": "Default key", + "type": "reusable", + "expires_in": 86400, + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "usage_limit": 0, + "ephemeral": true, + "allow_extra_dns_labels": true +}) +response = https.request(request) +puts response.read_body +``` + +```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\" + ], + \"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 ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/setup-keys', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS => '{ + "name": "Default key", + "type": "reusable", + "expires_in": 86400, + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "usage_limit": 0, + "ephemeral": true, + "allow_extra_dns_labels": true +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -209,6 +552,141 @@ curl -X GET https://api.netbird.io/api/setup-keys/{keyId} \ -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/setup-keys/{keyId}', + 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/setup-keys/{keyId}" + +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/setup-keys/{keyId}" + method := "GET" + + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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/setup-keys/{keyId}") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Get.new(url) +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +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/setup-keys/{keyId}") + .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/setup-keys/{keyId}', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'GET', + CURLOPT_HTTPHEADER => array( + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -300,9 +778,9 @@ 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 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "revoked": false, "auto_groups": [ @@ -310,6 +788,184 @@ curl -X PUT https://api.netbird.io/api/setup-keys/{keyId} \ ] }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "revoked": false, + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ] +}); +let config = { + method: 'put', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/setup-keys/{keyId}', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/setup-keys/{keyId}" +payload = json.dumps({ + "revoked": false, + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ] +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("PUT", url, headers=headers, data=payload) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/setup-keys/{keyId}" + method := "PUT" + + payload := strings.NewReader({ + "revoked": false, + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ] +}) + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/setup-keys/{keyId}") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Put.new(url) +request["Content-Type"] = "application/json" +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +request.body = JSON.dump({ + "revoked": false, + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ] +}) +response = https.request(request) +puts response.read_body +``` + +```java {{ title: 'Java' }} +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); +MediaType mediaType = MediaType.parse("application/json"); +RequestBody body = RequestBody.create(mediaType, '{ + "revoked": false, + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ] +}'); +Request request = new Request.Builder() + .url("https://api.netbird.io/api/setup-keys/{keyId}") + .method("PUT", body) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/setup-keys/{keyId}', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'PUT', + CURLOPT_POSTFIELDS => '{ + "revoked": false, + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ] +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -387,7 +1043,131 @@ 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 +const axios = require('axios'); + +let config = { + method: 'delete', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/setup-keys/{keyId}', + 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/setup-keys/{keyId}" + +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/setup-keys/{keyId}" + 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/setup-keys/{keyId}") + +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/setup-keys/{keyId}") + .method("DELETE", null) + .addHeader("Authorization", "Token ") + .build(); + +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/setup-keys/{keyId}', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => '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 aa39809b..4dbb3e6d 100644 --- a/src/pages/ipa/resources/tokens.mdx +++ b/src/pages/ipa/resources/tokens.mdx @@ -26,6 +26,141 @@ curl -X GET https://api.netbird.io/api/users/{userId}/tokens \ -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/{userId}/tokens', + 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/{userId}/tokens" + +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/{userId}/tokens" + method := "GET" + + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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/{userId}/tokens") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Get.new(url) +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +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/{userId}/tokens") + .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/{userId}/tokens', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'GET', + CURLOPT_HTTPHEADER => array( + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -99,14 +234,180 @@ Expiration in days ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/users/{userId}/tokens \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "name": "My first token", "expires_in": 30 }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "name": "My first token", + "expires_in": 30 +}); +let config = { + method: 'post', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/users/{userId}/tokens', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/users/{userId}/tokens" +payload = json.dumps({ + "name": "My first token", + "expires_in": 30 +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("POST", url, headers=headers, data=payload) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/users/{userId}/tokens" + method := "POST" + + payload := strings.NewReader(`{ + "name": "My first token", + "expires_in": 30 +}`) + client := &http.Client{} + req, err := http.NewRequest(method, url, payload) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Content-Type", "application/json") + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/users/{userId}/tokens") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Post.new(url) +request["Content-Type"] = "application/json" +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +request.body = JSON.dump({ + "name": "My first token", + "expires_in": 30 +}) +response = https.request(request) +puts response.read_body +``` + +```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 +}"); +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 ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/users/{userId}/tokens', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS => '{ + "name": "My first token", + "expires_in": 30 +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -174,6 +475,141 @@ curl -X GET https://api.netbird.io/api/users/{userId}/tokens/{tokenId} \ -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/{userId}/tokens/{tokenId}', + 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/{userId}/tokens/{tokenId}" + +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/{userId}/tokens/{tokenId}" + method := "GET" + + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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/{userId}/tokens/{tokenId}") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Get.new(url) +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +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/{userId}/tokens/{tokenId}") + .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/{userId}/tokens/{tokenId}', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'GET', + CURLOPT_HTTPHEADER => array( + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -232,7 +668,131 @@ 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 +const axios = require('axios'); + +let config = { + method: 'delete', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/users/{userId}/tokens/{tokenId}', + 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}/tokens/{tokenId}" + +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}/tokens/{tokenId}" + method := "DELETE" + + client := &http.Client{} + req, err := http.NewRequest(method, url, nil) + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Authorization", "Token ") + + 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}/tokens/{tokenId}") + +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}/tokens/{tokenId}") + .method("DELETE", null) + .addHeader("Authorization", "Token ") + .build(); + +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/users/{userId}/tokens/{tokenId}', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'DELETE', + CURLOPT_HTTPHEADER => array( + 'Authorization: Token ' + ), +)); + +$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 db9e6406..900beb0d 100644 --- a/src/pages/ipa/resources/users.mdx +++ b/src/pages/ipa/resources/users.mdx @@ -26,6 +26,141 @@ curl -X GET https://api.netbird.io/api/users \ -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', + 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" + +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" + 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") + +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") + .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', + 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' }} @@ -154,9 +289,9 @@ Is true if this user is a service user ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/users \ --H 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "email": "demo@netbird.io", "name": "Tom Schulz", @@ -167,6 +302,202 @@ curl -X POST https://api.netbird.io/api/users \ "is_service_user": false }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "email": "demo@netbird.io", + "name": "Tom Schulz", + "role": "admin", + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "is_service_user": false +}); +let config = { + method: 'post', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/users', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/users" +payload = json.dumps({ + "email": "demo@netbird.io", + "name": "Tom Schulz", + "role": "admin", + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "is_service_user": false +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("POST", url, headers=headers, data=payload) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/users" + method := "POST" + + payload := strings.NewReader(`{ + "email": "demo@netbird.io", + "name": "Tom Schulz", + "role": "admin", + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "is_service_user": false +}`) + client := &http.Client{} + req, err := http.NewRequest(method, url, payload) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Content-Type", "application/json") + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/users") + +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({ + "email": "demo@netbird.io", + "name": "Tom Schulz", + "role": "admin", + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "is_service_user": false +}) +response = https.request(request) +puts response.read_body +``` + +```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\" + ], + \"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 ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/users', + 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 => '{ + "email": "demo@netbird.io", + "name": "Tom Schulz", + "role": "admin", + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "is_service_user": false +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -296,9 +627,9 @@ 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 'Authorization: Token ' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ --data-raw '{ "role": "admin", "auto_groups": [ @@ -307,6 +638,190 @@ curl -X PUT https://api.netbird.io/api/users/{userId} \ "is_blocked": false }' ``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({ + "role": "admin", + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "is_blocked": false +}); +let config = { + method: 'put', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/users/{userId}', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/users/{userId}" +payload = json.dumps({ + "role": "admin", + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "is_blocked": false +}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("PUT", url, headers=headers, data=payload) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/users/{userId}" + method := "PUT" + + payload := strings.NewReader({ + "role": "admin", + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "is_blocked": false +}) + client := &http.Client{} + req, err := http.NewRequest(method, url, payload) + + if err != nil { + fmt.Println(err) + return + } + + req.Header.Add("Content-Type", "application/json") + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/users/{userId}") + +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({ + "role": "admin", + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "is_blocked": false +}) +response = https.request(request) +puts response.read_body +``` + +```java {{ title: 'Java' }} +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); +MediaType mediaType = MediaType.parse("application/json"); +RequestBody body = RequestBody.create(mediaType, '{ + "role": "admin", + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "is_blocked": false +}'); +Request request = new Request.Builder() + .url("https://api.netbird.io/api/users/{userId}") + .method("PUT", body) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/users/{userId}', + 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 => '{ + "role": "admin", + "auto_groups": [ + "ch8i4ug6lnn4g9hqv7m0" + ], + "is_blocked": false +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` ```json {{ title: 'Example' }} @@ -419,7 +934,131 @@ 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 +const axios = require('axios'); + +let config = { + method: 'delete', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/users/{userId}', + 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}" + +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}" + 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}") + +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}") + .method("DELETE", null) + .addHeader("Authorization", "Token ") + .build(); + +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/users/{userId}', + 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; ``` @@ -453,7 +1092,158 @@ The unique identifier of a user ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/users/{userId}/invite \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ -H 'Authorization: Token ' \ +--data-raw '{}' +``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({}); +let config = { + method: 'post', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/users/{userId}/invite', + 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 {{ title: 'Python' }} +import requests +import json + +url = "https://api.netbird.io/api/users/{userId}/invite" +payload = json.dumps({}) +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("POST", url, headers=headers, data=payload) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/users/{userId}/invite" + method := "POST" + + 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) + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/users/{userId}/invite") + +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 {{ 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", body) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + 'https://api.netbird.io/api/users/{userId}/invite', + 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 => '{}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; ``` @@ -487,7 +1277,158 @@ The unique identifier of a user ```bash {{ title: 'cURL' }} curl -X POST https://api.netbird.io/api/users/{userId}/approve \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ -H 'Authorization: Token ' \ +--data-raw '{}' +``` + +```js {{ title: 'JavaScript' }} +const axios = require('axios'); +let data = JSON.stringify({}); +let config = { + method: 'post', + maxBodyLength: Infinity, + url: 'https://api.netbird.io/api/users/{userId}/approve', + 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 {{ title: 'Python' }} +import requests +import json + +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("POST", url, headers=headers, data=payload) + +print(response.text) +``` + +```go {{ title: 'Go' }} +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/users/{userId}/approve" + method := "POST" + + 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) + 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 {{ title: 'Ruby' }} +require "uri" +require "json" +require "net/http" + +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::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 {{ 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}/approve") + .method("POST", body) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php {{ title: 'PHP' }} + '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 => 'POST', + CURLOPT_POSTFIELDS => '{}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; ``` @@ -601,7 +1542,131 @@ The unique identifier of a user ```bash {{ title: 'cURL' }} curl -X DELETE https://api.netbird.io/api/users/{userId}/reject \ --H 'Authorization: Token ' \ +-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; ``` @@ -627,6 +1692,141 @@ 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' }} From 1102f10396864561fedd357863ce45b14631905d Mon Sep 17 00:00:00 2001 From: aliamerj Date: Tue, 23 Sep 2025 22:20:53 +0300 Subject: [PATCH 5/5] fix java code --- openapi-gen/tsxParser/api/requests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openapi-gen/tsxParser/api/requests.ts b/openapi-gen/tsxParser/api/requests.ts index 6fbbcca0..1805fb49 100644 --- a/openapi-gen/tsxParser/api/requests.ts +++ b/openapi-gen/tsxParser/api/requests.ts @@ -421,7 +421,7 @@ func main() { url := "https://api.netbird.io${url}" method := "POST" - payload := strings.NewReader(\`${body}\`) + payload := strings.NewReader('${body}') client := &http.Client{} req, err := http.NewRequest(method, url, payload) @@ -476,7 +476,7 @@ puts response.read_body OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); -RequestBody body = RequestBody.create(mediaType, "${body.replace(/"/g, '\\"')}"); +RequestBody body = RequestBody.create(mediaType, '${body}'; Request request = new Request.Builder() .url("https://api.netbird.io${url}") .method("POST", body)