arpakitlib 1.5.30__py3-none-any.whl → 1.5.31__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 +11 -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.31.dist-info}/METADATA +1 -1
- {arpakitlib-1.5.30.dist-info → arpakitlib-1.5.31.dist-info}/RECORD +8 -7
- {arpakitlib-1.5.30.dist-info → arpakitlib-1.5.31.dist-info}/LICENSE +0 -0
- {arpakitlib-1.5.30.dist-info → arpakitlib-1.5.31.dist-info}/NOTICE +0 -0
- {arpakitlib-1.5.30.dist-info → arpakitlib-1.5.31.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,12 @@ class BaseAPISO(BaseAPISchema):
|
|
52
53
|
pass
|
53
54
|
|
54
55
|
|
56
|
+
class BaseAPISimpleSO(BaseAPISO):
|
57
|
+
id: int
|
58
|
+
long_id: str
|
59
|
+
creation_dt: datetime
|
60
|
+
|
61
|
+
|
55
62
|
class APIErrorSO(BaseAPISO):
|
56
63
|
class APIErrorCodes(EasyEnumeration):
|
57
64
|
cannot_authorize = "CANNOT_AUTHORIZE"
|
@@ -243,7 +250,7 @@ def add_ar_fastapi_static_docs_and_redoc_handlers_to_fastapi_app(
|
|
243
250
|
return fastapi_app
|
244
251
|
|
245
252
|
|
246
|
-
class
|
253
|
+
class BaseAPIEvent:
|
247
254
|
def __init__(self, *args, **kwargs):
|
248
255
|
self._logger = logging.getLogger(self.__class__.__name__)
|
249
256
|
|
@@ -251,11 +258,6 @@ class BaseAPIStartupEvent:
|
|
251
258
|
self._logger.info("on_startup starts")
|
252
259
|
self._logger.info("on_startup ends")
|
253
260
|
|
254
|
-
|
255
|
-
class BaseAPIShutdownEvent:
|
256
|
-
def __init__(self, *args, **kwargs):
|
257
|
-
self._logger = logging.getLogger(self.__class__.__name__)
|
258
|
-
|
259
261
|
async def on_shutdown(self, *args, **kwargs):
|
260
262
|
self._logger.info("on_shutdown starts")
|
261
263
|
self._logger.info("on_shutdown ends")
|
@@ -265,8 +267,7 @@ def create_fastapi_app(
|
|
265
267
|
*,
|
266
268
|
title: str,
|
267
269
|
description: str | None = None,
|
268
|
-
|
269
|
-
api_shutdown_event: BaseAPIShutdownEvent | None = BaseAPIShutdownEvent(),
|
270
|
+
api_event: BaseAPIEvent | None = BaseAPIEvent(),
|
270
271
|
api_handle_exception_: Callable | None = simple_api_handle_exception
|
271
272
|
):
|
272
273
|
app = FastAPI(
|
@@ -275,8 +276,8 @@ def create_fastapi_app(
|
|
275
276
|
docs_url=None,
|
276
277
|
redoc_url=None,
|
277
278
|
openapi_url="/openapi",
|
278
|
-
on_startup=[
|
279
|
-
on_shutdown=[
|
279
|
+
on_startup=[api_event.on_startup] if api_event else [],
|
280
|
+
on_shutdown=[api_event.on_shutdown] if api_event else []
|
280
281
|
)
|
281
282
|
|
282
283
|
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=A5cSh1axaqN4yE2E5QPLDK58aEZgT24fIQ4pgzAMI7I,9798
|
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.31.dist-info/LICENSE,sha256=1jqWIkbnMxDfs_i0SXP5qbV6PHjBr1g8506oW7uPjfg,11347
|
68
|
+
arpakitlib-1.5.31.dist-info/METADATA,sha256=2nk5FfCHFT4sV_hZ8MKq3LlSc6NauO5Fw6gxrQPGefs,2330
|
69
|
+
arpakitlib-1.5.31.dist-info/NOTICE,sha256=wHwmiq3wExfFfgMsE5U5TOBP9_l72ocIG82KurEels0,43
|
70
|
+
arpakitlib-1.5.31.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
71
|
+
arpakitlib-1.5.31.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|