Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion services/kms/src/stackit/kms/models/create_key_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set

from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
from pydantic import (
BaseModel,
ConfigDict,
Field,
StrictBool,
StrictStr,
)
from typing_extensions import Annotated, Self

from stackit.kms.models.access_scope import AccessScope
Expand Down
8 changes: 7 additions & 1 deletion services/kms/src/stackit/kms/models/decrypt_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set, Union

from pydantic import BaseModel, ConfigDict, Field, StrictBytes, StrictStr
from pydantic import (
BaseModel,
ConfigDict,
Field,
StrictBytes,
StrictStr,
)
from typing_extensions import Self


Expand Down
8 changes: 7 additions & 1 deletion services/kms/src/stackit/kms/models/decrypted_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set, Union

from pydantic import BaseModel, ConfigDict, Field, StrictBytes, StrictStr
from pydantic import (
BaseModel,
ConfigDict,
Field,
StrictBytes,
StrictStr,
)
from typing_extensions import Self


Expand Down
8 changes: 7 additions & 1 deletion services/kms/src/stackit/kms/models/encrypt_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set, Union

from pydantic import BaseModel, ConfigDict, Field, StrictBytes, StrictStr
from pydantic import (
BaseModel,
ConfigDict,
Field,
StrictBytes,
StrictStr,
)
from typing_extensions import Self


Expand Down
8 changes: 7 additions & 1 deletion services/kms/src/stackit/kms/models/encrypted_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set, Union

from pydantic import BaseModel, ConfigDict, Field, StrictBytes, StrictStr
from pydantic import (
BaseModel,
ConfigDict,
Field,
StrictBytes,
StrictStr,
)
from typing_extensions import Self


Expand Down
27 changes: 27 additions & 0 deletions services/kms/src/stackit/kms/models/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import json
import pprint
import re # noqa: F401
from datetime import datetime
from typing import Any, ClassVar, Dict, List, Optional, Set

Expand Down Expand Up @@ -80,6 +81,32 @@ class Key(BaseModel):
"state",
]

@field_validator("created_at", mode="before")
def created_at_change_year_zero_to_one(cls, value):
"""Workaround which prevents year 0 issue"""
if isinstance(value, str):
# Check for year "0000" at the beginning of the string
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
if value.startswith("0000-01-01T") and re.match(
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
):
# Workaround: Replace "0000" with "0001"
return "0001" + value[4:] # Take "0001" and append the rest of the string
return value

@field_validator("deletion_date", mode="before")
def deletion_date_change_year_zero_to_one(cls, value):
"""Workaround which prevents year 0 issue"""
if isinstance(value, str):
# Check for year "0000" at the beginning of the string
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
if value.startswith("0000-01-01T") and re.match(
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
):
# Workaround: Replace "0000" with "0001"
return "0001" + value[4:] # Take "0001" and append the rest of the string
return value

@field_validator("state")
def state_validate_enum(cls, value):
"""Validates the enum"""
Expand Down
14 changes: 14 additions & 0 deletions services/kms/src/stackit/kms/models/key_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import json
import pprint
import re # noqa: F401
from datetime import datetime
from typing import Any, ClassVar, Dict, List, Optional, Set

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

@field_validator("created_at", mode="before")
def created_at_change_year_zero_to_one(cls, value):
"""Workaround which prevents year 0 issue"""
if isinstance(value, str):
# Check for year "0000" at the beginning of the string
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
if value.startswith("0000-01-01T") and re.match(
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
):
# Workaround: Replace "0000" with "0001"
return "0001" + value[4:] # Take "0001" and append the rest of the string
return value

@field_validator("state")
def state_validate_enum(cls, value):
"""Validates the enum"""
Expand Down
8 changes: 7 additions & 1 deletion services/kms/src/stackit/kms/models/sign_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set, Union

from pydantic import BaseModel, ConfigDict, Field, StrictBytes, StrictStr
from pydantic import (
BaseModel,
ConfigDict,
Field,
StrictBytes,
StrictStr,
)
from typing_extensions import Self


Expand Down
8 changes: 7 additions & 1 deletion services/kms/src/stackit/kms/models/signed_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set, Union

from pydantic import BaseModel, ConfigDict, Field, StrictBytes, StrictStr
from pydantic import (
BaseModel,
ConfigDict,
Field,
StrictBytes,
StrictStr,
)
from typing_extensions import Self


Expand Down
8 changes: 7 additions & 1 deletion services/kms/src/stackit/kms/models/verify_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set, Union

from pydantic import BaseModel, ConfigDict, Field, StrictBytes, StrictStr
from pydantic import (
BaseModel,
ConfigDict,
Field,
StrictBytes,
StrictStr,
)
from typing_extensions import Self


Expand Down
27 changes: 27 additions & 0 deletions services/kms/src/stackit/kms/models/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import json
import pprint
import re # noqa: F401
from datetime import datetime
from typing import Any, ClassVar, Dict, List, Optional, Set

Expand Down Expand Up @@ -66,6 +67,32 @@ class Version(BaseModel):
"state",
]

@field_validator("created_at", mode="before")
def created_at_change_year_zero_to_one(cls, value):
"""Workaround which prevents year 0 issue"""
if isinstance(value, str):
# Check for year "0000" at the beginning of the string
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
if value.startswith("0000-01-01T") and re.match(
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
):
# Workaround: Replace "0000" with "0001"
return "0001" + value[4:] # Take "0001" and append the rest of the string
return value

@field_validator("destroy_date", mode="before")
def destroy_date_change_year_zero_to_one(cls, value):
"""Workaround which prevents year 0 issue"""
if isinstance(value, str):
# Check for year "0000" at the beginning of the string
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
if value.startswith("0000-01-01T") and re.match(
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
):
# Workaround: Replace "0000" with "0001"
return "0001" + value[4:] # Take "0001" and append the rest of the string
return value

@field_validator("state")
def state_validate_enum(cls, value):
"""Validates the enum"""
Expand Down
27 changes: 27 additions & 0 deletions services/kms/src/stackit/kms/models/wrapping_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import json
import pprint
import re # noqa: F401
from datetime import datetime
from typing import Any, ClassVar, Dict, List, Optional, Set

Expand Down Expand Up @@ -69,6 +70,32 @@ class WrappingKey(BaseModel):
"state",
]

@field_validator("created_at", mode="before")
def created_at_change_year_zero_to_one(cls, value):
"""Workaround which prevents year 0 issue"""
if isinstance(value, str):
# Check for year "0000" at the beginning of the string
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
if value.startswith("0000-01-01T") and re.match(
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
):
# Workaround: Replace "0000" with "0001"
return "0001" + value[4:] # Take "0001" and append the rest of the string
return value

@field_validator("expires_at", mode="before")
def expires_at_change_year_zero_to_one(cls, value):
"""Workaround which prevents year 0 issue"""
if isinstance(value, str):
# Check for year "0000" at the beginning of the string
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
if value.startswith("0000-01-01T") and re.match(
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
):
# Workaround: Replace "0000" with "0001"
return "0001" + value[4:] # Take "0001" and append the rest of the string
return value

@field_validator("state")
def state_validate_enum(cls, value):
"""Validates the enum"""
Expand Down