diff --git a/generator/api.ts b/generator/api.ts index 59024cc3..b08ad40a 100644 --- a/generator/api.ts +++ b/generator/api.ts @@ -1,17 +1,43 @@ import template from './templates/ApiTemplate' 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 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) { + // 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 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.1': case '3.0.3': + case '3.1.0': await gen_v3(spec, outputDir) 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 & { path: string } + +export type objectRepresentation = { + example: Object + schema: Object +} + export type enrichedOperation = OpenAPIV3.OperationObject & { path: string fullPath: string operationId: string + request: objectRepresentation + response: objectRepresentation } - export type schemaParameter = { name: string type: string @@ -46,12 +74,7 @@ export type schemaParameter = { minLength?: number maxLength?: number enum?: string[] -} - -export type component = { - example: Object - schema: Object - parameters: schemaParameter[] + sub?: Map } 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) => { 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 = { ...operation, path: key, @@ -71,6 +117,8 @@ async function gen_v3(spec: OpenAPIV3.Document, dest: string) { operationId: slugify(operation.summary!), responseList: toArrayWithKey(operation.responses!, 'responseCode') || [], + request: request, + response: response, } let tag = operation.tags.pop() 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) => { const operations = value @@ -98,121 +144,70 @@ async function gen_v3(spec: OpenAPIV3.Document, dest: string) { tag: key, sections, operations, - components, + // components, }) // Write to disk let outputFile = dest + "/" + key.toLowerCase().replace(" ", "-") + ".mdx" writeToDisk(outputFile, content) // console.log('Saved: ', outputFile) + }) } -function readComponents(components: OpenAPIV3.ComponentsObject) : Map { - let componentsOutput = new Map() - - for (const [key, value] of Object.entries(components.schemas)) { - let [schema, example, parameter] = resolveComponents(value, components) - let component = { - example: example, - schema: schema, - parameters: parameter +function extractInfo(obj, mode = 'example') { + // Handle the root level object that represents an array + if (obj.type === 'array' && obj.hasOwnProperty('items')) { + if (obj.items.hasOwnProperty('properties')) { + return [extractInfo(obj.items.properties, mode)]; + } else { + return [extractInfo(obj.items, mode)]; } - componentsOutput.set(key, component) } - return componentsOutput -} - -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() - let subcomponent = components.schemas[subcomponentName] - return resolveComponents(subcomponent, components) - } - if((value as OpenAPIV3.SchemaObject).properties) { - return resolveProperties(value as OpenAPIV3.SchemaObject, components) - } - if((value as OpenAPIV3.SchemaObject).allOf) { - return resolveAllOf(value as OpenAPIV3.SchemaObject, components) - } - if((value as OpenAPIV3.SchemaObject).type || (value as OpenAPIV3.SchemaObject).example) { - return [(value as OpenAPIV3.SchemaObject).type, (value as OpenAPIV3.SchemaObject).example, null] - } -} - -function resolveAllOf(object: OpenAPIV3.SchemaObject, components: OpenAPIV3.ComponentsObject) : [Object, Object, schemaParameter[]] { - let examples = new Map() - let schemas = new Map() - let parameters: schemaParameter[] = [] - for (const [key, value] of Object.entries(object.allOf)) { - let example; - let schema; - let parameter; - if((value as OpenAPIV3.ReferenceObject).$ref) { - let subcomponentName = (value as OpenAPIV3.ReferenceObject).$ref.split('/').pop() - let subcomponent = components.schemas[subcomponentName]; - [schema, example, parameter] = resolveComponents(subcomponent, components) - } - if((value as OpenAPIV3.SchemaObject).properties) { - [schema, example, parameter] = resolveProperties(value as OpenAPIV3.SchemaObject, components) - } - if(!(example instanceof Map)) { - example = new Map(Object.entries(example)) - } - if(!(schema instanceof Map)) { - schema = new Map(Object.entries(schema)) - } - parameters = parameters.concat(parameter) - examples = mergeMaps(examples, example) - schemas = mergeMaps(schemas, schema) - } - return [Object.fromEntries(schemas), Object.fromEntries(examples), parameters] -} - - -function resolveProperties(value: OpenAPIV3.SchemaObject, components: OpenAPIV3.ComponentsObject): [Object, Object, schemaParameter[]] { - let examples = new Map() - let schemas = new Map() - 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, map2: Map) : Map { - return new Map([...Array.from(map1.entries()), ...Array.from(map2.entries())]); + // If mode is 'example' and the object has an 'example', return it immediately + if (mode === 'example' && obj.hasOwnProperty('example')) { + return obj.example; + } + + // For an object with 'properties', check if there's an example at this level first + if (obj.type === 'object' && obj.hasOwnProperty('properties')) { + // If an example is provided at the current level, return it, avoiding deeper analysis + if (obj.hasOwnProperty('example')) { + return obj.example; + } else { + // If no example is provided, then proceed to extract info from its properties + const result = {}; + for (const key in obj.properties) { + if (obj.properties.hasOwnProperty(key)) { + result[key] = extractInfo(obj.properties[key], mode); + } + } + return result; + } + } + + // Return the type for elementary types if mode is 'type' + if (mode === 'type' && ['string', 'number', 'boolean', 'integer'].includes(obj.type)) { + return obj.type; + } + + // Handle arrays, assuming each item might be an object with its own structure + if (Array.isArray(obj)) { + return obj.map(item => extractInfo(item, mode)); + } + + // Special handling for objects that represent schemas (e.g., with 'type' and 'properties') + if (typeof obj === 'object' && obj !== null) { + const result = {}; + for (const key in obj) { + if (obj.hasOwnProperty(key)) { + result[key] = extractInfo(obj[key], mode); + } + } + return result; + } + + // Return the object if it doesn't match any of the above conditions + return obj; } diff --git a/generator/expandOpenAPIRef.go b/generator/expandOpenAPIRef.go new file mode 100644 index 00000000..803c6316 --- /dev/null +++ b/generator/expandOpenAPIRef.go @@ -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 + } + +} diff --git a/generator/go.mod b/generator/go.mod new file mode 100644 index 00000000..588084af --- /dev/null +++ b/generator/go.mod @@ -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 +) diff --git a/generator/go.sum b/generator/go.sum new file mode 100644 index 00000000..81067f17 --- /dev/null +++ b/generator/go.sum @@ -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= diff --git a/generator/templates/ApiTemplate.ts b/generator/templates/ApiTemplate.ts index a1405108..a62303fe 100644 --- a/generator/templates/ApiTemplate.ts +++ b/generator/templates/ApiTemplate.ts @@ -29,30 +29,67 @@ export const title = '<%- tag %>' <% }); -%> <% }; -%> - <% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %> + <% if(operation.requestBody && operation.requestBody["content"]["application/json"].schema.properties){ %> #### Request-Body Parameters - - <% components.get(operation.requestBody?.content['application/json'].schema.$ref.split('/').pop())?.parameters.forEach(function(parameter){ %> - \} - <% if(parameter.enum){ %> - enumList="<%- parameter.enum %>" - <% }; -%> - <% if(parameter.minimum){ %> - min=\{<%- parameter.minimum %>\} - <% }; -%> - <% if(parameter.maximum){ %> - max=\{<%- parameter.maximum %>\} - <% }; -%> - <% if(parameter.minLength){ %> - minLen=\{<%- parameter.minLength %>\} - <% }; -%> - <% if(parameter.maxLength){ %> - maxLen=\{<%- parameter.maxLength %>\} - <% }; -%> > - <%- parameter.description %> - - <% }); -%> - + + <% +function renderProperties(properties, required = [], depth = 0) { + %><% + Object.entries(properties).forEach(([key, value]) => { + let type = value.type; + var isRequired = required.includes(key) ? '{true}' : '{false}'; + + if (type === 'array' && value.items) { + if (value.items.type === 'object' && value.items.properties) { + type = 'object[]'; + } else { + type = value.items.type + '[]'; + } + } + + %><% + if(value.enum) { + %> enumList={<%- JSON.stringify(value.enum) %>}<% + } + if(value.minimum !== undefined) { + %> 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)) { %> +
+ <%- value.description || 'More Information' %> + + <% if (type === 'object[]') { %> + <% renderProperties(value.items.properties, value.items.required || [], depth + 1); %> + <% } else { %> + <% renderProperties(value.properties, value.required || [], depth + 1); %> + <% } %> + +
+ <% } else { %> + <% if(value.description) { %><%- value.description %><% } %> + <% } %> +
+ <% }); + %>
<% +} + +var schema = operation.requestBody["content"]["application/json"].schema; +if(schema && schema.properties) { + renderProperties(schema.properties, schema.required || []); +} +%> + + <% }; -%> @@ -65,13 +102,13 @@ curl -X <%- operation.operation.toUpperCase() %> <%- operation.fullPath %> \\<% -H 'Accept: application/json' \\<% }; -%> <% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %> -H 'Content-Type: application/json' \\<% }; %> --H 'Authorization: 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 ' <% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %>\\\n--data-raw '<%- JSON.stringify(operation.request.example, null, 2) -%>'<% }; %> \`\`\` \`\`\`js const axios = require('axios'); <% 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 = { method: '<%- operation.operation.toLowerCase() %>', @@ -103,7 +140,7 @@ import json url = "<%- operation.fullPath %>" <% 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(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %> @@ -133,7 +170,7 @@ func main() { url := "<%- operation.fullPath %>" method := "<%- operation.operation.toUpperCase() %>" <% 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 { } @@ -183,7 +220,7 @@ request["Content-Type"] = "application/json"<% }; -%> request["Accept"] = "application/json"<% }; %> request["Authorization"] = "Token " <% 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) puts response.read_body @@ -194,7 +231,7 @@ OkHttpClient client = new OkHttpClient().newBuilder() .build(); <% if(operation.requestBody?.content && operation.requestBody?.content['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() .url("<%- operation.fullPath %>") <% 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, <% if(true){ %>CURLOPT_CUSTOMREQUEST => '<%- operation.operation.toUpperCase() %>',<% }; -%> <% 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(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %> 'Content-Type: application/json',<% }; -%> @@ -239,29 +276,18 @@ echo $response; \`\`\` - <% operation.responseList.forEach(function(response){ %> - <% if(response?.content && response?.content['application/json']){ %> - <% if(response?.content['application/json'].schema.type === 'array'){ %> - + + <% if(operation.response){ %> + \`\`\`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.stringify(new Array(components.get(response?.content['application/json'].schema.items.$ref?.split('/').pop())?.schema), null, 2) %> +<%- JSON.stringify(operation.response.schema, null, 2) %> \`\`\` - - <% } else { %> - -\`\`\`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) %> -\`\`\` - - <% }; -%> - <% }; -%> - <% }); -%> + + <% }; %> + diff --git a/package.json b/package.json index 88ea5f6b..d6527a3e 100644 --- a/package.json +++ b/package.json @@ -37,11 +37,13 @@ "@tailwindcss/typography": "^0.5.8", "acorn": "^8.8.2", "algoliasearch": "^4.17.0", + "allof-merge": "^0.6.6", "autoprefixer": "^10.4.7", "clsx": "^1.2.0", "ejs": "^3.1.9", "focus-visible": "^5.2.0", "framer-motion": "10.12.9", + "js-yaml": "^4.1.0", "lodash": "^4.17.21", "mdast-util-to-string": "^3.2.0", "mdx-annotations": "^0.1.1", diff --git a/src/components/NavigationAPI.jsx b/src/components/NavigationAPI.jsx index be461c52..9922f179 100644 --- a/src/components/NavigationAPI.jsx +++ b/src/components/NavigationAPI.jsx @@ -29,6 +29,8 @@ export const apiNavigation = [ { title: 'Groups', href: '/api/resources/groups' }, { title: 'Rules', href: '/api/resources/rules' }, { 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: 'DNS', href: '/api/resources/dns' }, { title: 'Events', href: '/api/resources/events' }, diff --git a/src/components/mdx.jsx b/src/components/mdx.jsx index 4397f0d4..44a65c0d 100644 --- a/src/components/mdx.jsx +++ b/src/components/mdx.jsx @@ -98,12 +98,12 @@ export function Property({ name, type, required, min, max, minLen, maxLen, enumL {type}
Required
-
- {required && 'required'} -
-
- {!required && 'optional'} -
+ {required &&
+ required +
} + {!required &&
+ optional +
}
Enum
{/*{enumList && "Possible values: [" + enumList.split(',').forEach((type) => ({type})) + "]"}*/} diff --git a/src/pages/_app.jsx b/src/pages/_app.jsx index 5dad17b4..6c6c32d2 100644 --- a/src/pages/_app.jsx +++ b/src/pages/_app.jsx @@ -6,6 +6,7 @@ import * as mdxComponents from '@/components/mdx' import { useMobileNavigationStore } from '@/components/MobileNavigation' import '@/styles/tailwind.css' +import '@/styles/global.css'; import 'focus-visible' import {Layout} from "@/components/Layout"; import {slugifyWithCounter} from "@sindresorhus/slugify"; diff --git a/src/pages/ipa/resources/accounts.mdx b/src/pages/ipa/resources/accounts.mdx index a5532c7d..89376811 100644 --- a/src/pages/ipa/resources/accounts.mdx +++ b/src/pages/ipa/resources/accounts.mdx @@ -157,9 +157,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} [ { @@ -200,13 +199,174 @@ echo $response; } ] ``` - - - - - - + + + + + + +--- + + +## Delete an Account {{ tag: 'DELETE' , label: '/api/accounts/{accountId}' }} + + + + Deletes an account and all its resources. Only administrators and account owners can delete accounts. + + #### Path Parameters + + + + The unique identifier of an account + + + + + +```bash {{ title: 'cURL' }} +curl -X DELETE https://api.netbird.io/api/accounts/{accountId} \ +-H 'Authorization: Token ' +``` + +```js +const axios = require('axios'); + +let config = { + method: 'delete', + maxBodyLength: Infinity, + url: '/api/accounts/{accountId}', + headers: { + 'Authorization': 'Token ' + } +}; + +axios(config) +.then((response) => { + console.log(JSON.stringify(response.data)); +}) +.catch((error) => { + console.log(error); +}); +``` + +```python +import requests +import json + +url = "https://api.netbird.io/api/accounts/{accountId}" + +headers: { + 'Authorization': 'Token ' +} + +response = requests.request("DELETE", url, headers=headers) + +print(response.text) +``` + +```go +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/accounts/{accountId}" + method := "DELETE" + + client := &http.Client { + } + req, err := http.NewRequest(method, url, nil) + + if err != nil { + fmt.Println(err) + return + { + + req.Header.Add("Authorization", "Token ") + + res, err := client.Do(req) + if err != nil { + fmt.Println(err) + return + } + defer res.Body.Close() + + body, err := ioutil.ReadAll(res.Body) + if err != nil { + fmt.Println(err) + return + } + fmt.Println(string(body)) +} +``` + +```ruby +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/accounts/{accountId}") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Delete.new(url) +request["Authorization"] = "Token " + +response = https.request(request) +puts response.read_body +``` + +```java +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); + +Request request = new Request.Builder() + .url("https://api.netbird.io/api/accounts/{accountId}") + .method("DELETE") + .addHeader("Authorization: Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/accounts/{accountId}', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'DELETE', + CURLOPT_HTTPHEADER => array( + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` + + + + + + --- @@ -227,57 +387,69 @@ echo $response; #### Request-Body Parameters - + + - - 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). - +
+ More Information + + + - - Period of time after which peer login expires (seconds). - + 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). - - Allows propagate the new user auto groups to peers that belongs to the user - + + - - Allows extract groups from JWT claim and add it to account groups. - + Period of time after which peer login expires (seconds). - - Name of the claim from which we extract groups names to add it to account groups. - + + - - List of groups to which users are allowed access - + Allows propagate the new user auto groups to peers that belongs to the user - - (Cloud only) Enables or disables peer approval globally. If enabled, all peers added will be in pending state until approved by an admin. - - + + + + Allows extract groups from JWT claim and add it to account groups. + + + + + Name of the claim from which we extract groups names to add it to account groups. + + + + + List of groups to which users are allowed access + + + + +
+ More Information + + + + + (Cloud only) Enables or disables peer approval globally. If enabled, all peers added will be in pending state until approved by an admin. + + + + + +
+ +
+
+ + +
+ +
+
+ + @@ -539,9 +711,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7l0", @@ -578,6 +749,7 @@ echo $response; } } ``` + @@ -746,11 +918,8 @@ echo $response; - - - - - + + --- diff --git a/src/pages/ipa/resources/dns.mdx b/src/pages/ipa/resources/dns.mdx index 01cea194..c353af76 100644 --- a/src/pages/ipa/resources/dns.mdx +++ b/src/pages/ipa/resources/dns.mdx @@ -157,9 +157,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} [ { @@ -210,13 +209,10 @@ echo $response; } ] ``` - - - - - - - + + + + --- @@ -229,72 +225,72 @@ echo $response; Creates a Nameserver Group #### Request-Body Parameters - + + - - Name of nameserver group name - + Name of nameserver group name - - Description of the nameserver group - + + - - Nameserver list - + Description of the nameserver group - - Nameserver group status - + + - - Distribution group IDs that defines group of peers that will use this nameserver group - +
+ Nameserver list + + + - - Defines if a nameserver group is primary that resolves all domains. It should be true only if domains list is empty. - + Nameserver IP - - Match domain list. It should be empty only if primary is true. - + + - - Search domain status for match domains. It should be true only if domains list is not empty. - - + Nameserver Type + + + + + Nameserver Port + + + + + +
+ +
+ + + Nameserver group status + + + + + Distribution group IDs that defines group of peers that will use this nameserver group + + + + + Defines if a nameserver group is primary that resolves all domains. It should be true only if domains list is empty. + + + + + Match domain list. It should be empty only if primary is true. + + + + + Search domain status for match domains. It should be true only if domains list is not empty. + + +
+ + @@ -591,9 +587,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7m0", @@ -640,13 +635,10 @@ echo $response; "search_domains_enabled": "boolean" } ``` - - - - - - - + + + + --- @@ -815,9 +807,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7m0", @@ -864,13 +855,10 @@ echo $response; "search_domains_enabled": "boolean" } ``` - - - - - - - + + + + --- @@ -891,72 +879,72 @@ echo $response;
#### Request-Body Parameters - + + - - Name of nameserver group name - + Name of nameserver group name - - Description of the nameserver group - + + - - Nameserver list - + Description of the nameserver group - - Nameserver group status - + + - - Distribution group IDs that defines group of peers that will use this nameserver group - +
+ Nameserver list + + + - - Defines if a nameserver group is primary that resolves all domains. It should be true only if domains list is empty. - + Nameserver IP - - Match domain list. It should be empty only if primary is true. - + + - - Search domain status for match domains. It should be true only if domains list is not empty. - - + Nameserver Type + + + + + Nameserver Port + + + + + +
+ +
+ + + Nameserver group status + + + + + Distribution group IDs that defines group of peers that will use this nameserver group + + + + + Defines if a nameserver group is primary that resolves all domains. It should be true only if domains list is empty. + + + + + Match domain list. It should be empty only if primary is true. + + + + + Search domain status for match domains. It should be true only if domains list is not empty. + + +
+ + @@ -1253,9 +1241,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7m0", @@ -1302,13 +1289,10 @@ echo $response; "search_domains_enabled": "boolean" } ``` - - - - - - - + + + + --- @@ -1470,11 +1454,9 @@ echo $response; - - - - - + + + --- @@ -1635,34 +1617,30 @@ echo $response; - - - + + ```json {{ title: 'Example' }} -[ - { +{ + "items": { "disabled_management_groups": [ "ch8i4ug6lnn4g9hqv7m0" ] } -] +} ``` ```json {{ title: 'Schema' }} -[ - { +{ + "items": { "disabled_management_groups": [ "string" ] } -] +} ``` - - - - - - - + + + + --- @@ -1675,15 +1653,15 @@ echo $response; Updates a DNS settings object #### Request-Body Parameters - + + - - Groups whose DNS management is disabled - - + Groups whose DNS management is disabled + + + + + @@ -1875,9 +1853,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "disabled_management_groups": [ @@ -1892,13 +1869,10 @@ echo $response; ] } ``` - - - - - - - + + + + --- diff --git a/src/pages/ipa/resources/events.mdx b/src/pages/ipa/resources/events.mdx index 70f2080b..a2e56060 100644 --- a/src/pages/ipa/resources/events.mdx +++ b/src/pages/ipa/resources/events.mdx @@ -157,13 +157,12 @@ echo $response; - - - + + ```json {{ title: 'Example' }} [ { - "id": "10", + "id": 10, "timestamp": "2023-05-05T10:04:37.473542Z", "activity": "Route created", "activity_code": "route.add", @@ -190,17 +189,23 @@ echo $response; "initiator_name": "string", "initiator_email": "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" + } + } } ] ``` - - - - - - - + + + + --- diff --git a/src/pages/ipa/resources/geo-locations.mdx b/src/pages/ipa/resources/geo-locations.mdx new file mode 100644 index 00000000..27ffac9e --- /dev/null +++ b/src/pages/ipa/resources/geo-locations.mdx @@ -0,0 +1,364 @@ +export const title = 'Geo Locations' + + + +## List all country codes {{ tag: 'GET' , label: '/api/locations/countries' }} + + + + Get list of all country in 2-letter ISO 3166-1 alpha-2 codes + + + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/locations/countries \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' +``` + +```js +const axios = require('axios'); + +let config = { + method: 'get', + maxBodyLength: Infinity, + url: '/api/locations/countries', + headers: { + 'Accept': 'application/json', + 'Authorization': 'Token ' + } +}; + +axios(config) +.then((response) => { + console.log(JSON.stringify(response.data)); +}) +.catch((error) => { + console.log(error); +}); +``` + +```python +import requests +import json + +url = "https://api.netbird.io/api/locations/countries" + +headers: { + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("GET", url, headers=headers) + +print(response.text) +``` + +```go +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/locations/countries" + method := "GET" + + client := &http.Client { + } + req, err := http.NewRequest(method, url, nil) + + if err != nil { + fmt.Println(err) + return + { + + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + res, err := client.Do(req) + if err != nil { + fmt.Println(err) + return + } + defer res.Body.Close() + + body, err := ioutil.ReadAll(res.Body) + if err != nil { + fmt.Println(err) + return + } + fmt.Println(string(body)) +} +``` + +```ruby +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/locations/countries") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Get.new(url) +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +response = https.request(request) +puts response.read_body +``` + +```java +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); + +Request request = new Request.Builder() + .url("https://api.netbird.io/api/locations/countries") + .method("GET") + .addHeader("Accept", "application/json") + .addHeader("Authorization: Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/locations/countries', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'GET', + CURLOPT_HTTPHEADER => array( + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` + + + + + +```json {{ title: 'Example' }} +[ + "DE" +] +``` +```json {{ title: 'Schema' }} +[ + "string" +] +``` + + + + + + +--- + + +## List all city names by country {{ tag: 'GET' , label: '/api/locations/countries/{country}/cities' }} + + + + Get a list of all English city names for a given country code + + #### Path Parameters + + + + + + + + + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/locations/countries/{country}/cities \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' +``` + +```js +const axios = require('axios'); + +let config = { + method: 'get', + maxBodyLength: Infinity, + url: '/api/locations/countries/{country}/cities', + headers: { + 'Accept': 'application/json', + 'Authorization': 'Token ' + } +}; + +axios(config) +.then((response) => { + console.log(JSON.stringify(response.data)); +}) +.catch((error) => { + console.log(error); +}); +``` + +```python +import requests +import json + +url = "https://api.netbird.io/api/locations/countries/{country}/cities" + +headers: { + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("GET", url, headers=headers) + +print(response.text) +``` + +```go +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/locations/countries/{country}/cities" + method := "GET" + + client := &http.Client { + } + req, err := http.NewRequest(method, url, nil) + + if err != nil { + fmt.Println(err) + return + { + + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + res, err := client.Do(req) + if err != nil { + fmt.Println(err) + return + } + defer res.Body.Close() + + body, err := ioutil.ReadAll(res.Body) + if err != nil { + fmt.Println(err) + return + } + fmt.Println(string(body)) +} +``` + +```ruby +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/locations/countries/{country}/cities") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Get.new(url) +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +response = https.request(request) +puts response.read_body +``` + +```java +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); + +Request request = new Request.Builder() + .url("https://api.netbird.io/api/locations/countries/{country}/cities") + .method("GET") + .addHeader("Accept", "application/json") + .addHeader("Authorization: Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/locations/countries/{country}/cities', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'GET', + CURLOPT_HTTPHEADER => array( + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` + + + + + +```json {{ title: 'Example' }} +{ + "geoname_id": 2950158, + "city_name": "Berlin" +} +``` +```json {{ title: 'Schema' }} +{ + "geoname_id": "integer", + "city_name": "string" +} +``` + + + + + + +--- diff --git a/src/pages/ipa/resources/groups.mdx b/src/pages/ipa/resources/groups.mdx index ce4e7a03..bc120109 100644 --- a/src/pages/ipa/resources/groups.mdx +++ b/src/pages/ipa/resources/groups.mdx @@ -157,9 +157,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} [ { @@ -192,13 +191,10 @@ echo $response; } ] ``` - - - - - - - + + + + --- @@ -211,22 +207,20 @@ echo $response; Creates a group #### Request-Body Parameters - + + - - Group name identifier - + Group name identifier - - List of peers ids - - + + + + List of peers ids + + + + + @@ -425,9 +419,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7m0", @@ -456,13 +449,10 @@ echo $response; ] } ``` - - - - - - - + + + + --- @@ -631,9 +621,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7m0", @@ -662,13 +651,10 @@ echo $response; ] } ``` - - - - - - - + + + + --- @@ -689,22 +675,20 @@ echo $response;
#### Request-Body Parameters - + + - - Group name identifier - + Group name identifier - - List of peers ids - - + + + + List of peers ids + + + + + @@ -903,9 +887,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7m0", @@ -934,13 +917,10 @@ echo $response; ] } ``` - - - - - - - + + + + --- @@ -1102,11 +1082,9 @@ echo $response; - - - - - + + + --- diff --git a/src/pages/ipa/resources/peers.mdx b/src/pages/ipa/resources/peers.mdx index 6763b474..c7375357 100644 --- a/src/pages/ipa/resources/peers.mdx +++ b/src/pages/ipa/resources/peers.mdx @@ -157,18 +157,20 @@ echo $response; - - - + + ```json {{ title: 'Example' }} [ { "id": "chacbco6lnnbn6cg5s90", "name": "stage-host-1", "ip": "10.64.0.1", + "connection_ip": "35.64.0.1", "connected": true, "last_seen": "2023-05-05T10:05:26.420578Z", "os": "Darwin 13.2.1", + "kernel_version": "23.2.0", + "geoname_id": 2643743, "version": "0.14.0", "groups": [ { @@ -187,6 +189,8 @@ echo $response; "login_expired": false, "last_login": "2023-05-05T09:00:35.477782Z", "approval_required": true, + "country_code": "DE", + "city_name": "Berlin", "accessible_peers_count": 5 } ] @@ -197,9 +201,12 @@ echo $response; "id": "string", "name": "string", "ip": "string", + "connection_ip": "string", "connected": "boolean", "last_seen": "string", "os": "string", + "kernel_version": "string", + "geoname_id": "integer", "version": "string", "groups": [ { @@ -218,17 +225,16 @@ echo $response; "login_expired": "boolean", "last_login": "string", "approval_required": "boolean", + "country_code": "string", + "city_name": "string", "accessible_peers_count": "integer" } ] ``` - - - - - - - + + + + --- @@ -397,17 +403,19 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "id": "chacbco6lnnbn6cg5s90", "name": "stage-host-1", "ip": "10.64.0.1", + "connection_ip": "35.64.0.1", "connected": true, "last_seen": "2023-05-05T10:05:26.420578Z", "os": "Darwin 13.2.1", + "kernel_version": "23.2.0", + "geoname_id": 2643743, "version": "0.14.0", "groups": [ { @@ -426,6 +434,8 @@ echo $response; "login_expired": false, "last_login": "2023-05-05T09:00:35.477782Z", "approval_required": true, + "country_code": "DE", + "city_name": "Berlin", "accessible_peers": [ { "id": "chacbco6lnnbn6cg5s90", @@ -442,9 +452,12 @@ echo $response; "id": "string", "name": "string", "ip": "string", + "connection_ip": "string", "connected": "boolean", "last_seen": "string", "os": "string", + "kernel_version": "string", + "geoname_id": "integer", "version": "string", "groups": [ { @@ -463,6 +476,8 @@ echo $response; "login_expired": "boolean", "last_login": "string", "approval_required": "boolean", + "country_code": "string", + "city_name": "string", "accessible_peers": [ { "id": "string", @@ -474,13 +489,10 @@ echo $response; ] } ``` - - - - - - - + + + + --- @@ -501,36 +513,30 @@ echo $response;
#### Request-Body Parameters - + + - - - + - - - + + - - - + - - (Cloud only) Indicates whether peer needs approval - - + + + + + + + + + (Cloud only) Indicates whether peer needs approval + + + + + @@ -729,17 +735,19 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "id": "chacbco6lnnbn6cg5s90", "name": "stage-host-1", "ip": "10.64.0.1", + "connection_ip": "35.64.0.1", "connected": true, "last_seen": "2023-05-05T10:05:26.420578Z", "os": "Darwin 13.2.1", + "kernel_version": "23.2.0", + "geoname_id": 2643743, "version": "0.14.0", "groups": [ { @@ -758,6 +766,8 @@ echo $response; "login_expired": false, "last_login": "2023-05-05T09:00:35.477782Z", "approval_required": true, + "country_code": "DE", + "city_name": "Berlin", "accessible_peers": [ { "id": "chacbco6lnnbn6cg5s90", @@ -774,9 +784,12 @@ echo $response; "id": "string", "name": "string", "ip": "string", + "connection_ip": "string", "connected": "boolean", "last_seen": "string", "os": "string", + "kernel_version": "string", + "geoname_id": "integer", "version": "string", "groups": [ { @@ -795,6 +808,8 @@ echo $response; "login_expired": "boolean", "last_login": "string", "approval_required": "boolean", + "country_code": "string", + "city_name": "string", "accessible_peers": [ { "id": "string", @@ -806,13 +821,10 @@ echo $response; ] } ``` - - - - - - - + + + + --- @@ -974,11 +986,9 @@ echo $response; - - - - - + + + --- diff --git a/src/pages/ipa/resources/policies.mdx b/src/pages/ipa/resources/policies.mdx index 8b2a1482..3df44a33 100644 --- a/src/pages/ipa/resources/policies.mdx +++ b/src/pages/ipa/resources/policies.mdx @@ -157,9 +157,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} [ { @@ -167,6 +166,10 @@ echo $response; "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], + "rules": [ { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -207,6 +210,9 @@ echo $response; "name": "string", "description": "string", "enabled": "boolean", + "source_posture_checks": [ + "string" + ], "rules": [ { "id": "string", @@ -240,13 +246,10 @@ echo $response; } ] ``` - - - - - - - + + + + --- @@ -259,43 +262,97 @@ echo $response; Creates a policy #### Request-Body Parameters - + + - - Policy ID - + Policy ID - - Policy name identifier - + + - - Policy friendly description - + Policy name identifier - - Policy status - + + - - Policy rule object for policy UI editor - - + Policy friendly description + + + + + Policy status + + + + + Posture checks ID's applied to policy source groups + + + + +
+ Policy rule object for policy UI editor + + + + + Policy rule ID + + + + + Policy rule name identifier + + + + + Policy rule friendly description + + + + + Policy rule status + + + + + Policy rule accept or drops packets + + + + + Define if the rule is applicable in both directions, sources, and destinations. + + + + + Policy rule type of the traffic + + + + + Policy rule affected ports or it ranges list + + + + + Policy rule source group IDs + + + + + Policy rule destination group IDs + + + + + +
+ +
+
+ + @@ -310,6 +367,9 @@ curl -X POST https://api.netbird.io/api/policies \ "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], "rules": [ { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -340,6 +400,9 @@ let data = JSON.stringify({ "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], "rules": [ { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -392,6 +455,9 @@ payload = json.dumps({ "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], "rules": [ { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -444,6 +510,9 @@ func main() { "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], "rules": [ { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -514,6 +583,9 @@ request.body = JSON.dump({ "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], "rules": [ { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -548,6 +620,9 @@ RequestBody body = RequestBody.create(mediaType, '{ "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], "rules": [ { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -598,6 +673,9 @@ curl_setopt_array($curl, array( "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], "rules": [ { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -634,15 +712,17 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7mg", "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], "rules": [ { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -681,6 +761,9 @@ echo $response; "name": "string", "description": "string", "enabled": "boolean", + "source_posture_checks": [ + "string" + ], "rules": [ { "id": "string", @@ -713,9 +796,10 @@ echo $response; ] } ``` - - - + + + + --- @@ -884,15 +968,17 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7mg", "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], "rules": [ { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -931,6 +1017,9 @@ echo $response; "name": "string", "description": "string", "enabled": "boolean", + "source_posture_checks": [ + "string" + ], "rules": [ { "id": "string", @@ -963,13 +1052,10 @@ echo $response; ] } ``` - - - - - - - + + + + --- @@ -990,43 +1076,97 @@ echo $response; #### Request-Body Parameters - + + - - Policy ID - + Policy ID - - Policy name identifier - + + - - Policy friendly description - + Policy name identifier - - Policy status - + + - - Policy rule object for policy UI editor - - + Policy friendly description + + + + + Policy status + + + + + Posture checks ID's applied to policy source groups + + + + +
+ Policy rule object for policy UI editor + + + + + Policy rule ID + + + + + Policy rule name identifier + + + + + Policy rule friendly description + + + + + Policy rule status + + + + + Policy rule accept or drops packets + + + + + Define if the rule is applicable in both directions, sources, and destinations. + + + + + Policy rule type of the traffic + + + + + Policy rule affected ports or it ranges list + + + + + Policy rule source group IDs + + + + + Policy rule destination group IDs + + + + + +
+ +
+
+ + @@ -1041,6 +1181,9 @@ curl -X PUT https://api.netbird.io/api/policies/{policyId} \ "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], "rules": [ { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -1071,6 +1214,9 @@ let data = JSON.stringify({ "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], "rules": [ { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -1123,6 +1269,9 @@ payload = json.dumps({ "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], "rules": [ { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -1175,6 +1324,9 @@ func main() { "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], "rules": [ { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -1245,6 +1397,9 @@ request.body = JSON.dump({ "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], "rules": [ { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -1279,6 +1434,9 @@ RequestBody body = RequestBody.create(mediaType, '{ "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], "rules": [ { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -1329,6 +1487,9 @@ curl_setopt_array($curl, array( "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], "rules": [ { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -1365,15 +1526,17 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7mg", "name": "ch8i4ug6lnn4g9hqv7mg", "description": "This is a default policy that allows connections between all the resources", "enabled": true, + "source_posture_checks": [ + "chacdk86lnnboviihd70" + ], "rules": [ { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -1412,6 +1575,9 @@ echo $response; "name": "string", "description": "string", "enabled": "boolean", + "source_posture_checks": [ + "string" + ], "rules": [ { "id": "string", @@ -1444,13 +1610,10 @@ echo $response; ] } ``` - - - - - - - + + + + --- @@ -1612,11 +1775,9 @@ echo $response; - - - - - + + + --- diff --git a/src/pages/ipa/resources/posture-checks.mdx b/src/pages/ipa/resources/posture-checks.mdx new file mode 100644 index 00000000..1da50b3b --- /dev/null +++ b/src/pages/ipa/resources/posture-checks.mdx @@ -0,0 +1,2266 @@ +export const title = 'Posture Checks' + + + +## List all Posture Checks {{ tag: 'GET' , label: '/api/posture-checks' }} + + + + Returns a list of all posture checks + + + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/posture-checks \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' +``` + +```js +const axios = require('axios'); + +let config = { + method: 'get', + maxBodyLength: Infinity, + url: '/api/posture-checks', + headers: { + 'Accept': 'application/json', + 'Authorization': 'Token ' + } +}; + +axios(config) +.then((response) => { + console.log(JSON.stringify(response.data)); +}) +.catch((error) => { + console.log(error); +}); +``` + +```python +import requests +import json + +url = "https://api.netbird.io/api/posture-checks" + +headers: { + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("GET", url, headers=headers) + +print(response.text) +``` + +```go +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/posture-checks" + method := "GET" + + client := &http.Client { + } + req, err := http.NewRequest(method, url, nil) + + if err != nil { + fmt.Println(err) + return + { + + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + res, err := client.Do(req) + if err != nil { + fmt.Println(err) + return + } + defer res.Body.Close() + + body, err := ioutil.ReadAll(res.Body) + if err != nil { + fmt.Println(err) + return + } + fmt.Println(string(body)) +} +``` + +```ruby +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/posture-checks") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Get.new(url) +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +response = https.request(request) +puts response.read_body +``` + +```java +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); + +Request request = new Request.Builder() + .url("https://api.netbird.io/api/posture-checks") + .method("GET") + .addHeader("Accept", "application/json") + .addHeader("Authorization: Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/posture-checks', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'GET', + CURLOPT_HTTPHEADER => array( + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` + + + + + +```json {{ title: 'Example' }} +[ + { + "id": "ch8i4ug6lnn4g9hqv7mg", + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", + "checks": { + "nb_version_check": { + "min_version": "14.3" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ] + ], + "action": "allow" + } + } + } +] +``` +```json {{ title: 'Schema' }} +[ + { + "id": "string", + "name": "string", + "description": "string", + "checks": { + "nb_version_check": { + "min_version": "string" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "string", + "city_name": "string" + } + ], + "action": "string" + }, + "peer_network_range_check": { + "ranges": [ + "string" + ], + "action": "string" + } + } + } +] +``` + + + + + + +--- + + +## Create a Posture Check {{ tag: 'POST' , label: '/api/posture-checks' }} + + + + Creates a posture check + + #### Request-Body Parameters + + + + Posture check name identifier + + + + + Posture check friendly description + + + + +
+ List of objects that perform the actual checks + + + + +
+ Posture check for the version of operating system + + + + + Minimum acceptable version + + + + + +
+ +
+ + +
+ Posture check for the version of operating system + + + + +
+ Posture check for the version of operating system + + + + + Minimum acceptable version + + + + + +
+ +
+ + +
+ Posture check for the version of operating system + + + + + Minimum acceptable version + + + + + +
+ +
+ + +
+ Posture check for the version of operating system + + + + + Minimum acceptable version + + + + + +
+ +
+ + +
+ Posture check with the kernel version + + + + + Minimum acceptable version + + + + + +
+ +
+ + +
+ Posture check with the kernel version + + + + + Minimum acceptable version + + + + + +
+ +
+
+ +
+
+ +
+ + +
+ Posture check for geo location + + + + +
+ List of geo locations to which the policy applies + + + + + 2-letter ISO 3166-1 alpha-2 code that represents the country + + + + + Commonly used English name of the city + + + + + +
+ +
+ + + Action to take upon policy match + + +
+ +
+
+ +
+ + +
+ Posture check for allow or deny access based on peer local network addresses + + + + + List of peer network ranges in CIDR notation + + + + + Action to take upon policy match + + + + + +
+ +
+
+ +
+
+ +
+
+ + + + + + +```bash {{ title: 'cURL' }} +curl -X POST https://api.netbird.io/api/posture-checks \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", + "checks": { + "nb_version_check": { + "min_version": "14.3" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ] + ], + "action": "allow" + } + } +}' +``` + +```js +const axios = require('axios'); +let data = JSON.stringify({ + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", + "checks": { + "nb_version_check": { + "min_version": "14.3" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ] + ], + "action": "allow" + } + } +}); +let config = { + method: 'post', + maxBodyLength: Infinity, + url: '/api/posture-checks', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': 'Token ' + }, + data : data +}; + +axios(config) +.then((response) => { + console.log(JSON.stringify(response.data)); +}) +.catch((error) => { + console.log(error); +}); +``` + +```python +import requests +import json + +url = "https://api.netbird.io/api/posture-checks" +payload = json.dumps({ + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", + "checks": { + "nb_version_check": { + "min_version": "14.3" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ] + ], + "action": "allow" + } + } +}) +headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("POST", url, headers=headers, data=payload) + +print(response.text) +``` + +```go +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/posture-checks" + method := "POST" + + payload := strings.NewReader(`{ + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", + "checks": { + "nb_version_check": { + "min_version": "14.3" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ] + ], + "action": "allow" + } + } +}`) + client := &http.Client { + } + req, err := http.NewRequest(method, url, payload) + + if err != nil { + fmt.Println(err) + return + { + + req.Header.Add("Content-Type", "application/json") + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + res, err := client.Do(req) + if err != nil { + fmt.Println(err) + return + } + defer res.Body.Close() + + body, err := ioutil.ReadAll(res.Body) + if err != nil { + fmt.Println(err) + return + } + fmt.Println(string(body)) +} +``` + +```ruby +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/posture-checks") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Post.new(url) +request["Content-Type"] = "application/json" +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +request.body = JSON.dump({ + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", + "checks": { + "nb_version_check": { + "min_version": "14.3" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ] + ], + "action": "allow" + } + } +}) +response = https.request(request) +puts response.read_body +``` + +```java +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); +MediaType mediaType = MediaType.parse("application/json"); +RequestBody body = RequestBody.create(mediaType, '{ + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", + "checks": { + "nb_version_check": { + "min_version": "14.3" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ] + ], + "action": "allow" + } + } +}'); +Request request = new Request.Builder() + .url("https://api.netbird.io/api/posture-checks") + .method("POST", body) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .addHeader("Authorization: Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/posture-checks', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS => '{ + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", + "checks": { + "nb_version_check": { + "min_version": "14.3" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ] + ], + "action": "allow" + } + } +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` + + + + + +```json {{ title: 'Example' }} +{ + "id": "ch8i4ug6lnn4g9hqv7mg", + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", + "checks": { + "nb_version_check": { + "min_version": "14.3" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ] + ], + "action": "allow" + } + } +} +``` +```json {{ title: 'Schema' }} +{ + "id": "string", + "name": "string", + "description": "string", + "checks": { + "nb_version_check": { + "min_version": "string" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "string", + "city_name": "string" + } + ], + "action": "string" + }, + "peer_network_range_check": { + "ranges": [ + "string" + ], + "action": "string" + } + } +} +``` + + + + +
+ +--- + + +## Retrieve a Posture Check {{ tag: 'GET' , label: '/api/posture-checks/{postureCheckId}' }} + + + + Get information about a posture check + + #### Path Parameters + + + + The unique identifier of a posture check + + + + + + +```bash {{ title: 'cURL' }} +curl -X GET https://api.netbird.io/api/posture-checks/{postureCheckId} \ +-H 'Accept: application/json' \ +-H 'Authorization: Token ' +``` + +```js +const axios = require('axios'); + +let config = { + method: 'get', + maxBodyLength: Infinity, + url: '/api/posture-checks/{postureCheckId}', + headers: { + 'Accept': 'application/json', + 'Authorization': 'Token ' + } +}; + +axios(config) +.then((response) => { + console.log(JSON.stringify(response.data)); +}) +.catch((error) => { + console.log(error); +}); +``` + +```python +import requests +import json + +url = "https://api.netbird.io/api/posture-checks/{postureCheckId}" + +headers: { + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("GET", url, headers=headers) + +print(response.text) +``` + +```go +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/posture-checks/{postureCheckId}" + method := "GET" + + client := &http.Client { + } + req, err := http.NewRequest(method, url, nil) + + if err != nil { + fmt.Println(err) + return + { + + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + res, err := client.Do(req) + if err != nil { + fmt.Println(err) + return + } + defer res.Body.Close() + + body, err := ioutil.ReadAll(res.Body) + if err != nil { + fmt.Println(err) + return + } + fmt.Println(string(body)) +} +``` + +```ruby +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/posture-checks/{postureCheckId}") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Get.new(url) +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +response = https.request(request) +puts response.read_body +``` + +```java +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); + +Request request = new Request.Builder() + .url("https://api.netbird.io/api/posture-checks/{postureCheckId}") + .method("GET") + .addHeader("Accept", "application/json") + .addHeader("Authorization: Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/posture-checks/{postureCheckId}', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'GET', + CURLOPT_HTTPHEADER => array( + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` + + + + + +```json {{ title: 'Example' }} +{ + "id": "ch8i4ug6lnn4g9hqv7mg", + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", + "checks": { + "nb_version_check": { + "min_version": "14.3" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ] + ], + "action": "allow" + } + } +} +``` +```json {{ title: 'Schema' }} +{ + "id": "string", + "name": "string", + "description": "string", + "checks": { + "nb_version_check": { + "min_version": "string" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "string", + "city_name": "string" + } + ], + "action": "string" + }, + "peer_network_range_check": { + "ranges": [ + "string" + ], + "action": "string" + } + } +} +``` + + + + + + +--- + + +## Update a Posture Check {{ tag: 'PUT' , label: '/api/posture-checks/{postureCheckId}' }} + + + + Update/Replace a posture check + + #### Path Parameters + + + + The unique identifier of a posture check + + + + #### Request-Body Parameters + + + + Posture check name identifier + + + + + Posture check friendly description + + + + +
+ List of objects that perform the actual checks + + + + +
+ Posture check for the version of operating system + + + + + Minimum acceptable version + + + + + +
+ +
+ + +
+ Posture check for the version of operating system + + + + +
+ Posture check for the version of operating system + + + + + Minimum acceptable version + + + + + +
+ +
+ + +
+ Posture check for the version of operating system + + + + + Minimum acceptable version + + + + + +
+ +
+ + +
+ Posture check for the version of operating system + + + + + Minimum acceptable version + + + + + +
+ +
+ + +
+ Posture check with the kernel version + + + + + Minimum acceptable version + + + + + +
+ +
+ + +
+ Posture check with the kernel version + + + + + Minimum acceptable version + + + + + +
+ +
+
+ +
+
+ +
+ + +
+ Posture check for geo location + + + + +
+ List of geo locations to which the policy applies + + + + + 2-letter ISO 3166-1 alpha-2 code that represents the country + + + + + Commonly used English name of the city + + + + + +
+ +
+ + + Action to take upon policy match + + +
+ +
+
+ +
+ + +
+ Posture check for allow or deny access based on peer local network addresses + + + + + List of peer network ranges in CIDR notation + + + + + Action to take upon policy match + + + + + +
+ +
+
+ +
+
+ +
+
+ + + + + + +```bash {{ title: 'cURL' }} +curl -X PUT https://api.netbird.io/api/posture-checks/{postureCheckId} \ +-H 'Accept: application/json' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Token ' \ +--data-raw '{ + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", + "checks": { + "nb_version_check": { + "min_version": "14.3" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ] + ], + "action": "allow" + } + } +}' +``` + +```js +const axios = require('axios'); +let data = JSON.stringify({ + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", + "checks": { + "nb_version_check": { + "min_version": "14.3" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ] + ], + "action": "allow" + } + } +}); +let config = { + method: 'put', + maxBodyLength: Infinity, + url: '/api/posture-checks/{postureCheckId}', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': 'Token ' + }, + data : data +}; + +axios(config) +.then((response) => { + console.log(JSON.stringify(response.data)); +}) +.catch((error) => { + console.log(error); +}); +``` + +```python +import requests +import json + +url = "https://api.netbird.io/api/posture-checks/{postureCheckId}" +payload = json.dumps({ + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", + "checks": { + "nb_version_check": { + "min_version": "14.3" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ] + ], + "action": "allow" + } + } +}) +headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Token ' +} + +response = requests.request("PUT", url, headers=headers, data=payload) + +print(response.text) +``` + +```go +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/posture-checks/{postureCheckId}" + method := "PUT" + + payload := strings.NewReader(`{ + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", + "checks": { + "nb_version_check": { + "min_version": "14.3" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ] + ], + "action": "allow" + } + } +}`) + client := &http.Client { + } + req, err := http.NewRequest(method, url, payload) + + if err != nil { + fmt.Println(err) + return + { + + req.Header.Add("Content-Type", "application/json") + req.Header.Add("Accept", "application/json") + req.Header.Add("Authorization", "Token ") + + res, err := client.Do(req) + if err != nil { + fmt.Println(err) + return + } + defer res.Body.Close() + + body, err := ioutil.ReadAll(res.Body) + if err != nil { + fmt.Println(err) + return + } + fmt.Println(string(body)) +} +``` + +```ruby +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/posture-checks/{postureCheckId}") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Put.new(url) +request["Content-Type"] = "application/json" +request["Accept"] = "application/json" +request["Authorization"] = "Token " + +request.body = JSON.dump({ + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", + "checks": { + "nb_version_check": { + "min_version": "14.3" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ] + ], + "action": "allow" + } + } +}) +response = https.request(request) +puts response.read_body +``` + +```java +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); +MediaType mediaType = MediaType.parse("application/json"); +RequestBody body = RequestBody.create(mediaType, '{ + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", + "checks": { + "nb_version_check": { + "min_version": "14.3" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ] + ], + "action": "allow" + } + } +}'); +Request request = new Request.Builder() + .url("https://api.netbird.io/api/posture-checks/{postureCheckId}") + .method("PUT", body) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .addHeader("Authorization: Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/posture-checks/{postureCheckId}', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'PUT', + CURLOPT_POSTFIELDS => '{ + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", + "checks": { + "nb_version_check": { + "min_version": "14.3" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ] + ], + "action": "allow" + } + } +}', + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json', + 'Accept: application/json', + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` + + + + + +```json {{ title: 'Example' }} +{ + "id": "ch8i4ug6lnn4g9hqv7mg", + "name": "Default", + "description": "This checks if the peer is running required NetBird's version", + "checks": { + "nb_version_check": { + "min_version": "14.3" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "DE", + "city_name": "Berlin" + } + ], + "action": "allow" + }, + "peer_network_range_check": { + "ranges": [ + [ + "192.168.1.0/24", + "10.0.0.0/8", + "2001:db8:1234:1a00::/56" + ] + ], + "action": "allow" + } + } +} +``` +```json {{ title: 'Schema' }} +{ + "id": "string", + "name": "string", + "description": "string", + "checks": { + "nb_version_check": { + "min_version": "string" + }, + "os_version_check": { + "android": { + "min_version": "13" + }, + "ios": { + "min_version": "17.3.1" + }, + "darwin": { + "min_version": "14.2.1" + }, + "linux": { + "min_kernel_version": "5.3.3" + }, + "windows": { + "min_kernel_version": "10.0.1234" + } + }, + "geo_location_check": { + "locations": [ + { + "country_code": "string", + "city_name": "string" + } + ], + "action": "string" + }, + "peer_network_range_check": { + "ranges": [ + "string" + ], + "action": "string" + } + } +} +``` + + + + +
+ +--- + + +## Delete a Posture Check {{ tag: 'DELETE' , label: '/api/posture-checks/{postureCheckId}' }} + + + + Delete a posture check + + #### Path Parameters + + + + The unique identifier of a posture check + + + + + + +```bash {{ title: 'cURL' }} +curl -X DELETE https://api.netbird.io/api/posture-checks/{postureCheckId} \ +-H 'Authorization: Token ' +``` + +```js +const axios = require('axios'); + +let config = { + method: 'delete', + maxBodyLength: Infinity, + url: '/api/posture-checks/{postureCheckId}', + headers: { + 'Authorization': 'Token ' + } +}; + +axios(config) +.then((response) => { + console.log(JSON.stringify(response.data)); +}) +.catch((error) => { + console.log(error); +}); +``` + +```python +import requests +import json + +url = "https://api.netbird.io/api/posture-checks/{postureCheckId}" + +headers: { + 'Authorization': 'Token ' +} + +response = requests.request("DELETE", url, headers=headers) + +print(response.text) +``` + +```go +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://api.netbird.io/api/posture-checks/{postureCheckId}" + method := "DELETE" + + client := &http.Client { + } + req, err := http.NewRequest(method, url, nil) + + if err != nil { + fmt.Println(err) + return + { + + req.Header.Add("Authorization", "Token ") + + res, err := client.Do(req) + if err != nil { + fmt.Println(err) + return + } + defer res.Body.Close() + + body, err := ioutil.ReadAll(res.Body) + if err != nil { + fmt.Println(err) + return + } + fmt.Println(string(body)) +} +``` + +```ruby +require "uri" +require "json" +require "net/http" + +url = URI("https://api.netbird.io/api/posture-checks/{postureCheckId}") + +https = Net::HTTP.new(url.host, url.port) +https.use_ssl = true + +request = Net::HTTP::Delete.new(url) +request["Authorization"] = "Token " + +response = https.request(request) +puts response.read_body +``` + +```java +OkHttpClient client = new OkHttpClient().newBuilder() + .build(); + +Request request = new Request.Builder() + .url("https://api.netbird.io/api/posture-checks/{postureCheckId}") + .method("DELETE") + .addHeader("Authorization: Token ") + .build(); +Response response = client.newCall(request).execute(); +``` + +```php + 'https://api.netbird.io/api/posture-checks/{postureCheckId}', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'DELETE', + CURLOPT_HTTPHEADER => array( + 'Authorization: Token ' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` + + + + + + + + +--- diff --git a/src/pages/ipa/resources/routes.mdx b/src/pages/ipa/resources/routes.mdx index d6278a48..79f28a13 100644 --- a/src/pages/ipa/resources/routes.mdx +++ b/src/pages/ipa/resources/routes.mdx @@ -157,9 +157,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} [ { @@ -202,13 +201,10 @@ echo $response; } ] ``` - - - - - - - + + + + --- @@ -221,79 +217,55 @@ echo $response; Creates a Route #### Request-Body Parameters - + + - - Route description - + Route description - - Route network identifier, to group HA routes - + + - - Route status - + Route network identifier, to group HA routes - - Peer Identifier associated with route. This property can not be set together with `peer_groups` - + + - - Peers Group Identifier associated with route. This property can not be set together with `peer` - + Route status - - Network range in CIDR format - + + - - Route metric number. Lowest number has higher priority - + Peer Identifier associated with route. This property can not be set together with `peer_groups` - - Indicate if peer should masquerade traffic to this route's prefix - + + - - Group IDs containing routing peers - - + Peers Group Identifier associated with route. This property can not be set together with `peer` + + + + + Network range in CIDR format + + + + + Route metric number. Lowest number has higher priority + + + + + Indicate if peer should masquerade traffic to this route's prefix + + + + + Group IDs containing routing peers + + + + + @@ -555,9 +527,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "id": "chacdk86lnnboviihd7g", @@ -596,13 +567,10 @@ echo $response; ] } ``` - - - - - - - + + + + --- @@ -771,9 +739,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "id": "chacdk86lnnboviihd7g", @@ -812,13 +779,10 @@ echo $response; ] } ``` - - - - - - - + + + + --- @@ -839,79 +803,55 @@ echo $response; #### Request-Body Parameters - + + - - Route description - + Route description - - Route network identifier, to group HA routes - + + - - Route status - + Route network identifier, to group HA routes - - Peer Identifier associated with route. This property can not be set together with `peer_groups` - + + - - Peers Group Identifier associated with route. This property can not be set together with `peer` - + Route status - - Network range in CIDR format - + + - - Route metric number. Lowest number has higher priority - + Peer Identifier associated with route. This property can not be set together with `peer_groups` - - Indicate if peer should masquerade traffic to this route's prefix - + + - - Group IDs containing routing peers - - + Peers Group Identifier associated with route. This property can not be set together with `peer` + + + + + Network range in CIDR format + + + + + Route metric number. Lowest number has higher priority + + + + + Indicate if peer should masquerade traffic to this route's prefix + + + + + Group IDs containing routing peers + + + + + @@ -1173,9 +1113,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "id": "chacdk86lnnboviihd7g", @@ -1214,13 +1153,10 @@ echo $response; ] } ``` - - - - - - - + + + + --- @@ -1382,11 +1318,9 @@ echo $response; - - - - - + + + --- diff --git a/src/pages/ipa/resources/rules.mdx b/src/pages/ipa/resources/rules.mdx index bcc7d0cc..86094baa 100644 --- a/src/pages/ipa/resources/rules.mdx +++ b/src/pages/ipa/resources/rules.mdx @@ -157,9 +157,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} [ { @@ -214,13 +213,10 @@ echo $response; } ] ``` - - - - - - - + + + + --- @@ -233,50 +229,40 @@ echo $response; Creates a rule. This will be deprecated in favour of `/api/policies`. #### Request-Body Parameters - + + - - Rule name identifier - + Rule name identifier - - Rule friendly description - + + - - Rules status - + Rule friendly description - - Rule flow, currently, only "bidirect" for bi-directional traffic is accepted - + + - - List of source group IDs - + Rules status - - List of destination group IDs - - + + + + Rule flow, currently, only "bidirect" for bi-directional traffic is accepted + + + + + List of source group IDs + + + + + List of destination group IDs + + + + + @@ -517,9 +503,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -570,9 +555,10 @@ echo $response; ] } ``` - - - + + + + --- @@ -741,9 +727,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -794,13 +779,10 @@ echo $response; ] } ``` - - - - - - - + + + + --- @@ -821,50 +803,40 @@ echo $response; #### Request-Body Parameters - + + - - Rule name identifier - + Rule name identifier - - Rule friendly description - + + - - Rules status - + Rule friendly description - - Rule flow, currently, only "bidirect" for bi-directional traffic is accepted - + + - - List of source group IDs - + Rules status - - List of destination group IDs - - + + + + Rule flow, currently, only "bidirect" for bi-directional traffic is accepted + + + + + List of source group IDs + + + + + List of destination group IDs + + + + + @@ -1105,9 +1077,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "id": "ch8i4ug6lnn4g9hqv7mg", @@ -1158,13 +1129,10 @@ echo $response; ] } ``` - - - - - - - + + + + --- @@ -1326,11 +1294,9 @@ echo $response; - - - - - + + + --- diff --git a/src/pages/ipa/resources/setup-keys.mdx b/src/pages/ipa/resources/setup-keys.mdx index a4ced75a..59c8ed9e 100644 --- a/src/pages/ipa/resources/setup-keys.mdx +++ b/src/pages/ipa/resources/setup-keys.mdx @@ -157,13 +157,12 @@ echo $response; - - - + + ```json {{ title: 'Example' }} [ { - "id": "2531583362", + "id": 2531583362, "key": "A616097E-FCF0-48FA-9354-CA4A61142761", "name": "Default key", "expires": "2023-06-01T14:47:22.291057Z", @@ -204,13 +203,10 @@ echo $response; } ] ``` - - - - - - - + + + + --- @@ -223,61 +219,45 @@ echo $response; Creates a setup key #### Request-Body Parameters - + + - - Setup Key name - + Setup Key name - - Setup key type, one-off for single time usage and reusable - + + - - Expiration time in seconds - + Setup key type, one-off for single time usage and reusable - - Setup key revocation status - + + - - List of group IDs to auto-assign to peers registered with this key - + Expiration time in seconds - - A number of times this key can be used. The value of 0 indicates the unlimited usage. - + + - - Indicate that the peer will be ephemeral or not - - + Setup key revocation status + + + + + List of group IDs to auto-assign to peers registered with this key + + + + + A number of times this key can be used. The value of 0 indicates the unlimited usage. + + + + + Indicate that the peer will be ephemeral or not + + + + + @@ -511,12 +491,11 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { - "id": "2531583362", + "id": 2531583362, "key": "A616097E-FCF0-48FA-9354-CA4A61142761", "name": "Default key", "expires": "2023-06-01T14:47:22.291057Z", @@ -554,13 +533,10 @@ echo $response; "ephemeral": "boolean" } ``` - - - - - - - + + + + --- @@ -729,12 +705,11 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { - "id": "2531583362", + "id": 2531583362, "key": "A616097E-FCF0-48FA-9354-CA4A61142761", "name": "Default key", "expires": "2023-06-01T14:47:22.291057Z", @@ -772,13 +747,10 @@ echo $response; "ephemeral": "boolean" } ``` - - - - - - - + + + + --- @@ -799,61 +771,45 @@ echo $response; #### Request-Body Parameters - + + - - Setup Key name - + Setup Key name - - Setup key type, one-off for single time usage and reusable - + + - - Expiration time in seconds - + Setup key type, one-off for single time usage and reusable - - Setup key revocation status - + + - - List of group IDs to auto-assign to peers registered with this key - + Expiration time in seconds - - A number of times this key can be used. The value of 0 indicates the unlimited usage. - + + - - Indicate that the peer will be ephemeral or not - - + Setup key revocation status + + + + + List of group IDs to auto-assign to peers registered with this key + + + + + A number of times this key can be used. The value of 0 indicates the unlimited usage. + + + + + Indicate that the peer will be ephemeral or not + + + + + @@ -1087,12 +1043,11 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { - "id": "2531583362", + "id": 2531583362, "key": "A616097E-FCF0-48FA-9354-CA4A61142761", "name": "Default key", "expires": "2023-06-01T14:47:22.291057Z", @@ -1130,13 +1085,10 @@ echo $response; "ephemeral": "boolean" } ``` - - - - - - - + + + + --- diff --git a/src/pages/ipa/resources/tokens.mdx b/src/pages/ipa/resources/tokens.mdx index 69267fd0..e065aff0 100644 --- a/src/pages/ipa/resources/tokens.mdx +++ b/src/pages/ipa/resources/tokens.mdx @@ -165,9 +165,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} [ { @@ -192,13 +191,10 @@ echo $response; } ] ``` - - - - - - - + + + + --- @@ -219,26 +215,20 @@ echo $response; #### Request-Body Parameters - + + - - Name of the token - + Name of the token - - Expiration in days - - + + + + Expiration in days + + + + + @@ -423,12 +413,11 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { - "plain_token": "2023-05-02T14:48:20.465209Z", + "plain_token": {}, "personal_access_token": { "id": "ch8i54g6lnn4g9hqv7n0", "name": "My first token", @@ -452,13 +441,10 @@ echo $response; } } ``` - - - - - - - + + + + --- @@ -631,9 +617,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "id": "ch8i54g6lnn4g9hqv7n0", @@ -654,13 +639,10 @@ echo $response; "last_used": "string" } ``` - - - - - - - + + + + --- @@ -826,11 +808,9 @@ echo $response; - - - - - + + + --- diff --git a/src/pages/ipa/resources/users.mdx b/src/pages/ipa/resources/users.mdx index b34ba319..08dafc4c 100644 --- a/src/pages/ipa/resources/users.mdx +++ b/src/pages/ipa/resources/users.mdx @@ -165,9 +165,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} [ { @@ -206,13 +205,10 @@ echo $response; } ] ``` - - - - - - - + + + + --- @@ -225,43 +221,35 @@ echo $response; Creates a new service user or sends an invite to a regular user #### Request-Body Parameters - + + - - User's Email to send invite to - + User's Email to send invite to - - User's full name - + + - - User's NetBird account role - + User's full name - - Group IDs to auto-assign to peers registered by this user - + + - - Is true if this user is a service user - - + User's NetBird account role + + + + + Group IDs to auto-assign to peers registered by this user + + + + + Is true if this user is a service user + + + + + @@ -481,9 +469,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "id": "google-oauth2|277474792786460067937", @@ -518,13 +505,10 @@ echo $response; "issued": "string" } ``` - - - - - - - + + + + --- @@ -545,29 +529,25 @@ echo $response; #### Request-Body Parameters - + + - - User's NetBird account role - + User's NetBird account role - - Group IDs to auto-assign to peers registered by this user - + + - - If set to true then user is blocked and can't use the system - - + Group IDs to auto-assign to peers registered by this user + + + + + If set to true then user is blocked and can't use the system + + + + + @@ -773,9 +753,8 @@ echo $response; - - - + + ```json {{ title: 'Example' }} { "id": "google-oauth2|277474792786460067937", @@ -810,13 +789,10 @@ echo $response; "issued": "string" } ``` - - - - - - - + + + + --- @@ -978,11 +954,9 @@ echo $response; - - - - - + + + --- @@ -1144,11 +1118,9 @@ echo $response; - - - - - + + + --- diff --git a/src/styles/global.css b/src/styles/global.css new file mode 100644 index 00000000..7e55846d --- /dev/null +++ b/src/styles/global.css @@ -0,0 +1,3 @@ +.custom-details li { + margin-left: 50px !important; +} \ No newline at end of file