Update api generation workflow (#190)

This commit is contained in:
pascal-fischer
2024-05-15 21:47:49 +02:00
committed by GitHub
parent 94780de0f2
commit 503696de09
14 changed files with 143 additions and 96 deletions

View File

@@ -19,42 +19,48 @@ jobs:
input_string: ${{ github.event.inputs.tag }}
version_extractor_regex: '\/v(.*)$'
# - uses: actions/checkout@v2
# with:
# token: ${{ secrets.DEV_GITHUB_TOKEN }}
#
# - name: Install swagger-codegen
# run: brew install swagger-codegen
#
# - name: Set up JDK 11
# uses: actions/setup-java@v2
# with:
# java-version: '11'
# distribution: 'adopt'
#
# - name: Npm install
# run: npm install
#
# - name: Generate api pages for netbird main openapi definition
# run: |
# swagger-codegen generate -i https://raw.githubusercontent.com/netbirdio/netbird/v${{ steps.semver_parser.outputs.fullversion }}/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
#
# - name: Check git diff and send to output
# id: git_diff
# run: |
# if git --no-pager diff --exit-code; then
# echo "changed=false" >> "$GITHUB_OUTPUT"
# else
# echo "changed=true" >> "$GITHUB_OUTPUT"
# fi
#
# - name: Commit and push changes
# if: steps.git_diff.outputs.changed == 'true'
# run: |
# git config --global user.email "dev@netbird.io"
# git config --global user.name "netbirddev"
#
# git add -A
# git commit -m "Update API pages with v${{ steps.semver_parser.outputs.fullversion }}"
# git push
- uses: actions/checkout@v2
with:
token: ${{ secrets.DEV_GITHUB_TOKEN }}
- name: Create directory
run: mkdir -p generator/openapi
- name: Download openapi.yml
run: curl -L -o generator/openapi/openapi.yml "https://raw.githubusercontent.com/netbirdio/netbird/v${{ steps.semver_parser.outputs.fullversion }}/management/server/http/api/openapi.yml"
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: '1.21.1'
- name: Build Go project
run: (cd ./generator && go build -o expandOpenAPIRef)
- name: Expand openapi.yml
run: (cd ./generator && ./expandOpenAPIRef)
- name: Npm install
run: npm install
- name: Generate api pages for netbird main openapi definition
run: npx ts-node generator/index.ts gen --input generator/openapi/expanded.yml --output src/pages/ipa/resources
- name: Check git diff and send to output
id: git_diff
run: |
if git --no-pager diff --exit-code; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Commit and push changes
if: steps.git_diff.outputs.changed == 'true'
run: |
git config --global user.email "dev@netbird.io"
git config --global user.name "netbirddev"
git add -A
git commit -m "Update API pages with v${{ steps.semver_parser.outputs.fullversion }}"
git push

1
.gitignore vendored
View File

@@ -26,3 +26,4 @@ package-lock.json
/yarn.lock
/generator/openapi/
/generator/openapi.yml
/generator/expandOpenAPIRef

View File

@@ -45,7 +45,7 @@ import json
url = "https://api.netbird.io/api/accounts"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
@@ -166,6 +166,7 @@ echo $response;
"settings": {
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200,
"regular_users_view_blocked": true,
"groups_propagation_enabled": true,
"jwt_groups_enabled": true,
"jwt_groups_claim_name": "roles",
@@ -186,6 +187,7 @@ echo $response;
"settings": {
"peer_login_expiration_enabled": "boolean",
"peer_login_expiration": "integer",
"regular_users_view_blocked": "boolean",
"groups_propagation_enabled": "boolean",
"jwt_groups_enabled": "boolean",
"jwt_groups_claim_name": "string",
@@ -212,7 +214,7 @@ echo $response;
<Row>
<Col>
Deletes an account and all its resources. Only administrators and account owners can delete accounts.
Deletes an account and all its resources. Only account owners can delete accounts.
#### Path Parameters
<Properties>
@@ -257,7 +259,7 @@ import json
url = "https://api.netbird.io/api/accounts/{accountId}"
headers: {
headers = {
'Authorization': 'Token <TOKEN>'
}
@@ -403,6 +405,11 @@ echo $response;
Period of time after which peer login expires (seconds).
</Property>
<Property name="regular_users_view_blocked" type="boolean" required={true}>
Allows blocking regular users from viewing parts of the system.
</Property>
<Property name="groups_propagation_enabled" type="boolean" required={false}>
@@ -463,6 +470,7 @@ curl -X PUT https://api.netbird.io/api/accounts/{accountId} \
"settings": {
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200,
"regular_users_view_blocked": true,
"groups_propagation_enabled": true,
"jwt_groups_enabled": true,
"jwt_groups_claim_name": "roles",
@@ -482,6 +490,7 @@ let data = JSON.stringify({
"settings": {
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200,
"regular_users_view_blocked": true,
"groups_propagation_enabled": true,
"jwt_groups_enabled": true,
"jwt_groups_claim_name": "roles",
@@ -523,6 +532,7 @@ payload = json.dumps({
"settings": {
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200,
"regular_users_view_blocked": true,
"groups_propagation_enabled": true,
"jwt_groups_enabled": true,
"jwt_groups_claim_name": "roles",
@@ -534,7 +544,7 @@ payload = json.dumps({
}
}
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
@@ -564,6 +574,7 @@ func main() {
"settings": {
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200,
"regular_users_view_blocked": true,
"groups_propagation_enabled": true,
"jwt_groups_enabled": true,
"jwt_groups_claim_name": "roles",
@@ -623,6 +634,7 @@ request.body = JSON.dump({
"settings": {
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200,
"regular_users_view_blocked": true,
"groups_propagation_enabled": true,
"jwt_groups_enabled": true,
"jwt_groups_claim_name": "roles",
@@ -646,6 +658,7 @@ RequestBody body = RequestBody.create(mediaType, '{
"settings": {
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200,
"regular_users_view_blocked": true,
"groups_propagation_enabled": true,
"jwt_groups_enabled": true,
"jwt_groups_claim_name": "roles",
@@ -685,6 +698,7 @@ curl_setopt_array($curl, array(
"settings": {
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200,
"regular_users_view_blocked": true,
"groups_propagation_enabled": true,
"jwt_groups_enabled": true,
"jwt_groups_claim_name": "roles",
@@ -719,6 +733,7 @@ echo $response;
"settings": {
"peer_login_expiration_enabled": true,
"peer_login_expiration": 43200,
"regular_users_view_blocked": true,
"groups_propagation_enabled": true,
"jwt_groups_enabled": true,
"jwt_groups_claim_name": "roles",
@@ -737,6 +752,7 @@ echo $response;
"settings": {
"peer_login_expiration_enabled": "boolean",
"peer_login_expiration": "integer",
"regular_users_view_blocked": "boolean",
"groups_propagation_enabled": "boolean",
"jwt_groups_enabled": "boolean",
"jwt_groups_claim_name": "string",

View File

@@ -45,7 +45,7 @@ import json
url = "https://api.netbird.io/api/dns/nameservers"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
@@ -390,7 +390,7 @@ payload = json.dumps({
],
"search_domains_enabled": true
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
@@ -695,7 +695,7 @@ import json
url = "https://api.netbird.io/api/dns/nameservers/{nsgroupId}"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
@@ -1044,7 +1044,7 @@ payload = json.dumps({
],
"search_domains_enabled": true
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
@@ -1347,7 +1347,7 @@ import json
url = "https://api.netbird.io/api/dns/nameservers/{nsgroupId}"
headers: {
headers = {
'Authorization': 'Token <TOKEN>'
}
@@ -1505,7 +1505,7 @@ import json
url = "https://api.netbird.io/api/dns/settings"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
@@ -1716,7 +1716,7 @@ payload = json.dumps({
"ch8i4ug6lnn4g9hqv7m0"
]
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'

View File

@@ -45,7 +45,7 @@ import json
url = "https://api.netbird.io/api/events"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}

View File

@@ -45,7 +45,7 @@ import json
url = "https://api.netbird.io/api/locations/countries"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
@@ -229,7 +229,7 @@ import json
url = "https://api.netbird.io/api/locations/countries/{country}/cities"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}

View File

@@ -45,7 +45,7 @@ import json
url = "https://api.netbird.io/api/groups"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
@@ -278,7 +278,7 @@ payload = json.dumps({
"ch8i4ug6lnn4g9hqv7m1"
]
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
@@ -509,7 +509,7 @@ import json
url = "https://api.netbird.io/api/groups/{groupId}"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
@@ -746,7 +746,7 @@ payload = json.dumps({
"ch8i4ug6lnn4g9hqv7m1"
]
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
@@ -975,7 +975,7 @@ import json
url = "https://api.netbird.io/api/groups/{groupId}"
headers: {
headers = {
'Authorization': 'Token <TOKEN>'
}

View File

@@ -45,7 +45,7 @@ import json
url = "https://api.netbird.io/api/peers"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
@@ -191,6 +191,7 @@ echo $response;
"approval_required": true,
"country_code": "DE",
"city_name": "Berlin",
"serial_number": "C02XJ0J0JGH7",
"accessible_peers_count": 5
}
]
@@ -227,6 +228,7 @@ echo $response;
"approval_required": "boolean",
"country_code": "string",
"city_name": "string",
"serial_number": "string",
"accessible_peers_count": "integer"
}
]
@@ -291,7 +293,7 @@ import json
url = "https://api.netbird.io/api/peers/{peerId}"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
@@ -436,6 +438,7 @@ echo $response;
"approval_required": true,
"country_code": "DE",
"city_name": "Berlin",
"serial_number": "C02XJ0J0JGH7",
"accessible_peers": [
{
"id": "chacbco6lnnbn6cg5s90",
@@ -478,6 +481,7 @@ echo $response;
"approval_required": "boolean",
"country_code": "string",
"city_name": "string",
"serial_number": "string",
"accessible_peers": [
{
"id": "string",
@@ -594,7 +598,7 @@ payload = json.dumps({
"login_expiration_enabled": false,
"approval_required": true
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
@@ -768,6 +772,7 @@ echo $response;
"approval_required": true,
"country_code": "DE",
"city_name": "Berlin",
"serial_number": "C02XJ0J0JGH7",
"accessible_peers": [
{
"id": "chacbco6lnnbn6cg5s90",
@@ -810,6 +815,7 @@ echo $response;
"approval_required": "boolean",
"country_code": "string",
"city_name": "string",
"serial_number": "string",
"accessible_peers": [
{
"id": "string",
@@ -879,7 +885,7 @@ import json
url = "https://api.netbird.io/api/peers/{peerId}"
headers: {
headers = {
'Authorization': 'Token <TOKEN>'
}

View File

@@ -45,7 +45,7 @@ import json
url = "https://api.netbird.io/api/policies"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
@@ -478,7 +478,7 @@ payload = json.dumps({
}
]
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
@@ -855,7 +855,7 @@ import json
url = "https://api.netbird.io/api/policies/{policyId}"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
@@ -1292,7 +1292,7 @@ payload = json.dumps({
}
]
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
@@ -1667,7 +1667,7 @@ import json
url = "https://api.netbird.io/api/policies/{policyId}"
headers: {
headers = {
'Authorization': 'Token <TOKEN>'
}

View File

@@ -45,7 +45,7 @@ import json
url = "https://api.netbird.io/api/posture-checks"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
@@ -646,7 +646,7 @@ payload = json.dumps({
}
}
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
@@ -1097,7 +1097,7 @@ import json
url = "https://api.netbird.io/api/posture-checks/{postureCheckId}"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
@@ -1702,7 +1702,7 @@ payload = json.dumps({
}
}
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
@@ -2151,7 +2151,7 @@ import json
url = "https://api.netbird.io/api/posture-checks/{postureCheckId}"
headers: {
headers = {
'Authorization': 'Token <TOKEN>'
}

View File

@@ -45,7 +45,7 @@ import json
url = "https://api.netbird.io/api/routes"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
@@ -350,7 +350,7 @@ payload = json.dumps({
"chacdk86lnnboviihd70"
]
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
@@ -627,7 +627,7 @@ import json
url = "https://api.netbird.io/api/routes/{routeId}"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
@@ -936,7 +936,7 @@ payload = json.dumps({
"chacdk86lnnboviihd70"
]
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
@@ -1211,7 +1211,7 @@ import json
url = "https://api.netbird.io/api/routes/{routeId}"
headers: {
headers = {
'Authorization': 'Token <TOKEN>'
}

View File

@@ -45,7 +45,7 @@ import json
url = "https://api.netbird.io/api/setup-keys"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
@@ -330,7 +330,7 @@ payload = json.dumps({
"usage_limit": 0,
"ephemeral": true
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
@@ -593,7 +593,7 @@ import json
url = "https://api.netbird.io/api/setup-keys/{keyId}"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
@@ -882,7 +882,7 @@ payload = json.dumps({
"usage_limit": 0,
"ephemeral": true
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'

View File

@@ -53,7 +53,7 @@ import json
url = "https://api.netbird.io/api/users/{userId}/tokens"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
@@ -280,7 +280,7 @@ payload = json.dumps({
"name": "My first token",
"expires_in": 30
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
@@ -505,7 +505,7 @@ import json
url = "https://api.netbird.io/api/users/{userId}/tokens/{tokenId}"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
@@ -701,7 +701,7 @@ import json
url = "https://api.netbird.io/api/users/{userId}/tokens/{tokenId}"
headers: {
headers = {
'Authorization': 'Token <TOKEN>'
}

View File

@@ -53,7 +53,7 @@ import json
url = "https://api.netbird.io/api/users"
headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
@@ -182,7 +182,10 @@ echo $response;
"is_current": true,
"is_service_user": false,
"is_blocked": false,
"issued": "api"
"issued": "api",
"permissions": {
"dashboard_view": "limited"
}
}
]
```
@@ -201,7 +204,10 @@ echo $response;
"is_current": "boolean",
"is_service_user": "boolean",
"is_blocked": "boolean",
"issued": "string"
"issued": "string",
"permissions": {
"dashboard_view": "string"
}
}
]
```
@@ -316,7 +322,7 @@ payload = json.dumps({
],
"is_service_user": false
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
@@ -485,7 +491,10 @@ echo $response;
"is_current": true,
"is_service_user": false,
"is_blocked": false,
"issued": "api"
"issued": "api",
"permissions": {
"dashboard_view": "limited"
}
}
```
```json {{ title: 'Schema' }}
@@ -502,7 +511,10 @@ echo $response;
"is_current": "boolean",
"is_service_user": "boolean",
"is_blocked": "boolean",
"issued": "string"
"issued": "string",
"permissions": {
"dashboard_view": "string"
}
}
```
</CodeGroup>
@@ -608,7 +620,7 @@ payload = json.dumps({
],
"is_blocked": false
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
@@ -769,7 +781,10 @@ echo $response;
"is_current": true,
"is_service_user": false,
"is_blocked": false,
"issued": "api"
"issued": "api",
"permissions": {
"dashboard_view": "limited"
}
}
```
```json {{ title: 'Schema' }}
@@ -786,7 +801,10 @@ echo $response;
"is_current": "boolean",
"is_service_user": "boolean",
"is_blocked": "boolean",
"issued": "string"
"issued": "string",
"permissions": {
"dashboard_view": "string"
}
}
```
</CodeGroup>
@@ -847,7 +865,7 @@ import json
url = "https://api.netbird.io/api/users/{userId}"
headers: {
headers = {
'Authorization': 'Token <TOKEN>'
}
@@ -1011,7 +1029,7 @@ import json
url = "https://api.netbird.io/api/users/{userId}/invite"
headers: {
headers = {
'Authorization': 'Token <TOKEN>'
}