fastapi-factory-utilities 0.1.0__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.

Potentially problematic release.


This version of fastapi-factory-utilities might be problematic. Click here for more details.

Files changed (57) hide show
  1. fastapi_factory_utilities-0.1.0/LICENSE +21 -0
  2. fastapi_factory_utilities-0.1.0/PKG-INFO +131 -0
  3. fastapi_factory_utilities-0.1.0/README.md +93 -0
  4. fastapi_factory_utilities-0.1.0/pyproject.toml +133 -0
  5. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/__main__.py +6 -0
  6. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/__init__.py +1 -0
  7. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/api/__init__.py +25 -0
  8. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/api/tags.py +9 -0
  9. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/api/v1/sys/__init__.py +12 -0
  10. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/api/v1/sys/health.py +53 -0
  11. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/api/v1/sys/readiness.py +53 -0
  12. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/app/__init__.py +19 -0
  13. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/app/base/__init__.py +17 -0
  14. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/app/base/application.py +123 -0
  15. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/app/base/config_abstract.py +78 -0
  16. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/app/base/exceptions.py +25 -0
  17. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/app/base/fastapi_application_abstract.py +88 -0
  18. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/app/base/plugins_manager_abstract.py +136 -0
  19. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/app/enums.py +11 -0
  20. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/plugins/__init__.py +15 -0
  21. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/plugins/odm_plugin/__init__.py +97 -0
  22. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/plugins/odm_plugin/builder.py +239 -0
  23. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/plugins/odm_plugin/configs.py +17 -0
  24. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/plugins/odm_plugin/documents.py +31 -0
  25. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/plugins/odm_plugin/exceptions.py +25 -0
  26. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/plugins/odm_plugin/repositories.py +172 -0
  27. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/plugins/opentelemetry_plugin/__init__.py +124 -0
  28. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/plugins/opentelemetry_plugin/builder.py +266 -0
  29. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/plugins/opentelemetry_plugin/configs.py +103 -0
  30. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/plugins/opentelemetry_plugin/exceptions.py +13 -0
  31. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/plugins/opentelemetry_plugin/helpers.py +42 -0
  32. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/protocols.py +82 -0
  33. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/utils/configs.py +80 -0
  34. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/utils/importlib.py +28 -0
  35. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/utils/log.py +178 -0
  36. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/utils/uvicorn.py +45 -0
  37. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/core/utils/yaml_reader.py +166 -0
  38. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/example/__init__.py +11 -0
  39. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/example/__main__.py +6 -0
  40. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/example/api/__init__.py +19 -0
  41. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/example/api/books/__init__.py +5 -0
  42. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/example/api/books/responses.py +26 -0
  43. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/example/api/books/routes.py +62 -0
  44. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/example/app/__init__.py +6 -0
  45. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/example/app/app.py +37 -0
  46. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/example/app/config.py +12 -0
  47. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/example/application.yaml +26 -0
  48. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/example/entities/books/__init__.py +7 -0
  49. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/example/entities/books/entities.py +16 -0
  50. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/example/entities/books/enums.py +16 -0
  51. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/example/entities/books/types.py +54 -0
  52. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/example/models/__init__.py +1 -0
  53. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/example/models/books/__init__.py +6 -0
  54. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/example/models/books/document.py +20 -0
  55. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/example/models/books/repository.py +11 -0
  56. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/example/services/books/__init__.py +5 -0
  57. fastapi_factory_utilities-0.1.0/src/fastapi_factory_utilities/example/services/books/services.py +167 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 VANROYE Victorien
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,131 @@
1
+ Metadata-Version: 2.1
2
+ Name: fastapi_factory_utilities
3
+ Version: 0.1.0
4
+ Summary: Consolidate libraries and utilities to create microservices in Python with FastAPI, Beanie, Httpx, AioPika and OpenTelemetry.
5
+ Home-page: https://github.com/miragecentury/fastapi_factory_utilities
6
+ License: MIT
7
+ Keywords: python,fastapi,beanie,httpx,opentelemetry,microservices
8
+ Author: miragecentury
9
+ Author-email: victorien.vanroye@gmail.com
10
+ Maintainer: miragecentury
11
+ Maintainer-email: victorien.vanroye@gmail.com
12
+ Requires-Python: >=3.12,<3.13
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Libraries
20
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Dist: beanie (>=1.27.0,<2.0.0)
23
+ Requires-Dist: fastapi (>=0.115.4,<0.116.0)
24
+ Requires-Dist: httpx (>=0.28.1,<0.29.0)
25
+ Requires-Dist: opentelemetry-exporter-otlp-proto-http (>=1.26.0,<2.0.0)
26
+ Requires-Dist: opentelemetry-instrumentation-fastapi (>=0.49b1,<0.50)
27
+ Requires-Dist: opentelemetry-instrumentation-pymongo (>=0.49b2,<0.50)
28
+ Requires-Dist: opentelemetry-propagator-b3 (>=1.26.0,<2.0.0)
29
+ Requires-Dist: opentelemetry-sdk (>=1.26.0,<2.0.0)
30
+ Requires-Dist: pydantic (>=2.8.2,<3.0.0)
31
+ Requires-Dist: pymongo (>=4.9.2,<4.10.0)
32
+ Requires-Dist: structlog (>=24.1.0,<25.0.0)
33
+ Requires-Dist: typer (>=0.15.1,<0.16.0)
34
+ Requires-Dist: uvicorn (>=0.32.0,<0.33.0)
35
+ Project-URL: Repository, https://github.com/miragecentury/fastapi_factory_utilities
36
+ Description-Content-Type: text/markdown
37
+
38
+ # fastapi_factory_utilities
39
+
40
+ Project Empty for Python with Poetry
41
+
42
+ ## Setup
43
+
44
+ ### Dev Tools
45
+
46
+ #### Python
47
+
48
+ <https://www.python.org/downloads/>
49
+
50
+ ```bash
51
+ sudo apt install software-properties-common -y
52
+ sudo add-apt-repository ppa:deadsnakes/ppa
53
+ sudo apt update
54
+ sudo apt install python3.12 -y
55
+ ```
56
+
57
+ #### Poetry
58
+
59
+ <https://python-poetry.org/>
60
+
61
+ ```bash
62
+ curl -sSL https://install.python-poetry.org | python3.12 -
63
+ ```
64
+
65
+ #### Pre-commit
66
+
67
+ Included in the project while in virtual environment
68
+ <https://pre-commit.com/>
69
+
70
+ #### Docker
71
+
72
+ <https://docs.docker.com/get-docker/>
73
+
74
+ #### Skaffold
75
+
76
+ <https://skaffold.dev>
77
+
78
+ ```bash
79
+ curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64
80
+ chmod +x skaffold
81
+ sudo mv skaffold /usr/local/bin
82
+ ```
83
+
84
+ #### Buildpacks
85
+
86
+ <https://buildpacks.io/>
87
+
88
+ ```bash
89
+ sudo add-apt-repository ppa:cncf-buildpacks/pack-cli
90
+ sudo apt-get update
91
+ sudo apt-get install pack-cli
92
+ ```
93
+
94
+ #### Paketo
95
+
96
+ Included with the usage of buildpacks
97
+ <https://paketo.io/>
98
+
99
+ #### Portman
100
+
101
+ ```bash
102
+ npm install -g @apideck/portman
103
+ ```
104
+
105
+ ### MongoDB
106
+
107
+ <https://docs.mongodb.com/manual/installation/>
108
+
109
+ ```bash
110
+ sudo apt install -y mongodb
111
+ ```
112
+
113
+ ### 1- Dev Environment
114
+
115
+ ```bash
116
+ # Initialize python virtual environment and install dependencies
117
+ ./scripts/setup_dev_env.sh
118
+
119
+ pre-commit run --all-files
120
+ ```
121
+
122
+ ### 2- Build and Run Application on Docker
123
+
124
+ ```bash
125
+ ./scripts/dev-in-container.sh
126
+ ```
127
+
128
+ ```bash
129
+ ./scripts/test_portman.sh
130
+ ```
131
+
@@ -0,0 +1,93 @@
1
+ # fastapi_factory_utilities
2
+
3
+ Project Empty for Python with Poetry
4
+
5
+ ## Setup
6
+
7
+ ### Dev Tools
8
+
9
+ #### Python
10
+
11
+ <https://www.python.org/downloads/>
12
+
13
+ ```bash
14
+ sudo apt install software-properties-common -y
15
+ sudo add-apt-repository ppa:deadsnakes/ppa
16
+ sudo apt update
17
+ sudo apt install python3.12 -y
18
+ ```
19
+
20
+ #### Poetry
21
+
22
+ <https://python-poetry.org/>
23
+
24
+ ```bash
25
+ curl -sSL https://install.python-poetry.org | python3.12 -
26
+ ```
27
+
28
+ #### Pre-commit
29
+
30
+ Included in the project while in virtual environment
31
+ <https://pre-commit.com/>
32
+
33
+ #### Docker
34
+
35
+ <https://docs.docker.com/get-docker/>
36
+
37
+ #### Skaffold
38
+
39
+ <https://skaffold.dev>
40
+
41
+ ```bash
42
+ curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64
43
+ chmod +x skaffold
44
+ sudo mv skaffold /usr/local/bin
45
+ ```
46
+
47
+ #### Buildpacks
48
+
49
+ <https://buildpacks.io/>
50
+
51
+ ```bash
52
+ sudo add-apt-repository ppa:cncf-buildpacks/pack-cli
53
+ sudo apt-get update
54
+ sudo apt-get install pack-cli
55
+ ```
56
+
57
+ #### Paketo
58
+
59
+ Included with the usage of buildpacks
60
+ <https://paketo.io/>
61
+
62
+ #### Portman
63
+
64
+ ```bash
65
+ npm install -g @apideck/portman
66
+ ```
67
+
68
+ ### MongoDB
69
+
70
+ <https://docs.mongodb.com/manual/installation/>
71
+
72
+ ```bash
73
+ sudo apt install -y mongodb
74
+ ```
75
+
76
+ ### 1- Dev Environment
77
+
78
+ ```bash
79
+ # Initialize python virtual environment and install dependencies
80
+ ./scripts/setup_dev_env.sh
81
+
82
+ pre-commit run --all-files
83
+ ```
84
+
85
+ ### 2- Build and Run Application on Docker
86
+
87
+ ```bash
88
+ ./scripts/dev-in-container.sh
89
+ ```
90
+
91
+ ```bash
92
+ ./scripts/test_portman.sh
93
+ ```
@@ -0,0 +1,133 @@
1
+ [tool.poetry]
2
+ name = "fastapi_factory_utilities"
3
+ homepage = "https://github.com/miragecentury/fastapi_factory_utilities"
4
+ repository = "https://github.com/miragecentury/fastapi_factory_utilities"
5
+ keywords = ["python", "fastapi", "beanie", "httpx", "opentelemetry", "microservices"]
6
+ version = "0.1.0"
7
+ description = "Consolidate libraries and utilities to create microservices in Python with FastAPI, Beanie, Httpx, AioPika and OpenTelemetry."
8
+ authors = ["miragecentury <victorien.vanroye@gmail.com>"]
9
+ maintainers = ["miragecentury <victorien.vanroye@gmail.com>"]
10
+ license = "MIT"
11
+ readme = "README.md"
12
+ packages = [
13
+ { include = "fastapi_factory_utilities", from = "src" },
14
+ ]
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3.12",
17
+ "Development Status :: 3 - Alpha",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent",
20
+ "Intended Audience :: Developers",
21
+ "Topic :: Software Development :: Libraries",
22
+ "Topic :: Software Development :: Libraries :: Python Modules",
23
+ "Topic :: Software Development :: Libraries :: Application Frameworks",
24
+ ]
25
+
26
+ [tool.poetry.dependencies]
27
+ python = "~3.12"
28
+ structlog = "^24.1.0"
29
+ typer = "^0.15.1"
30
+ pydantic = "^2.8.2"
31
+ fastapi = "^0.115.4"
32
+ uvicorn = "^0.32.0"
33
+ opentelemetry-sdk = "^1.26.0"
34
+ opentelemetry-exporter-otlp-proto-http = "^1.26.0"
35
+ httpx = "^0.28.1"
36
+ opentelemetry-instrumentation-fastapi = "^0.49b1"
37
+ opentelemetry-propagator-b3 = "^1.26.0"
38
+ beanie = "^1.27.0"
39
+ opentelemetry-instrumentation-pymongo = "^0.49b2"
40
+ pymongo = "~4.9.2" # version fixed to fix integration between beanie and pytest-mongo
41
+
42
+ [tool.poetry.group.test]
43
+ optional = true
44
+
45
+ [tool.poetry.group.test.dependencies]
46
+ mypy = "^1.10.0"
47
+ types-requests = "^2.32.0.20240712"
48
+ types-pyyaml = "^6.0.12.20240311"
49
+ pylint = {version="^3.2.2", extras=["spelling"]}
50
+ black = "^24.4.2"
51
+ pre-commit = "^4.0.1"
52
+ pyupgrade = "^3.15.2"
53
+ pytest = "^8.2.0"
54
+ pytest-xdist = "^3.6.1"
55
+ pytest-cov = "^6.0.0"
56
+ ruff = "^0.7.2"
57
+ pytest-asyncio = "^0.25.0"
58
+ pytest-mongo = "^3.1.0"
59
+ locust = "^2.32.4"
60
+ testcontainers = { version="^4.9.0", extras=["mongodb"] }
61
+ types-deprecated = "^1.2.15.20241117"
62
+ types-pygments = "^2.18.0.20240506"
63
+ types-colorama = "^0.4.15.20240311"
64
+ types-protobuf = "^5.29.1.20241207"
65
+ types-psutil = "^6.1.0.20241221"
66
+ types-pyopenssl = "^24.1.0.20240722"
67
+ types-ujson = "^5.10.0.20240515"
68
+
69
+ [tool.poetry.extras]
70
+
71
+ [tool.poetry.scripts]
72
+ fastapi_factory_utilities-example = "fastapi_factory_utilities.example.__main__:main"
73
+
74
+ [build-system]
75
+ requires = ["poetry-core"]
76
+ build-backend = "poetry.core.masonry.api"
77
+
78
+ [tool.pytest.ini_options]
79
+ addopts = "tests/units tests/integrations -n auto --color=yes --import-mode=importlib"
80
+ filterwarnings = [
81
+ "ignore:.*Type google._upb._message.MessageMapContainer:DeprecationWarning",
82
+ "ignore:.*Type google._upb._message.ScalarMapContainer:DeprecationWarning",
83
+ "ignore:.*pkg_resources is deprecated as an API.:DeprecationWarning",
84
+ ]
85
+ asyncio_mode = "auto"
86
+ asyncio_default_fixture_loop_scope = "session"
87
+ mongo_params = ""
88
+
89
+ [tool.black]
90
+ line-length = 120
91
+ target-version = ['py312']
92
+
93
+ [tool.isort]
94
+ profile = "black"
95
+
96
+ [tool.mypy]
97
+ python_version = "3.12"
98
+ warn_unused_configs = true
99
+ packages = "fastapi_factory_utilities"
100
+ mypy_path = "src:tests"
101
+ namespace_packages = true
102
+ plugins = ["pydantic.mypy"]
103
+ follow_imports = "silent"
104
+ warn_redundant_casts = true
105
+ warn_unused_ignores = true
106
+ disallow_any_generics = true
107
+ check_untyped_defs = true
108
+ no_implicit_reexport = true
109
+
110
+ # for strict mypy: (this is the tricky one :-))
111
+ disallow_untyped_defs = true
112
+
113
+ [tool.pydantic-mypy]
114
+ init_forbid_extra = true
115
+ init_typed = true
116
+ warn_required_dynamic_aliases = true
117
+
118
+ [tool.ruff]
119
+ # Same as Black.
120
+ line-length = 120
121
+ indent-width = 4
122
+
123
+ [tool.ruff.lint]
124
+ select = ["D","F","E","W","I","UP","PL","N","RUF"]
125
+
126
+ [tool.ruff.format]
127
+ quote-style = "double"
128
+ indent-style = "space"
129
+ docstring-code-format = true
130
+ docstring-code-line-length = 120
131
+
132
+ [tool.ruff.lint.pydocstyle]
133
+ convention = "google"
@@ -0,0 +1,6 @@
1
+ """Re-Use the main function from the example module."""
2
+
3
+ from fastapi_factory_utilities.example import main
4
+
5
+ if __name__ == "__main__":
6
+ main()
@@ -0,0 +1 @@
1
+ """Python Factory Core Module."""
@@ -0,0 +1,25 @@
1
+ """Define the API for the Python Factory."""
2
+
3
+ from fastapi import APIRouter
4
+
5
+ from .tags import TagEnum
6
+ from .v1.sys import api_v1_sys
7
+
8
+ api: APIRouter = APIRouter(prefix="/api")
9
+
10
+ ### API v1 ###
11
+ # Prefix the API with /api/v1
12
+ api_v1: APIRouter = APIRouter(prefix="/v1")
13
+ api_v1.include_router(router=api_v1_sys)
14
+
15
+
16
+ ### API v2 ###
17
+ # Prefix the API with /api/v2
18
+ api_v2: APIRouter = APIRouter(prefix="/v2")
19
+
20
+
21
+ ### Include the API routers ###
22
+ api.include_router(router=api_v1)
23
+ api.include_router(router=api_v2)
24
+
25
+ __all__: list[str] = ["api", "TagEnum"]
@@ -0,0 +1,9 @@
1
+ """Provides the Tag as Enum."""
2
+
3
+ from enum import StrEnum, auto
4
+
5
+
6
+ class TagEnum(StrEnum):
7
+ """Define Tag for OpenAPI Description."""
8
+
9
+ SYS = auto()
@@ -0,0 +1,12 @@
1
+ """Package for system related API endpoints."""
2
+
3
+ from fastapi import APIRouter
4
+
5
+ from .health import api_v1_sys_health
6
+ from .readiness import api_v1_sys_readiness
7
+
8
+ api_v1_sys = APIRouter(prefix="/sys")
9
+ api_v1_sys.include_router(router=api_v1_sys_health)
10
+ api_v1_sys.include_router(router=api_v1_sys_readiness)
11
+
12
+ __all__: list[str] = ["api_v1_sys"]
@@ -0,0 +1,53 @@
1
+ """API v1 sys health module.
2
+
3
+ Provide the Get health endpoint
4
+ """
5
+
6
+ from enum import StrEnum
7
+ from http import HTTPStatus
8
+
9
+ from fastapi import APIRouter, Response
10
+ from pydantic import BaseModel
11
+
12
+ api_v1_sys_health = APIRouter(prefix="/health")
13
+
14
+
15
+ class HealthStatusEnum(StrEnum):
16
+ """Health status enum."""
17
+
18
+ HEALTHY = "healthy"
19
+ UNHEALTHY = "unhealthy"
20
+
21
+
22
+ class HealthResponseModel(BaseModel):
23
+ """Health response schema."""
24
+
25
+ status: HealthStatusEnum
26
+
27
+
28
+ @api_v1_sys_health.get(
29
+ path="",
30
+ tags=["sys"],
31
+ response_model=HealthResponseModel,
32
+ responses={
33
+ HTTPStatus.OK.value: {
34
+ "model": HealthResponseModel,
35
+ "description": "Health status.",
36
+ },
37
+ HTTPStatus.INTERNAL_SERVER_ERROR.value: {
38
+ "model": HealthResponseModel,
39
+ "description": "Internal server error.",
40
+ },
41
+ },
42
+ )
43
+ def get_api_v1_sys_health(response: Response) -> HealthResponseModel:
44
+ """Get the health of the system.
45
+
46
+ Args:
47
+ response (Response): The response object.
48
+
49
+ Returns:
50
+ HealthResponse: The health status.
51
+ """
52
+ response.status_code = HTTPStatus.OK
53
+ return HealthResponseModel(status=HealthStatusEnum.HEALTHY)
@@ -0,0 +1,53 @@
1
+ """API v1 sys readiness module.
2
+
3
+ Provide the Get readiness endpoint
4
+ """
5
+
6
+ from enum import StrEnum
7
+ from http import HTTPStatus
8
+
9
+ from fastapi import APIRouter, Response
10
+ from pydantic import BaseModel
11
+
12
+ api_v1_sys_readiness = APIRouter(prefix="/readiness")
13
+
14
+
15
+ class ReadinessStatusEnum(StrEnum):
16
+ """Readiness status enum."""
17
+
18
+ READY = "ready"
19
+ NOT_READY = "not_ready"
20
+
21
+
22
+ class ReadinessResponseModel(BaseModel):
23
+ """Readiness response schema."""
24
+
25
+ status: ReadinessStatusEnum
26
+
27
+
28
+ @api_v1_sys_readiness.get(
29
+ path="",
30
+ tags=["sys"],
31
+ response_model=ReadinessResponseModel,
32
+ responses={
33
+ HTTPStatus.OK.value: {
34
+ "model": ReadinessResponseModel,
35
+ "description": "Readiness status.",
36
+ },
37
+ HTTPStatus.INTERNAL_SERVER_ERROR.value: {
38
+ "model": ReadinessResponseModel,
39
+ "description": "Internal server error.",
40
+ },
41
+ },
42
+ )
43
+ def get_api_v1_sys_readiness(response: Response) -> ReadinessResponseModel:
44
+ """Get the readiness of the system.
45
+
46
+ Args:
47
+ response (Response): The response object.
48
+
49
+ Returns:
50
+ ReadinessResponse: The readiness status.
51
+ """
52
+ response.status_code = HTTPStatus.OK
53
+ return ReadinessResponseModel(status=ReadinessStatusEnum.READY)
@@ -0,0 +1,19 @@
1
+ """Provides the core application module for the Python Factory."""
2
+
3
+ from .base import (
4
+ AppConfigAbstract,
5
+ ApplicationConfigFactoryException,
6
+ ApplicationFactoryException,
7
+ BaseApplication,
8
+ BaseApplicationException,
9
+ )
10
+ from .enums import EnvironmentEnum
11
+
12
+ __all__: list[str] = [
13
+ "BaseApplication",
14
+ "AppConfigAbstract",
15
+ "EnvironmentEnum",
16
+ "ApplicationConfigFactoryException",
17
+ "ApplicationFactoryException",
18
+ "BaseApplicationException",
19
+ ]
@@ -0,0 +1,17 @@
1
+ """Package for the base application, abstract config classes and related exceptions."""
2
+
3
+ from .application import BaseApplication
4
+ from .config_abstract import AppConfigAbstract
5
+ from .exceptions import (
6
+ ApplicationConfigFactoryException,
7
+ ApplicationFactoryException,
8
+ BaseApplicationException,
9
+ )
10
+
11
+ __all__: list[str] = [
12
+ "BaseApplication",
13
+ "AppConfigAbstract",
14
+ "ApplicationConfigFactoryException",
15
+ "ApplicationFactoryException",
16
+ "BaseApplicationException",
17
+ ]