Resetting utils subtree.

This commit is contained in:
2024-12-04 13:35:23 +05:30
parent 964656702a
commit 033a617980
90 changed files with 38 additions and 15145 deletions
+38
View File
@@ -58,6 +58,9 @@ from utils_v2.api.async_quart import (
handle_cancelled_request
)
# Data models:
from utils_v2.api.log import APILogModel
# For asynchronous activities:
import asyncio
@@ -344,6 +347,41 @@ async def get_logs_by_filter(
)
# ---------------------------------------------------------------------------------------------------------------------
@logs_bp.route("/set/api", methods = ["POST"])
@set_api_version(api_version = "2.1.0")
@read_input(sanitize_headers = True, sanitize_data = True)
@should_not_be_under_maintenance(attr_name = "is_under_maintenance")
@only_whitelisted_ips(attr_name = "whitelisted_ips")
@validate_input(data_validator = lambda x: APILogModel(**x))
async def set_api_log(
inbound_headers: dict = None,
inbound_data: dict | APILogModel = None,
inbound_files: dict = None,
**kwargs
):
"""
To set logs from internal whitelisted IPs.
:param inbound_headers: auto-extracted by the decorators.
:param inbound_data: auto-extracted by the decorators.
:param inbound_files: auto-extracted by the decorators.
:param kwargs: Any number of extra inputs supplied by the decorators.
"""
inserted_id = await current_app.mongo.insert_one(
collection = "logs",
document = inbound_data.model_dump()
)
return ResponseModel(
status_code = StatusCodes.OK if inserted_id else StatusCodes.FAILED,
http_code = HttpCodes.SUCCESS if inserted_id else HttpCodes.BAD_REQUEST
)
# *****************************************************************************************************************
# ***** ****
# *** MAIN PROGRAM ***