arpakitlib 1.5.30__py3-none-any.whl → 1.5.33__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.
- arpakitlib/ar_fastapi_util.py +15 -10
- arpakitlib/ar_operation_execution_util.py +2 -5
- arpakitlib/ar_story_log_util.py +37 -0
- {arpakitlib-1.5.30.dist-info → arpakitlib-1.5.33.dist-info}/METADATA +1 -1
- {arpakitlib-1.5.30.dist-info → arpakitlib-1.5.33.dist-info}/RECORD +8 -7
- {arpakitlib-1.5.30.dist-info → arpakitlib-1.5.33.dist-info}/LICENSE +0 -0
- {arpakitlib-1.5.30.dist-info → arpakitlib-1.5.33.dist-info}/NOTICE +0 -0
- {arpakitlib-1.5.30.dist-info → arpakitlib-1.5.33.dist-info}/WHEEL +0 -0
arpakitlib/ar_fastapi_util.py
CHANGED
@@ -6,6 +6,7 @@ import asyncio
|
|
6
6
|
import logging
|
7
7
|
import os.path
|
8
8
|
import pathlib
|
9
|
+
from datetime import datetime
|
9
10
|
from typing import Any, Callable
|
10
11
|
|
11
12
|
import fastapi.exceptions
|
@@ -52,6 +53,16 @@ class BaseAPISO(BaseAPISchema):
|
|
52
53
|
pass
|
53
54
|
|
54
55
|
|
56
|
+
class APISimpleDataSO(BaseAPISO):
|
57
|
+
data: dict[str, Any] = {}
|
58
|
+
|
59
|
+
|
60
|
+
class BaseAPISimpleSO(BaseAPISO):
|
61
|
+
id: int
|
62
|
+
long_id: str
|
63
|
+
creation_dt: datetime
|
64
|
+
|
65
|
+
|
55
66
|
class APIErrorSO(BaseAPISO):
|
56
67
|
class APIErrorCodes(EasyEnumeration):
|
57
68
|
cannot_authorize = "CANNOT_AUTHORIZE"
|
@@ -243,7 +254,7 @@ def add_ar_fastapi_static_docs_and_redoc_handlers_to_fastapi_app(
|
|
243
254
|
return fastapi_app
|
244
255
|
|
245
256
|
|
246
|
-
class
|
257
|
+
class BaseAPIEvent:
|
247
258
|
def __init__(self, *args, **kwargs):
|
248
259
|
self._logger = logging.getLogger(self.__class__.__name__)
|
249
260
|
|
@@ -251,11 +262,6 @@ class BaseAPIStartupEvent:
|
|
251
262
|
self._logger.info("on_startup starts")
|
252
263
|
self._logger.info("on_startup ends")
|
253
264
|
|
254
|
-
|
255
|
-
class BaseAPIShutdownEvent:
|
256
|
-
def __init__(self, *args, **kwargs):
|
257
|
-
self._logger = logging.getLogger(self.__class__.__name__)
|
258
|
-
|
259
265
|
async def on_shutdown(self, *args, **kwargs):
|
260
266
|
self._logger.info("on_shutdown starts")
|
261
267
|
self._logger.info("on_shutdown ends")
|
@@ -265,8 +271,7 @@ def create_fastapi_app(
|
|
265
271
|
*,
|
266
272
|
title: str,
|
267
273
|
description: str | None = None,
|
268
|
-
|
269
|
-
api_shutdown_event: BaseAPIShutdownEvent | None = BaseAPIShutdownEvent(),
|
274
|
+
api_event: BaseAPIEvent | None = BaseAPIEvent(),
|
270
275
|
api_handle_exception_: Callable | None = simple_api_handle_exception
|
271
276
|
):
|
272
277
|
app = FastAPI(
|
@@ -275,8 +280,8 @@ def create_fastapi_app(
|
|
275
280
|
docs_url=None,
|
276
281
|
redoc_url=None,
|
277
282
|
openapi_url="/openapi",
|
278
|
-
on_startup=[
|
279
|
-
on_shutdown=[
|
283
|
+
on_startup=[api_event.on_startup] if api_event else [],
|
284
|
+
on_shutdown=[api_event.on_shutdown] if api_event else []
|
280
285
|
)
|
281
286
|
|
282
287
|
add_middleware_cors_to_fastapi_app(fastapi_app=app)
|
@@ -16,7 +16,7 @@ from arpakitlib.ar_datetime_util import now_utc_dt
|
|
16
16
|
from arpakitlib.ar_dict_util import combine_dicts
|
17
17
|
from arpakitlib.ar_easy_sqlalchemy_util import EasySQLAlchemyDB
|
18
18
|
from arpakitlib.ar_enumeration import EasyEnumeration
|
19
|
-
from arpakitlib.ar_fastapi_util import BaseAPISO
|
19
|
+
from arpakitlib.ar_fastapi_util import BaseAPISO, BaseAPISimpleSO
|
20
20
|
from arpakitlib.ar_sqlalchemy_model_util import SimpleDBM
|
21
21
|
|
22
22
|
_ARPAKIT_LIB_MODULE_VERSION = "3.0"
|
@@ -78,10 +78,7 @@ class OperationDBM(SimpleDBM):
|
|
78
78
|
return self.duration.total_seconds()
|
79
79
|
|
80
80
|
|
81
|
-
class OperationSO(
|
82
|
-
id: int
|
83
|
-
long_id: str
|
84
|
-
creation_dt: datetime
|
81
|
+
class OperationSO(BaseAPISimpleSO):
|
85
82
|
execution_start_dt: datetime | None
|
86
83
|
execution_finish_dt: datetime | None
|
87
84
|
status: str
|
@@ -0,0 +1,37 @@
|
|
1
|
+
from datetime import datetime
|
2
|
+
from typing import Any
|
3
|
+
|
4
|
+
from sqlalchemy import TEXT
|
5
|
+
from sqlalchemy.dialects.postgresql import JSONB
|
6
|
+
from sqlalchemy.orm import Mapped, mapped_column
|
7
|
+
|
8
|
+
from arpakitlib.ar_enumeration import EasyEnumeration
|
9
|
+
from arpakitlib.ar_fastapi_util import BaseAPISO, BaseAPISimpleSO
|
10
|
+
from arpakitlib.ar_sqlalchemy_model_util import BaseDBM, SimpleDBM
|
11
|
+
|
12
|
+
_ARPAKIT_LIB_MODULE_VERSION = "3.0"
|
13
|
+
|
14
|
+
|
15
|
+
class StoryLogDBM(SimpleDBM):
|
16
|
+
__tablename__ = "story_log"
|
17
|
+
|
18
|
+
class Levels(EasyEnumeration):
|
19
|
+
info = "info"
|
20
|
+
warning = "warning"
|
21
|
+
error = "error"
|
22
|
+
|
23
|
+
level: Mapped[str] = mapped_column(
|
24
|
+
TEXT, insert_default=Levels.info, server_default=Levels.info, index=True, nullable=False
|
25
|
+
)
|
26
|
+
title: Mapped[str | None] = mapped_column(TEXT, index=True, default=None, nullable=True)
|
27
|
+
data: Mapped[dict[str, Any]] = mapped_column(
|
28
|
+
JSONB, insert_default={}, server_default="{}", index=True, nullable=False
|
29
|
+
)
|
30
|
+
|
31
|
+
|
32
|
+
class AdminStoryLogSO(BaseAPISimpleSO):
|
33
|
+
level: str
|
34
|
+
title: str | None
|
35
|
+
data: dict[str, Any]
|
36
|
+
|
37
|
+
|
@@ -36,7 +36,7 @@ arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.css,sha256=jzPZlgJTFwSdSphk9C
|
|
36
36
|
arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.css.map,sha256=5wq8eXMLU6Zxb45orZPL1zAsBFJReFw6GjYqGpUX3hg,262650
|
37
37
|
arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.js,sha256=ffrLZHHEQ_g84A-ul3yWa10Kk09waOAxHcQXPuZuavg,339292
|
38
38
|
arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.js.map,sha256=9UhIW7MqCOZPAz1Sl1IKfZUuhWU0p-LJqrnjjJD9Xhc,1159454
|
39
|
-
arpakitlib/ar_fastapi_util.py,sha256=
|
39
|
+
arpakitlib/ar_fastapi_util.py,sha256=lt5ziw_nbueLH71d4QHi8VE2hof6YYqPEwLF2w5vjkE,9864
|
40
40
|
arpakitlib/ar_file_storage_in_dir.py,sha256=D3e3rGuHoI6xqAA5mVvEpVVpOWY1jyjNsjj2UhyHRbE,3674
|
41
41
|
arpakitlib/ar_generate_env_example.py,sha256=WseNlk_So6mTVQ2amMuigWYV4ZVmd940POvXtodoYj0,325
|
42
42
|
arpakitlib/ar_hash_util.py,sha256=Iqy6KBAOLBQMFLWv676boI5sV7atT2B-fb7aCdHOmIQ,340
|
@@ -51,7 +51,7 @@ arpakitlib/ar_logging_util.py,sha256=c5wX2FLqCzb4aLckLVhIJ7go52rJQ4GN9dIkJ6KMc3o
|
|
51
51
|
arpakitlib/ar_mongodb_util.py,sha256=2ECkTnGAZ92qxioL-fmN6R4yZOSr3bXdXLWTzT1C3vk,4038
|
52
52
|
arpakitlib/ar_need_type_util.py,sha256=qCRSWlSgx-3yU0NRHZDQ5lCOmuZKcz2Na3py9nr6hJM,1618
|
53
53
|
arpakitlib/ar_openai_util.py,sha256=d5Aj1O2yo_zYLZCLeOLvuveYYxA2jGOqhMs1oUbuVk8,1210
|
54
|
-
arpakitlib/ar_operation_execution_util.py,sha256=
|
54
|
+
arpakitlib/ar_operation_execution_util.py,sha256=PGyyvJoYAv01MWQl1TNWGamchfIrDkSovLrNMiyKqEg,11770
|
55
55
|
arpakitlib/ar_parse_command.py,sha256=qpr2OwG3Bf7DFiL9S3iWgtbvtE80RSC35E5zFJvjG1I,2714
|
56
56
|
arpakitlib/ar_postgresql_util.py,sha256=SAHEmAyMkZe516uk2gS830v_Wn2kRUZUYNcTNwmgXJk,1160
|
57
57
|
arpakitlib/ar_run_cmd.py,sha256=D_rPavKMmWkQtwvZFz-Io5Ak8eSODHkcFeLPzNVC68g,1072
|
@@ -59,12 +59,13 @@ arpakitlib/ar_schedule_uust_api_client.py,sha256=1JGUy6rrjAXdWjeAqiAOQlCAEV3xuc5
|
|
59
59
|
arpakitlib/ar_sleep_util.py,sha256=9ZN4Qo4eZ_q3hjM7vNBQjFRcH-9-sqv3QLSjnxVJE90,1405
|
60
60
|
arpakitlib/ar_sqlalchemy_model_util.py,sha256=3zscvaloi9XY1NR70rJ4-jJlFUIqhmTbQ9wdvK-Yjf8,1379
|
61
61
|
arpakitlib/ar_ssh_runner.py,sha256=jlnss4V4pziBN1rBzoK_lDiWm6nMOqGXfa6NFJSKH-Y,6796
|
62
|
+
arpakitlib/ar_story_log_util.py,sha256=NKzC1nZkjofRTePHhncatO7B25hAFPvIwG45XWjI0tQ,1060
|
62
63
|
arpakitlib/ar_str_util.py,sha256=xSEzmsDvRiZVaxyqFFjcgzpphktCbXg2FHcvsd1DYpA,1885
|
63
64
|
arpakitlib/ar_type_util.py,sha256=-h-SCsVl11eVo1u4hy2Asn0IfD5TIxmX3Ndug4AvnPE,1761
|
64
65
|
arpakitlib/ar_yookassa_api_client.py,sha256=BwsTygaXf35AACVBl_09uYlSD_t-U1OOzbj58OOFT4Q,6480
|
65
66
|
arpakitlib/ar_zabbix_util.py,sha256=MTQbmS0QpNCKNOGONNQHf6j7KTZsKGlIbd5rCH0R0WI,6313
|
66
|
-
arpakitlib-1.5.
|
67
|
-
arpakitlib-1.5.
|
68
|
-
arpakitlib-1.5.
|
69
|
-
arpakitlib-1.5.
|
70
|
-
arpakitlib-1.5.
|
67
|
+
arpakitlib-1.5.33.dist-info/LICENSE,sha256=1jqWIkbnMxDfs_i0SXP5qbV6PHjBr1g8506oW7uPjfg,11347
|
68
|
+
arpakitlib-1.5.33.dist-info/METADATA,sha256=xScH-mZtscIaV19pqqlcgX6IfeEKych_R7jlqzO-FJg,2330
|
69
|
+
arpakitlib-1.5.33.dist-info/NOTICE,sha256=wHwmiq3wExfFfgMsE5U5TOBP9_l72ocIG82KurEels0,43
|
70
|
+
arpakitlib-1.5.33.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
71
|
+
arpakitlib-1.5.33.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|