192 lines
6.5 KiB
Python
192 lines
6.5 KiB
Python
"""
|
|
|
|
AUTHOR:
|
|
|
|
Khushal P Soonderji
|
|
|
|
DATE:
|
|
|
|
Monday, 10th Feb., 2025.
|
|
|
|
OBJECTIVE:
|
|
|
|
Maa chude, yaar. Ab fark nahin padtaa.
|
|
|
|
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, Any
|
|
|
|
# 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 ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
# RegEx Patterns:
|
|
REGEX_SESSION_TOKEN = r"^[a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$"
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** VARIABLES ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
# --- Nothing Yet
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** FUNCTIONS ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
class MikroTikConfigAttemptResponse(BaseModel):
|
|
|
|
actionChain: str | int = Field(
|
|
description = "To be able to link all the actions of one process",
|
|
frozen = False,
|
|
default = None
|
|
)
|
|
|
|
success: bool = Field(
|
|
description = "To indicate whether or not, the action was a success",
|
|
frozen = False,
|
|
default = False
|
|
)
|
|
|
|
message: str = Field(
|
|
description = "To explain what happened in the process of handling the OAuth callback.",
|
|
frozen = False,
|
|
default = "ERR: Message not captured."
|
|
)
|
|
|
|
exception: Any = Field(
|
|
description = "To pass on any exception that occurred in the process.",
|
|
frozen = False,
|
|
default = None
|
|
)
|
|
|
|
# ┏┓ ┏•
|
|
# ┃ ┏┓┏┓╋┓┏┓
|
|
# ┗┛┗┛┛┗┛┗┗┫
|
|
# ┛
|
|
|
|
class Config:
|
|
extra = "forbid"
|
|
|
|
# ┏┓ ┏┓
|
|
# ┃ ┓┏┏╋┏┓┏┳┓ ┣ ┓┏┏┓┏┏
|
|
# ┗┛┗┻┛┗┗┛┛┗┗ ┻ ┗┻┛┗┗┛
|
|
|
|
def __add__(self, other):
|
|
|
|
return MikroTikConfigAttemptResponse(
|
|
actionChain = other.actionChain or self.actionChain,
|
|
success = self.success and other.success,
|
|
message = self.message + " -> " + other.message,
|
|
exception = other.exception or self.exception
|
|
)
|
|
|
|
# ┓┏ ┓• ┓ •
|
|
# ┃┃┏┓┃┓┏┫┏┓╋┓┏┓┏┓
|
|
# ┗┛┗┻┗┗┗┻┗┻┗┗┗┛┛┗
|
|
|
|
pass
|
|
|
|
|
|
# ---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
class MikroTikRollBackAttemptResponse(BaseModel):
|
|
|
|
actionChain: str | int = Field(
|
|
description = "To be able to link all the actions of one process",
|
|
frozen = False,
|
|
default = None
|
|
)
|
|
|
|
success: bool = Field(
|
|
description = "To indicate whether or not, the action was a success",
|
|
frozen = False,
|
|
default = False
|
|
)
|
|
|
|
message: str = Field(
|
|
description = "To explain what happened in the process of handling the OAuth callback.",
|
|
frozen = False,
|
|
default = "ERR: Message not captured."
|
|
)
|
|
|
|
exception: Any = Field(
|
|
description = "To pass on any exception that occurred in the process.",
|
|
frozen = False,
|
|
default = None
|
|
)
|
|
|
|
# ┏┓ ┏•
|
|
# ┃ ┏┓┏┓╋┓┏┓
|
|
# ┗┛┗┛┛┗┛┗┗┫
|
|
# ┛
|
|
|
|
class Config:
|
|
extra = "forbid"
|
|
|
|
# ┏┓ ┏┓
|
|
# ┃ ┓┏┏╋┏┓┏┳┓ ┣ ┓┏┏┓┏┏
|
|
# ┗┛┗┻┛┗┗┛┛┗┗ ┻ ┗┻┛┗┗┛
|
|
|
|
pass
|
|
|
|
# ┓┏ ┓• ┓ •
|
|
# ┃┃┏┓┃┓┏┫┏┓╋┓┏┓┏┓
|
|
# ┗┛┗┻┗┗┗┻┗┻┗┗┗┛┛┗
|
|
|
|
pass
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** MAIN PROGRAM ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
pass
|