Change API parser to handle nested objects (#159)

* rewrite parser to handle new format and nested objects

* add properties section also to nested properties

* update docs manually
This commit is contained in:
pascal-fischer
2024-02-29 15:24:00 +02:00
committed by GitHub
parent 69cddadbe4
commit dd08a8e07d
23 changed files with 4242 additions and 1260 deletions

View File

@@ -1,17 +1,43 @@
import template from './templates/ApiTemplate' import template from './templates/ApiTemplate'
import { slugify, toArrayWithKey, toTitle, writeToDisk } from './helpers' import { slugify, toArrayWithKey, toTitle, writeToDisk } from './helpers'
import {OpenAPIV3} from 'openapi-types' import {OpenAPIV3, OpenAPIV3_1} from 'openapi-types'
import * as fs from 'fs' import * as fs from 'fs'
import * as ejs from 'ejs' import * as ejs from 'ejs'
import { spawn } from 'child_process';
import * as yaml from 'js-yaml';
import { merge } from 'allof-merge'
import RequestBodyObject = OpenAPIV3_1.RequestBodyObject;
const goExecutable = './generator/expandOpenAPIRef'
export default async function gen(inputFileName: string, outputDir: string) { export default async function gen(inputFileName: string, outputDir: string) {
// const args = [inputFileName];
// const process = spawn(goExecutable, args);
// process.stdout.on('data', (data) => {
// console.log(`Output: ${data}`);
// });
// process.stderr.on('data', (data) => {
// console.error(`Error: ${data}`);
// });
// process.on('close', (code) => {
// console.log(`Process exited with code ${code}`);
// });
// const specRaw = fs.readFileSync("generator/openapi/expanded.yml", 'utf8')
const specRaw = fs.readFileSync(inputFileName, 'utf8') const specRaw = fs.readFileSync(inputFileName, 'utf8')
const spec = JSON.parse(specRaw) as any // const spec = JSON.parse(specRaw) as any
const specYaml = yaml.load(specRaw);
const onMergeError = (msg) => {
throw new Error(msg)
}
const merged = merge(specYaml, { onMergeError })
switch (spec.openapi || spec.swagger) { const spec = merged as OpenAPIV3.Document
switch (spec.openapi) {
case '3.0.0': case '3.0.0':
case '3.0.1': case '3.0.1':
case '3.0.3': case '3.0.3':
case '3.1.0':
await gen_v3(spec, outputDir) await gen_v3(spec, outputDir)
break break
@@ -21,21 +47,23 @@ export default async function gen(inputFileName: string, outputDir: string) {
} }
} }
/**
* Versioned Generator
*/
// OPENAPI-SPEC-VERSION: 3.0.0
type v3OperationWithPath = OpenAPIV3.OperationObject & { type v3OperationWithPath = OpenAPIV3.OperationObject & {
path: string path: string
} }
export type objectRepresentation = {
example: Object
schema: Object
}
export type enrichedOperation = OpenAPIV3.OperationObject & { export type enrichedOperation = OpenAPIV3.OperationObject & {
path: string path: string
fullPath: string fullPath: string
operationId: string operationId: string
request: objectRepresentation
response: objectRepresentation
} }
export type schemaParameter = { export type schemaParameter = {
name: string name: string
type: string type: string
@@ -46,12 +74,7 @@ export type schemaParameter = {
minLength?: number minLength?: number
maxLength?: number maxLength?: number
enum?: string[] enum?: string[]
} sub?: Map<string,schemaParameter>
export type component = {
example: Object
schema: Object
parameters: schemaParameter[]
} }
async function gen_v3(spec: OpenAPIV3.Document, dest: string) { async function gen_v3(spec: OpenAPIV3.Document, dest: string) {
@@ -64,6 +87,29 @@ async function gen_v3(spec: OpenAPIV3.Document, dest: string) {
toArrayWithKey(val!, 'operation').forEach((o) => { toArrayWithKey(val!, 'operation').forEach((o) => {
const operation = o as v3OperationWithPath const operation = o as v3OperationWithPath
var request = null
if (operation.requestBody && 'content' in operation.requestBody && operation.requestBody.content['application/json']) {
request = {
example: extractInfo((operation.requestBody as RequestBodyObject).content['application/json'].schema, 'example'),
schema: extractInfo((operation.requestBody as RequestBodyObject).content['application/json'].schema, 'type')
}
}
var response = null
if(operation.responses["200"] != undefined && operation.responses["200"]["content"]["application/json"] != undefined) {
response = {
example: extractInfo(operation.responses["200"]["content"]["application/json"].schema, 'example'),
schema: extractInfo(operation.responses["200"]["content"]["application/json"].schema, 'type')
}
}
// if(operation.summary == "List all Tokens") {
// console.log(response.example)
// console.log(operation.responses["200"]["content"]["application/json"].schema.items.properties)
// }
const enriched = { const enriched = {
...operation, ...operation,
path: key, path: key,
@@ -71,6 +117,8 @@ async function gen_v3(spec: OpenAPIV3.Document, dest: string) {
operationId: slugify(operation.summary!), operationId: slugify(operation.summary!),
responseList: toArrayWithKey(operation.responses!, 'responseCode') || [], responseList: toArrayWithKey(operation.responses!, 'responseCode') || [],
request: request,
response: response,
} }
let tag = operation.tags.pop() let tag = operation.tags.pop()
let tagOperations = tagGroups.get(tag) ?? [] let tagOperations = tagGroups.get(tag) ?? []
@@ -78,8 +126,6 @@ async function gen_v3(spec: OpenAPIV3.Document, dest: string) {
}) })
}) })
let components = readComponents(spec.components)
tagGroups.forEach((value: enrichedOperation[], key: string) => { tagGroups.forEach((value: enrichedOperation[], key: string) => {
const operations = value const operations = value
@@ -98,121 +144,70 @@ async function gen_v3(spec: OpenAPIV3.Document, dest: string) {
tag: key, tag: key,
sections, sections,
operations, operations,
components, // components,
}) })
// Write to disk // Write to disk
let outputFile = dest + "/" + key.toLowerCase().replace(" ", "-") + ".mdx" let outputFile = dest + "/" + key.toLowerCase().replace(" ", "-") + ".mdx"
writeToDisk(outputFile, content) writeToDisk(outputFile, content)
// console.log('Saved: ', outputFile) // console.log('Saved: ', outputFile)
}) })
} }
function readComponents(components: OpenAPIV3.ComponentsObject) : Map<string, component> { function extractInfo(obj, mode = 'example') {
let componentsOutput = new Map<string, component>() // Handle the root level object that represents an array
if (obj.type === 'array' && obj.hasOwnProperty('items')) {
for (const [key, value] of Object.entries(components.schemas)) { if (obj.items.hasOwnProperty('properties')) {
let [schema, example, parameter] = resolveComponents(value, components) return [extractInfo(obj.items.properties, mode)];
let component = { } else {
example: example, return [extractInfo(obj.items, mode)];
schema: schema,
parameters: parameter
} }
componentsOutput.set(key, component)
} }
return componentsOutput // If mode is 'example' and the object has an 'example', return it immediately
} if (mode === 'example' && obj.hasOwnProperty('example')) {
return obj.example;
function resolveComponents(value: OpenAPIV3.ReferenceObject | OpenAPIV3.ArraySchemaObject | OpenAPIV3.NonArraySchemaObject, components: OpenAPIV3.ComponentsObject) : [Object, Object, schemaParameter[]] { }
if((value as OpenAPIV3.ReferenceObject).$ref) {
let subcomponentName = (value as OpenAPIV3.ReferenceObject).$ref.split('/').pop() // For an object with 'properties', check if there's an example at this level first
let subcomponent = components.schemas[subcomponentName] if (obj.type === 'object' && obj.hasOwnProperty('properties')) {
return resolveComponents(subcomponent, components) // If an example is provided at the current level, return it, avoiding deeper analysis
} if (obj.hasOwnProperty('example')) {
if((value as OpenAPIV3.SchemaObject).properties) { return obj.example;
return resolveProperties(value as OpenAPIV3.SchemaObject, components) } else {
} // If no example is provided, then proceed to extract info from its properties
if((value as OpenAPIV3.SchemaObject).allOf) { const result = {};
return resolveAllOf(value as OpenAPIV3.SchemaObject, components) for (const key in obj.properties) {
} if (obj.properties.hasOwnProperty(key)) {
if((value as OpenAPIV3.SchemaObject).type || (value as OpenAPIV3.SchemaObject).example) { result[key] = extractInfo(obj.properties[key], mode);
return [(value as OpenAPIV3.SchemaObject).type, (value as OpenAPIV3.SchemaObject).example, null] }
} }
} return result;
}
function resolveAllOf(object: OpenAPIV3.SchemaObject, components: OpenAPIV3.ComponentsObject) : [Object, Object, schemaParameter[]] { }
let examples = new Map<string, any>()
let schemas = new Map<string, any>() // Return the type for elementary types if mode is 'type'
let parameters: schemaParameter[] = [] if (mode === 'type' && ['string', 'number', 'boolean', 'integer'].includes(obj.type)) {
for (const [key, value] of Object.entries(object.allOf)) { return obj.type;
let example; }
let schema;
let parameter; // Handle arrays, assuming each item might be an object with its own structure
if((value as OpenAPIV3.ReferenceObject).$ref) { if (Array.isArray(obj)) {
let subcomponentName = (value as OpenAPIV3.ReferenceObject).$ref.split('/').pop() return obj.map(item => extractInfo(item, mode));
let subcomponent = components.schemas[subcomponentName]; }
[schema, example, parameter] = resolveComponents(subcomponent, components)
} // Special handling for objects that represent schemas (e.g., with 'type' and 'properties')
if((value as OpenAPIV3.SchemaObject).properties) { if (typeof obj === 'object' && obj !== null) {
[schema, example, parameter] = resolveProperties(value as OpenAPIV3.SchemaObject, components) const result = {};
} for (const key in obj) {
if(!(example instanceof Map)) { if (obj.hasOwnProperty(key)) {
example = new Map(Object.entries(example)) result[key] = extractInfo(obj[key], mode);
} }
if(!(schema instanceof Map)) { }
schema = new Map(Object.entries(schema)) return result;
} }
parameters = parameters.concat(parameter)
examples = mergeMaps(examples, example) // Return the object if it doesn't match any of the above conditions
schemas = mergeMaps(schemas, schema) return obj;
}
return [Object.fromEntries(schemas), Object.fromEntries(examples), parameters]
}
function resolveProperties(value: OpenAPIV3.SchemaObject, components: OpenAPIV3.ComponentsObject): [Object, Object, schemaParameter[]] {
let examples = new Map<string, Object>()
let schemas = new Map<string, Object>()
let parameters: schemaParameter[] = []
for(const [key, property] of Object.entries(value.properties)) {
let type: string = ""
if(property["$ref"]) {
let [schema, example, parameter] = resolveComponents(property, components)
examples.set(key, example)
schemas.set(key, schema)
parameters = parameters.concat(parameter)
continue
}
switch (property["type"]) {
case "array":
type = ((property["items"] as OpenAPIV3.SchemaObject).type || (property["items"] as OpenAPIV3.ReferenceObject).$ref.split('/').pop()) + "[]"
let [schema, example] = resolveComponents(property["items"], components)
examples.set(key, new Array(example))
schemas.set(key, new Array(schema))
break;
case "object":
default:
type = property["type"]
examples.set(key, property["example"])
schemas.set(key, property["type"])
}
let parameter: schemaParameter = {
name: key,
type: type,
description: property["description"],
required: value.required?.includes(key) || false,
minimum: property["minimum"],
maximum: property["maximum"],
minLength: property["minLength"],
maxLength: property["maxLength"],
enum: property["enum"],
}
parameters.push(parameter)
}
return [Object.fromEntries(schemas), Object.fromEntries(examples), parameters]
}
function mergeMaps(map1: Map<string, Object>, map2: Map<string, Object>) : Map<string, Object> {
return new Map([...Array.from(map1.entries()), ...Array.from(map2.entries())]);
} }

