Skip to content

Commit 2c7e29b

Browse files
Generate serviceaccount
1 parent e731cb6 commit 2c7e29b

10 files changed

+229
-5
lines changed

services/serviceaccount/src/stackit/serviceaccount/models/access_token.py

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

2432

@@ -39,6 +47,32 @@ class AccessToken(BaseModel):
3947
)
4048
__properties: ClassVar[List[str]] = ["active", "createdAt", "id", "token", "validUntil"]
4149

50+
@field_validator("created_at", mode="before")
51+
def created_at_change_year_zero_to_one(cls, value):
52+
"""Workaround which prevents year 0 issue"""
53+
if isinstance(value, str):
54+
# Check for year "0000" at the beginning of the string
55+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
56+
if value.startswith("0000-01-01T") and re.match(
57+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
58+
):
59+
# Workaround: Replace "0000" with "0001"
60+
return "0001" + value[4:] # Take "0001" and append the rest of the string
61+
return value
62+
63+
@field_validator("valid_until", mode="before")
64+
def valid_until_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+
4276
model_config = ConfigDict(
4377
populate_by_name=True,
4478
validate_assignment=True,

services/serviceaccount/src/stackit/serviceaccount/models/access_token_metadata.py

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

2432

@@ -38,6 +46,32 @@ class AccessTokenMetadata(BaseModel):
3846
)
3947
__properties: ClassVar[List[str]] = ["active", "createdAt", "id", "validUntil"]
4048

49+
@field_validator("created_at", mode="before")
50+
def created_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+
62+
@field_validator("valid_until", mode="before")
63+
def valid_until_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+
4175
model_config = ConfigDict(
4276
populate_by_name=True,
4377
validate_assignment=True,

services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_payload.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

@@ -53,6 +54,19 @@ def algorithm_validate_enum(cls, value):
5354
raise ValueError("must be one of enum values ('RSA_2048', 'RSA_4096')")
5455
return value
5556

57+
@field_validator("valid_until", mode="before")
58+
def valid_until_change_year_zero_to_one(cls, value):
59+
"""Workaround which prevents year 0 issue"""
60+
if isinstance(value, str):
61+
# Check for year "0000" at the beginning of the string
62+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
63+
if value.startswith("0000-01-01T") and re.match(
64+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
65+
):
66+
# Workaround: Replace "0000" with "0001"
67+
return "0001" + value[4:] # Take "0001" and append the rest of the string
68+
return value
69+
5670
model_config = ConfigDict(
5771
populate_by_name=True,
5872
validate_assignment=True,

services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_response.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,6 +64,19 @@ class CreateServiceAccountKeyResponse(BaseModel):
6364
"validUntil",
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("key_algorithm")
6781
def key_algorithm_validate_enum(cls, value):
6882
"""Validates the enum"""
@@ -84,6 +98,19 @@ def key_type_validate_enum(cls, value):
8498
raise ValueError("must be one of enum values ('USER_MANAGED', 'SYSTEM_MANAGED')")
8599
return value
86100

101+
@field_validator("valid_until", mode="before")
102+
def valid_until_change_year_zero_to_one(cls, value):
103+
"""Workaround which prevents year 0 issue"""
104+
if isinstance(value, str):
105+
# Check for year "0000" at the beginning of the string
106+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
107+
if value.startswith("0000-01-01T") and re.match(
108+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
109+
):
110+
# Workaround: Replace "0000" with "0001"
111+
return "0001" + value[4:] # Take "0001" and append the rest of the string
112+
return value
113+
87114
model_config = ConfigDict(
88115
populate_by_name=True,
89116
validate_assignment=True,

services/serviceaccount/src/stackit/serviceaccount/models/error.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, StrictInt, StrictStr
22+
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator
2223
from typing_extensions import Self
2324

2425

@@ -34,6 +35,19 @@ class Error(BaseModel):
3435
time_stamp: datetime = Field(alias="timeStamp")
3536
__properties: ClassVar[List[str]] = ["error", "message", "path", "status", "timeStamp"]
3637

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

services/serviceaccount/src/stackit/serviceaccount/models/get_service_account_key_response.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,6 +64,19 @@ class GetServiceAccountKeyResponse(BaseModel):
6364
"validUntil",
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("key_algorithm")
6781
def key_algorithm_validate_enum(cls, value):
6882
"""Validates the enum"""
@@ -84,6 +98,19 @@ def key_type_validate_enum(cls, value):
8498
raise ValueError("must be one of enum values ('USER_MANAGED', 'SYSTEM_MANAGED')")
8599
return value
86100

101+
@field_validator("valid_until", mode="before")
102+
def valid_until_change_year_zero_to_one(cls, value):
103+
"""Workaround which prevents year 0 issue"""
104+
if isinstance(value, str):
105+
# Check for year "0000" at the beginning of the string
106+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
107+
if value.startswith("0000-01-01T") and re.match(
108+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
109+
):
110+
# Workaround: Replace "0000" with "0001"
111+
return "0001" + value[4:] # Take "0001" and append the rest of the string
112+
return value
113+
87114
model_config = ConfigDict(
88115
populate_by_name=True,
89116
validate_assignment=True,

services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_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, StrictBool
22+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator
2223
from typing_extensions import Self
2324

2425

@@ -37,6 +38,19 @@ class PartialUpdateServiceAccountKeyPayload(BaseModel):
3738
)
3839
__properties: ClassVar[List[str]] = ["active", "validUntil"]
3940

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

services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_key_response.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

@@ -53,6 +54,19 @@ class PartialUpdateServiceAccountKeyResponse(BaseModel):
5354
"validUntil",
5455
]
5556

57+
@field_validator("created_at", mode="before")
58+
def created_at_change_year_zero_to_one(cls, value):
59+
"""Workaround which prevents year 0 issue"""
60+
if isinstance(value, str):
61+
# Check for year "0000" at the beginning of the string
62+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
63+
if value.startswith("0000-01-01T") and re.match(
64+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
65+
):
66+
# Workaround: Replace "0000" with "0001"
67+
return "0001" + value[4:] # Take "0001" and append the rest of the string
68+
return value
69+
5670
@field_validator("key_algorithm")
5771
def key_algorithm_validate_enum(cls, value):
5872
"""Validates the enum"""
@@ -74,6 +88,19 @@ def key_type_validate_enum(cls, value):
7488
raise ValueError("must be one of enum values ('USER_MANAGED', 'SYSTEM_MANAGED')")
7589
return value
7690

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

services/serviceaccount/src/stackit/serviceaccount/models/service_account.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@
1717
import pprint
1818
from typing import Any, ClassVar, Dict, List, Optional, Set
1919

20-
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
20+
from pydantic import (
21+
BaseModel,
22+
ConfigDict,
23+
Field,
24+
StrictBool,
25+
StrictStr,
26+
)
2127
from typing_extensions import Self
2228

2329

0 commit comments

Comments
 (0)