From f33b4df3dd32506b26de50ad09bd7df803e8c1fc Mon Sep 17 00:00:00 2001 From: pascal-fischer <32096965+pascal-fischer@users.noreply.github.com> Date: Mon, 5 Jun 2023 09:35:54 +0200 Subject: [PATCH] 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 --- .github/workflows/build_n_push.yml | 39 +- .gitignore | 2 + generator/api.json/.swagger-codegen-ignore | 23 - generator/api.json/.swagger-codegen/VERSION | 1 - generator/api.json/README.md | 0 generator/api.json/openapi.json | 3271 ------------------- generator/api.ts | 221 +- generator/openapi.yml | 2219 ------------- package.json | 2 +- src/pages/ipa/resources/accounts.mdx | 43 +- src/pages/ipa/resources/dns.mdx | 3 +- src/pages/ipa/resources/events.mdx | 1 - src/pages/ipa/resources/groups.mdx | 39 +- src/pages/ipa/resources/peers.mdx | 1 - src/pages/ipa/resources/policies.mdx | 473 +-- src/pages/ipa/resources/routes.mdx | 3 +- src/pages/ipa/resources/rules.mdx | 11 +- src/pages/ipa/resources/setup-keys.mdx | 7 +- src/pages/ipa/resources/tokens.mdx | 1 - src/pages/ipa/resources/users.mdx | 49 +- 20 files changed, 481 insertions(+), 5928 deletions(-) delete mode 100644 generator/api.json/.swagger-codegen-ignore delete mode 100644 generator/api.json/.swagger-codegen/VERSION delete mode 100644 generator/api.json/README.md delete mode 100644 generator/api.json/openapi.json delete mode 100644 generator/openapi.yml diff --git a/.github/workflows/build_n_push.yml b/.github/workflows/build_n_push.yml index c3b508ce..72fa4cb2 100644 --- a/.github/workflows/build_n_push.yml +++ b/.github/workflows/build_n_push.yml @@ -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 diff --git a/.gitignore b/.gitignore index 35a25d54..1ba65dec 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ yarn-error.log* package-lock.json /.next/ /yarn.lock +/generator/openapi/ +/generator/openapi.yml diff --git a/generator/api.json/.swagger-codegen-ignore b/generator/api.json/.swagger-codegen-ignore deleted file mode 100644 index c5fa491b..00000000 --- a/generator/api.json/.swagger-codegen-ignore +++ /dev/null @@ -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 diff --git a/generator/api.json/.swagger-codegen/VERSION b/generator/api.json/.swagger-codegen/VERSION deleted file mode 100644 index 34ec317a..00000000 --- a/generator/api.json/.swagger-codegen/VERSION +++ /dev/null @@ -1 +0,0 @@ -3.0.42 \ No newline at end of file diff --git a/generator/api.json/README.md b/generator/api.json/README.md deleted file mode 100644 index e69de29b..00000000 diff --git a/generator/api.json/openapi.json b/generator/api.json/openapi.json deleted file mode 100644 index b0a40828..00000000 --- a/generator/api.json/openapi.json +++ /dev/null @@ -1,3271 +0,0 @@ -{ - "openapi" : "3.0.1", - "info" : { - "title" : "NetBird REST API", - "description" : "API to manipulate groups, rules, policies and retrieve information about peers and users", - "version" : "0.0.1" - }, - "servers" : [ { - "url" : "https://api.netbird.io", - "description" : "Default server" - } ], - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ], - "tags" : [ { - "name" : "Users", - "description" : "Interact with and view information about users." - }, { - "name" : "Tokens", - "description" : "Interact with and view information about tokens." - }, { - "name" : "Peers", - "description" : "Interact with and view information about peers." - }, { - "name" : "Setup Keys", - "description" : "Interact with and view information about setup keys." - }, { - "name" : "Groups", - "description" : "Interact with and view information about groups." - }, { - "name" : "Rules", - "description" : "Interact with and view information about rules." - }, { - "name" : "Policies", - "description" : "Interact with and view information about policies." - }, { - "name" : "Routes", - "description" : "Interact with and view information about routes." - }, { - "name" : "DNS", - "description" : "Interact with and view information about DNS configuration." - }, { - "name" : "Events", - "description" : "View information about the account and network events." - }, { - "name" : "Accounts", - "description" : "View information about the accounts." - } ], - "paths" : { - "/api/accounts" : { - "get" : { - "tags" : [ "Accounts" ], - "summary" : "List all Accounts", - "description" : "Returns a list of accounts of a user. Always returns a list of one account.", - "operationId" : "getAccounts", - "responses" : { - "200" : { - "description" : "A JSON array of accounts", - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Account" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - }, - "/api/accounts/{accountId}" : { - "put" : { - "tags" : [ "Accounts" ], - "summary" : "Update an Account", - "description" : "Update information about an account", - "operationId" : "updateAccount", - "parameters" : [ { - "name" : "accountId", - "in" : "path", - "description" : "The unique identifier of an account", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "requestBody" : { - "description" : "update an account", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/AccountSettings" - } - } - } - }, - "responses" : { - "200" : { - "description" : "An Account object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Account" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - }, - "/api/users" : { - "get" : { - "tags" : [ "Users" ], - "summary" : "List all Users", - "description" : "Returns a list of all users", - "operationId" : "getUsers", - "parameters" : [ { - "name" : "service_user", - "in" : "query", - "description" : "Filters users and returns either regular users or service users", - "required" : false, - "style" : "form", - "explode" : true, - "schema" : { - "type" : "boolean" - } - } ], - "responses" : { - "200" : { - "description" : "A JSON array of Users", - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/User" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "post" : { - "tags" : [ "Users" ], - "summary" : "Create a User", - "description" : "Creates a new service user or sends an invite to a regular user", - "operationId" : "createUser", - "requestBody" : { - "description" : "User invite information", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/UserCreateRequest" - } - } - } - }, - "responses" : { - "200" : { - "description" : "A User object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - }, - "/api/users/{userId}" : { - "put" : { - "tags" : [ "Users" ], - "summary" : "Update a User", - "description" : "Update information about a User", - "operationId" : "updateUser", - "parameters" : [ { - "name" : "userId", - "in" : "path", - "description" : "The unique identifier of a user", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "requestBody" : { - "description" : "User update", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/UserRequest" - } - } - } - }, - "responses" : { - "200" : { - "description" : "A User object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "delete" : { - "tags" : [ "Users" ], - "summary" : "Delete a User", - "description" : "Delete a User", - "operationId" : "deleteUser", - "parameters" : [ { - "name" : "userId", - "in" : "path", - "description" : "The unique identifier of a user", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "Delete status code", - "content" : { } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - }, - "/api/users/{userId}/tokens" : { - "get" : { - "tags" : [ "Tokens" ], - "summary" : "List all Tokens", - "description" : "Returns a list of all tokens for a user", - "operationId" : "getTokens", - "parameters" : [ { - "name" : "userId", - "in" : "path", - "description" : "The unique identifier of a user", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "A JSON Array of PersonalAccessTokens", - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/PersonalAccessToken" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "post" : { - "tags" : [ "Tokens" ], - "summary" : "Create a Token", - "description" : "Create a new token for a user", - "operationId" : "createToken", - "parameters" : [ { - "name" : "userId", - "in" : "path", - "description" : "The unique identifier of a user", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "requestBody" : { - "description" : "PersonalAccessToken create parameters", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/PersonalAccessTokenRequest" - } - } - } - }, - "responses" : { - "200" : { - "description" : "The token in plain text", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/PersonalAccessTokenGenerated" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - }, - "/api/users/{userId}/tokens/{tokenId}" : { - "get" : { - "tags" : [ "Tokens" ], - "summary" : "Retrieve a Token", - "description" : "Returns a specific token for a user", - "operationId" : "getToken", - "parameters" : [ { - "name" : "userId", - "in" : "path", - "description" : "The unique identifier of a user", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - }, { - "name" : "tokenId", - "in" : "path", - "description" : "The unique identifier of a token", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "A PersonalAccessTokens Object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/PersonalAccessToken" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "delete" : { - "tags" : [ "Tokens" ], - "summary" : "Delete a Token", - "description" : "Delete a token for a user", - "operationId" : "deleteToken", - "parameters" : [ { - "name" : "userId", - "in" : "path", - "description" : "The unique identifier of a user", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - }, { - "name" : "tokenId", - "in" : "path", - "description" : "The unique identifier of a token", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "Delete status code", - "content" : { } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - }, - "/api/peers" : { - "get" : { - "tags" : [ "Peers" ], - "summary" : "List all Peers", - "description" : "Returns a list of all peers", - "operationId" : "getPeers", - "responses" : { - "200" : { - "description" : "A JSON Array of Peers", - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Peer" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - }, - "/api/peers/{peerId}" : { - "get" : { - "tags" : [ "Peers" ], - "summary" : "Retrieve a Peer", - "description" : "Get information about a peer", - "operationId" : "getPeer", - "parameters" : [ { - "name" : "peerId", - "in" : "path", - "description" : "The unique identifier of a peer", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "A Peer object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Peer" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "put" : { - "tags" : [ "Peers" ], - "summary" : "Update a Peer", - "description" : "Update information about a peer", - "parameters" : [ { - "name" : "peerId", - "in" : "path", - "description" : "The unique identifier of a peer", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "requestBody" : { - "description" : "update a peer", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/PeerRequest" - } - } - } - }, - "responses" : { - "200" : { - "description" : "A Peer object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Peer" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "delete" : { - "tags" : [ "Peers" ], - "summary" : "Delete a Peer", - "description" : "Delete a peer", - "parameters" : [ { - "name" : "peerId", - "in" : "path", - "description" : "The unique identifier of a peer", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "Delete status code", - "content" : { } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - }, - "/api/setup-keys" : { - "get" : { - "tags" : [ "Setup Keys" ], - "summary" : "List all Setup Keys", - "description" : "Returns a list of all Setup Keys", - "responses" : { - "200" : { - "description" : "A JSON Array of Setup keys", - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/SetupKey" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "post" : { - "tags" : [ "Setup Keys" ], - "summary" : "Create a Setup Key", - "description" : "Creates a Setup Key", - "requestBody" : { - "description" : "New Setup Key request", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/SetupKeyRequest" - } - } - } - }, - "responses" : { - "200" : { - "description" : "A Setup Keys Object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/SetupKey" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - }, - "/api/setup-keys/{keyId}" : { - "get" : { - "tags" : [ "Setup Keys" ], - "summary" : "Retrieve a Setup Key", - "description" : "Get information about a Setup Key", - "parameters" : [ { - "name" : "keyId", - "in" : "path", - "description" : "The unique identifier of a setup key", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "A Setup Key object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/SetupKey" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "put" : { - "tags" : [ "Setup Keys" ], - "summary" : "Update a Setup Key", - "description" : "Update information about a Setup Key", - "parameters" : [ { - "name" : "keyId", - "in" : "path", - "description" : "The unique identifier of a setup key", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "requestBody" : { - "description" : "update to Setup Key", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/SetupKeyRequest" - } - } - } - }, - "responses" : { - "200" : { - "description" : "A Setup Key object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/SetupKey" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - }, - "/api/groups" : { - "get" : { - "tags" : [ "Groups" ], - "summary" : "List all Groups", - "description" : "Returns a list of all Groups", - "responses" : { - "200" : { - "description" : "A JSON Array of Groups", - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Group" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "post" : { - "tags" : [ "Groups" ], - "summary" : "Create a Group", - "description" : "Creates a Group", - "requestBody" : { - "description" : "New Group request", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/GroupRequest" - } - } - } - }, - "responses" : { - "200" : { - "description" : "A Group Object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Group" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - }, - "/api/groups/{groupId}" : { - "get" : { - "tags" : [ "Groups" ], - "summary" : "Retrieve a Group", - "description" : "Get information about a Group", - "parameters" : [ { - "name" : "groupId", - "in" : "path", - "description" : "The unique identifier of a group", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "A Group object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Group" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "put" : { - "tags" : [ "Groups" ], - "summary" : "Update a Group", - "description" : "Update/Replace a Group", - "parameters" : [ { - "name" : "groupId", - "in" : "path", - "description" : "The unique identifier of a group", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "requestBody" : { - "description" : "Update Group request", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/GroupRequest" - } - } - } - }, - "responses" : { - "200" : { - "description" : "A Group object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Group" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "delete" : { - "tags" : [ "Groups" ], - "summary" : "Delete a Group", - "description" : "Delete a Group", - "parameters" : [ { - "name" : "groupId", - "in" : "path", - "description" : "The unique identifier of a group", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "Delete status code", - "content" : { } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - }, - "/api/rules" : { - "get" : { - "tags" : [ "Rules" ], - "summary" : "List all Rules", - "description" : "Returns a list of all Rules", - "responses" : { - "200" : { - "description" : "A JSON Array of Rules", - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Rule" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "post" : { - "tags" : [ "Rules" ], - "summary" : "Create a Rule", - "description" : "Creates a Rule", - "requestBody" : { - "description" : "New Rule request", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/RuleRequest" - } - } - } - }, - "responses" : { - "200" : { - "description" : "A Rule Object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Rule" - } - } - } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - }, - "/api/rules/{ruleId}" : { - "get" : { - "tags" : [ "Rules" ], - "summary" : "Retrieve a Rule", - "description" : "Get information about a Rules", - "parameters" : [ { - "name" : "ruleId", - "in" : "path", - "description" : "The unique identifier of a rule", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "A Rule object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Rule" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "put" : { - "tags" : [ "Rules" ], - "summary" : "Update a Rule", - "description" : "Update/Replace a Rule", - "parameters" : [ { - "name" : "ruleId", - "in" : "path", - "description" : "The unique identifier of a rule", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "requestBody" : { - "description" : "Update Rule request", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/RuleRequest" - } - } - } - }, - "responses" : { - "200" : { - "description" : "A Rule object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Rule" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "delete" : { - "tags" : [ "Rules" ], - "summary" : "Delete a Rule", - "description" : "Delete a Rule", - "parameters" : [ { - "name" : "ruleId", - "in" : "path", - "description" : "The unique identifier of a rule", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "Delete status code", - "content" : { } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - }, - "/api/policies" : { - "get" : { - "tags" : [ "Policies" ], - "summary" : "List all Policies", - "description" : "Returns a list of all Policies", - "responses" : { - "200" : { - "description" : "A JSON Array of Policies", - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Policy" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "post" : { - "tags" : [ "Policies" ], - "summary" : "Create a Policy", - "description" : "Creates a Policy", - "requestBody" : { - "description" : "New Policy request", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/PolicyMinimum" - } - } - } - }, - "responses" : { - "200" : { - "description" : "A Policy Object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Policy" - } - } - } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - }, - "/api/policies/{policyId}" : { - "get" : { - "tags" : [ "Policies" ], - "summary" : "Retrieve a Policy", - "description" : "Get information about a Policies", - "parameters" : [ { - "name" : "policyId", - "in" : "path", - "description" : "The unique identifier of a policy", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "A Policy object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Policy" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "put" : { - "tags" : [ "Policies" ], - "summary" : "Update a Policy", - "description" : "Update/Replace a Policy", - "parameters" : [ { - "name" : "policyId", - "in" : "path", - "description" : "The unique identifier of a policy", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "requestBody" : { - "description" : "Update Policy request", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/PolicyMinimum" - } - } - } - }, - "responses" : { - "200" : { - "description" : "A Policy object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Policy" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "delete" : { - "tags" : [ "Policies" ], - "summary" : "Delete a Policy", - "description" : "Delete a Policy", - "parameters" : [ { - "name" : "policyId", - "in" : "path", - "description" : "The unique identifier of a policy", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "Delete status code", - "content" : { } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - }, - "/api/routes" : { - "get" : { - "tags" : [ "Routes" ], - "summary" : "List all Routes", - "description" : "Returns a list of all routes", - "responses" : { - "200" : { - "description" : "A JSON Array of Routes", - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Route" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "post" : { - "tags" : [ "Routes" ], - "summary" : "Create a Route", - "description" : "Creates a Route", - "requestBody" : { - "description" : "New Routes request", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/RouteRequest" - } - } - } - }, - "responses" : { - "200" : { - "description" : "A Route Object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Route" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - }, - "/api/routes/{routeId}" : { - "get" : { - "tags" : [ "Routes" ], - "summary" : "Retrieve a Route", - "description" : "Get information about a Routes", - "parameters" : [ { - "name" : "routeId", - "in" : "path", - "description" : "The unique identifier of a route", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "A Route object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Route" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "put" : { - "tags" : [ "Routes" ], - "summary" : "Update a Route", - "description" : "Update/Replace a Route", - "parameters" : [ { - "name" : "routeId", - "in" : "path", - "description" : "The unique identifier of a route", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "requestBody" : { - "description" : "Update Route request", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/RouteRequest" - } - } - } - }, - "responses" : { - "200" : { - "description" : "A Route object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Route" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "delete" : { - "tags" : [ "Routes" ], - "summary" : "Delete a Route", - "description" : "Delete a Route", - "parameters" : [ { - "name" : "routeId", - "in" : "path", - "description" : "The unique identifier of a route", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "Delete status code", - "content" : { } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - }, - "/api/dns/nameservers" : { - "get" : { - "tags" : [ "DNS" ], - "summary" : "List all Nameserver Groups", - "description" : "Returns a list of all Nameserver Groups", - "responses" : { - "200" : { - "description" : "A JSON Array of Nameserver Groups", - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/NameserverGroup" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "post" : { - "tags" : [ "DNS" ], - "summary" : "Create a Nameserver Group", - "description" : "Creates a Nameserver Group", - "requestBody" : { - "description" : "New Nameserver Groups request", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/NameserverGroupRequest" - } - } - } - }, - "responses" : { - "200" : { - "description" : "A Nameserver Groups Object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/NameserverGroup" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - }, - "/api/dns/nameservers/{nsgroupId}" : { - "get" : { - "tags" : [ "DNS" ], - "summary" : "Retrieve a Nameserver Group", - "description" : "Get information about a Nameserver Groups", - "parameters" : [ { - "name" : "nsgroupId", - "in" : "path", - "description" : "The unique identifier of a Nameserver Group", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "A Nameserver Group object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/NameserverGroup" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "put" : { - "tags" : [ "DNS" ], - "summary" : "Update a Nameserver Group", - "description" : "Update/Replace a Nameserver Group", - "parameters" : [ { - "name" : "nsgroupId", - "in" : "path", - "description" : "The unique identifier of a Nameserver Group", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "requestBody" : { - "description" : "Update Nameserver Group request", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/NameserverGroupRequest" - } - } - } - }, - "responses" : { - "200" : { - "description" : "A Nameserver Group object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/NameserverGroup" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "delete" : { - "tags" : [ "DNS" ], - "summary" : "Delete a Nameserver Group", - "description" : "Delete a Nameserver Group", - "parameters" : [ { - "name" : "nsgroupId", - "in" : "path", - "description" : "The unique identifier of a Nameserver Group", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "Delete status code", - "content" : { } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - }, - "/api/dns/settings" : { - "get" : { - "tags" : [ "DNS" ], - "summary" : "Retrieve DNS Settings", - "description" : "Returns a DNS settings object", - "responses" : { - "200" : { - "description" : "A JSON Object of DNS Setting", - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/DNSSettings" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - }, - "put" : { - "tags" : [ "DNS" ], - "summary" : "Update DNS Settings", - "description" : "Updates a DNS settings object", - "requestBody" : { - "description" : "A DNS settings object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/DNSSettings" - } - } - } - }, - "responses" : { - "200" : { - "description" : "A JSON Object of DNS Setting", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/DNSSettings" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - }, - "/api/events" : { - "get" : { - "tags" : [ "Events" ], - "summary" : "List all Events", - "description" : "Returns a list of all events", - "responses" : { - "200" : { - "description" : "A JSON Array of Events", - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Event" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { } - }, - "401" : { - "description" : "Requires authentication", - "content" : { } - }, - "403" : { - "description" : "Forbidden", - "content" : { } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { } - } - }, - "security" : [ { - "BearerAuth" : [ ] - }, { - "TokenAuth" : [ ] - } ] - } - } - }, - "components" : { - "schemas" : { - "Account" : { - "required" : [ "id", "settings" ], - "properties" : { - "id" : { - "type" : "string", - "description" : "Account ID", - "example" : "ch8i4ug6lnn4g9hqv7l0" - }, - "settings" : { - "$ref" : "#/components/schemas/AccountSettings" - } - } - }, - "AccountSettings" : { - "required" : [ "peer_login_expiration", "peer_login_expiration_enabled" ], - "properties" : { - "peer_login_expiration_enabled" : { - "type" : "boolean", - "description" : "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).", - "example" : true - }, - "peer_login_expiration" : { - "type" : "integer", - "description" : "Period of time after which peer login expires (seconds).", - "example" : 43200 - } - } - }, - "User" : { - "required" : [ "auto_groups", "email", "id", "name", "role", "status" ], - "type" : "object", - "properties" : { - "id" : { - "type" : "string", - "description" : "User ID", - "example" : "google-oauth2|277474792786460067937" - }, - "email" : { - "type" : "string", - "description" : "User's email address", - "example" : "demo@netbird.io" - }, - "name" : { - "type" : "string", - "description" : "User's name from idp provider", - "example" : "Tom Schulz" - }, - "role" : { - "type" : "string", - "description" : "User's NetBird account role", - "example" : "admin" - }, - "status" : { - "type" : "string", - "description" : "User's status", - "example" : "active", - "enum" : [ "active", "invited", "disabled" ] - }, - "auto_groups" : { - "type" : "array", - "description" : "Groups to auto-assign to peers registered by this user", - "items" : { - "type" : "string", - "example" : "devs" - } - }, - "is_current" : { - "type" : "boolean", - "description" : "Is true if authenticated user is the same as this user", - "readOnly" : true, - "example" : true - }, - "is_service_user" : { - "type" : "boolean", - "description" : "Is true if this user is a service user", - "readOnly" : true, - "example" : false - } - } - }, - "UserRequest" : { - "required" : [ "auto_groups", "role" ], - "type" : "object", - "properties" : { - "role" : { - "type" : "string", - "description" : "User's NetBird account role", - "example" : "admin" - }, - "auto_groups" : { - "type" : "array", - "description" : "Groups to auto-assign to peers registered by this user", - "items" : { - "type" : "string", - "example" : "devs" - } - } - } - }, - "UserCreateRequest" : { - "required" : [ "auto_groups", "is_service_user", "role" ], - "type" : "object", - "properties" : { - "email" : { - "type" : "string", - "description" : "User's Email to send invite to", - "example" : "demo@netbird.io" - }, - "name" : { - "type" : "string", - "description" : "User's full name", - "example" : "Tom Schulz" - }, - "role" : { - "type" : "string", - "description" : "User's NetBird account role", - "example" : "admin" - }, - "auto_groups" : { - "type" : "array", - "description" : "Groups to auto-assign to peers registered by this user", - "items" : { - "type" : "string", - "example" : "devs" - } - }, - "is_service_user" : { - "type" : "boolean", - "description" : "Is true if this user is a service user", - "example" : false - } - } - }, - "PeerMinimum" : { - "required" : [ "id", "name" ], - "type" : "object", - "properties" : { - "id" : { - "type" : "string", - "description" : "Peer ID", - "example" : "chacbco6lnnbn6cg5s90" - }, - "name" : { - "type" : "string", - "description" : "Peer's hostname", - "example" : "stage-host-1" - } - } - }, - "PeerRequest" : { - "required" : [ "login_expiration_enabled", "name", "ssh_enabled" ], - "type" : "object", - "properties" : { - "name" : { - "type" : "string", - "example" : "stage-host-1" - }, - "ssh_enabled" : { - "type" : "boolean", - "example" : true - }, - "login_expiration_enabled" : { - "type" : "boolean", - "example" : false - } - } - }, - "Peer" : { - "allOf" : [ { - "$ref" : "#/components/schemas/PeerMinimum" - }, { - "required" : [ "connected", "dns_label", "groups", "hostname", "ip", "last_login", "last_seen", "login_expiration_enabled", "login_expired", "os", "ssh_enabled", "version" ], - "type" : "object", - "properties" : { - "ip" : { - "type" : "string", - "description" : "Peer's IP address", - "example" : "10.64.0.1" - }, - "connected" : { - "type" : "boolean", - "description" : "Peer to Management connection status", - "example" : true - }, - "last_seen" : { - "type" : "string", - "description" : "Last time peer connected to Netbird's management service", - "format" : "date-time", - "example" : "2023-05-05T10:05:26.420578Z" - }, - "os" : { - "type" : "string", - "description" : "Peer's operating system and version", - "example" : "Darwin 13.2.1" - }, - "version" : { - "type" : "string", - "description" : "Peer's daemon or cli version", - "example" : "0.14.0" - }, - "groups" : { - "type" : "array", - "description" : "Groups that the peer belongs to", - "items" : { - "$ref" : "#/components/schemas/GroupMinimum" - } - }, - "ssh_enabled" : { - "type" : "boolean", - "description" : "Indicates whether SSH server is enabled on this peer", - "example" : true - }, - "user_id" : { - "type" : "string", - "description" : "User ID of the user that enrolled this peer", - "example" : "google-oauth2|277474792786460067937" - }, - "hostname" : { - "type" : "string", - "description" : "Hostname of the machine", - "example" : "stage-host-1" - }, - "ui_version" : { - "type" : "string", - "description" : "Peer's desktop UI version", - "example" : "0.14.0" - }, - "dns_label" : { - "type" : "string", - "description" : "Peer's DNS label is the parsed peer name for domain resolution. It is used to form an FQDN by appending the account's domain to the peer label. e.g. peer-dns-label.netbird.cloud", - "example" : "stage-host-1.netbird.cloud" - }, - "login_expiration_enabled" : { - "type" : "boolean", - "description" : "Indicates whether peer login expiration has been enabled or not", - "example" : false - }, - "login_expired" : { - "type" : "boolean", - "description" : "Indicates whether peer's login expired or not", - "example" : false - }, - "last_login" : { - "type" : "string", - "description" : "Last time this peer performed log in (authentication). E.g., user authenticated.", - "format" : "date-time", - "example" : "2023-05-05T09:00:35.477782Z" - } - } - } ] - }, - "SetupKey" : { - "required" : [ "auto_groups", "expires", "id", "key", "last_used", "name", "revoked", "state", "type", "updated_at", "usage_limit", "used_times", "valid" ], - "type" : "object", - "properties" : { - "id" : { - "type" : "string", - "description" : "Setup Key ID", - "example" : "2531583362" - }, - "key" : { - "type" : "string", - "description" : "Setup Key value", - "example" : "A616097E-FCF0-48FA-9354-CA4A61142761" - }, - "name" : { - "type" : "string", - "description" : "Setup key name identifier", - "example" : "Default key" - }, - "expires" : { - "type" : "string", - "description" : "Setup Key expiration date", - "format" : "date-time", - "example" : "2023-06-01T14:47:22.291057Z" - }, - "type" : { - "type" : "string", - "description" : "Setup key type, one-off for single time usage and reusable", - "example" : "reusable" - }, - "valid" : { - "type" : "boolean", - "description" : "Setup key validity status", - "example" : true - }, - "revoked" : { - "type" : "boolean", - "description" : "Setup key revocation status", - "example" : false - }, - "used_times" : { - "type" : "integer", - "description" : "Usage count of setup key", - "example" : 2 - }, - "last_used" : { - "type" : "string", - "description" : "Setup key last usage date", - "format" : "date-time", - "example" : "2023-05-05T09:00:35.477782Z" - }, - "state" : { - "type" : "string", - "description" : "Setup key status, \"valid\", \"overused\",\"expired\" or \"revoked\"", - "example" : "valid" - }, - "auto_groups" : { - "type" : "array", - "description" : "Setup key groups to auto-assign to peers registered with this key", - "items" : { - "type" : "string", - "example" : "devs" - } - }, - "updated_at" : { - "type" : "string", - "description" : "Setup key last update date", - "format" : "date-time", - "example" : "2023-05-05T09:00:35.477782Z" - }, - "usage_limit" : { - "type" : "integer", - "description" : "A number of times this key can be used. The value of 0 indicates the unlimited usage.", - "example" : 0 - } - } - }, - "SetupKeyRequest" : { - "required" : [ "auto_groups", "expires_in", "name", "revoked", "type", "usage_limit" ], - "type" : "object", - "properties" : { - "name" : { - "type" : "string", - "description" : "Setup Key name", - "example" : "Default key" - }, - "type" : { - "type" : "string", - "description" : "Setup key type, one-off for single time usage and reusable", - "example" : "reusable" - }, - "expires_in" : { - "type" : "integer", - "description" : "Expiration time in seconds", - "example" : 43200 - }, - "revoked" : { - "type" : "boolean", - "description" : "Setup key revocation status", - "example" : false - }, - "auto_groups" : { - "type" : "array", - "description" : "Setup key groups to auto-assign to peers registered with this key", - "items" : { - "type" : "string", - "example" : "devs" - } - }, - "usage_limit" : { - "type" : "integer", - "description" : "A number of times this key can be used. The value of 0 indicates the unlimited usage.", - "example" : 0 - } - } - }, - "PersonalAccessToken" : { - "required" : [ "created_at", "created_by", "expiration_date", "id", "name" ], - "type" : "object", - "properties" : { - "id" : { - "type" : "string", - "description" : "ID of a token", - "example" : "ch8i54g6lnn4g9hqv7n0" - }, - "name" : { - "type" : "string", - "description" : "Name of the token", - "example" : "My first token" - }, - "expiration_date" : { - "type" : "string", - "description" : "Date the token expires", - "format" : "date-time", - "example" : "2023-05-05T14:38:28.977616Z" - }, - "created_by" : { - "type" : "string", - "description" : "User ID of the user who created the token", - "example" : "google-oauth2|277474792786460067937" - }, - "created_at" : { - "type" : "string", - "description" : "Date the token was created", - "format" : "date-time", - "example" : "2023-05-02T14:48:20.465209Z" - }, - "last_used" : { - "type" : "string", - "description" : "Date the token was last used", - "format" : "date-time", - "example" : "2023-05-04T12:45:25.9723616Z" - } - } - }, - "PersonalAccessTokenGenerated" : { - "required" : [ "personal_access_token", "plain_token" ], - "type" : "object", - "properties" : { - "plain_token" : { - "type" : "string", - "description" : "Plain text representation of the generated token", - "example" : "2023-05-02T14:48:20.465209Z" - }, - "personal_access_token" : { - "$ref" : "#/components/schemas/PersonalAccessToken" - } - } - }, - "PersonalAccessTokenRequest" : { - "required" : [ "expires_in", "name" ], - "type" : "object", - "properties" : { - "name" : { - "type" : "string", - "description" : "Name of the token", - "example" : "My first token" - }, - "expires_in" : { - "maximum" : 365, - "minimum" : 1, - "type" : "integer", - "description" : "Expiration in days", - "example" : 30 - } - } - }, - "GroupMinimum" : { - "required" : [ "id", "name", "peers_count" ], - "type" : "object", - "properties" : { - "id" : { - "type" : "string", - "description" : "Group ID", - "example" : "ch8i4ug6lnn4g9hqv7m0" - }, - "name" : { - "type" : "string", - "description" : "Group Name identifier", - "example" : "devs" - }, - "peers_count" : { - "type" : "integer", - "description" : "Count of peers associated to the group", - "example" : 2 - } - } - }, - "GroupRequest" : { - "required" : [ "name" ], - "type" : "object", - "properties" : { - "name" : { - "type" : "string", - "description" : "Group name identifier", - "example" : "devs" - }, - "peers" : { - "type" : "array", - "description" : "List of peers ids", - "example" : "ch8i4ug6lnn4g9hqv7m1", - "items" : { - "type" : "string" - } - } - } - }, - "Group" : { - "allOf" : [ { - "$ref" : "#/components/schemas/GroupMinimum" - }, { - "required" : [ "peers" ], - "type" : "object", - "properties" : { - "peers" : { - "type" : "array", - "description" : "List of peers object", - "items" : { - "$ref" : "#/components/schemas/PeerMinimum" - } - } - } - } ] - }, - "RuleMinimum" : { - "required" : [ "description", "disabled", "flow", "name" ], - "type" : "object", - "properties" : { - "name" : { - "type" : "string", - "description" : "Rule name identifier", - "example" : "Default" - }, - "description" : { - "type" : "string", - "description" : "Rule friendly description", - "example" : "This is a default rule that allows connections between all the resources" - }, - "disabled" : { - "type" : "boolean", - "description" : "Rules status", - "example" : false - }, - "flow" : { - "type" : "string", - "description" : "Rule flow, currently, only \"bidirect\" for bi-directional traffic is accepted", - "example" : "bidirect" - } - } - }, - "RuleRequest" : { - "allOf" : [ { - "$ref" : "#/components/schemas/RuleMinimum" - }, { - "type" : "object", - "properties" : { - "sources" : { - "type" : "array", - "description" : "List of source groups", - "items" : { - "type" : "string", - "example" : "ch8i4ug6lnn4g9hqv7m1" - } - }, - "destinations" : { - "type" : "array", - "description" : "List of destination groups", - "items" : { - "type" : "string", - "example" : "ch8i4ug6lnn4g9hqv7m0" - } - } - } - } ] - }, - "Rule" : { - "allOf" : [ { - "required" : [ "id" ], - "type" : "object", - "properties" : { - "id" : { - "type" : "string", - "description" : "Rule ID", - "example" : "ch8i4ug6lnn4g9hqv7mg" - } - } - }, { - "$ref" : "#/components/schemas/RuleMinimum" - }, { - "required" : [ "destinations", "sources" ], - "type" : "object", - "properties" : { - "sources" : { - "type" : "array", - "description" : "Rule source groups", - "items" : { - "$ref" : "#/components/schemas/GroupMinimum" - } - }, - "destinations" : { - "type" : "array", - "description" : "Rule destination groups", - "items" : { - "$ref" : "#/components/schemas/GroupMinimum" - } - } - } - } ] - }, - "PolicyRule" : { - "required" : [ "action", "destinations", "enabled", "name", "sources" ], - "type" : "object", - "properties" : { - "id" : { - "type" : "string", - "description" : "Rule ID", - "example" : "ch8i4ug6lnn4g9hqv7mg" - }, - "name" : { - "type" : "string", - "description" : "Rule name identifier", - "example" : "Default" - }, - "description" : { - "type" : "string", - "description" : "Rule friendly description", - "example" : "This is a default rule that allows connections between all the resources" - }, - "enabled" : { - "type" : "boolean", - "description" : "Rules status", - "example" : true - }, - "sources" : { - "type" : "array", - "description" : "policy source groups", - "items" : { - "$ref" : "#/components/schemas/GroupMinimum" - } - }, - "destinations" : { - "type" : "array", - "description" : "policy destination groups", - "items" : { - "$ref" : "#/components/schemas/GroupMinimum" - } - }, - "action" : { - "type" : "string", - "description" : "policy accept or drops packets", - "example" : "accept", - "enum" : [ "accept", "drop" ] - } - } - }, - "PolicyMinimum" : { - "required" : [ "description", "enabled", "name", "query", "rules" ], - "type" : "object", - "properties" : { - "name" : { - "type" : "string", - "description" : "Policy name identifier", - "example" : "ch8i4ug6lnn4g9hqv7mg" - }, - "description" : { - "type" : "string", - "description" : "Policy friendly description", - "example" : "This is a default policy that allows connections between all the resources" - }, - "enabled" : { - "type" : "boolean", - "description" : "Policy status", - "example" : true - }, - "query" : { - "type" : "string", - "description" : "Policy Rego query", - "example" : "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" : { - "type" : "array", - "description" : "Policy rule object for policy UI editor", - "items" : { - "$ref" : "#/components/schemas/PolicyRule" - } - } - } - }, - "Policy" : { - "allOf" : [ { - "$ref" : "#/components/schemas/PolicyMinimum" - }, { - "required" : [ "id" ], - "type" : "object", - "properties" : { - "id" : { - "type" : "string", - "description" : "Policy ID", - "example" : "ch8i4ug6lnn4g9hqv7mg" - } - } - } ] - }, - "RouteRequest" : { - "required" : [ "description", "enabled", "groups", "id", "masquerade", "metric", "network", "network_id", "peer" ], - "type" : "object", - "properties" : { - "description" : { - "type" : "string", - "description" : "Route description", - "example" : "My first route" - }, - "network_id" : { - "maxLength" : 40, - "minLength" : 1, - "type" : "string", - "description" : "Route network identifier, to group HA routes", - "example" : "Route 1" - }, - "enabled" : { - "type" : "boolean", - "description" : "Route status", - "example" : true - }, - "peer" : { - "type" : "string", - "description" : "Peer Identifier associated with route", - "example" : "chacbco6lnnbn6cg5s91" - }, - "network" : { - "type" : "string", - "description" : "Network range in CIDR format", - "example" : "10.64.0.0/24" - }, - "metric" : { - "maximum" : 9999, - "minimum" : 1, - "type" : "integer", - "description" : "Route metric number. Lowest number has higher priority", - "example" : 9999 - }, - "masquerade" : { - "type" : "boolean", - "description" : "Indicate if peer should masquerade traffic to this route's prefix", - "example" : true - }, - "groups" : { - "type" : "array", - "description" : "Route group tag groups", - "items" : { - "type" : "string", - "example" : "chacdk86lnnboviihd70" - } - } - } - }, - "Route" : { - "allOf" : [ { - "required" : [ "id", "network_type" ], - "type" : "object", - "properties" : { - "id" : { - "type" : "string", - "description" : "Route Id", - "example" : "chacdk86lnnboviihd7g" - }, - "network_type" : { - "type" : "string", - "description" : "Network type indicating if it is IPv4 or IPv6", - "example" : "IPv4" - } - } - }, { - "$ref" : "#/components/schemas/RouteRequest" - } ] - }, - "Nameserver" : { - "required" : [ "ip", "ns_type", "port" ], - "type" : "object", - "properties" : { - "ip" : { - "type" : "string", - "description" : "Nameserver IP", - "example" : "8.8.8.8" - }, - "ns_type" : { - "type" : "string", - "description" : "Nameserver Type", - "example" : "udp", - "enum" : [ "udp" ] - }, - "port" : { - "type" : "integer", - "description" : "Nameserver Port", - "example" : 53 - } - } - }, - "NameserverGroupRequest" : { - "required" : [ "description", "domains", "enabled", "groups", "name", "nameservers", "primary" ], - "type" : "object", - "properties" : { - "name" : { - "maxLength" : 40, - "minLength" : 1, - "type" : "string", - "description" : "Nameserver group name", - "example" : "Google DNS" - }, - "description" : { - "type" : "string", - "description" : "Nameserver group description", - "example" : "Google DNS servers" - }, - "nameservers" : { - "maxLength" : 2, - "minLength" : 1, - "type" : "array", - "description" : "Nameserver group", - "items" : { - "$ref" : "#/components/schemas/Nameserver" - } - }, - "enabled" : { - "type" : "boolean", - "description" : "Nameserver group status", - "example" : true - }, - "groups" : { - "type" : "array", - "description" : "Nameserver group tag groups", - "items" : { - "type" : "string", - "example" : "ch8i4ug6lnn4g9hqv7m0" - } - }, - "primary" : { - "type" : "boolean", - "description" : "Nameserver group primary status", - "example" : true - }, - "domains" : { - "type" : "array", - "description" : "Nameserver group domain list", - "items" : { - "maxLength" : 255, - "minLength" : 1, - "type" : "string", - "example" : "example.com" - } - } - } - }, - "NameserverGroup" : { - "allOf" : [ { - "required" : [ "id" ], - "type" : "object", - "properties" : { - "id" : { - "type" : "string", - "description" : "Nameserver group ID", - "example" : "ch8i4ug6lnn4g9hqv7m0" - } - } - }, { - "$ref" : "#/components/schemas/NameserverGroupRequest" - } ] - }, - "DNSSettings" : { - "required" : [ "disabled_management_groups" ], - "type" : "object", - "properties" : { - "disabled_management_groups" : { - "type" : "array", - "description" : "Groups whose DNS management is disabled", - "items" : { - "type" : "string", - "example" : "ch8i4ug6lnn4g9hqv7m0" - } - } - } - }, - "Event" : { - "required" : [ "activity", "activity_code", "id", "initiator_id", "meta", "target_id", "timestamp" ], - "type" : "object", - "properties" : { - "id" : { - "type" : "string", - "description" : "Event unique identifier", - "example" : "10" - }, - "timestamp" : { - "type" : "string", - "description" : "The date and time when the event occurred", - "format" : "date-time", - "example" : "2023-05-05T10:04:37.473542Z" - }, - "activity" : { - "type" : "string", - "description" : "The activity that occurred during the event", - "example" : "Route created" - }, - "activity_code" : { - "type" : "string", - "description" : "The string code of the activity that occurred during the event", - "example" : "route.add", - "enum" : [ "user.peer.delete", "user.join", "user.invite", "user.peer.add", "user.group.add", "user.group.delete", "user.role.update", "setupkey.peer.add", "setupkey.add", "setupkey.update", "setupkey.revoke", "setupkey.overuse", "setupkey.group.delete", "setupkey.group.add", "rule.add", "rule.delete", "rule.update", "policy.add", "policy.delete", "policy.update", "group.add", "group.update", "dns.setting.disabled.management.group.add", "dns.setting.disabled.management.group.delete", "account.create", "account.setting.peer.login.expiration.update", "account.setting.peer.login.expiration.disable", "account.setting.peer.login.expiration.enable", "route.add", "route.delete", "route.update", "nameserver.group.add", "nameserver.group.delete", "nameserver.group.update", "peer.ssh.disable", "peer.ssh.enable", "peer.rename", "peer.login.expiration.disable", "peer.login.expiration.enable", "service.user.create", "personal.access.token.create", "service.user.delete", "personal.access.token.delete" ] - }, - "initiator_id" : { - "type" : "string", - "description" : "The ID of the initiator of the event. E.g., an ID of a user that triggered the event.", - "example" : "google-oauth2|123456789012345678901" - }, - "target_id" : { - "type" : "string", - "description" : "The ID of the target of the event. E.g., an ID of the peer that a user removed.", - "example" : "chad9d86lnnc59g18ou0" - }, - "meta" : { - "type" : "object", - "additionalProperties" : { - "type" : "string" - }, - "description" : "The metadata of the event", - "example" : { - "name" : "my route", - "network_range" : "10.64.0.0/24", - "peer_id" : "chacbco6lnnbn6cg5s91" - } - } - } - } - }, - "responses" : { - "not_found" : { - "description" : "Resource not found", - "content" : { } - }, - "validation_failed_simple" : { - "description" : "Validation failed", - "content" : { } - }, - "bad_request" : { - "description" : "Bad Request", - "content" : { } - }, - "internal_error" : { - "description" : "Internal Server Error", - "content" : { } - }, - "validation_failed" : { - "description" : "Validation failed", - "content" : { } - }, - "forbidden" : { - "description" : "Forbidden", - "content" : { } - }, - "requires_authentication" : { - "description" : "Requires authentication", - "content" : { } - } - }, - "securitySchemes" : { - "BearerAuth" : { - "type" : "http", - "scheme" : "bearer", - "bearerFormat" : "JWT" - }, - "TokenAuth" : { - "type" : "apiKey", - "description" : "Enter the token with the `Token` prefix, e.g. \"Token nbp_F3f0d.....\".", - "name" : "Authorization", - "in" : "header" - } - } - } -} \ No newline at end of file diff --git a/generator/api.ts b/generator/api.ts index be74f984..59024cc3 100644 --- a/generator/api.ts +++ b/generator/api.ts @@ -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(); - Object.entries(spec.components?.schemas).forEach(([key, val]) => { - const schema = val as OpenAPIV3.SchemaObject - let outputSchema = new Map(); - let outputExample = new Map(); - 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() - 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 { + 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 + } + 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() + 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 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() - 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() + 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 (items as OpenAPIV3.ArraySchemaObject).example + 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())]); +} diff --git a/generator/openapi.yml b/generator/openapi.yml deleted file mode 100644 index 8d3b7a5b..00000000 --- a/generator/openapi.yml +++ /dev/null @@ -1,2219 +0,0 @@ -openapi: 3.0.1 -servers: - - url: https://api.netbird.io - description: Default server -info: - title: NetBird REST API - description: API to manipulate groups, rules, policies and retrieve information about peers and users - version: 0.0.1 -tags: - - name: Users - description: Interact with and view information about users. - - name: Tokens - description: Interact with and view information about tokens. - - name: Peers - description: Interact with and view information about peers. - - name: Setup Keys - description: Interact with and view information about setup keys. - - name: Groups - description: Interact with and view information about groups. - - name: Rules - description: Interact with and view information about rules. - - name: Policies - description: Interact with and view information about policies. - - name: Routes - description: Interact with and view information about routes. - - name: DNS - description: Interact with and view information about DNS configuration. - - name: Events - description: View information about the account and network events. - - name: Accounts - description: View information about the accounts. -components: - schemas: - Account: - properties: - id: - description: Account ID - type: string - example: ch8i4ug6lnn4g9hqv7l0 - settings: - $ref: '#/components/schemas/AccountSettings' - required: - - id - - settings - AccountSettings: - properties: - peer_login_expiration_enabled: - description: 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). - type: boolean - example: true - peer_login_expiration: - description: Period of time after which peer login expires (seconds). - type: integer - example: 43200 - required: - - peer_login_expiration_enabled - - peer_login_expiration - User: - type: object - properties: - id: - description: User ID - type: string - example: google-oauth2|277474792786460067937 - email: - description: User's email address - type: string - example: demo@netbird.io - name: - description: User's name from idp provider - type: string - example: Tom Schulz - role: - description: User's NetBird account role - type: string - example: admin - status: - description: User's status - type: string - enum: [ "active","invited","disabled" ] - example: active - auto_groups: - description: Groups to auto-assign to peers registered by this user - type: array - items: - type: string - example: devs - is_current: - description: Is true if authenticated user is the same as this user - type: boolean - readOnly: true - example: true - is_service_user: - description: Is true if this user is a service user - type: boolean - readOnly: true - example: false - required: - - id - - email - - name - - role - - auto_groups - - status - UserRequest: - type: object - properties: - role: - description: User's NetBird account role - type: string - example: admin - auto_groups: - description: Groups to auto-assign to peers registered by this user - type: array - items: - type: string - example: devs - required: - - role - - auto_groups - UserCreateRequest: - type: object - properties: - email: - description: User's Email to send invite to - type: string - example: demo@netbird.io - name: - description: User's full name - type: string - example: Tom Schulz - role: - description: User's NetBird account role - type: string - example: admin - auto_groups: - description: Groups to auto-assign to peers registered by this user - type: array - items: - type: string - example: devs - is_service_user: - description: Is true if this user is a service user - type: boolean - example: false - required: - - role - - auto_groups - - is_service_user - PeerMinimum: - type: object - properties: - id: - description: Peer ID - type: string - example: chacbco6lnnbn6cg5s90 - name: - description: Peer's hostname - type: string - example: stage-host-1 - required: - - id - - name - PeerRequest: - type: object - properties: - name: - type: string - example: stage-host-1 - ssh_enabled: - type: boolean - example: true - login_expiration_enabled: - type: boolean - example: false - required: - - name - - ssh_enabled - - login_expiration_enabled - Peer: - allOf: - - $ref: '#/components/schemas/PeerMinimum' - - type: object - properties: - ip: - description: Peer's IP address - type: string - example: 10.64.0.1 - connected: - description: Peer to Management connection status - type: boolean - example: true - last_seen: - description: Last time peer connected to Netbird's management service - type: string - format: date-time - example: 2023-05-05T10:05:26.420578Z - os: - description: Peer's operating system and version - type: string - example: Darwin 13.2.1 - version: - description: Peer's daemon or cli version - type: string - example: 0.14.0 - groups: - description: Groups that the peer belongs to - type: array - items: - $ref: '#/components/schemas/GroupMinimum' - ssh_enabled: - description: Indicates whether SSH server is enabled on this peer - type: boolean - example: true - user_id: - description: User ID of the user that enrolled this peer - type: string - example: google-oauth2|277474792786460067937 - hostname: - description: Hostname of the machine - type: string - example: stage-host-1 - ui_version: - description: Peer's desktop UI version - type: string - example: 0.14.0 - dns_label: - description: Peer's DNS label is the parsed peer name for domain resolution. It is used to form an FQDN by appending the account's domain to the peer label. e.g. peer-dns-label.netbird.cloud - type: string - example: stage-host-1.netbird.cloud - login_expiration_enabled: - description: Indicates whether peer login expiration has been enabled or not - type: boolean - example: false - login_expired: - description: Indicates whether peer's login expired or not - type: boolean - example: false - last_login: - description: Last time this peer performed log in (authentication). E.g., user authenticated. - type: string - format: date-time - example: 2023-05-05T09:00:35.477782Z - required: - - ip - - connected - - last_seen - - os - - version - - groups - - ssh_enabled - - hostname - - dns_label - - login_expiration_enabled - - login_expired - - last_login - SetupKey: - type: object - properties: - id: - description: Setup Key ID - type: string - example: 2531583362 - key: - description: Setup Key value - type: string - example: A616097E-FCF0-48FA-9354-CA4A61142761 - name: - description: Setup key name identifier - type: string - example: Default key - expires: - description: Setup Key expiration date - type: string - format: date-time - example: 2023-06-01T14:47:22.291057Z - type: - description: Setup key type, one-off for single time usage and reusable - type: string - example: reusable - valid: - description: Setup key validity status - type: boolean - example: true - revoked: - description: Setup key revocation status - type: boolean - example: false - used_times: - description: Usage count of setup key - type: integer - example: 2 - last_used: - description: Setup key last usage date - type: string - format: date-time - example: 2023-05-05T09:00:35.477782Z - state: - description: Setup key status, "valid", "overused","expired" or "revoked" - type: string - example: valid - auto_groups: - description: Setup key groups to auto-assign to peers registered with this key - type: array - items: - type: string - example: "devs" - updated_at: - description: Setup key last update date - type: string - format: date-time - example: 2023-05-05T09:00:35.477782Z - usage_limit: - description: A number of times this key can be used. The value of 0 indicates the unlimited usage. - type: integer - example: 0 - required: - - id - - key - - name - - expires - - type - - valid - - revoked - - used_times - - last_used - - state - - auto_groups - - updated_at - - usage_limit - SetupKeyRequest: - type: object - properties: - name: - description: Setup Key name - type: string - example: Default key - type: - description: Setup key type, one-off for single time usage and reusable - type: string - example: reusable - expires_in: - description: Expiration time in seconds - type: integer - example: 43200 - revoked: - description: Setup key revocation status - type: boolean - example: false - auto_groups: - description: Setup key groups to auto-assign to peers registered with this key - type: array - items: - type: string - example: "devs" - usage_limit: - description: A number of times this key can be used. The value of 0 indicates the unlimited usage. - type: integer - example: 0 - required: - - name - - type - - expires_in - - revoked - - auto_groups - - usage_limit - PersonalAccessToken: - type: object - properties: - id: - description: ID of a token - type: string - example: ch8i54g6lnn4g9hqv7n0 - name: - description: Name of the token - type: string - example: My first token - expiration_date: - description: Date the token expires - type: string - format: date-time - example: 2023-05-05T14:38:28.977616Z - created_by: - description: User ID of the user who created the token - type: string - example: google-oauth2|277474792786460067937 - created_at: - description: Date the token was created - type: string - format: date-time - example: 2023-05-02T14:48:20.465209Z - last_used: - description: Date the token was last used - type: string - format: date-time - example: 2023-05-04T12:45:25.9723616Z - required: - - id - - name - - expiration_date - - created_by - - created_at - PersonalAccessTokenGenerated: - type: object - properties: - plain_token: - description: Plain text representation of the generated token - type: string - example: 2023-05-02T14:48:20.465209Z - personal_access_token: - $ref: '#/components/schemas/PersonalAccessToken' - required: - - plain_token - - personal_access_token - PersonalAccessTokenRequest: - type: object - properties: - name: - description: Name of the token - type: string - example: My first token - expires_in: - description: Expiration in days - type: integer - minimum: 1 - maximum: 365 - example: 30 - required: - - name - - expires_in - GroupMinimum: - type: object - properties: - id: - description: Group ID - type: string - example: ch8i4ug6lnn4g9hqv7m0 - name: - description: Group Name identifier - type: string - example: devs - peers_count: - description: Count of peers associated to the group - type: integer - example: 2 - required: - - id - - name - - peers_count - GroupRequest: - type: object - properties: - name: - type: string - description: Group name identifier - example: devs - peers: - type: array - description: List of peers ids - items: - type: string - example: "ch8i4ug6lnn4g9hqv7m1" - required: - - name - Group: - allOf: - - $ref: '#/components/schemas/GroupMinimum' - - type: object - properties: - peers: - description: List of peers object - type: array - items: - $ref: '#/components/schemas/PeerMinimum' - required: - - peers - RuleMinimum: - type: object - properties: - name: - description: Rule name identifier - type: string - example: Default - description: - description: Rule friendly description - type: string - example: This is a default rule that allows connections between all the resources - disabled: - description: Rules status - type: boolean - example: false - flow: - description: Rule flow, currently, only "bidirect" for bi-directional traffic is accepted - type: string - example: bidirect - required: - - name - - description - - disabled - - flow - RuleRequest: - allOf: - - $ref: '#/components/schemas/RuleMinimum' - - type: object - properties: - sources: - type: array - description: List of source groups - items: - type: string - example: "ch8i4ug6lnn4g9hqv7m1" - destinations: - type: array - description: List of destination groups - items: - type: string - example: "ch8i4ug6lnn4g9hqv7m0" - Rule: - allOf: - - type: object - properties: - id: - description: Rule ID - type: string - example: ch8i4ug6lnn4g9hqv7mg - required: - - id - - $ref: '#/components/schemas/RuleMinimum' - - type: object - properties: - sources: - description: Rule source groups - type: array - items: - $ref: '#/components/schemas/GroupMinimum' - destinations: - description: Rule destination groups - type: array - items: - $ref: '#/components/schemas/GroupMinimum' - required: - - sources - - destinations - PolicyRule: - type: object - properties: - id: - description: Rule ID - type: string - example: ch8i4ug6lnn4g9hqv7mg - name: - description: Rule name identifier - type: string - example: Default - description: - description: Rule friendly description - type: string - example: This is a default rule that allows connections between all the resources - enabled: - description: Rules status - type: boolean - example: true - sources: - description: policy source groups - type: array - items: - $ref: '#/components/schemas/GroupMinimum' - destinations: - description: policy destination groups - type: array - items: - $ref: '#/components/schemas/GroupMinimum' - action: - description: policy accept or drops packets - type: string - enum: ["accept","drop"] - example: accept - required: - - name - - sources - - destinations - - action - - enabled - PolicyMinimum: - type: object - properties: - name: - description: Policy name identifier - type: string - example: ch8i4ug6lnn4g9hqv7mg - description: - description: Policy friendly description - type: string - example: This is a default policy that allows connections between all the resources - enabled: - description: Policy status - type: boolean - example: true - query: - description: Policy Rego query - type: string - example: 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: - description: Policy rule object for policy UI editor - type: array - items: - $ref: '#/components/schemas/PolicyRule' - required: - - name - - description - - enabled - - query - - rules - Policy: - allOf: - - $ref: '#/components/schemas/PolicyMinimum' - - type: object - properties: - id: - description: Policy ID - type: string - example: ch8i4ug6lnn4g9hqv7mg - required: - - id - RouteRequest: - type: object - properties: - description: - description: Route description - type: string - example: My first route - network_id: - description: Route network identifier, to group HA routes - type: string - maxLength: 40 - minLength: 1 - example: Route 1 - enabled: - description: Route status - type: boolean - example: true - peer: - description: Peer Identifier associated with route - type: string - example: chacbco6lnnbn6cg5s91 - network: - description: Network range in CIDR format - type: string - example: 10.64.0.0/24 - metric: - description: Route metric number. Lowest number has higher priority - type: integer - maximum: 9999 - minimum: 1 - example: 9999 - masquerade: - description: Indicate if peer should masquerade traffic to this route's prefix - type: boolean - example: true - groups: - description: Route group tag groups - type: array - items: - type: string - example: "chacdk86lnnboviihd70" - required: - - id - - description - - network_id - - enabled - - peer - - network - - metric - - masquerade - - groups - Route: - allOf: - - type: object - properties: - id: - description: Route Id - type: string - example: chacdk86lnnboviihd7g - network_type: - description: Network type indicating if it is IPv4 or IPv6 - type: string - example: IPv4 - required: - - id - - network_type - - $ref: '#/components/schemas/RouteRequest' - Nameserver: - type: object - properties: - ip: - description: Nameserver IP - type: string - example: 8.8.8.8 - ns_type: - description: Nameserver Type - type: string - enum: [ "udp" ] - example: udp - port: - description: Nameserver Port - type: integer - example: 53 - required: - - ip - - ns_type - - port - NameserverGroupRequest: - type: object - properties: - name: - description: Nameserver group name - type: string - maxLength: 40 - minLength: 1 - example: Google DNS - description: - description: Nameserver group description - type: string - example: Google DNS servers - nameservers: - description: Nameserver group - minLength: 1 - maxLength: 2 - type: array - items: - $ref: '#/components/schemas/Nameserver' - enabled: - description: Nameserver group status - type: boolean - example: true - groups: - description: Nameserver group tag groups - type: array - items: - type: string - example: ch8i4ug6lnn4g9hqv7m0 - primary: - description: Nameserver group primary status - type: boolean - example: true - domains: - description: Nameserver group domain list - type: array - items: - type: string - minLength: 1 - maxLength: 255 - example: "example.com" - required: - - name - - description - - nameservers - - enabled - - groups - - primary - - domains - NameserverGroup: - allOf: - - type: object - properties: - id: - description: Nameserver group ID - type: string - example: ch8i4ug6lnn4g9hqv7m0 - required: - - id - - $ref: '#/components/schemas/NameserverGroupRequest' - DNSSettings: - type: object - properties: - disabled_management_groups: - description: Groups whose DNS management is disabled - type: array - items: - type: string - example: ch8i4ug6lnn4g9hqv7m0 - required: - - disabled_management_groups - Event: - type: object - properties: - id: - description: Event unique identifier - type: string - example: 10 - timestamp: - description: The date and time when the event occurred - type: string - format: date-time - example: 2023-05-05T10:04:37.473542Z - activity: - description: The activity that occurred during the event - type: string - example: Route created - activity_code: - description: The string code of the activity that occurred during the event - type: string - enum: [ "user.peer.delete", "user.join", "user.invite", "user.peer.add", "user.group.add", "user.group.delete", - "user.role.update", - "setupkey.peer.add", "setupkey.add", "setupkey.update", "setupkey.revoke", "setupkey.overuse", - "setupkey.group.delete", "setupkey.group.add", - "rule.add", "rule.delete", "rule.update", - "policy.add", "policy.delete", "policy.update", - "group.add", "group.update", "dns.setting.disabled.management.group.add", "dns.setting.disabled.management.group.delete", - "account.create", "account.setting.peer.login.expiration.update", "account.setting.peer.login.expiration.disable", "account.setting.peer.login.expiration.enable", - "route.add", "route.delete", "route.update", - "nameserver.group.add", "nameserver.group.delete", "nameserver.group.update", - "peer.ssh.disable", "peer.ssh.enable", "peer.rename", "peer.login.expiration.disable", "peer.login.expiration.enable", - "service.user.create", "personal.access.token.create", "service.user.delete", "personal.access.token.delete" ] - example: route.add - initiator_id: - description: The ID of the initiator of the event. E.g., an ID of a user that triggered the event. - type: string - example: google-oauth2|123456789012345678901 - target_id: - description: The ID of the target of the event. E.g., an ID of the peer that a user removed. - type: string - example: chad9d86lnnc59g18ou0 - meta: - description: The metadata of the event - type: object - additionalProperties: - type: string - example: { "name": "my route", "network_range": "10.64.0.0/24", "peer_id": "chacbco6lnnbn6cg5s91"} - required: - - id - - timestamp - - activity - - activity_code - - initiator_id - - target_id - - meta - responses: - not_found: - description: Resource not found - content: { } - validation_failed_simple: - description: Validation failed - content: { } - bad_request: - description: Bad Request - content: { } - internal_error: - description: Internal Server Error - content: { } - validation_failed: - description: Validation failed - content: { } - forbidden: - description: Forbidden - content: { } - requires_authentication: - description: Requires authentication - content: { } - securitySchemes: - BearerAuth: - type: http - scheme: bearer - bearerFormat: JWT - TokenAuth: - type: apiKey - in: header - name: Authorization - description: >- - Enter the token with the `Token` prefix, e.g. "Token nbp_F3f0d.....". -security: - - BearerAuth: [ ] - - TokenAuth: [ ] -paths: - /api/accounts: - get: - summary: List all Accounts - description: Returns a list of accounts of a user. Always returns a list of one account. - tags: [ Accounts ] - operationId: getAccounts - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - responses: - '200': - description: A JSON array of accounts - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Account' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - /api/accounts/{accountId}: - put: - summary: Update an Account - description: Update information about an account - tags: [ Accounts ] - operationId: updateAccount - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: accountId - required: true - schema: - type: string - description: The unique identifier of an account - requestBody: - description: update an account - content: - 'application/json': - schema: - $ref: '#/components/schemas/AccountSettings' - responses: - '200': - description: An Account object - content: - application/json: - schema: - $ref: '#/components/schemas/Account' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - /api/users: - get: - summary: List all Users - description: Returns a list of all users - tags: [ Users ] - operationId: getUsers - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: query - name: service_user - schema: - type: boolean - description: Filters users and returns either regular users or service users - responses: - '200': - description: A JSON array of Users - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/User' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - post: - summary: Create a User - description: Creates a new service user or sends an invite to a regular user - tags: [ Users ] - operationId: createUser - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - requestBody: - description: User invite information - content: - 'application/json': - schema: - $ref: '#/components/schemas/UserCreateRequest' - responses: - '200': - description: A User object - content: - application/json: - schema: - $ref: '#/components/schemas/User' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - /api/users/{userId}: - put: - summary: Update a User - description: Update information about a User - tags: [ Users ] - operationId: updateUser - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: userId - required: true - schema: - type: string - description: The unique identifier of a user - requestBody: - description: User update - content: - 'application/json': - schema: - $ref: '#/components/schemas/UserRequest' - responses: - '200': - description: A User object - content: - application/json: - schema: - $ref: '#/components/schemas/User' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - delete: - summary: Delete a User - description: Delete a User - tags: [ Users ] - operationId: deleteUser - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: userId - required: true - schema: - type: string - description: The unique identifier of a user - responses: - '200': - description: Delete status code - content: { } - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - /api/users/{userId}/tokens: - get: - summary: List all Tokens - description: Returns a list of all tokens for a user - tags: [ Tokens ] - operationId: getTokens - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: userId - required: true - schema: - type: string - description: The unique identifier of a user - responses: - '200': - description: A JSON Array of PersonalAccessTokens - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/PersonalAccessToken' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - post: - summary: Create a Token - description: Create a new token for a user - tags: [ Tokens ] - operationId: createToken - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: userId - required: true - schema: - type: string - description: The unique identifier of a user - requestBody: - description: PersonalAccessToken create parameters - content: - application/json: - schema: - $ref: '#/components/schemas/PersonalAccessTokenRequest' - responses: - '200': - description: The token in plain text - content: - application/json: - schema: - $ref: '#/components/schemas/PersonalAccessTokenGenerated' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - /api/users/{userId}/tokens/{tokenId}: - get: - summary: Retrieve a Token - description: Returns a specific token for a user - tags: [ Tokens ] - operationId: getToken - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: userId - required: true - schema: - type: string - description: The unique identifier of a user - - in: path - name: tokenId - required: true - schema: - type: string - description: The unique identifier of a token - responses: - '200': - description: A PersonalAccessTokens Object - content: - application/json: - schema: - $ref: '#/components/schemas/PersonalAccessToken' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - delete: - summary: Delete a Token - description: Delete a token for a user - tags: [ Tokens ] - operationId: deleteToken - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: userId - required: true - schema: - type: string - description: The unique identifier of a user - - in: path - name: tokenId - required: true - schema: - type: string - description: The unique identifier of a token - responses: - '200': - description: Delete status code - content: { } - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - /api/peers: - get: - summary: List all Peers - description: Returns a list of all peers - tags: [ Peers ] - operationId: getPeers - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - responses: - '200': - description: A JSON Array of Peers - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Peer' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - /api/peers/{peerId}: - get: - summary: Retrieve a Peer - description: Get information about a peer - tags: [ Peers ] - operationId: getPeer - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: peerId - required: true - schema: - type: string - description: The unique identifier of a peer - responses: - '200': - description: A Peer object - content: - application/json: - schema: - $ref: '#/components/schemas/Peer' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - put: - summary: Update a Peer - description: Update information about a peer - tags: [ Peers ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: peerId - required: true - schema: - type: string - description: The unique identifier of a peer - requestBody: - description: update a peer - content: - 'application/json': - schema: - $ref: '#/components/schemas/PeerRequest' - responses: - '200': - description: A Peer object - content: - application/json: - schema: - $ref: '#/components/schemas/Peer' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - delete: - summary: Delete a Peer - description: Delete a peer - tags: [ Peers ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: peerId - required: true - schema: - type: string - description: The unique identifier of a peer - responses: - '200': - description: Delete status code - content: { } - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - /api/setup-keys: - get: - summary: List all Setup Keys - description: Returns a list of all Setup Keys - tags: [ Setup Keys ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - responses: - '200': - description: A JSON Array of Setup keys - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/SetupKey' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - post: - summary: Create a Setup Key - description: Creates a Setup Key - tags: [ Setup Keys ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - requestBody: - description: New Setup Key request - content: - 'application/json': - schema: - $ref: '#/components/schemas/SetupKeyRequest' - responses: - '200': - description: A Setup Keys Object - content: - application/json: - schema: - $ref: '#/components/schemas/SetupKey' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - /api/setup-keys/{keyId}: - get: - summary: Retrieve a Setup Key - description: Get information about a Setup Key - tags: [ Setup Keys ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: keyId - required: true - schema: - type: string - description: The unique identifier of a setup key - responses: - '200': - description: A Setup Key object - content: - application/json: - schema: - $ref: '#/components/schemas/SetupKey' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - put: - summary: Update a Setup Key - description: Update information about a Setup Key - tags: [ Setup Keys ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: keyId - required: true - schema: - type: string - description: The unique identifier of a setup key - requestBody: - description: update to Setup Key - content: - 'application/json': - schema: - $ref: '#/components/schemas/SetupKeyRequest' - responses: - '200': - description: A Setup Key object - content: - application/json: - schema: - $ref: '#/components/schemas/SetupKey' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - /api/groups: - get: - summary: List all Groups - description: Returns a list of all Groups - tags: [ Groups ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - responses: - '200': - description: A JSON Array of Groups - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Group' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - post: - summary: Create a Group - description: Creates a Group - tags: [ Groups ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - requestBody: - description: New Group request - content: - 'application/json': - schema: - $ref: '#/components/schemas/GroupRequest' - responses: - '200': - description: A Group Object - content: - application/json: - schema: - $ref: '#/components/schemas/Group' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - /api/groups/{groupId}: - get: - summary: Retrieve a Group - description: Get information about a Group - tags: [ Groups ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: groupId - required: true - schema: - type: string - description: The unique identifier of a group - responses: - '200': - description: A Group object - content: - application/json: - schema: - $ref: '#/components/schemas/Group' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - put: - summary: Update a Group - description: Update/Replace a Group - tags: [ Groups ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: groupId - required: true - schema: - type: string - description: The unique identifier of a group - requestBody: - description: Update Group request - content: - 'application/json': - schema: - $ref: '#/components/schemas/GroupRequest' - responses: - '200': - description: A Group object - content: - application/json: - schema: - $ref: '#/components/schemas/Group' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - delete: - summary: Delete a Group - description: Delete a Group - tags: [ Groups ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: groupId - required: true - schema: - type: string - description: The unique identifier of a group - responses: - '200': - description: Delete status code - content: { } - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - /api/rules: - get: - summary: List all Rules - description: Returns a list of all Rules - tags: [ Rules ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - responses: - '200': - description: A JSON Array of Rules - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Rule' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - post: - summary: Create a Rule - description: Creates a Rule - tags: [ Rules ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - requestBody: - description: New Rule request - content: - 'application/json': - schema: - $ref: '#/components/schemas/RuleRequest' - responses: - '200': - description: A Rule Object - content: - application/json: - schema: - $ref: '#/components/schemas/Rule' - /api/rules/{ruleId}: - get: - summary: Retrieve a Rule - description: Get information about a Rules - tags: [ Rules ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: ruleId - required: true - schema: - type: string - description: The unique identifier of a rule - responses: - '200': - description: A Rule object - content: - application/json: - schema: - $ref: '#/components/schemas/Rule' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - put: - summary: Update a Rule - description: Update/Replace a Rule - tags: [ Rules ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: ruleId - required: true - schema: - type: string - description: The unique identifier of a rule - requestBody: - description: Update Rule request - content: - 'application/json': - schema: - $ref: '#/components/schemas/RuleRequest' - responses: - '200': - description: A Rule object - content: - application/json: - schema: - $ref: '#/components/schemas/Rule' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - delete: - summary: Delete a Rule - description: Delete a Rule - tags: [ Rules ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: ruleId - required: true - schema: - type: string - description: The unique identifier of a rule - responses: - '200': - description: Delete status code - content: { } - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - /api/policies: - get: - summary: List all Policies - description: Returns a list of all Policies - tags: [ Policies ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - responses: - '200': - description: A JSON Array of Policies - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Policy' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - post: - summary: Create a Policy - description: Creates a Policy - tags: [ Policies ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - requestBody: - description: New Policy request - content: - 'application/json': - schema: - $ref: '#/components/schemas/PolicyMinimum' - responses: - '200': - description: A Policy Object - content: - application/json: - schema: - $ref: '#/components/schemas/Policy' - /api/policies/{policyId}: - get: - summary: Retrieve a Policy - description: Get information about a Policies - tags: [ Policies ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: policyId - required: true - schema: - type: string - description: The unique identifier of a policy - responses: - '200': - description: A Policy object - content: - application/json: - schema: - $ref: '#/components/schemas/Policy' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - put: - summary: Update a Policy - description: Update/Replace a Policy - tags: [ Policies ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: policyId - required: true - schema: - type: string - description: The unique identifier of a policy - requestBody: - description: Update Policy request - content: - 'application/json': - schema: - $ref: '#/components/schemas/PolicyMinimum' - responses: - '200': - description: A Policy object - content: - application/json: - schema: - $ref: '#/components/schemas/Policy' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - delete: - summary: Delete a Policy - description: Delete a Policy - tags: [ Policies ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: policyId - required: true - schema: - type: string - description: The unique identifier of a policy - responses: - '200': - description: Delete status code - content: { } - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - /api/routes: - get: - summary: List all Routes - description: Returns a list of all routes - tags: [ Routes ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - responses: - '200': - description: A JSON Array of Routes - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Route' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - post: - summary: Create a Route - description: Creates a Route - tags: [ Routes ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - requestBody: - description: New Routes request - content: - 'application/json': - schema: - $ref: '#/components/schemas/RouteRequest' - responses: - '200': - description: A Route Object - content: - application/json: - schema: - $ref: '#/components/schemas/Route' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - - /api/routes/{routeId}: - get: - summary: Retrieve a Route - description: Get information about a Routes - tags: [ Routes ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: routeId - required: true - schema: - type: string - description: The unique identifier of a route - responses: - '200': - description: A Route object - content: - application/json: - schema: - $ref: '#/components/schemas/Route' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - put: - summary: Update a Route - description: Update/Replace a Route - tags: [ Routes ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: routeId - required: true - schema: - type: string - description: The unique identifier of a route - requestBody: - description: Update Route request - content: - application/json: - schema: - $ref: '#/components/schemas/RouteRequest' - responses: - '200': - description: A Route object - content: - application/json: - schema: - $ref: '#/components/schemas/Route' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - delete: - summary: Delete a Route - description: Delete a Route - tags: [ Routes ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: routeId - required: true - schema: - type: string - description: The unique identifier of a route - responses: - '200': - description: Delete status code - content: { } - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - /api/dns/nameservers: - get: - summary: List all Nameserver Groups - description: Returns a list of all Nameserver Groups - tags: [ DNS ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - responses: - '200': - description: A JSON Array of Nameserver Groups - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/NameserverGroup' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - post: - summary: Create a Nameserver Group - description: Creates a Nameserver Group - tags: [ DNS ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - requestBody: - description: New Nameserver Groups request - content: - 'application/json': - schema: - $ref: '#/components/schemas/NameserverGroupRequest' - responses: - '200': - description: A Nameserver Groups Object - content: - application/json: - schema: - $ref: '#/components/schemas/NameserverGroup' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - /api/dns/nameservers/{nsgroupId}: - get: - summary: Retrieve a Nameserver Group - description: Get information about a Nameserver Groups - tags: [ DNS ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: nsgroupId - required: true - schema: - type: string - description: The unique identifier of a Nameserver Group - responses: - '200': - description: A Nameserver Group object - content: - application/json: - schema: - $ref: '#/components/schemas/NameserverGroup' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - put: - summary: Update a Nameserver Group - description: Update/Replace a Nameserver Group - tags: [ DNS ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: nsgroupId - required: true - schema: - type: string - description: The unique identifier of a Nameserver Group - requestBody: - description: Update Nameserver Group request - content: - application/json: - schema: - $ref: '#/components/schemas/NameserverGroupRequest' - responses: - '200': - description: A Nameserver Group object - content: - application/json: - schema: - $ref: '#/components/schemas/NameserverGroup' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - delete: - summary: Delete a Nameserver Group - description: Delete a Nameserver Group - tags: [ DNS ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - parameters: - - in: path - name: nsgroupId - required: true - schema: - type: string - description: The unique identifier of a Nameserver Group - responses: - '200': - description: Delete status code - content: { } - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - /api/dns/settings: - get: - summary: Retrieve DNS Settings - description: Returns a DNS settings object - tags: [ DNS ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - responses: - '200': - description: A JSON Object of DNS Setting - content: - application/json: - schema: - items: - $ref: '#/components/schemas/DNSSettings' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - put: - summary: Update DNS Settings - description: Updates a DNS settings object - tags: [ DNS ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - requestBody: - description: A DNS settings object - content: - 'application/json': - schema: - $ref: '#/components/schemas/DNSSettings' - responses: - '200': - description: A JSON Object of DNS Setting - content: - application/json: - schema: - $ref: '#/components/schemas/DNSSettings' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" - /api/events: - get: - summary: List all Events - description: Returns a list of all events - tags: [ Events ] - security: - - BearerAuth: [ ] - - TokenAuth: [ ] - responses: - '200': - description: A JSON Array of Events - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Event' - '400': - "$ref": "#/components/responses/bad_request" - '401': - "$ref": "#/components/responses/requires_authentication" - '403': - "$ref": "#/components/responses/forbidden" - '500': - "$ref": "#/components/responses/internal_error" diff --git a/package.json b/package.json index 18c5b3ea..6df53217 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/src/pages/ipa/resources/accounts.mdx b/src/pages/ipa/resources/accounts.mdx index 7accbe63..be0f519e 100644 --- a/src/pages/ipa/resources/accounts.mdx +++ b/src/pages/ipa/resources/accounts.mdx @@ -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 ' \ --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 " 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', diff --git a/src/pages/ipa/resources/dns.mdx b/src/pages/ipa/resources/dns.mdx index 0976c5f8..e8ea29a4 100644 --- a/src/pages/ipa/resources/dns.mdx +++ b/src/pages/ipa/resources/dns.mdx @@ -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' }} diff --git a/src/pages/ipa/resources/events.mdx b/src/pages/ipa/resources/events.mdx index feb88055..d2ae0cd3 100644 --- a/src/pages/ipa/resources/events.mdx +++ b/src/pages/ipa/resources/events.mdx @@ -1,4 +1,3 @@ - export const title = 'Events' diff --git a/src/pages/ipa/resources/groups.mdx b/src/pages/ipa/resources/groups.mdx index d4fa4902..6f9e5f2c 100644 --- a/src/pages/ipa/resources/groups.mdx +++ b/src/pages/ipa/resources/groups.mdx @@ -1,4 +1,3 @@ - export const title = 'Groups' @@ -7,7 +6,7 @@ export const title = 'Groups' - Returns a list of all Groups + Returns a list of all groups @@ -207,7 +206,7 @@ echo $response; - Creates a Group + Creates a group #### Request-Body Parameters @@ -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 " 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; - Get information about a Group + Get information about a group #### Path Parameters @@ -673,7 +672,7 @@ echo $response; - Update/Replace a Group + Update/Replace a group #### Path Parameters @@ -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 " 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; - Delete a Group + Delete a group #### Path Parameters diff --git a/src/pages/ipa/resources/peers.mdx b/src/pages/ipa/resources/peers.mdx index a48aa303..4e3458e9 100644 --- a/src/pages/ipa/resources/peers.mdx +++ b/src/pages/ipa/resources/peers.mdx @@ -1,4 +1,3 @@ - export const title = 'Peers' diff --git a/src/pages/ipa/resources/policies.mdx b/src/pages/ipa/resources/policies.mdx index 24db1374..3471c268 100644 --- a/src/pages/ipa/resources/policies.mdx +++ b/src/pages/ipa/resources/policies.mdx @@ -1,4 +1,3 @@ - export const title = 'Policies' @@ -7,7 +6,7 @@ export const title = 'Policies' - Returns a list of all Policies + Returns a list of all policies @@ -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; - Creates a Policy + Creates a policy #### Request-Body Parameters + + Policy ID + + - @@ -295,31 +311,29 @@ curl -X POST https://api.netbird.io/api/policies \ -H 'Content-Type: application/json' \ -H 'Authorization: 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 " 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; ```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" + ] } ``` @@ -887,16 +899,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", @@ -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" + ] } ``` @@ -978,6 +1000,13 @@ echo $response; #### Request-Body Parameters + + Policy ID + + - @@ -1023,31 +1052,29 @@ curl -X PUT https://api.netbird.io/api/policies/{policyId} \ -H 'Content-Type: application/json' \ -H 'Authorization: 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 " 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; ```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" + ] } ``` @@ -1455,7 +1480,7 @@ echo $response; - Delete a Policy + Delete a policy #### Path Parameters diff --git a/src/pages/ipa/resources/routes.mdx b/src/pages/ipa/resources/routes.mdx index e032eb84..477bdbed 100644 --- a/src/pages/ipa/resources/routes.mdx +++ b/src/pages/ipa/resources/routes.mdx @@ -1,4 +1,3 @@ - export const title = 'Routes' @@ -1151,7 +1150,7 @@ echo $response; - Delete a Route + Delete a route #### Path Parameters diff --git a/src/pages/ipa/resources/rules.mdx b/src/pages/ipa/resources/rules.mdx index b18b59cc..4896e594 100644 --- a/src/pages/ipa/resources/rules.mdx +++ b/src/pages/ipa/resources/rules.mdx @@ -1,4 +1,3 @@ - export const title = 'Rules' @@ -7,7 +6,7 @@ export const title = 'Rules' - Returns a list of all Rules + Returns a list of all rules @@ -227,7 +226,7 @@ echo $response; - Creates a Rule + Creates a rule #### Request-Body Parameters @@ -575,7 +574,7 @@ echo $response; - Get information about a Rules + Get information about a rules #### Path Parameters @@ -799,7 +798,7 @@ echo $response; - Update/Replace a Rule + Update/Replace a rule #### Path Parameters @@ -1159,7 +1158,7 @@ echo $response; - Delete a Rule + Delete a rule #### Path Parameters diff --git a/src/pages/ipa/resources/setup-keys.mdx b/src/pages/ipa/resources/setup-keys.mdx index 2f0b08ae..1b86aaa8 100644 --- a/src/pages/ipa/resources/setup-keys.mdx +++ b/src/pages/ipa/resources/setup-keys.mdx @@ -1,4 +1,3 @@ - export const title = 'Setup Keys' @@ -219,7 +218,7 @@ echo $response; - Creates a Setup Key + Creates a setup key #### Request-Body Parameters @@ -549,7 +548,7 @@ echo $response; - Get information about a Setup Key + Get information about a setup key #### Path Parameters @@ -765,7 +764,7 @@ echo $response; - Update information about a Setup Key + Update information about a setup key #### Path Parameters diff --git a/src/pages/ipa/resources/tokens.mdx b/src/pages/ipa/resources/tokens.mdx index 2b5b6ac4..9a13fab8 100644 --- a/src/pages/ipa/resources/tokens.mdx +++ b/src/pages/ipa/resources/tokens.mdx @@ -1,4 +1,3 @@ - export const title = 'Tokens' diff --git a/src/pages/ipa/resources/users.mdx b/src/pages/ipa/resources/users.mdx index 0f46d1b8..a5b93790 100644 --- a/src/pages/ipa/resources/users.mdx +++ b/src/pages/ipa/resources/users.mdx @@ -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" } ``` @@ -548,6 +551,13 @@ echo $response; > Groups to auto-assign to peers registered by this user + + + + If set to true then user is blocked and can't use the system @@ -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" } ``` @@ -795,7 +814,7 @@ echo $response; - Delete a User + Delete a user #### Path Parameters