View File

@@ -0,0 +1,61 @@
package main
import (
"fmt"
"io/ioutil"
"os"
"github.com/pb33f/libopenapi/index"
"gopkg.in/yaml.v3"
)
func main() {
// if len(os.Args) != 1 {
// fmt.Printf("No input file provided!\n")
// }
// load an OpenAPI 3 specification from bytes
// petstore, _ := ioutil.ReadFile(os.Args[0])
petstore, _ := ioutil.ReadFile("openapi/openapi.yml")
// create a root node to unmarshal the spec into.
var rootNode yaml.Node
_ = yaml.Unmarshal(petstore, &rootNode)
// create a new config that does not allow lookups.
indexConfig := index.CreateClosedAPIIndexConfig()
// create a new rolodex
rolodex := index.NewRolodex(indexConfig)
// set the rolodex root node to the root node of the spec.
rolodex.SetRootNode(&rootNode)
// index the rolodex
indexedErr := rolodex.IndexTheRolodex()
if indexedErr != nil {
panic(indexedErr)
}
// resolve the petstore
rolodex.Resolve()
// extract the resolver from the root index.
node := rolodex.GetRootNode()
b, e := yaml.Marshal(node)
if e != nil {
panic(e)
}
var newNode yaml.Node
_ = yaml.Unmarshal(b, &newNode)
err := os.WriteFile("openapi/expanded.yml", b, 0644)
if err != nil {
fmt.Printf("Failed to write file: %v", err)
return
}
}

17
generator/go.mod Normal file
View File

