alpha-python 0.5.1__tar.gz → 0.6.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- alpha_python-0.6.1/PKG-INFO +210 -0
- alpha_python-0.6.1/README.md +153 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/pyproject.toml +69 -8
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/__init__.py +57 -5
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/adapters/rest_api_unit_of_work.py +9 -3
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/adapters/sqla_unit_of_work.py +23 -5
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/cli.py +27 -23
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/containers/container.py +52 -47
- alpha_python-0.6.1/src/alpha/domain/__init__.py +21 -0
- alpha_python-0.6.1/src/alpha/domain/models/__init__.py +21 -0
- alpha_python-0.6.1/src/alpha/domain/models/base_model.py +61 -0
- alpha_python-0.6.1/src/alpha/domain/models/group.py +85 -0
- alpha_python-0.6.1/src/alpha/domain/models/life_cycle_base.py +29 -0
- alpha_python-0.5.1/src/alpha/domain/models/user.py → alpha_python-0.6.1/src/alpha/domain/models/role.py +55 -58
- alpha_python-0.6.1/src/alpha/domain/models/user.py +143 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/encoder.py +25 -3
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/factories/class_factories.py +49 -22
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/factories/default_field_factory.py +1 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/factories/field_iterator.py +8 -2
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/factories/jwt_factory.py +59 -18
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/factories/logging_handler_factory.py +7 -5
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/factories/model_class_factory.py +6 -3
- alpha_python-0.6.1/src/alpha/factories/models/factory_classes.py +39 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/factories/password_factory.py +39 -15
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/factories/request_factory.py +24 -13
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/factories/response_factory.py +5 -2
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/factories/type_factories.py +16 -2
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/api_generate_handler.py +37 -33
- alpha_python-0.6.1/src/alpha/handlers/run-api.sh +4 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/__main__.mustache +26 -9
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/controller.mustache +131 -30
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/controller_test.mustache +1 -1
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/model.mustache +7 -1
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/setup.mustache +0 -19
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/infra/__init__.py +14 -5
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/infra/connectors/__init__.py +9 -4
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/infra/connectors/ldap_connector.py +38 -29
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/infra/connectors/oidc_connector.py +1 -1
- {alpha_python-0.5.1/src/alpha/infra/databases → alpha_python-0.6.1/src/alpha/infra/connectors}/sql_alchemy.py +42 -38
- alpha_python-0.6.1/src/alpha/infra/databases/sql_alchemy.py +9 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/infra/models/filter_operators.py +6 -1
- alpha_python-0.6.1/src/alpha/infra/models/json_patch.py +45 -0
- alpha_python-0.6.1/src/alpha/infra/models/order_by.py +143 -0
- alpha_python-0.6.1/src/alpha/infra/models/query_clause.py +68 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/infra/models/search_filter.py +96 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/interfaces/__init__.py +2 -2
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/interfaces/api_repository.py +11 -5
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/interfaces/factories.py +5 -2
- alpha_python-0.6.1/src/alpha/interfaces/patchable.py +24 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/interfaces/providers.py +4 -4
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/interfaces/sql_mapper.py +6 -3
- alpha_python-0.6.1/src/alpha/interfaces/sql_repository.py +356 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/interfaces/token_factory.py +12 -10
- alpha_python-0.6.1/src/alpha/interfaces/unit_of_work.py +70 -0
- alpha_python-0.6.1/src/alpha/interfaces/updatable.py +21 -0
- alpha_python-0.6.1/src/alpha/mixins/__init__.py +5 -0
- alpha_python-0.6.1/src/alpha/mixins/group_lifecycle.py +159 -0
- alpha_python-0.6.1/src/alpha/mixins/user_lifecycle.py +188 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/providers/database_provider.py +5 -4
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/providers/ldap_provider.py +82 -66
- alpha_python-0.6.1/src/alpha/providers/models/credentials.py +43 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/providers/models/identity.py +20 -11
- alpha_python-0.6.1/src/alpha/providers/models/token.py +111 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/providers/oidc_provider.py +56 -35
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/repositories/rest_api_repository.py +23 -24
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/repositories/sql_alchemy_repository.py +179 -133
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/services/authentication_service.py +274 -51
- alpha_python-0.6.1/src/alpha/services/models/__init__.py +0 -0
- alpha_python-0.6.1/src/alpha/services/models/cookie.py +5 -0
- alpha_python-0.6.1/src/alpha/services/user_lifecycle_management.py +63 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/utils/__init__.py +2 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/utils/_http_codes.py +8 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/utils/is_attrs.py +1 -1
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/utils/is_pydantic.py +1 -1
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/utils/logging_configurator.py +19 -17
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/utils/logging_level_checker.py +3 -3
- alpha_python-0.6.1/src/alpha/utils/openapi_test/__init__.py +0 -0
- alpha_python-0.6.1/src/alpha/utils/openapi_test/container.py +181 -0
- alpha_python-0.6.1/src/alpha/utils/openapi_test/exceptions.py +17 -0
- alpha_python-0.6.1/src/alpha/utils/openapi_test/models.py +83 -0
- alpha_python-0.6.1/src/alpha/utils/openapi_test/orm.py +90 -0
- alpha_python-0.6.1/src/alpha/utils/openapi_test/response.py +12 -0
- alpha_python-0.6.1/src/alpha/utils/openapi_test/service.py +166 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/utils/request_headers.py +8 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/utils/response_object.py +19 -8
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/utils/secret_generator.py +2 -2
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/utils/verify_identity.py +7 -7
- alpha_python-0.6.1/src/alpha_python.egg-info/PKG-INFO +210 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha_python.egg-info/SOURCES.txt +14 -1
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha_python.egg-info/requires.txt +4 -4
- alpha_python-0.6.1/tests/test_cli.py +168 -0
- alpha_python-0.5.1/PKG-INFO +0 -100
- alpha_python-0.5.1/README.md +0 -58
- alpha_python-0.5.1/src/alpha/domain/__init__.py +0 -10
- alpha_python-0.5.1/src/alpha/domain/models/__init__.py +0 -10
- alpha_python-0.5.1/src/alpha/domain/models/base_model.py +0 -25
- alpha_python-0.5.1/src/alpha/domain/models/group.py +0 -35
- alpha_python-0.5.1/src/alpha/domain/models/life_cycle_base.py +0 -10
- alpha_python-0.5.1/src/alpha/factories/models/factory_classes.py +0 -20
- alpha_python-0.5.1/src/alpha/handlers/run-api.sh +0 -12
- alpha_python-0.5.1/src/alpha/handlers/templates/python-flask/requirements.mustache +0 -19
- alpha_python-0.5.1/src/alpha/infra/models/json_patch.py +0 -19
- alpha_python-0.5.1/src/alpha/infra/models/order_by.py +0 -69
- alpha_python-0.5.1/src/alpha/infra/models/query_clause.py +0 -43
- alpha_python-0.5.1/src/alpha/interfaces/patchable.py +0 -8
- alpha_python-0.5.1/src/alpha/interfaces/sql_repository.py +0 -369
- alpha_python-0.5.1/src/alpha/interfaces/unit_of_work.py +0 -53
- alpha_python-0.5.1/src/alpha/interfaces/updateable.py +0 -7
- alpha_python-0.5.1/src/alpha/mixins/__init__.py +0 -3
- alpha_python-0.5.1/src/alpha/providers/models/credentials.py +0 -21
- alpha_python-0.5.1/src/alpha/providers/models/token.py +0 -55
- alpha_python-0.5.1/src/alpha/services/user_lifecycle_management.py +0 -331
- alpha_python-0.5.1/src/alpha_python.egg-info/PKG-INFO +0 -100
- {alpha_python-0.5.1 → alpha_python-0.6.1}/LICENSE +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/setup.cfg +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/adapters/__init__.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/containers/__init__.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/exceptions.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/factories/__init__.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/factories/_type_conversion_matrix.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/factories/_type_mapping.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/factories/models/__init__.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/__init__.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/api_run_handler.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/base_handler.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/gen-code.sh +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/models/__init__.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/models/argument.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/models/command.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/models/section.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/models/subparser.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/__init__.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/Dockerfile.mustache +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/README.mustache +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/__init__model.mustache +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/__init__test.mustache +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/base_model.mustache +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/dockerignore.mustache +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/encoder.mustache +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/git_push.sh.mustache +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/gitignore.mustache +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/openapi.mustache +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/param_type.mustache +0 -0
- /alpha_python-0.5.1/src/alpha/providers/api_key_provider.py → /alpha_python-0.6.1/src/alpha/handlers/templates/python-flask/requirements.mustache +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/security_controller_.mustache +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/test-requirements.mustache +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/tox.mustache +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/travis.mustache +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/typing_utils.mustache +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/handlers/templates/python-flask/util.mustache +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/infra/databases/__init__.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/infra/models/__init__.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/interfaces/attrs_instance.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/interfaces/dataclass_instance.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/interfaces/handler.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/interfaces/openapi_model.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/interfaces/pydantic_instance.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/interfaces/sql_database.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/mixins/jwt_provider.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/providers/__init__.py +0 -0
- /alpha_python-0.5.1/src/alpha/py.typed → /alpha_python-0.6.1/src/alpha/providers/api_key_provider.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/providers/models/__init__.py +0 -0
- /alpha_python-0.5.1/src/alpha/services/models/__init__.py → /alpha_python-0.6.1/src/alpha/py.typed +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/repositories/__init__.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/repositories/models/__init__.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/repositories/models/repository_model.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/services/__init__.py +0 -0
- {alpha_python-0.5.1/src/alpha/services/models → alpha_python-0.6.1/src/alpha/utils}/cookie.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha/utils/version_checker.py +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha_python.egg-info/dependency_links.txt +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha_python.egg-info/entry_points.txt +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/src/alpha_python.egg-info/top_level.txt +0 -0
- {alpha_python-0.5.1 → alpha_python-0.6.1}/tests/test_encoder.py +0 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: alpha-python
|
|
3
|
+
Version: 0.6.1
|
|
4
|
+
Summary: Alpha is intended to be the first dependency you need to add to your Python application. It is a Python library which contains standard building blocks that can be used in applications that are used as APIs and/or make use of database interaction.
|
|
5
|
+
Author-email: Bart Reijling <bart@reijling.eu>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/breijling/alpha
|
|
8
|
+
Project-URL: Issues, https://github.com/breijling/alpha/issues
|
|
9
|
+
Project-URL: Documentation, https://alpha-python.readthedocs.io/en/latest/
|
|
10
|
+
Project-URL: Changelog, https://alpha-python.readthedocs.io/en/latest/changelog/
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Requires-Python: <3.15,>=3.11
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: attrs>=25.4.0
|
|
23
|
+
Requires-Dist: gunicorn>=23.0.0
|
|
24
|
+
Requires-Dist: jsonpatch>=1.33
|
|
25
|
+
Requires-Dist: numpy>=2.3.5
|
|
26
|
+
Requires-Dist: pandas>=1.13
|
|
27
|
+
Requires-Dist: pydantic>=2.12.5
|
|
28
|
+
Requires-Dist: pyjwt>=2.10.1
|
|
29
|
+
Requires-Dist: six>=1.17.0
|
|
30
|
+
Requires-Dist: sqlalchemy>=2.0.44
|
|
31
|
+
Requires-Dist: requests>=2.28.1
|
|
32
|
+
Requires-Dist: dependency-injector[yaml]!=4.48.3,<5.0.0,>=4.42.0
|
|
33
|
+
Requires-Dist: argon2-cffi>=25.1.0
|
|
34
|
+
Requires-Dist: httpx
|
|
35
|
+
Requires-Dist: cryptography
|
|
36
|
+
Provides-Extra: api-generator
|
|
37
|
+
Requires-Dist: openapi-generator-cli==7.14.0; extra == "api-generator"
|
|
38
|
+
Requires-Dist: jdk4py; extra == "api-generator"
|
|
39
|
+
Provides-Extra: flask
|
|
40
|
+
Requires-Dist: connexion[swagger-ui]<3,>=2.14.2; extra == "flask"
|
|
41
|
+
Requires-Dist: swagger-ui-bundle>=0.0.2; extra == "flask"
|
|
42
|
+
Requires-Dist: python_dateutil>=2.6.0; extra == "flask"
|
|
43
|
+
Requires-Dist: itsdangerous==1.1.0; extra == "flask"
|
|
44
|
+
Requires-Dist: MarkupSafe<2.0.2; extra == "flask"
|
|
45
|
+
Requires-Dist: Jinja2==2.11.2; extra == "flask"
|
|
46
|
+
Requires-Dist: Flask<2,>=1.1.2; extra == "flask"
|
|
47
|
+
Requires-Dist: Werkzeug<2.1.0,>=1.0.1; extra == "flask"
|
|
48
|
+
Requires-Dist: flask-cors>=3.0.10; extra == "flask"
|
|
49
|
+
Requires-Dist: Flask-Compress>=1.13; extra == "flask"
|
|
50
|
+
Provides-Extra: mysql
|
|
51
|
+
Requires-Dist: pymysql>=1.1.2; extra == "mysql"
|
|
52
|
+
Provides-Extra: postgresql
|
|
53
|
+
Requires-Dist: psycopg2-binary>=2.9.11; extra == "postgresql"
|
|
54
|
+
Provides-Extra: ldap
|
|
55
|
+
Requires-Dist: ldap3>=2.9.1; extra == "ldap"
|
|
56
|
+
Dynamic: license-file
|
|
57
|
+
|
|
58
|
+
# Alpha
|
|
59
|
+
|
|
60
|
+
Alpha is intended to be the first dependency you need to add to your Python application. It is a Python library which contains standard building blocks that can be used in applications that are used as APIs and/or make use of database interaction.
|
|
61
|
+
|
|
62
|
+
## Badges
|
|
63
|
+
|
|
64
|
+
[](https://badge.fury.io/py/alpha-python)
|
|
65
|
+
[](https://pypistats.org/packages/alpha-python)
|
|
66
|
+
[](https://github.com/breijling/alpha/actions/workflows/python-app.yml)
|
|
67
|
+
[](https://pypi.org/project/alpha-python)
|
|
68
|
+
[](https://coveralls.io/github/BReijling/alpha?branch=main)
|
|
69
|
+
[](https://docs.astral.sh/uv/)
|
|
70
|
+
[](https://mypy-lang.org/)
|
|
71
|
+
[](https://docs.pytest.org/)
|
|
72
|
+
[](https://www.python.org/dev/peps/pep-0008/)
|
|
73
|
+
[](https://github.com/astral-sh/ruff)
|
|
74
|
+
[](https://alpha-python.readthedocs.io/en/latest/)
|
|
75
|
+
[](https://choosealicense.com/licenses/mit/)
|
|
76
|
+
[](https://github.com/sponsors/BReijling)
|
|
77
|
+
|
|
78
|
+
## TL;DR
|
|
79
|
+
|
|
80
|
+
Alpha provides a comprehensive set of tools for building Python applications that interact with APIs and databases, including API code generation, authentication and authorization, database access layers, error handling, logging, and more. It is designed to be the first dependency you add to your project, providing a solid foundation for your application's architecture.
|
|
81
|
+
|
|
82
|
+
## Documentation
|
|
83
|
+
|
|
84
|
+
Full documentation is available at [alpha-python.readthedocs.io](https://alpha-python.readthedocs.io/).
|
|
85
|
+
|
|
86
|
+
## Installation
|
|
87
|
+
|
|
88
|
+
The library is still in development, but you can already install it using pip:
|
|
89
|
+
|
|
90
|
+
```shell
|
|
91
|
+
pip install alpha-python
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
If you want to use the alpha cli for generating API code, you can install it using pip as well:
|
|
95
|
+
|
|
96
|
+
```shell
|
|
97
|
+
pip install alpha-python[api-generator]
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
If you want to add the library to your API project, you can add it to your pyproject.toml file:
|
|
101
|
+
|
|
102
|
+
```shell
|
|
103
|
+
# Poetry example
|
|
104
|
+
poetry add alpha-python --extras "flask, postgresql"
|
|
105
|
+
poetry add --dev alpha-python --extras "api-generator"
|
|
106
|
+
|
|
107
|
+
# UV example
|
|
108
|
+
uv add alpha-python --extra flask --extra postgresql
|
|
109
|
+
uv add --dev alpha-python --extra api-generator
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Features
|
|
113
|
+
|
|
114
|
+
- API code generation
|
|
115
|
+
- Authentication and authorization
|
|
116
|
+
- Database interaction
|
|
117
|
+
- Logging
|
|
118
|
+
- Error handling
|
|
119
|
+
- And much more!
|
|
120
|
+
|
|
121
|
+
## Usage
|
|
122
|
+
|
|
123
|
+
The library contains many components. Below are a few practical examples that map to the guides in the documentation.
|
|
124
|
+
|
|
125
|
+
### 1) API code generation using OpenAPI spec
|
|
126
|
+
|
|
127
|
+
```shell
|
|
128
|
+
alpha api gen --spec-file specification/openapi.yaml --service-package my_app
|
|
129
|
+
|
|
130
|
+
alpha api run --port 8080
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 2) Authenticate with Keycloak (OIDC)
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
from alpha import KeyCloakOIDCConnector, KeyCloakProvider, PasswordCredentials
|
|
137
|
+
|
|
138
|
+
keycloak_connector = KeyCloakOIDCConnector(
|
|
139
|
+
base_url="https://keycloak.example.com",
|
|
140
|
+
realm="myrealm",
|
|
141
|
+
client_id="myclient",
|
|
142
|
+
client_secret="myclientsecret",
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
keycloak_provider = KeyCloakProvider(connector=keycloak_connector)
|
|
146
|
+
|
|
147
|
+
credentials = PasswordCredentials(username="user1", password="user1_password")
|
|
148
|
+
identity = keycloak_provider.authenticate(credentials)
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### 3) Query data using SqlAlchemyDatabase + SqlAlchemyRepository
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
from alpha import SqlAlchemyDatabase, SqlAlchemyRepository
|
|
155
|
+
from my_app import User
|
|
156
|
+
|
|
157
|
+
db = SqlAlchemyDatabase(conn_str="postgresql://user:password@localhost:5432/mydatabase")
|
|
158
|
+
|
|
159
|
+
with db.get_session() as session:
|
|
160
|
+
users = SqlAlchemyRepository[User](session=session, default_model=User)
|
|
161
|
+
user = users.get_by_id(1)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### 4) Use Unit of Work for transactional operations
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
from alpha import (
|
|
168
|
+
RepositoryModel,
|
|
169
|
+
SqlAlchemyDatabase,
|
|
170
|
+
SqlAlchemyRepository,
|
|
171
|
+
SqlAlchemyUnitOfWork,
|
|
172
|
+
)
|
|
173
|
+
from my_app import User, OrmMapper
|
|
174
|
+
|
|
175
|
+
db = SqlAlchemyDatabase(..., mapper=OrmMapper)
|
|
176
|
+
repositories = [
|
|
177
|
+
RepositoryModel(
|
|
178
|
+
name="users",
|
|
179
|
+
repository=SqlAlchemyRepository[User],
|
|
180
|
+
default_model=User,
|
|
181
|
+
)
|
|
182
|
+
]
|
|
183
|
+
|
|
184
|
+
uow = SqlAlchemyUnitOfWork(db=db, repos=repositories)
|
|
185
|
+
|
|
186
|
+
with uow:
|
|
187
|
+
user = uow.users.get_by_id(1)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
See also:
|
|
191
|
+
|
|
192
|
+
- Design principles and patterns: https://alpha-python.readthedocs.io/en/latest/concepts/design-principles/
|
|
193
|
+
- Dependency injection concept: https://alpha-python.readthedocs.io/en/latest/concepts/dependency-injection/
|
|
194
|
+
- API code generation guide: https://alpha-python.readthedocs.io/en/latest/guides/api-generation/
|
|
195
|
+
- Authentication guide: https://alpha-python.readthedocs.io/en/latest/guides/authentication/
|
|
196
|
+
- Database interaction guide: https://alpha-python.readthedocs.io/en/latest/guides/database-interaction/
|
|
197
|
+
|
|
198
|
+
## Contributing
|
|
199
|
+
|
|
200
|
+
If you want to contribute to the development of this library, you can fork the repository and create a pull request with your changes.
|
|
201
|
+
|
|
202
|
+
## Support
|
|
203
|
+
|
|
204
|
+
If Alpha saves you time in production, consider supporting development by buying me a coffee! Your support helps me to continue improving the library and adding new features. Thank you!
|
|
205
|
+
|
|
206
|
+
<a href="https://www.buymeacoffee.com/breijling"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=breijling&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff" /></a>
|
|
207
|
+
|
|
208
|
+
## License
|
|
209
|
+
|
|
210
|
+
This library is licensed under the MIT License. See the LICENSE file for more information.
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Alpha
|
|
2
|
+
|
|
3
|
+
Alpha is intended to be the first dependency you need to add to your Python application. It is a Python library which contains standard building blocks that can be used in applications that are used as APIs and/or make use of database interaction.
|
|
4
|
+
|
|
5
|
+
## Badges
|
|
6
|
+
|
|
7
|
+
[](https://badge.fury.io/py/alpha-python)
|
|
8
|
+
[](https://pypistats.org/packages/alpha-python)
|
|
9
|
+
[](https://github.com/breijling/alpha/actions/workflows/python-app.yml)
|
|
10
|
+
[](https://pypi.org/project/alpha-python)
|
|
11
|
+
[](https://coveralls.io/github/BReijling/alpha?branch=main)
|
|
12
|
+
[](https://docs.astral.sh/uv/)
|
|
13
|
+
[](https://mypy-lang.org/)
|
|
14
|
+
[](https://docs.pytest.org/)
|
|
15
|
+
[](https://www.python.org/dev/peps/pep-0008/)
|
|
16
|
+
[](https://github.com/astral-sh/ruff)
|
|
17
|
+
[](https://alpha-python.readthedocs.io/en/latest/)
|
|
18
|
+
[](https://choosealicense.com/licenses/mit/)
|
|
19
|
+
[](https://github.com/sponsors/BReijling)
|
|
20
|
+
|
|
21
|
+
## TL;DR
|
|
22
|
+
|
|
23
|
+
Alpha provides a comprehensive set of tools for building Python applications that interact with APIs and databases, including API code generation, authentication and authorization, database access layers, error handling, logging, and more. It is designed to be the first dependency you add to your project, providing a solid foundation for your application's architecture.
|
|
24
|
+
|
|
25
|
+
## Documentation
|
|
26
|
+
|
|
27
|
+
Full documentation is available at [alpha-python.readthedocs.io](https://alpha-python.readthedocs.io/).
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
The library is still in development, but you can already install it using pip:
|
|
32
|
+
|
|
33
|
+
```shell
|
|
34
|
+
pip install alpha-python
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
If you want to use the alpha cli for generating API code, you can install it using pip as well:
|
|
38
|
+
|
|
39
|
+
```shell
|
|
40
|
+
pip install alpha-python[api-generator]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
If you want to add the library to your API project, you can add it to your pyproject.toml file:
|
|
44
|
+
|
|
45
|
+
```shell
|
|
46
|
+
# Poetry example
|
|
47
|
+
poetry add alpha-python --extras "flask, postgresql"
|
|
48
|
+
poetry add --dev alpha-python --extras "api-generator"
|
|
49
|
+
|
|
50
|
+
# UV example
|
|
51
|
+
uv add alpha-python --extra flask --extra postgresql
|
|
52
|
+
uv add --dev alpha-python --extra api-generator
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Features
|
|
56
|
+
|
|
57
|
+
- API code generation
|
|
58
|
+
- Authentication and authorization
|
|
59
|
+
- Database interaction
|
|
60
|
+
- Logging
|
|
61
|
+
- Error handling
|
|
62
|
+
- And much more!
|
|
63
|
+
|
|
64
|
+
## Usage
|
|
65
|
+
|
|
66
|
+
The library contains many components. Below are a few practical examples that map to the guides in the documentation.
|
|
67
|
+
|
|
68
|
+
### 1) API code generation using OpenAPI spec
|
|
69
|
+
|
|
70
|
+
```shell
|
|
71
|
+
alpha api gen --spec-file specification/openapi.yaml --service-package my_app
|
|
72
|
+
|
|
73
|
+
alpha api run --port 8080
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 2) Authenticate with Keycloak (OIDC)
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from alpha import KeyCloakOIDCConnector, KeyCloakProvider, PasswordCredentials
|
|
80
|
+
|
|
81
|
+
keycloak_connector = KeyCloakOIDCConnector(
|
|
82
|
+
base_url="https://keycloak.example.com",
|
|
83
|
+
realm="myrealm",
|
|
84
|
+
client_id="myclient",
|
|
85
|
+
client_secret="myclientsecret",
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
keycloak_provider = KeyCloakProvider(connector=keycloak_connector)
|
|
89
|
+
|
|
90
|
+
credentials = PasswordCredentials(username="user1", password="user1_password")
|
|
91
|
+
identity = keycloak_provider.authenticate(credentials)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 3) Query data using SqlAlchemyDatabase + SqlAlchemyRepository
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from alpha import SqlAlchemyDatabase, SqlAlchemyRepository
|
|
98
|
+
from my_app import User
|
|
99
|
+
|
|
100
|
+
db = SqlAlchemyDatabase(conn_str="postgresql://user:password@localhost:5432/mydatabase")
|
|
101
|
+
|
|
102
|
+
with db.get_session() as session:
|
|
103
|
+
users = SqlAlchemyRepository[User](session=session, default_model=User)
|
|
104
|
+
user = users.get_by_id(1)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 4) Use Unit of Work for transactional operations
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from alpha import (
|
|
111
|
+
RepositoryModel,
|
|
112
|
+
SqlAlchemyDatabase,
|
|
113
|
+
SqlAlchemyRepository,
|
|
114
|
+
SqlAlchemyUnitOfWork,
|
|
115
|
+
)
|
|
116
|
+
from my_app import User, OrmMapper
|
|
117
|
+
|
|
118
|
+
db = SqlAlchemyDatabase(..., mapper=OrmMapper)
|
|
119
|
+
repositories = [
|
|
120
|
+
RepositoryModel(
|
|
121
|
+
name="users",
|
|
122
|
+
repository=SqlAlchemyRepository[User],
|
|
123
|
+
default_model=User,
|
|
124
|
+
)
|
|
125
|
+
]
|
|
126
|
+
|
|
127
|
+
uow = SqlAlchemyUnitOfWork(db=db, repos=repositories)
|
|
128
|
+
|
|
129
|
+
with uow:
|
|
130
|
+
user = uow.users.get_by_id(1)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
See also:
|
|
134
|
+
|
|
135
|
+
- Design principles and patterns: https://alpha-python.readthedocs.io/en/latest/concepts/design-principles/
|
|
136
|
+
- Dependency injection concept: https://alpha-python.readthedocs.io/en/latest/concepts/dependency-injection/
|
|
137
|
+
- API code generation guide: https://alpha-python.readthedocs.io/en/latest/guides/api-generation/
|
|
138
|
+
- Authentication guide: https://alpha-python.readthedocs.io/en/latest/guides/authentication/
|
|
139
|
+
- Database interaction guide: https://alpha-python.readthedocs.io/en/latest/guides/database-interaction/
|
|
140
|
+
|
|
141
|
+
## Contributing
|
|
142
|
+
|
|
143
|
+
If you want to contribute to the development of this library, you can fork the repository and create a pull request with your changes.
|
|
144
|
+
|
|
145
|
+
## Support
|
|
146
|
+
|
|
147
|
+
If Alpha saves you time in production, consider supporting development by buying me a coffee! Your support helps me to continue improving the library and adding new features. Thank you!
|
|
148
|
+
|
|
149
|
+
<a href="https://www.buymeacoffee.com/breijling"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=breijling&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff" /></a>
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
This library is licensed under the MIT License. See the LICENSE file for more information.
|
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "alpha-python"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.6.1"
|
|
4
4
|
description = "Alpha is intended to be the first dependency you need to add to your Python application. It is a Python library which contains standard building blocks that can be used in applications that are used as APIs and/or make use of database interaction."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
7
7
|
{ name = "Bart Reijling", email = "bart@reijling.eu" }
|
|
8
8
|
]
|
|
9
|
-
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Development Status :: 4 - Beta",
|
|
11
|
+
"Intended Audience :: Developers",
|
|
12
|
+
"Programming Language :: Python :: 3",
|
|
13
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
14
|
+
"Programming Language :: Python :: 3.11",
|
|
15
|
+
"Programming Language :: Python :: 3.12",
|
|
16
|
+
"Programming Language :: Python :: 3.13",
|
|
17
|
+
"Programming Language :: Python :: 3.14",
|
|
18
|
+
]
|
|
19
|
+
license = "MIT"
|
|
20
|
+
license-files = ['LICENSE']
|
|
21
|
+
requires-python = ">=3.11, <3.15"
|
|
10
22
|
dependencies = [
|
|
11
23
|
"attrs>=25.4.0",
|
|
12
24
|
"gunicorn>=23.0.0",
|
|
13
25
|
"jsonpatch>=1.33",
|
|
14
26
|
"numpy>=2.3.5",
|
|
15
|
-
"pandas>=
|
|
27
|
+
"pandas>=1.13",
|
|
16
28
|
"pydantic>=2.12.5",
|
|
17
29
|
"pyjwt>=2.10.1",
|
|
18
30
|
"six>=1.17.0",
|
|
@@ -20,8 +32,16 @@ dependencies = [
|
|
|
20
32
|
"requests>=2.28.1",
|
|
21
33
|
"dependency-injector[yaml]>=4.42.0,<5.0.0,!=4.48.3",
|
|
22
34
|
"argon2-cffi>=25.1.0",
|
|
35
|
+
"httpx",
|
|
36
|
+
"cryptography",
|
|
23
37
|
]
|
|
24
38
|
|
|
39
|
+
[project.urls]
|
|
40
|
+
Homepage = "https://github.com/breijling/alpha"
|
|
41
|
+
Issues = "https://github.com/breijling/alpha/issues"
|
|
42
|
+
Documentation = "https://alpha-python.readthedocs.io/en/latest/"
|
|
43
|
+
Changelog = "https://alpha-python.readthedocs.io/en/latest/changelog/"
|
|
44
|
+
|
|
25
45
|
[project.scripts]
|
|
26
46
|
alpha = "alpha.cli:init"
|
|
27
47
|
|
|
@@ -60,11 +80,21 @@ dev = [
|
|
|
60
80
|
"ipykernel>=7.2.0",
|
|
61
81
|
"flask<2",
|
|
62
82
|
"httpx>=0.28.1",
|
|
83
|
+
"tox>=4.0.0",
|
|
84
|
+
"types-ldap3",
|
|
85
|
+
"types-requests",
|
|
86
|
+
"pandas-stubs",
|
|
63
87
|
]
|
|
88
|
+
# docs = [
|
|
89
|
+
# "mkdocs-material>=9.5",
|
|
90
|
+
# "mkdocstrings[python]>=0.29",
|
|
91
|
+
# "mkdocs-autorefs>=1.0",
|
|
92
|
+
# "mkdocs-mermaid2-plugin>=1.2.0"
|
|
93
|
+
# ]
|
|
64
94
|
|
|
65
95
|
[project.optional-dependencies]
|
|
66
96
|
api-generator = [
|
|
67
|
-
"openapi-generator-cli==7.14.0
|
|
97
|
+
"openapi-generator-cli==7.14.0",
|
|
68
98
|
"jdk4py"
|
|
69
99
|
]
|
|
70
100
|
flask = [
|
|
@@ -97,18 +127,46 @@ testpaths = [
|
|
|
97
127
|
"tests"
|
|
98
128
|
]
|
|
99
129
|
|
|
130
|
+
[tool.tox]
|
|
131
|
+
legacy_tox_ini = """
|
|
132
|
+
[tox]
|
|
133
|
+
min_version = 4.0
|
|
134
|
+
env_list = py311,py312,py313,py314
|
|
135
|
+
isolated_build = true
|
|
136
|
+
|
|
137
|
+
[testenv]
|
|
138
|
+
description = Run full test suite on {basepython}
|
|
139
|
+
package = editable
|
|
140
|
+
extras = flask,postgresql,mysql,ldap,api-generator
|
|
141
|
+
deps =
|
|
142
|
+
pytest>=9.0.1
|
|
143
|
+
pytest-cov>=7.0.0
|
|
144
|
+
uv
|
|
145
|
+
commands =
|
|
146
|
+
pytest {posargs}
|
|
147
|
+
pass_env =
|
|
148
|
+
GITHUB_ACTIONS
|
|
149
|
+
TEST_PSQL_HOST
|
|
150
|
+
TEST_PSQL_PORT
|
|
151
|
+
TEST_PSQL_USERNAME
|
|
152
|
+
TEST_PSQL_PASSWORD
|
|
153
|
+
TEST_PSQL_DATABASE
|
|
154
|
+
"""
|
|
155
|
+
|
|
156
|
+
|
|
100
157
|
[tool.coverage.run]
|
|
101
158
|
source = ["src"]
|
|
102
159
|
omit = [
|
|
103
160
|
"tests/*",
|
|
104
161
|
"__init__.py",
|
|
105
|
-
"_http_codes.py"
|
|
162
|
+
"_http_codes.py",
|
|
163
|
+
"src/alpha/utils/openapi_test/*"
|
|
106
164
|
]
|
|
107
165
|
|
|
108
166
|
[tool.black]
|
|
109
167
|
line-length = 79
|
|
110
168
|
skip-string-normalization = true
|
|
111
|
-
target-version = ['
|
|
169
|
+
target-version = ['py311', 'py312', 'py313', 'py314']
|
|
112
170
|
|
|
113
171
|
[tool.isort]
|
|
114
172
|
py_version = 311
|
|
@@ -118,10 +176,13 @@ force_grid_wrap = 0
|
|
|
118
176
|
|
|
119
177
|
[tool.mypy]
|
|
120
178
|
python_version = "3.11"
|
|
121
|
-
exclude = [
|
|
179
|
+
exclude = ["^tests/", "src/alpha/utils/openapi_test"]
|
|
122
180
|
|
|
123
181
|
[[tool.mypy.overrides]]
|
|
124
|
-
module = [
|
|
182
|
+
module = [
|
|
183
|
+
"flask",
|
|
184
|
+
"flask.*",
|
|
185
|
+
]
|
|
125
186
|
ignore_missing_imports = true
|
|
126
187
|
|
|
127
188
|
[tool.ruff]
|
|
@@ -1,16 +1,25 @@
|
|
|
1
|
+
from importlib.metadata import version
|
|
2
|
+
|
|
1
3
|
from alpha.adapters.rest_api_unit_of_work import RestApiUnitOfWork
|
|
2
4
|
from alpha.adapters.sqla_unit_of_work import SqlAlchemyUnitOfWork
|
|
3
5
|
from alpha.factories.jwt_factory import JWTFactory
|
|
4
6
|
from alpha.factories.logging_handler_factory import LoggingHandlerFactory
|
|
5
7
|
from alpha.factories.model_class_factory import ModelClassFactory
|
|
6
8
|
from alpha.domain.models.user import User
|
|
7
|
-
from alpha.domain.models.
|
|
9
|
+
from alpha.domain.models.group import Group
|
|
10
|
+
from alpha.domain.models.role import Role
|
|
11
|
+
from alpha.domain.models.base_model import (
|
|
12
|
+
BaseDomainModel,
|
|
13
|
+
DomainModel,
|
|
14
|
+
DomainModelCovariant,
|
|
15
|
+
DomainModelContravariant,
|
|
16
|
+
)
|
|
8
17
|
from alpha.domain.models.life_cycle_base import LifeCycleBase
|
|
9
18
|
from alpha.infra.connectors.oidc_connector import (
|
|
10
19
|
OIDCConnector,
|
|
11
20
|
KeyCloakOIDCConnector,
|
|
12
21
|
)
|
|
13
|
-
from alpha.infra.
|
|
22
|
+
from alpha.infra.connectors.sql_alchemy import SqlAlchemyDatabase
|
|
14
23
|
from alpha.infra.models.filter_operators import And, Or
|
|
15
24
|
from alpha.infra.models.json_patch import JsonPatch
|
|
16
25
|
from alpha.infra.models.order_by import OrderBy, Order
|
|
@@ -19,7 +28,7 @@ from alpha.interfaces.attrs_instance import AttrsInstance
|
|
|
19
28
|
from alpha.interfaces.dataclass_instance import DataclassInstance
|
|
20
29
|
from alpha.interfaces.pydantic_instance import PydanticInstance
|
|
21
30
|
from alpha.interfaces.openapi_model import OpenAPIModel
|
|
22
|
-
from alpha.interfaces.
|
|
31
|
+
from alpha.interfaces.updatable import Updatable
|
|
23
32
|
from alpha.interfaces.patchable import Patchable
|
|
24
33
|
from alpha.interfaces.api_repository import ApiRepository
|
|
25
34
|
from alpha.interfaces.sql_repository import SqlRepository
|
|
@@ -36,6 +45,8 @@ from alpha.interfaces.providers import (
|
|
|
36
45
|
)
|
|
37
46
|
from alpha.interfaces.token_factory import TokenFactory
|
|
38
47
|
from alpha.mixins.jwt_provider import JWTProviderMixin
|
|
48
|
+
from alpha.mixins.user_lifecycle import UserLifecycleMixin
|
|
49
|
+
from alpha.mixins.group_lifecycle import GroupLifecycleMixin
|
|
39
50
|
from alpha.providers.models.identity import (
|
|
40
51
|
Identity,
|
|
41
52
|
DEFAULT_LDAP_MAPPINGS,
|
|
@@ -44,7 +55,12 @@ from alpha.providers.models.identity import (
|
|
|
44
55
|
)
|
|
45
56
|
from alpha.providers.models.credentials import PasswordCredentials
|
|
46
57
|
from alpha.providers.models.token import Token
|
|
47
|
-
from alpha.providers.oidc_provider import
|
|
58
|
+
from alpha.providers.oidc_provider import (
|
|
59
|
+
OIDCProvider,
|
|
60
|
+
KeyCloakProvider,
|
|
61
|
+
DEFAULT_OIDC_MAPPINGS,
|
|
62
|
+
DEFAULT_KEYCLOAK_MAPPINGS,
|
|
63
|
+
)
|
|
48
64
|
from alpha.repositories.models.repository_model import RepositoryModel
|
|
49
65
|
from alpha.repositories.rest_api_repository import RestApiRepository
|
|
50
66
|
from alpha.repositories.sql_alchemy_repository import SqlAlchemyRepository
|
|
@@ -63,6 +79,7 @@ from alpha.utils.verify_identity import verify_identity
|
|
|
63
79
|
from alpha.utils.version_checker import minor_version_gte
|
|
64
80
|
from alpha.encoder import JSONEncoder
|
|
65
81
|
|
|
82
|
+
|
|
66
83
|
# Optional LDAP support - only import if ldap3 is available
|
|
67
84
|
try:
|
|
68
85
|
from alpha.infra.connectors.ldap_connector import (
|
|
@@ -77,6 +94,9 @@ try:
|
|
|
77
94
|
except ImportError:
|
|
78
95
|
_LDAP_AVAILABLE = False # type: ignore
|
|
79
96
|
|
|
97
|
+
|
|
98
|
+
__version__ = version("alpha-python")
|
|
99
|
+
|
|
80
100
|
__all__ = [
|
|
81
101
|
"RestApiUnitOfWork",
|
|
82
102
|
"SqlAlchemyUnitOfWork",
|
|
@@ -85,8 +105,12 @@ __all__ = [
|
|
|
85
105
|
"ModelClassFactory",
|
|
86
106
|
"BaseDomainModel",
|
|
87
107
|
"DomainModel",
|
|
108
|
+
"DomainModelCovariant",
|
|
109
|
+
"DomainModelContravariant",
|
|
88
110
|
"LifeCycleBase",
|
|
89
111
|
"User",
|
|
112
|
+
"Group",
|
|
113
|
+
"Role",
|
|
90
114
|
"OIDCConnector",
|
|
91
115
|
"KeyCloakOIDCConnector",
|
|
92
116
|
"SqlAlchemyDatabase",
|
|
@@ -101,7 +125,7 @@ __all__ = [
|
|
|
101
125
|
"DataclassInstance",
|
|
102
126
|
"PydanticInstance",
|
|
103
127
|
"OpenAPIModel",
|
|
104
|
-
"
|
|
128
|
+
"Updatable",
|
|
105
129
|
"Patchable",
|
|
106
130
|
"ApiRepository",
|
|
107
131
|
"SqlRepository",
|
|
@@ -116,6 +140,8 @@ __all__ = [
|
|
|
116
140
|
"TokenIssuer",
|
|
117
141
|
"TokenFactory",
|
|
118
142
|
"JWTProviderMixin",
|
|
143
|
+
"UserLifecycleMixin",
|
|
144
|
+
"GroupLifecycleMixin",
|
|
119
145
|
"Identity",
|
|
120
146
|
"DEFAULT_LDAP_MAPPINGS",
|
|
121
147
|
"DEFAULT_AD_MAPPINGS",
|
|
@@ -124,6 +150,8 @@ __all__ = [
|
|
|
124
150
|
"Token",
|
|
125
151
|
"OIDCProvider",
|
|
126
152
|
"KeyCloakProvider",
|
|
153
|
+
"DEFAULT_OIDC_MAPPINGS",
|
|
154
|
+
"DEFAULT_KEYCLOAK_MAPPINGS",
|
|
127
155
|
"RepositoryModel",
|
|
128
156
|
"RestApiRepository",
|
|
129
157
|
"SqlAlchemyRepository",
|
|
@@ -151,3 +179,27 @@ if _LDAP_AVAILABLE:
|
|
|
151
179
|
"ADProvider",
|
|
152
180
|
]
|
|
153
181
|
)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def _ensure_ast_str_compat() -> None:
|
|
185
|
+
"""Provide ast.Str compatibility for Python 3.14+.
|
|
186
|
+
|
|
187
|
+
Older Werkzeug versions (used by Flask 1.x) still instantiate ast.Str.
|
|
188
|
+
Python 3.14 removed that alias, so we recreate it with ast.Constant.
|
|
189
|
+
"""
|
|
190
|
+
if hasattr(ast, "Str"):
|
|
191
|
+
return
|
|
192
|
+
|
|
193
|
+
class _StrCompat(ast.Constant):
|
|
194
|
+
def __new__(cls, s: str = "", **kwargs): # noqa: N804
|
|
195
|
+
return ast.Constant(value=s, **kwargs)
|
|
196
|
+
|
|
197
|
+
setattr(ast, "Str", _StrCompat)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
try:
|
|
201
|
+
import ast
|
|
202
|
+
|
|
203
|
+
_ensure_ast_str_compat()
|
|
204
|
+
except ImportError:
|
|
205
|
+
pass
|
|
@@ -11,7 +11,13 @@ UOW = TypeVar("UOW", bound="RestApiUnitOfWork")
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class RestApiUnitOfWork:
|
|
14
|
-
"""Unit of Work implementation for REST API interactions.
|
|
14
|
+
"""Unit of Work implementation for REST API interactions.
|
|
15
|
+
|
|
16
|
+
This class manages the lifecycle of a shared HTTP session and provides
|
|
17
|
+
access to configured repositories for API interactions. It does not support
|
|
18
|
+
transactional operations like commit, flush, rollback, or refresh, as these
|
|
19
|
+
concepts do not apply to REST API interactions.
|
|
20
|
+
"""
|
|
15
21
|
|
|
16
22
|
def __init__(
|
|
17
23
|
self,
|
|
@@ -22,9 +28,9 @@ class RestApiUnitOfWork:
|
|
|
22
28
|
|
|
23
29
|
Parameters
|
|
24
30
|
----------
|
|
25
|
-
repos
|
|
31
|
+
repos
|
|
26
32
|
The list of repository models to use.
|
|
27
|
-
session
|
|
33
|
+
session
|
|
28
34
|
The requests session (or compatible HTTP client, e.g., httpx) to
|
|
29
35
|
use for context management, by default None
|
|
30
36
|
|