fastapi-factory-utilities 0.3.0__py3-none-any.whl → 0.3.1__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.

@@ -2,7 +2,13 @@
2
2
 
3
3
  from .application import ApplicationAbstract
4
4
  from .builder import ApplicationGenericBuilder
5
- from .config import BaseApplicationConfig, RootConfig
5
+ from .config import (
6
+ BaseApplicationConfig,
7
+ DependencyConfig,
8
+ HttpServiceDependencyConfig,
9
+ RootConfig,
10
+ depends_dependency_config,
11
+ )
6
12
  from .enums import EnvironmentEnum
7
13
 
8
14
  __all__: list[str] = [
@@ -11,4 +17,7 @@ __all__: list[str] = [
11
17
  "ApplicationAbstract",
12
18
  "ApplicationGenericBuilder",
13
19
  "RootConfig",
20
+ "HttpServiceDependencyConfig",
21
+ "DependencyConfig",
22
+ "depends_dependency_config",
14
23
  ]
@@ -4,9 +4,22 @@ import datetime
4
4
  from abc import ABC
5
5
  from collections.abc import AsyncGenerator, Callable
6
6
  from contextlib import asynccontextmanager
7
- from typing import Any, Generic, TypeVar, get_args
7
+ from typing import (
8
+ Any,
9
+ Dict,
10
+ Generic,
11
+ List,
12
+ Mapping,
13
+ Optional,
14
+ Tuple,
15
+ TypeVar,
16
+ Union,
17
+ get_args,
18
+ )
8
19
  from uuid import UUID
9
20
 
21
+ from beanie import SortDirection
22
+ from beanie.odm.queries.find import FindMany
10
23
  from motor.motor_asyncio import AsyncIOMotorClientSession, AsyncIOMotorDatabase
11
24
  from pydantic import BaseModel
12
25
  from pymongo.errors import DuplicateKeyError, PyMongoError
@@ -214,3 +227,66 @@ class AbstractRepository(ABC, Generic[DocumentGenericType, EntityGenericType]):
214
227
  return
215
228
 
216
229
  raise OperationError("Failed to delete document.")
230
+
231
+ @managed_session()
232
+ async def find(
233
+ self,
234
+ *args: Union[Mapping[str, Any], bool],
235
+ projection_model: None = None,
236
+ skip: Optional[int] = None,
237
+ limit: Optional[int] = None,
238
+ sort: Union[None, str, List[Tuple[str, SortDirection]]] = None,
239
+ session: Optional[AsyncIOMotorClientSession] = None,
240
+ ignore_cache: bool = False,
241
+ fetch_links: bool = False,
242
+ lazy_parse: bool = False,
243
+ nesting_depth: Optional[int] = None,
244
+ nesting_depths_per_field: Optional[Dict[str, int]] = None,
245
+ **pymongo_kwargs: Any,
246
+ ) -> list[EntityGenericType]:
247
+ """Find documents in the database.
248
+
249
+ Args:
250
+ *args: The arguments to pass to the find method.
251
+ projection_model: The projection model to use.
252
+ skip: The number of documents to skip.
253
+ limit: The number of documents to return.
254
+ sort: The sort order.
255
+ session: The session to use.
256
+ ignore_cache: Whether to ignore the cache.
257
+ fetch_links: Whether to fetch links.
258
+ lazy_parse: Whether to lazy parse the documents.
259
+ nesting_depth: The nesting depth.
260
+ nesting_depths_per_field: The nesting depths per field.
261
+ **pymongo_kwargs: Additional keyword arguments to pass to the find method.
262
+
263
+ Returns:
264
+ list[EntityGenericType]: The list of entities.
265
+
266
+ Raises:
267
+ OperationError: If the operation fails.
268
+ ValueError: If the entity cannot be created from the document.
269
+ """
270
+ try:
271
+ documents: list[DocumentGenericType] = await self._document_type.find(
272
+ *args,
273
+ projection_model=projection_model,
274
+ skip=skip,
275
+ limit=limit,
276
+ sort=sort,
277
+ session=session,
278
+ ignore_cache=ignore_cache,
279
+ fetch_links=fetch_links,
280
+ lazy_parse=lazy_parse,
281
+ nesting_depth=nesting_depth,
282
+ nesting_depths_per_field=nesting_depths_per_field,
283
+ ).to_list()
284
+ except PyMongoError as error:
285
+ raise OperationError(f"Failed to find documents: {error}") from error
286
+
287
+ try:
288
+ entities: list[EntityGenericType] = [self._entity_type(**document.model_dump()) for document in documents]
289
+ except ValueError as error:
290
+ raise ValueError(f"Failed to create entity from document: {error}") from error
291
+
292
+ return entities
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: fastapi_factory_utilities
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: Consolidate libraries and utilities to create microservices in Python with FastAPI, Beanie, Httpx, AioPika and OpenTelemetry.
5
5
  License: MIT
6
6
  Keywords: python,fastapi,beanie,httpx,opentelemetry,microservices
@@ -5,7 +5,7 @@ fastapi_factory_utilities/core/api/tags.py,sha256=3hQcTeW0FS78sPTJ2PB44dMDTSkoW-
5
5
  fastapi_factory_utilities/core/api/v1/sys/__init__.py,sha256=mTXhpn3_KgQ1snt0-0PFmGvFr4n5srQRRADEdRSGFJM,345
6
6
  fastapi_factory_utilities/core/api/v1/sys/health.py,sha256=IF51Z1seOFn91m3FC57U8uWfAA7c_EhhBpjbu_ly9WQ,2807
7
7
  fastapi_factory_utilities/core/api/v1/sys/readiness.py,sha256=xIY8pQLShU7KWRtlOUK5gTDyZ8aB1KBvLczC6boT-tg,1711
8
- fastapi_factory_utilities/core/app/__init__.py,sha256=I04abOkkWiY9ChgkUNeiwnuWq8kkBoRAtMLBUKB7J7Y,405
8
+ fastapi_factory_utilities/core/app/__init__.py,sha256=IHHkcu3t-fX8vxQk12A36cE-yTjGn_PInDpL_OlRSE8,596
9
9
  fastapi_factory_utilities/core/app/application.py,sha256=WrDXh00r_jzQTtZGeFO43lIzvDraplitejTaSJj_uFE,5091
10
10
  fastapi_factory_utilities/core/app/builder.py,sha256=VbThqoI1qWnADwPQ61D774oNZ5d6OMxW0tyXr_Yz5E4,4503
11
11
  fastapi_factory_utilities/core/app/config.py,sha256=81KYoxB14TX05jMWujPNjLI1BXkvMnUyw2VgF7nJIE0,7063
@@ -25,7 +25,7 @@ fastapi_factory_utilities/core/plugins/odm_plugin/configs.py,sha256=zQoJC1wLNyq2
25
25
  fastapi_factory_utilities/core/plugins/odm_plugin/depends.py,sha256=OcLsfTLzMBk_xFV6qsMy_-qFkiphEbbEuaHUooagxg8,730
26
26
  fastapi_factory_utilities/core/plugins/odm_plugin/documents.py,sha256=BFQYHxHBmTacJRfhZi2OffvT_RAFvAAiDVQAa_d6Y7w,1141
27
27
  fastapi_factory_utilities/core/plugins/odm_plugin/exceptions.py,sha256=acnKJB0lGAzDs-7-LjBap8shjP3iV1a7dw7ouPVF27o,551
28
- fastapi_factory_utilities/core/plugins/odm_plugin/repositories.py,sha256=r880o--iVj3oK3yTenM5kgJwfFWKSUZa0bfnEwOukFE,8705
28
+ fastapi_factory_utilities/core/plugins/odm_plugin/repositories.py,sha256=56rZRcpyzFlClRbR4QO8cLJf6icsaUm3U10DzkOq2_E,11412
29
29
  fastapi_factory_utilities/core/plugins/opentelemetry_plugin/__init__.py,sha256=UsXPjiAASn5GIHW8vrF32mklxGNq8ajILV-ty4K1Tbs,4371
30
30
  fastapi_factory_utilities/core/plugins/opentelemetry_plugin/builder.py,sha256=9npQImifYAbEg0lFG7KwZ8V78SNrPoaINgd8vKitdMw,12509
31
31
  fastapi_factory_utilities/core/plugins/opentelemetry_plugin/configs.py,sha256=pMG9leMB7rtdkdGFLIxXflV7bf9epGrrYPt2N97KZcM,3750
@@ -71,8 +71,8 @@ fastapi_factory_utilities/example/models/books/repository.py,sha256=7K63uAsSEGZ2
71
71
  fastapi_factory_utilities/example/services/books/__init__.py,sha256=Z06yNRoA7Zg3TGN-Q9rrvJg6Bbx-qJw661MVwukV6vQ,148
72
72
  fastapi_factory_utilities/example/services/books/services.py,sha256=-x7d4hotUWLzWo5uImMjFmtNcSTHwWv2bfttIbYYKbA,5380
73
73
  fastapi_factory_utilities/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
- fastapi_factory_utilities-0.3.0.dist-info/LICENSE,sha256=iO1nLzMMst6vEiqgSUrfrbetM7b0bvdzXhbed5tqG8o,1074
75
- fastapi_factory_utilities-0.3.0.dist-info/METADATA,sha256=Leqepw4j2B1UqEphj5J1M-w_miwtf0RX7KQql4Q_WN4,3477
76
- fastapi_factory_utilities-0.3.0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
77
- fastapi_factory_utilities-0.3.0.dist-info/entry_points.txt,sha256=IK0VcBexXo4uXQmTrbfhhnnfq4GmXPRn0GBB8hzlsq4,101
78
- fastapi_factory_utilities-0.3.0.dist-info/RECORD,,
74
+ fastapi_factory_utilities-0.3.1.dist-info/LICENSE,sha256=iO1nLzMMst6vEiqgSUrfrbetM7b0bvdzXhbed5tqG8o,1074
75
+ fastapi_factory_utilities-0.3.1.dist-info/METADATA,sha256=EF9C_1EW1EvdkTtdzsKjmOlW4o4BgBfi-RXXNtRERDc,3477
76
+ fastapi_factory_utilities-0.3.1.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
77
+ fastapi_factory_utilities-0.3.1.dist-info/entry_points.txt,sha256=IK0VcBexXo4uXQmTrbfhhnnfq4GmXPRn0GBB8hzlsq4,101
78
+ fastapi_factory_utilities-0.3.1.dist-info/RECORD,,