Skip to content

Commit 8412b09

Browse files
Generate kms
1 parent e731cb6 commit 8412b09

File tree

12 files changed

+151
-8
lines changed

12 files changed

+151
-8
lines changed

services/kms/src/stackit/kms/models/create_key_payload.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 Annotated, Self
2228

2329
from stackit.kms.models.access_scope import AccessScope

services/kms/src/stackit/kms/models/decrypt_payload.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, Union
1919

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

2329

services/kms/src/stackit/kms/models/decrypted_data.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, Union
1919

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

2329

services/kms/src/stackit/kms/models/encrypt_payload.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, Union
1919

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

2329

services/kms/src/stackit/kms/models/encrypted_data.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, Union
1919

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

2329

services/kms/src/stackit/kms/models/key.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

@@ -80,6 +81,32 @@ class Key(BaseModel):
8081
"state",
8182
]
8283

84+
@field_validator("created_at", mode="before")
85+
def created_at_change_year_zero_to_one(cls, value):
86+
"""Workaround which prevents year 0 issue"""
87+
if isinstance(value, str):
88+
# Check for year "0000" at the beginning of the string
89+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
90+
if value.startswith("0000-01-01T") and re.match(
91+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
92+
):
93+
# Workaround: Replace "0000" with "0001"
94+
return "0001" + value[4:] # Take "0001" and append the rest of the string
95+
return value
96+
97+
@field_validator("deletion_date", mode="before")
98+
def deletion_date_change_year_zero_to_one(cls, value):
99+
"""Workaround which prevents year 0 issue"""
100+
if isinstance(value, str):
101+
# Check for year "0000" at the beginning of the string
102+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
103+
if value.startswith("0000-01-01T") and re.match(
104+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
105+
):
106+
# Workaround: Replace "0000" with "0001"
107+
return "0001" + value[4:] # Take "0001" and append the rest of the string
108+
return value
109+
83110
@field_validator("state")
84111
def state_validate_enum(cls, value):
85112
"""Validates the enum"""

services/kms/src/stackit/kms/models/key_ring.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

@@ -40,6 +41,19 @@ class KeyRing(BaseModel):
4041
state: StrictStr = Field(description="The current state of the key ring.")
4142
__properties: ClassVar[List[str]] = ["createdAt", "description", "displayName", "id", "state"]
4243

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

services/kms/src/stackit/kms/models/sign_payload.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, Union
1919

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

2329

services/kms/src/stackit/kms/models/signed_data.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, Union
1919

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

2329

services/kms/src/stackit/kms/models/verify_payload.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, Union
1919

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

2329

0 commit comments

Comments
 (0)