From 9980da06851c8bf359188879399bf6e838f7fdf6 Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Tue, 14 Oct 2025 10:25:28 +0000 Subject: [PATCH] Generate auditlog --- .../models/audit_log_entry_response.py | 27 +++++++++++++++++++ .../stackit/auditlog/models/error_response.py | 24 ++++++++++++++++- .../auditlog/models/gateway_error_response.py | 9 ++++++- .../models/list_audit_log_entries_response.py | 9 ++++++- 4 files changed, 66 insertions(+), 3 deletions(-) diff --git a/services/auditlog/src/stackit/auditlog/models/audit_log_entry_response.py b/services/auditlog/src/stackit/auditlog/models/audit_log_entry_response.py index 7c9c91cbf..2f73721dd 100644 --- a/services/auditlog/src/stackit/auditlog/models/audit_log_entry_response.py +++ b/services/auditlog/src/stackit/auditlog/models/audit_log_entry_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 @@ -118,6 +119,19 @@ class AuditLogEntryResponse(BaseModel): "visibility", ] + @field_validator("event_time_stamp", mode="before") + def event_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 + @field_validator("event_type") def event_type_validate_enum(cls, value): """Validates the enum""" @@ -125,6 +139,19 @@ def event_type_validate_enum(cls, value): raise ValueError("must be one of enum values ('ADMIN_ACTIVITY', 'SYSTEM_EVENT', 'POLICY_DENIED')") return value + @field_validator("received_time_stamp", mode="before") + def received_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 + @field_validator("severity") def severity_validate_enum(cls, value): """Validates the enum""" diff --git a/services/auditlog/src/stackit/auditlog/models/error_response.py b/services/auditlog/src/stackit/auditlog/models/error_response.py index 40308da48..82e420c48 100644 --- a/services/auditlog/src/stackit/auditlog/models/error_response.py +++ b/services/auditlog/src/stackit/auditlog/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 @@ -33,6 +42,19 @@ class ErrorResponse(BaseModel): timestamp: Optional[datetime] = Field(default=None, description="Timestamp at which the error occurred.") __properties: ClassVar[List[str]] = ["message", "path", "status", "timestamp"] + @field_validator("timestamp", mode="before") + def timestamp_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/auditlog/src/stackit/auditlog/models/gateway_error_response.py b/services/auditlog/src/stackit/auditlog/models/gateway_error_response.py index 698598ca0..2b90ea284 100644 --- a/services/auditlog/src/stackit/auditlog/models/gateway_error_response.py +++ b/services/auditlog/src/stackit/auditlog/models/gateway_error_response.py @@ -17,7 +17,14 @@ import pprint 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, +) from typing_extensions import Self diff --git a/services/auditlog/src/stackit/auditlog/models/list_audit_log_entries_response.py b/services/auditlog/src/stackit/auditlog/models/list_audit_log_entries_response.py index 2b8610151..95b8689b8 100644 --- a/services/auditlog/src/stackit/auditlog/models/list_audit_log_entries_response.py +++ b/services/auditlog/src/stackit/auditlog/models/list_audit_log_entries_response.py @@ -17,7 +17,14 @@ import pprint 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, +) from typing_extensions import Self from stackit.auditlog.models.audit_log_entry_response import AuditLogEntryResponse