Skip to content

Commit bde7783

Browse files
Generate cdn
1 parent e731cb6 commit bde7783

File tree

5 files changed

+120
-3
lines changed

5 files changed

+120
-3
lines changed

services/cdn/src/stackit/cdn/models/distribution.py

Lines changed: 27 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

@@ -63,13 +64,39 @@ class Distribution(BaseModel):
6364
"waf",
6465
]
6566

67+
@field_validator("created_at", mode="before")
68+
def created_at_change_year_zero_to_one(cls, value):
69+
"""Workaround which prevents year 0 issue"""
70+
if isinstance(value, str):
71+
# Check for year "0000" at the beginning of the string
72+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
73+
if value.startswith("0000-01-01T") and re.match(
74+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
75+
):
76+
# Workaround: Replace "0000" with "0001"
77+
return "0001" + value[4:] # Take "0001" and append the rest of the string
78+
return value
79+
6680
@field_validator("status")
6781
def status_validate_enum(cls, value):
6882
"""Validates the enum"""
6983
if value not in set(["CREATING", "ACTIVE", "UPDATING", "DELETING", "ERROR"]):
7084
raise ValueError("must be one of enum values ('CREATING', 'ACTIVE', 'UPDATING', 'DELETING', 'ERROR')")
7185
return value
7286

87+
@field_validator("updated_at", mode="before")
88+
def updated_at_change_year_zero_to_one(cls, value):
89+
"""Workaround which prevents year 0 issue"""
90+
if isinstance(value, str):
91+
# Check for year "0000" at the beginning of the string
92+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
93+
if value.startswith("0000-01-01T") and re.match(
94+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
95+
):
96+
# Workaround: Replace "0000" with "0001"
97+
return "0001" + value[4:] # Take "0001" and append the rest of the string
98+
return value
99+
73100
model_config = ConfigDict(
74101
populate_by_name=True,
75102
validate_assignment=True,

services/cdn/src/stackit/cdn/models/distribution_logs_record.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,19 @@
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, StrictBool, StrictInt, StrictStr
22+
from pydantic import (
23+
BaseModel,
24+
ConfigDict,
25+
Field,
26+
StrictBool,
27+
StrictInt,
28+
StrictStr,
29+
field_validator,
30+
)
2231
from typing_extensions import Annotated, Self
2332

2433

@@ -50,6 +59,19 @@ class DistributionLogsRecord(BaseModel):
5059
"timestamp",
5160
]
5261

62+
@field_validator("timestamp", mode="before")
63+
def timestamp_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+
5375
model_config = ConfigDict(
5476
populate_by_name=True,
5577
validate_assignment=True,

services/cdn/src/stackit/cdn/models/distribution_statistics_record.py

Lines changed: 28 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, StrictInt
22+
from pydantic import BaseModel, ConfigDict, Field, StrictInt, field_validator
2223
from typing_extensions import Self
2324

2425
from stackit.cdn.models.distribution_statistics_record_regions import (
@@ -48,6 +49,32 @@ class DistributionStatisticsRecord(BaseModel):
4849
"start",
4950
]
5051

52+
@field_validator("end", mode="before")
53+
def end_change_year_zero_to_one(cls, value):
54+
"""Workaround which prevents year 0 issue"""
55+
if isinstance(value, str):
56+
# Check for year "0000" at the beginning of the string
57+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
58+
if value.startswith("0000-01-01T") and re.match(
59+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
60+
):
61+
# Workaround: Replace "0000" with "0001"
62+
return "0001" + value[4:] # Take "0001" and append the rest of the string
63+
return value
64+
65+
@field_validator("start", mode="before")
66+
def start_change_year_zero_to_one(cls, value):
67+
"""Workaround which prevents year 0 issue"""
68+
if isinstance(value, str):
69+
# Check for year "0000" at the beginning of the string
70+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
71+
if value.startswith("0000-01-01T") and re.match(
72+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
73+
):
74+
# Workaround: Replace "0000" with "0001"
75+
return "0001" + value[4:] # Take "0001" and append the rest of the string
76+
return value
77+
5178
model_config = ConfigDict(
5279
populate_by_name=True,
5380
validate_assignment=True,

services/cdn/src/stackit/cdn/models/get_cache_info_response.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
from stackit.cdn.models.get_cache_info_response_history_entry import (
@@ -38,6 +39,19 @@ class GetCacheInfoResponse(BaseModel):
3839
)
3940
__properties: ClassVar[List[str]] = ["history", "lastPurgeTime"]
4041

42+
@field_validator("last_purge_time", mode="before")
43+
def last_purge_time_change_year_zero_to_one(cls, value):
44+
"""Workaround which prevents year 0 issue"""
45+
if isinstance(value, str):
46+
# Check for year "0000" at the beginning of the string
47+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
48+
if value.startswith("0000-01-01T") and re.match(
49+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
50+
):
51+
# Workaround: Replace "0000" with "0001"
52+
return "0001" + value[4:] # Take "0001" and append the rest of the string
53+
return value
54+
4155
model_config = ConfigDict(
4256
populate_by_name=True,
4357
validate_assignment=True,

services/cdn/src/stackit/cdn/models/get_cache_info_response_history_entry.py

Lines changed: 27 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

@@ -32,6 +33,32 @@ class GetCacheInfoResponseHistoryEntry(BaseModel):
3233
type: StrictStr
3334
__properties: ClassVar[List[str]] = ["occuredAt", "occurredAt", "type"]
3435

36+
@field_validator("occured_at", mode="before")
37+
def occured_at_change_year_zero_to_one(cls, value):
38+
"""Workaround which prevents year 0 issue"""
39+
if isinstance(value, str):
40+
# Check for year "0000" at the beginning of the string
41+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
42+
if value.startswith("0000-01-01T") and re.match(
43+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
44+
):
45+
# Workaround: Replace "0000" with "0001"
46+
return "0001" + value[4:] # Take "0001" and append the rest of the string
47+
return value
48+
49+
@field_validator("occurred_at", mode="before")
50+
def occurred_at_change_year_zero_to_one(cls, value):
51+
"""Workaround which prevents year 0 issue"""
52+
if isinstance(value, str):
53+
# Check for year "0000" at the beginning of the string
54+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
55+
if value.startswith("0000-01-01T") and re.match(
56+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
57+
):
58+
# Workaround: Replace "0000" with "0001"
59+
return "0001" + value[4:] # Take "0001" and append the rest of the string
60+
return value
61+
3562
@field_validator("type")
3663
def type_validate_enum(cls, value):
3764
"""Validates the enum"""

0 commit comments

Comments
 (0)