@@ -0,0 +1,17 @@
module generator
go 1.21.1
require github.com/pb33f/libopenapi v0.15.13
require (
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/vmware-labs/yaml-jsonpath v0.3.2 // indirect
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect
golang.org/x/sync v0.6.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

144
generator/go.sum Normal file
View File

@@ -0,0 +1,144 @@
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dprotaso/go-yit v0.0.0-20191028211022-135eb7262960/go.mod h1:9HQzr9D/0PGwMEbC3d5AB7oi67+h4TsQqItC1GVYG58=
github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 h1:PRxIJD8XjimM5aTknUK9w6DHLDox2r2M3DI4i2pnd3w=
github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936/go.mod h1:ttYvX5qlB+mlV1okblJqcSMtR4c52UKxDiX9GRBS8+Q=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.10.2/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw=
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
github.com/pb33f/libopenapi v0.15.13 h1:x9G0ZViDR6usizfDZfk/y8mwkvx/fpYLf6zupYcuRuE=
github.com/pb33f/libopenapi v0.15.13/go.mod h1:PEXNwvtT4KNdjrwudp5OYnD1ryqK6uJ68aMNyWvoMuc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/vmware-labs/yaml-jsonpath v0.3.2 h1:/5QKeCBGdsInyDCyVNLbXyilb61MXGi9NP674f9Hobk=
github.com/vmware-labs/yaml-jsonpath v0.3.2/go.mod h1:U6whw1z03QyqgWdgXxvVnQ90zN1BWz5V+51Ewf8k+rQ=
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a h1:HinSgX1tJRX3KsL//Gxynpw5CTOAIPhgL4W8PNiIpVE=
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc=
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20191026110619-0b21df46bc1d/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@@ -29,30 +29,67 @@ export const title = '<%- tag %>'
<% }); -%> <% }); -%>
</Properties> </Properties>
<% }; -%> <% }; -%>
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %> <% if(operation.requestBody && operation.requestBody["content"]["application/json"].schema.properties){ %>
#### Request-Body Parameters #### Request-Body Parameters
<Properties>
<% components.get(operation.requestBody?.content['application/json'].schema.$ref.split('/').pop())?.parameters.forEach(function(parameter){ %> <%
<Property name="<%- parameter.name %>" type="<%- parameter.type %>" required=\{<%- parameter.required %>\} function renderProperties(properties, required = [], depth = 0) {
<% if(parameter.enum){ %> %><Properties><%
enumList="<%- parameter.enum %>" Object.entries(properties).forEach(([key, value]) => {
<% }; -%> let type = value.type;
<% if(parameter.minimum){ %> var isRequired = required.includes(key) ? '{true}' : '{false}';
min=\{<%- parameter.minimum %>\}
<% }; -%> if (type === 'array' && value.items) {
<% if(parameter.maximum){ %> if (value.items.type === 'object' && value.items.properties) {
max=\{<%- parameter.maximum %>\} type = 'object[]';
<% }; -%> } else {
<% if(parameter.minLength){ %> type = value.items.type + '[]';
minLen=\{<%- parameter.minLength %>\} }
<% }; -%> }
<% if(parameter.maxLength){ %>
maxLen=\{<%- parameter.maxLength %>\} %><Property name="<%- key %>" type="<%- type %>" required=<%- isRequired %><%
<% }; -%> > if(value.enum) {
<%- parameter.description %> %> enumList={<%- JSON.stringify(value.enum) %>}<%
</Property> }
<% }); -%> if(value.minimum !== undefined) {
</Properties> %> min={<%- value.minimum %>}<%
}
if(value.maximum !== undefined) {
%> max={<%- value.maximum %>}<%
}
if(value.minLength !== undefined) {
%> minLen={<%- value.minLength %>}<%
}
if(value.maxLength !== undefined) {
%> maxLen={<%- value.maxLength %>}<%
}
%>>%>
<% if ((type === 'object' && value.properties) || (type === 'object[]' && value.items.properties)) { %>
<details class="custom-details" open>
<summary><%- value.description || 'More Information' %></summary>
<Properties>
<% if (type === 'object[]') { %>
<% renderProperties(value.items.properties, value.items.required || [], depth + 1); %>
<% } else { %>
<% renderProperties(value.properties, value.required || [], depth + 1); %>
<% } %>
</Properties>
</details>
<% } else { %>
<% if(value.description) { %><%- value.description %><% } %>
<% } %>
</Property>
<% });
%></Properties><%
}
var schema = operation.requestBody["content"]["application/json"].schema;
if(schema && schema.properties) {
renderProperties(schema.properties, schema.required || []);
}
%>
<% }; -%> <% }; -%>
</Col> </Col>
@@ -65,13 +102,13 @@ curl -X <%- operation.operation.toUpperCase() %> <%- operation.fullPath %> \\<%
-H 'Accept: application/json' \\<% }; -%> -H 'Accept: application/json' \\<% }; -%>
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %> <% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %>
-H 'Content-Type: application/json' \\<% }; %> -H 'Content-Type: application/json' \\<% }; %>
-H 'Authorization: Token <TOKEN>' <% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %>\\\n--data-raw '<%- JSON.stringify(components.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.example, null, 2) -%>'<% }; %> -H 'Authorization: Token <TOKEN>' <% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %>\\\n--data-raw '<%- JSON.stringify(operation.request.example, null, 2) -%>'<% }; %>
\`\`\` \`\`\`
\`\`\`js \`\`\`js
const axios = require('axios'); const axios = require('axios');
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ -%> <% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ -%>
let data = JSON.stringify(<%- JSON.stringify(components.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.example, null, 2) %>);<% }; -%> let data = JSON.stringify(<%- JSON.stringify(operation.request.example, null, 2) %>);<% }; -%>
let config = { let config = {
method: '<%- operation.operation.toLowerCase() %>', method: '<%- operation.operation.toLowerCase() %>',
@@ -103,7 +140,7 @@ import json
url = "<%- operation.fullPath %>" url = "<%- operation.fullPath %>"
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ -%> <% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ -%>
payload = json.dumps(<%- JSON.stringify(components.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.example, null, 2) %>)<% }; -%> payload = json.dumps(<%- JSON.stringify(operation.request.example, null, 2) %>)<% }; -%>
<% if(true){%>headers: { <% }; -%> <% if(true){%>headers: { <% }; -%>
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %> <% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %>
@@ -133,7 +170,7 @@ func main() {
url := "<%- operation.fullPath %>" url := "<%- operation.fullPath %>"
method := "<%- operation.operation.toUpperCase() %>" method := "<%- operation.operation.toUpperCase() %>"
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %> <% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %>
payload := strings.NewReader(\`<%- JSON.stringify(components.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.example, null, 2) %>\`)<% }; -%> payload := strings.NewReader(\`<%- JSON.stringify(operation.request.example, null, 2) %>\`)<% }; -%>
client := &http.Client { client := &http.Client {
} }
@@ -183,7 +220,7 @@ request["Content-Type"] = "application/json"<% }; -%>
request["Accept"] = "application/json"<% }; %> request["Accept"] = "application/json"<% }; %>
request["Authorization"] = "Token <TOKEN>" request["Authorization"] = "Token <TOKEN>"
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %> <% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %>
request.body = JSON.dump(<%- JSON.stringify(components.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.example, null, 2) %>)<% }; -%> request.body = JSON.dump(<%- JSON.stringify(operation.request.example, null, 2) %>)<% }; -%>
response = https.request(request) response = https.request(request)
puts response.read_body puts response.read_body
@@ -194,7 +231,7 @@ OkHttpClient client = new OkHttpClient().newBuilder()
.build(); .build();
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ -%> <% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ -%>
MediaType mediaType = MediaType.parse("application/json"); MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, '<%- JSON.stringify(components.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.example, null, 2) %>');<% }; %> RequestBody body = RequestBody.create(mediaType, '<%- JSON.stringify(operation.request.example, null, 2) %>');<% }; %>
Request request = new Request.Builder() Request request = new Request.Builder()
.url("<%- operation.fullPath %>") .url("<%- operation.fullPath %>")
<% if(true){ %>.method("<%- operation.operation.toUpperCase() %>"<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %>, body<% }; %>)<% }; -%> <% if(true){ %>.method("<%- operation.operation.toUpperCase() %>"<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %>, body<% }; %>)<% }; -%>
@@ -222,7 +259,7 @@ curl_setopt_array($curl, array(
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
<% if(true){ %>CURLOPT_CUSTOMREQUEST => '<%- operation.operation.toUpperCase() %>',<% }; -%> <% if(true){ %>CURLOPT_CUSTOMREQUEST => '<%- operation.operation.toUpperCase() %>',<% }; -%>
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %> <% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %>
CURLOPT_POSTFIELDS => '<%- JSON.stringify(components.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.example, null, 2) %>',<% }; %> CURLOPT_POSTFIELDS => '<%- JSON.stringify(operation.request.example, null, 2) %>',<% }; %>
<% if(true){ %>CURLOPT_HTTPHEADER => array(<% }; -%> <% if(true){ %>CURLOPT_HTTPHEADER => array(<% }; -%>
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %> <% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %>
'Content-Type: application/json',<% }; -%> 'Content-Type: application/json',<% }; -%>
@@ -239,29 +276,18 @@ echo $response;
\`\`\` \`\`\`
</CodeGroup> </CodeGroup>
<% operation.responseList.forEach(function(response){ %>
<% if(response?.content && response?.content['application/json']){ %> <% if(operation.response){ %>
<% if(response?.content['application/json'].schema.type === 'array'){ %> <CodeGroup title="Response">
<CodeGroup title="Response">
\`\`\`json {{ title: 'Example' }} \`\`\`json {{ title: 'Example' }}
<%- JSON.stringify(new Array(components.get(response?.content['application/json'].schema.items.$ref?.split('/').pop())?.example), null, 2) %> <%- JSON.stringify(operation.response.example, null, 2) %>
\`\`\` \`\`\`
\`\`\`json {{ title: 'Schema' }} \`\`\`json {{ title: 'Schema' }}
<%- JSON.stringify(new Array(components.get(response?.content['application/json'].schema.items.$ref?.split('/').pop())?.schema), null, 2) %> <%- JSON.stringify(operation.response.schema, null, 2) %>
\`\`\` \`\`\`
</CodeGroup> </CodeGroup>
<% } else { %> <% }; %>
<CodeGroup title="Response">
\`\`\`json {{ title: 'Example' }}
<%- JSON.stringify(components.get(response?.content['application/json'].schema.$ref?.split('/').pop())?.example, null, 2) %>
\`\`\`
\`\`\`json {{ title: 'Schema' }}
<%- JSON.stringify(components.get(response?.content['application/json'].schema.$ref?.split('/').pop())?.schema, null, 2) %>
\`\`\`
</CodeGroup>
<% }; -%>
<% }; -%>
<% }); -%>
</Col> </Col>
</Row> </Row>

View File

@@ -37,11 +37,13 @@
"@tailwindcss/typography": "^0.5.8", "@tailwindcss/typography": "^0.5.8",
"acorn": "^8.8.2", "acorn": "^8.8.2",
"algoliasearch": "^4.17.0", "algoliasearch": "^4.17.0",
"allof-merge": "^0.6.6",
"autoprefixer": "^10.4.7", "autoprefixer": "^10.4.7",
"clsx": "^1.2.0", "clsx": "^1.2.0",
"ejs": "^3.1.9", "ejs": "^3.1.9",
"focus-visible": "^5.2.0", "focus-visible": "^5.2.0",
"framer-motion": "10.12.9", "framer-motion": "10.12.9",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"mdast-util-to-string": "^3.2.0", "mdast-util-to-string": "^3.2.0",
"mdx-annotations": "^0.1.1", "mdx-annotations": "^0.1.1",

View File

@@ -29,6 +29,8 @@ export const apiNavigation = [
{ title: 'Groups', href: '/api/resources/groups' }, { title: 'Groups', href: '/api/resources/groups' },
{ title: 'Rules', href: '/api/resources/rules' }, { title: 'Rules', href: '/api/resources/rules' },
{ title: 'Policies', href: '/api/resources/policies' }, { title: 'Policies', href: '/api/resources/policies' },
{ title: 'Posture-Checks', href: '/api/resources/posture-checks' },
{ title: 'Geo-Locations', href: '/api/resources/geo-locations' },
{ title: 'Routes', href: '/api/resources/routes' }, { title: 'Routes', href: '/api/resources/routes' },
{ title: 'DNS', href: '/api/resources/dns' }, { title: 'DNS', href: '/api/resources/dns' },
{ title: 'Events', href: '/api/resources/events' }, { title: 'Events', href: '/api/resources/events' },

View File

@@ -98,12 +98,12 @@ export function Property({ name, type, required, min, max, minLen, maxLen, enumL
{type} {type}
</dd> </dd>
<dt className="sr-only">Required</dt> <dt className="sr-only">Required</dt>
<dd className="font-mono text-xs text-red-600 dark:text-red-600"> {required && <dd className="font-mono text-xs text-red-600 dark:text-red-600">
{required && 'required'} required
</dd> </dd>}
<dd className="font-mono text-xs text-zinc-400 dark:text-zinc-500"> {!required && <dd className="font-mono text-xs text-zinc-400 dark:text-zinc-500">
{!required && 'optional'} optional
</dd> </dd>}
<dt className="sr-only">Enum</dt> <dt className="sr-only">Enum</dt>
<dd className="w-full flex-none [&>:first-child]:mt-0 [&>:last-child]:mb-0"> <dd className="w-full flex-none [&>:first-child]:mt-0 [&>:last-child]:mb-0">
{/*{enumList && "Possible values: [" + enumList.split(',').forEach((type) => (<tag>{type}</tag>)) + "]"}*/} {/*{enumList && "Possible values: [" + enumList.split(',').forEach((type) => (<tag>{type}</tag>)) + "]"}*/}

View File

@@ -6,6 +6,7 @@ import * as mdxComponents from '@/components/mdx'
import { useMobileNavigationStore } from '@/components/MobileNavigation' import { useMobileNavigationStore } from '@/components/MobileNavigation'
import '@/styles/tailwind.css' import '@/styles/tailwind.css'
import '@/styles/global.css';
import 'focus-visible' import 'focus-visible'
import {Layout} from "@/components/Layout"; import {Layout} from "@/components/Layout";
import {slugifyWithCounter} from "@sindresorhus/slugify"; import {slugifyWithCounter} from "@sindresorhus/slugify";

View File

@@ -157,9 +157,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
[ [
{ {
@@ -200,13 +199,174 @@ echo $response;
} }
] ]
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Row>
---
## Delete an Account {{ tag: 'DELETE' , label: '/api/accounts/{accountId}' }}
<Row>
<Col>
Deletes an account and all its resources. Only administrators and account owners can delete accounts.
#### Path Parameters
<Properties>
<Property name="accountId" type="string" required={true}>
The unique identifier of an account
</Property>
</Properties>
</Col> </Col>
<Col sticky>
<CodeGroup title="Request" tag="DELETE" label="/api/accounts/{accountId}">
```bash {{ title: 'cURL' }}
curl -X DELETE https://api.netbird.io/api/accounts/{accountId} \
-H 'Authorization: Token <TOKEN>'
```
```js
const axios = require('axios');
let config = {
method: 'delete',
maxBodyLength: Infinity,
url: '/api/accounts/{accountId}',
headers: {
'Authorization': 'Token <TOKEN>'
}
};
axios(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
```
```python
import requests
import json
url = "https://api.netbird.io/api/accounts/{accountId}"
headers: {
'Authorization': 'Token <TOKEN>'
}
response = requests.request("DELETE", url, headers=headers)
print(response.text)
```
```go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.netbird.io/api/accounts/{accountId}"
method := "DELETE"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
{
req.Header.Add("Authorization", "Token <TOKEN>")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
```
```ruby
require "uri"
require "json"
require "net/http"
url = URI("https://api.netbird.io/api/accounts/{accountId}")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = "Token <TOKEN>"
response = https.request(request)
puts response.read_body
```
```java
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.netbird.io/api/accounts/{accountId}")
.method("DELETE")
.addHeader("Authorization: Token <TOKEN>")
.build();
Response response = client.newCall(request).execute();
```
```php
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.netbird.io/api/accounts/{accountId}',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => array(
'Authorization: Token <TOKEN>'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
```
</CodeGroup>
</Col>
</Row> </Row>
--- ---
@@ -227,57 +387,69 @@ echo $response;
</Properties> </Properties>
#### Request-Body Parameters #### Request-Body Parameters
<Properties>
<Properties><Property name="settings" type="object" required={true}>
<Property name="peer_login_expiration_enabled" type="boolean" required={true} <details class="custom-details" open>
<summary>More Information</summary>
<Properties>
>
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). <Properties><Property name="peer_login_expiration_enabled" type="boolean" required={true}>
</Property>
<Property name="peer_login_expiration" type="integer" required={true} Enables or disables peer login expiration globally. After peer's login has expired the user has to log in (authenticate). Applies only to peers that were added by a user (interactive SSO login).
>
Period of time after which peer login expires (seconds).
</Property>
<Property name="groups_propagation_enabled" type="boolean" required={false} </Property>
<Property name="peer_login_expiration" type="integer" required={true}>
>
Allows propagate the new user auto groups to peers that belongs to the user
</Property>
<Property name="jwt_groups_enabled" type="boolean" required={false} Period of time after which peer login expires (seconds).
>
Allows extract groups from JWT claim and add it to account groups.
</Property>
<Property name="jwt_groups_claim_name" type="string" required={false} </Property>
<Property name="groups_propagation_enabled" type="boolean" required={false}>
>
Name of the claim from which we extract groups names to add it to account groups.
</Property>
<Property name="jwt_allow_groups" type="string[]" required={false} Allows propagate the new user auto groups to peers that belongs to the user
>
List of groups to which users are allowed access
</Property>
<Property name="peer_approval_enabled" type="boolean" required={false} </Property>
<Property name="jwt_groups_enabled" type="boolean" required={false}>
> Allows extract groups from JWT claim and add it to account groups.
(Cloud only) Enables or disables peer approval globally. If enabled, all peers added will be in pending state until approved by an admin.
</Property> </Property>
</Properties> <Property name="jwt_groups_claim_name" type="string" required={false}>
Name of the claim from which we extract groups names to add it to account groups.
</Property>
<Property name="jwt_allow_groups" type="string[]" required={false}>
List of groups to which users are allowed access
</Property>
<Property name="extra" type="object" required={false}>
<details class="custom-details" open>
<summary>More Information</summary>
<Properties>
<Properties><Property name="peer_approval_enabled" type="boolean" required={false}>
(Cloud only) Enables or disables peer approval globally. If enabled, all peers added will be in pending state until approved by an admin.
</Property>
</Properties>
</Properties>
</details>
</Property>
</Properties>
</Properties>
</details>
</Property>
</Properties>
</Col> </Col>
<Col sticky> <Col sticky>
@@ -539,9 +711,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "ch8i4ug6lnn4g9hqv7l0", "id": "ch8i4ug6lnn4g9hqv7l0",
@@ -578,6 +749,7 @@ echo $response;
} }
} }
``` ```
</CodeGroup> </CodeGroup>
@@ -746,11 +918,8 @@ echo $response;
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---

View File

@@ -157,9 +157,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
[ [
{ {
@@ -210,13 +209,10 @@ echo $response;
} }
] ]
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -229,72 +225,72 @@ echo $response;
Creates a Nameserver Group Creates a Nameserver Group
#### Request-Body Parameters #### Request-Body Parameters
<Properties>
<Properties><Property name="name" type="string" required={true} minLen={1} maxLen={40}>
<Property name="name" type="string" required={true} Name of nameserver group name
minLen={1}
maxLen={40}
>
Name of nameserver group name
</Property>
<Property name="description" type="string" required={true} </Property>
<Property name="description" type="string" required={true}>
>
Description of the nameserver group
</Property>
<Property name="nameservers" type="Nameserver[]" required={true} Description of the nameserver group
minLen={1}
maxLen={2}
>
Nameserver list
</Property>
<Property name="enabled" type="boolean" required={true} </Property>
<Property name="nameservers" type="object[]" required={true} minLen={1} maxLen={3}>
>
Nameserver group status
</Property>
<Property name="groups" type="string[]" required={true} <details class="custom-details" open>
<summary>Nameserver list</summary>
<Properties>
>
Distribution group IDs that defines group of peers that will use this nameserver group <Properties><Property name="ip" type="string" required={true}>
</Property>
<Property name="primary" type="boolean" required={true} Nameserver IP
>
Defines if a nameserver group is primary that resolves all domains. It should be true only if domains list is empty.
</Property>
<Property name="domains" type="string[]" required={true} </Property>
<Property name="ns_type" type="string" required={true} enumList={["udp"]}>
>
Match domain list. It should be empty only if primary is true.
</Property>
<Property name="search_domains_enabled" type="boolean" required={true} Nameserver Type
</Property>
> <Property name="port" type="integer" required={true}>
Search domain status for match domains. It should be true only if domains list is not empty.
</Property> Nameserver Port
</Properties>
</Property>
</Properties>
</Properties>
</details>
</Property>
<Property name="enabled" type="boolean" required={true}>
Nameserver group status
</Property>
<Property name="groups" type="string[]" required={true}>
Distribution group IDs that defines group of peers that will use this nameserver group
</Property>
<Property name="primary" type="boolean" required={true}>
Defines if a nameserver group is primary that resolves all domains. It should be true only if domains list is empty.
</Property>
<Property name="domains" type="string[]" required={true}>
Match domain list. It should be empty only if primary is true.
</Property>
<Property name="search_domains_enabled" type="boolean" required={true}>
Search domain status for match domains. It should be true only if domains list is not empty.
</Property>
</Properties>
</Col> </Col>
<Col sticky> <Col sticky>
@@ -591,9 +587,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "ch8i4ug6lnn4g9hqv7m0", "id": "ch8i4ug6lnn4g9hqv7m0",
@@ -640,13 +635,10 @@ echo $response;
"search_domains_enabled": "boolean" "search_domains_enabled": "boolean"
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -815,9 +807,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "ch8i4ug6lnn4g9hqv7m0", "id": "ch8i4ug6lnn4g9hqv7m0",
@@ -864,13 +855,10 @@ echo $response;
"search_domains_enabled": "boolean" "search_domains_enabled": "boolean"
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -891,72 +879,72 @@ echo $response;
</Properties> </Properties>
#### Request-Body Parameters #### Request-Body Parameters
<Properties>
<Properties><Property name="name" type="string" required={true} minLen={1} maxLen={40}>
<Property name="name" type="string" required={true} Name of nameserver group name
minLen={1}
maxLen={40}
>
Name of nameserver group name
</Property>
<Property name="description" type="string" required={true} </Property>
<Property name="description" type="string" required={true}>
>
Description of the nameserver group
</Property>
<Property name="nameservers" type="Nameserver[]" required={true} Description of the nameserver group
minLen={1}
maxLen={2}
>
Nameserver list
</Property>
<Property name="enabled" type="boolean" required={true} </Property>
<Property name="nameservers" type="object[]" required={true} minLen={1} maxLen={3}>
>
Nameserver group status
</Property>
<Property name="groups" type="string[]" required={true} <details class="custom-details" open>
<summary>Nameserver list</summary>
<Properties>
>
Distribution group IDs that defines group of peers that will use this nameserver group <Properties><Property name="ip" type="string" required={true}>
</Property>
<Property name="primary" type="boolean" required={true} Nameserver IP
>
Defines if a nameserver group is primary that resolves all domains. It should be true only if domains list is empty.
</Property>
<Property name="domains" type="string[]" required={true} </Property>
<Property name="ns_type" type="string" required={true} enumList={["udp"]}>
>
Match domain list. It should be empty only if primary is true.
</Property>
<Property name="search_domains_enabled" type="boolean" required={true} Nameserver Type
</Property>
> <Property name="port" type="integer" required={true}>
Search domain status for match domains. It should be true only if domains list is not empty.
</Property> Nameserver Port
</Properties>
</Property>
</Properties>
</Properties>
</details>
</Property>
<Property name="enabled" type="boolean" required={true}>
Nameserver group status
</Property>
<Property name="groups" type="string[]" required={true}>
Distribution group IDs that defines group of peers that will use this nameserver group
</Property>
<Property name="primary" type="boolean" required={true}>
Defines if a nameserver group is primary that resolves all domains. It should be true only if domains list is empty.
</Property>
<Property name="domains" type="string[]" required={true}>
Match domain list. It should be empty only if primary is true.
</Property>
<Property name="search_domains_enabled" type="boolean" required={true}>
Search domain status for match domains. It should be true only if domains list is not empty.
</Property>
</Properties>
</Col> </Col>
<Col sticky> <Col sticky>
@@ -1253,9 +1241,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "ch8i4ug6lnn4g9hqv7m0", "id": "ch8i4ug6lnn4g9hqv7m0",
@@ -1302,13 +1289,10 @@ echo $response;
"search_domains_enabled": "boolean" "search_domains_enabled": "boolean"
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -1470,11 +1454,9 @@ echo $response;
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -1635,34 +1617,30 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
[ {
{ "items": {
"disabled_management_groups": [ "disabled_management_groups": [
"ch8i4ug6lnn4g9hqv7m0" "ch8i4ug6lnn4g9hqv7m0"
] ]
} }
] }
``` ```
```json {{ title: 'Schema' }} ```json {{ title: 'Schema' }}
[ {
{ "items": {
"disabled_management_groups": [ "disabled_management_groups": [
"string" "string"
] ]
} }
] }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -1675,15 +1653,15 @@ echo $response;
Updates a DNS settings object Updates a DNS settings object
#### Request-Body Parameters #### Request-Body Parameters
<Properties>
<Properties><Property name="disabled_management_groups" type="string[]" required={true}>
<Property name="disabled_management_groups" type="string[]" required={true} Groups whose DNS management is disabled
</Property>
> </Properties>
Groups whose DNS management is disabled
</Property>
</Properties>
</Col> </Col>
<Col sticky> <Col sticky>
@@ -1875,9 +1853,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"disabled_management_groups": [ "disabled_management_groups": [
@@ -1892,13 +1869,10 @@ echo $response;
] ]
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---

View File

@@ -157,13 +157,12 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
[ [
{ {
"id": "10", "id": 10,
"timestamp": "2023-05-05T10:04:37.473542Z", "timestamp": "2023-05-05T10:04:37.473542Z",
"activity": "Route created", "activity": "Route created",
"activity_code": "route.add", "activity_code": "route.add",
@@ -190,17 +189,23 @@ echo $response;
"initiator_name": "string", "initiator_name": "string",
"initiator_email": "string", "initiator_email": "string",
"target_id": "string", "target_id": "string",
"meta": "object" "meta": {
"description": "The metadata of the event",
"type": "object",
"additionalProperties": "string",
"example": {
"name": "my route",
"network_range": "10.64.0.0/24",
"peer_id": "chacbco6lnnbn6cg5s91"
}
}
} }
] ]
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---

View File

@@ -0,0 +1,364 @@
export const title = 'Geo Locations'
## List all country codes {{ tag: 'GET' , label: '/api/locations/countries' }}
<Row>
<Col>
Get list of all country in 2-letter ISO 3166-1 alpha-2 codes
</Col>
<Col sticky>
<CodeGroup title="Request" tag="GET" label="/api/locations/countries">
```bash {{ title: 'cURL' }}
curl -X GET https://api.netbird.io/api/locations/countries \
-H 'Accept: application/json' \
-H 'Authorization: Token <TOKEN>'
```
```js
const axios = require('axios');
let config = {
method: 'get',
maxBodyLength: Infinity,
url: '/api/locations/countries',
headers: {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
};
axios(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
```
```python
import requests
import json
url = "https://api.netbird.io/api/locations/countries"
headers: {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
response = requests.request("GET", url, headers=headers)
print(response.text)
```
```go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.netbird.io/api/locations/countries"
method := "GET"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
{
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Token <TOKEN>")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
```
```ruby
require "uri"
require "json"
require "net/http"
url = URI("https://api.netbird.io/api/locations/countries")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Accept"] = "application/json"
request["Authorization"] = "Token <TOKEN>"
response = https.request(request)
puts response.read_body
```
```java
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.netbird.io/api/locations/countries")
.method("GET")
.addHeader("Accept", "application/json")
.addHeader("Authorization: Token <TOKEN>")
.build();
Response response = client.newCall(request).execute();
```
```php
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.netbird.io/api/locations/countries',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Accept: application/json',
'Authorization: Token <TOKEN>'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
```
</CodeGroup>
<CodeGroup title="Response">
```json {{ title: 'Example' }}
[
"DE"
]
```
```json {{ title: 'Schema' }}
[
"string"
]
```
</CodeGroup>
</Col>
</Row>
---
## List all city names by country {{ tag: 'GET' , label: '/api/locations/countries/{country}/cities' }}
<Row>
<Col>
Get a list of all English city names for a given country code
#### Path Parameters
<Properties>
<Property name="country" type="string" required={true}>
</Property>
</Properties>
</Col>
<Col sticky>
<CodeGroup title="Request" tag="GET" label="/api/locations/countries/{country}/cities">
```bash {{ title: 'cURL' }}
curl -X GET https://api.netbird.io/api/locations/countries/{country}/cities \
-H 'Accept: application/json' \
-H 'Authorization: Token <TOKEN>'
```
```js
const axios = require('axios');
let config = {
method: 'get',
maxBodyLength: Infinity,
url: '/api/locations/countries/{country}/cities',
headers: {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
};
axios(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
```
```python
import requests
import json
url = "https://api.netbird.io/api/locations/countries/{country}/cities"
headers: {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
response = requests.request("GET", url, headers=headers)
print(response.text)
```
```go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.netbird.io/api/locations/countries/{country}/cities"
method := "GET"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
{
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Token <TOKEN>")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
```
```ruby
require "uri"
require "json"
require "net/http"
url = URI("https://api.netbird.io/api/locations/countries/{country}/cities")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Accept"] = "application/json"
request["Authorization"] = "Token <TOKEN>"
response = https.request(request)
puts response.read_body
```
```java
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.netbird.io/api/locations/countries/{country}/cities")
.method("GET")
.addHeader("Accept", "application/json")
.addHeader("Authorization: Token <TOKEN>")
.build();
Response response = client.newCall(request).execute();
```
```php
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.netbird.io/api/locations/countries/{country}/cities',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Accept: application/json',
'Authorization: Token <TOKEN>'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
```
</CodeGroup>
<CodeGroup title="Response">
```json {{ title: 'Example' }}
{
"geoname_id": 2950158,
"city_name": "Berlin"
}
```
```json {{ title: 'Schema' }}
{
"geoname_id": "integer",
"city_name": "string"
}
```
</CodeGroup>
</Col>
</Row>
---

View File

@@ -157,9 +157,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
[ [
{ {
@@ -192,13 +191,10 @@ echo $response;
} }
] ]
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -211,22 +207,20 @@ echo $response;
Creates a group Creates a group
#### Request-Body Parameters #### Request-Body Parameters
<Properties>
<Properties><Property name="name" type="string" required={true}>
<Property name="name" type="string" required={true} Group name identifier
>
Group name identifier
</Property>
<Property name="peers" type="string[]" required={false} </Property>
<Property name="peers" type="string[]" required={false}>
> List of peers ids
List of peers ids
</Property> </Property>
</Properties> </Properties>
</Col> </Col>
<Col sticky> <Col sticky>
@@ -425,9 +419,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "ch8i4ug6lnn4g9hqv7m0", "id": "ch8i4ug6lnn4g9hqv7m0",
@@ -456,13 +449,10 @@ echo $response;
] ]
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -631,9 +621,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "ch8i4ug6lnn4g9hqv7m0", "id": "ch8i4ug6lnn4g9hqv7m0",
@@ -662,13 +651,10 @@ echo $response;
] ]
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -689,22 +675,20 @@ echo $response;
</Properties> </Properties>
#### Request-Body Parameters #### Request-Body Parameters
<Properties>
<Properties><Property name="name" type="string" required={true}>
<Property name="name" type="string" required={true} Group name identifier
>
Group name identifier
</Property>
<Property name="peers" type="string[]" required={false} </Property>
<Property name="peers" type="string[]" required={false}>
> List of peers ids
List of peers ids
</Property> </Property>
</Properties> </Properties>
</Col> </Col>
<Col sticky> <Col sticky>
@@ -903,9 +887,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "ch8i4ug6lnn4g9hqv7m0", "id": "ch8i4ug6lnn4g9hqv7m0",
@@ -934,13 +917,10 @@ echo $response;
] ]
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -1102,11 +1082,9 @@ echo $response;
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---

View File

@@ -157,18 +157,20 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
[ [
{ {
"id": "chacbco6lnnbn6cg5s90", "id": "chacbco6lnnbn6cg5s90",
"name": "stage-host-1", "name": "stage-host-1",
"ip": "10.64.0.1", "ip": "10.64.0.1",
"connection_ip": "35.64.0.1",
"connected": true, "connected": true,
"last_seen": "2023-05-05T10:05:26.420578Z", "last_seen": "2023-05-05T10:05:26.420578Z",
"os": "Darwin 13.2.1", "os": "Darwin 13.2.1",
"kernel_version": "23.2.0",
"geoname_id": 2643743,
"version": "0.14.0", "version": "0.14.0",
"groups": [ "groups": [
{ {
@@ -187,6 +189,8 @@ echo $response;
"login_expired": false, "login_expired": false,
"last_login": "2023-05-05T09:00:35.477782Z", "last_login": "2023-05-05T09:00:35.477782Z",
"approval_required": true, "approval_required": true,
"country_code": "DE",
"city_name": "Berlin",
"accessible_peers_count": 5 "accessible_peers_count": 5
} }
] ]
@@ -197,9 +201,12 @@ echo $response;
"id": "string", "id": "string",
"name": "string", "name": "string",
"ip": "string", "ip": "string",
"connection_ip": "string",
"connected": "boolean", "connected": "boolean",
"last_seen": "string", "last_seen": "string",
"os": "string", "os": "string",
"kernel_version": "string",
"geoname_id": "integer",
"version": "string", "version": "string",
"groups": [ "groups": [
{ {
@@ -218,17 +225,16 @@ echo $response;
"login_expired": "boolean", "login_expired": "boolean",
"last_login": "string", "last_login": "string",
"approval_required": "boolean", "approval_required": "boolean",
"country_code": "string",
"city_name": "string",
"accessible_peers_count": "integer" "accessible_peers_count": "integer"
} }
] ]
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -397,17 +403,19 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "chacbco6lnnbn6cg5s90", "id": "chacbco6lnnbn6cg5s90",
"name": "stage-host-1", "name": "stage-host-1",
"ip": "10.64.0.1", "ip": "10.64.0.1",
"connection_ip": "35.64.0.1",
"connected": true, "connected": true,
"last_seen": "2023-05-05T10:05:26.420578Z", "last_seen": "2023-05-05T10:05:26.420578Z",
"os": "Darwin 13.2.1", "os": "Darwin 13.2.1",
"kernel_version": "23.2.0",
"geoname_id": 2643743,
"version": "0.14.0", "version": "0.14.0",
"groups": [ "groups": [
{ {
@@ -426,6 +434,8 @@ echo $response;
"login_expired": false, "login_expired": false,
"last_login": "2023-05-05T09:00:35.477782Z", "last_login": "2023-05-05T09:00:35.477782Z",
"approval_required": true, "approval_required": true,
"country_code": "DE",
"city_name": "Berlin",
"accessible_peers": [ "accessible_peers": [
{ {
"id": "chacbco6lnnbn6cg5s90", "id": "chacbco6lnnbn6cg5s90",
@@ -442,9 +452,12 @@ echo $response;
"id": "string", "id": "string",
"name": "string", "name": "string",
"ip": "string", "ip": "string",
"connection_ip": "string",
"connected": "boolean", "connected": "boolean",
"last_seen": "string", "last_seen": "string",
"os": "string", "os": "string",
"kernel_version": "string",
"geoname_id": "integer",
"version": "string", "version": "string",
"groups": [ "groups": [
{ {
@@ -463,6 +476,8 @@ echo $response;
"login_expired": "boolean", "login_expired": "boolean",
"last_login": "string", "last_login": "string",
"approval_required": "boolean", "approval_required": "boolean",
"country_code": "string",
"city_name": "string",
"accessible_peers": [ "accessible_peers": [
{ {
"id": "string", "id": "string",
@@ -474,13 +489,10 @@ echo $response;
] ]
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -501,36 +513,30 @@ echo $response;
</Properties> </Properties>
#### Request-Body Parameters #### Request-Body Parameters
<Properties>
<Properties><Property name="name" type="string" required={true}>
<Property name="name" type="string" required={true}
>
</Property>
<Property name="ssh_enabled" type="boolean" required={true} </Property>
<Property name="ssh_enabled" type="boolean" required={true}>
>
</Property>
<Property name="login_expiration_enabled" type="boolean" required={true}
>
</Property>
<Property name="approval_required" type="boolean" required={false} </Property>
<Property name="login_expiration_enabled" type="boolean" required={true}>
>
(Cloud only) Indicates whether peer needs approval
</Property> </Property>
</Properties> <Property name="approval_required" type="boolean" required={false}>
(Cloud only) Indicates whether peer needs approval
</Property>
</Properties>
</Col> </Col>
<Col sticky> <Col sticky>
@@ -729,17 +735,19 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "chacbco6lnnbn6cg5s90", "id": "chacbco6lnnbn6cg5s90",
"name": "stage-host-1", "name": "stage-host-1",
"ip": "10.64.0.1", "ip": "10.64.0.1",
"connection_ip": "35.64.0.1",
"connected": true, "connected": true,
"last_seen": "2023-05-05T10:05:26.420578Z", "last_seen": "2023-05-05T10:05:26.420578Z",
"os": "Darwin 13.2.1", "os": "Darwin 13.2.1",
"kernel_version": "23.2.0",
"geoname_id": 2643743,
"version": "0.14.0", "version": "0.14.0",
"groups": [ "groups": [
{ {
@@ -758,6 +766,8 @@ echo $response;
"login_expired": false, "login_expired": false,
"last_login": "2023-05-05T09:00:35.477782Z", "last_login": "2023-05-05T09:00:35.477782Z",
"approval_required": true, "approval_required": true,
"country_code": "DE",
"city_name": "Berlin",
"accessible_peers": [ "accessible_peers": [
{ {
"id": "chacbco6lnnbn6cg5s90", "id": "chacbco6lnnbn6cg5s90",
@@ -774,9 +784,12 @@ echo $response;
"id": "string", "id": "string",
"name": "string", "name": "string",
"ip": "string", "ip": "string",
"connection_ip": "string",
"connected": "boolean", "connected": "boolean",
"last_seen": "string", "last_seen": "string",
"os": "string", "os": "string",
"kernel_version": "string",
"geoname_id": "integer",
"version": "string", "version": "string",
"groups": [ "groups": [
{ {
@@ -795,6 +808,8 @@ echo $response;
"login_expired": "boolean", "login_expired": "boolean",
"last_login": "string", "last_login": "string",
"approval_required": "boolean", "approval_required": "boolean",
"country_code": "string",
"city_name": "string",
"accessible_peers": [ "accessible_peers": [
{ {
"id": "string", "id": "string",
@@ -806,13 +821,10 @@ echo $response;
] ]
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -974,11 +986,9 @@ echo $response;
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---

View File

@@ -157,9 +157,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
[ [
{ {
@@ -167,6 +166,10 @@ echo $response;
"name": "ch8i4ug6lnn4g9hqv7mg", "name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources", "description": "This is a default policy that allows connections between all the resources",
"enabled": true, "enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [ "rules": [
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
@@ -207,6 +210,9 @@ echo $response;
"name": "string", "name": "string",
"description": "string", "description": "string",
"enabled": "boolean", "enabled": "boolean",
"source_posture_checks": [
"string"
],
"rules": [ "rules": [
{ {
"id": "string", "id": "string",
@@ -240,13 +246,10 @@ echo $response;
} }
] ]
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -259,43 +262,97 @@ echo $response;
Creates a policy Creates a policy
#### Request-Body Parameters #### Request-Body Parameters
<Properties>
<Properties><Property name="id" type="string" required={false}>
<Property name="id" type="string" required={false} Policy ID
>
Policy ID
</Property>
<Property name="name" type="string" required={true} </Property>
<Property name="name" type="string" required={true}>
>
Policy name identifier
</Property>
<Property name="description" type="string" required={true} Policy name identifier
>
Policy friendly description
</Property>
<Property name="enabled" type="boolean" required={true} </Property>
<Property name="description" type="string" required={true}>
>
Policy status
</Property>
<Property name="rules" type="PolicyRuleUpdate[]" required={true} Policy friendly description
</Property>
> <Property name="enabled" type="boolean" required={true}>
Policy rule object for policy UI editor
</Property> Policy status
</Properties>
</Property>
<Property name="source_posture_checks" type="string[]" required={false}>
Posture checks ID's applied to policy source groups
</Property>
<Property name="rules" type="object[]" required={true}>
<details class="custom-details" open>
<summary>Policy rule object for policy UI editor</summary>
<Properties>
<Properties><Property name="id" type="string" required={false}>
Policy rule ID
</Property>
<Property name="name" type="string" required={true}>
Policy rule name identifier
</Property>
<Property name="description" type="string" required={false}>
Policy rule friendly description
</Property>
<Property name="enabled" type="boolean" required={true}>
Policy rule status
</Property>
<Property name="action" type="string" required={true} enumList={["accept","drop"]}>
Policy rule accept or drops packets
</Property>
<Property name="bidirectional" type="boolean" required={true}>
Define if the rule is applicable in both directions, sources, and destinations.
</Property>
<Property name="protocol" type="string" required={true} enumList={["all","tcp","udp","icmp"]}>
Policy rule type of the traffic
</Property>
<Property name="ports" type="string[]" required={false}>
Policy rule affected ports or it ranges list
</Property>
<Property name="sources" type="string[]" required={true}>
Policy rule source group IDs
</Property>
<Property name="destinations" type="string[]" required={true}>
Policy rule destination group IDs
</Property>
</Properties>
</Properties>
</details>
</Property>
</Properties>
</Col> </Col>
<Col sticky> <Col sticky>
@@ -310,6 +367,9 @@ curl -X POST https://api.netbird.io/api/policies \
"name": "ch8i4ug6lnn4g9hqv7mg", "name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources", "description": "This is a default policy that allows connections between all the resources",
"enabled": true, "enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [ "rules": [
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
@@ -340,6 +400,9 @@ let data = JSON.stringify({
"name": "ch8i4ug6lnn4g9hqv7mg", "name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources", "description": "This is a default policy that allows connections between all the resources",
"enabled": true, "enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [ "rules": [
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
@@ -392,6 +455,9 @@ payload = json.dumps({
"name": "ch8i4ug6lnn4g9hqv7mg", "name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources", "description": "This is a default policy that allows connections between all the resources",
"enabled": true, "enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [ "rules": [
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
@@ -444,6 +510,9 @@ func main() {
"name": "ch8i4ug6lnn4g9hqv7mg", "name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources", "description": "This is a default policy that allows connections between all the resources",
"enabled": true, "enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [ "rules": [
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
@@ -514,6 +583,9 @@ request.body = JSON.dump({
"name": "ch8i4ug6lnn4g9hqv7mg", "name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources", "description": "This is a default policy that allows connections between all the resources",
"enabled": true, "enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [ "rules": [
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
@@ -548,6 +620,9 @@ RequestBody body = RequestBody.create(mediaType, '{
"name": "ch8i4ug6lnn4g9hqv7mg", "name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources", "description": "This is a default policy that allows connections between all the resources",
"enabled": true, "enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [ "rules": [
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
@@ -598,6 +673,9 @@ curl_setopt_array($curl, array(
"name": "ch8i4ug6lnn4g9hqv7mg", "name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources", "description": "This is a default policy that allows connections between all the resources",
"enabled": true, "enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [ "rules": [
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
@@ -634,15 +712,17 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg", "name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources", "description": "This is a default policy that allows connections between all the resources",
"enabled": true, "enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [ "rules": [
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
@@ -681,6 +761,9 @@ echo $response;
"name": "string", "name": "string",
"description": "string", "description": "string",
"enabled": "boolean", "enabled": "boolean",
"source_posture_checks": [
"string"
],
"rules": [ "rules": [
{ {
"id": "string", "id": "string",
@@ -713,9 +796,10 @@ echo $response;
] ]
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -884,15 +968,17 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg", "name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources", "description": "This is a default policy that allows connections between all the resources",
"enabled": true, "enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [ "rules": [
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
@@ -931,6 +1017,9 @@ echo $response;
"name": "string", "name": "string",
"description": "string", "description": "string",
"enabled": "boolean", "enabled": "boolean",
"source_posture_checks": [
"string"
],
"rules": [ "rules": [
{ {
"id": "string", "id": "string",
@@ -963,13 +1052,10 @@ echo $response;
] ]
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -990,43 +1076,97 @@ echo $response;
</Properties> </Properties>
#### Request-Body Parameters #### Request-Body Parameters
<Properties>
<Properties><Property name="id" type="string" required={false}>
<Property name="id" type="string" required={false} Policy ID
>
Policy ID
</Property>
<Property name="name" type="string" required={true} </Property>
<Property name="name" type="string" required={true}>
>
Policy name identifier
</Property>
<Property name="description" type="string" required={true} Policy name identifier
>
Policy friendly description
</Property>
<Property name="enabled" type="boolean" required={true} </Property>
<Property name="description" type="string" required={true}>
>
Policy status
</Property>
<Property name="rules" type="PolicyRuleUpdate[]" required={true} Policy friendly description
</Property>
> <Property name="enabled" type="boolean" required={true}>
Policy rule object for policy UI editor
</Property> Policy status
</Properties>
</Property>
<Property name="source_posture_checks" type="string[]" required={false}>
Posture checks ID's applied to policy source groups
</Property>
<Property name="rules" type="object[]" required={true}>
<details class="custom-details" open>
<summary>Policy rule object for policy UI editor</summary>
<Properties>
<Properties><Property name="id" type="string" required={false}>
Policy rule ID
</Property>
<Property name="name" type="string" required={true}>
Policy rule name identifier
</Property>
<Property name="description" type="string" required={false}>
Policy rule friendly description
</Property>
<Property name="enabled" type="boolean" required={true}>
Policy rule status
</Property>
<Property name="action" type="string" required={true} enumList={["accept","drop"]}>
Policy rule accept or drops packets
</Property>
<Property name="bidirectional" type="boolean" required={true}>
Define if the rule is applicable in both directions, sources, and destinations.
</Property>
<Property name="protocol" type="string" required={true} enumList={["all","tcp","udp","icmp"]}>
Policy rule type of the traffic
</Property>
<Property name="ports" type="string[]" required={false}>
Policy rule affected ports or it ranges list
</Property>
<Property name="sources" type="string[]" required={true}>
Policy rule source group IDs
</Property>
<Property name="destinations" type="string[]" required={true}>
Policy rule destination group IDs
</Property>
</Properties>
</Properties>
</details>
</Property>
</Properties>
</Col> </Col>
<Col sticky> <Col sticky>
@@ -1041,6 +1181,9 @@ curl -X PUT https://api.netbird.io/api/policies/{policyId} \
"name": "ch8i4ug6lnn4g9hqv7mg", "name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources", "description": "This is a default policy that allows connections between all the resources",
"enabled": true, "enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [ "rules": [
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
@@ -1071,6 +1214,9 @@ let data = JSON.stringify({
"name": "ch8i4ug6lnn4g9hqv7mg", "name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources", "description": "This is a default policy that allows connections between all the resources",
"enabled": true, "enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [ "rules": [
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
@@ -1123,6 +1269,9 @@ payload = json.dumps({
"name": "ch8i4ug6lnn4g9hqv7mg", "name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources", "description": "This is a default policy that allows connections between all the resources",
"enabled": true, "enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [ "rules": [
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
@@ -1175,6 +1324,9 @@ func main() {
"name": "ch8i4ug6lnn4g9hqv7mg", "name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources", "description": "This is a default policy that allows connections between all the resources",
"enabled": true, "enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [ "rules": [
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
@@ -1245,6 +1397,9 @@ request.body = JSON.dump({
"name": "ch8i4ug6lnn4g9hqv7mg", "name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources", "description": "This is a default policy that allows connections between all the resources",
"enabled": true, "enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [ "rules": [
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
@@ -1279,6 +1434,9 @@ RequestBody body = RequestBody.create(mediaType, '{
"name": "ch8i4ug6lnn4g9hqv7mg", "name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources", "description": "This is a default policy that allows connections between all the resources",
"enabled": true, "enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [ "rules": [
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
@@ -1329,6 +1487,9 @@ curl_setopt_array($curl, array(
"name": "ch8i4ug6lnn4g9hqv7mg", "name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources", "description": "This is a default policy that allows connections between all the resources",
"enabled": true, "enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [ "rules": [
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
@@ -1365,15 +1526,17 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg", "name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources", "description": "This is a default policy that allows connections between all the resources",
"enabled": true, "enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [ "rules": [
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
@@ -1412,6 +1575,9 @@ echo $response;
"name": "string", "name": "string",
"description": "string", "description": "string",
"enabled": "boolean", "enabled": "boolean",
"source_posture_checks": [
"string"
],
"rules": [ "rules": [
{ {
"id": "string", "id": "string",
@@ -1444,13 +1610,10 @@ echo $response;
] ]
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -1612,11 +1775,9 @@ echo $response;
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---

File diff suppressed because it is too large Load Diff

View File

@@ -157,9 +157,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
[ [
{ {
@@ -202,13 +201,10 @@ echo $response;
} }
] ]
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -221,79 +217,55 @@ echo $response;
Creates a Route Creates a Route
#### Request-Body Parameters #### Request-Body Parameters
<Properties>
<Properties><Property name="description" type="string" required={true}>
<Property name="description" type="string" required={true} Route description
>
Route description
</Property>
<Property name="network_id" type="string" required={true} </Property>
<Property name="network_id" type="string" required={true} minLen={1} maxLen={40}>
minLen={1}
maxLen={40}
>
Route network identifier, to group HA routes
</Property>
<Property name="enabled" type="boolean" required={true} Route network identifier, to group HA routes
>
Route status
</Property>
<Property name="peer" type="string" required={false} </Property>
<Property name="enabled" type="boolean" required={true}>
>
Peer Identifier associated with route. This property can not be set together with `peer_groups`
</Property>
<Property name="peer_groups" type="string[]" required={false} Route status
>
Peers Group Identifier associated with route. This property can not be set together with `peer`
</Property>
<Property name="network" type="string" required={true} </Property>
<Property name="peer" type="string" required={false}>
>
Network range in CIDR format
</Property>
<Property name="metric" type="integer" required={true} Peer Identifier associated with route. This property can not be set together with `peer_groups`
min={1}
max={9999}
>
Route metric number. Lowest number has higher priority
</Property>
<Property name="masquerade" type="boolean" required={true} </Property>
<Property name="peer_groups" type="string[]" required={false}>
>
Indicate if peer should masquerade traffic to this route's prefix
</Property>
<Property name="groups" type="string[]" required={true} Peers Group Identifier associated with route. This property can not be set together with `peer`
</Property>
> <Property name="network" type="string" required={true}>
Group IDs containing routing peers
</Property> Network range in CIDR format
</Properties>
</Property>
<Property name="metric" type="integer" required={true} min={1} max={9999}>
Route metric number. Lowest number has higher priority
</Property>
<Property name="masquerade" type="boolean" required={true}>
Indicate if peer should masquerade traffic to this route's prefix
</Property>
<Property name="groups" type="string[]" required={true}>
Group IDs containing routing peers
</Property>
</Properties>
</Col> </Col>
<Col sticky> <Col sticky>
@@ -555,9 +527,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "chacdk86lnnboviihd7g", "id": "chacdk86lnnboviihd7g",
@@ -596,13 +567,10 @@ echo $response;
] ]
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -771,9 +739,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "chacdk86lnnboviihd7g", "id": "chacdk86lnnboviihd7g",
@@ -812,13 +779,10 @@ echo $response;
] ]
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -839,79 +803,55 @@ echo $response;
</Properties> </Properties>
#### Request-Body Parameters #### Request-Body Parameters
<Properties>
<Properties><Property name="description" type="string" required={true}>
<Property name="description" type="string" required={true} Route description
>
Route description
</Property>
<Property name="network_id" type="string" required={true} </Property>
<Property name="network_id" type="string" required={true} minLen={1} maxLen={40}>
minLen={1}
maxLen={40}
>
Route network identifier, to group HA routes
</Property>
<Property name="enabled" type="boolean" required={true} Route network identifier, to group HA routes
>
Route status
</Property>
<Property name="peer" type="string" required={false} </Property>
<Property name="enabled" type="boolean" required={true}>
>
Peer Identifier associated with route. This property can not be set together with `peer_groups`
</Property>
<Property name="peer_groups" type="string[]" required={false} Route status
>
Peers Group Identifier associated with route. This property can not be set together with `peer`
</Property>
<Property name="network" type="string" required={true} </Property>
<Property name="peer" type="string" required={false}>
>
Network range in CIDR format
</Property>
<Property name="metric" type="integer" required={true} Peer Identifier associated with route. This property can not be set together with `peer_groups`
min={1}
max={9999}
>
Route metric number. Lowest number has higher priority
</Property>
<Property name="masquerade" type="boolean" required={true} </Property>
<Property name="peer_groups" type="string[]" required={false}>
>
Indicate if peer should masquerade traffic to this route's prefix
</Property>
<Property name="groups" type="string[]" required={true} Peers Group Identifier associated with route. This property can not be set together with `peer`
</Property>
> <Property name="network" type="string" required={true}>
Group IDs containing routing peers
</Property> Network range in CIDR format
</Properties>
</Property>
<Property name="metric" type="integer" required={true} min={1} max={9999}>
Route metric number. Lowest number has higher priority
</Property>
<Property name="masquerade" type="boolean" required={true}>
Indicate if peer should masquerade traffic to this route's prefix
</Property>
<Property name="groups" type="string[]" required={true}>
Group IDs containing routing peers
</Property>
</Properties>
</Col> </Col>
<Col sticky> <Col sticky>
@@ -1173,9 +1113,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "chacdk86lnnboviihd7g", "id": "chacdk86lnnboviihd7g",
@@ -1214,13 +1153,10 @@ echo $response;
] ]
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -1382,11 +1318,9 @@ echo $response;
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---

View File

@@ -157,9 +157,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
[ [
{ {
@@ -214,13 +213,10 @@ echo $response;
} }
] ]
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -233,50 +229,40 @@ echo $response;
Creates a rule. This will be deprecated in favour of `/api/policies`. Creates a rule. This will be deprecated in favour of `/api/policies`.
#### Request-Body Parameters #### Request-Body Parameters
<Properties>
<Properties><Property name="name" type="string" required={true}>
<Property name="name" type="string" required={true} Rule name identifier
>
Rule name identifier
</Property>
<Property name="description" type="string" required={true} </Property>
<Property name="description" type="string" required={true}>
>
Rule friendly description
</Property>
<Property name="disabled" type="boolean" required={true} Rule friendly description
>
Rules status
</Property>
<Property name="flow" type="string" required={true} </Property>
<Property name="disabled" type="boolean" required={true}>
>
Rule flow, currently, only "bidirect" for bi-directional traffic is accepted
</Property>
<Property name="sources" type="string[]" required={false} Rules status
>
List of source group IDs
</Property>
<Property name="destinations" type="string[]" required={false} </Property>
<Property name="flow" type="string" required={true}>
> Rule flow, currently, only "bidirect" for bi-directional traffic is accepted
List of destination group IDs
</Property> </Property>
</Properties> <Property name="sources" type="string[]" required={false}>
List of source group IDs
</Property>
<Property name="destinations" type="string[]" required={false}>
List of destination group IDs
</Property>
</Properties>
</Col> </Col>
<Col sticky> <Col sticky>
@@ -517,9 +503,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
@@ -570,9 +555,10 @@ echo $response;
] ]
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -741,9 +727,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
@@ -794,13 +779,10 @@ echo $response;
] ]
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -821,50 +803,40 @@ echo $response;
</Properties> </Properties>
#### Request-Body Parameters #### Request-Body Parameters
<Properties>
<Properties><Property name="name" type="string" required={true}>
<Property name="name" type="string" required={true} Rule name identifier
>
Rule name identifier
</Property>
<Property name="description" type="string" required={true} </Property>
<Property name="description" type="string" required={true}>
>
Rule friendly description
</Property>
<Property name="disabled" type="boolean" required={true} Rule friendly description
>
Rules status
</Property>
<Property name="flow" type="string" required={true} </Property>
<Property name="disabled" type="boolean" required={true}>
>
Rule flow, currently, only "bidirect" for bi-directional traffic is accepted
</Property>
<Property name="sources" type="string[]" required={false} Rules status
>
List of source group IDs
</Property>
<Property name="destinations" type="string[]" required={false} </Property>
<Property name="flow" type="string" required={true}>
> Rule flow, currently, only "bidirect" for bi-directional traffic is accepted
List of destination group IDs
</Property> </Property>
</Properties> <Property name="sources" type="string[]" required={false}>
List of source group IDs
</Property>
<Property name="destinations" type="string[]" required={false}>
List of destination group IDs
</Property>
</Properties>
</Col> </Col>
<Col sticky> <Col sticky>
@@ -1105,9 +1077,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "ch8i4ug6lnn4g9hqv7mg", "id": "ch8i4ug6lnn4g9hqv7mg",
@@ -1158,13 +1129,10 @@ echo $response;
] ]
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -1326,11 +1294,9 @@ echo $response;
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---

View File

@@ -157,13 +157,12 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
[ [
{ {
"id": "2531583362", "id": 2531583362,
"key": "A616097E-FCF0-48FA-9354-CA4A61142761", "key": "A616097E-FCF0-48FA-9354-CA4A61142761",
"name": "Default key", "name": "Default key",
"expires": "2023-06-01T14:47:22.291057Z", "expires": "2023-06-01T14:47:22.291057Z",
@@ -204,13 +203,10 @@ echo $response;
} }
] ]
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -223,61 +219,45 @@ echo $response;
Creates a setup key Creates a setup key
#### Request-Body Parameters #### Request-Body Parameters
<Properties>
<Properties><Property name="name" type="string" required={true}>
<Property name="name" type="string" required={true} Setup Key name
>
Setup Key name
</Property>
<Property name="type" type="string" required={true} </Property>
<Property name="type" type="string" required={true}>
>
Setup key type, one-off for single time usage and reusable
</Property>
<Property name="expires_in" type="integer" required={true} Setup key type, one-off for single time usage and reusable
min={86400}
max={31536000}
>
Expiration time in seconds
</Property>
<Property name="revoked" type="boolean" required={true} </Property>
<Property name="expires_in" type="integer" required={true} min={86400} max={31536000}>
>
Setup key revocation status
</Property>
<Property name="auto_groups" type="string[]" required={true} Expiration time in seconds
>
List of group IDs to auto-assign to peers registered with this key
</Property>
<Property name="usage_limit" type="integer" required={true} </Property>
<Property name="revoked" type="boolean" required={true}>
>
A number of times this key can be used. The value of 0 indicates the unlimited usage.
</Property>
<Property name="ephemeral" type="boolean" required={false} Setup key revocation status
</Property>
> <Property name="auto_groups" type="string[]" required={true}>
Indicate that the peer will be ephemeral or not
</Property> List of group IDs to auto-assign to peers registered with this key
</Properties>
</Property>
<Property name="usage_limit" type="integer" required={true}>
A number of times this key can be used. The value of 0 indicates the unlimited usage.
</Property>
<Property name="ephemeral" type="boolean" required={false}>
Indicate that the peer will be ephemeral or not
</Property>
</Properties>
</Col> </Col>
<Col sticky> <Col sticky>
@@ -511,12 +491,11 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "2531583362", "id": 2531583362,
"key": "A616097E-FCF0-48FA-9354-CA4A61142761", "key": "A616097E-FCF0-48FA-9354-CA4A61142761",
"name": "Default key", "name": "Default key",
"expires": "2023-06-01T14:47:22.291057Z", "expires": "2023-06-01T14:47:22.291057Z",
@@ -554,13 +533,10 @@ echo $response;
"ephemeral": "boolean" "ephemeral": "boolean"
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -729,12 +705,11 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "2531583362", "id": 2531583362,
"key": "A616097E-FCF0-48FA-9354-CA4A61142761", "key": "A616097E-FCF0-48FA-9354-CA4A61142761",
"name": "Default key", "name": "Default key",
"expires": "2023-06-01T14:47:22.291057Z", "expires": "2023-06-01T14:47:22.291057Z",
@@ -772,13 +747,10 @@ echo $response;
"ephemeral": "boolean" "ephemeral": "boolean"
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -799,61 +771,45 @@ echo $response;
</Properties> </Properties>
#### Request-Body Parameters #### Request-Body Parameters
<Properties>
<Properties><Property name="name" type="string" required={true}>
<Property name="name" type="string" required={true} Setup Key name
>
Setup Key name
</Property>
<Property name="type" type="string" required={true} </Property>
<Property name="type" type="string" required={true}>
>
Setup key type, one-off for single time usage and reusable
</Property>
<Property name="expires_in" type="integer" required={true} Setup key type, one-off for single time usage and reusable
min={86400}
max={31536000}
>
Expiration time in seconds
</Property>
<Property name="revoked" type="boolean" required={true} </Property>
<Property name="expires_in" type="integer" required={true} min={86400} max={31536000}>
>
Setup key revocation status
</Property>
<Property name="auto_groups" type="string[]" required={true} Expiration time in seconds
>
List of group IDs to auto-assign to peers registered with this key
</Property>
<Property name="usage_limit" type="integer" required={true} </Property>
<Property name="revoked" type="boolean" required={true}>
>
A number of times this key can be used. The value of 0 indicates the unlimited usage.
</Property>
<Property name="ephemeral" type="boolean" required={false} Setup key revocation status
</Property>
> <Property name="auto_groups" type="string[]" required={true}>
Indicate that the peer will be ephemeral or not
</Property> List of group IDs to auto-assign to peers registered with this key
</Properties>
</Property>
<Property name="usage_limit" type="integer" required={true}>
A number of times this key can be used. The value of 0 indicates the unlimited usage.
</Property>
<Property name="ephemeral" type="boolean" required={false}>
Indicate that the peer will be ephemeral or not
</Property>
</Properties>
</Col> </Col>
<Col sticky> <Col sticky>
@@ -1087,12 +1043,11 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "2531583362", "id": 2531583362,
"key": "A616097E-FCF0-48FA-9354-CA4A61142761", "key": "A616097E-FCF0-48FA-9354-CA4A61142761",
"name": "Default key", "name": "Default key",
"expires": "2023-06-01T14:47:22.291057Z", "expires": "2023-06-01T14:47:22.291057Z",
@@ -1130,13 +1085,10 @@ echo $response;
"ephemeral": "boolean" "ephemeral": "boolean"
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---

View File

@@ -165,9 +165,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
[ [
{ {
@@ -192,13 +191,10 @@ echo $response;
} }
] ]
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -219,26 +215,20 @@ echo $response;
</Properties> </Properties>
#### Request-Body Parameters #### Request-Body Parameters
<Properties>
<Properties><Property name="name" type="string" required={true}>
<Property name="name" type="string" required={true} Name of the token
>
Name of the token
</Property>
<Property name="expires_in" type="integer" required={true} </Property>
<Property name="expires_in" type="integer" required={true} min={1} max={365}>
min={1} Expiration in days
</Property>
max={365} </Properties>
>
Expiration in days
</Property>
</Properties>
</Col> </Col>
<Col sticky> <Col sticky>
@@ -423,12 +413,11 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"plain_token": "2023-05-02T14:48:20.465209Z", "plain_token": {},
"personal_access_token": { "personal_access_token": {
"id": "ch8i54g6lnn4g9hqv7n0", "id": "ch8i54g6lnn4g9hqv7n0",
"name": "My first token", "name": "My first token",
@@ -452,13 +441,10 @@ echo $response;
} }
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -631,9 +617,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "ch8i54g6lnn4g9hqv7n0", "id": "ch8i54g6lnn4g9hqv7n0",
@@ -654,13 +639,10 @@ echo $response;
"last_used": "string" "last_used": "string"
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -826,11 +808,9 @@ echo $response;
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---

View File

@@ -165,9 +165,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
[ [
{ {
@@ -206,13 +205,10 @@ echo $response;
} }
] ]
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -225,43 +221,35 @@ echo $response;
Creates a new service user or sends an invite to a regular user Creates a new service user or sends an invite to a regular user
#### Request-Body Parameters #### Request-Body Parameters
<Properties>
<Properties><Property name="email" type="string" required={false}>
<Property name="email" type="string" required={false} User's Email to send invite to
>
User's Email to send invite to
</Property>
<Property name="name" type="string" required={false} </Property>
<Property name="name" type="string" required={false}>
>
User's full name
</Property>
<Property name="role" type="string" required={true} User's full name
>
User's NetBird account role
</Property>
<Property name="auto_groups" type="string[]" required={true} </Property>
<Property name="role" type="string" required={true}>
>
Group IDs to auto-assign to peers registered by this user
</Property>
<Property name="is_service_user" type="boolean" required={true} User's NetBird account role
</Property>
> <Property name="auto_groups" type="string[]" required={true}>
Is true if this user is a service user
</Property> Group IDs to auto-assign to peers registered by this user
</Properties>
</Property>
<Property name="is_service_user" type="boolean" required={true}>
Is true if this user is a service user
</Property>
</Properties>
</Col> </Col>
<Col sticky> <Col sticky>
@@ -481,9 +469,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "google-oauth2|277474792786460067937", "id": "google-oauth2|277474792786460067937",
@@ -518,13 +505,10 @@ echo $response;
"issued": "string" "issued": "string"
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -545,29 +529,25 @@ echo $response;
</Properties> </Properties>
#### Request-Body Parameters #### Request-Body Parameters
<Properties>
<Properties><Property name="role" type="string" required={true}>
<Property name="role" type="string" required={true} User's NetBird account role
>
User's NetBird account role
</Property>
<Property name="auto_groups" type="string[]" required={true} </Property>
<Property name="auto_groups" type="string[]" required={true}>
>
Group IDs to auto-assign to peers registered by this user
</Property>
<Property name="is_blocked" type="boolean" required={true} Group IDs to auto-assign to peers registered by this user
</Property>
> <Property name="is_blocked" type="boolean" required={true}>
If set to true then user is blocked and can't use the system
</Property> If set to true then user is blocked and can't use the system
</Properties>
</Property>
</Properties>
</Col> </Col>
<Col sticky> <Col sticky>
@@ -773,9 +753,8 @@ echo $response;
</CodeGroup> </CodeGroup>
<CodeGroup title="Response">
<CodeGroup title="Response">
```json {{ title: 'Example' }} ```json {{ title: 'Example' }}
{ {
"id": "google-oauth2|277474792786460067937", "id": "google-oauth2|277474792786460067937",
@@ -810,13 +789,10 @@ echo $response;
"issued": "string" "issued": "string"
} }
``` ```
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -978,11 +954,9 @@ echo $response;
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---
@@ -1144,11 +1118,9 @@ echo $response;
</CodeGroup> </CodeGroup>
</Col>
</Col>
</Row> </Row>
--- ---

3
src/styles/global.css Normal file
View File

@@ -0,0 +1,3 @@
.custom-details li {
margin-left: 50px !important;
}