Add workflow for api gen and refactor genration script (#60)

* update gitignore

* add first version of api generation flow

* try to run flow

* testing flow

* update gen flow

* switch flow to macOS

* fix

* add npm install

* test workflow

* Update API pages

* test workflow with current main

* refactor parser

* merge examples and schema functions

* merge examples and schema functions

* merge parameters as well

* revert template to single class component

* update account

* finalizing

* update with the newest version of openapi

* full flow

* update

* add docker command

* split flow in two jobs

* remove testing trigger

---------

Co-authored-by: GitHub Actions <no-reply@github.com>
This commit is contained in:
pascal-fischer
2023-06-05 09:35:54 +02:00
committed by GitHub
parent 33b3153723
commit f33b4df3dd
20 changed files with 481 additions and 5928 deletions

View File

@@ -5,13 +5,44 @@ on:
- main
tags:
- "**"
pull_request:
workflow_dispatch:
inputs:
generateAPI:
description: 'Generates API pages if set'
required: false
default: false
type: boolean
jobs:
docs_build_n_push:
runs-on: ubuntu-latest
generate_api_pages:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Install swagger-codegen
if: ${{ inputs.generateAPI }}
run: brew install swagger-codegen
- name: Generate api pages for netbird main openapi definition
if: ${{ inputs.generateAPI }}
run: |
npm install
npm run gen
- name: Commit and push changes
if: ${{ inputs.generateAPI }}
run: |
git config --global user.email "no-reply@github.com"
git config --global user.name "GitHub Actions"
git add -A
git commit -m "Update API pages"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git push
docs_build_n_push:
runs-on: ubuntu-latest
needs: [generate_api_pages]
steps:
-
name: Docker meta
id: meta

2
.gitignore vendored
View File

@@ -24,3 +24,5 @@ yarn-error.log*
package-lock.json
/.next/
/yarn.lock
/generator/openapi/
/generator/openapi.yml

View File

@@ -1,23 +0,0 @@
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View File

@@ -1 +0,0 @@
3.0.42

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,12 @@
import template from './templates/ApiTemplate'
import { slugify, toArrayWithKey, toTitle, writeToDisk } from './helpers'
import { OpenAPIV3, OpenAPIV2 } from 'openapi-types'
import {OpenAPIV3} from 'openapi-types'
import * as fs from 'fs'
import * as ejs from 'ejs'
export default async function gen(inputFileName: string, outputDir: string) {
const specRaw = fs.readFileSync(inputFileName, 'utf8')
const spec = JSON.parse(specRaw) as any
// console.log('spec', spec)
switch (spec.openapi || spec.swagger) {
case '3.0.0':
@@ -79,90 +78,7 @@ async function gen_v3(spec: OpenAPIV3.Document, dest: string) {
})
})
let components = new Map<string, component>();
Object.entries(spec.components?.schemas).forEach(([key, val]) => {
const schema = val as OpenAPIV3.SchemaObject
let outputSchema = new Map<string, any>();
let outputExample = new Map<string, any>();
let parameters : schemaParameter[] = []
if(schema.allOf){
schema.allOf.forEach((item) => {
if((item as OpenAPIV3.ReferenceObject).$ref){
let component = components.get((item as OpenAPIV3.ReferenceObject).$ref.split('/').pop())
let schemaMap = new Map(Object.entries(component.schema))
let exampleMap = new Map(Object.entries(component.example))
schemaMap.forEach((value, key) => {
outputSchema.set(key, value)
})
exampleMap.forEach((value, key) => {
outputExample.set(key, value)
})
parameters = parameters.concat(component.parameters)
}
if((item as OpenAPIV3.SchemaObject).properties){
Object.entries((item as OpenAPIV3.SchemaObject).properties).forEach(([key, val]) => {
let property = val as OpenAPIV3.SchemaObject
let type, exampleValue
if (property.type === "array") {
type = new Array(resolveType(property.items, spec.components?.schemas))
exampleValue = new Array(resolveExampleValue(property.items, spec.components?.schemas))
} else {
type = resolveType(property, spec.components?.schemas)
exampleValue = resolveExampleValue(property, spec.components?.schemas)
}
outputSchema.set(key, type)
outputExample.set(key, exampleValue)
let parameter: schemaParameter = {
name: key,
type: property.type === "array" ? ((property.items as OpenAPIV3.SchemaObject).type || (property.items as OpenAPIV3.ReferenceObject).$ref.split('/').pop()) + "[]" : property.type,
description: property.description,
required: schema.required?.includes(key) || false,
minimum: property.minimum,
maximum: property.maximum,
minLength: property.minLength,
maxLength: property.maxLength,
enum: property.enum
}
parameters.push(parameter)
})
}
})
} else {
Object.entries(schema.properties).forEach(([key, val]) => {
let property = val as OpenAPIV3.SchemaObject
let type, exampleValue
if(property.type === "array"){
type = new Array(resolveType(property.items, spec.components?.schemas))
exampleValue = new Array(resolveExampleValue(property.items, spec.components?.schemas))
} else {
type = resolveType(property, spec.components?.schemas)
exampleValue = resolveExampleValue(property, spec.components?.schemas)
}
outputSchema.set(key, type)
outputExample.set(key, exampleValue)
let parameter : schemaParameter = {
name: key,
type: property.type === "array" ? ((property.items as OpenAPIV3.SchemaObject).type || (property.items as OpenAPIV3.ReferenceObject).$ref.split('/').pop()) + "[]" : property.type,
description: property.description,
required: schema.required?.includes(key) || false,
minimum: property.minimum,
maximum: property.maximum,
minLength: property.minLength,
maxLength: property.maxLength,
enum: property.enum
}
parameters.push(parameter)
})
}
let output : component = {
example: Object.fromEntries(outputExample),
schema: Object.fromEntries(outputSchema),
parameters: parameters
}
components.set(key, output)
})
let components = readComponents(spec.components)
tagGroups.forEach((value: enrichedOperation[], key: string) => {
@@ -192,42 +108,111 @@ async function gen_v3(spec: OpenAPIV3.Document, dest: string) {
})
}
function resolveType(items: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject | OpenAPIV3.NonArraySchemaObjectType, schemas) : any {
if((items as OpenAPIV3.ReferenceObject).$ref){
let ref = (items as OpenAPIV3.ReferenceObject).$ref
let map = new Map<string, any>()
Object.entries(schemas[ref.split('/').pop()].properties).forEach(([key, val]) => {
let property = val as OpenAPIV3.SchemaObject
let type
if(property.type === "array"){
type = new Array(resolveType(property.items, schemas))
} else {
type = resolveType(property, schemas)
}
map.set(key, type)
})
return Object.fromEntries(map)
function readComponents(components: OpenAPIV3.ComponentsObject) : Map<string, component> {
let componentsOutput = new Map<string, component>()
for (const [key, value] of Object.entries(components.schemas)) {
let [schema, example, parameter] = resolveComponents(value, components)
let component = {
example: example,
schema: schema,
parameters: parameter
}
componentsOutput.set(key, component)
}
return (items as OpenAPIV3.ArraySchemaObject).type
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<string, any>()
let schemas = new Map<string, any>()
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 resolveExampleValue(items: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject | OpenAPIV3.NonArraySchemaObjectType, schemas) : any {
if((items as OpenAPIV3.ReferenceObject).$ref){
let ref = (items as OpenAPIV3.ReferenceObject).$ref
let map = new Map<string, any>()
Object.entries(schemas[ref.split('/').pop()].properties).forEach(([key, val]) => {
let property = val as OpenAPIV3.SchemaObject
let exampleValue
if(property.type === "array"){
exampleValue = new Array(resolveExampleValue(property.items, schemas))
} else {
exampleValue = resolveExampleValue(property, schemas)
}
map.set(key, exampleValue)
})
return Object.fromEntries(map)
function resolveProperties(value: OpenAPIV3.SchemaObject, components: OpenAPIV3.ComponentsObject): [Object, Object, schemaParameter[]] {
let examples = new Map<string, Object>()
let schemas = new Map<string, Object>()
let parameters: schemaParameter[] = []
for(const [key, property] of Object.entries(value.properties)) {
let type: string = ""
if(property["$ref"]) {
let [schema, example, parameter] = resolveComponents(property, components)
examples.set(key, example)
schemas.set(key, schema)
parameters = parameters.concat(parameter)
continue
}
switch (property["type"]) {
case "array":
type = ((property["items"] as OpenAPIV3.SchemaObject).type || (property["items"] as OpenAPIV3.ReferenceObject).$ref.split('/').pop()) + "[]"
let [schema, example] = resolveComponents(property["items"], components)
examples.set(key, new Array(example))
schemas.set(key, new Array(schema))
break;
case "object":
default:
type = property["type"]
examples.set(key, property["example"])
schemas.set(key, property["type"])
}
let parameter: schemaParameter = {
name: key,
type: type,
description: property["description"],
required: value.required?.includes(key) || false,
minimum: property["minimum"],
maximum: property["maximum"],
minLength: property["minLength"],
maxLength: property["maxLength"],
enum: property["enum"],
}
parameters.push(parameter)
}
return (items as OpenAPIV3.ArraySchemaObject).example
return [Object.fromEntries(schemas), Object.fromEntries(examples), parameters]
}
function mergeMaps(map1: Map<string, Object>, map2: Map<string, Object>) : Map<string, Object> {
return new Map([...Array.from(map1.entries()), ...Array.from(map2.entries())]);
}

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,7 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"gen": "swagger-codegen generate -i generator/openapi.yml -l openapi -o generator/api.json && npx ts-node generator/index.ts gen --input generator/api.json/openapi.json --output src/pages/ipa/resources",
"gen": "swagger-codegen generate -i https://raw.githubusercontent.com/netbirdio/netbird/main/management/server/http/api/openapi.yml -l openapi -o generator/openapi && npx ts-node generator/index.ts gen --input generator/openapi/openapi.json --output src/pages/ipa/resources",
"start": "next start",
"lint": "next lint"
},

View File

@@ -1,4 +1,3 @@
export const title = 'Accounts'
@@ -236,16 +235,20 @@ curl -X PUT https://api.netbird.io/api/accounts/{accountId} \
-H 'Content-Type: application/json' \
-H 'Authorization: Token <TOKEN>' \
--data-raw '{
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200
"settings": {
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200
}
}'
```
```js
const axios = require('axios');
let data = JSON.stringify({
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200
"settings": {
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200
}
});
let config = {
method: 'put',
@@ -274,8 +277,10 @@ import json
url = "https://api.netbird.io/api/accounts/{accountId}"
payload = json.dumps({
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200
"settings": {
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200
}
})
headers: {
'Content-Type': 'application/json',
@@ -304,8 +309,10 @@ func main() {
method := "PUT"
payload := strings.NewReader(`{
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200
"settings": {
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200
}
}`)
client := &http.Client {
}
@@ -352,8 +359,10 @@ request["Accept"] = "application/json"
request["Authorization"] = "Token <TOKEN>"
request.body = JSON.dump({
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200
"settings": {
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200
}
})
response = https.request(request)
puts response.read_body
@@ -364,8 +373,10 @@ OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, '{
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200
"settings": {
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200
}
}');
Request request = new Request.Builder()
.url("https://api.netbird.io/api/accounts/{accountId}")
@@ -392,8 +403,10 @@ curl_setopt_array($curl, array(
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => '{
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200
"settings": {
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200
}
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',

View File

@@ -1,4 +1,3 @@
export const title = 'DNS'
@@ -1445,7 +1444,7 @@ echo $response;
---
## Retrieve DNS Settings {{ tag: 'GET' , label: '/api/dns/settings' }}
## Retrieve DNS settings {{ tag: 'GET' , label: '/api/dns/settings' }}
<Row>
<Col>

View File

@@ -1,4 +1,3 @@
export const title = 'Events'

View File

@@ -1,4 +1,3 @@
export const title = 'Groups'
@@ -7,7 +6,7 @@ export const title = 'Groups'
<Row>
<Col>
Returns a list of all Groups
Returns a list of all groups
</Col>
<Col sticky>
@@ -207,7 +206,7 @@ echo $response;
<Row>
<Col>
Creates a Group
Creates a group
#### Request-Body Parameters
<Properties>
@@ -238,7 +237,7 @@ curl -X POST https://api.netbird.io/api/groups \
--data-raw '{
"name": "devs",
"peers": [
null
"ch8i4ug6lnn4g9hqv7m1"
]
}'
```
@@ -248,7 +247,7 @@ const axios = require('axios');
let data = JSON.stringify({
"name": "devs",
"peers": [
null
"ch8i4ug6lnn4g9hqv7m1"
]
});
let config = {
@@ -280,7 +279,7 @@ url = "https://api.netbird.io/api/groups"
payload = json.dumps({
"name": "devs",
"peers": [
null
"ch8i4ug6lnn4g9hqv7m1"
]
})
headers: {
@@ -312,7 +311,7 @@ func main() {
payload := strings.NewReader(`{
"name": "devs",
"peers": [
null
"ch8i4ug6lnn4g9hqv7m1"
]
}`)
client := &http.Client {
@@ -362,7 +361,7 @@ request["Authorization"] = "Token <TOKEN>"
request.body = JSON.dump({
"name": "devs",
"peers": [
null
"ch8i4ug6lnn4g9hqv7m1"
]
})
response = https.request(request)
@@ -376,7 +375,7 @@ MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, '{
"name": "devs",
"peers": [
null
"ch8i4ug6lnn4g9hqv7m1"
]
}');
Request request = new Request.Builder()
@@ -406,7 +405,7 @@ curl_setopt_array($curl, array(
CURLOPT_POSTFIELDS => '{
"name": "devs",
"peers": [
null
"ch8i4ug6lnn4g9hqv7m1"
]
}',
CURLOPT_HTTPHEADER => array(
@@ -469,7 +468,7 @@ echo $response;
<Row>
<Col>
Get information about a Group
Get information about a group
#### Path Parameters
<Properties>
@@ -673,7 +672,7 @@ echo $response;
<Row>
<Col>
Update/Replace a Group
Update/Replace a group
#### Path Parameters
<Properties>
@@ -712,7 +711,7 @@ curl -X PUT https://api.netbird.io/api/groups/{groupId} \
--data-raw '{
"name": "devs",
"peers": [
null
"ch8i4ug6lnn4g9hqv7m1"
]
}'
```
@@ -722,7 +721,7 @@ const axios = require('axios');
let data = JSON.stringify({
"name": "devs",
"peers": [
null
"ch8i4ug6lnn4g9hqv7m1"
]
});
let config = {
@@ -754,7 +753,7 @@ url = "https://api.netbird.io/api/groups/{groupId}"
payload = json.dumps({
"name": "devs",
"peers": [
null
"ch8i4ug6lnn4g9hqv7m1"
]
})
headers: {
@@ -786,7 +785,7 @@ func main() {
payload := strings.NewReader(`{
"name": "devs",
"peers": [
null
"ch8i4ug6lnn4g9hqv7m1"
]
}`)
client := &http.Client {
@@ -836,7 +835,7 @@ request["Authorization"] = "Token <TOKEN>"
request.body = JSON.dump({
"name": "devs",
"peers": [
null
"ch8i4ug6lnn4g9hqv7m1"
]
})
response = https.request(request)
@@ -850,7 +849,7 @@ MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, '{
"name": "devs",
"peers": [
null
"ch8i4ug6lnn4g9hqv7m1"
]
}');
Request request = new Request.Builder()
@@ -880,7 +879,7 @@ curl_setopt_array($curl, array(
CURLOPT_POSTFIELDS => '{
"name": "devs",
"peers": [
null
"ch8i4ug6lnn4g9hqv7m1"
]
}',
CURLOPT_HTTPHEADER => array(
@@ -943,7 +942,7 @@ echo $response;
<Row>
<Col>
Delete a Group
Delete a group
#### Path Parameters
<Properties>

View File

@@ -1,4 +1,3 @@
export const title = 'Peers'

View File

@@ -1,4 +1,3 @@
export const title = 'Policies'
@@ -7,7 +6,7 @@ export const title = 'Policies'
<Row>
<Col>
Returns a list of all Policies
Returns a list of all policies
</Col>
<Col sticky>
@@ -164,16 +163,23 @@ echo $response;
```json {{ title: 'Example' }}
[
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
@@ -187,17 +193,16 @@ echo $response;
"name": "devs",
"peers_count": 2
}
],
"action": "accept"
]
}
],
"id": "ch8i4ug6lnn4g9hqv7mg"
]
}
]
```
```json {{ title: 'Schema' }}
[
{
"id": "string",
"name": "string",
"description": "string",
"enabled": "boolean",
@@ -208,6 +213,12 @@ echo $response;
"name": "string",
"description": "string",
"enabled": "boolean",
"action": "string",
"bidirectional": "boolean",
"protocol": "string",
"ports": [
"string"
],
"sources": [
{
"id": "string",
@@ -221,11 +232,9 @@ echo $response;
"name": "string",
"peers_count": "integer"
}
],
"action": "string"
]
}
],
"id": "string"
]
}
]
```
@@ -245,11 +254,18 @@ echo $response;
<Row>
<Col>
Creates a Policy
Creates a policy
#### Request-Body Parameters
<Properties>
<Property name="id" type="string" required={false}
>
Policy ID
</Property>
<Property name="name" type="string" required={true}
@@ -278,7 +294,7 @@ echo $response;
Policy Rego query
</Property>
<Property name="rules" type="PolicyRule[]" required={true}
<Property name="rules" type="PolicyRuleUpdate[]" required={true}
>
@@ -295,31 +311,29 @@ curl -X POST https://api.netbird.io/api/policies \
-H 'Content-Type: application/json' \
-H 'Authorization: Token <TOKEN>' \
--data-raw '{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
"ch8i4ug6lnn4g9hqv797"
],
"destinations": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
],
"action": "accept"
"ch8i4ug6lnn4g9h7v7m0"
]
}
]
}'
@@ -328,31 +342,29 @@ curl -X POST https://api.netbird.io/api/policies \
```js
const axios = require('axios');
let data = JSON.stringify({
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
"ch8i4ug6lnn4g9hqv797"
],
"destinations": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
],
"action": "accept"
"ch8i4ug6lnn4g9h7v7m0"
]
}
]
});
@@ -383,31 +395,29 @@ import json
url = "https://api.netbird.io/api/policies"
payload = json.dumps({
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
"ch8i4ug6lnn4g9hqv797"
],
"destinations": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
],
"action": "accept"
"ch8i4ug6lnn4g9h7v7m0"
]
}
]
})
@@ -438,31 +448,29 @@ func main() {
method := "POST"
payload := strings.NewReader(`{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
"ch8i4ug6lnn4g9hqv797"
],
"destinations": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
],
"action": "accept"
"ch8i4ug6lnn4g9h7v7m0"
]
}
]
}`)
@@ -511,31 +519,29 @@ request["Accept"] = "application/json"
request["Authorization"] = "Token <TOKEN>"
request.body = JSON.dump({
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
"ch8i4ug6lnn4g9hqv797"
],
"destinations": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
],
"action": "accept"
"ch8i4ug6lnn4g9h7v7m0"
]
}
]
})
@@ -548,31 +554,29 @@ OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, '{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
"ch8i4ug6lnn4g9hqv797"
],
"destinations": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
],
"action": "accept"
"ch8i4ug6lnn4g9h7v7m0"
]
}
]
}');
@@ -601,31 +605,29 @@ curl_setopt_array($curl, array(
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
"ch8i4ug6lnn4g9hqv797"
],
"destinations": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
],
"action": "accept"
"ch8i4ug6lnn4g9h7v7m0"
]
}
]
}',
@@ -649,16 +651,23 @@ echo $response;
<CodeGroup title="Response">
```json {{ title: 'Example' }}
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
@@ -672,15 +681,14 @@ echo $response;
"name": "devs",
"peers_count": 2
}
],
"action": "accept"
]
}
],
"id": "ch8i4ug6lnn4g9hqv7mg"
]
}
```
```json {{ title: 'Schema' }}
{
"id": "string",
"name": "string",
"description": "string",
"enabled": "boolean",
@@ -691,6 +699,12 @@ echo $response;
"name": "string",
"description": "string",
"enabled": "boolean",
"action": "string",
"bidirectional": "boolean",
"protocol": "string",
"ports": [
"string"
],
"sources": [
{
"id": "string",
@@ -704,11 +718,9 @@ echo $response;
"name": "string",
"peers_count": "integer"
}
],
"action": "string"
]
}
],
"id": "string"
]
}
```
</CodeGroup>
@@ -887,16 +899,23 @@ echo $response;
<CodeGroup title="Response">
```json {{ title: 'Example' }}
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
@@ -910,15 +929,14 @@ echo $response;
"name": "devs",
"peers_count": 2
}
],
"action": "accept"
]
}
],
"id": "ch8i4ug6lnn4g9hqv7mg"
]
}
```
```json {{ title: 'Schema' }}
{
"id": "string",
"name": "string",
"description": "string",
"enabled": "boolean",
@@ -929,6 +947,12 @@ echo $response;
"name": "string",
"description": "string",
"enabled": "boolean",
"action": "string",
"bidirectional": "boolean",
"protocol": "string",
"ports": [
"string"
],
"sources": [
{
"id": "string",
@@ -942,11 +966,9 @@ echo $response;
"name": "string",
"peers_count": "integer"
}
],
"action": "string"
]
}
],
"id": "string"
]
}
```
</CodeGroup>
@@ -978,6 +1000,13 @@ echo $response;
#### Request-Body Parameters
<Properties>
<Property name="id" type="string" required={false}
>
Policy ID
</Property>
<Property name="name" type="string" required={true}
@@ -1006,7 +1035,7 @@ echo $response;
Policy Rego query
</Property>
<Property name="rules" type="PolicyRule[]" required={true}
<Property name="rules" type="PolicyRuleUpdate[]" required={true}
>
@@ -1023,31 +1052,29 @@ curl -X PUT https://api.netbird.io/api/policies/{policyId} \
-H 'Content-Type: application/json' \
-H 'Authorization: Token <TOKEN>' \
--data-raw '{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
"ch8i4ug6lnn4g9hqv797"
],
"destinations": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
],
"action": "accept"
"ch8i4ug6lnn4g9h7v7m0"
]
}
]
}'
@@ -1056,31 +1083,29 @@ curl -X PUT https://api.netbird.io/api/policies/{policyId} \
```js
const axios = require('axios');
let data = JSON.stringify({
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
"ch8i4ug6lnn4g9hqv797"
],
"destinations": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
],
"action": "accept"
"ch8i4ug6lnn4g9h7v7m0"
]
}
]
});
@@ -1111,31 +1136,29 @@ import json
url = "https://api.netbird.io/api/policies/{policyId}"
payload = json.dumps({
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
"ch8i4ug6lnn4g9hqv797"
],
"destinations": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
],
"action": "accept"
"ch8i4ug6lnn4g9h7v7m0"
]
}
]
})
@@ -1166,31 +1189,29 @@ func main() {
method := "PUT"
payload := strings.NewReader(`{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
"ch8i4ug6lnn4g9hqv797"
],
"destinations": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
],
"action": "accept"
"ch8i4ug6lnn4g9h7v7m0"
]
}
]
}`)
@@ -1239,31 +1260,29 @@ request["Accept"] = "application/json"
request["Authorization"] = "Token <TOKEN>"
request.body = JSON.dump({
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
"ch8i4ug6lnn4g9hqv797"
],
"destinations": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
],
"action": "accept"
"ch8i4ug6lnn4g9h7v7m0"
]
}
]
})
@@ -1276,31 +1295,29 @@ OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, '{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
"ch8i4ug6lnn4g9hqv797"
],
"destinations": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
],
"action": "accept"
"ch8i4ug6lnn4g9h7v7m0"
]
}
]
}');
@@ -1329,31 +1346,29 @@ curl_setopt_array($curl, array(
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => '{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
"ch8i4ug6lnn4g9hqv797"
],
"destinations": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2
}
],
"action": "accept"
"ch8i4ug6lnn4g9h7v7m0"
]
}
]
}',
@@ -1377,16 +1392,23 @@ echo $response;
<CodeGroup title="Response">
```json {{ title: 'Example' }}
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"query": "package netbird\\n\\nall[rule] {\\n is_peer_in_any_group([\\\"ch8i4ug6lnn4g9hqv7m0\\\",\\\"ch8i4ug6lnn4g9hqv7m0\\\"])\\n rule := {\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"dst\\\", \\\"accept\\\", \\\"\\\"),\\n rules_from_group(\\\"ch8i4ug6lnn4g9hqv7m0\\\", \\\"src\\\", \\\"accept\\\", \\\"\\\"),\\n }[_][_]\\n}\\n",
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
@@ -1400,15 +1422,14 @@ echo $response;
"name": "devs",
"peers_count": 2
}
],
"action": "accept"
]
}
],
"id": "ch8i4ug6lnn4g9hqv7mg"
]
}
```
```json {{ title: 'Schema' }}
{
"id": "string",
"name": "string",
"description": "string",
"enabled": "boolean",
@@ -1419,6 +1440,12 @@ echo $response;
"name": "string",
"description": "string",
"enabled": "boolean",
"action": "string",
"bidirectional": "boolean",
"protocol": "string",
"ports": [
"string"
],
"sources": [
{
"id": "string",
@@ -1432,11 +1459,9 @@ echo $response;
"name": "string",
"peers_count": "integer"
}
],
"action": "string"
]
}
],
"id": "string"
]
}
```
</CodeGroup>
@@ -1455,7 +1480,7 @@ echo $response;
<Row>
<Col>
Delete a Policy
Delete a policy
#### Path Parameters
<Properties>

