fastapi-factory-utilities 0.1.0__py3-none-any.whl
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.
- fastapi_factory_utilities/__main__.py +6 -0
- fastapi_factory_utilities/core/__init__.py +1 -0
- fastapi_factory_utilities/core/api/__init__.py +25 -0
- fastapi_factory_utilities/core/api/tags.py +9 -0
- fastapi_factory_utilities/core/api/v1/sys/__init__.py +12 -0
- fastapi_factory_utilities/core/api/v1/sys/health.py +53 -0
- fastapi_factory_utilities/core/api/v1/sys/readiness.py +53 -0
- fastapi_factory_utilities/core/app/__init__.py +19 -0
- fastapi_factory_utilities/core/app/base/__init__.py +17 -0
- fastapi_factory_utilities/core/app/base/application.py +123 -0
- fastapi_factory_utilities/core/app/base/config_abstract.py +78 -0
- fastapi_factory_utilities/core/app/base/exceptions.py +25 -0
- fastapi_factory_utilities/core/app/base/fastapi_application_abstract.py +88 -0
- fastapi_factory_utilities/core/app/base/plugins_manager_abstract.py +136 -0
- fastapi_factory_utilities/core/app/enums.py +11 -0
- fastapi_factory_utilities/core/plugins/__init__.py +15 -0
- fastapi_factory_utilities/core/plugins/odm_plugin/__init__.py +97 -0
- fastapi_factory_utilities/core/plugins/odm_plugin/builder.py +239 -0
- fastapi_factory_utilities/core/plugins/odm_plugin/configs.py +17 -0
- fastapi_factory_utilities/core/plugins/odm_plugin/documents.py +31 -0
- fastapi_factory_utilities/core/plugins/odm_plugin/exceptions.py +25 -0
- fastapi_factory_utilities/core/plugins/odm_plugin/repositories.py +172 -0
- fastapi_factory_utilities/core/plugins/opentelemetry_plugin/__init__.py +124 -0
- fastapi_factory_utilities/core/plugins/opentelemetry_plugin/builder.py +266 -0
- fastapi_factory_utilities/core/plugins/opentelemetry_plugin/configs.py +103 -0
- fastapi_factory_utilities/core/plugins/opentelemetry_plugin/exceptions.py +13 -0
- fastapi_factory_utilities/core/plugins/opentelemetry_plugin/helpers.py +42 -0
- fastapi_factory_utilities/core/protocols.py +82 -0
- fastapi_factory_utilities/core/utils/configs.py +80 -0
- fastapi_factory_utilities/core/utils/importlib.py +28 -0
- fastapi_factory_utilities/core/utils/log.py +178 -0
- fastapi_factory_utilities/core/utils/uvicorn.py +45 -0
- fastapi_factory_utilities/core/utils/yaml_reader.py +166 -0
- fastapi_factory_utilities/example/__init__.py +11 -0
- fastapi_factory_utilities/example/__main__.py +6 -0
- fastapi_factory_utilities/example/api/__init__.py +19 -0
- fastapi_factory_utilities/example/api/books/__init__.py +5 -0
- fastapi_factory_utilities/example/api/books/responses.py +26 -0
- fastapi_factory_utilities/example/api/books/routes.py +62 -0
- fastapi_factory_utilities/example/app/__init__.py +6 -0
- fastapi_factory_utilities/example/app/app.py +37 -0
- fastapi_factory_utilities/example/app/config.py +12 -0
- fastapi_factory_utilities/example/application.yaml +26 -0
- fastapi_factory_utilities/example/entities/books/__init__.py +7 -0
- fastapi_factory_utilities/example/entities/books/entities.py +16 -0
- fastapi_factory_utilities/example/entities/books/enums.py +16 -0
- fastapi_factory_utilities/example/entities/books/types.py +54 -0
- fastapi_factory_utilities/example/models/__init__.py +1 -0
- fastapi_factory_utilities/example/models/books/__init__.py +6 -0
- fastapi_factory_utilities/example/models/books/document.py +20 -0
- fastapi_factory_utilities/example/models/books/repository.py +11 -0
- fastapi_factory_utilities/example/services/books/__init__.py +5 -0
- fastapi_factory_utilities/example/services/books/services.py +167 -0
- fastapi_factory_utilities-0.1.0.dist-info/LICENSE +21 -0
- fastapi_factory_utilities-0.1.0.dist-info/METADATA +131 -0
- fastapi_factory_utilities-0.1.0.dist-info/RECORD +58 -0
- fastapi_factory_utilities-0.1.0.dist-info/WHEEL +4 -0
- fastapi_factory_utilities-0.1.0.dist-info/entry_points.txt +3 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
application:
|
|
3
|
+
service_name: fastapi_factory_utilities_example
|
|
4
|
+
service_namespace: fastapi_factory_utilities_example
|
|
5
|
+
title: Python Factory Example
|
|
6
|
+
description: An example application for Python Factory
|
|
7
|
+
version: 0.1.0
|
|
8
|
+
environment: ${ENVIRONMENT:development}
|
|
9
|
+
debug: ${APPLICATION_DEBUG:false}
|
|
10
|
+
reload: ${APPLICATION_RELOAD:false}
|
|
11
|
+
|
|
12
|
+
plugins:
|
|
13
|
+
activate:
|
|
14
|
+
- opentelemetry_plugin
|
|
15
|
+
- odm_plugin
|
|
16
|
+
|
|
17
|
+
opentelemetry:
|
|
18
|
+
activate: "${OTEL_ACTIVE:false}"
|
|
19
|
+
|
|
20
|
+
odm:
|
|
21
|
+
uri: "${MONGO_URI:mongodb://localhost:27017}"
|
|
22
|
+
database: "test"
|
|
23
|
+
|
|
24
|
+
logging:
|
|
25
|
+
- name: pymongo
|
|
26
|
+
level: INFO
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Provides the Book entity."""
|
|
2
|
+
|
|
3
|
+
from uuid import UUID, uuid4
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel, Field
|
|
6
|
+
|
|
7
|
+
from .enums import BookType
|
|
8
|
+
from .types import BookName
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class BookEntity(BaseModel):
|
|
12
|
+
"""Book entity."""
|
|
13
|
+
|
|
14
|
+
id: UUID = Field(title="Unique identifier of the book", default_factory=uuid4)
|
|
15
|
+
title: BookName = Field(title="Title of the book")
|
|
16
|
+
book_type: BookType = Field(title="Type of book")
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Provides enums for the books service."""
|
|
2
|
+
|
|
3
|
+
from enum import StrEnum, auto
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class BookType(StrEnum):
|
|
7
|
+
"""Enumeration of book types."""
|
|
8
|
+
|
|
9
|
+
SCIENCE_FICTION = auto()
|
|
10
|
+
FANTASY = auto()
|
|
11
|
+
MYSTERY = auto()
|
|
12
|
+
ROMANCE = auto()
|
|
13
|
+
THRILLER = auto()
|
|
14
|
+
HORROR = auto()
|
|
15
|
+
HISTORICAL_FICTION = auto()
|
|
16
|
+
ADVENTURE = auto()
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Provides types for the books service."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, cast
|
|
4
|
+
|
|
5
|
+
from pydantic import GetCoreSchemaHandler
|
|
6
|
+
from pydantic_core import core_schema
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class BookName(str):
|
|
10
|
+
"""Book name type."""
|
|
11
|
+
|
|
12
|
+
MIN_LENGTH: int = 1
|
|
13
|
+
MAX_LENGTH: int = 100
|
|
14
|
+
|
|
15
|
+
def __new__(cls, value: str) -> "BookName":
|
|
16
|
+
"""Create a new instance of BookName."""
|
|
17
|
+
return super().__new__(cls, cls.validate(value))
|
|
18
|
+
|
|
19
|
+
@classmethod
|
|
20
|
+
def __get_pydantic_core_schema__(cls, source: type[Any], handler: GetCoreSchemaHandler) -> core_schema.CoreSchema:
|
|
21
|
+
"""Get the Pydantic core schema for the book name.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
source (Type[Any]): Source type.
|
|
25
|
+
handler (GetCoreSchemaHandler): Handler.
|
|
26
|
+
|
|
27
|
+
Returns:
|
|
28
|
+
core_schema.CoreSchema: Core schema.
|
|
29
|
+
"""
|
|
30
|
+
del source, handler
|
|
31
|
+
return cast(
|
|
32
|
+
core_schema.CoreSchema,
|
|
33
|
+
core_schema.no_info_after_validator_function(
|
|
34
|
+
function=cls.validate,
|
|
35
|
+
schema=core_schema.str_schema(min_length=cls.MIN_LENGTH, max_length=cls.MAX_LENGTH),
|
|
36
|
+
),
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
@classmethod
|
|
40
|
+
def validate(cls, value: str) -> str:
|
|
41
|
+
"""Validate the book name.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
value (str): Book name.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
str: Book name.
|
|
48
|
+
"""
|
|
49
|
+
if not cls.MIN_LENGTH <= len(value) <= cls.MAX_LENGTH:
|
|
50
|
+
raise ValueError(
|
|
51
|
+
f"Expected a string with length between {cls.MIN_LENGTH}" + f" and {cls.MAX_LENGTH}, got {len(value)}"
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
return value
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Provide Models."""
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Model for Book."""
|
|
2
|
+
|
|
3
|
+
from typing import Annotated
|
|
4
|
+
|
|
5
|
+
from beanie import Indexed # pyright: ignore[reportUnknownVariableType]
|
|
6
|
+
|
|
7
|
+
from fastapi_factory_utilities.core.plugins.odm_plugin.documents import BaseDocument
|
|
8
|
+
from fastapi_factory_utilities.example.entities.books import BookName, BookType
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class BookDocument(BaseDocument):
|
|
12
|
+
"""BookModel."""
|
|
13
|
+
|
|
14
|
+
title: Annotated[BookName, Indexed(unique=True)]
|
|
15
|
+
book_type: Annotated[BookType, Indexed()]
|
|
16
|
+
|
|
17
|
+
class Settings(BaseDocument.Settings):
|
|
18
|
+
"""Meta class for BookModel."""
|
|
19
|
+
|
|
20
|
+
collection: str = "books"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Repository for books."""
|
|
2
|
+
|
|
3
|
+
from fastapi_factory_utilities.core.plugins.odm_plugin.repositories import (
|
|
4
|
+
AbstractRepository,
|
|
5
|
+
)
|
|
6
|
+
from fastapi_factory_utilities.example.entities.books import BookEntity
|
|
7
|
+
from fastapi_factory_utilities.example.models.books.document import BookDocument
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class BookRepository(AbstractRepository[BookDocument, BookEntity]):
|
|
11
|
+
"""Repository for books."""
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"""Provides services for books."""
|
|
2
|
+
|
|
3
|
+
from typing import ClassVar
|
|
4
|
+
from uuid import UUID
|
|
5
|
+
|
|
6
|
+
from opentelemetry import metrics
|
|
7
|
+
|
|
8
|
+
from fastapi_factory_utilities.core.plugins.opentelemetry_plugin.helpers import (
|
|
9
|
+
trace_span,
|
|
10
|
+
)
|
|
11
|
+
from fastapi_factory_utilities.example.entities.books import (
|
|
12
|
+
BookEntity,
|
|
13
|
+
BookName,
|
|
14
|
+
BookType,
|
|
15
|
+
)
|
|
16
|
+
from fastapi_factory_utilities.example.models.books.repository import BookRepository
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class BookService:
|
|
20
|
+
"""Provides services for books."""
|
|
21
|
+
|
|
22
|
+
book_store: ClassVar[dict[UUID, BookEntity]] = {}
|
|
23
|
+
|
|
24
|
+
# Metrics Definitions
|
|
25
|
+
METER_COUNTER_BOOK_GET_NAME: str = "book_get"
|
|
26
|
+
METER_COUNTER_BOOK_ADD_NAME: str = "book_add"
|
|
27
|
+
METER_COUNTER_BOOK_REMOVE_NAME: str = "book_remove"
|
|
28
|
+
METER_COUNTER_BOOK_UPDATE_NAME: str = "book_update"
|
|
29
|
+
# ====================
|
|
30
|
+
|
|
31
|
+
meter: metrics.Meter = metrics.get_meter(__name__)
|
|
32
|
+
|
|
33
|
+
METER_COUNTER_BOOK_GET: metrics.Counter = meter.create_counter(
|
|
34
|
+
name=METER_COUNTER_BOOK_GET_NAME, description="The number of books retrieved."
|
|
35
|
+
)
|
|
36
|
+
METER_COUNTER_BOOK_ADD: metrics.Counter = meter.create_counter(
|
|
37
|
+
name=METER_COUNTER_BOOK_ADD_NAME,
|
|
38
|
+
description="The number of books added.",
|
|
39
|
+
)
|
|
40
|
+
METER_COUNTER_BOOK_REMOVE: metrics.Counter = meter.create_counter(
|
|
41
|
+
name=METER_COUNTER_BOOK_REMOVE_NAME,
|
|
42
|
+
description="The number of books removed.",
|
|
43
|
+
)
|
|
44
|
+
METER_COUNTER_BOOK_UPDATE: metrics.Counter = meter.create_counter(
|
|
45
|
+
name=METER_COUNTER_BOOK_UPDATE_NAME,
|
|
46
|
+
description="The number of books updated.",
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
def __init__(
|
|
50
|
+
self,
|
|
51
|
+
book_repository: BookRepository,
|
|
52
|
+
) -> None:
|
|
53
|
+
"""Initialize the service.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
book_repository (injector.Inject[BookRepository]): The book repository.
|
|
57
|
+
meter (metrics.Meter, optional): The meter. Defaults to None use for testing purpose.
|
|
58
|
+
|
|
59
|
+
Raises:
|
|
60
|
+
ValueError: If the book already exists.
|
|
61
|
+
|
|
62
|
+
"""
|
|
63
|
+
self.book_repository: BookRepository = book_repository
|
|
64
|
+
|
|
65
|
+
# Build the book store if it is empty
|
|
66
|
+
if len(self.book_store) == 0:
|
|
67
|
+
self.build_book_store()
|
|
68
|
+
|
|
69
|
+
@classmethod
|
|
70
|
+
def build_default_book_store(cls) -> list[BookEntity]:
|
|
71
|
+
"""Build the default book store."""
|
|
72
|
+
return [
|
|
73
|
+
BookEntity(title=BookName("Book 1"), book_type=BookType.FANTASY),
|
|
74
|
+
BookEntity(title=BookName("Book 2"), book_type=BookType.MYSTERY),
|
|
75
|
+
BookEntity(title=BookName("Book 3"), book_type=BookType.SCIENCE_FICTION),
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
@classmethod
|
|
79
|
+
def build_book_store(cls, books: list[BookEntity] | None = None) -> None:
|
|
80
|
+
"""Build the book store.
|
|
81
|
+
|
|
82
|
+
Args:
|
|
83
|
+
books (list[BookEntity], optional): The books to add. Defaults to None.
|
|
84
|
+
"""
|
|
85
|
+
if books is None:
|
|
86
|
+
books = cls.build_default_book_store()
|
|
87
|
+
|
|
88
|
+
cls.book_store = {book.id: book for book in books}
|
|
89
|
+
|
|
90
|
+
@trace_span(name="Add Book")
|
|
91
|
+
def add_book(self, book: BookEntity) -> None:
|
|
92
|
+
"""Add a book.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
book (BookEntity): The book to add
|
|
96
|
+
|
|
97
|
+
Raises:
|
|
98
|
+
ValueError: If the book already exists.
|
|
99
|
+
"""
|
|
100
|
+
if book.id in self.book_store:
|
|
101
|
+
raise ValueError(f"Book with id {book.id} already exists.")
|
|
102
|
+
|
|
103
|
+
self.book_store[book.id] = book
|
|
104
|
+
|
|
105
|
+
self.METER_COUNTER_BOOK_ADD.add(amount=1)
|
|
106
|
+
|
|
107
|
+
def get_book(self, book_id: UUID) -> BookEntity:
|
|
108
|
+
"""Get a book.
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
book_id (UUID): The book id
|
|
112
|
+
|
|
113
|
+
Returns:
|
|
114
|
+
BookEntity: The book
|
|
115
|
+
|
|
116
|
+
Raises:
|
|
117
|
+
ValueError: If the book does not exist.
|
|
118
|
+
"""
|
|
119
|
+
if book_id not in self.book_store:
|
|
120
|
+
raise ValueError(f"Book with id {book_id} does not exist.")
|
|
121
|
+
|
|
122
|
+
self.METER_COUNTER_BOOK_GET.add(amount=1, attributes={"book_count": 1})
|
|
123
|
+
|
|
124
|
+
return self.book_store[book_id]
|
|
125
|
+
|
|
126
|
+
def get_all_books(self) -> list[BookEntity]:
|
|
127
|
+
"""Get all books.
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
list[BookEntity]: All books
|
|
131
|
+
"""
|
|
132
|
+
self.METER_COUNTER_BOOK_GET.add(amount=1, attributes={"book_count": len(self.book_store)})
|
|
133
|
+
return list(self.book_store.values())
|
|
134
|
+
|
|
135
|
+
@trace_span(name="Remove Book")
|
|
136
|
+
def remove_book(self, book_id: UUID) -> None:
|
|
137
|
+
"""Remove a book.
|
|
138
|
+
|
|
139
|
+
Args:
|
|
140
|
+
book_id (UUID): The book id
|
|
141
|
+
|
|
142
|
+
Raises:
|
|
143
|
+
ValueError: If the book does not exist.
|
|
144
|
+
"""
|
|
145
|
+
if book_id not in self.book_store:
|
|
146
|
+
raise ValueError(f"Book with id {book_id} does not exist.")
|
|
147
|
+
|
|
148
|
+
del self.book_store[book_id]
|
|
149
|
+
|
|
150
|
+
self.METER_COUNTER_BOOK_REMOVE.add(amount=1)
|
|
151
|
+
|
|
152
|
+
@trace_span(name="Update Book")
|
|
153
|
+
def update_book(self, book: BookEntity) -> None:
|
|
154
|
+
"""Update a book.
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
book (BookEntity): The book to update
|
|
158
|
+
|
|
159
|
+
Raises:
|
|
160
|
+
ValueError: If the book does not exist.
|
|
161
|
+
"""
|
|
162
|
+
if book.id not in self.book_store:
|
|
163
|
+
raise ValueError(f"Book with id {book.id} does not exist.")
|
|
164
|
+
|
|
165
|
+
self.book_store[book.id] = book
|
|
166
|
+
|
|
167
|
+
self.METER_COUNTER_BOOK_UPDATE.add(amount=1)
|
|
@@ -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,58 @@
|
|
|
1
|
+
fastapi_factory_utilities/__main__.py,sha256=w8o9KpyHcxGyLHmTK8ixbIqJIsB3NbIGuAMY7OfnxrA,147
|
|
2
|
+
fastapi_factory_utilities/core/__init__.py,sha256=tt5a-MgeFt_oACkc9K5xl2rynIbca9DGqsKBDEqGzto,34
|
|
3
|
+
fastapi_factory_utilities/core/api/__init__.py,sha256=eehUFVDPk07MUPIorGdC8WqDRB8NjdSy7Za55CdLrps,542
|
|
4
|
+
fastapi_factory_utilities/core/api/tags.py,sha256=3hQcTeW0FS78sPTJ2PB44dMDTSkoW-xKj7rrfKX2Lk0,154
|
|
5
|
+
fastapi_factory_utilities/core/api/v1/sys/__init__.py,sha256=mTXhpn3_KgQ1snt0-0PFmGvFr4n5srQRRADEdRSGFJM,345
|
|
6
|
+
fastapi_factory_utilities/core/api/v1/sys/health.py,sha256=1c2B6x0yH-yDflwE5GFJf69cVQgnHiVCjVbCmjk_MaU,1208
|
|
7
|
+
fastapi_factory_utilities/core/api/v1/sys/readiness.py,sha256=OT_uL44gAOPnDiJGunwVl6yB5_RanbqEQtFAfOK5Xus,1265
|
|
8
|
+
fastapi_factory_utilities/core/app/__init__.py,sha256=SNStp3mA0_FPGUu5KFWhkXAe7vZJ8uhrJFO6h4hRqQ8,476
|
|
9
|
+
fastapi_factory_utilities/core/app/base/__init__.py,sha256=n04ypdWv1tup1I_oY7LMaGBPAjc35kARfYtGzFVGNFA,489
|
|
10
|
+
fastapi_factory_utilities/core/app/base/application.py,sha256=rtSi3gPq4PH2q72_xBtWxeEOYzYJfkMgecFBwLlbCXU,4155
|
|
11
|
+
fastapi_factory_utilities/core/app/base/config_abstract.py,sha256=lsFj4ix9hURzAuPv55rPi7YZ0hM_Ht2bG63n6wTkv9s,2735
|
|
12
|
+
fastapi_factory_utilities/core/app/base/exceptions.py,sha256=aEQqaOzNn5FZxzTtn0XpCw__BQj0CftIUWDVanpGUkE,531
|
|
13
|
+
fastapi_factory_utilities/core/app/base/fastapi_application_abstract.py,sha256=mUHxCzT-xjbMSHoFrHeNbaioWlZnJvBnqLVI6GyWKDk,2562
|
|
14
|
+
fastapi_factory_utilities/core/app/base/plugins_manager_abstract.py,sha256=RUfNq1WhR17BUuw9qF0ZNOLhMR3_wGq8zXGK5mIUrCg,5243
|
|
15
|
+
fastapi_factory_utilities/core/app/enums.py,sha256=X1upnaehYU0eHExXTde5xsH-pI9q7HZDNsOEF5PApdg,226
|
|
16
|
+
fastapi_factory_utilities/core/plugins/__init__.py,sha256=ZDIJj8EBiKqnjIP4kJ-XPOLL6l-OLEu9IMdD26zxHMM,233
|
|
17
|
+
fastapi_factory_utilities/core/plugins/odm_plugin/__init__.py,sha256=QJ5Q0Gg4vIkiNQ8oYTwPDX_xZHYK8-XgRISXZCsLdFA,3046
|
|
18
|
+
fastapi_factory_utilities/core/plugins/odm_plugin/builder.py,sha256=bvkvks6oCMaJ2-F4ZUdpSax3TGzxcOlbbaLkjZEAyEY,7938
|
|
19
|
+
fastapi_factory_utilities/core/plugins/odm_plugin/configs.py,sha256=R474FjbnH5cuUWRxlpG7lUlR1DVlYtpvCjp-vNjAFio,354
|
|
20
|
+
fastapi_factory_utilities/core/plugins/odm_plugin/documents.py,sha256=ENEB-Lm3T7_tN1xuIYPsUh8fpWj4aqh0xmrZt6vJCK0,1075
|
|
21
|
+
fastapi_factory_utilities/core/plugins/odm_plugin/exceptions.py,sha256=acnKJB0lGAzDs-7-LjBap8shjP3iV1a7dw7ouPVF27o,551
|
|
22
|
+
fastapi_factory_utilities/core/plugins/odm_plugin/repositories.py,sha256=Wxh5C_gnU4jY8H5qpvcFuSlaM1dLrsDXqxGuuaxwB68,6912
|
|
23
|
+
fastapi_factory_utilities/core/plugins/opentelemetry_plugin/__init__.py,sha256=m5bUdY8dHwtUgKXnUpY2Jri4kOfBKJsvo_x4YT2gEtA,4351
|
|
24
|
+
fastapi_factory_utilities/core/plugins/opentelemetry_plugin/builder.py,sha256=JLcnEEXqdDqjdo28AwdLp2msfddnJI2hhK8cUpUx-UU,9778
|
|
25
|
+
fastapi_factory_utilities/core/plugins/opentelemetry_plugin/configs.py,sha256=4mMa5SrmnPY1R_gVFRtFhi9WNaTGEGZL5iNNhyjcZQ0,3448
|
|
26
|
+
fastapi_factory_utilities/core/plugins/opentelemetry_plugin/exceptions.py,sha256=CpsHayfQpP0zghN8y5PP6TBy-cXhHoNxBR--I86gAdE,327
|
|
27
|
+
fastapi_factory_utilities/core/plugins/opentelemetry_plugin/helpers.py,sha256=qpTIzX67orJz7vy6SBIwRs24omMBoToJkhpurZRjPuk,1533
|
|
28
|
+
fastapi_factory_utilities/core/protocols.py,sha256=BeV5vDEotobA95OnzD3w5agH3TgCP3pLfR0crVoGvcg,2105
|
|
29
|
+
fastapi_factory_utilities/core/utils/configs.py,sha256=YQQ7XXBdUFul2XX6eV5pD2pAu084kvb8ECrWLKnO1kk,2567
|
|
30
|
+
fastapi_factory_utilities/core/utils/importlib.py,sha256=DYcPo7K0s95WV5xxtucpufWsTj8Pxv25sWunDmmNUYI,797
|
|
31
|
+
fastapi_factory_utilities/core/utils/log.py,sha256=6V9CL3bQio4e47YxcSXM2JQRGhVxuBfmcEbcF4RtCfQ,6393
|
|
32
|
+
fastapi_factory_utilities/core/utils/uvicorn.py,sha256=p6182q_SD4MVMmPwI67AJSj3z0pIDox71Y0gy8pu1-8,1361
|
|
33
|
+
fastapi_factory_utilities/core/utils/yaml_reader.py,sha256=G7F1SFynghUYjuTZTNotNW9OIiCaeGAWkcYvTFYsCMQ,6101
|
|
34
|
+
fastapi_factory_utilities/example/__init__.py,sha256=24Db3fKjJBVNKwtkFUbErVvh7_usjpK8yQBoH6bYtJA,186
|
|
35
|
+
fastapi_factory_utilities/example/__main__.py,sha256=Iwp_6rK7Lcv2F-XAKn6xjxQHOWjx2OjgwKAr91tfUfk,135
|
|
36
|
+
fastapi_factory_utilities/example/api/__init__.py,sha256=qI82eeSwVjR6jSkX1pxm8ALv9WPQ_iHurFY4G2K7VzE,554
|
|
37
|
+
fastapi_factory_utilities/example/api/books/__init__.py,sha256=zXARBnjywJwg1XsLbcixYWcHH4uC9mF-kbbX4P8cVgA,160
|
|
38
|
+
fastapi_factory_utilities/example/api/books/responses.py,sha256=21WeD6bdg0MCD_0vRHwmsL4W79iDcG9NnDLemXysc84,540
|
|
39
|
+
fastapi_factory_utilities/example/api/books/routes.py,sha256=vm4HFrEuX40qZTL__7C9lzaYX89G_nKnOB--USEotbo,1754
|
|
40
|
+
fastapi_factory_utilities/example/app/__init__.py,sha256=nqpeYhQJc_XPvjTdIChuniDAnU3tcAKBRFQyxfwzoU8,141
|
|
41
|
+
fastapi_factory_utilities/example/app/app.py,sha256=PxnfTkVr-Frp7j7jTZ1AD2npvqWsI01nDVO60mwtJNk,1279
|
|
42
|
+
fastapi_factory_utilities/example/app/config.py,sha256=A1Agngw7j-uo9BGKAwiqhPsfc-fflNmtAPx0hmUsC8U,247
|
|
43
|
+
fastapi_factory_utilities/example/application.yaml,sha256=nEblzDV_blyE849rWsFl-XHezpDUKahFTHzk5ex5DRo,578
|
|
44
|
+
fastapi_factory_utilities/example/entities/books/__init__.py,sha256=q2UTwLyCs3te38n7RgwT0go3Hp0bE9-NvoX7P-DR-3o,185
|
|
45
|
+
fastapi_factory_utilities/example/entities/books/entities.py,sha256=rLE01lE7U6WizrD5ZHMRwkynd8_dWF6DltBFH61f-Do,405
|
|
46
|
+
fastapi_factory_utilities/example/entities/books/enums.py,sha256=lXYUvhIkT1pi0teflMpnqeafeiBZMokyWxoFLgzV6a8,330
|
|
47
|
+
fastapi_factory_utilities/example/entities/books/types.py,sha256=7LYGPu-CcI3noIORJyIZlVF-CBugWPXEqgDzWrO3XmQ,1558
|
|
48
|
+
fastapi_factory_utilities/example/models/__init__.py,sha256=RJmp3R9bhbQv7n0WOlsHP65LqbEs_DjF9hzYKwYTRGo,22
|
|
49
|
+
fastapi_factory_utilities/example/models/books/__init__.py,sha256=1GJFCYMGZugQRxlFl-q7fPBFvNsl2ykeW8lV7rpURHU,181
|
|
50
|
+
fastapi_factory_utilities/example/models/books/document.py,sha256=lYJfMGr5GqEEsn7L--PFs75hC2q-jQx77wl7EhTrp5U,568
|
|
51
|
+
fastapi_factory_utilities/example/models/books/repository.py,sha256=7K63uAsSEGZ2EXqufU4Tc8KpymgXK8JX8WjAE2Sw8ok,387
|
|
52
|
+
fastapi_factory_utilities/example/services/books/__init__.py,sha256=zMCbkCa_g6QrW8VLHy661BlLFmBfcvUqJG8s1EW7GxI,102
|
|
53
|
+
fastapi_factory_utilities/example/services/books/services.py,sha256=Iy3VXCzGaAcxG3dklVEjeulArCni1UICGG1Aj1vKo8A,5056
|
|
54
|
+
fastapi_factory_utilities-0.1.0.dist-info/LICENSE,sha256=iO1nLzMMst6vEiqgSUrfrbetM7b0bvdzXhbed5tqG8o,1074
|
|
55
|
+
fastapi_factory_utilities-0.1.0.dist-info/METADATA,sha256=G6KBfLcQd1NZyQIuX-dZJRci6cuA3MZpElkSZXGMIgQ,3224
|
|
56
|
+
fastapi_factory_utilities-0.1.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
57
|
+
fastapi_factory_utilities-0.1.0.dist-info/entry_points.txt,sha256=IK0VcBexXo4uXQmTrbfhhnnfq4GmXPRn0GBB8hzlsq4,101
|
|
58
|
+
fastapi_factory_utilities-0.1.0.dist-info/RECORD,,
|