1515
1616import json
1717import pprint
18+ import re # noqa: F401
1819from datetime import datetime
1920from typing import Any , ClassVar , Dict , List , Optional , Set
2021
21- from pydantic import BaseModel , ConfigDict , Field
22+ from pydantic import BaseModel , ConfigDict , Field , field_validator
2223from typing_extensions import Self
2324
2425
@@ -30,6 +31,19 @@ class CreateAccessKeyPayload(BaseModel):
3031 expires : Optional [datetime ] = Field (default = None , description = "Expiration date. Null means never expires." )
3132 __properties : ClassVar [List [str ]] = ["expires" ]
3233
34+ @field_validator ("expires" , mode = "before" )
35+ def expires_change_year_zero_to_one (cls , value ):
36+ """Workaround which prevents year 0 issue"""
37+ if isinstance (value , str ):
38+ # Check for year "0000" at the beginning of the string
39+ # This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
40+ if value .startswith ("0000-01-01T" ) and re .match (
41+ r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$" , value
42+ ):
43+ # Workaround: Replace "0000" with "0001"
44+ return "0001" + value [4 :] # Take "0001" and append the rest of the string
45+ return value
46+
3347 model_config = ConfigDict (
3448 populate_by_name = True ,
3549 validate_assignment = True ,
0 commit comments