diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/access_token.py b/services/serviceaccount/src/stackit/serviceaccount/models/access_token.py index 8aeee5414..7bb265cc6 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/access_token.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/access_token.py @@ -15,10 +15,18 @@ import json import pprint +import re # noqa: F401 from datetime import datetime 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, + field_validator, +) from typing_extensions import Self @@ -39,6 +47,32 @@ class AccessToken(BaseModel): ) __properties: ClassVar[List[str]] = ["active", "createdAt", "id", "token", "validUntil"] + @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("valid_until", mode="before") + def valid_until_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 + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/access_token_metadata.py b/services/serviceaccount/src/stackit/serviceaccount/models/access_token_metadata.py index df2ffbfe1..b3bd0779b 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/access_token_metadata.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/access_token_metadata.py @@ -15,10 +15,18 @@ import json import pprint +import re # noqa: F401 from datetime import datetime 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, + field_validator, +) from typing_extensions import Self @@ -38,6 +46,32 @@ class AccessTokenMetadata(BaseModel): ) __properties: ClassVar[List[str]] = ["active", "createdAt", "id", "validUntil"] + @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("valid_until", mode="before") + def valid_until_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 + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_payload.py b/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_payload.py index ab577b157..6865e45f3 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_payload.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_payload.py @@ -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 @@ -53,6 +54,19 @@ def algorithm_validate_enum(cls, value): raise ValueError("must be one of enum values ('RSA_2048', 'RSA_4096')") return value + @field_validator("valid_until", mode="before") + def valid_until_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 + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_response.py b/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_response.py index 5de09c8d0..72b1998fd 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_response.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_response.py @@ -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 @@ -63,6 +64,19 @@ class CreateServiceAccountKeyResponse(BaseModel): "validUntil", ] + @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("key_algorithm") def key_algorithm_validate_enum(cls, value): """Validates the enum""" @@ -84,6 +98,19 @@ def key_type_validate_enum(cls, value): raise ValueError("must be one of enum values ('USER_MANAGED', 'SYSTEM_MANAGED')") return value + @field_validator("valid_until", mode="before") + def valid_until_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 + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/error.py b/services/serviceaccount/src/stackit/serviceaccount/models/error.py index 9c1bcb0f1..2016ce21c 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/error.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/error.py @@ -15,10 +15,11 @@ import json import pprint +import re # noqa: F401 from datetime import datetime from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator from typing_extensions import Self @@ -34,6 +35,19 @@ class Error(BaseModel): time_stamp: datetime = Field(alias="timeStamp") __properties: ClassVar[List[str]] = ["error", "message", "path", "status", "timeStamp"] + @field_validator("time_stamp", mode="before") + def time_stamp_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 + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/get_service_account_key_response.py b/services/serviceaccount/src/stackit/serviceaccount/models/get_service_account_key_response.py index 998de674a..bcd33a0fc 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/get_service_account_key_response.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/get_service_account_key_response.py @@ -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 @@ -63,6 +64,19 @@ class GetServiceAccountKeyResponse(BaseModel): "validUntil", ] + @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("key_algorithm") def key_algorithm_validate_enum(cls, value): """Validates the enum""" @@ -84,6 +98,19 @@ def key_type_validate_enum(cls, value): raise ValueError("must be one of enum values ('USER_MANAGED', 'SYSTEM_MANAGED')") return value + @field_validator("valid_until", mode="before") + def valid_until_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 + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_key_payload.py b/services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_key_payload.py index c4c16a7fc..7bd9b1dd4 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_key_payload.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_key_payload.py @@ -15,10 +15,11 @@ import json import pprint +import re # noqa: F401 from datetime import datetime from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator from typing_extensions import Self @@ -37,6 +38,19 @@ class PartialUpdateServiceAccountKeyPayload(BaseModel): ) __properties: ClassVar[List[str]] = ["active", "validUntil"] + @field_validator("valid_until", mode="before") + def valid_until_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 + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_key_response.py b/services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_key_response.py index c567aea2b..cf6c64f6f 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_key_response.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_key_response.py @@ -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 @@ -53,6 +54,19 @@ class PartialUpdateServiceAccountKeyResponse(BaseModel): "validUntil", ] + @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("key_algorithm") def key_algorithm_validate_enum(cls, value): """Validates the enum""" @@ -74,6 +88,19 @@ def key_type_validate_enum(cls, value): raise ValueError("must be one of enum values ('USER_MANAGED', 'SYSTEM_MANAGED')") return value + @field_validator("valid_until", mode="before") + def valid_until_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 + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/service_account.py b/services/serviceaccount/src/stackit/serviceaccount/models/service_account.py index 7d781fca1..ee257b1bd 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/service_account.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/service_account.py @@ -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 Self diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/service_account_key_list_response.py b/services/serviceaccount/src/stackit/serviceaccount/models/service_account_key_list_response.py index 1e8c9c136..257d6b483 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/service_account_key_list_response.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/service_account_key_list_response.py @@ -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 @@ -53,6 +54,19 @@ class ServiceAccountKeyListResponse(BaseModel): "validUntil", ] + @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("key_algorithm") def key_algorithm_validate_enum(cls, value): """Validates the enum""" @@ -74,6 +88,19 @@ def key_type_validate_enum(cls, value): raise ValueError("must be one of enum values ('USER_MANAGED', 'SYSTEM_MANAGED')") return value + @field_validator("valid_until", mode="before") + def valid_until_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 + model_config = ConfigDict( populate_by_name=True, validate_assignment=True,