Skip to content

Commit 6f2c680

Browse files
Generate intake
1 parent e731cb6 commit 6f2c680

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

services/intake/src/stackit/intake/models/intake_response.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
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

@@ -75,6 +76,19 @@ class IntakeResponse(BaseModel):
7576
"uri",
7677
]
7778

79+
@field_validator("create_time", mode="before")
80+
def create_time_change_year_zero_to_one(cls, value):
81+
"""Workaround which prevents year 0 issue"""
82+
if isinstance(value, str):
83+
# Check for year "0000" at the beginning of the string
84+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
85+
if value.startswith("0000-01-01T") and re.match(
86+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
87+
):
88+
# Workaround: Replace "0000" with "0001"
89+
return "0001" + value[4:] # Take "0001" and append the rest of the string
90+
return value
91+
7892
@field_validator("state")
7993
def state_validate_enum(cls, value):
8094
"""Validates the enum"""

services/intake/src/stackit/intake/models/intake_runner_response.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
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

@@ -59,6 +60,19 @@ class IntakeRunnerResponse(BaseModel):
5960
"uri",
6061
]
6162

63+
@field_validator("create_time", mode="before")
64+
def create_time_change_year_zero_to_one(cls, value):
65+
"""Workaround which prevents year 0 issue"""
66+
if isinstance(value, str):
67+
# Check for year "0000" at the beginning of the string
68+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
69+
if value.startswith("0000-01-01T") and re.match(
70+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
71+
):
72+
# Workaround: Replace "0000" with "0001"
73+
return "0001" + value[4:] # Take "0001" and append the rest of the string
74+
return value
75+
6276
@field_validator("state")
6377
def state_validate_enum(cls, value):
6478
"""Validates the enum"""

services/intake/src/stackit/intake/models/intake_user_response.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
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

@@ -58,6 +59,19 @@ class IntakeUserResponse(BaseModel):
5859
"user",
5960
]
6061

62+
@field_validator("create_time", mode="before")
63+
def create_time_change_year_zero_to_one(cls, value):
64+
"""Workaround which prevents year 0 issue"""
65+
if isinstance(value, str):
66+
# Check for year "0000" at the beginning of the string
67+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
68+
if value.startswith("0000-01-01T") and re.match(
69+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
70+
):
71+
# Workaround: Replace "0000" with "0001"
72+
return "0001" + value[4:] # Take "0001" and append the rest of the string
73+
return value
74+
6175
@field_validator("state")
6276
def state_validate_enum(cls, value):
6377
"""Validates the enum"""

0 commit comments

Comments
 (0)