""" AUTHOR: Khushal P Soonderji DATE: Wednesday, 25th Dec., 2024. OBJECTIVE: To provide a structure to work with requests surrounding Log handling. REFERENCES: N/A DOWNLOADS: N/A """ # ***************************************************************************************************************** # ***** **** # *** IMPORT *** # ***** **** # ***************************************************************************************************************** # To make sibling directories accessible for imports: import sys sys.path.append(".") sys.path.append("..") # For making data behaviour_models: from pydantic import BaseModel, Field, field_validator, PastDatetime, model_validator from typing import Optional, Literal, Union # My utils: from utils_v2.string import regex from utils_v2.date_time import date_time # To work with date and time: import datetime # ***************************************************************************************************************** # ***** **** # *** MACROS / ONE-TIME INIT *** # ***** **** # ***************************************************************************************************************** # --- Nothing Yet # ***************************************************************************************************************** # ***** **** # *** VARIABLES *** # ***** **** # ***************************************************************************************************************** # --- Nothing Yet # ***************************************************************************************************************** # ***** **** # *** FUNCTIONS *** # ***** **** # ***************************************************************************************************************** class LogsByFilterRequestData(BaseModel): filter: dict = Field( description = "the filter condition(s) while picking logs", frozen = True ) limit: int = Field( description = "the max. logs to pick", default = 25, frozen = True ) skip: int = Field( description = "how many initial matches to skip before picking logs; needed for pagination", default = 0, frozen = True ) sort: dict = Field( description = "the sorting conditions for the picked logs", default = {"_id": -1}, frozen = True ) projection: dict = Field( description = "to decide what fields are retrieved", default = {"_id": False}, frozen = True ) # ┏┓ ┏• # ┃ ┏┓┏┓╋┓┏┓ # ┗┛┗┛┛┗┛┗┗┫ # ┛ class Config: extra = "forbid" # ┓┏ ┓• ┓ • # ┃┃┏┓┃┓┏┫┏┓╋┓┏┓┏┓ # ┗┛┗┻┗┗┗┻┗┻┗┗┗┛┛┗ @field_validator("unsetJson", "setJson", mode = "before") def ensure_non_null(cls, value): if value is None: value = {} return value # ***************************************************************************************************************** # ***** **** # *** MAIN PROGRAM *** # ***** **** # ***************************************************************************************************************** if __name__ == "__main__": pass