(20251114) Both APIs ready for production test.

This commit is contained in:
2025-11-14 19:06:00 +05:30
parent 6ddc0e6966
commit a2f6390755
7 changed files with 440 additions and 56 deletions
+1 -1
View File
@@ -76,7 +76,7 @@ class SimpleCosecCredentialsHeaders(BaseModel):
cosecUrl: str = Field(
description = "The URL to Cosec's portal.",
frozen = True,
alias = "X-Cosec-URL"
alias = "X-Cosec-Url"
)
cosecUsername: str = Field(
+131
View File
@@ -0,0 +1,131 @@
"""
AUTHOR:
Khushal P Soonderji
DATE:
Fri, 14th Nov, 2025.
OBJECTIVE:
To provide data model(s) for receiving API requests to get Muster Roll Reports.
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, AwareDatetime
from typing import Optional, Literal, List
# My utils:
from utils_v2.string import regex
from utils_v2.date_time import date_time
# *****************************************************************************************************************
# ***** ****
# *** MACROS / ONE-TIME INIT ***
# ***** ****
# *****************************************************************************************************************
# --- Nothing Yet
# *****************************************************************************************************************
# ***** ****
# *** VARIABLES ***
# ***** ****
# *****************************************************************************************************************
# --- Nothing Yet
# *****************************************************************************************************************
# ***** ****
# *** FUNCTIONS ***
# ***** ****
# *****************************************************************************************************************
class CosecMusterRollReportRequestData(BaseModel):
onDate: AwareDatetime | None = Field(
description = "The date when the report is desired.",
frozen = True,
default = None
)
groupIds: List[str] | str = Field(
description = "Each company/entity in Cosec's system is represented by a group id. This is a list of those ids.",
frozen = True,
)
# ┏┓ ┏•
# ┃ ┏┓┏┓╋┓┏┓
# ┗┛┗┛┛┗┛┗┗┫
# ┛
class Config:
extra = "forbid"
# ┓┏ ┓• ┓ •
# ┃┃┏┓┃┓┏┫┏┓╋┓┏┓┏┓┏
# ┗┛┗┻┗┗┗┻┗┻┗┗┗┛┛┗┛
@field_validator("onDate", mode = "before")
def parse_date_time(cls, value):
if value is None: value = date_time.get_current_utc_date_time(as_string = False)
value = date_time.parse_date_time(
input_value = value,
date_formats = [
"%Y%m%d",
"%Y-%m-%d",
"%Y-%m-%d %H:%M:%S",
"%Y-%m-%d %H:%M:%S%z",
"%Y-%m-%dT%H:%M:%S",
"%Y-%m-%dT%H:%M:%S%z",
],
timezone = date_time.TIMEZONE_UTC
)
return value
@field_validator("groupIds", mode = "after")
def parse_group_ids(cls, value):
if isinstance(value, str): value = value.split(",")
return value
# *****************************************************************************************************************
# ***** ****
# *** MAIN PROGRAM ***
# ***** ****
# *****************************************************************************************************************
if __name__ == "__main__":
pass