diff --git a/services/iaasalpha/src/stackit/iaasalpha/models/add_routing_table_to_area_payload.py b/services/iaasalpha/src/stackit/iaasalpha/models/add_routing_table_to_area_payload.py index 0bf1405f7..d5c08e979 100644 --- a/services/iaasalpha/src/stackit/iaasalpha/models/add_routing_table_to_area_payload.py +++ b/services/iaasalpha/src/stackit/iaasalpha/models/add_routing_table_to_area_payload.py @@ -64,6 +64,19 @@ class AddRoutingTableToAreaPayload(BaseModel): "updatedAt", ] + @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("id") def id_validate_regular_expression(cls, value): """Validates the regular expression""" @@ -83,6 +96,19 @@ def name_validate_regular_expression(cls, value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value + @field_validator("updated_at", mode="before") + def updated_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 + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/services/iaasalpha/src/stackit/iaasalpha/models/network.py b/services/iaasalpha/src/stackit/iaasalpha/models/network.py index 309ba1d50..8386da67c 100644 --- a/services/iaasalpha/src/stackit/iaasalpha/models/network.py +++ b/services/iaasalpha/src/stackit/iaasalpha/models/network.py @@ -79,6 +79,19 @@ class Network(BaseModel): "updatedAt", ] + @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("id") def id_validate_regular_expression(cls, value): """Validates the regular expression""" @@ -100,6 +113,19 @@ def routing_table_id_validate_regular_expression(cls, value): ) return value + @field_validator("updated_at", mode="before") + def updated_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 + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/services/iaasalpha/src/stackit/iaasalpha/models/route.py b/services/iaasalpha/src/stackit/iaasalpha/models/route.py index 42eb0fef4..eb703aecd 100644 --- a/services/iaasalpha/src/stackit/iaasalpha/models/route.py +++ b/services/iaasalpha/src/stackit/iaasalpha/models/route.py @@ -49,6 +49,19 @@ class Route(BaseModel): ) __properties: ClassVar[List[str]] = ["createdAt", "destination", "id", "labels", "nexthop", "updatedAt"] + @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("id") def id_validate_regular_expression(cls, value): """Validates the regular expression""" @@ -61,6 +74,19 @@ def id_validate_regular_expression(cls, value): ) return value + @field_validator("updated_at", mode="before") + def updated_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 + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, diff --git a/services/iaasalpha/src/stackit/iaasalpha/models/routing_table.py b/services/iaasalpha/src/stackit/iaasalpha/models/routing_table.py index 9eab2461d..c6374160c 100644 --- a/services/iaasalpha/src/stackit/iaasalpha/models/routing_table.py +++ b/services/iaasalpha/src/stackit/iaasalpha/models/routing_table.py @@ -64,6 +64,19 @@ class RoutingTable(BaseModel): "updatedAt", ] + @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("id") def id_validate_regular_expression(cls, value): """Validates the regular expression""" @@ -83,6 +96,19 @@ def name_validate_regular_expression(cls, value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value + @field_validator("updated_at", mode="before") + def updated_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 + model_config = ConfigDict( populate_by_name=True, validate_assignment=True,