Skip to content

Commit 70cfd3d

Browse files
Generate objectstorage
1 parent a8e19f6 commit 70cfd3d

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

services/objectstorage/src/stackit/objectstorage/models/create_access_key_payload.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515

1616
import json
1717
import pprint
18+
import re # noqa: F401
1819
from datetime import datetime
1920
from 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
2223
from 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

Comments
 (0)