arpakitlib 1.8.36__py3-none-any.whl → 1.8.39__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/_arpakit_project_template_v_5/arpakitlib_project_template_info.json +1 -1
- arpakitlib/_arpakit_project_template_v_5/command/emojize.py +9 -0
- arpakitlib/_arpakit_project_template_v_5/project/api/create_api_app.py +12 -2
- arpakitlib/_arpakit_project_template_v_5/project/api/exception_handler.py +1 -1
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/check_sqlalchemy_db.py +43 -0
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/clear_log_file.py +44 -0
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/create_operation.py +78 -0
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_arpakitlib_project_template_info.py +8 -2
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_auth_data.py +8 -2
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_log_file.py +33 -0
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_operation.py +63 -0
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_operation_allowed_statuses.py +40 -0
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_operation_allowed_types.py +40 -0
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_sqlalchemy_db_table_name_to_amount.py +39 -0
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_story_log.py +14 -4
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/init_sqlalchemy_db.py +8 -2
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/main_router.py +43 -1
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/raise_fake_error.py +1 -2
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/reinit_sqlalchemy_db.py +8 -2
- arpakitlib/_arpakit_project_template_v_5/project/api/router/client/get_current_user.py +11 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/router/client/get_current_user_token.py +10 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/router/client/main_router.py +1 -11
- arpakitlib/_arpakit_project_template_v_5/project/api/router/general/check_authorization.py +46 -0
- arpakitlib/_arpakit_project_template_v_5/project/api/router/{client → general}/get_current_api_key.py +9 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/router/{client → general}/get_errors_info.py +10 -8
- arpakitlib/_arpakit_project_template_v_5/project/api/router/general/healthcheck.py +12 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/router/general/main_router.py +18 -1
- arpakitlib/_arpakit_project_template_v_5/project/api/router/general/now_utc_datetime.py +14 -2
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/common.py +11 -0
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/admin/common.py +1 -0
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/admin/operation.py +6 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/admin/story_log.py +8 -6
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/client/common.py +3 -1
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/client/user.py +14 -5
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/client/user_token.py +5 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/{client → general}/api_key.py +5 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/general/user.py +31 -0
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/general/user_token.py +16 -0
- arpakitlib/_arpakit_project_template_v_5/project/operation_execution/operation_executor_worker.py +27 -4
- arpakitlib/_arpakit_project_template_v_5/project/operation_execution/scheduled_operation_creator_worker.py +2 -1
- arpakitlib/_arpakit_project_template_v_5/project/sandbox/sandbox_1.py +6 -1
- arpakitlib/_arpakit_project_template_v_5/project/sqladmin_/model_view/api_key.py +4 -11
- arpakitlib/_arpakit_project_template_v_5/project/sqladmin_/model_view/common.py +1 -1
- arpakitlib/_arpakit_project_template_v_5/project/sqladmin_/model_view/operation.py +6 -18
- arpakitlib/_arpakit_project_template_v_5/project/sqladmin_/model_view/story_log.py +5 -15
- arpakitlib/_arpakit_project_template_v_5/project/sqladmin_/model_view/user.py +5 -15
- arpakitlib/_arpakit_project_template_v_5/project/sqladmin_/model_view/user_token.py +5 -11
- arpakitlib/_arpakit_project_template_v_5/project/sqlalchemy_db_/sqlalchemy_model/operation.py +6 -1
- arpakitlib/_arpakit_project_template_v_5/project/sqlalchemy_db_/sqlalchemy_model/story_log.py +6 -9
- arpakitlib/_arpakit_project_template_v_5/project/sqlalchemy_db_/sqlalchemy_model/user.py +30 -30
- arpakitlib/_arpakit_project_template_v_5/project/sqlalchemy_db_/sqlalchemy_model/user_token.py +4 -0
- arpakitlib/_arpakit_project_template_v_5/project/test_data/make_test_api_keys.py +2 -2
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/blank/{client.py → general.py} +7 -6
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/const.py +2 -2
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/kb/inline_/client/hello_world.py +1 -1
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/kb/static_/client/hello_world.py +1 -1
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/router/general/about.py +4 -4
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/router/general/author.py +4 -4
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/router/general/error_handler.py +2 -2
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/router/general/healthcheck.py +3 -3
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/router/general/hello_world.py +3 -3
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/router/general/raw_callback_query.py +1 -1
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/router/general/raw_message.py +1 -1
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/router/general/start.py +4 -4
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/router/general/support.py +4 -4
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot/util/set_tg_bot_commands.py +14 -14
- arpakitlib/ar_enumeration_util.py +2 -2
- arpakitlib/ar_sqlalchemy_util.py +52 -24
- arpakitlib/ar_str_util.py +6 -0
- arpakitlib/ar_zabbix_api_client_util.py +43 -3
- {arpakitlib-1.8.36.dist-info → arpakitlib-1.8.39.dist-info}/METADATA +1 -1
- {arpakitlib-1.8.36.dist-info → arpakitlib-1.8.39.dist-info}/RECORD +75 -65
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/general/errors_info_general.py +0 -6
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/general/healthcheck.py +0 -5
- {arpakitlib-1.8.36.dist-info → arpakitlib-1.8.39.dist-info}/LICENSE +0 -0
- {arpakitlib-1.8.36.dist-info → arpakitlib-1.8.39.dist-info}/WHEEL +0 -0
- {arpakitlib-1.8.36.dist-info → arpakitlib-1.8.39.dist-info}/entry_points.txt +0 -0
@@ -4,11 +4,17 @@ from fastapi import APIRouter
|
|
4
4
|
from project.api.authorize import APIAuthorizeData, api_authorize, require_user_token_dbm_api_authorize_middleware, \
|
5
5
|
require_not_prod_mode_api_authorize_middleware, \
|
6
6
|
require_api_key_dbm_api_authorize_middleware
|
7
|
+
from project.api.schema.common import BaseRouteSO
|
7
8
|
from project.api.schema.out.common.error import ErrorCommonSO
|
8
9
|
from project.api.schema.out.common.raw_data import RawDataCommonSO
|
9
10
|
from project.sqlalchemy_db_.sqlalchemy_db import get_cached_sqlalchemy_db
|
10
11
|
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
11
12
|
|
13
|
+
|
14
|
+
class ReinitSqlalchemyDbRouteSO(BaseRouteSO, RawDataCommonSO):
|
15
|
+
pass
|
16
|
+
|
17
|
+
|
12
18
|
api_router = APIRouter()
|
13
19
|
|
14
20
|
|
@@ -16,7 +22,7 @@ api_router = APIRouter()
|
|
16
22
|
path="",
|
17
23
|
name="Reinit sqlalchemy db",
|
18
24
|
status_code=fastapi.status.HTTP_200_OK,
|
19
|
-
response_model=
|
25
|
+
response_model=ReinitSqlalchemyDbRouteSO | ErrorCommonSO,
|
20
26
|
)
|
21
27
|
async def _(
|
22
28
|
*,
|
@@ -34,4 +40,4 @@ async def _(
|
|
34
40
|
]))
|
35
41
|
):
|
36
42
|
get_cached_sqlalchemy_db().reinit()
|
37
|
-
return
|
43
|
+
return ReinitSqlalchemyDbRouteSO()
|
@@ -1,12 +1,20 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
1
3
|
import fastapi.requests
|
2
4
|
from fastapi import APIRouter
|
3
5
|
|
4
6
|
from project.api.authorize import APIAuthorizeData, api_authorize, require_user_token_dbm_api_authorize_middleware, \
|
5
7
|
require_api_key_dbm_api_authorize_middleware
|
6
|
-
from project.api.schema.
|
8
|
+
from project.api.schema.common import BaseRouteSO
|
9
|
+
from project.api.schema.out.client.user import UserClient1SO
|
7
10
|
from project.api.schema.out.common.error import ErrorCommonSO
|
8
11
|
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
9
12
|
|
13
|
+
|
14
|
+
class GetCurrentUserRouteSO(BaseRouteSO, UserClient1SO):
|
15
|
+
pass
|
16
|
+
|
17
|
+
|
10
18
|
api_router = APIRouter()
|
11
19
|
|
12
20
|
|
@@ -14,7 +22,7 @@ api_router = APIRouter()
|
|
14
22
|
"",
|
15
23
|
name="Get current user",
|
16
24
|
status_code=fastapi.status.HTTP_200_OK,
|
17
|
-
response_model=
|
25
|
+
response_model=GetCurrentUserRouteSO | ErrorCommonSO,
|
18
26
|
)
|
19
27
|
async def _(
|
20
28
|
*,
|
@@ -30,6 +38,6 @@ async def _(
|
|
30
38
|
)
|
31
39
|
]))
|
32
40
|
):
|
33
|
-
return
|
41
|
+
return GetCurrentUserRouteSO.from_dbm(
|
34
42
|
simple_dbm=api_auth_data.user_token_dbm.user
|
35
43
|
)
|
arpakitlib/_arpakit_project_template_v_5/project/api/router/client/get_current_user_token.py
CHANGED
@@ -3,10 +3,17 @@ from fastapi import APIRouter
|
|
3
3
|
|
4
4
|
from project.api.authorize import APIAuthorizeData, api_authorize, require_user_token_dbm_api_authorize_middleware, \
|
5
5
|
require_api_key_dbm_api_authorize_middleware
|
6
|
-
from project.api.schema.
|
6
|
+
from project.api.schema.common import BaseRouteSO
|
7
|
+
from project.api.schema.out.client.user import UserClient1SO
|
8
|
+
from project.api.schema.out.client.user_token import UserTokenClient1SO
|
7
9
|
from project.api.schema.out.common.error import ErrorCommonSO
|
8
10
|
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
9
11
|
|
12
|
+
|
13
|
+
class GetCurrentUserTokenRouteSO(BaseRouteSO, UserTokenClient1SO):
|
14
|
+
user: UserClient1SO
|
15
|
+
|
16
|
+
|
10
17
|
api_router = APIRouter()
|
11
18
|
|
12
19
|
|
@@ -14,7 +21,7 @@ api_router = APIRouter()
|
|
14
21
|
"",
|
15
22
|
name="Get current user token",
|
16
23
|
status_code=fastapi.status.HTTP_200_OK,
|
17
|
-
response_model=
|
24
|
+
response_model=GetCurrentUserTokenRouteSO | ErrorCommonSO,
|
18
25
|
)
|
19
26
|
async def _(
|
20
27
|
*,
|
@@ -30,6 +37,6 @@ async def _(
|
|
30
37
|
)
|
31
38
|
]))
|
32
39
|
):
|
33
|
-
return
|
40
|
+
return GetCurrentUserTokenRouteSO.from_dbm(
|
34
41
|
simple_dbm=api_auth_data.user_token_dbm
|
35
42
|
)
|
@@ -1,14 +1,9 @@
|
|
1
1
|
from fastapi import APIRouter
|
2
2
|
|
3
|
-
from project.api.router.client import
|
3
|
+
from project.api.router.client import get_current_user, get_current_user_token
|
4
4
|
|
5
5
|
main_client_api_router = APIRouter()
|
6
6
|
|
7
|
-
main_client_api_router.include_router(
|
8
|
-
router=get_errors_info.api_router,
|
9
|
-
prefix="/get_errors_info"
|
10
|
-
)
|
11
|
-
|
12
7
|
main_client_api_router.include_router(
|
13
8
|
router=get_current_user.api_router,
|
14
9
|
prefix="/get_current_user"
|
@@ -18,8 +13,3 @@ main_client_api_router.include_router(
|
|
18
13
|
router=get_current_user_token.api_router,
|
19
14
|
prefix="/get_current_user_token"
|
20
15
|
)
|
21
|
-
|
22
|
-
main_client_api_router.include_router(
|
23
|
-
router=get_current_api_key.api_router,
|
24
|
-
prefix="/get_current_api_key"
|
25
|
-
)
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import fastapi.requests
|
2
|
+
from fastapi import APIRouter
|
3
|
+
|
4
|
+
from project.api.authorize import APIAuthorizeData, api_authorize
|
5
|
+
from project.api.schema.common import BaseRouteSO
|
6
|
+
from project.api.schema.out.common.error import ErrorCommonSO
|
7
|
+
from project.api.schema.out.general.api_key import ApiKeyGeneral1SO
|
8
|
+
from project.api.schema.out.general.user import UserGeneral1SO
|
9
|
+
from project.api.schema.out.general.user_token import UserTokenGeneral1SO
|
10
|
+
|
11
|
+
|
12
|
+
class CheckAuthorizationGeneralRouteSO(BaseRouteSO):
|
13
|
+
is_current_api_key_ok: bool = False
|
14
|
+
is_current_user_token_ok: bool = False
|
15
|
+
current_api_key: ApiKeyGeneral1SO | None = None
|
16
|
+
current_user_token: UserTokenGeneral1SO | None = None
|
17
|
+
current_user: UserGeneral1SO | None = None
|
18
|
+
|
19
|
+
|
20
|
+
api_router = APIRouter()
|
21
|
+
|
22
|
+
|
23
|
+
@api_router.get(
|
24
|
+
"",
|
25
|
+
name="Check authorization",
|
26
|
+
status_code=fastapi.status.HTTP_200_OK,
|
27
|
+
response_model=CheckAuthorizationGeneralRouteSO | ErrorCommonSO,
|
28
|
+
)
|
29
|
+
async def _(
|
30
|
+
*,
|
31
|
+
request: fastapi.requests.Request,
|
32
|
+
response: fastapi.responses.Response,
|
33
|
+
api_auth_data: APIAuthorizeData = fastapi.Depends(api_authorize())
|
34
|
+
):
|
35
|
+
return CheckAuthorizationGeneralRouteSO(
|
36
|
+
is_current_api_key_ok=api_auth_data.api_key_dbm is not None,
|
37
|
+
is_current_user_token_ok=api_auth_data.user_token_dbm is not None,
|
38
|
+
current_api_key=ApiKeyGeneral1SO.from_dbm(simple_dbm=api_auth_data.api_key_dbm),
|
39
|
+
current_user_token=UserTokenGeneral1SO.from_dbm(
|
40
|
+
simple_dbm=api_auth_data.user_token_dbm
|
41
|
+
) if api_auth_data.user_token_dbm is not None else None
|
42
|
+
,
|
43
|
+
current_user=UserGeneral1SO.from_dbm(
|
44
|
+
simple_dbm=api_auth_data.user_token_dbm.user
|
45
|
+
) if api_auth_data.user_token_dbm is not None else None
|
46
|
+
)
|
@@ -3,10 +3,16 @@ from fastapi import APIRouter
|
|
3
3
|
|
4
4
|
from project.api.authorize import APIAuthorizeData, api_authorize, require_user_token_dbm_api_authorize_middleware, \
|
5
5
|
require_api_key_dbm_api_authorize_middleware
|
6
|
-
from project.api.schema.
|
6
|
+
from project.api.schema.common import BaseRouteSO
|
7
7
|
from project.api.schema.out.common.error import ErrorCommonSO
|
8
|
+
from project.api.schema.out.general.api_key import ApiKeyGeneral1SO
|
8
9
|
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
9
10
|
|
11
|
+
|
12
|
+
class GetCurrentApiKeyRouteSO(BaseRouteSO, ApiKeyGeneral1SO):
|
13
|
+
pass
|
14
|
+
|
15
|
+
|
10
16
|
api_router = APIRouter()
|
11
17
|
|
12
18
|
|
@@ -14,7 +20,7 @@ api_router = APIRouter()
|
|
14
20
|
"",
|
15
21
|
name="Get current api key",
|
16
22
|
status_code=fastapi.status.HTTP_200_OK,
|
17
|
-
response_model=
|
23
|
+
response_model=GetCurrentApiKeyRouteSO | str | ErrorCommonSO,
|
18
24
|
)
|
19
25
|
async def _(
|
20
26
|
*,
|
@@ -30,6 +36,6 @@ async def _(
|
|
30
36
|
)
|
31
37
|
]))
|
32
38
|
):
|
33
|
-
return
|
39
|
+
return GetCurrentApiKeyRouteSO.from_dbm(
|
34
40
|
simple_dbm=api_auth_data.api_key_dbm
|
35
41
|
)
|
arpakitlib/_arpakit_project_template_v_5/project/api/router/{client → general}/get_errors_info.py
RENAMED
@@ -1,11 +1,16 @@
|
|
1
1
|
import fastapi.requests
|
2
2
|
from fastapi import APIRouter
|
3
3
|
|
4
|
-
from project.api.authorize import APIAuthorizeData, api_authorize,
|
5
|
-
require_api_key_dbm_api_authorize_middleware
|
4
|
+
from project.api.authorize import APIAuthorizeData, api_authorize, require_api_key_dbm_api_authorize_middleware
|
6
5
|
from project.api.const import APIErrorCodes, APIErrorSpecificationCodes
|
6
|
+
from project.api.schema.common import BaseRouteSO
|
7
7
|
from project.api.schema.out.common.error import ErrorCommonSO
|
8
|
-
|
8
|
+
|
9
|
+
|
10
|
+
class GetErrorsInfoRouteSO(BaseRouteSO):
|
11
|
+
api_error_codes: list[str] = []
|
12
|
+
api_error_specification_codes: list[str] = []
|
13
|
+
|
9
14
|
|
10
15
|
api_router = APIRouter()
|
11
16
|
|
@@ -14,7 +19,7 @@ api_router = APIRouter()
|
|
14
19
|
"",
|
15
20
|
name="Get errors info",
|
16
21
|
status_code=fastapi.status.HTTP_200_OK,
|
17
|
-
response_model=
|
22
|
+
response_model=GetErrorsInfoRouteSO | ErrorCommonSO,
|
18
23
|
)
|
19
24
|
async def _(
|
20
25
|
*,
|
@@ -23,13 +28,10 @@ async def _(
|
|
23
28
|
api_auth_data: APIAuthorizeData = fastapi.Depends(api_authorize(middlewares=[
|
24
29
|
require_api_key_dbm_api_authorize_middleware(
|
25
30
|
require_active=True
|
26
|
-
),
|
27
|
-
require_user_token_dbm_api_authorize_middleware(
|
28
|
-
require_active_user_token=True
|
29
31
|
)
|
30
32
|
]))
|
31
33
|
):
|
32
|
-
return
|
34
|
+
return GetErrorsInfoRouteSO(
|
33
35
|
api_error_codes=APIErrorCodes.values_list(),
|
34
36
|
api_error_specification_codes=APIErrorSpecificationCodes.values_list()
|
35
37
|
)
|
@@ -1,8 +1,17 @@
|
|
1
|
+
import datetime as dt
|
2
|
+
|
1
3
|
import fastapi
|
2
4
|
from fastapi import APIRouter
|
3
5
|
|
6
|
+
from project.api.schema.common import BaseRouteSO
|
4
7
|
from project.api.schema.out.common.error import ErrorCommonSO
|
5
|
-
from project.
|
8
|
+
from project.core.util import now_local_dt
|
9
|
+
|
10
|
+
|
11
|
+
class HealthcheckRouteSO(BaseRouteSO):
|
12
|
+
is_ok: bool = True
|
13
|
+
datetime: dt.datetime
|
14
|
+
|
6
15
|
|
7
16
|
api_router = APIRouter()
|
8
17
|
|
@@ -11,11 +20,11 @@ api_router = APIRouter()
|
|
11
20
|
"",
|
12
21
|
name="Healthcheck",
|
13
22
|
status_code=fastapi.status.HTTP_200_OK,
|
14
|
-
response_model=
|
23
|
+
response_model=HealthcheckRouteSO | ErrorCommonSO,
|
15
24
|
)
|
16
25
|
async def _(
|
17
26
|
*,
|
18
27
|
request: fastapi.requests.Request,
|
19
28
|
response: fastapi.responses.Response
|
20
29
|
):
|
21
|
-
return
|
30
|
+
return HealthcheckRouteSO(is_ok=True, datetime=now_local_dt())
|
@@ -1,6 +1,7 @@
|
|
1
1
|
from fastapi import APIRouter
|
2
2
|
|
3
|
-
from project.api.router.general import healthcheck, now_utc_datetime
|
3
|
+
from project.api.router.general import healthcheck, now_utc_datetime, get_current_api_key, check_authorization, \
|
4
|
+
get_errors_info
|
4
5
|
|
5
6
|
main_general_api_router = APIRouter()
|
6
7
|
|
@@ -8,7 +9,23 @@ main_general_api_router.include_router(
|
|
8
9
|
router=healthcheck.api_router,
|
9
10
|
prefix="/healthcheck"
|
10
11
|
)
|
12
|
+
|
11
13
|
main_general_api_router.include_router(
|
12
14
|
router=now_utc_datetime.api_router,
|
13
15
|
prefix="/now_utc_datetime"
|
14
16
|
)
|
17
|
+
|
18
|
+
main_general_api_router.include_router(
|
19
|
+
router=get_current_api_key.api_router,
|
20
|
+
prefix="/get_current_api_key"
|
21
|
+
)
|
22
|
+
|
23
|
+
main_general_api_router.include_router(
|
24
|
+
router=check_authorization.api_router,
|
25
|
+
prefix="/check_authorization"
|
26
|
+
)
|
27
|
+
|
28
|
+
main_general_api_router.include_router(
|
29
|
+
router=get_errors_info.api_router,
|
30
|
+
prefix="/get_errors_info"
|
31
|
+
)
|
@@ -2,9 +2,16 @@ import fastapi
|
|
2
2
|
from fastapi import APIRouter
|
3
3
|
|
4
4
|
from arpakitlib.ar_datetime_util import now_utc_dt
|
5
|
+
from project.api.authorize import require_api_key_dbm_api_authorize_middleware, APIAuthorizeData, api_authorize
|
6
|
+
from project.api.schema.common import BaseRouteSO
|
5
7
|
from project.api.schema.out.common.datetime_ import DatetimeCommonSO
|
6
8
|
from project.api.schema.out.common.error import ErrorCommonSO
|
7
9
|
|
10
|
+
|
11
|
+
class NowUTCDatetimeRouteSO(BaseRouteSO, DatetimeCommonSO):
|
12
|
+
pass
|
13
|
+
|
14
|
+
|
8
15
|
api_router = APIRouter()
|
9
16
|
|
10
17
|
|
@@ -12,11 +19,16 @@ api_router = APIRouter()
|
|
12
19
|
"",
|
13
20
|
name="Now UTC datetime",
|
14
21
|
status_code=fastapi.status.HTTP_200_OK,
|
15
|
-
response_model=
|
22
|
+
response_model=NowUTCDatetimeRouteSO | ErrorCommonSO,
|
16
23
|
)
|
17
24
|
async def _(
|
18
25
|
*,
|
19
26
|
request: fastapi.requests.Request,
|
20
27
|
response: fastapi.responses.Response,
|
28
|
+
api_auth_data: APIAuthorizeData = fastapi.Depends(api_authorize(middlewares=[
|
29
|
+
require_api_key_dbm_api_authorize_middleware(
|
30
|
+
require_active=True
|
31
|
+
)
|
32
|
+
]))
|
21
33
|
):
|
22
|
-
return
|
34
|
+
return NowUTCDatetimeRouteSO.from_datetime(datetime_=now_utc_dt())
|
@@ -24,3 +24,14 @@ class BaseSI(BaseSchema):
|
|
24
24
|
|
25
25
|
class BaseSO(BaseSchema):
|
26
26
|
pass
|
27
|
+
|
28
|
+
|
29
|
+
class BaseRouteSO(BaseSchema):
|
30
|
+
@classmethod
|
31
|
+
def __pydantic_init_subclass__(cls, **kwargs: Any) -> None:
|
32
|
+
if not (
|
33
|
+
cls.__name__.endswith("RouteSO")
|
34
|
+
or cls.__name__.endswith("RouteSchemaOut")
|
35
|
+
):
|
36
|
+
raise ValueError("Route APISchema class should ends with RouteSO | RouteSchemaOut")
|
37
|
+
super().__init_subclass__(**kwargs)
|
@@ -7,7 +7,7 @@ from project.api.schema.out.admin.common import SimpleDBMAdminSO
|
|
7
7
|
from project.sqlalchemy_db_.sqlalchemy_model import OperationDBM
|
8
8
|
|
9
9
|
|
10
|
-
class
|
10
|
+
class OperationAdmin1SO(SimpleDBMAdminSO):
|
11
11
|
execution_start_dt: dt.datetime | None
|
12
12
|
execution_finish_dt: dt.datetime | None
|
13
13
|
status: str
|
@@ -16,10 +16,13 @@ class OperationAdminSO(SimpleDBMAdminSO):
|
|
16
16
|
input_data: dict[str, Any]
|
17
17
|
output_data: dict[str, Any]
|
18
18
|
error_data: dict[str, Any]
|
19
|
+
|
19
20
|
duration_total_seconds: float | None
|
20
21
|
allowed_statuses: list[str]
|
21
22
|
allowed_types: list[str]
|
22
23
|
|
23
24
|
@classmethod
|
24
|
-
def from_dbm(cls, *, simple_dbm: OperationDBM) ->
|
25
|
-
return cls.model_validate(simple_dbm.simple_dict_with_sd_properties(
|
25
|
+
def from_dbm(cls, *, simple_dbm: OperationDBM) -> OperationAdmin1SO:
|
26
|
+
return cls.model_validate(simple_dbm.simple_dict_with_sd_properties(
|
27
|
+
only_columns_and_sd_properties=cls.model_fields.keys()
|
28
|
+
))
|
@@ -1,17 +1,19 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
-
from typing import Any
|
4
|
-
|
5
3
|
from project.api.schema.out.admin.common import SimpleDBMAdminSO
|
6
4
|
from project.sqlalchemy_db_.sqlalchemy_model import StoryLogDBM
|
7
5
|
|
8
6
|
|
9
|
-
class
|
7
|
+
class StoryLogAdmin1SO(SimpleDBMAdminSO):
|
10
8
|
level: str
|
11
9
|
type: str | None
|
12
10
|
title: str | None
|
13
|
-
|
11
|
+
|
12
|
+
allowed_levels: list[str]
|
13
|
+
allowed_types: list[str]
|
14
14
|
|
15
15
|
@classmethod
|
16
|
-
def from_dbm(cls, *, simple_dbm: StoryLogDBM) ->
|
17
|
-
return cls.model_validate(simple_dbm.simple_dict_with_sd_properties(
|
16
|
+
def from_dbm(cls, *, simple_dbm: StoryLogDBM) -> StoryLogAdmin1SO:
|
17
|
+
return cls.model_validate(simple_dbm.simple_dict_with_sd_properties(
|
18
|
+
only_columns_and_sd_properties=cls.model_fields.keys()
|
19
|
+
))
|
@@ -15,4 +15,6 @@ class SimpleDBMClientSO(BaseSO):
|
|
15
15
|
|
16
16
|
@classmethod
|
17
17
|
def from_dbm(cls, *, simple_dbm: SimpleDBM) -> SimpleDBMClientSO:
|
18
|
-
return cls.model_validate(simple_dbm.simple_dict_with_sd_properties(
|
18
|
+
return cls.model_validate(simple_dbm.simple_dict_with_sd_properties(
|
19
|
+
only_columns_and_sd_properties=cls.model_fields.keys()
|
20
|
+
))
|
@@ -1,22 +1,31 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
import datetime as dt
|
4
|
-
from typing import Any
|
5
4
|
|
6
5
|
from project.api.schema.out.client.common import SimpleDBMClientSO
|
7
6
|
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
8
7
|
|
9
8
|
|
10
|
-
class
|
9
|
+
class UserClient1SO(SimpleDBMClientSO):
|
11
10
|
email: str | None
|
12
11
|
roles: list[str]
|
13
12
|
is_active: bool
|
14
13
|
tg_id: int | None
|
15
14
|
tg_bot_last_action_dt: dt.datetime | None
|
16
|
-
|
15
|
+
|
17
16
|
roles_has_admin: bool
|
18
17
|
roles_has_client: bool
|
18
|
+
allowed_roles: list[str]
|
19
|
+
tg_data_first_name: str | None
|
20
|
+
tg_data_last_name: str | None
|
21
|
+
tg_data_language_code: str | None
|
22
|
+
tg_data_username: str | None
|
23
|
+
tg_data_at_username: str | None
|
24
|
+
tg_data_fullname: str | None
|
25
|
+
tg_data_link_by_username: str | None
|
19
26
|
|
20
27
|
@classmethod
|
21
|
-
def from_dbm(cls, *, simple_dbm: UserDBM) ->
|
22
|
-
return cls.model_validate(simple_dbm.simple_dict_with_sd_properties(
|
28
|
+
def from_dbm(cls, *, simple_dbm: UserDBM) -> UserClient1SO:
|
29
|
+
return cls.model_validate(simple_dbm.simple_dict_with_sd_properties(
|
30
|
+
only_columns_and_sd_properties=cls.model_fields.keys()
|
31
|
+
))
|
@@ -4,11 +4,13 @@ from project.api.schema.out.client.common import SimpleDBMClientSO
|
|
4
4
|
from project.sqlalchemy_db_.sqlalchemy_model import UserTokenDBM
|
5
5
|
|
6
6
|
|
7
|
-
class
|
7
|
+
class UserTokenClient1SO(SimpleDBMClientSO):
|
8
8
|
value: str
|
9
9
|
user_id: int
|
10
10
|
is_active: bool
|
11
11
|
|
12
12
|
@classmethod
|
13
|
-
def from_dbm(cls, *, simple_dbm: UserTokenDBM) ->
|
14
|
-
return cls.model_validate(simple_dbm.simple_dict_with_sd_properties(
|
13
|
+
def from_dbm(cls, *, simple_dbm: UserTokenDBM) -> UserTokenClient1SO:
|
14
|
+
return cls.model_validate(simple_dbm.simple_dict_with_sd_properties(
|
15
|
+
only_columns_and_sd_properties=cls.model_fields.keys()
|
16
|
+
))
|
arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/{client → general}/api_key.py
RENAMED
@@ -4,11 +4,13 @@ from project.api.schema.out.client.common import SimpleDBMClientSO
|
|
4
4
|
from project.sqlalchemy_db_.sqlalchemy_model import ApiKeyDBM
|
5
5
|
|
6
6
|
|
7
|
-
class
|
7
|
+
class ApiKeyGeneral1SO(SimpleDBMClientSO):
|
8
8
|
title: str | None
|
9
9
|
value: str
|
10
10
|
is_active: bool
|
11
11
|
|
12
12
|
@classmethod
|
13
|
-
def from_dbm(cls, *, simple_dbm: ApiKeyDBM) ->
|
14
|
-
return cls.model_validate(simple_dbm.simple_dict_with_sd_properties(
|
13
|
+
def from_dbm(cls, *, simple_dbm: ApiKeyDBM) -> ApiKeyGeneral1SO:
|
14
|
+
return cls.model_validate(simple_dbm.simple_dict_with_sd_properties(
|
15
|
+
only_columns_and_sd_properties=cls.model_fields.keys()
|
16
|
+
))
|
@@ -0,0 +1,31 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
import datetime as dt
|
4
|
+
|
5
|
+
from project.api.schema.out.client.common import SimpleDBMClientSO
|
6
|
+
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
7
|
+
|
8
|
+
|
9
|
+
class UserGeneral1SO(SimpleDBMClientSO):
|
10
|
+
email: str | None
|
11
|
+
roles: list[str]
|
12
|
+
is_active: bool
|
13
|
+
tg_id: int | None
|
14
|
+
tg_bot_last_action_dt: dt.datetime | None
|
15
|
+
|
16
|
+
roles_has_admin: bool
|
17
|
+
roles_has_client: bool
|
18
|
+
allowed_roles: list[str]
|
19
|
+
tg_data_first_name: str | None
|
20
|
+
tg_data_last_name: str | None
|
21
|
+
tg_data_language_code: str | None
|
22
|
+
tg_data_username: str | None
|
23
|
+
tg_data_at_username: str | None
|
24
|
+
tg_data_fullname: str | None
|
25
|
+
tg_data_link_by_username: str | None
|
26
|
+
|
27
|
+
@classmethod
|
28
|
+
def from_dbm(cls, *, simple_dbm: UserDBM) -> UserGeneral1SO:
|
29
|
+
return cls.model_validate(simple_dbm.simple_dict_with_sd_properties(
|
30
|
+
only_columns_and_sd_properties=cls.model_fields.keys()
|
31
|
+
))
|
@@ -0,0 +1,16 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from project.api.schema.out.client.common import SimpleDBMClientSO
|
4
|
+
from project.sqlalchemy_db_.sqlalchemy_model import UserTokenDBM
|
5
|
+
|
6
|
+
|
7
|
+
class UserTokenGeneral1SO(SimpleDBMClientSO):
|
8
|
+
value: str
|
9
|
+
user_id: int
|
10
|
+
is_active: bool
|
11
|
+
|
12
|
+
@classmethod
|
13
|
+
def from_dbm(cls, *, simple_dbm: UserTokenDBM) -> UserTokenGeneral1SO:
|
14
|
+
return cls.model_validate(simple_dbm.simple_dict_with_sd_properties(
|
15
|
+
only_columns_and_sd_properties=cls.model_fields.keys()
|
16
|
+
))
|
arpakitlib/_arpakit_project_template_v_5/project/operation_execution/operation_executor_worker.py
CHANGED
@@ -45,7 +45,18 @@ class OperationExecutorWorker(BaseWorker):
|
|
45
45
|
elif operation_dbm.type == OperationDBM.Types.raise_fake_error_:
|
46
46
|
self._logger.error(f"{OperationDBM.Types.raise_fake_error_}")
|
47
47
|
raise Exception(f"{OperationDBM.Types.raise_fake_error_}")
|
48
|
-
|
48
|
+
else:
|
49
|
+
with self.sqlalchemy_db.new_session() as session:
|
50
|
+
operation_dbm: OperationDBM = session.query(
|
51
|
+
OperationDBM
|
52
|
+
).filter(OperationDBM.id == operation_dbm.id).one()
|
53
|
+
operation_dbm.output_data = combine_dicts(
|
54
|
+
operation_dbm.output_data,
|
55
|
+
{"warning": f"unknown operation_type = {operation_dbm.type=}"}
|
56
|
+
)
|
57
|
+
session.commit()
|
58
|
+
session.refresh(operation_dbm)
|
59
|
+
self._logger.info(f"unknown operation_type, {operation_dbm.id=}, {operation_dbm.type=}")
|
49
60
|
|
50
61
|
async def async_execute_operation(self, *, operation_dbm: OperationDBM):
|
51
62
|
if operation_dbm.type == OperationDBM.Types.healthcheck_:
|
@@ -53,7 +64,19 @@ class OperationExecutorWorker(BaseWorker):
|
|
53
64
|
elif operation_dbm.type == OperationDBM.Types.raise_fake_error_:
|
54
65
|
self._logger.error(f"{OperationDBM.Types.raise_fake_error_}")
|
55
66
|
raise Exception(f"{OperationDBM.Types.raise_fake_error_}")
|
56
|
-
|
67
|
+
else:
|
68
|
+
async with self.sqlalchemy_db.new_async_session() as session:
|
69
|
+
result = await session.execute(
|
70
|
+
sqlalchemy.select(OperationDBM).filter(OperationDBM.id == operation_dbm.id)
|
71
|
+
)
|
72
|
+
operation_dbm: OperationDBM = result.scalar_one()
|
73
|
+
operation_dbm.output_data = combine_dicts(
|
74
|
+
operation_dbm.output_data,
|
75
|
+
{"warning": f"unknown operation_type = {operation_dbm.type}"}
|
76
|
+
)
|
77
|
+
await session.commit()
|
78
|
+
await session.refresh(operation_dbm)
|
79
|
+
self._logger.info(f"unknown operation_type, {operation_dbm.id=}, {operation_dbm.type=}")
|
57
80
|
|
58
81
|
def sync_run(self):
|
59
82
|
# 1
|
@@ -140,7 +163,7 @@ class OperationExecutorWorker(BaseWorker):
|
|
140
163
|
f", operation_id={operation_dbm.id}"
|
141
164
|
f", operation_type={operation_dbm.type}"
|
142
165
|
),
|
143
|
-
|
166
|
+
extra_data={
|
144
167
|
"operation_id": operation_dbm.id,
|
145
168
|
"operation_type": operation_dbm.type,
|
146
169
|
}
|
@@ -236,7 +259,7 @@ class OperationExecutorWorker(BaseWorker):
|
|
236
259
|
f", operation_id={operation_dbm.id}"
|
237
260
|
f", operation_type={operation_dbm.type}"
|
238
261
|
),
|
239
|
-
|
262
|
+
extra_data={
|
240
263
|
"operation_id": operation_dbm.id,
|
241
264
|
"operation_type": operation_dbm.type,
|
242
265
|
}
|
@@ -45,7 +45,8 @@ class ScheduledOperationCreatorWorker(BaseWorker):
|
|
45
45
|
with self.sqlalchemy_db.new_session() as session:
|
46
46
|
operation_dbm = OperationDBM(
|
47
47
|
type=scheduled_operation.type,
|
48
|
-
input_data=scheduled_operation.input_data
|
48
|
+
input_data=scheduled_operation.input_data,
|
49
|
+
status=OperationDBM.Statuses.waiting_for_execution
|
49
50
|
)
|
50
51
|
session.add(operation_dbm)
|
51
52
|
session.commit()
|