diff --git a/services/resourcemanager/src/stackit/resourcemanager/models/error_response.py b/services/resourcemanager/src/stackit/resourcemanager/models/error_response.py index d6225a663..384952ee5 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/error_response.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/error_response.py @@ -15,10 +15,19 @@ import json import pprint +import re # noqa: F401 from datetime import datetime from typing import Any, ClassVar, Dict, List, Optional, Set, Union -from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictFloat, + StrictInt, + StrictStr, + field_validator, +) from typing_extensions import Self @@ -34,6 +43,19 @@ class ErrorResponse(BaseModel): time_stamp: datetime = Field(description="Timestamp at which the error occurred.", 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/resourcemanager/src/stackit/resourcemanager/models/folder_response.py b/services/resourcemanager/src/stackit/resourcemanager/models/folder_response.py index 37d8925ef..f95576806 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/folder_response.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/folder_response.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, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from typing_extensions import Self from stackit.resourcemanager.models.parent import Parent @@ -49,6 +50,32 @@ class FolderResponse(BaseModel): "updateTime", ] + @field_validator("creation_time", mode="before") + def creation_time_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("update_time", mode="before") + def update_time_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/resourcemanager/src/stackit/resourcemanager/models/get_folder_details_response.py b/services/resourcemanager/src/stackit/resourcemanager/models/get_folder_details_response.py index 1971ad9e1..a9dbd6cb0 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/get_folder_details_response.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/get_folder_details_response.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, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from typing_extensions import Self from stackit.resourcemanager.models.parent import Parent @@ -52,6 +53,32 @@ class GetFolderDetailsResponse(BaseModel): "updateTime", ] + @field_validator("creation_time", mode="before") + def creation_time_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("update_time", mode="before") + def update_time_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/resourcemanager/src/stackit/resourcemanager/models/get_project_response.py b/services/resourcemanager/src/stackit/resourcemanager/models/get_project_response.py index 60b1308a2..469589f63 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/get_project_response.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/get_project_response.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, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from typing_extensions import Self from stackit.resourcemanager.models.lifecycle_state import LifecycleState @@ -55,6 +56,32 @@ class GetProjectResponse(BaseModel): "updateTime", ] + @field_validator("creation_time", mode="before") + def creation_time_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("update_time", mode="before") + def update_time_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/resourcemanager/src/stackit/resourcemanager/models/list_folders_response_items_inner.py b/services/resourcemanager/src/stackit/resourcemanager/models/list_folders_response_items_inner.py index 45a7b0242..117fad493 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/list_folders_response_items_inner.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/list_folders_response_items_inner.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, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from typing_extensions import Self from stackit.resourcemanager.models.parent import Parent @@ -49,6 +50,32 @@ class ListFoldersResponseItemsInner(BaseModel): "updateTime", ] + @field_validator("creation_time", mode="before") + def creation_time_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("update_time", mode="before") + def update_time_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/resourcemanager/src/stackit/resourcemanager/models/list_organizations_response_items_inner.py b/services/resourcemanager/src/stackit/resourcemanager/models/list_organizations_response_items_inner.py index dc0ab923a..71c2931ae 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/list_organizations_response_items_inner.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/list_organizations_response_items_inner.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, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from typing_extensions import Self from stackit.resourcemanager.models.lifecycle_state import LifecycleState @@ -53,6 +54,32 @@ class ListOrganizationsResponseItemsInner(BaseModel): "updateTime", ] + @field_validator("creation_time", mode="before") + def creation_time_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("update_time", mode="before") + def update_time_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/resourcemanager/src/stackit/resourcemanager/models/organization_response.py b/services/resourcemanager/src/stackit/resourcemanager/models/organization_response.py index a21adec45..0084e28ad 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/organization_response.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/organization_response.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, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from typing_extensions import Self from stackit.resourcemanager.models.lifecycle_state import LifecycleState @@ -53,6 +54,32 @@ class OrganizationResponse(BaseModel): "updateTime", ] + @field_validator("creation_time", mode="before") + def creation_time_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("update_time", mode="before") + def update_time_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/resourcemanager/src/stackit/resourcemanager/models/project.py b/services/resourcemanager/src/stackit/resourcemanager/models/project.py index 2e8840dfb..3f5a18f12 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/project.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/project.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, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from typing_extensions import Self from stackit.resourcemanager.models.lifecycle_state import LifecycleState @@ -52,6 +53,32 @@ class Project(BaseModel): "updateTime", ] + @field_validator("creation_time", mode="before") + def creation_time_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("update_time", mode="before") + def update_time_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,