View File

@@ -1,4 +1,3 @@
export const title = 'Routes'
@@ -1151,7 +1150,7 @@ echo $response;
<Row>
<Col>
Delete a Route
Delete a route
#### Path Parameters
<Properties>

View File

@@ -1,4 +1,3 @@
export const title = 'Rules'
@@ -7,7 +6,7 @@ export const title = 'Rules'
<Row>
<Col>
Returns a list of all Rules
Returns a list of all rules
</Col>
<Col sticky>
@@ -227,7 +226,7 @@ echo $response;
<Row>
<Col>
Creates a Rule
Creates a rule
#### Request-Body Parameters
<Properties>
@@ -575,7 +574,7 @@ echo $response;
<Row>
<Col>
Get information about a Rules
Get information about a rules
#### Path Parameters
<Properties>
@@ -799,7 +798,7 @@ echo $response;
<Row>
<Col>
Update/Replace a Rule
Update/Replace a rule
#### Path Parameters
<Properties>
@@ -1159,7 +1158,7 @@ echo $response;
<Row>
<Col>
Delete a Rule
Delete a rule
#### Path Parameters
<Properties>

View File

@@ -1,4 +1,3 @@
export const title = 'Setup Keys'
@@ -219,7 +218,7 @@ echo $response;
<Row>
<Col>
Creates a Setup Key
Creates a setup key
#### Request-Body Parameters
<Properties>
@@ -549,7 +548,7 @@ echo $response;
<Row>
<Col>
Get information about a Setup Key
Get information about a setup key
#### Path Parameters
<Properties>
@@ -765,7 +764,7 @@ echo $response;
<Row>
<Col>
Update information about a Setup Key
Update information about a setup key
#### Path Parameters
<Properties>

