186 lines
6.3 KiB
Python
186 lines
6.3 KiB
Python
"""
|
|
|
|
AUTHOR:
|
|
|
|
Khushal P Soonderji
|
|
|
|
DATE:
|
|
|
|
Thursday, 16th Jan., 2025.
|
|
|
|
OBJECTIVE:
|
|
|
|
To provide the structure for the request and response of the APIs that will be used to request OAuth2.0
|
|
authorization for mail services.
|
|
|
|
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
|
|
from typing import Optional, Literal, Any
|
|
|
|
# My utils:
|
|
from utils_v2.string import regex
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** MACROS / ONE-TIME INIT ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
# --- Nothing Yet
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** VARIABLES ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
# --- Nothing Yet
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** FUNCTIONS ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
class OAuthMailGetAuthorizationURLResponse(BaseModel):
|
|
|
|
success: bool = Field(
|
|
description = "To indicate whether or not, the action was a success",
|
|
frozen = False,
|
|
default = False
|
|
)
|
|
|
|
url: str | None = Field(
|
|
description = "The URL to use to integrate the mail client.",
|
|
frozen = False,
|
|
default = None
|
|
)
|
|
|
|
message: str = Field(
|
|
description = "To explain what happened in the process generating a URL.",
|
|
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
|
|
|
|
|
|
# ---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
class OAuthMailHandleCallbackResponse(BaseModel):
|
|
|
|
success: bool = Field(
|
|
description = "To indicate whether or not, the action was a success",
|
|
frozen = False,
|
|
default = False
|
|
)
|
|
|
|
action: Literal[
|
|
"unknown", # ..... Initial value when the user's intent is not known.
|
|
"denied", # ...... The user consciously denied permission.
|
|
"cancelled", # ... The user cancelled the process midway.
|
|
"authorized" # ... The user gave authorization.
|
|
] = Field(
|
|
description = "To describe what the user did with the authorization URL.",
|
|
frozen = True,
|
|
default = "unknown"
|
|
)
|
|
|
|
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
|