root: generate python client (#9107)
* generate api client Signed-off-by: Jens Langhammer <jens@goauthentik.io> # Conflicts: # authentik/lib/expression/evaluator.py # poetry.lock * don't attempt to pr upgrade api client Signed-off-by: Jens Langhammer <jens@goauthentik.io> # Conflicts: # poetry.lock # pyproject.toml * use new generator Signed-off-by: Jens Langhammer <jens@goauthentik.io> * t Signed-off-by: Jens Langhammer <jens@goauthentik.io> * use upstream generator since that one is v2 already 🤦 Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add missing help to makefile Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
58
.github/workflows/api-py-publish.yml
vendored
Normal file
58
.github/workflows/api-py-publish.yml
vendored
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
name: authentik-api-py-publish
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
paths:
|
||||||
|
- "schema.yml"
|
||||||
|
workflow_dispatch:
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
id-token: write
|
||||||
|
steps:
|
||||||
|
- id: generate_token
|
||||||
|
uses: tibdex/github-app-token@v2
|
||||||
|
with:
|
||||||
|
app_id: ${{ secrets.GH_APP_ID }}
|
||||||
|
private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ steps.generate_token.outputs.token }}
|
||||||
|
- uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version-file: "pyproject.toml"
|
||||||
|
cache: "poetry"
|
||||||
|
- name: Generate API Client
|
||||||
|
run: make gen-client-py
|
||||||
|
- name: Publish package
|
||||||
|
working-directory: gen-py-api/
|
||||||
|
run: |
|
||||||
|
poetry build
|
||||||
|
- name: Publish package to PyPI
|
||||||
|
uses: pypa/gh-action-pypi-publish@release/v1
|
||||||
|
with:
|
||||||
|
packages-dir: gen-py-api/dist/
|
||||||
|
# We can't easily upgrade the API client being used due to poetry being poetry
|
||||||
|
# so we'll have to rely on dependabot
|
||||||
|
# - name: Upgrade /
|
||||||
|
# run: |
|
||||||
|
# export VERSION=$(cd gen-py-api && poetry version -s)
|
||||||
|
# poetry add "authentik_client=$VERSION" --allow-prereleases --lock
|
||||||
|
# - uses: peter-evans/create-pull-request@v6
|
||||||
|
# id: cpr
|
||||||
|
# with:
|
||||||
|
# token: ${{ steps.generate_token.outputs.token }}
|
||||||
|
# branch: update-root-api-client
|
||||||
|
# commit-message: "root: bump API Client version"
|
||||||
|
# title: "root: bump API Client version"
|
||||||
|
# body: "root: bump API Client version"
|
||||||
|
# delete-branch: true
|
||||||
|
# signoff: true
|
||||||
|
# # ID from https://api.github.com/users/authentik-automation[bot]
|
||||||
|
# author: authentik-automation[bot] <135050075+authentik-automation[bot]@users.noreply.github.com>
|
||||||
|
# - uses: peter-evans/enable-pull-request-automerge@v3
|
||||||
|
# with:
|
||||||
|
# token: ${{ steps.generate_token.outputs.token }}
|
||||||
|
# pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
|
||||||
|
# merge-method: squash
|
@ -1,4 +1,4 @@
|
|||||||
name: authentik-web-api-publish
|
name: authentik-api-ts-publish
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
20
Makefile
20
Makefile
@ -9,6 +9,7 @@ PY_SOURCES = authentik tests scripts lifecycle .github
|
|||||||
DOCKER_IMAGE ?= "authentik:test"
|
DOCKER_IMAGE ?= "authentik:test"
|
||||||
|
|
||||||
GEN_API_TS = "gen-ts-api"
|
GEN_API_TS = "gen-ts-api"
|
||||||
|
GEN_API_PY = "gen-py-api"
|
||||||
GEN_API_GO = "gen-go-api"
|
GEN_API_GO = "gen-go-api"
|
||||||
|
|
||||||
pg_user := $(shell python -m authentik.lib.config postgresql.user 2>/dev/null)
|
pg_user := $(shell python -m authentik.lib.config postgresql.user 2>/dev/null)
|
||||||
@ -137,7 +138,10 @@ gen-clean-ts: ## Remove generated API client for Typescript
|
|||||||
gen-clean-go: ## Remove generated API client for Go
|
gen-clean-go: ## Remove generated API client for Go
|
||||||
rm -rf ./${GEN_API_GO}/
|
rm -rf ./${GEN_API_GO}/
|
||||||
|
|
||||||
gen-clean: gen-clean-ts gen-clean-go ## Remove generated API clients
|
gen-clean-py: ## Remove generated API client for Python
|
||||||
|
rm -rf ./${GEN_API_PY}/
|
||||||
|
|
||||||
|
gen-clean: gen-clean-ts gen-clean-go gen-clean-py ## Remove generated API clients
|
||||||
|
|
||||||
gen-client-ts: gen-clean-ts ## Build and install the authentik API for Typescript into the authentik UI Application
|
gen-client-ts: gen-clean-ts ## Build and install the authentik API for Typescript into the authentik UI Application
|
||||||
docker run \
|
docker run \
|
||||||
@ -155,6 +159,20 @@ gen-client-ts: gen-clean-ts ## Build and install the authentik API for Typescri
|
|||||||
cd ./${GEN_API_TS} && npm i
|
cd ./${GEN_API_TS} && npm i
|
||||||
\cp -rf ./${GEN_API_TS}/* web/node_modules/@goauthentik/api
|
\cp -rf ./${GEN_API_TS}/* web/node_modules/@goauthentik/api
|
||||||
|
|
||||||
|
gen-client-py: gen-clean-py ## Build and install the authentik API for Python
|
||||||
|
docker run \
|
||||||
|
--rm -v ${PWD}:/local \
|
||||||
|
--user ${UID}:${GID} \
|
||||||
|
docker.io/openapitools/openapi-generator-cli:v7.4.0 generate \
|
||||||
|
-i /local/schema.yml \
|
||||||
|
-g python \
|
||||||
|
-o /local/${GEN_API_PY} \
|
||||||
|
-c /local/scripts/api-py-config.yaml \
|
||||||
|
--additional-properties=packageVersion=${NPM_VERSION} \
|
||||||
|
--git-repo-id authentik \
|
||||||
|
--git-user-id goauthentik
|
||||||
|
pip install ./${GEN_API_PY}
|
||||||
|
|
||||||
gen-client-go: gen-clean-go ## Build and install the authentik API for Golang
|
gen-client-go: gen-clean-go ## Build and install the authentik API for Golang
|
||||||
mkdir -p ./${GEN_API_GO} ./${GEN_API_GO}/templates
|
mkdir -p ./${GEN_API_GO} ./${GEN_API_GO}/templates
|
||||||
wget https://raw.githubusercontent.com/goauthentik/client-go/main/config.yaml -O ./${GEN_API_GO}/config.yaml
|
wget https://raw.githubusercontent.com/goauthentik/client-go/main/config.yaml -O ./${GEN_API_GO}/config.yaml
|
||||||
|
@ -85,7 +85,7 @@ class UserGroupSerializer(ModelSerializer):
|
|||||||
"""Simplified Group Serializer for user's groups"""
|
"""Simplified Group Serializer for user's groups"""
|
||||||
|
|
||||||
attributes = JSONDictField(required=False)
|
attributes = JSONDictField(required=False)
|
||||||
parent_name = CharField(source="parent.name", read_only=True)
|
parent_name = CharField(source="parent.name", read_only=True, allow_null=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Group
|
model = Group
|
||||||
|
@ -156,6 +156,7 @@ SPECTACULAR_SETTINGS = {
|
|||||||
"UserTypeEnum": "authentik.core.models.UserTypes",
|
"UserTypeEnum": "authentik.core.models.UserTypes",
|
||||||
},
|
},
|
||||||
"ENUM_ADD_EXPLICIT_BLANK_NULL_CHOICE": False,
|
"ENUM_ADD_EXPLICIT_BLANK_NULL_CHOICE": False,
|
||||||
|
"ENUM_GENERATE_CHOICE_DESCRIPTION": False,
|
||||||
"POSTPROCESSING_HOOKS": [
|
"POSTPROCESSING_HOOKS": [
|
||||||
"authentik.api.schema.postprocess_schema_responses",
|
"authentik.api.schema.postprocess_schema_responses",
|
||||||
"drf_spectacular.hooks.postprocess_schema_enums",
|
"drf_spectacular.hooks.postprocess_schema_enums",
|
||||||
|
1866
schema.yml
1866
schema.yml
File diff suppressed because it is too large
Load Diff
4
scripts/api-py-config.yaml
Normal file
4
scripts/api-py-config.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
additionalProperties:
|
||||||
|
packageName: authentik_client
|
||||||
|
projectName: authentik-client
|
||||||
|
infoName: authentik Team
|
Reference in New Issue
Block a user