View File

@@ -1,4 +1,3 @@
export const title = 'Tokens'

View File

@@ -1,4 +1,3 @@
export const title = 'Users'
@@ -181,7 +180,8 @@ echo $response;
"devs"
],
"is_current": true,
"is_service_user": false
"is_service_user": false,
"is_blocked": false
}
]
```
@@ -197,7 +197,8 @@ echo $response;
"string"
],
"is_current": "boolean",
"is_service_user": "boolean"
"is_service_user": "boolean",
"is_blocked": "boolean"
}
]
```
@@ -490,7 +491,8 @@ echo $response;
"devs"
],
"is_current": true,
"is_service_user": false
"is_service_user": false,
"is_blocked": false
}
```
```json {{ title: 'Schema' }}
@@ -504,7 +506,8 @@ echo $response;
"string"
],
"is_current": "boolean",
"is_service_user": "boolean"
"is_service_user": "boolean",
"is_blocked": "boolean"
}
```
</CodeGroup>
@@ -548,6 +551,13 @@ echo $response;
>
Groups to auto-assign to peers registered by this user
</Property>
<Property name="is_blocked" type="boolean" required={true}
>
If set to true then user is blocked and can't use the system
</Property>
</Properties>
</Col>
@@ -563,7 +573,8 @@ curl -X PUT https://api.netbird.io/api/users/{userId} \
"role": "admin",
"auto_groups": [
"devs"
]
],
"is_blocked": false
}'
```
@@ -573,7 +584,8 @@ let data = JSON.stringify({
"role": "admin",
"auto_groups": [
"devs"
]
],
"is_blocked": false
});
let config = {
method: 'put',
@@ -605,7 +617,8 @@ payload = json.dumps({
"role": "admin",
"auto_groups": [
"devs"
]
],
"is_blocked": false
})
headers: {
'Content-Type': 'application/json',
@@ -637,7 +650,8 @@ func main() {
"role": "admin",
"auto_groups": [
"devs"
]
],
"is_blocked": false
}`)
client := &http.Client {
}
@@ -687,7 +701,8 @@ request.body = JSON.dump({
"role": "admin",
"auto_groups": [
"devs"
]
],
"is_blocked": false
})
response = https.request(request)
puts response.read_body
@@ -701,7 +716,8 @@ RequestBody body = RequestBody.create(mediaType, '{
"role": "admin",
"auto_groups": [
"devs"
]
],
"is_blocked": false
}');
Request request = new Request.Builder()
.url("https://api.netbird.io/api/users/{userId}")
@@ -731,7 +747,8 @@ curl_setopt_array($curl, array(
"role": "admin",
"auto_groups": [
"devs"
]
],
"is_blocked": false
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
@@ -762,7 +779,8 @@ echo $response;
"devs"
],
"is_current": true,
"is_service_user": false
"is_service_user": false,
"is_blocked": false
}
```
```json {{ title: 'Schema' }}
@@ -776,7 +794,8 @@ echo $response;
"string"
],
"is_current": "boolean",
"is_service_user": "boolean"
"is_service_user": "boolean",
"is_blocked": "boolean"
}
```
</CodeGroup>
@@ -795,7 +814,7 @@ echo $response;
<Row>
<Col>
Delete a User
Delete a user
#### Path Parameters
<Properties>