Skip to content

Commit

Permalink
Update api generation workflow (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
pascal-fischer authored May 15, 2024
1 parent 94780de commit 503696d
Show file tree
Hide file tree
Showing 14 changed files with 143 additions and 96 deletions.
84 changes: 45 additions & 39 deletions .github/workflows/generate_api_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "[email protected]"
# 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 "[email protected]"
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 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ package-lock.json
/yarn.lock
/generator/openapi/
/generator/openapi.yml
/generator/expandOpenAPIRef
24 changes: 20 additions & 4 deletions src/pages/ipa/resources/accounts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import json

url = "https://api.netbird.io/api/accounts"

headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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>
Expand Down Expand Up @@ -257,7 +259,7 @@ import json

url = "https://api.netbird.io/api/accounts/{accountId}"

headers: {
headers = {
'Authorization': 'Token <TOKEN>'
}

Expand Down Expand Up @@ -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}>
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -534,7 +544,7 @@ payload = json.dumps({
}
}
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
14 changes: 7 additions & 7 deletions src/pages/ipa/resources/dns.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import json

url = "https://api.netbird.io/api/dns/nameservers"

headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
Expand Down Expand Up @@ -390,7 +390,7 @@ payload = json.dumps({
],
"search_domains_enabled": true
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
Expand Down Expand Up @@ -695,7 +695,7 @@ import json

url = "https://api.netbird.io/api/dns/nameservers/{nsgroupId}"

headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
Expand Down Expand Up @@ -1044,7 +1044,7 @@ payload = json.dumps({
],
"search_domains_enabled": true
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
Expand Down Expand Up @@ -1347,7 +1347,7 @@ import json

url = "https://api.netbird.io/api/dns/nameservers/{nsgroupId}"

headers: {
headers = {
'Authorization': 'Token <TOKEN>'
}

Expand Down Expand Up @@ -1505,7 +1505,7 @@ import json

url = "https://api.netbird.io/api/dns/settings"

headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
Expand Down Expand Up @@ -1716,7 +1716,7 @@ payload = json.dumps({
"ch8i4ug6lnn4g9hqv7m0"
]
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ipa/resources/events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import json

url = "https://api.netbird.io/api/events"

headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/ipa/resources/geo-locations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import json

url = "https://api.netbird.io/api/locations/countries"

headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
Expand Down Expand Up @@ -229,7 +229,7 @@ import json

url = "https://api.netbird.io/api/locations/countries/{country}/cities"

headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
Expand Down
10 changes: 5 additions & 5 deletions src/pages/ipa/resources/groups.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import json

url = "https://api.netbird.io/api/groups"

headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
Expand Down Expand Up @@ -278,7 +278,7 @@ payload = json.dumps({
"ch8i4ug6lnn4g9hqv7m1"
]
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
Expand Down Expand Up @@ -509,7 +509,7 @@ import json

url = "https://api.netbird.io/api/groups/{groupId}"

headers: {
headers = {
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
}
Expand Down Expand Up @@ -746,7 +746,7 @@ payload = json.dumps({
"ch8i4ug6lnn4g9hqv7m1"
]
})
headers: {
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Token <TOKEN>'
Expand Down Expand Up @@ -975,7 +975,7 @@ import json

url = "https://api.netbird.io/api/groups/{groupId}"

headers: {
headers = {
'Authorization': 'Token <TOKEN>'
}

Expand Down
Loading

0 comments on commit 503696d

Please sign in to comment.