arpakitlib 1.8.52__py3-none-any.whl → 1.8.55__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/.gitignore +1 -0
- arpakitlib/_arpakit_project_template_v_5/arpakitlib_project_template_info.json +1 -1
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/check_sqlalchemy_db.py +4 -4
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/clear_log_file.py +3 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/create_operation.py +3 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_arpakitlib_project_template_info.py +3 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_auth_data.py +3 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_operation.py +3 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_operation_allowed_statuses.py +3 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_operation_allowed_types.py +3 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_settings.py +4 -4
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_sqlalchemy_db_table_name_to_amount.py +3 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_story_log.py +3 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_user.py +81 -0
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/init_sqlalchemy_db.py +3 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/main_router.py +11 -1
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/make_test_data_1.py +41 -0
- arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/reinit_sqlalchemy_db.py +3 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/router/client/get_current_user.py +3 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/router/client/get_current_user_token.py +3 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/router/general/check_authorization.py +5 -4
- arpakitlib/_arpakit_project_template_v_5/project/api/router/general/get_current_api_key.py +3 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/router/general/get_errors_info.py +3 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/router/general/healthcheck.py +3 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/router/general/now_utc_datetime.py +3 -3
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/admin/common.py +3 -1
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/admin/user.py +35 -0
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/client/common.py +1 -0
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/client/user.py +3 -0
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/common/raw_data.py +1 -1
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/general/common.py +4 -1
- arpakitlib/_arpakit_project_template_v_5/project/api/schema/out/general/user.py +3 -0
- arpakitlib/_arpakit_project_template_v_5/project/operation_execution/scheduled_operations.py +1 -1
- arpakitlib/_arpakit_project_template_v_5/project/sandbox/sandbox_1.py +5 -1
- arpakitlib/_arpakit_project_template_v_5/project/sqladmin_/admin_authorize.py +1 -0
- arpakitlib/_arpakit_project_template_v_5/project/sqladmin_/model_view/user.py +1 -0
- arpakitlib/_arpakit_project_template_v_5/project/sqlalchemy_db_/sqlalchemy_model/api_key.py +29 -11
- arpakitlib/_arpakit_project_template_v_5/project/sqlalchemy_db_/sqlalchemy_model/common.py +47 -12
- arpakitlib/_arpakit_project_template_v_5/project/sqlalchemy_db_/sqlalchemy_model/operation.py +81 -12
- arpakitlib/_arpakit_project_template_v_5/project/sqlalchemy_db_/sqlalchemy_model/story_log.py +33 -6
- arpakitlib/_arpakit_project_template_v_5/project/sqlalchemy_db_/sqlalchemy_model/user.py +59 -18
- arpakitlib/_arpakit_project_template_v_5/project/sqlalchemy_db_/sqlalchemy_model/user_token.py +18 -6
- arpakitlib/_arpakit_project_template_v_5/project/sqlalchemy_db_/util.py +0 -28
- arpakitlib/_arpakit_project_template_v_5/project/test_data/make_test_api_keys.py +2 -2
- arpakitlib/_arpakit_project_template_v_5/project/test_data/make_test_data_1.py +36 -0
- arpakitlib/ar_str_util.py +9 -0
- {arpakitlib-1.8.52.dist-info → arpakitlib-1.8.55.dist-info}/METADATA +1 -1
- {arpakitlib-1.8.52.dist-info → arpakitlib-1.8.55.dist-info}/RECORD +51 -50
- arpakitlib/ar_steam_payment_api_client_util.py +0 -21
- arpakitlib/ar_wata_api_client.py +0 -21
- {arpakitlib-1.8.52.dist-info → arpakitlib-1.8.55.dist-info}/LICENSE +0 -0
- {arpakitlib-1.8.52.dist-info → arpakitlib-1.8.55.dist-info}/WHEEL +0 -0
- {arpakitlib-1.8.52.dist-info → arpakitlib-1.8.55.dist-info}/entry_points.txt +0 -0
@@ -10,7 +10,7 @@ from project.sqlalchemy_db_.sqlalchemy_db import get_cached_sqlalchemy_db
|
|
10
10
|
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
11
11
|
|
12
12
|
|
13
|
-
class
|
13
|
+
class CheckSQLAlchemyDbAdminRouteSO(BaseRouteSO, RawDataCommonSO):
|
14
14
|
pass
|
15
15
|
|
16
16
|
|
@@ -21,7 +21,7 @@ api_router = APIRouter()
|
|
21
21
|
path="",
|
22
22
|
name="Check sqlalchemy db",
|
23
23
|
status_code=fastapi.status.HTTP_200_OK,
|
24
|
-
response_model=
|
24
|
+
response_model=CheckSQLAlchemyDbAdminRouteSO | ErrorCommonSO
|
25
25
|
)
|
26
26
|
async def _(
|
27
27
|
*,
|
@@ -38,6 +38,6 @@ async def _(
|
|
38
38
|
]))
|
39
39
|
):
|
40
40
|
get_cached_sqlalchemy_db().is_conn_good()
|
41
|
-
return
|
42
|
-
|
41
|
+
return CheckSQLAlchemyDbAdminRouteSO(
|
42
|
+
raw_data={"is_conn_good": get_cached_sqlalchemy_db().is_conn_good()}
|
43
43
|
)
|
@@ -11,7 +11,7 @@ from project.core.settings import get_cached_settings
|
|
11
11
|
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
12
12
|
|
13
13
|
|
14
|
-
class
|
14
|
+
class ClearLogFileAdminRouteSO(BaseRouteSO, RawDataCommonSO):
|
15
15
|
pass
|
16
16
|
|
17
17
|
|
@@ -22,7 +22,7 @@ api_router = APIRouter()
|
|
22
22
|
path="",
|
23
23
|
name="Clear log file",
|
24
24
|
status_code=fastapi.status.HTTP_200_OK,
|
25
|
-
response_model=
|
25
|
+
response_model=ClearLogFileAdminRouteSO | ErrorCommonSO
|
26
26
|
)
|
27
27
|
def _(
|
28
28
|
*,
|
@@ -41,4 +41,4 @@ def _(
|
|
41
41
|
init_log_file(log_filepath=get_cached_settings().log_filepath)
|
42
42
|
with open(file=get_cached_settings().log_filepath, mode="w") as f:
|
43
43
|
f.write("")
|
44
|
-
return
|
44
|
+
return ClearLogFileAdminRouteSO()
|
@@ -20,7 +20,7 @@ class CreateOperationAdminSI(BaseSI):
|
|
20
20
|
input_data: dict[str, Any] = NotSet
|
21
21
|
|
22
22
|
|
23
|
-
class
|
23
|
+
class CreateOperationAdminRouteSO(BaseRouteSO, OperationAdmin1SO):
|
24
24
|
pass
|
25
25
|
|
26
26
|
|
@@ -31,7 +31,7 @@ api_router = APIRouter()
|
|
31
31
|
"",
|
32
32
|
name="Create operation",
|
33
33
|
status_code=fastapi.status.HTTP_200_OK,
|
34
|
-
response_model=
|
34
|
+
response_model=CreateOperationAdminRouteSO | None | ErrorCommonSO,
|
35
35
|
)
|
36
36
|
async def _(
|
37
37
|
*,
|
@@ -75,4 +75,4 @@ async def _(
|
|
75
75
|
await async_session.commit()
|
76
76
|
await async_session.refresh(operation_dbm)
|
77
77
|
|
78
|
-
return
|
78
|
+
return CreateOperationAdminRouteSO.from_dbm(simple_dbm=operation_dbm)
|
@@ -10,7 +10,7 @@ from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
|
10
10
|
from project.util.arpakitlib_project_template import get_arpakitlib_project_template_info
|
11
11
|
|
12
12
|
|
13
|
-
class
|
13
|
+
class GetArpakitlibProjectTemplateInfoAdminRouteSO(BaseRouteSO, RawDataCommonSO):
|
14
14
|
pass
|
15
15
|
|
16
16
|
|
@@ -21,7 +21,7 @@ api_router = APIRouter()
|
|
21
21
|
"",
|
22
22
|
name="Get arpakitlib project template info",
|
23
23
|
status_code=fastapi.status.HTTP_200_OK,
|
24
|
-
response_model=
|
24
|
+
response_model=GetArpakitlibProjectTemplateInfoAdminRouteSO | ErrorCommonSO
|
25
25
|
)
|
26
26
|
async def _(
|
27
27
|
*,
|
@@ -37,4 +37,4 @@ async def _(
|
|
37
37
|
]))
|
38
38
|
):
|
39
39
|
arpakitlib_project_template_data = get_arpakitlib_project_template_info()
|
40
|
-
return
|
40
|
+
return GetArpakitlibProjectTemplateInfoAdminRouteSO(raw_data=arpakitlib_project_template_data)
|
@@ -10,7 +10,7 @@ from project.api.schema.out.common.raw_data import RawDataCommonSO
|
|
10
10
|
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
11
11
|
|
12
12
|
|
13
|
-
class
|
13
|
+
class GetAuthDataAdminRouteSO(BaseRouteSO, RawDataCommonSO):
|
14
14
|
pass
|
15
15
|
|
16
16
|
|
@@ -21,7 +21,7 @@ api_router = APIRouter()
|
|
21
21
|
path="",
|
22
22
|
name="Get auth data",
|
23
23
|
status_code=fastapi.status.HTTP_200_OK,
|
24
|
-
response_model=
|
24
|
+
response_model=GetAuthDataAdminRouteSO | ErrorCommonSO,
|
25
25
|
)
|
26
26
|
async def _(
|
27
27
|
*,
|
@@ -37,4 +37,4 @@ async def _(
|
|
37
37
|
)
|
38
38
|
]))
|
39
39
|
):
|
40
|
-
return
|
40
|
+
return GetAuthDataAdminRouteSO(raw_data=transfer_data_to_json_str_to_data(api_auth_data.model_dump()))
|
@@ -12,7 +12,7 @@ from project.sqlalchemy_db_.sqlalchemy_db import get_cached_sqlalchemy_db
|
|
12
12
|
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM, OperationDBM
|
13
13
|
|
14
14
|
|
15
|
-
class
|
15
|
+
class GetOperationAdminRouteSO(BaseRouteSO, OperationAdmin1SO):
|
16
16
|
pass
|
17
17
|
|
18
18
|
|
@@ -23,7 +23,7 @@ api_router = APIRouter()
|
|
23
23
|
"",
|
24
24
|
name="Get story log",
|
25
25
|
status_code=fastapi.status.HTTP_200_OK,
|
26
|
-
response_model=
|
26
|
+
response_model=GetOperationAdminRouteSO | None | ErrorCommonSO,
|
27
27
|
)
|
28
28
|
async def _(
|
29
29
|
*,
|
@@ -60,4 +60,4 @@ async def _(
|
|
60
60
|
result = await async_session.scalar(query)
|
61
61
|
if result is None:
|
62
62
|
return None
|
63
|
-
return
|
63
|
+
return GetOperationAdminRouteSO.from_dbm(simple_dbm=result)
|
arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_operation_allowed_statuses.py
CHANGED
@@ -8,7 +8,7 @@ from project.api.schema.out.common.error import ErrorCommonSO
|
|
8
8
|
from project.sqlalchemy_db_.sqlalchemy_model import OperationDBM, UserDBM
|
9
9
|
|
10
10
|
|
11
|
-
class
|
11
|
+
class GetOperationAllowedStatusesAdminRouteSO(BaseRouteSO):
|
12
12
|
allowed_statuses: list[str]
|
13
13
|
|
14
14
|
|
@@ -19,7 +19,7 @@ api_router = APIRouter()
|
|
19
19
|
"",
|
20
20
|
name="Get operation allowed statuses",
|
21
21
|
status_code=fastapi.status.HTTP_200_OK,
|
22
|
-
response_model=
|
22
|
+
response_model=GetOperationAllowedStatusesAdminRouteSO | ErrorCommonSO,
|
23
23
|
)
|
24
24
|
async def _(
|
25
25
|
*,
|
@@ -35,6 +35,6 @@ async def _(
|
|
35
35
|
)
|
36
36
|
]))
|
37
37
|
):
|
38
|
-
return
|
38
|
+
return GetOperationAllowedStatusesAdminRouteSO(
|
39
39
|
allowed_statuses=OperationDBM.Statuses.values_list()
|
40
40
|
)
|
arpakitlib/_arpakit_project_template_v_5/project/api/router/admin/get_operation_allowed_types.py
CHANGED
@@ -8,7 +8,7 @@ from project.api.schema.out.common.error import ErrorCommonSO
|
|
8
8
|
from project.sqlalchemy_db_.sqlalchemy_model import OperationDBM, UserDBM
|
9
9
|
|
10
10
|
|
11
|
-
class
|
11
|
+
class GetOperationAllowedTypesAdminRouteSO(BaseRouteSO):
|
12
12
|
allowed_types: list[str]
|
13
13
|
|
14
14
|
|
@@ -19,7 +19,7 @@ api_router = APIRouter()
|
|
19
19
|
"",
|
20
20
|
name="Get operation allowed types",
|
21
21
|
status_code=fastapi.status.HTTP_200_OK,
|
22
|
-
response_model=
|
22
|
+
response_model=GetOperationAllowedTypesAdminRouteSO | ErrorCommonSO,
|
23
23
|
)
|
24
24
|
async def _(
|
25
25
|
*,
|
@@ -35,6 +35,6 @@ async def _(
|
|
35
35
|
)
|
36
36
|
]))
|
37
37
|
):
|
38
|
-
return
|
38
|
+
return GetOperationAllowedTypesAdminRouteSO(
|
39
39
|
allowed_types=OperationDBM.Types.values_list()
|
40
40
|
)
|
@@ -10,7 +10,7 @@ from project.core.settings import get_cached_settings
|
|
10
10
|
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
11
11
|
|
12
12
|
|
13
|
-
class
|
13
|
+
class GetSettingsAdminRouteSO(BaseRouteSO, RawDataCommonSO):
|
14
14
|
pass
|
15
15
|
|
16
16
|
|
@@ -21,7 +21,7 @@ api_router = APIRouter()
|
|
21
21
|
"",
|
22
22
|
name="Get settings",
|
23
23
|
status_code=fastapi.status.HTTP_200_OK,
|
24
|
-
response_model=
|
24
|
+
response_model=GetSettingsAdminRouteSO | ErrorCommonSO,
|
25
25
|
)
|
26
26
|
async def _(
|
27
27
|
*,
|
@@ -37,6 +37,6 @@ async def _(
|
|
37
37
|
)
|
38
38
|
]))
|
39
39
|
):
|
40
|
-
return
|
41
|
-
|
40
|
+
return GetSettingsAdminRouteSO(
|
41
|
+
raw_data=get_cached_settings().model_dump(mode="json")
|
42
42
|
)
|
@@ -10,7 +10,7 @@ from project.sqlalchemy_db_.sqlalchemy_db import get_cached_sqlalchemy_db
|
|
10
10
|
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
11
11
|
|
12
12
|
|
13
|
-
class
|
13
|
+
class GetAuthDataAdminRouteSO(BaseRouteSO, RawDataCommonSO):
|
14
14
|
pass
|
15
15
|
|
16
16
|
|
@@ -21,7 +21,7 @@ api_router = APIRouter()
|
|
21
21
|
"",
|
22
22
|
name="Get sqlalchemy db table name to amount",
|
23
23
|
status_code=fastapi.status.HTTP_200_OK,
|
24
|
-
response_model=
|
24
|
+
response_model=GetAuthDataAdminRouteSO | ErrorCommonSO
|
25
25
|
)
|
26
26
|
async def _(
|
27
27
|
*,
|
@@ -36,4 +36,4 @@ async def _(
|
|
36
36
|
)
|
37
37
|
]))
|
38
38
|
):
|
39
|
-
return
|
39
|
+
return GetAuthDataAdminRouteSO(raw_data=await get_cached_sqlalchemy_db().async_get_table_name_to_amount())
|
@@ -12,7 +12,7 @@ from project.sqlalchemy_db_.sqlalchemy_db import get_cached_sqlalchemy_db
|
|
12
12
|
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM, StoryLogDBM
|
13
13
|
|
14
14
|
|
15
|
-
class
|
15
|
+
class GetStoryLogAdminRouteSO(BaseRouteSO, StoryLogAdmin1SO):
|
16
16
|
pass
|
17
17
|
|
18
18
|
|
@@ -23,7 +23,7 @@ api_router = APIRouter()
|
|
23
23
|
"",
|
24
24
|
name="Get story log",
|
25
25
|
status_code=fastapi.status.HTTP_200_OK,
|
26
|
-
response_model=
|
26
|
+
response_model=GetStoryLogAdminRouteSO | None | ErrorCommonSO,
|
27
27
|
)
|
28
28
|
async def _(
|
29
29
|
*,
|
@@ -60,4 +60,4 @@ async def _(
|
|
60
60
|
result = await async_session.scalar(query)
|
61
61
|
if result is None:
|
62
62
|
return None
|
63
|
-
return
|
63
|
+
return GetStoryLogAdminRouteSO.from_dbm(simple_dbm=result)
|
@@ -0,0 +1,81 @@
|
|
1
|
+
import fastapi.requests
|
2
|
+
import sqlalchemy
|
3
|
+
from fastapi import APIRouter
|
4
|
+
|
5
|
+
from arpakitlib.ar_str_util import strip_if_not_none, make_none_if_blank
|
6
|
+
from project.api.authorize import APIAuthorizeData, api_authorize, require_user_token_dbm_api_authorize_middleware, \
|
7
|
+
require_api_key_dbm_api_authorize_middleware
|
8
|
+
from project.api.schema.common import BaseRouteSO
|
9
|
+
from project.api.schema.out.admin.user import UserAdmin1SO
|
10
|
+
from project.api.schema.out.common.error import ErrorCommonSO
|
11
|
+
from project.sqlalchemy_db_.sqlalchemy_db import get_cached_sqlalchemy_db
|
12
|
+
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
13
|
+
|
14
|
+
|
15
|
+
class GetUserAdminRouteSO(BaseRouteSO, UserAdmin1SO):
|
16
|
+
pass
|
17
|
+
|
18
|
+
|
19
|
+
api_router = APIRouter()
|
20
|
+
|
21
|
+
|
22
|
+
@api_router.get(
|
23
|
+
"",
|
24
|
+
name="Get user",
|
25
|
+
status_code=fastapi.status.HTTP_200_OK,
|
26
|
+
response_model=GetUserAdminRouteSO | None | ErrorCommonSO,
|
27
|
+
)
|
28
|
+
async def _(
|
29
|
+
*,
|
30
|
+
request: fastapi.requests.Request,
|
31
|
+
response: fastapi.responses.Response,
|
32
|
+
api_auth_data: APIAuthorizeData = fastapi.Depends(api_authorize(middlewares=[
|
33
|
+
require_api_key_dbm_api_authorize_middleware(
|
34
|
+
require_active=True
|
35
|
+
),
|
36
|
+
require_user_token_dbm_api_authorize_middleware(
|
37
|
+
require_active_user_token=True,
|
38
|
+
require_user_roles=[UserDBM.Roles.admin]
|
39
|
+
)
|
40
|
+
])),
|
41
|
+
filter_id: int | None = fastapi.Query(default=None),
|
42
|
+
filter_long_id: str | None = fastapi.Query(default=None),
|
43
|
+
filter_slug: str | None = fastapi.Query(default=None),
|
44
|
+
filter_email: str | None = fastapi.Query(default=None),
|
45
|
+
filter_username: str | None = fastapi.Query(default=None),
|
46
|
+
filter_tg_id: int | None = fastapi.Query(default=None),
|
47
|
+
):
|
48
|
+
filter_long_id = make_none_if_blank(strip_if_not_none(filter_long_id))
|
49
|
+
filter_slug = make_none_if_blank(strip_if_not_none(filter_slug))
|
50
|
+
filter_email = make_none_if_blank(strip_if_not_none(filter_email))
|
51
|
+
filter_username = make_none_if_blank(strip_if_not_none(filter_username))
|
52
|
+
|
53
|
+
if (
|
54
|
+
filter_id is None
|
55
|
+
and filter_long_id is None
|
56
|
+
and filter_slug is None
|
57
|
+
and filter_email is None
|
58
|
+
and filter_username is None
|
59
|
+
and filter_tg_id is None
|
60
|
+
):
|
61
|
+
return None
|
62
|
+
|
63
|
+
query = sqlalchemy.select(UserDBM)
|
64
|
+
if filter_id is not None:
|
65
|
+
query = query.filter(UserDBM.id == filter_id)
|
66
|
+
if filter_long_id is not None:
|
67
|
+
query = query.filter(UserDBM.long_id == filter_long_id)
|
68
|
+
if filter_slug is not None:
|
69
|
+
query = query.filter(UserDBM.slug == filter_slug)
|
70
|
+
if filter_email is not None:
|
71
|
+
query = query.filter(UserDBM.email == filter_email)
|
72
|
+
if filter_username is not None:
|
73
|
+
query = query.filter(UserDBM.username == filter_username)
|
74
|
+
if filter_tg_id is not None:
|
75
|
+
query = query.filter(UserDBM.tg_id == filter_tg_id)
|
76
|
+
|
77
|
+
async with get_cached_sqlalchemy_db().new_async_session() as async_session:
|
78
|
+
result = await async_session.scalar(query)
|
79
|
+
if result is None:
|
80
|
+
return None
|
81
|
+
return GetUserAdminRouteSO.from_dbm(simple_dbm=result)
|
@@ -10,7 +10,7 @@ from project.sqlalchemy_db_.sqlalchemy_db import get_cached_sqlalchemy_db
|
|
10
10
|
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
11
11
|
|
12
12
|
|
13
|
-
class
|
13
|
+
class InitSqlalchemyDbAdminRouteSO(BaseRouteSO, RawDataCommonSO):
|
14
14
|
pass
|
15
15
|
|
16
16
|
|
@@ -21,7 +21,7 @@ api_router = APIRouter()
|
|
21
21
|
path="",
|
22
22
|
name="Init sqlalchemy db",
|
23
23
|
status_code=fastapi.status.HTTP_200_OK,
|
24
|
-
response_model=
|
24
|
+
response_model=InitSqlalchemyDbAdminRouteSO | ErrorCommonSO,
|
25
25
|
)
|
26
26
|
async def _(
|
27
27
|
*,
|
@@ -39,4 +39,4 @@ async def _(
|
|
39
39
|
]))
|
40
40
|
):
|
41
41
|
get_cached_sqlalchemy_db().init()
|
42
|
-
return
|
42
|
+
return InitSqlalchemyDbAdminRouteSO()
|
@@ -3,7 +3,7 @@ from fastapi import APIRouter
|
|
3
3
|
from project.api.router.admin import get_auth_data, get_arpakitlib_project_template_info, raise_fake_error, \
|
4
4
|
reinit_sqlalchemy_db, get_story_log, init_sqlalchemy_db, get_sqlalchemy_db_table_name_to_amount, \
|
5
5
|
get_operation_allowed_statuses, get_operation, create_operation, get_operation_allowed_types, get_log_file, \
|
6
|
-
clear_log_file, check_sqlalchemy_db, get_settings
|
6
|
+
clear_log_file, check_sqlalchemy_db, get_settings, get_user, make_test_data_1
|
7
7
|
|
8
8
|
main_admin_api_router = APIRouter()
|
9
9
|
|
@@ -81,3 +81,13 @@ main_admin_api_router.include_router(
|
|
81
81
|
router=get_settings.api_router,
|
82
82
|
prefix="/get_settings"
|
83
83
|
)
|
84
|
+
|
85
|
+
main_admin_api_router.include_router(
|
86
|
+
router=get_user.api_router,
|
87
|
+
prefix="/get_user"
|
88
|
+
)
|
89
|
+
|
90
|
+
main_admin_api_router.include_router(
|
91
|
+
router=make_test_data_1.api_router,
|
92
|
+
prefix="/make_test_data_1"
|
93
|
+
)
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import fastapi
|
2
|
+
from fastapi import APIRouter
|
3
|
+
|
4
|
+
from project.api.authorize import require_api_key_dbm_api_authorize_middleware, APIAuthorizeData, \
|
5
|
+
require_user_token_dbm_api_authorize_middleware, api_authorize
|
6
|
+
from project.api.schema.common import BaseRouteSO
|
7
|
+
from project.api.schema.out.common.error import ErrorCommonSO
|
8
|
+
from project.api.schema.out.common.raw_data import RawDataCommonSO
|
9
|
+
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
10
|
+
from project.test_data.make_test_data_1 import make_test_data_1
|
11
|
+
|
12
|
+
|
13
|
+
class MakeTestData1AdminRouteSO(BaseRouteSO, RawDataCommonSO):
|
14
|
+
pass
|
15
|
+
|
16
|
+
|
17
|
+
api_router = APIRouter()
|
18
|
+
|
19
|
+
|
20
|
+
@api_router.get(
|
21
|
+
path="",
|
22
|
+
name="Make test data 1",
|
23
|
+
status_code=fastapi.status.HTTP_200_OK,
|
24
|
+
response_model=MakeTestData1AdminRouteSO | ErrorCommonSO
|
25
|
+
)
|
26
|
+
def _(
|
27
|
+
*,
|
28
|
+
request: fastapi.requests.Request,
|
29
|
+
response: fastapi.responses.Response,
|
30
|
+
api_auth_data: APIAuthorizeData = fastapi.Depends(api_authorize(middlewares=[
|
31
|
+
require_api_key_dbm_api_authorize_middleware(
|
32
|
+
require_active=True
|
33
|
+
),
|
34
|
+
require_user_token_dbm_api_authorize_middleware(
|
35
|
+
require_active_user_token=True,
|
36
|
+
require_user_roles=[UserDBM.Roles.admin]
|
37
|
+
)
|
38
|
+
]))
|
39
|
+
):
|
40
|
+
make_test_data_1()
|
41
|
+
return MakeTestData1AdminRouteSO()
|
@@ -11,7 +11,7 @@ from project.sqlalchemy_db_.sqlalchemy_db import get_cached_sqlalchemy_db
|
|
11
11
|
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
12
12
|
|
13
13
|
|
14
|
-
class
|
14
|
+
class ReinitSqlalchemyDbAdminRouteSO(BaseRouteSO, RawDataCommonSO):
|
15
15
|
pass
|
16
16
|
|
17
17
|
|
@@ -22,7 +22,7 @@ api_router = APIRouter()
|
|
22
22
|
path="",
|
23
23
|
name="Reinit sqlalchemy db",
|
24
24
|
status_code=fastapi.status.HTTP_200_OK,
|
25
|
-
response_model=
|
25
|
+
response_model=ReinitSqlalchemyDbAdminRouteSO | ErrorCommonSO,
|
26
26
|
)
|
27
27
|
async def _(
|
28
28
|
*,
|
@@ -40,4 +40,4 @@ async def _(
|
|
40
40
|
]))
|
41
41
|
):
|
42
42
|
get_cached_sqlalchemy_db().reinit()
|
43
|
-
return
|
43
|
+
return ReinitSqlalchemyDbAdminRouteSO()
|
@@ -11,7 +11,7 @@ from project.api.schema.out.common.error import ErrorCommonSO
|
|
11
11
|
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
12
12
|
|
13
13
|
|
14
|
-
class
|
14
|
+
class GetCurrentUserClientRouteSO(BaseRouteSO, UserClient1SO):
|
15
15
|
pass
|
16
16
|
|
17
17
|
|
@@ -22,7 +22,7 @@ api_router = APIRouter()
|
|
22
22
|
"",
|
23
23
|
name="Get current user",
|
24
24
|
status_code=fastapi.status.HTTP_200_OK,
|
25
|
-
response_model=
|
25
|
+
response_model=GetCurrentUserClientRouteSO | ErrorCommonSO,
|
26
26
|
)
|
27
27
|
async def _(
|
28
28
|
*,
|
@@ -38,6 +38,6 @@ async def _(
|
|
38
38
|
)
|
39
39
|
]))
|
40
40
|
):
|
41
|
-
return
|
41
|
+
return GetCurrentUserClientRouteSO.from_dbm(
|
42
42
|
simple_dbm=api_auth_data.user_token_dbm.user
|
43
43
|
)
|
arpakitlib/_arpakit_project_template_v_5/project/api/router/client/get_current_user_token.py
CHANGED
@@ -10,7 +10,7 @@ from project.api.schema.out.common.error import ErrorCommonSO
|
|
10
10
|
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
11
11
|
|
12
12
|
|
13
|
-
class
|
13
|
+
class GetCurrentUserTokenClientRouteSO(BaseRouteSO, UserTokenClient1SO):
|
14
14
|
user: UserClient1SO
|
15
15
|
|
16
16
|
|
@@ -21,7 +21,7 @@ api_router = APIRouter()
|
|
21
21
|
"",
|
22
22
|
name="Get current user token",
|
23
23
|
status_code=fastapi.status.HTTP_200_OK,
|
24
|
-
response_model=
|
24
|
+
response_model=GetCurrentUserTokenClientRouteSO | ErrorCommonSO,
|
25
25
|
)
|
26
26
|
async def _(
|
27
27
|
*,
|
@@ -37,6 +37,6 @@ async def _(
|
|
37
37
|
)
|
38
38
|
]))
|
39
39
|
):
|
40
|
-
return
|
40
|
+
return GetCurrentUserTokenClientRouteSO.from_dbm(
|
41
41
|
simple_dbm=api_auth_data.user_token_dbm
|
42
42
|
)
|
@@ -35,12 +35,13 @@ async def _(
|
|
35
35
|
return CheckAuthorizationGeneralRouteSO(
|
36
36
|
is_current_api_key_ok=api_auth_data.api_key_dbm is not None,
|
37
37
|
is_current_user_token_ok=api_auth_data.user_token_dbm is not None,
|
38
|
-
current_api_key=ApiKeyGeneral1SO.from_dbm(
|
38
|
+
current_api_key=ApiKeyGeneral1SO.from_dbm(
|
39
|
+
simple_dbm=api_auth_data.api_key_dbm
|
40
|
+
) if api_auth_data.api_key_dbm is not None else None,
|
39
41
|
current_user_token=UserTokenGeneral1SO.from_dbm(
|
40
42
|
simple_dbm=api_auth_data.user_token_dbm
|
41
|
-
) if api_auth_data.user_token_dbm is not None else None
|
42
|
-
,
|
43
|
+
) if api_auth_data.user_token_dbm is not None else None,
|
43
44
|
current_user=UserGeneral1SO.from_dbm(
|
44
45
|
simple_dbm=api_auth_data.user_token_dbm.user
|
45
|
-
) if api_auth_data.user_token_dbm is not None else None
|
46
|
+
) if (api_auth_data.user_token_dbm is not None and api_auth_data.user_token_dbm.user is not None) else None
|
46
47
|
)
|
@@ -9,7 +9,7 @@ from project.api.schema.out.general.api_key import ApiKeyGeneral1SO
|
|
9
9
|
from project.sqlalchemy_db_.sqlalchemy_model import UserDBM
|
10
10
|
|
11
11
|
|
12
|
-
class
|
12
|
+
class GetCurrentApiKeyGeneralRouteSO(BaseRouteSO, ApiKeyGeneral1SO):
|
13
13
|
pass
|
14
14
|
|
15
15
|
|
@@ -20,7 +20,7 @@ api_router = APIRouter()
|
|
20
20
|
"",
|
21
21
|
name="Get current api key",
|
22
22
|
status_code=fastapi.status.HTTP_200_OK,
|
23
|
-
response_model=
|
23
|
+
response_model=GetCurrentApiKeyGeneralRouteSO | str | ErrorCommonSO,
|
24
24
|
)
|
25
25
|
async def _(
|
26
26
|
*,
|
@@ -36,6 +36,6 @@ async def _(
|
|
36
36
|
)
|
37
37
|
]))
|
38
38
|
):
|
39
|
-
return
|
39
|
+
return GetCurrentApiKeyGeneralRouteSO.from_dbm(
|
40
40
|
simple_dbm=api_auth_data.api_key_dbm
|
41
41
|
)
|
@@ -7,7 +7,7 @@ from project.api.schema.common import BaseRouteSO
|
|
7
7
|
from project.api.schema.out.common.error import ErrorCommonSO
|
8
8
|
|
9
9
|
|
10
|
-
class
|
10
|
+
class GetErrorsInfoGeneralRouteSO(BaseRouteSO):
|
11
11
|
api_error_codes: list[str] = []
|
12
12
|
api_error_specification_codes: list[str] = []
|
13
13
|
|
@@ -19,7 +19,7 @@ api_router = APIRouter()
|
|
19
19
|
"",
|
20
20
|
name="Get errors info",
|
21
21
|
status_code=fastapi.status.HTTP_200_OK,
|
22
|
-
response_model=
|
22
|
+
response_model=GetErrorsInfoGeneralRouteSO | ErrorCommonSO,
|
23
23
|
)
|
24
24
|
async def _(
|
25
25
|
*,
|
@@ -31,7 +31,7 @@ async def _(
|
|
31
31
|
)
|
32
32
|
]))
|
33
33
|
):
|
34
|
-
return
|
34
|
+
return GetErrorsInfoGeneralRouteSO(
|
35
35
|
api_error_codes=APIErrorCodes.values_list(),
|
36
36
|
api_error_specification_codes=APIErrorSpecificationCodes.values_list()
|
37
37
|
)
|
@@ -8,7 +8,7 @@ from project.api.schema.out.common.error import ErrorCommonSO
|
|
8
8
|
from project.core.util import now_local_dt
|
9
9
|
|
10
10
|
|
11
|
-
class
|
11
|
+
class HealthcheckGeneralRouteSO(BaseRouteSO):
|
12
12
|
is_ok: bool = True
|
13
13
|
datetime: dt.datetime
|
14
14
|
|
@@ -20,11 +20,11 @@ api_router = APIRouter()
|
|
20
20
|
"",
|
21
21
|
name="Healthcheck",
|
22
22
|
status_code=fastapi.status.HTTP_200_OK,
|
23
|
-
response_model=
|
23
|
+
response_model=HealthcheckGeneralRouteSO | ErrorCommonSO,
|
24
24
|
)
|
25
25
|
async def _(
|
26
26
|
*,
|
27
27
|
request: fastapi.requests.Request,
|
28
28
|
response: fastapi.responses.Response
|
29
29
|
):
|
30
|
-
return
|
30
|
+
return HealthcheckGeneralRouteSO(is_ok=True, datetime=now_local_dt())
|
@@ -8,7 +8,7 @@ from project.api.schema.out.common.datetime_ import DatetimeCommonSO
|
|
8
8
|
from project.api.schema.out.common.error import ErrorCommonSO
|
9
9
|
|
10
10
|
|
11
|
-
class
|
11
|
+
class NowUTCDatetimeGeneralRouteSO(BaseRouteSO, DatetimeCommonSO):
|
12
12
|
pass
|
13
13
|
|
14
14
|
|
@@ -19,7 +19,7 @@ api_router = APIRouter()
|
|
19
19
|
"",
|
20
20
|
name="Now UTC datetime",
|
21
21
|
status_code=fastapi.status.HTTP_200_OK,
|
22
|
-
response_model=
|
22
|
+
response_model=NowUTCDatetimeGeneralRouteSO | ErrorCommonSO,
|
23
23
|
)
|
24
24
|
async def _(
|
25
25
|
*,
|
@@ -31,4 +31,4 @@ async def _(
|
|
31
31
|
)
|
32
32
|
]))
|
33
33
|
):
|
34
|
-
return
|
34
|
+
return NowUTCDatetimeGeneralRouteSO.from_datetime(datetime_=now_utc_dt())
|
@@ -18,4 +18,6 @@ class SimpleDBMAdminSO(BaseSO):
|
|
18
18
|
|
19
19
|
@classmethod
|
20
20
|
def from_dbm(cls, *, simple_dbm: SimpleDBM) -> SimpleDBMAdminSO:
|
21
|
-
return cls.model_validate(simple_dbm.simple_dict_with_sd_properties(
|
21
|
+
return cls.model_validate(simple_dbm.simple_dict_with_sd_properties(
|
22
|
+
only_columns_and_sd_properties=cls.model_fields.keys()
|
23
|
+
))
|