diff --git a/CHANGELOG.md b/CHANGELOG.md index aafc8c1d8..38bc365de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,78 @@ ## Release (2026-MM-DD) -- `cost`: [v0.1.0](services/cost/CHANGELOG.md#v010) - - **New**: STACKIT cost service +- `auditlog`: + - [v0.2.0](services/auditlog/CHANGELOG.md#v020) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `authorization`: + - [v0.8.0](services/authorization/CHANGELOG.md#080) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `cost`: + - [v0.2.0](services/cost/CHANGELOG.md#v020) + - **Feature:** regenerate with openapi-generator v7.22.0 + - [v0.1.0](services/cost/CHANGELOG.md#v010) + - **New**: STACKIT cost service +- `dns`: + - [v0.6.0](services/dns/CHANGELOG.md#v060) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `edge`: + - [v0.4.0](services/edge/CHANGELOG.md#v040) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `git`: + - [v0.9.0](services/git/CHANGELOG.md#v090) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `intake`: + - [v0.6.0](services/intake/CHANGELOG.md#v060) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `logme`: + - [v0.5.0](services/logme/CHANGELOG.md#v050) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `logs`: + - [v0.3.0](services/logs/CHANGELOG.md#v030) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `mariadb`: + - [v0.4.0](services/mariadb/CHANGELOG.md#v040) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `modelserving`: + - [v0.3.0](services/modelserving/CHANGELOG.md#v030) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `mongodbflex`: + - [v1.3.0](services/mongodbflex/CHANGELOG.md#v130) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `opensearch`: + - [v0.5.0](services/opensearch/CHANGELOG.md#v050) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `postgresflex`: + - [v1.3.0](services/postgresflex/CHANGELOG.md#v130) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `rabbitmq`: + - [v0.5.0](services/rabbitmq/CHANGELOG.md#v050) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `redis`: + - [v0.4.0](services/redis/CHANGELOG.md#v040) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `resourcemanager`: + - [v0.8.0](services/resourcemanager/CHANGELOG.md#v080) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `runcommand`: + - [v1.2.0](services/runcommand/CHANGELOG.md#v120) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `scf`: + - [v0.5.0](services/scf/CHANGELOG.md#v050) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `secretsmanager`: + - [v0.5.0](services/secretsmanager/CHANGELOG.md#v050) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `serverbackup`: + - [v1.2.0](services/serverbackup/CHANGELOG.md#v120) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `serverupdate`: + - [v1.2.0](services/serverupdate/CHANGELOG.md#v120) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `serviceenablement`: + - [v1.2.0](services/serviceenablement/CHANGELOG.md#v120) + - **Feature:** regenerate with openapi-generator v7.22.0 - `sfs`: + - [v0.6.0](services/sfs/CHANGELOG.md#v060) + - **Feature:** regenerate with openapi-generator v7.22.0 - [v0.5.0](services/sfs/CHANGELOG.md#v050) - **Deprecation:** deprecated field `schedules` in model `SnapshotPolicy` - **Feature:** new field `snapshotSchedules` in model `SnapshotPolicy` @@ -16,45 +87,84 @@ - **Feature:** model `UpdateResourcePoolPayload` now has an additional field `snapshotPolicyId` - **Feature:** new models: `DisableLockResponse`, `EnableLockResponse`, `GetLockResponse`, `GetScheduleResponse`, `GetSnapshotPolicyResponse`, `ListSchedulesResponse`, `ListSnapshotPoliciesResponse`, `ResourcePoolSnapshotPolicy`, `Schedule`, `SnapshotPolicy`, `SnapshotPolicySchedule`, `UpdateResourcePoolSnapshotPayload`, `UpdateResourcePoolSnapshotResponse` - **Feature:** new operations: `UpdateResourcePoolSnapshot`, `ListSchedules`, `GetSchedule`, `ListSnapshotPolicies`, `GetSnapshotPolicy`, `DisableLock`, `GetLock`, `EnableLock`, -- `ske`: [v1.8.0](services/ske/CHANGELOG.md#v180) - - **Breaking Change:** Change status codes: remove 200, change response type of 202 and add 400 in some API calls - - **Breaking Change:** Aligned CRI name validation with the API side validation (removed docker) - - **Feature:** New models `ExpirationStatus`, `ExpirationStatusKubernetes` and `ExpirationStatusNodepool` - - **Feature:** Add attribute `expiration` of type `ExpirationStatus` to model `ClusterStatus` - - **Improvement:** Update description of `AccessScope` -- `iaas`: [v1.3.0](services/iaas/CHANGELOG.md#v130) - - **Feature:** Add optional `cascade` parameter to `delete_volume` API call - - **Feature:** Add `config_drive` attribute to ModelClass `Server` and `CreateServerPayload` -- `alb`: [v0.9.3](services/alb/CHANGELOG.md#v093) - - Add HTTP 429 status code to some API client methods -- `cdn`: [v2.5.0](services/cdn/CHANGELOG.md#v250) - - **Feature:** New model classes `TlsConfigPatch` and `TlsConfig` - - **Feature:** add attributes `forwardHostHeader`, `stripResponseCookies` and `tls` to the model classes: - - `Config` - - `ConfigPatch` - - `CreateDistributionPayload` -- `certificates`: [v1.3.1](services/certificates/CHANGELOG.md#v131) - - Add HTTP 429 status code to some API client methods -- `loadbalancer`: [v0.9.3](services/loadbalancer/CHANGELOG.md#v093) - - Add HTTP 429 status code to some API client methods -- `iaas`: [v1.2.2](services/iaas/CHANGELOG.md#v122) - - **Docs:** Extend description of `PortRange` class -- `kms`: [v0.9.0](services/kms/CHANGELOG.md#v090) - - Set field `public_key` optional in `WrappingKey` model -- `objectstorage`: [v1.3.0](services/objectstorage/CHANGELOG.md#v130) - - **Feature:** New models: `SetDefaultRetentionPayload`, `GetCredentialsGroupResponse`, `DeleteDefaultRetentionResponse`, `DefaultRetentionResponse`, `CredentialsGroupExtended`, `ComplianceLockResponse` - - **Feature:** New enum type `RetentionMode` - - **Feature:** New field `object_lock_enabled` in `Bucket` model struct - - **Feature:** New API client methods: `create_compliance_lock`, `delete_compliance_lock`, `delete_default_retention`, `get_compliance_lock`, `get_credentials_group`, `get_default_retention`, `set_default_retention` +- `ske`: + - [v1.9.0](services/ske/CHANGELOG.md#v190) + - **Feature:** regenerate with openapi-generator v7.22.0 + - [v1.8.0](services/ske/CHANGELOG.md#v180) + - **Breaking Change:** Change status codes: remove 200, change response type of 202 and add 400 in some API calls + - **Breaking Change:** Aligned CRI name validation with the API side validation (removed docker) + - **Feature:** New models `ExpirationStatus`, `ExpirationStatusKubernetes` and `ExpirationStatusNodepool` + - **Feature:** Add attribute `expiration` of type `ExpirationStatus` to model `ClusterStatus` + - **Improvement:** Update description of `AccessScope` +- `sqlserverflex`: + - [v1.2.0](services/sqlserverflex/CHANGELOG.md#v120) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `telemetryrouter`: + - [v0.2.0](services/telemetryrouter/CHANGELOG.md#v020) + - **Feature:** regenerate with openapi-generator v7.22.0 +- `iaas`: + - [v1.4.0](services/iaas/CHANGELOG.md#v140) + - **Feature:** regenerate with openapi-generator v7.22.0 + - [v1.3.0](services/iaas/CHANGELOG.md#v130) + - **Feature:** Add optional `cascade` parameter to `delete_volume` API call + - **Feature:** Add `config_drive` attribute to ModelClass `Server` and `CreateServerPayload` +- `alb`: + - [v0.10.0](services/alb/CHANGELOG.md#v0100) + - **Feature:** regenerate with openapi-generator v7.22.0 + - [v0.9.3](services/alb/CHANGELOG.md#v093) + - Add HTTP 429 status code to some API client methods +- `cdn`: + - [v2.6.0](services/cdn/CHANGELOG.md#v260) + - **Feature:** regenerate with openapi-generator v7.22.0 + - [v2.5.0](services/cdn/CHANGELOG.md#v250) + - **Feature:** New model classes `TlsConfigPatch` and `TlsConfig` + - **Feature:** add attributes `forwardHostHeader`, `stripResponseCookies` and `tls` to the model classes: + - `Config` + - `ConfigPatch` + - `CreateDistributionPayload` +- `certificates`: + - [v1.4.0](services/certificates/CHANGELOG.md#v140) + - **Feature:** regenerate with openapi-generator v7.22.0 + - [v1.3.1](services/certificates/CHANGELOG.md#v131) + - Add HTTP 429 status code to some API client methods +- `loadbalancer`: + - [v0.10.0](services/loadbalancer/CHANGELOG.md#v0100) + - **Feature:** regenerate with openapi-generator v7.22.0 + - [v0.9.3](services/loadbalancer/CHANGELOG.md#v093) + - Add HTTP 429 status code to some API client methods +- `iaas`: + - [v1.2.2](services/iaas/CHANGELOG.md#v122) + - **Docs:** Extend description of `PortRange` class +- `kms`: + - [v0.10.0](services/kms/CHANGELOG.md#v0100) + - **Feature:** regenerate with openapi-generator v7.22.0 + - [v0.9.0](services/kms/CHANGELOG.md#v090) + - Set field `public_key` optional in `WrappingKey` model +- `objectstorage`: + - [v1.4.0](services/objectstorage/CHANGELOG.md#v140) + - **Feature:** regenerate with openapi-generator v7.22.0 + - [v1.3.0](services/objectstorage/CHANGELOG.md#v130) + - **Feature:** New models: `SetDefaultRetentionPayload`, `GetCredentialsGroupResponse`, `DeleteDefaultRetentionResponse`, `DefaultRetentionResponse`, `CredentialsGroupExtended`, `ComplianceLockResponse` + - **Feature:** New enum type `RetentionMode` + - **Feature:** New field `object_lock_enabled` in `Bucket` model struct + - **Feature:** New API client methods: `create_compliance_lock`, `delete_compliance_lock`, `delete_default_retention`, `get_compliance_lock`, `get_credentials_group`, `get_default_retention`, `set_default_retention` - `serviceaccount`: + - [v0.8.0](services/serviceaccount/CHANGELOG.md#v080) + - **Feature:** regenerate with openapi-generator v7.22.0 - [v0.7.0](services/serviceaccount/CHANGELOG.md#v070) - **Feature:** Add `token_endpoint` attribute to `CreateServiceAccountKeyResponseCredentials` model class - [v0.8.0](services/serviceaccount/CHANGELOG.md#v080) - **Feature:** New API client method `get_federated_identity_provider` -- `observability`: [v0.14.0](services/observability/CHANGELOG.md#v0140) - - **Feature:** Add attribute `otlp_http_logs_url` to `InstanceSensitiveData` model class -- `vpn`: [v0.1.0](services/vpn/CHANGELOG.md#v010) - - Initial publication of STACKIT Python SDK module for STACKIT VPN service +- `observability`: + - [v0.15.0](services/observability/CHANGELOG.md#v0150) + - **Feature:** regenerate with openapi-generator v7.22.0 + - [v0.14.0](services/observability/CHANGELOG.md#v0140) + - **Feature:** Add attribute `otlp_http_logs_url` to `InstanceSensitiveData` model class +- `vpn`: + - [v0.2.0](services/vpn/CHANGELOG.md#v020) + - **Feature:** regenerate with openapi-generator v7.22.0 + - [v0.1.0](services/vpn/CHANGELOG.md#v010) + - Initial publication of STACKIT Python SDK module for STACKIT VPN service ## Release (2026-03-27) diff --git a/services/alb/CHANGELOG.md b/services/alb/CHANGELOG.md index c5af6ddc7..e562805fe 100644 --- a/services/alb/CHANGELOG.md +++ b/services/alb/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.10.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.9.3 - Add HTTP 429 status code to some API client methods diff --git a/services/alb/pyproject.toml b/services/alb/pyproject.toml index 9283e7920..1baac2006 100644 --- a/services/alb/pyproject.toml +++ b/services/alb/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-alb" -version = "v0.9.3" +version = "v0.10.0" description = "Application Load Balancer API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/alb/src/stackit/alb/api_client.py b/services/alb/src/stackit/alb/api_client.py index c50fe9337..a3f0f874b 100644 --- a/services/alb/src/stackit/alb/api_client.py +++ b/services/alb/src/stackit/alb/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/alb/src/stackit/alb/models/active_health_check.py b/services/alb/src/stackit/alb/models/active_health_check.py index 5f2188bc2..f7d5ec3d4 100644 --- a/services/alb/src/stackit/alb/models/active_health_check.py +++ b/services/alb/src/stackit/alb/models/active_health_check.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.alb.models.http_health_checks import HttpHealthChecks @@ -66,6 +67,9 @@ def interval_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$", value): raise ValueError(r"must validate the regular expression /^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$/") return value @@ -76,6 +80,9 @@ def interval_jitter_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$", value): raise ValueError(r"must validate the regular expression /^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$/") return value @@ -86,12 +93,16 @@ def timeout_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$", value): raise ValueError(r"must validate the regular expression /^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -102,8 +113,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/certificate_config.py b/services/alb/src/stackit/alb/models/certificate_config.py index bd1fc8b63..0274b8941 100644 --- a/services/alb/src/stackit/alb/models/certificate_config.py +++ b/services/alb/src/stackit/alb/models/certificate_config.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class CertificateConfig(BaseModel): __properties: ClassVar[List[str]] = ["certificateIds"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/cookie_persistence.py b/services/alb/src/stackit/alb/models/cookie_persistence.py index 16aa42f82..a6ca26d9f 100644 --- a/services/alb/src/stackit/alb/models/cookie_persistence.py +++ b/services/alb/src/stackit/alb/models/cookie_persistence.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -40,12 +41,16 @@ def ttl_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$", value): raise ValueError(r"must validate the regular expression /^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +61,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/create_credentials_payload.py b/services/alb/src/stackit/alb/models/create_credentials_payload.py index 77f8995cd..86c84697b 100644 --- a/services/alb/src/stackit/alb/models/create_credentials_payload.py +++ b/services/alb/src/stackit/alb/models/create_credentials_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -46,12 +47,16 @@ def display_name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,251}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,251}[0-9a-z])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -62,8 +67,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/create_credentials_response.py b/services/alb/src/stackit/alb/models/create_credentials_response.py index 6a4d93190..7cb5eeeff 100644 --- a/services/alb/src/stackit/alb/models/create_credentials_response.py +++ b/services/alb/src/stackit/alb/models/create_credentials_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.alb.models.credentials_response import CredentialsResponse @@ -32,7 +33,8 @@ class CreateCredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["credential"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/create_load_balancer_payload.py b/services/alb/src/stackit/alb/models/create_load_balancer_payload.py index 3a6360d3e..3168cec1f 100644 --- a/services/alb/src/stackit/alb/models/create_load_balancer_payload.py +++ b/services/alb/src/stackit/alb/models/create_load_balancer_payload.py @@ -26,6 +26,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.alb.models.listener import Listener @@ -123,6 +124,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value @@ -142,7 +146,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -153,8 +158,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/credentials_response.py b/services/alb/src/stackit/alb/models/credentials_response.py index 50dec693a..76821555b 100644 --- a/services/alb/src/stackit/alb/models/credentials_response.py +++ b/services/alb/src/stackit/alb/models/credentials_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -47,12 +48,16 @@ def display_name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -63,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/get_credentials_response.py b/services/alb/src/stackit/alb/models/get_credentials_response.py index 606c6da8a..af747aaa7 100644 --- a/services/alb/src/stackit/alb/models/get_credentials_response.py +++ b/services/alb/src/stackit/alb/models/get_credentials_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.alb.models.credentials_response import CredentialsResponse @@ -32,7 +33,8 @@ class GetCredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["credential"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/get_quota_response.py b/services/alb/src/stackit/alb/models/get_quota_response.py index 2425d07c6..df327643a 100644 --- a/services/alb/src/stackit/alb/models/get_quota_response.py +++ b/services/alb/src/stackit/alb/models/get_quota_response.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -65,6 +66,9 @@ def project_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/" @@ -77,12 +81,16 @@ def region_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z]{2,4}[0-9]{2}$", value): raise ValueError(r"must validate the regular expression /^[a-z]{2,4}[0-9]{2}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -93,8 +101,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/google_protobuf_any.py b/services/alb/src/stackit/alb/models/google_protobuf_any.py index 59e120614..7a72b8857 100644 --- a/services/alb/src/stackit/alb/models/google_protobuf_any.py +++ b/services/alb/src/stackit/alb/models/google_protobuf_any.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class GoogleProtobufAny(BaseModel): __properties: ClassVar[List[str]] = ["@type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/host_config.py b/services/alb/src/stackit/alb/models/host_config.py index 674452108..66cfa25c9 100644 --- a/services/alb/src/stackit/alb/models/host_config.py +++ b/services/alb/src/stackit/alb/models/host_config.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.alb.models.rule import Rule @@ -37,7 +38,8 @@ class HostConfig(BaseModel): __properties: ClassVar[List[str]] = ["host", "rules"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/http_header.py b/services/alb/src/stackit/alb/models/http_header.py index cce4d62b5..1ebd3a375 100644 --- a/services/alb/src/stackit/alb/models/http_header.py +++ b/services/alb/src/stackit/alb/models/http_header.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -33,7 +34,8 @@ class HttpHeader(BaseModel): __properties: ClassVar[List[str]] = ["exactMatch", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/http_health_checks.py b/services/alb/src/stackit/alb/models/http_health_checks.py index b6f09d1f7..f3fca1648 100644 --- a/services/alb/src/stackit/alb/models/http_health_checks.py +++ b/services/alb/src/stackit/alb/models/http_health_checks.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.alb.models.tls_config import TlsConfig @@ -36,7 +37,8 @@ class HttpHealthChecks(BaseModel): __properties: ClassVar[List[str]] = ["okStatuses", "path", "tls"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/list_credentials_response.py b/services/alb/src/stackit/alb/models/list_credentials_response.py index 06e03fdfc..796241042 100644 --- a/services/alb/src/stackit/alb/models/list_credentials_response.py +++ b/services/alb/src/stackit/alb/models/list_credentials_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.alb.models.credentials_response import CredentialsResponse @@ -32,7 +33,8 @@ class ListCredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["credentials"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/list_load_balancers_response.py b/services/alb/src/stackit/alb/models/list_load_balancers_response.py index 995eed9bf..9f12b6752 100644 --- a/services/alb/src/stackit/alb/models/list_load_balancers_response.py +++ b/services/alb/src/stackit/alb/models/list_load_balancers_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.alb.models.load_balancer import LoadBalancer @@ -43,12 +44,16 @@ def next_page_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -59,8 +64,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/list_plans_response.py b/services/alb/src/stackit/alb/models/list_plans_response.py index 98d6ceb71..f4b12530c 100644 --- a/services/alb/src/stackit/alb/models/list_plans_response.py +++ b/services/alb/src/stackit/alb/models/list_plans_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.alb.models.plan_details import PlanDetails @@ -34,7 +35,8 @@ class ListPlansResponse(BaseModel): __properties: ClassVar[List[str]] = ["validPlans"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/listener.py b/services/alb/src/stackit/alb/models/listener.py index 6658f0333..8a10e3ae6 100644 --- a/services/alb/src/stackit/alb/models/listener.py +++ b/services/alb/src/stackit/alb/models/listener.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.alb.models.protocol_options_http import ProtocolOptionsHTTP @@ -53,6 +54,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value @@ -73,12 +77,16 @@ def waf_config_name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -89,8 +97,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/load_balancer.py b/services/alb/src/stackit/alb/models/load_balancer.py index abeb8560d..8b9e5ec0b 100644 --- a/services/alb/src/stackit/alb/models/load_balancer.py +++ b/services/alb/src/stackit/alb/models/load_balancer.py @@ -26,6 +26,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.alb.models.listener import Listener @@ -123,6 +124,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value @@ -142,7 +146,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -153,8 +158,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/load_balancer_error.py b/services/alb/src/stackit/alb/models/load_balancer_error.py index 500e2f118..557aaa0c2 100644 --- a/services/alb/src/stackit/alb/models/load_balancer_error.py +++ b/services/alb/src/stackit/alb/models/load_balancer_error.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -61,7 +62,8 @@ def type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -72,8 +74,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/load_balancer_options.py b/services/alb/src/stackit/alb/models/load_balancer_options.py index ba94508ed..253ae2751 100644 --- a/services/alb/src/stackit/alb/models/load_balancer_options.py +++ b/services/alb/src/stackit/alb/models/load_balancer_options.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.alb.models.loadbalancer_option_access_control import ( @@ -48,7 +49,8 @@ class LoadBalancerOptions(BaseModel): __properties: ClassVar[List[str]] = ["accessControl", "ephemeralAddress", "observability", "privateNetworkOnly"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -59,8 +61,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/loadbalancer_option_access_control.py b/services/alb/src/stackit/alb/models/loadbalancer_option_access_control.py index aa19fa9c2..7fffeb20f 100644 --- a/services/alb/src/stackit/alb/models/loadbalancer_option_access_control.py +++ b/services/alb/src/stackit/alb/models/loadbalancer_option_access_control.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class LoadbalancerOptionAccessControl(BaseModel): __properties: ClassVar[List[str]] = ["allowedSourceRanges"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/loadbalancer_option_logs.py b/services/alb/src/stackit/alb/models/loadbalancer_option_logs.py index b75e24852..3847770a2 100644 --- a/services/alb/src/stackit/alb/models/loadbalancer_option_logs.py +++ b/services/alb/src/stackit/alb/models/loadbalancer_option_logs.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -39,7 +40,8 @@ class LoadbalancerOptionLogs(BaseModel): __properties: ClassVar[List[str]] = ["credentialsRef", "pushUrl"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/loadbalancer_option_metrics.py b/services/alb/src/stackit/alb/models/loadbalancer_option_metrics.py index acf1dca87..eda8d3f53 100644 --- a/services/alb/src/stackit/alb/models/loadbalancer_option_metrics.py +++ b/services/alb/src/stackit/alb/models/loadbalancer_option_metrics.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -39,7 +40,8 @@ class LoadbalancerOptionMetrics(BaseModel): __properties: ClassVar[List[str]] = ["credentialsRef", "pushUrl"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/loadbalancer_option_observability.py b/services/alb/src/stackit/alb/models/loadbalancer_option_observability.py index 295b0a374..ff35bb18a 100644 --- a/services/alb/src/stackit/alb/models/loadbalancer_option_observability.py +++ b/services/alb/src/stackit/alb/models/loadbalancer_option_observability.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.alb.models.loadbalancer_option_logs import LoadbalancerOptionLogs @@ -34,7 +35,8 @@ class LoadbalancerOptionObservability(BaseModel): __properties: ClassVar[List[str]] = ["logs", "metrics"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/network.py b/services/alb/src/stackit/alb/models/network.py index 0df3c7cf3..3ff42ea5d 100644 --- a/services/alb/src/stackit/alb/models/network.py +++ b/services/alb/src/stackit/alb/models/network.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -45,6 +46,9 @@ def network_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/" @@ -64,7 +68,8 @@ def role_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -75,8 +80,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/path.py b/services/alb/src/stackit/alb/models/path.py index ff5779650..2dad6def1 100644 --- a/services/alb/src/stackit/alb/models/path.py +++ b/services/alb/src/stackit/alb/models/path.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -38,7 +39,8 @@ class Path(BaseModel): __properties: ClassVar[List[str]] = ["exactMatch", "prefix"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/plan_details.py b/services/alb/src/stackit/alb/models/plan_details.py index 13e226d45..5f12311a4 100644 --- a/services/alb/src/stackit/alb/models/plan_details.py +++ b/services/alb/src/stackit/alb/models/plan_details.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -39,7 +40,8 @@ class PlanDetails(BaseModel): __properties: ClassVar[List[str]] = ["description", "flavorName", "maxConnections", "name", "planId", "region"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/protocol_options_http.py b/services/alb/src/stackit/alb/models/protocol_options_http.py index a7e746b7f..49bf0c124 100644 --- a/services/alb/src/stackit/alb/models/protocol_options_http.py +++ b/services/alb/src/stackit/alb/models/protocol_options_http.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.alb.models.host_config import HostConfig @@ -32,7 +33,8 @@ class ProtocolOptionsHTTP(BaseModel): __properties: ClassVar[List[str]] = ["hosts"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/protocol_options_https.py b/services/alb/src/stackit/alb/models/protocol_options_https.py index 90efeffbf..00057ac30 100644 --- a/services/alb/src/stackit/alb/models/protocol_options_https.py +++ b/services/alb/src/stackit/alb/models/protocol_options_https.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.alb.models.certificate_config import CertificateConfig @@ -32,7 +33,8 @@ class ProtocolOptionsHTTPS(BaseModel): __properties: ClassVar[List[str]] = ["certificateConfig"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/query_parameter.py b/services/alb/src/stackit/alb/models/query_parameter.py index 1ce67ae29..a46cca04d 100644 --- a/services/alb/src/stackit/alb/models/query_parameter.py +++ b/services/alb/src/stackit/alb/models/query_parameter.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -33,7 +34,8 @@ class QueryParameter(BaseModel): __properties: ClassVar[List[str]] = ["exactMatch", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/rule.py b/services/alb/src/stackit/alb/models/rule.py index 5855cd8b1..59d3d792f 100644 --- a/services/alb/src/stackit/alb/models/rule.py +++ b/services/alb/src/stackit/alb/models/rule.py @@ -24,6 +24,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.alb.models.cookie_persistence import CookiePersistence @@ -61,7 +62,8 @@ class Rule(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -72,8 +74,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/security_group.py b/services/alb/src/stackit/alb/models/security_group.py index c2d126695..360da6bde 100644 --- a/services/alb/src/stackit/alb/models/security_group.py +++ b/services/alb/src/stackit/alb/models/security_group.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class SecurityGroup(BaseModel): __properties: ClassVar[List[str]] = ["id", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/status.py b/services/alb/src/stackit/alb/models/status.py index 284d1892d..e8133cd71 100644 --- a/services/alb/src/stackit/alb/models/status.py +++ b/services/alb/src/stackit/alb/models/status.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.alb.models.google_protobuf_any import GoogleProtobufAny @@ -43,7 +44,8 @@ class Status(BaseModel): __properties: ClassVar[List[str]] = ["code", "details", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/target.py b/services/alb/src/stackit/alb/models/target.py index 5e1b0fdee..efbeab69e 100644 --- a/services/alb/src/stackit/alb/models/target.py +++ b/services/alb/src/stackit/alb/models/target.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -41,6 +42,9 @@ def display_name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z](?:(?:[0-9a-zA-Z]|-){0,61}[0-9a-zA-Z])?$", value): raise ValueError( r"must validate the regular expression /^[0-9a-zA-Z](?:(?:[0-9a-zA-Z]|-){0,61}[0-9a-zA-Z])?$/" @@ -48,7 +52,8 @@ def display_name_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -59,8 +64,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/target_pool.py b/services/alb/src/stackit/alb/models/target_pool.py index a012d4559..786c4524b 100644 --- a/services/alb/src/stackit/alb/models/target_pool.py +++ b/services/alb/src/stackit/alb/models/target_pool.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.alb.models.active_health_check import ActiveHealthCheck @@ -50,12 +51,16 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -66,8 +71,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/tls_config.py b/services/alb/src/stackit/alb/models/tls_config.py index b9b53dd24..efb03e924 100644 --- a/services/alb/src/stackit/alb/models/tls_config.py +++ b/services/alb/src/stackit/alb/models/tls_config.py @@ -24,6 +24,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -49,7 +50,8 @@ class TlsConfig(BaseModel): __properties: ClassVar[List[str]] = ["customCa", "enabled", "skipCertificateValidation"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +62,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/update_credentials_payload.py b/services/alb/src/stackit/alb/models/update_credentials_payload.py index b20c87aad..77f9afda1 100644 --- a/services/alb/src/stackit/alb/models/update_credentials_payload.py +++ b/services/alb/src/stackit/alb/models/update_credentials_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -46,12 +47,16 @@ def display_name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,251}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,251}[0-9a-z])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -62,8 +67,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/update_credentials_response.py b/services/alb/src/stackit/alb/models/update_credentials_response.py index 9e73a047d..a258f09cf 100644 --- a/services/alb/src/stackit/alb/models/update_credentials_response.py +++ b/services/alb/src/stackit/alb/models/update_credentials_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.alb.models.credentials_response import CredentialsResponse @@ -32,7 +33,8 @@ class UpdateCredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["credential"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/update_load_balancer_payload.py b/services/alb/src/stackit/alb/models/update_load_balancer_payload.py index 4e04222f2..269ff970f 100644 --- a/services/alb/src/stackit/alb/models/update_load_balancer_payload.py +++ b/services/alb/src/stackit/alb/models/update_load_balancer_payload.py @@ -26,6 +26,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.alb.models.listener import Listener @@ -123,6 +124,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value @@ -142,7 +146,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -153,8 +158,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/alb/src/stackit/alb/models/update_target_pool_payload.py b/services/alb/src/stackit/alb/models/update_target_pool_payload.py index d15d480cf..3b408a390 100644 --- a/services/alb/src/stackit/alb/models/update_target_pool_payload.py +++ b/services/alb/src/stackit/alb/models/update_target_pool_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.alb.models.active_health_check import ActiveHealthCheck @@ -50,12 +51,16 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -66,8 +71,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/auditlog/CHANGELOG.md b/services/auditlog/CHANGELOG.md index d16fef25e..954720f9f 100644 --- a/services/auditlog/CHANGELOG.md +++ b/services/auditlog/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.2.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.1.2 - **Feature:** client now supports UUID and decimal types - **Bugfix:** timeouts now passed to requests library @@ -7,4 +10,4 @@ ## v0.1.0 -- **New**: STACKIT Audit Log module for retrieving recorded actions and system changes. Download audit log entries for folders, organizations, and projects with time range filtering, pagination, and configurable result limits. \ No newline at end of file +- **New**: STACKIT Audit Log module for retrieving recorded actions and system changes. Download audit log entries for folders, organizations, and projects with time range filtering, pagination, and configurable result limits. diff --git a/services/auditlog/pyproject.toml b/services/auditlog/pyproject.toml index f0769b13f..6a457b900 100644 --- a/services/auditlog/pyproject.toml +++ b/services/auditlog/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-auditlog" -version = "v0.1.2" +version = "v0.2.0" description = "Audit Log API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4" diff --git a/services/auditlog/src/stackit/auditlog/api_client.py b/services/auditlog/src/stackit/auditlog/api_client.py index b03ac46d2..6ac56a65d 100644 --- a/services/auditlog/src/stackit/auditlog/api_client.py +++ b/services/auditlog/src/stackit/auditlog/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/auditlog/src/stackit/auditlog/models/audit_log_entry_context_response.py b/services/auditlog/src/stackit/auditlog/models/audit_log_entry_context_response.py index 809fd9e22..193b78d0b 100644 --- a/services/auditlog/src/stackit/auditlog/models/audit_log_entry_context_response.py +++ b/services/auditlog/src/stackit/auditlog/models/audit_log_entry_context_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -38,7 +39,8 @@ class AuditLogEntryContextResponse(BaseModel): __properties: ClassVar[List[str]] = ["folderId", "organizationId", "projectId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/auditlog/src/stackit/auditlog/models/audit_log_entry_initiator_response.py b/services/auditlog/src/stackit/auditlog/models/audit_log_entry_initiator_response.py index 87d04d31e..b025dae5d 100644 --- a/services/auditlog/src/stackit/auditlog/models/audit_log_entry_initiator_response.py +++ b/services/auditlog/src/stackit/auditlog/models/audit_log_entry_initiator_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,7 +34,8 @@ class AuditLogEntryInitiatorResponse(BaseModel): __properties: ClassVar[List[str]] = ["email", "id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/auditlog/src/stackit/auditlog/models/audit_log_entry_request_response.py b/services/auditlog/src/stackit/auditlog/models/audit_log_entry_request_response.py index 3b65270ef..5b8804b67 100644 --- a/services/auditlog/src/stackit/auditlog/models/audit_log_entry_request_response.py +++ b/services/auditlog/src/stackit/auditlog/models/audit_log_entry_request_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -38,7 +39,8 @@ class AuditLogEntryRequestResponse(BaseModel): __properties: ClassVar[List[str]] = ["body", "endpoint", "headers", "parameters"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: 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 d9c42a9ba..18867c818 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 @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.auditlog.models.audit_log_entry_context_response import ( @@ -167,7 +168,8 @@ def visibility_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -178,8 +180,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/auditlog/src/stackit/auditlog/models/audit_log_entry_service_account_delegation_info_response.py b/services/auditlog/src/stackit/auditlog/models/audit_log_entry_service_account_delegation_info_response.py index b4e12323d..0a95f98a3 100644 --- a/services/auditlog/src/stackit/auditlog/models/audit_log_entry_service_account_delegation_info_response.py +++ b/services/auditlog/src/stackit/auditlog/models/audit_log_entry_service_account_delegation_info_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.auditlog.models.service_account_delegation_info_principal_response import ( @@ -36,7 +37,8 @@ class AuditLogEntryServiceAccountDelegationInfoResponse(BaseModel): __properties: ClassVar[List[str]] = ["principals"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/auditlog/src/stackit/auditlog/models/error_response.py b/services/auditlog/src/stackit/auditlog/models/error_response.py index bc90c9d28..793284c45 100644 --- a/services/auditlog/src/stackit/auditlog/models/error_response.py +++ b/services/auditlog/src/stackit/auditlog/models/error_response.py @@ -28,6 +28,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -56,7 +57,8 @@ def timestamp_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -67,8 +69,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: 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 27fa6136c..510cade62 100644 --- a/services/auditlog/src/stackit/auditlog/models/gateway_error_response.py +++ b/services/auditlog/src/stackit/auditlog/models/gateway_error_response.py @@ -25,6 +25,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -38,7 +39,8 @@ class GatewayErrorResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "status"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[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 02cc150d4..4ccbb88b1 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 @@ -25,6 +25,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.auditlog.models.audit_log_entry_response import AuditLogEntryResponse @@ -43,7 +44,8 @@ class ListAuditLogEntriesResponse(BaseModel): __properties: ClassVar[List[str]] = ["cursor", "items", "limit"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/auditlog/src/stackit/auditlog/models/service_account_delegation_info_principal_response.py b/services/auditlog/src/stackit/auditlog/models/service_account_delegation_info_principal_response.py index 06843040a..20f9f75dc 100644 --- a/services/auditlog/src/stackit/auditlog/models/service_account_delegation_info_principal_response.py +++ b/services/auditlog/src/stackit/auditlog/models/service_account_delegation_info_principal_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,7 +34,8 @@ class ServiceAccountDelegationInfoPrincipalResponse(BaseModel): __properties: ClassVar[List[str]] = ["email", "id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/CHANGELOG.md b/services/authorization/CHANGELOG.md index 20966591a..c45a899c2 100644 --- a/services/authorization/CHANGELOG.md +++ b/services/authorization/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.8.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.7.1 - **Feature:** client now supports UUID and decimal types - **Bugfix:** timeouts now passed to requests library diff --git a/services/authorization/pyproject.toml b/services/authorization/pyproject.toml index d17614c0b..e72d44bdf 100644 --- a/services/authorization/pyproject.toml +++ b/services/authorization/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-authorization" -version = "v0.7.1" +version = "v0.8.0" description = "STACKIT Membership API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/authorization/src/stackit/authorization/api_client.py b/services/authorization/src/stackit/authorization/api_client.py index 1eb145afc..831851cbd 100644 --- a/services/authorization/src/stackit/authorization/api_client.py +++ b/services/authorization/src/stackit/authorization/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/authorization/src/stackit/authorization/models/add_custom_role_response.py b/services/authorization/src/stackit/authorization/models/add_custom_role_response.py index 6c35d314b..29a0c03c1 100644 --- a/services/authorization/src/stackit/authorization/models/add_custom_role_response.py +++ b/services/authorization/src/stackit/authorization/models/add_custom_role_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.authorization.models.role import Role @@ -37,6 +38,9 @@ class AddCustomRoleResponse(BaseModel): @field_validator("resource_id") def resource_id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^([a-zA-Z0-9\/_|\-=+@.]{1,})$", value): raise ValueError(r"must validate the regular expression /^([a-zA-Z0-9\/_|\-=+@.]{1,})$/") return value @@ -44,12 +48,16 @@ def resource_id_validate_regular_expression(cls, value): @field_validator("resource_type") def resource_type_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z](?:-?[a-z]){1,63}$", value): raise ValueError(r"must validate the regular expression /^[a-z](?:-?[a-z]){1,63}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/add_members_payload.py b/services/authorization/src/stackit/authorization/models/add_members_payload.py index a01cd4e13..f2be7542d 100644 --- a/services/authorization/src/stackit/authorization/models/add_members_payload.py +++ b/services/authorization/src/stackit/authorization/models/add_members_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.authorization.models.member import Member @@ -36,12 +37,16 @@ class AddMembersPayload(BaseModel): @field_validator("resource_type") def resource_type_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z](?:-?[a-z]){1,63}$", value): raise ValueError(r"must validate the regular expression /^[a-z](?:-?[a-z]){1,63}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -52,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/add_role_payload.py b/services/authorization/src/stackit/authorization/models/add_role_payload.py index ca9c58241..3c0a1460a 100644 --- a/services/authorization/src/stackit/authorization/models/add_role_payload.py +++ b/services/authorization/src/stackit/authorization/models/add_role_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.authorization.models.permission_request import PermissionRequest @@ -37,12 +38,16 @@ class AddRolePayload(BaseModel): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z](?:[-.]?[a-z]){1,63}$", value): raise ValueError(r"must validate the regular expression /^[a-z](?:[-.]?[a-z]){1,63}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +58,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/delete_role_response.py b/services/authorization/src/stackit/authorization/models/delete_role_response.py index e1b097ae9..f76a3f406 100644 --- a/services/authorization/src/stackit/authorization/models/delete_role_response.py +++ b/services/authorization/src/stackit/authorization/models/delete_role_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.authorization.models.zookie import Zookie @@ -32,7 +33,8 @@ class DeleteRoleResponse(BaseModel): __properties: ClassVar[List[str]] = ["writtenAt"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/error_response.py b/services/authorization/src/stackit/authorization/models/error_response.py index 9eff4a3c3..0cb9ff2b7 100644 --- a/services/authorization/src/stackit/authorization/models/error_response.py +++ b/services/authorization/src/stackit/authorization/models/error_response.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -49,7 +50,8 @@ def time_stamp_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +62,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/existing_permission.py b/services/authorization/src/stackit/authorization/models/existing_permission.py index c46b4a3e1..de573afea 100644 --- a/services/authorization/src/stackit/authorization/models/existing_permission.py +++ b/services/authorization/src/stackit/authorization/models/existing_permission.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -34,12 +35,16 @@ class ExistingPermission(BaseModel): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z](?:[-.]?[a-z]){1,63}$", value): raise ValueError(r"must validate the regular expression /^[a-z](?:[-.]?[a-z]){1,63}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/get_role_response.py b/services/authorization/src/stackit/authorization/models/get_role_response.py index e4b3bb38e..6120f39a0 100644 --- a/services/authorization/src/stackit/authorization/models/get_role_response.py +++ b/services/authorization/src/stackit/authorization/models/get_role_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.authorization.models.role import Role @@ -37,6 +38,9 @@ class GetRoleResponse(BaseModel): @field_validator("resource_id") def resource_id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^([a-zA-Z0-9\/_|\-=+@.]{1,})$", value): raise ValueError(r"must validate the regular expression /^([a-zA-Z0-9\/_|\-=+@.]{1,})$/") return value @@ -44,12 +48,16 @@ def resource_id_validate_regular_expression(cls, value): @field_validator("resource_type") def resource_type_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z](?:-?[a-z]){1,63}$", value): raise ValueError(r"must validate the regular expression /^[a-z](?:-?[a-z]){1,63}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/list_members_response.py b/services/authorization/src/stackit/authorization/models/list_members_response.py index ebdb4d4e5..ccd5b1e66 100644 --- a/services/authorization/src/stackit/authorization/models/list_members_response.py +++ b/services/authorization/src/stackit/authorization/models/list_members_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.authorization.models.member import Member @@ -37,6 +38,9 @@ class ListMembersResponse(BaseModel): @field_validator("resource_id") def resource_id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^([a-zA-Z0-9\/_|\-=+@.]{1,})$", value): raise ValueError(r"must validate the regular expression /^([a-zA-Z0-9\/_|\-=+@.]{1,})$/") return value @@ -44,12 +48,16 @@ def resource_id_validate_regular_expression(cls, value): @field_validator("resource_type") def resource_type_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z](?:-?[a-z]){1,63}$", value): raise ValueError(r"must validate the regular expression /^[a-z](?:-?[a-z]){1,63}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/list_permissions_response.py b/services/authorization/src/stackit/authorization/models/list_permissions_response.py index 222e76078..62556aaa9 100644 --- a/services/authorization/src/stackit/authorization/models/list_permissions_response.py +++ b/services/authorization/src/stackit/authorization/models/list_permissions_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.authorization.models.permission import Permission @@ -32,7 +33,8 @@ class ListPermissionsResponse(BaseModel): __properties: ClassVar[List[str]] = ["permissions"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/list_user_memberships_response.py b/services/authorization/src/stackit/authorization/models/list_user_memberships_response.py index e6ecebf55..adbbd8354 100644 --- a/services/authorization/src/stackit/authorization/models/list_user_memberships_response.py +++ b/services/authorization/src/stackit/authorization/models/list_user_memberships_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.authorization.models.user_membership import UserMembership @@ -32,7 +33,8 @@ class ListUserMembershipsResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/list_user_permissions_response.py b/services/authorization/src/stackit/authorization/models/list_user_permissions_response.py index 5e4010c9b..086d81302 100644 --- a/services/authorization/src/stackit/authorization/models/list_user_permissions_response.py +++ b/services/authorization/src/stackit/authorization/models/list_user_permissions_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.authorization.models.user_permission import UserPermission @@ -32,7 +33,8 @@ class ListUserPermissionsResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/member.py b/services/authorization/src/stackit/authorization/models/member.py index 5f8454a1a..71deb7f45 100644 --- a/services/authorization/src/stackit/authorization/models/member.py +++ b/services/authorization/src/stackit/authorization/models/member.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -34,12 +35,16 @@ class Member(BaseModel): @field_validator("role") def role_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z](?:[-.]?[a-z]){1,63}$", value): raise ValueError(r"must validate the regular expression /^[a-z](?:[-.]?[a-z]){1,63}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/members_response.py b/services/authorization/src/stackit/authorization/models/members_response.py index 46154d22c..dd55171b6 100644 --- a/services/authorization/src/stackit/authorization/models/members_response.py +++ b/services/authorization/src/stackit/authorization/models/members_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.authorization.models.member import Member @@ -39,6 +40,9 @@ class MembersResponse(BaseModel): @field_validator("resource_id") def resource_id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^([a-zA-Z0-9\/_|\-=+@.]{1,})$", value): raise ValueError(r"must validate the regular expression /^([a-zA-Z0-9\/_|\-=+@.]{1,})$/") return value @@ -46,12 +50,16 @@ def resource_id_validate_regular_expression(cls, value): @field_validator("resource_type") def resource_type_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z](?:-?[a-z]){1,63}$", value): raise ValueError(r"must validate the regular expression /^[a-z](?:-?[a-z]){1,63}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -62,8 +70,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/permission.py b/services/authorization/src/stackit/authorization/models/permission.py index df24b5805..c3ad992ca 100644 --- a/services/authorization/src/stackit/authorization/models/permission.py +++ b/services/authorization/src/stackit/authorization/models/permission.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -34,12 +35,16 @@ class Permission(BaseModel): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z](?:[-.]?[a-z]){1,63}$", value): raise ValueError(r"must validate the regular expression /^[a-z](?:[-.]?[a-z]){1,63}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/permission_request.py b/services/authorization/src/stackit/authorization/models/permission_request.py index 2e3d910ec..0cef4abce 100644 --- a/services/authorization/src/stackit/authorization/models/permission_request.py +++ b/services/authorization/src/stackit/authorization/models/permission_request.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,12 +34,16 @@ class PermissionRequest(BaseModel): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z](?:[-.]?[a-z]){1,63}$", value): raise ValueError(r"must validate the regular expression /^[a-z](?:[-.]?[a-z]){1,63}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +54,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/remove_members_payload.py b/services/authorization/src/stackit/authorization/models/remove_members_payload.py index 5658461f1..a13b88d53 100644 --- a/services/authorization/src/stackit/authorization/models/remove_members_payload.py +++ b/services/authorization/src/stackit/authorization/models/remove_members_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.authorization.models.member import Member @@ -37,12 +38,16 @@ class RemoveMembersPayload(BaseModel): @field_validator("resource_type") def resource_type_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z](?:-?[a-z]){1,63}$", value): raise ValueError(r"must validate the regular expression /^[a-z](?:-?[a-z]){1,63}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +58,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/role.py b/services/authorization/src/stackit/authorization/models/role.py index facd5125f..834be9c94 100644 --- a/services/authorization/src/stackit/authorization/models/role.py +++ b/services/authorization/src/stackit/authorization/models/role.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.authorization.models.permission import Permission @@ -42,6 +43,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^([a-zA-Z0-9\/_|\-=+]{1,})$", value): raise ValueError(r"must validate the regular expression /^([a-zA-Z0-9\/_|\-=+]{1,})$/") return value @@ -49,12 +53,16 @@ def id_validate_regular_expression(cls, value): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z](?:[-.]?[a-z]){1,63}$", value): raise ValueError(r"must validate the regular expression /^[a-z](?:[-.]?[a-z]){1,63}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -65,8 +73,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/roles_response.py b/services/authorization/src/stackit/authorization/models/roles_response.py index 336e59aa1..9e89ab7a3 100644 --- a/services/authorization/src/stackit/authorization/models/roles_response.py +++ b/services/authorization/src/stackit/authorization/models/roles_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.authorization.models.role import Role @@ -37,6 +38,9 @@ class RolesResponse(BaseModel): @field_validator("resource_id") def resource_id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^([a-zA-Z0-9\/_|\-=+@.]{1,})$", value): raise ValueError(r"must validate the regular expression /^([a-zA-Z0-9\/_|\-=+@.]{1,})$/") return value @@ -44,12 +48,16 @@ def resource_id_validate_regular_expression(cls, value): @field_validator("resource_type") def resource_type_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z](?:-?[a-z]){1,63}$", value): raise ValueError(r"must validate the regular expression /^[a-z](?:-?[a-z]){1,63}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/update_role_payload.py b/services/authorization/src/stackit/authorization/models/update_role_payload.py index 772370476..f78469a38 100644 --- a/services/authorization/src/stackit/authorization/models/update_role_payload.py +++ b/services/authorization/src/stackit/authorization/models/update_role_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.authorization.models.permission_request import PermissionRequest @@ -38,12 +39,16 @@ class UpdateRolePayload(BaseModel): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z](?:[-.]?[a-z]){1,63}$", value): raise ValueError(r"must validate the regular expression /^[a-z](?:[-.]?[a-z]){1,63}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -54,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/update_role_response.py b/services/authorization/src/stackit/authorization/models/update_role_response.py index 72331a0a0..786de615a 100644 --- a/services/authorization/src/stackit/authorization/models/update_role_response.py +++ b/services/authorization/src/stackit/authorization/models/update_role_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.authorization.models.role import Role @@ -37,6 +38,9 @@ class UpdateRoleResponse(BaseModel): @field_validator("resource_id") def resource_id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^([a-zA-Z0-9\/_|\-=+@.]{1,})$", value): raise ValueError(r"must validate the regular expression /^([a-zA-Z0-9\/_|\-=+@.]{1,})$/") return value @@ -44,12 +48,16 @@ def resource_id_validate_regular_expression(cls, value): @field_validator("resource_type") def resource_type_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z](?:-?[a-z]){1,63}$", value): raise ValueError(r"must validate the regular expression /^[a-z](?:-?[a-z]){1,63}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/user_membership.py b/services/authorization/src/stackit/authorization/models/user_membership.py index 7a547aa05..33de65ee5 100644 --- a/services/authorization/src/stackit/authorization/models/user_membership.py +++ b/services/authorization/src/stackit/authorization/models/user_membership.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -36,6 +37,9 @@ class UserMembership(BaseModel): @field_validator("resource_id") def resource_id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^([a-zA-Z0-9\/_|\-=+@.]{1,})$", value): raise ValueError(r"must validate the regular expression /^([a-zA-Z0-9\/_|\-=+@.]{1,})$/") return value @@ -43,6 +47,9 @@ def resource_id_validate_regular_expression(cls, value): @field_validator("resource_type") def resource_type_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z](?:-?[a-z]){1,63}$", value): raise ValueError(r"must validate the regular expression /^[a-z](?:-?[a-z]){1,63}$/") return value @@ -50,12 +57,16 @@ def resource_type_validate_regular_expression(cls, value): @field_validator("role") def role_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z](?:[-.]?[a-z]){1,63}$", value): raise ValueError(r"must validate the regular expression /^[a-z](?:[-.]?[a-z]){1,63}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -66,8 +77,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/user_permission.py b/services/authorization/src/stackit/authorization/models/user_permission.py index 6d132bdb3..11f4d1add 100644 --- a/services/authorization/src/stackit/authorization/models/user_permission.py +++ b/services/authorization/src/stackit/authorization/models/user_permission.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.authorization.models.existing_permission import ExistingPermission @@ -37,6 +38,9 @@ class UserPermission(BaseModel): @field_validator("resource_id") def resource_id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^([a-zA-Z0-9\/_|\-=+@.]{1,})$", value): raise ValueError(r"must validate the regular expression /^([a-zA-Z0-9\/_|\-=+@.]{1,})$/") return value @@ -44,12 +48,16 @@ def resource_id_validate_regular_expression(cls, value): @field_validator("resource_type") def resource_type_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z](?:-?[a-z]){1,63}$", value): raise ValueError(r"must validate the regular expression /^[a-z](?:-?[a-z]){1,63}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/authorization/src/stackit/authorization/models/zookie.py b/services/authorization/src/stackit/authorization/models/zookie.py index 23423fea0..6d9ba0a96 100644 --- a/services/authorization/src/stackit/authorization/models/zookie.py +++ b/services/authorization/src/stackit/authorization/models/zookie.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class Zookie(BaseModel): __properties: ClassVar[List[str]] = ["zookie"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/CHANGELOG.md b/services/cdn/CHANGELOG.md index f3ff2f215..0b6f5ba71 100644 --- a/services/cdn/CHANGELOG.md +++ b/services/cdn/CHANGELOG.md @@ -1,3 +1,6 @@ +## v2.6.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v2.5.0 - **Feature:** New model classes `TlsConfigPatch` and `TlsConfig` - **Feature:** add attributes `forwardHostHeader`, `stripResponseCookies` and `tls` to the model classes: diff --git a/services/cdn/pyproject.toml b/services/cdn/pyproject.toml index c56e090f4..7fa006984 100644 --- a/services/cdn/pyproject.toml +++ b/services/cdn/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-cdn" -version = "v2.5.0" +version = "v2.6.0" description = "CDN API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/cdn/src/stackit/cdn/api_client.py b/services/cdn/src/stackit/cdn/api_client.py index 048b8e45d..367a45165 100644 --- a/services/cdn/src/stackit/cdn/api_client.py +++ b/services/cdn/src/stackit/cdn/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/cdn/src/stackit/cdn/models/bucket_backend.py b/services/cdn/src/stackit/cdn/models/bucket_backend.py index 4a0da218b..b32e23f11 100644 --- a/services/cdn/src/stackit/cdn/models/bucket_backend.py +++ b/services/cdn/src/stackit/cdn/models/bucket_backend.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class BucketBackend(BaseModel): __properties: ClassVar[List[str]] = ["bucketUrl", "region", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/bucket_backend_create.py b/services/cdn/src/stackit/cdn/models/bucket_backend_create.py index 2bf67e67a..a7b33580d 100644 --- a/services/cdn/src/stackit/cdn/models/bucket_backend_create.py +++ b/services/cdn/src/stackit/cdn/models/bucket_backend_create.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.bucket_credentials import BucketCredentials @@ -35,7 +36,8 @@ class BucketBackendCreate(BaseModel): __properties: ClassVar[List[str]] = ["bucketUrl", "credentials", "region", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/bucket_backend_patch.py b/services/cdn/src/stackit/cdn/models/bucket_backend_patch.py index bb9cbb293..6c07ee497 100644 --- a/services/cdn/src/stackit/cdn/models/bucket_backend_patch.py +++ b/services/cdn/src/stackit/cdn/models/bucket_backend_patch.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.bucket_credentials import BucketCredentials @@ -35,7 +36,8 @@ class BucketBackendPatch(BaseModel): __properties: ClassVar[List[str]] = ["bucketUrl", "credentials", "region", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/bucket_credentials.py b/services/cdn/src/stackit/cdn/models/bucket_credentials.py index 7faa0cedf..aa9d8da83 100644 --- a/services/cdn/src/stackit/cdn/models/bucket_credentials.py +++ b/services/cdn/src/stackit/cdn/models/bucket_credentials.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class BucketCredentials(BaseModel): __properties: ClassVar[List[str]] = ["accessKeyId", "secretAccessKey"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/config.py b/services/cdn/src/stackit/cdn/models/config.py index a36b8dfa4..821824e40 100644 --- a/services/cdn/src/stackit/cdn/models/config.py +++ b/services/cdn/src/stackit/cdn/models/config.py @@ -24,6 +24,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.cdn.models.config_backend import ConfigBackend @@ -90,7 +91,8 @@ class Config(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -101,8 +103,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/config_patch.py b/services/cdn/src/stackit/cdn/models/config_patch.py index 04471f768..851665be1 100644 --- a/services/cdn/src/stackit/cdn/models/config_patch.py +++ b/services/cdn/src/stackit/cdn/models/config_patch.py @@ -24,6 +24,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.cdn.models.config_patch_backend import ConfigPatchBackend @@ -94,7 +95,8 @@ class ConfigPatch(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -105,8 +107,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/create_distribution_payload.py b/services/cdn/src/stackit/cdn/models/create_distribution_payload.py index 39755349d..3a0cbe128 100644 --- a/services/cdn/src/stackit/cdn/models/create_distribution_payload.py +++ b/services/cdn/src/stackit/cdn/models/create_distribution_payload.py @@ -24,6 +24,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.cdn.models.create_distribution_payload_backend import ( @@ -104,7 +105,8 @@ class CreateDistributionPayload(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -115,8 +117,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/create_distribution_response.py b/services/cdn/src/stackit/cdn/models/create_distribution_response.py index b74c34ce0..0e6e67b2f 100644 --- a/services/cdn/src/stackit/cdn/models/create_distribution_response.py +++ b/services/cdn/src/stackit/cdn/models/create_distribution_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.distribution import Distribution @@ -32,7 +33,8 @@ class CreateDistributionResponse(BaseModel): __properties: ClassVar[List[str]] = ["distribution"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/custom_domain.py b/services/cdn/src/stackit/cdn/models/custom_domain.py index 26df40d67..3611aacf6 100644 --- a/services/cdn/src/stackit/cdn/models/custom_domain.py +++ b/services/cdn/src/stackit/cdn/models/custom_domain.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.cdn.models.domain_status import DomainStatus @@ -39,7 +40,8 @@ class CustomDomain(BaseModel): __properties: ClassVar[List[str]] = ["errors", "name", "status"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/delete_custom_domain_response.py b/services/cdn/src/stackit/cdn/models/delete_custom_domain_response.py index 40b1884af..b6c2f368b 100644 --- a/services/cdn/src/stackit/cdn/models/delete_custom_domain_response.py +++ b/services/cdn/src/stackit/cdn/models/delete_custom_domain_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.custom_domain import CustomDomain @@ -32,7 +33,8 @@ class DeleteCustomDomainResponse(BaseModel): __properties: ClassVar[List[str]] = ["customDomain"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/delete_distribution_response.py b/services/cdn/src/stackit/cdn/models/delete_distribution_response.py index 6236dfec3..d671224ee 100644 --- a/services/cdn/src/stackit/cdn/models/delete_distribution_response.py +++ b/services/cdn/src/stackit/cdn/models/delete_distribution_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.distribution import Distribution @@ -32,7 +33,8 @@ class DeleteDistributionResponse(BaseModel): __properties: ClassVar[List[str]] = ["distribution"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/distribution.py b/services/cdn/src/stackit/cdn/models/distribution.py index 84f4a34fc..eff272435 100644 --- a/services/cdn/src/stackit/cdn/models/distribution.py +++ b/services/cdn/src/stackit/cdn/models/distribution.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.cdn.models.config import Config @@ -98,7 +99,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -109,8 +111,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/distribution_logs_record.py b/services/cdn/src/stackit/cdn/models/distribution_logs_record.py index db263da40..acf1be7fb 100644 --- a/services/cdn/src/stackit/cdn/models/distribution_logs_record.py +++ b/services/cdn/src/stackit/cdn/models/distribution_logs_record.py @@ -28,6 +28,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.cdn.models.waf_violation import WAFViolation @@ -77,7 +78,8 @@ def timestamp_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -88,8 +90,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/distribution_statistics_record.py b/services/cdn/src/stackit/cdn/models/distribution_statistics_record.py index 913940729..c1d2fae05 100644 --- a/services/cdn/src/stackit/cdn/models/distribution_statistics_record.py +++ b/services/cdn/src/stackit/cdn/models/distribution_statistics_record.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.distribution_statistics_record_regions import ( @@ -76,7 +77,8 @@ def start_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -87,8 +89,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/distribution_statistics_record_entry.py b/services/cdn/src/stackit/cdn/models/distribution_statistics_record_entry.py index 44fcbcc99..73f9e7138 100644 --- a/services/cdn/src/stackit/cdn/models/distribution_statistics_record_entry.py +++ b/services/cdn/src/stackit/cdn/models/distribution_statistics_record_entry.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class DistributionStatisticsRecordEntry(BaseModel): __properties: ClassVar[List[str]] = ["cachedRequests", "totalRequests", "totalTrafficBytes"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/distribution_statistics_record_regions.py b/services/cdn/src/stackit/cdn/models/distribution_statistics_record_regions.py index e2173fbd4..76f298660 100644 --- a/services/cdn/src/stackit/cdn/models/distribution_statistics_record_regions.py +++ b/services/cdn/src/stackit/cdn/models/distribution_statistics_record_regions.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.distribution_statistics_record_entry import ( @@ -38,7 +39,8 @@ class DistributionStatisticsRecordRegions(BaseModel): __properties: ClassVar[List[str]] = ["AF", "ASIA", "EU", "SA", "US"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/distribution_waf.py b/services/cdn/src/stackit/cdn/models/distribution_waf.py index 5511d60f3..f93b0a5b1 100644 --- a/services/cdn/src/stackit/cdn/models/distribution_waf.py +++ b/services/cdn/src/stackit/cdn/models/distribution_waf.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.waf_status_rule_block import WafStatusRuleBlock @@ -34,7 +35,8 @@ class DistributionWaf(BaseModel): __properties: ClassVar[List[str]] = ["disabledRules", "enabledRules", "logOnlyRules"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/domain.py b/services/cdn/src/stackit/cdn/models/domain.py index 3781aab5f..f94cc4036 100644 --- a/services/cdn/src/stackit/cdn/models/domain.py +++ b/services/cdn/src/stackit/cdn/models/domain.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.cdn.models.domain_status import DomainStatus @@ -57,7 +58,8 @@ def type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -68,8 +70,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/error_details.py b/services/cdn/src/stackit/cdn/models/error_details.py index 6fbee6d5a..1df52c37f 100644 --- a/services/cdn/src/stackit/cdn/models/error_details.py +++ b/services/cdn/src/stackit/cdn/models/error_details.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -48,7 +49,8 @@ def key_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -59,8 +61,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/find_cache_paths_response.py b/services/cdn/src/stackit/cdn/models/find_cache_paths_response.py index d0f07a9d2..ffde94710 100644 --- a/services/cdn/src/stackit/cdn/models/find_cache_paths_response.py +++ b/services/cdn/src/stackit/cdn/models/find_cache_paths_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.find_cache_paths_response_entry import ( @@ -34,7 +35,8 @@ class FindCachePathsResponse(BaseModel): __properties: ClassVar[List[str]] = ["response"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/find_cache_paths_response_entry.py b/services/cdn/src/stackit/cdn/models/find_cache_paths_response_entry.py index 77b52194d..6ee3929bc 100644 --- a/services/cdn/src/stackit/cdn/models/find_cache_paths_response_entry.py +++ b/services/cdn/src/stackit/cdn/models/find_cache_paths_response_entry.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -32,7 +33,8 @@ class FindCachePathsResponseEntry(BaseModel): __properties: ClassVar[List[str]] = ["path"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/generic_json_response.py b/services/cdn/src/stackit/cdn/models/generic_json_response.py index 8d6ada354..84a6279a8 100644 --- a/services/cdn/src/stackit/cdn/models/generic_json_response.py +++ b/services/cdn/src/stackit/cdn/models/generic_json_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.cdn.models.error_details import ErrorDetails @@ -33,7 +34,8 @@ class GenericJsonResponse(BaseModel): __properties: ClassVar[List[str]] = ["details", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/get_cache_info_response.py b/services/cdn/src/stackit/cdn/models/get_cache_info_response.py index 7a8da9ef4..17b999567 100644 --- a/services/cdn/src/stackit/cdn/models/get_cache_info_response.py +++ b/services/cdn/src/stackit/cdn/models/get_cache_info_response.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.get_cache_info_response_history_entry import ( @@ -53,7 +54,8 @@ def last_purge_time_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -64,8 +66,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/get_cache_info_response_history_entry.py b/services/cdn/src/stackit/cdn/models/get_cache_info_response_history_entry.py index b4ed657e2..a1e7dba94 100644 --- a/services/cdn/src/stackit/cdn/models/get_cache_info_response_history_entry.py +++ b/services/cdn/src/stackit/cdn/models/get_cache_info_response_history_entry.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -53,7 +54,8 @@ def type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -64,8 +66,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/get_custom_domain_custom_certificate.py b/services/cdn/src/stackit/cdn/models/get_custom_domain_custom_certificate.py index d55a91b3f..273008ba3 100644 --- a/services/cdn/src/stackit/cdn/models/get_custom_domain_custom_certificate.py +++ b/services/cdn/src/stackit/cdn/models/get_custom_domain_custom_certificate.py @@ -24,6 +24,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -43,7 +44,8 @@ class GetCustomDomainCustomCertificate(BaseModel): __properties: ClassVar[List[str]] = ["skipDnsCheck", "type", "version"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/get_custom_domain_managed_certificate.py b/services/cdn/src/stackit/cdn/models/get_custom_domain_managed_certificate.py index 55bc0f5bf..34e1c4464 100644 --- a/services/cdn/src/stackit/cdn/models/get_custom_domain_managed_certificate.py +++ b/services/cdn/src/stackit/cdn/models/get_custom_domain_managed_certificate.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class GetCustomDomainManagedCertificate(BaseModel): __properties: ClassVar[List[str]] = ["type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/get_custom_domain_response.py b/services/cdn/src/stackit/cdn/models/get_custom_domain_response.py index 0a24ea226..9b8fec6b6 100644 --- a/services/cdn/src/stackit/cdn/models/get_custom_domain_response.py +++ b/services/cdn/src/stackit/cdn/models/get_custom_domain_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.custom_domain import CustomDomain @@ -36,7 +37,8 @@ class GetCustomDomainResponse(BaseModel): __properties: ClassVar[List[str]] = ["certificate", "customDomain"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/get_distribution_response.py b/services/cdn/src/stackit/cdn/models/get_distribution_response.py index dd7f8231d..f95ae1347 100644 --- a/services/cdn/src/stackit/cdn/models/get_distribution_response.py +++ b/services/cdn/src/stackit/cdn/models/get_distribution_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.distribution import Distribution @@ -32,7 +33,8 @@ class GetDistributionResponse(BaseModel): __properties: ClassVar[List[str]] = ["distribution"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/get_logs_response.py b/services/cdn/src/stackit/cdn/models/get_logs_response.py index cb1e34338..17282deaf 100644 --- a/services/cdn/src/stackit/cdn/models/get_logs_response.py +++ b/services/cdn/src/stackit/cdn/models/get_logs_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.distribution_logs_record import DistributionLogsRecord @@ -33,7 +34,8 @@ class GetLogsResponse(BaseModel): __properties: ClassVar[List[str]] = ["logs", "nextPageIdentifier"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/get_logs_search_filters_response.py b/services/cdn/src/stackit/cdn/models/get_logs_search_filters_response.py index 193d9ac4f..99a0dfb59 100644 --- a/services/cdn/src/stackit/cdn/models/get_logs_search_filters_response.py +++ b/services/cdn/src/stackit/cdn/models/get_logs_search_filters_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.cdn.models.get_logs_search_filters_response_datacenter_block import ( @@ -50,7 +51,8 @@ def cache_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -61,8 +63,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/get_logs_search_filters_response_datacenter_block.py b/services/cdn/src/stackit/cdn/models/get_logs_search_filters_response_datacenter_block.py index fb1a45cc4..61db59d26 100644 --- a/services/cdn/src/stackit/cdn/models/get_logs_search_filters_response_datacenter_block.py +++ b/services/cdn/src/stackit/cdn/models/get_logs_search_filters_response_datacenter_block.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.get_logs_search_filters_response_datacenter_block_item import ( @@ -38,7 +39,8 @@ class GetLogsSearchFiltersResponseDatacenterBlock(BaseModel): __properties: ClassVar[List[str]] = ["AF", "ASIA", "EU", "NA", "SA"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/get_logs_search_filters_response_datacenter_block_item.py b/services/cdn/src/stackit/cdn/models/get_logs_search_filters_response_datacenter_block_item.py index db4f1589f..c7863043e 100644 --- a/services/cdn/src/stackit/cdn/models/get_logs_search_filters_response_datacenter_block_item.py +++ b/services/cdn/src/stackit/cdn/models/get_logs_search_filters_response_datacenter_block_item.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class GetLogsSearchFiltersResponseDatacenterBlockItem(BaseModel): __properties: ClassVar[List[str]] = ["displayName", "id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/get_statistics_response.py b/services/cdn/src/stackit/cdn/models/get_statistics_response.py index 96eeb67ff..f1454ce6e 100644 --- a/services/cdn/src/stackit/cdn/models/get_statistics_response.py +++ b/services/cdn/src/stackit/cdn/models/get_statistics_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.distribution_statistics_record import ( @@ -34,7 +35,8 @@ class GetStatisticsResponse(BaseModel): __properties: ClassVar[List[str]] = ["records"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/http_backend.py b/services/cdn/src/stackit/cdn/models/http_backend.py index fecec512a..3169f3e63 100644 --- a/services/cdn/src/stackit/cdn/models/http_backend.py +++ b/services/cdn/src/stackit/cdn/models/http_backend.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -41,7 +42,8 @@ class HttpBackend(BaseModel): __properties: ClassVar[List[str]] = ["geofencing", "originRequestHeaders", "originUrl", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -52,8 +54,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/http_backend_create.py b/services/cdn/src/stackit/cdn/models/http_backend_create.py index 734a0bf50..6db053090 100644 --- a/services/cdn/src/stackit/cdn/models/http_backend_create.py +++ b/services/cdn/src/stackit/cdn/models/http_backend_create.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -43,7 +44,8 @@ class HttpBackendCreate(BaseModel): __properties: ClassVar[List[str]] = ["geofencing", "originRequestHeaders", "originUrl", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/http_backend_patch.py b/services/cdn/src/stackit/cdn/models/http_backend_patch.py index 5b881e76e..16fe26275 100644 --- a/services/cdn/src/stackit/cdn/models/http_backend_patch.py +++ b/services/cdn/src/stackit/cdn/models/http_backend_patch.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -40,7 +41,8 @@ class HttpBackendPatch(BaseModel): __properties: ClassVar[List[str]] = ["geofencing", "originRequestHeaders", "originUrl", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/list_distributions_response.py b/services/cdn/src/stackit/cdn/models/list_distributions_response.py index 2817d38e3..c36f231d1 100644 --- a/services/cdn/src/stackit/cdn/models/list_distributions_response.py +++ b/services/cdn/src/stackit/cdn/models/list_distributions_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.distribution import Distribution @@ -33,7 +34,8 @@ class ListDistributionsResponse(BaseModel): __properties: ClassVar[List[str]] = ["distributions", "nextPageIdentifier"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/list_waf_collections_response.py b/services/cdn/src/stackit/cdn/models/list_waf_collections_response.py index cf58448bb..8829a643c 100644 --- a/services/cdn/src/stackit/cdn/models/list_waf_collections_response.py +++ b/services/cdn/src/stackit/cdn/models/list_waf_collections_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.waf_rule_collection import WafRuleCollection @@ -32,7 +33,8 @@ class ListWafCollectionsResponse(BaseModel): __properties: ClassVar[List[str]] = ["collections"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/loki_log_sink.py b/services/cdn/src/stackit/cdn/models/loki_log_sink.py index 0272985ac..850c09c96 100644 --- a/services/cdn/src/stackit/cdn/models/loki_log_sink.py +++ b/services/cdn/src/stackit/cdn/models/loki_log_sink.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class LokiLogSink(BaseModel): __properties: ClassVar[List[str]] = ["pushUrl", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/loki_log_sink_create.py b/services/cdn/src/stackit/cdn/models/loki_log_sink_create.py index b7e12d9a4..721f5a86f 100644 --- a/services/cdn/src/stackit/cdn/models/loki_log_sink_create.py +++ b/services/cdn/src/stackit/cdn/models/loki_log_sink_create.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.loki_log_sink_credentials import LokiLogSinkCredentials @@ -34,7 +35,8 @@ class LokiLogSinkCreate(BaseModel): __properties: ClassVar[List[str]] = ["credentials", "pushUrl", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/loki_log_sink_credentials.py b/services/cdn/src/stackit/cdn/models/loki_log_sink_credentials.py index 5ab9b4df8..7171d31f0 100644 --- a/services/cdn/src/stackit/cdn/models/loki_log_sink_credentials.py +++ b/services/cdn/src/stackit/cdn/models/loki_log_sink_credentials.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class LokiLogSinkCredentials(BaseModel): __properties: ClassVar[List[str]] = ["password", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/loki_log_sink_patch.py b/services/cdn/src/stackit/cdn/models/loki_log_sink_patch.py index 0564fee41..1e899963d 100644 --- a/services/cdn/src/stackit/cdn/models/loki_log_sink_patch.py +++ b/services/cdn/src/stackit/cdn/models/loki_log_sink_patch.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.loki_log_sink_credentials import LokiLogSinkCredentials @@ -34,7 +35,8 @@ class LokiLogSinkPatch(BaseModel): __properties: ClassVar[List[str]] = ["credentials", "pushUrl", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/matcher.py b/services/cdn/src/stackit/cdn/models/matcher.py index fd85b07f9..707d32e7f 100644 --- a/services/cdn/src/stackit/cdn/models/matcher.py +++ b/services/cdn/src/stackit/cdn/models/matcher.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.cdn.models.match_condition import MatchCondition @@ -35,7 +36,8 @@ class Matcher(BaseModel): __properties: ClassVar[List[str]] = ["valueMatchCondition", "values"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/optimizer.py b/services/cdn/src/stackit/cdn/models/optimizer.py index 9401d7ddc..5671d86d6 100644 --- a/services/cdn/src/stackit/cdn/models/optimizer.py +++ b/services/cdn/src/stackit/cdn/models/optimizer.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class Optimizer(BaseModel): __properties: ClassVar[List[str]] = ["enabled"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/optimizer_patch.py b/services/cdn/src/stackit/cdn/models/optimizer_patch.py index 7539123d9..096c6921a 100644 --- a/services/cdn/src/stackit/cdn/models/optimizer_patch.py +++ b/services/cdn/src/stackit/cdn/models/optimizer_patch.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class OptimizerPatch(BaseModel): __properties: ClassVar[List[str]] = ["enabled"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/patch_distribution_payload.py b/services/cdn/src/stackit/cdn/models/patch_distribution_payload.py index 8a4c3a802..0bd49bc24 100644 --- a/services/cdn/src/stackit/cdn/models/patch_distribution_payload.py +++ b/services/cdn/src/stackit/cdn/models/patch_distribution_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.config_patch import ConfigPatch @@ -37,7 +38,8 @@ class PatchDistributionPayload(BaseModel): __properties: ClassVar[List[str]] = ["config", "intentId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/patch_distribution_response.py b/services/cdn/src/stackit/cdn/models/patch_distribution_response.py index 23f78d27e..8b0d77779 100644 --- a/services/cdn/src/stackit/cdn/models/patch_distribution_response.py +++ b/services/cdn/src/stackit/cdn/models/patch_distribution_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.distribution import Distribution @@ -32,7 +33,8 @@ class PatchDistributionResponse(BaseModel): __properties: ClassVar[List[str]] = ["distribution"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/purge_cache_payload.py b/services/cdn/src/stackit/cdn/models/purge_cache_payload.py index 43af8f7ba..81f4a6bc1 100644 --- a/services/cdn/src/stackit/cdn/models/purge_cache_payload.py +++ b/services/cdn/src/stackit/cdn/models/purge_cache_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -33,7 +34,8 @@ class PurgeCachePayload(BaseModel): __properties: ClassVar[List[str]] = ["path"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/put_custom_domain_custom_certificate.py b/services/cdn/src/stackit/cdn/models/put_custom_domain_custom_certificate.py index 81a3de020..32fc5e201 100644 --- a/services/cdn/src/stackit/cdn/models/put_custom_domain_custom_certificate.py +++ b/services/cdn/src/stackit/cdn/models/put_custom_domain_custom_certificate.py @@ -24,6 +24,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -43,7 +44,8 @@ class PutCustomDomainCustomCertificate(BaseModel): __properties: ClassVar[List[str]] = ["certificate", "key", "skipDnsCheck", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/put_custom_domain_managed_certificate.py b/services/cdn/src/stackit/cdn/models/put_custom_domain_managed_certificate.py index 37418e38a..76ded116e 100644 --- a/services/cdn/src/stackit/cdn/models/put_custom_domain_managed_certificate.py +++ b/services/cdn/src/stackit/cdn/models/put_custom_domain_managed_certificate.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class PutCustomDomainManagedCertificate(BaseModel): __properties: ClassVar[List[str]] = ["type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/put_custom_domain_payload.py b/services/cdn/src/stackit/cdn/models/put_custom_domain_payload.py index cd60d2e5d..fa79a4149 100644 --- a/services/cdn/src/stackit/cdn/models/put_custom_domain_payload.py +++ b/services/cdn/src/stackit/cdn/models/put_custom_domain_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.put_custom_domain_payload_certificate import ( @@ -39,7 +40,8 @@ class PutCustomDomainPayload(BaseModel): __properties: ClassVar[List[str]] = ["certificate", "intentId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/put_custom_domain_response.py b/services/cdn/src/stackit/cdn/models/put_custom_domain_response.py index 255a229fc..b4bb89cd0 100644 --- a/services/cdn/src/stackit/cdn/models/put_custom_domain_response.py +++ b/services/cdn/src/stackit/cdn/models/put_custom_domain_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.custom_domain import CustomDomain @@ -36,7 +37,8 @@ class PutCustomDomainResponse(BaseModel): __properties: ClassVar[List[str]] = ["certificate", "customDomain"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/redirect_config.py b/services/cdn/src/stackit/cdn/models/redirect_config.py index c07a18a04..7d682311d 100644 --- a/services/cdn/src/stackit/cdn/models/redirect_config.py +++ b/services/cdn/src/stackit/cdn/models/redirect_config.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.redirect_rule import RedirectRule @@ -34,7 +35,8 @@ class RedirectConfig(BaseModel): __properties: ClassVar[List[str]] = ["rules"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/redirect_rule.py b/services/cdn/src/stackit/cdn/models/redirect_rule.py index de7bce823..4335eabcf 100644 --- a/services/cdn/src/stackit/cdn/models/redirect_rule.py +++ b/services/cdn/src/stackit/cdn/models/redirect_rule.py @@ -25,6 +25,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.cdn.models.match_condition import MatchCondition @@ -64,7 +65,8 @@ def status_code_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -75,8 +77,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/status_error.py b/services/cdn/src/stackit/cdn/models/status_error.py index 351aa9bc1..85af223ce 100644 --- a/services/cdn/src/stackit/cdn/models/status_error.py +++ b/services/cdn/src/stackit/cdn/models/status_error.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -57,7 +58,8 @@ def key_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -68,8 +70,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/tls_config.py b/services/cdn/src/stackit/cdn/models/tls_config.py index b154b096a..f9cd3503e 100644 --- a/services/cdn/src/stackit/cdn/models/tls_config.py +++ b/services/cdn/src/stackit/cdn/models/tls_config.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -35,7 +36,8 @@ class TlsConfig(BaseModel): __properties: ClassVar[List[str]] = ["enableTls10", "enableTls11"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/tls_config_patch.py b/services/cdn/src/stackit/cdn/models/tls_config_patch.py index 23e3a68a1..6ee7e0f08 100644 --- a/services/cdn/src/stackit/cdn/models/tls_config_patch.py +++ b/services/cdn/src/stackit/cdn/models/tls_config_patch.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -39,7 +40,8 @@ class TlsConfigPatch(BaseModel): __properties: ClassVar[List[str]] = ["enableTls10", "enableTls11"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/waf_config.py b/services/cdn/src/stackit/cdn/models/waf_config.py index 89527d8b9..4b99a4cc9 100644 --- a/services/cdn/src/stackit/cdn/models/waf_config.py +++ b/services/cdn/src/stackit/cdn/models/waf_config.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.cdn.models.waf_mode import WafMode @@ -97,7 +98,8 @@ class WafConfig(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -108,8 +110,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/waf_config_patch.py b/services/cdn/src/stackit/cdn/models/waf_config_patch.py index d3d3ded86..ccd1659ef 100644 --- a/services/cdn/src/stackit/cdn/models/waf_config_patch.py +++ b/services/cdn/src/stackit/cdn/models/waf_config_patch.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.cdn.models.waf_mode import WafMode @@ -94,7 +95,8 @@ class WafConfigPatch(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -105,8 +107,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/waf_rule.py b/services/cdn/src/stackit/cdn/models/waf_rule.py index 287076c55..e5bc5281f 100644 --- a/services/cdn/src/stackit/cdn/models/waf_rule.py +++ b/services/cdn/src/stackit/cdn/models/waf_rule.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class WafRule(BaseModel): __properties: ClassVar[List[str]] = ["code", "description", "id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/waf_rule_collection.py b/services/cdn/src/stackit/cdn/models/waf_rule_collection.py index 45a3eba9d..2c117fcc4 100644 --- a/services/cdn/src/stackit/cdn/models/waf_rule_collection.py +++ b/services/cdn/src/stackit/cdn/models/waf_rule_collection.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.waf_rule_group import WafRuleGroup @@ -34,7 +35,8 @@ class WafRuleCollection(BaseModel): __properties: ClassVar[List[str]] = ["groups", "id", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/waf_rule_group.py b/services/cdn/src/stackit/cdn/models/waf_rule_group.py index 4d583e3a5..134709139 100644 --- a/services/cdn/src/stackit/cdn/models/waf_rule_group.py +++ b/services/cdn/src/stackit/cdn/models/waf_rule_group.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.waf_rule import WafRule @@ -34,7 +35,8 @@ class WafRuleGroup(BaseModel): __properties: ClassVar[List[str]] = ["description", "name", "rules"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/waf_status_rule_block.py b/services/cdn/src/stackit/cdn/models/waf_status_rule_block.py index 52b1472a5..0ca00e172 100644 --- a/services/cdn/src/stackit/cdn/models/waf_status_rule_block.py +++ b/services/cdn/src/stackit/cdn/models/waf_status_rule_block.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.waf_status_rule_block_reason import WafStatusRuleBlockReason @@ -33,7 +34,8 @@ class WafStatusRuleBlock(BaseModel): __properties: ClassVar[List[str]] = ["id", "reason"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/waf_status_rule_block_reason_directly_defined.py b/services/cdn/src/stackit/cdn/models/waf_status_rule_block_reason_directly_defined.py index b37b3c9ec..ae694210b 100644 --- a/services/cdn/src/stackit/cdn/models/waf_status_rule_block_reason_directly_defined.py +++ b/services/cdn/src/stackit/cdn/models/waf_status_rule_block_reason_directly_defined.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class WafStatusRuleBlockReasonDirectlyDefined(BaseModel): __properties: ClassVar[List[str]] = ["type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/waf_status_rule_block_reason_inherited_from_collection.py b/services/cdn/src/stackit/cdn/models/waf_status_rule_block_reason_inherited_from_collection.py index aa90e7cc6..15d3ac747 100644 --- a/services/cdn/src/stackit/cdn/models/waf_status_rule_block_reason_inherited_from_collection.py +++ b/services/cdn/src/stackit/cdn/models/waf_status_rule_block_reason_inherited_from_collection.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -33,7 +34,8 @@ class WafStatusRuleBlockReasonInheritedFromCollection(BaseModel): __properties: ClassVar[List[str]] = ["collectionId", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/waf_status_rule_block_reason_inherited_from_group.py b/services/cdn/src/stackit/cdn/models/waf_status_rule_block_reason_inherited_from_group.py index 2bc780bbb..c24ece50d 100644 --- a/services/cdn/src/stackit/cdn/models/waf_status_rule_block_reason_inherited_from_group.py +++ b/services/cdn/src/stackit/cdn/models/waf_status_rule_block_reason_inherited_from_group.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -33,7 +34,8 @@ class WafStatusRuleBlockReasonInheritedFromGroup(BaseModel): __properties: ClassVar[List[str]] = ["groupId", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/waf_status_rule_block_reason_invalid_waf_type.py b/services/cdn/src/stackit/cdn/models/waf_status_rule_block_reason_invalid_waf_type.py index 0e460d33a..2bb24cef8 100644 --- a/services/cdn/src/stackit/cdn/models/waf_status_rule_block_reason_invalid_waf_type.py +++ b/services/cdn/src/stackit/cdn/models/waf_status_rule_block_reason_invalid_waf_type.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.cdn.models.waf_type import WafType @@ -36,7 +37,8 @@ class WafStatusRuleBlockReasonInvalidWafType(BaseModel): __properties: ClassVar[List[str]] = ["allowedWafTypes", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/waf_status_rule_block_reason_never_defined.py b/services/cdn/src/stackit/cdn/models/waf_status_rule_block_reason_never_defined.py index 495baee8c..df632c6c7 100644 --- a/services/cdn/src/stackit/cdn/models/waf_status_rule_block_reason_never_defined.py +++ b/services/cdn/src/stackit/cdn/models/waf_status_rule_block_reason_never_defined.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class WafStatusRuleBlockReasonNeverDefined(BaseModel): __properties: ClassVar[List[str]] = ["type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cdn/src/stackit/cdn/models/waf_violation.py b/services/cdn/src/stackit/cdn/models/waf_violation.py index 443a3e7e2..6fabcdbbe 100644 --- a/services/cdn/src/stackit/cdn/models/waf_violation.py +++ b/services/cdn/src/stackit/cdn/models/waf_violation.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cdn.models.waf_rule_action import WAFRuleAction @@ -37,7 +38,8 @@ class WAFViolation(BaseModel): __properties: ClassVar[List[str]] = ["action", "asn", "message", "method", "requestHeaders", "ruleId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/certificates/CHANGELOG.md b/services/certificates/CHANGELOG.md index 48908aab1..36f2c65d3 100644 --- a/services/certificates/CHANGELOG.md +++ b/services/certificates/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.4.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v1.3.1 - Add HTTP 429 status code to some API client methods diff --git a/services/certificates/pyproject.toml b/services/certificates/pyproject.toml index 4fcd2f0b0..eb990db19 100644 --- a/services/certificates/pyproject.toml +++ b/services/certificates/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-certificates" -version = "v1.3.1" +version = "v1.4.0" description = "Load Balancer Certificates API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/certificates/src/stackit/certificates/api_client.py b/services/certificates/src/stackit/certificates/api_client.py index 9afef88e3..dfd507add 100644 --- a/services/certificates/src/stackit/certificates/api_client.py +++ b/services/certificates/src/stackit/certificates/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/certificates/src/stackit/certificates/models/certificates_quota.py b/services/certificates/src/stackit/certificates/models/certificates_quota.py index debb5feb9..48efa4e1c 100644 --- a/services/certificates/src/stackit/certificates/models/certificates_quota.py +++ b/services/certificates/src/stackit/certificates/models/certificates_quota.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -35,7 +36,8 @@ class CertificatesQuota(BaseModel): __properties: ClassVar[List[str]] = ["limit", "usage"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/certificates/src/stackit/certificates/models/create_certificate_payload.py b/services/certificates/src/stackit/certificates/models/create_certificate_payload.py index 79097b008..46f584c73 100644 --- a/services/certificates/src/stackit/certificates/models/create_certificate_payload.py +++ b/services/certificates/src/stackit/certificates/models/create_certificate_payload.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -45,6 +46,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value @@ -55,6 +59,9 @@ def project_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/" @@ -67,12 +74,16 @@ def region_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z]{2,4}[0-9]{2}$", value): raise ValueError(r"must validate the regular expression /^[a-z]{2,4}[0-9]{2}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -83,8 +94,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/certificates/src/stackit/certificates/models/get_certificate_response.py b/services/certificates/src/stackit/certificates/models/get_certificate_response.py index 9813e206e..a8a218065 100644 --- a/services/certificates/src/stackit/certificates/models/get_certificate_response.py +++ b/services/certificates/src/stackit/certificates/models/get_certificate_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -41,6 +42,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,251}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,251}[0-9a-z])?$/") return value @@ -51,12 +55,16 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,251}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,251}[0-9a-z])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -67,8 +75,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/certificates/src/stackit/certificates/models/get_quota_response.py b/services/certificates/src/stackit/certificates/models/get_quota_response.py index c317a483e..c57d7769c 100644 --- a/services/certificates/src/stackit/certificates/models/get_quota_response.py +++ b/services/certificates/src/stackit/certificates/models/get_quota_response.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.certificates.models.quotas import Quotas @@ -41,6 +42,9 @@ def project_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/" @@ -53,12 +57,16 @@ def region_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z]{2,4}[0-9]{2}$", value): raise ValueError(r"must validate the regular expression /^[a-z]{2,4}[0-9]{2}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -69,8 +77,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/certificates/src/stackit/certificates/models/google_protobuf_any.py b/services/certificates/src/stackit/certificates/models/google_protobuf_any.py index faec854f3..5b9efe3c4 100644 --- a/services/certificates/src/stackit/certificates/models/google_protobuf_any.py +++ b/services/certificates/src/stackit/certificates/models/google_protobuf_any.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class GoogleProtobufAny(BaseModel): __properties: ClassVar[List[str]] = ["@type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/certificates/src/stackit/certificates/models/list_certificates_response.py b/services/certificates/src/stackit/certificates/models/list_certificates_response.py index 32aecdbf4..d388f030b 100644 --- a/services/certificates/src/stackit/certificates/models/list_certificates_response.py +++ b/services/certificates/src/stackit/certificates/models/list_certificates_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.certificates.models.get_certificate_response import GetCertificateResponse @@ -43,12 +44,16 @@ def next_page_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -59,8 +64,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/certificates/src/stackit/certificates/models/quotas.py b/services/certificates/src/stackit/certificates/models/quotas.py index 146fa63af..931ac6d0f 100644 --- a/services/certificates/src/stackit/certificates/models/quotas.py +++ b/services/certificates/src/stackit/certificates/models/quotas.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.certificates.models.certificates_quota import CertificatesQuota @@ -32,7 +33,8 @@ class Quotas(BaseModel): __properties: ClassVar[List[str]] = ["certificates"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/certificates/src/stackit/certificates/models/status.py b/services/certificates/src/stackit/certificates/models/status.py index edd3a309d..cf8909b7d 100644 --- a/services/certificates/src/stackit/certificates/models/status.py +++ b/services/certificates/src/stackit/certificates/models/status.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.certificates.models.google_protobuf_any import GoogleProtobufAny @@ -43,7 +44,8 @@ class Status(BaseModel): __properties: ClassVar[List[str]] = ["code", "details", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cost/CHANGELOG.md b/services/cost/CHANGELOG.md index be8f7def9..e561c7885 100644 --- a/services/cost/CHANGELOG.md +++ b/services/cost/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.2.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.1.0 - **New**: STACKIT cost service diff --git a/services/cost/pyproject.toml b/services/cost/pyproject.toml index 4dc28073a..b4aa1a19a 100644 --- a/services/cost/pyproject.toml +++ b/services/cost/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-cost" -version = "v0.1.0" +version = "v0.2.0" description = "STACKIT Cost API" authors = [{name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud"}] requires-python = ">=3.9,<4.0" diff --git a/services/cost/src/stackit/cost/api_client.py b/services/cost/src/stackit/cost/api_client.py index 7a8345ca7..34466a008 100644 --- a/services/cost/src/stackit/cost/api_client.py +++ b/services/cost/src/stackit/cost/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/cost/src/stackit/cost/models/auth_error_response.py b/services/cost/src/stackit/cost/models/auth_error_response.py index d1ec0e1ea..dc594c883 100644 --- a/services/cost/src/stackit/cost/models/auth_error_response.py +++ b/services/cost/src/stackit/cost/models/auth_error_response.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -49,7 +50,8 @@ def time_stamp_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +62,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cost/src/stackit/cost/models/detailed_service_cost.py b/services/cost/src/stackit/cost/models/detailed_service_cost.py index 3fa4f8efc..db2b30fe1 100644 --- a/services/cost/src/stackit/cost/models/detailed_service_cost.py +++ b/services/cost/src/stackit/cost/models/detailed_service_cost.py @@ -24,6 +24,7 @@ StrictFloat, StrictInt, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.cost.models.report_data import ReportData @@ -70,7 +71,8 @@ class DetailedServiceCost(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -81,8 +83,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cost/src/stackit/cost/models/error_response.py b/services/cost/src/stackit/cost/models/error_response.py index f05bfab59..0a826d55d 100644 --- a/services/cost/src/stackit/cost/models/error_response.py +++ b/services/cost/src/stackit/cost/models/error_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class ErrorResponse(BaseModel): __properties: ClassVar[List[str]] = ["msg"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cost/src/stackit/cost/models/project_cost_with_detailed_services.py b/services/cost/src/stackit/cost/models/project_cost_with_detailed_services.py index da95923a7..1c1877c3a 100644 --- a/services/cost/src/stackit/cost/models/project_cost_with_detailed_services.py +++ b/services/cost/src/stackit/cost/models/project_cost_with_detailed_services.py @@ -26,6 +26,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cost.models.detailed_service_cost import DetailedServiceCost @@ -61,7 +62,8 @@ class ProjectCostWithDetailedServices(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -72,8 +74,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cost/src/stackit/cost/models/project_cost_with_reports.py b/services/cost/src/stackit/cost/models/project_cost_with_reports.py index 5ecc6ce56..8d6c4d191 100644 --- a/services/cost/src/stackit/cost/models/project_cost_with_reports.py +++ b/services/cost/src/stackit/cost/models/project_cost_with_reports.py @@ -26,6 +26,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cost.models.report_data import ReportData @@ -62,7 +63,8 @@ class ProjectCostWithReports(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -73,8 +75,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cost/src/stackit/cost/models/project_cost_with_summarized_services.py b/services/cost/src/stackit/cost/models/project_cost_with_summarized_services.py index 7d6bab9f4..fedeeb08f 100644 --- a/services/cost/src/stackit/cost/models/project_cost_with_summarized_services.py +++ b/services/cost/src/stackit/cost/models/project_cost_with_summarized_services.py @@ -26,6 +26,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cost.models.summarized_service_cost import SummarizedServiceCost @@ -58,7 +59,8 @@ class ProjectCostWithSummarizedServices(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -69,8 +71,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cost/src/stackit/cost/models/report_data.py b/services/cost/src/stackit/cost/models/report_data.py index b230abe84..237e820fa 100644 --- a/services/cost/src/stackit/cost/models/report_data.py +++ b/services/cost/src/stackit/cost/models/report_data.py @@ -24,6 +24,7 @@ StrictFloat, StrictInt, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.cost.models.report_data_time_period import ReportDataTimePeriod @@ -41,7 +42,8 @@ class ReportData(BaseModel): __properties: ClassVar[List[str]] = ["charge", "discount", "quantity", "timePeriod"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -52,8 +54,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cost/src/stackit/cost/models/report_data_time_period.py b/services/cost/src/stackit/cost/models/report_data_time_period.py index 9ed32be13..c39a80231 100644 --- a/services/cost/src/stackit/cost/models/report_data_time_period.py +++ b/services/cost/src/stackit/cost/models/report_data_time_period.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class ReportDataTimePeriod(BaseModel): __properties: ClassVar[List[str]] = ["end", "start"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cost/src/stackit/cost/models/summarized_project_cost.py b/services/cost/src/stackit/cost/models/summarized_project_cost.py index 10ed44878..2de458c73 100644 --- a/services/cost/src/stackit/cost/models/summarized_project_cost.py +++ b/services/cost/src/stackit/cost/models/summarized_project_cost.py @@ -26,6 +26,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -54,7 +55,8 @@ class SummarizedProjectCost(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -65,8 +67,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/cost/src/stackit/cost/models/summarized_service_cost.py b/services/cost/src/stackit/cost/models/summarized_service_cost.py index 3da6db3f5..7b368498e 100644 --- a/services/cost/src/stackit/cost/models/summarized_service_cost.py +++ b/services/cost/src/stackit/cost/models/summarized_service_cost.py @@ -26,6 +26,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -54,7 +55,8 @@ class SummarizedServiceCost(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -65,8 +67,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/CHANGELOG.md b/services/dns/CHANGELOG.md index c2bbccc36..e8dde512b 100644 --- a/services/dns/CHANGELOG.md +++ b/services/dns/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.6.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.5.1 - **Feature:** client now supports UUID and decimal types - **Bugfix:** timeouts now passed to requests library diff --git a/services/dns/pyproject.toml b/services/dns/pyproject.toml index 39da771f7..359fa6d46 100644 --- a/services/dns/pyproject.toml +++ b/services/dns/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-dns" -version = "v0.5.1" +version = "v0.6.0" description = "STACKIT DNS API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/dns/src/stackit/dns/api_client.py b/services/dns/src/stackit/dns/api_client.py index 62ff9367c..b7efe9e2f 100644 --- a/services/dns/src/stackit/dns/api_client.py +++ b/services/dns/src/stackit/dns/api_client.py @@ -67,6 +67,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -266,7 +267,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -327,25 +328,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -418,6 +414,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/dns/src/stackit/dns/models/clone_zone_payload.py b/services/dns/src/stackit/dns/models/clone_zone_payload.py index 5820d2a08..f3e94150e 100644 --- a/services/dns/src/stackit/dns/models/clone_zone_payload.py +++ b/services/dns/src/stackit/dns/models/clone_zone_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -45,7 +46,8 @@ class CloneZonePayload(BaseModel): __properties: ClassVar[List[str]] = ["adjustRecords", "description", "dnsName", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +58,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/create_label_payload.py b/services/dns/src/stackit/dns/models/create_label_payload.py index d8f5e1fbb..dc7957bda 100644 --- a/services/dns/src/stackit/dns/models/create_label_payload.py +++ b/services/dns/src/stackit/dns/models/create_label_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -32,7 +33,8 @@ class CreateLabelPayload(BaseModel): __properties: ClassVar[List[str]] = ["key", "value"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/create_label_response.py b/services/dns/src/stackit/dns/models/create_label_response.py index fa37b36fb..2a8a02739 100644 --- a/services/dns/src/stackit/dns/models/create_label_response.py +++ b/services/dns/src/stackit/dns/models/create_label_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.dns.models.label import Label @@ -34,7 +35,8 @@ class CreateLabelResponse(BaseModel): __properties: ClassVar[List[str]] = ["label", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/create_record_set_payload.py b/services/dns/src/stackit/dns/models/create_record_set_payload.py index efadaca3a..1ac7eca65 100644 --- a/services/dns/src/stackit/dns/models/create_record_set_payload.py +++ b/services/dns/src/stackit/dns/models/create_record_set_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.dns.models.record_payload import RecordPayload @@ -80,7 +81,8 @@ def type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -91,8 +93,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/create_zone_payload.py b/services/dns/src/stackit/dns/models/create_zone_payload.py index d5e617525..c26a15277 100644 --- a/services/dns/src/stackit/dns/models/create_zone_payload.py +++ b/services/dns/src/stackit/dns/models/create_zone_payload.py @@ -26,6 +26,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.dns.models.zone_extensions import ZoneExtensions @@ -98,7 +99,8 @@ def type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -109,8 +111,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/delete_label_response.py b/services/dns/src/stackit/dns/models/delete_label_response.py index 18f28d2ac..9ce9dd155 100644 --- a/services/dns/src/stackit/dns/models/delete_label_response.py +++ b/services/dns/src/stackit/dns/models/delete_label_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.dns.models.label import Label @@ -34,7 +35,8 @@ class DeleteLabelResponse(BaseModel): __properties: ClassVar[List[str]] = ["label", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/domain_extensions.py b/services/dns/src/stackit/dns/models/domain_extensions.py index 8e62e4834..8a46b50a6 100644 --- a/services/dns/src/stackit/dns/models/domain_extensions.py +++ b/services/dns/src/stackit/dns/models/domain_extensions.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.dns.models.domain_observability_extension import ( @@ -37,7 +38,8 @@ class DomainExtensions(BaseModel): __properties: ClassVar[List[str]] = ["observabilityExtension"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/domain_observability_extension.py b/services/dns/src/stackit/dns/models/domain_observability_extension.py index c88d5f119..06c9e3a48 100644 --- a/services/dns/src/stackit/dns/models/domain_observability_extension.py +++ b/services/dns/src/stackit/dns/models/domain_observability_extension.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class DomainObservabilityExtension(BaseModel): __properties: ClassVar[List[str]] = ["observabilityInstanceId", "state"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/error_message.py b/services/dns/src/stackit/dns/models/error_message.py index 6a77fb404..392ef7d45 100644 --- a/services/dns/src/stackit/dns/models/error_message.py +++ b/services/dns/src/stackit/dns/models/error_message.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class ErrorMessage(BaseModel): __properties: ClassVar[List[str]] = ["error", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/export_record_sets_payload.py b/services/dns/src/stackit/dns/models/export_record_sets_payload.py index a41fd7ce5..35c7e3f6a 100644 --- a/services/dns/src/stackit/dns/models/export_record_sets_payload.py +++ b/services/dns/src/stackit/dns/models/export_record_sets_payload.py @@ -26,6 +26,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -49,7 +50,8 @@ def format_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +62,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/import_record_sets_payload.py b/services/dns/src/stackit/dns/models/import_record_sets_payload.py index 031165514..24264f8af 100644 --- a/services/dns/src/stackit/dns/models/import_record_sets_payload.py +++ b/services/dns/src/stackit/dns/models/import_record_sets_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.dns.models.zone_models_import_record_model import ( @@ -35,7 +36,8 @@ class ImportRecordSetsPayload(BaseModel): __properties: ClassVar[List[str]] = ["rrSets"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/import_record_sets_response.py b/services/dns/src/stackit/dns/models/import_record_sets_response.py index 7b886c933..3e2249d02 100644 --- a/services/dns/src/stackit/dns/models/import_record_sets_response.py +++ b/services/dns/src/stackit/dns/models/import_record_sets_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.dns.models.import_summary import ImportSummary @@ -34,7 +35,8 @@ class ImportRecordSetsResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "summary"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/import_summary.py b/services/dns/src/stackit/dns/models/import_summary.py index 8be19baa5..d3240b4de 100644 --- a/services/dns/src/stackit/dns/models/import_summary.py +++ b/services/dns/src/stackit/dns/models/import_summary.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -55,7 +56,8 @@ class ImportSummary(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -66,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/label.py b/services/dns/src/stackit/dns/models/label.py index 76421a4fc..bcad10321 100644 --- a/services/dns/src/stackit/dns/models/label.py +++ b/services/dns/src/stackit/dns/models/label.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -32,7 +33,8 @@ class Label(BaseModel): __properties: ClassVar[List[str]] = ["key", "value"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/list_labels_response.py b/services/dns/src/stackit/dns/models/list_labels_response.py index 6f2440f2d..4b0486aec 100644 --- a/services/dns/src/stackit/dns/models/list_labels_response.py +++ b/services/dns/src/stackit/dns/models/list_labels_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.dns.models.label import Label @@ -34,7 +35,8 @@ class ListLabelsResponse(BaseModel): __properties: ClassVar[List[str]] = ["labels", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/list_record_sets_response.py b/services/dns/src/stackit/dns/models/list_record_sets_response.py index 36ea48e6c..1a277d750 100644 --- a/services/dns/src/stackit/dns/models/list_record_sets_response.py +++ b/services/dns/src/stackit/dns/models/list_record_sets_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.dns.models.record_set import RecordSet @@ -37,7 +38,8 @@ class ListRecordSetsResponse(BaseModel): __properties: ClassVar[List[str]] = ["itemsPerPage", "message", "rrSets", "totalItems", "totalPages"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/list_zones_response.py b/services/dns/src/stackit/dns/models/list_zones_response.py index 6c22da3c4..d1e6152ac 100644 --- a/services/dns/src/stackit/dns/models/list_zones_response.py +++ b/services/dns/src/stackit/dns/models/list_zones_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.dns.models.zone import Zone @@ -37,7 +38,8 @@ class ListZonesResponse(BaseModel): __properties: ClassVar[List[str]] = ["itemsPerPage", "message", "totalItems", "totalPages", "zones"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/message.py b/services/dns/src/stackit/dns/models/message.py index 17aaacf07..70d46718d 100644 --- a/services/dns/src/stackit/dns/models/message.py +++ b/services/dns/src/stackit/dns/models/message.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class Message(BaseModel): __properties: ClassVar[List[str]] = ["message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/move_code_response.py b/services/dns/src/stackit/dns/models/move_code_response.py index a6a6fdc2f..9b7b1be4b 100644 --- a/services/dns/src/stackit/dns/models/move_code_response.py +++ b/services/dns/src/stackit/dns/models/move_code_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -33,7 +34,8 @@ class MoveCodeResponse(BaseModel): __properties: ClassVar[List[str]] = ["code", "expiresAt", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/move_zone_payload.py b/services/dns/src/stackit/dns/models/move_zone_payload.py index 1937968be..3998ef98a 100644 --- a/services/dns/src/stackit/dns/models/move_zone_payload.py +++ b/services/dns/src/stackit/dns/models/move_zone_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -36,7 +37,8 @@ class MoveZonePayload(BaseModel): __properties: ClassVar[List[str]] = ["code", "zoneDnsName"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/partial_update_record_payload.py b/services/dns/src/stackit/dns/models/partial_update_record_payload.py index 633710fcf..64e33fc50 100644 --- a/services/dns/src/stackit/dns/models/partial_update_record_payload.py +++ b/services/dns/src/stackit/dns/models/partial_update_record_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.dns.models.record_payload import RecordPayload @@ -41,7 +42,8 @@ def action_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -52,8 +54,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/partial_update_record_set_payload.py b/services/dns/src/stackit/dns/models/partial_update_record_set_payload.py index 9c718bc3d..0b50ae8e9 100644 --- a/services/dns/src/stackit/dns/models/partial_update_record_set_payload.py +++ b/services/dns/src/stackit/dns/models/partial_update_record_set_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.dns.models.record_payload import RecordPayload @@ -42,7 +43,8 @@ class PartialUpdateRecordSetPayload(BaseModel): __properties: ClassVar[List[str]] = ["comment", "name", "records", "ttl"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/partial_update_zone_payload.py b/services/dns/src/stackit/dns/models/partial_update_zone_payload.py index 413c7bfbc..381fb4792 100644 --- a/services/dns/src/stackit/dns/models/partial_update_zone_payload.py +++ b/services/dns/src/stackit/dns/models/partial_update_zone_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.dns.models.zone_extensions import ZoneExtensions @@ -73,7 +74,8 @@ class PartialUpdateZonePayload(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -84,8 +86,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/record.py b/services/dns/src/stackit/dns/models/record.py index da2192b9f..02787a0da 100644 --- a/services/dns/src/stackit/dns/models/record.py +++ b/services/dns/src/stackit/dns/models/record.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -34,7 +35,8 @@ class Record(BaseModel): __properties: ClassVar[List[str]] = ["content", "id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/record_data_exchange.py b/services/dns/src/stackit/dns/models/record_data_exchange.py index dd64f94f0..a4736b33c 100644 --- a/services/dns/src/stackit/dns/models/record_data_exchange.py +++ b/services/dns/src/stackit/dns/models/record_data_exchange.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -35,7 +36,8 @@ class RecordDataExchange(BaseModel): __properties: ClassVar[List[str]] = ["comment", "content", "name", "ttl", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/record_payload.py b/services/dns/src/stackit/dns/models/record_payload.py index 6949652c4..11747e9c3 100644 --- a/services/dns/src/stackit/dns/models/record_payload.py +++ b/services/dns/src/stackit/dns/models/record_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,7 +34,8 @@ class RecordPayload(BaseModel): __properties: ClassVar[List[str]] = ["content"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/record_set.py b/services/dns/src/stackit/dns/models/record_set.py index 974e033fc..f62c9d329 100644 --- a/services/dns/src/stackit/dns/models/record_set.py +++ b/services/dns/src/stackit/dns/models/record_set.py @@ -26,6 +26,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.dns.models.record import Record @@ -128,7 +129,8 @@ def type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -139,8 +141,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/record_set_response.py b/services/dns/src/stackit/dns/models/record_set_response.py index 81c474833..8168c9050 100644 --- a/services/dns/src/stackit/dns/models/record_set_response.py +++ b/services/dns/src/stackit/dns/models/record_set_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.dns.models.record_set import RecordSet @@ -34,7 +35,8 @@ class RecordSetResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "rrset"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/validate_move_code_payload.py b/services/dns/src/stackit/dns/models/validate_move_code_payload.py index c566deb12..413532843 100644 --- a/services/dns/src/stackit/dns/models/validate_move_code_payload.py +++ b/services/dns/src/stackit/dns/models/validate_move_code_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,7 +34,8 @@ class ValidateMoveCodePayload(BaseModel): __properties: ClassVar[List[str]] = ["code"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/zone.py b/services/dns/src/stackit/dns/models/zone.py index 11fa9b662..7a8e5b68c 100644 --- a/services/dns/src/stackit/dns/models/zone.py +++ b/services/dns/src/stackit/dns/models/zone.py @@ -27,6 +27,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.dns.models.domain_extensions import DomainExtensions @@ -155,7 +156,8 @@ def visibility_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -166,8 +168,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/zone_data_exchange.py b/services/dns/src/stackit/dns/models/zone_data_exchange.py index 470e252ab..e6206a762 100644 --- a/services/dns/src/stackit/dns/models/zone_data_exchange.py +++ b/services/dns/src/stackit/dns/models/zone_data_exchange.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.dns.models.record_data_exchange import RecordDataExchange @@ -33,7 +34,8 @@ class ZoneDataExchange(BaseModel): __properties: ClassVar[List[str]] = ["rrSets"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/zone_extensions.py b/services/dns/src/stackit/dns/models/zone_extensions.py index b635b75b4..7e9711cc5 100644 --- a/services/dns/src/stackit/dns/models/zone_extensions.py +++ b/services/dns/src/stackit/dns/models/zone_extensions.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.dns.models.zone_observability_extension import ZoneObservabilityExtension @@ -33,7 +34,8 @@ class ZoneExtensions(BaseModel): __properties: ClassVar[List[str]] = ["observabilityExtension"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/zone_models_import_record_model.py b/services/dns/src/stackit/dns/models/zone_models_import_record_model.py index 441eae2f2..62f195b5e 100644 --- a/services/dns/src/stackit/dns/models/zone_models_import_record_model.py +++ b/services/dns/src/stackit/dns/models/zone_models_import_record_model.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -35,7 +36,8 @@ class ZoneModelsImportRecordModel(BaseModel): __properties: ClassVar[List[str]] = ["comment", "content", "name", "ttl", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/zone_models_import_zone_json.py b/services/dns/src/stackit/dns/models/zone_models_import_zone_json.py index 72be11a07..f23f97b10 100644 --- a/services/dns/src/stackit/dns/models/zone_models_import_zone_json.py +++ b/services/dns/src/stackit/dns/models/zone_models_import_zone_json.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.dns.models.zone_models_import_record_model import ( @@ -35,7 +36,8 @@ class ZoneModelsImportZoneJson(BaseModel): __properties: ClassVar[List[str]] = ["rrSets"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/zone_observability_extension.py b/services/dns/src/stackit/dns/models/zone_observability_extension.py index ccd1e69dd..7bd224554 100644 --- a/services/dns/src/stackit/dns/models/zone_observability_extension.py +++ b/services/dns/src/stackit/dns/models/zone_observability_extension.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class ZoneObservabilityExtension(BaseModel): __properties: ClassVar[List[str]] = ["observabilityInstanceId", "state"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/dns/src/stackit/dns/models/zone_response.py b/services/dns/src/stackit/dns/models/zone_response.py index c51b789dc..e78bca4ca 100644 --- a/services/dns/src/stackit/dns/models/zone_response.py +++ b/services/dns/src/stackit/dns/models/zone_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.dns.models.zone import Zone @@ -34,7 +35,8 @@ class ZoneResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "zone"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/edge/CHANGELOG.md b/services/edge/CHANGELOG.md index d8c5ddb83..3351e8731 100644 --- a/services/edge/CHANGELOG.md +++ b/services/edge/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.4.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.3.0 - Removal of deprecated API client method `list_plans_global` diff --git a/services/edge/pyproject.toml b/services/edge/pyproject.toml index bf03afa85..028b6a9b8 100644 --- a/services/edge/pyproject.toml +++ b/services/edge/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-edge" -version = "v0.3.0" +version = "v0.4.0" description = "STACKIT Edge Cloud API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4" diff --git a/services/edge/src/stackit/edge/api_client.py b/services/edge/src/stackit/edge/api_client.py index 57b6ea31a..f6aa02f79 100644 --- a/services/edge/src/stackit/edge/api_client.py +++ b/services/edge/src/stackit/edge/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/edge/src/stackit/edge/models/bad_request.py b/services/edge/src/stackit/edge/models/bad_request.py index 6f9b8d5e5..bd09fdef7 100644 --- a/services/edge/src/stackit/edge/models/bad_request.py +++ b/services/edge/src/stackit/edge/models/bad_request.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class BadRequest(BaseModel): __properties: ClassVar[List[str]] = ["code", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/edge/src/stackit/edge/models/create_instance_payload.py b/services/edge/src/stackit/edge/models/create_instance_payload.py index b497a592e..21d9d3914 100644 --- a/services/edge/src/stackit/edge/models/create_instance_payload.py +++ b/services/edge/src/stackit/edge/models/create_instance_payload.py @@ -19,6 +19,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -37,7 +38,8 @@ class CreateInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["description", "displayName", "planId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/edge/src/stackit/edge/models/instance.py b/services/edge/src/stackit/edge/models/instance.py index a6589c2bb..453c92102 100644 --- a/services/edge/src/stackit/edge/models/instance.py +++ b/services/edge/src/stackit/edge/models/instance.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -73,7 +74,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -84,8 +86,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/edge/src/stackit/edge/models/instance_list.py b/services/edge/src/stackit/edge/models/instance_list.py index 644929223..1d5cc25d2 100644 --- a/services/edge/src/stackit/edge/models/instance_list.py +++ b/services/edge/src/stackit/edge/models/instance_list.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.edge.models.instance import Instance @@ -32,7 +33,8 @@ class InstanceList(BaseModel): __properties: ClassVar[List[str]] = ["instances"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/edge/src/stackit/edge/models/kubeconfig.py b/services/edge/src/stackit/edge/models/kubeconfig.py index ef2269570..b9f2139cd 100644 --- a/services/edge/src/stackit/edge/models/kubeconfig.py +++ b/services/edge/src/stackit/edge/models/kubeconfig.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class Kubeconfig(BaseModel): __properties: ClassVar[List[str]] = ["kubeconfig"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/edge/src/stackit/edge/models/plan.py b/services/edge/src/stackit/edge/models/plan.py index 133820056..0e22a1b00 100644 --- a/services/edge/src/stackit/edge/models/plan.py +++ b/services/edge/src/stackit/edge/models/plan.py @@ -19,6 +19,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -39,7 +40,8 @@ class Plan(BaseModel): __properties: ClassVar[List[str]] = ["description", "id", "maxEdgeHosts", "minEdgeHosts", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/edge/src/stackit/edge/models/plan_list.py b/services/edge/src/stackit/edge/models/plan_list.py index 649684919..730f5d7c7 100644 --- a/services/edge/src/stackit/edge/models/plan_list.py +++ b/services/edge/src/stackit/edge/models/plan_list.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.edge.models.plan import Plan @@ -32,7 +33,8 @@ class PlanList(BaseModel): __properties: ClassVar[List[str]] = ["validPlans"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/edge/src/stackit/edge/models/token.py b/services/edge/src/stackit/edge/models/token.py index 41f6ae88e..2bbb1f28d 100644 --- a/services/edge/src/stackit/edge/models/token.py +++ b/services/edge/src/stackit/edge/models/token.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class Token(BaseModel): __properties: ClassVar[List[str]] = ["token"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/edge/src/stackit/edge/models/unauthorized_request.py b/services/edge/src/stackit/edge/models/unauthorized_request.py index 5ef8af622..c61390c79 100644 --- a/services/edge/src/stackit/edge/models/unauthorized_request.py +++ b/services/edge/src/stackit/edge/models/unauthorized_request.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class UnauthorizedRequest(BaseModel): __properties: ClassVar[List[str]] = ["code", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/edge/src/stackit/edge/models/update_instance_by_name_payload.py b/services/edge/src/stackit/edge/models/update_instance_by_name_payload.py index 6c4293086..ebd92c671 100644 --- a/services/edge/src/stackit/edge/models/update_instance_by_name_payload.py +++ b/services/edge/src/stackit/edge/models/update_instance_by_name_payload.py @@ -19,6 +19,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -36,7 +37,8 @@ class UpdateInstanceByNamePayload(BaseModel): __properties: ClassVar[List[str]] = ["description", "planId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/edge/src/stackit/edge/models/update_instance_payload.py b/services/edge/src/stackit/edge/models/update_instance_payload.py index 1304f4c90..f78917d9c 100644 --- a/services/edge/src/stackit/edge/models/update_instance_payload.py +++ b/services/edge/src/stackit/edge/models/update_instance_payload.py @@ -19,6 +19,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -36,7 +37,8 @@ class UpdateInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["description", "planId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/edge/src/stackit/edge/models/user.py b/services/edge/src/stackit/edge/models/user.py index 952b1bb3b..7c6a7726c 100644 --- a/services/edge/src/stackit/edge/models/user.py +++ b/services/edge/src/stackit/edge/models/user.py @@ -19,6 +19,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class User(BaseModel): __properties: ClassVar[List[str]] = ["email", "internalId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/CHANGELOG.md b/services/git/CHANGELOG.md index 81b220eb8..e6b8551a5 100644 --- a/services/git/CHANGELOG.md +++ b/services/git/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.9.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.8.0 - **Feature:** client now supports UUID and decimal types - **Bugfix:** timeouts now passed to requests library diff --git a/services/git/pyproject.toml b/services/git/pyproject.toml index 432526768..b6ab04cb1 100644 --- a/services/git/pyproject.toml +++ b/services/git/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-git" -version = "v0.8.0" +version = "v0.9.0" description = "STACKIT Git API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/git/src/stackit/git/api/default_api.py b/services/git/src/stackit/git/api/default_api.py index 8b9a2c46c..b411bb9ca 100644 --- a/services/git/src/stackit/git/api/default_api.py +++ b/services/git/src/stackit/git/api/default_api.py @@ -15,7 +15,13 @@ from typing import Any, Dict, List, Optional, Tuple, Union from uuid import UUID -from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call +from pydantic import ( + Field, + StrictFloat, + StrictInt, + StrictStr, + validate_call, +) from stackit.core.configuration import Configuration from typing_extensions import Annotated diff --git a/services/git/src/stackit/git/api_client.py b/services/git/src/stackit/git/api_client.py index 38d5894a3..dda26313c 100644 --- a/services/git/src/stackit/git/api_client.py +++ b/services/git/src/stackit/git/api_client.py @@ -67,6 +67,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -266,7 +267,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -327,25 +328,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -418,6 +414,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/git/src/stackit/git/models/already_exists_error.py b/services/git/src/stackit/git/models/already_exists_error.py index 11b7f6190..f222b8484 100644 --- a/services/git/src/stackit/git/models/already_exists_error.py +++ b/services/git/src/stackit/git/models/already_exists_error.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class AlreadyExistsError(BaseModel): __properties: ClassVar[List[str]] = ["message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/authentication.py b/services/git/src/stackit/git/models/authentication.py index d4311e134..7585ccd29 100644 --- a/services/git/src/stackit/git/models/authentication.py +++ b/services/git/src/stackit/git/models/authentication.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -64,6 +65,9 @@ class Authentication(BaseModel): @field_validator("auto_discover_url") def auto_discover_url_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$", value): raise ValueError( r"must validate the regular expression /^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$/" @@ -86,6 +90,9 @@ def created_at_change_year_zero_to_one(cls, value): @field_validator("icon_url") def icon_url_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$", value): raise ValueError( r"must validate the regular expression /^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$/" @@ -93,7 +100,8 @@ def icon_url_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -104,8 +112,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/authentication_list.py b/services/git/src/stackit/git/models/authentication_list.py index 224cb44c7..a1ba9a190 100644 --- a/services/git/src/stackit/git/models/authentication_list.py +++ b/services/git/src/stackit/git/models/authentication_list.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.git.models.authentication import Authentication @@ -33,7 +34,8 @@ class AuthenticationList(BaseModel): __properties: ClassVar[List[str]] = ["authentication"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/bad_error_response.py b/services/git/src/stackit/git/models/bad_error_response.py index 86233a751..9f636174d 100644 --- a/services/git/src/stackit/git/models/bad_error_response.py +++ b/services/git/src/stackit/git/models/bad_error_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class BadErrorResponse(BaseModel): __properties: ClassVar[List[str]] = ["details", "error"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/conflict_error_response.py b/services/git/src/stackit/git/models/conflict_error_response.py index dec38a288..0ec8683ee 100644 --- a/services/git/src/stackit/git/models/conflict_error_response.py +++ b/services/git/src/stackit/git/models/conflict_error_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class ConflictErrorResponse(BaseModel): __properties: ClassVar[List[str]] = ["details", "error"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/create_authentication_payload.py b/services/git/src/stackit/git/models/create_authentication_payload.py index bf1985a9e..5030ff4e0 100644 --- a/services/git/src/stackit/git/models/create_authentication_payload.py +++ b/services/git/src/stackit/git/models/create_authentication_payload.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -56,6 +57,9 @@ class CreateAuthenticationPayload(BaseModel): @field_validator("auto_discover_url") def auto_discover_url_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$", value): raise ValueError( r"must validate the regular expression /^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$/" @@ -68,6 +72,9 @@ def icon_url_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$", value): raise ValueError( r"must validate the regular expression /^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$/" @@ -75,7 +82,8 @@ def icon_url_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -86,8 +94,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/create_instance_payload.py b/services/git/src/stackit/git/models/create_instance_payload.py index 75fa6e001..9300163a8 100644 --- a/services/git/src/stackit/git/models/create_instance_payload.py +++ b/services/git/src/stackit/git/models/create_instance_payload.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -50,12 +51,16 @@ def flavor_validate_enum(cls, value): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z]([a-z0-9\-]){0,30}[a-z0-9]+$", value): raise ValueError(r"must validate the regular expression /^[a-z]([a-z0-9\-]){0,30}[a-z0-9]+$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -66,8 +71,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/create_runner_payload.py b/services/git/src/stackit/git/models/create_runner_payload.py index 6d3f1d4c7..20b81af88 100644 --- a/services/git/src/stackit/git/models/create_runner_payload.py +++ b/services/git/src/stackit/git/models/create_runner_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class CreateRunnerPayload(BaseModel): __properties: ClassVar[List[str]] = ["labels"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/feature_toggle.py b/services/git/src/stackit/git/models/feature_toggle.py index 80987381d..65c2fd631 100644 --- a/services/git/src/stackit/git/models/feature_toggle.py +++ b/services/git/src/stackit/git/models/feature_toggle.py @@ -26,6 +26,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -54,7 +55,8 @@ def default_email_notifications_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -65,8 +67,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/flavor.py b/services/git/src/stackit/git/models/flavor.py index 80fc07a63..2c98daf79 100644 --- a/services/git/src/stackit/git/models/flavor.py +++ b/services/git/src/stackit/git/models/flavor.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -42,7 +43,8 @@ def availability_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/generic_error_response.py b/services/git/src/stackit/git/models/generic_error_response.py index 945532c5e..3a093efb2 100644 --- a/services/git/src/stackit/git/models/generic_error_response.py +++ b/services/git/src/stackit/git/models/generic_error_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class GenericErrorResponse(BaseModel): __properties: ClassVar[List[str]] = ["details", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/instance.py b/services/git/src/stackit/git/models/instance.py index 498ac9222..30f6fdb84 100644 --- a/services/git/src/stackit/git/models/instance.py +++ b/services/git/src/stackit/git/models/instance.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.git.models.feature_toggle import FeatureToggle @@ -88,7 +89,8 @@ def state_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -99,8 +101,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/internal_server_error_response.py b/services/git/src/stackit/git/models/internal_server_error_response.py index 460f428ea..ad2d8a1ac 100644 --- a/services/git/src/stackit/git/models/internal_server_error_response.py +++ b/services/git/src/stackit/git/models/internal_server_error_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class InternalServerErrorResponse(BaseModel): __properties: ClassVar[List[str]] = ["details", "error"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/list_flavors.py b/services/git/src/stackit/git/models/list_flavors.py index 2a374a156..669495595 100644 --- a/services/git/src/stackit/git/models/list_flavors.py +++ b/services/git/src/stackit/git/models/list_flavors.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.git.models.flavor import Flavor @@ -33,7 +34,8 @@ class ListFlavors(BaseModel): __properties: ClassVar[List[str]] = ["flavors"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/list_instances.py b/services/git/src/stackit/git/models/list_instances.py index 0c7853158..5c8b6bc12 100644 --- a/services/git/src/stackit/git/models/list_instances.py +++ b/services/git/src/stackit/git/models/list_instances.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.git.models.instance import Instance @@ -33,7 +34,8 @@ class ListInstances(BaseModel): __properties: ClassVar[List[str]] = ["instances"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/not_found_error_response.py b/services/git/src/stackit/git/models/not_found_error_response.py index dbf478cc6..eba1b99f9 100644 --- a/services/git/src/stackit/git/models/not_found_error_response.py +++ b/services/git/src/stackit/git/models/not_found_error_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class NotFoundErrorResponse(BaseModel): __properties: ClassVar[List[str]] = ["details", "error"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/patch_authentication_payload.py b/services/git/src/stackit/git/models/patch_authentication_payload.py index c4399a5e9..701b5c9e5 100644 --- a/services/git/src/stackit/git/models/patch_authentication_payload.py +++ b/services/git/src/stackit/git/models/patch_authentication_payload.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -55,6 +56,9 @@ def auto_discover_url_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$", value): raise ValueError( r"must validate the regular expression /^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$/" @@ -67,6 +71,9 @@ def icon_url_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$", value): raise ValueError( r"must validate the regular expression /^https:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,})+(\/.*)?$/" @@ -74,7 +81,8 @@ def icon_url_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -85,8 +93,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/patch_instance_payload.py b/services/git/src/stackit/git/models/patch_instance_payload.py index 6e2e7c594..ca463f345 100644 --- a/services/git/src/stackit/git/models/patch_instance_payload.py +++ b/services/git/src/stackit/git/models/patch_instance_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.git.models.feature_toggle import FeatureToggle @@ -36,7 +37,8 @@ class PatchInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["acl", "feature_toggle"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/patch_operation.py b/services/git/src/stackit/git/models/patch_operation.py index f3866b48c..83f3d9bdd 100644 --- a/services/git/src/stackit/git/models/patch_operation.py +++ b/services/git/src/stackit/git/models/patch_operation.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -42,7 +43,8 @@ def op_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/runner.py b/services/git/src/stackit/git/models/runner.py index e02bf4672..eaf4819fe 100644 --- a/services/git/src/stackit/git/models/runner.py +++ b/services/git/src/stackit/git/models/runner.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -50,7 +51,8 @@ def created_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -61,8 +63,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/runner_runtime.py b/services/git/src/stackit/git/models/runner_runtime.py index 65c1ef237..2be422dea 100644 --- a/services/git/src/stackit/git/models/runner_runtime.py +++ b/services/git/src/stackit/git/models/runner_runtime.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -35,7 +36,8 @@ class RunnerRuntime(BaseModel): __properties: ClassVar[List[str]] = ["availability", "description", "display_name", "id", "label"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/runner_runtime_list.py b/services/git/src/stackit/git/models/runner_runtime_list.py index 2778510be..898807263 100644 --- a/services/git/src/stackit/git/models/runner_runtime_list.py +++ b/services/git/src/stackit/git/models/runner_runtime_list.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.git.models.runner_runtime import RunnerRuntime @@ -33,7 +34,8 @@ class RunnerRuntimeList(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/git/src/stackit/git/models/unauthorized_error_response.py b/services/git/src/stackit/git/models/unauthorized_error_response.py index 96f2f4124..4ee3bd0a2 100644 --- a/services/git/src/stackit/git/models/unauthorized_error_response.py +++ b/services/git/src/stackit/git/models/unauthorized_error_response.py @@ -21,6 +21,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -50,7 +51,8 @@ def timestamp_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -61,8 +63,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/CHANGELOG.md b/services/iaas/CHANGELOG.md index 15a4f1188..b66edb972 100644 --- a/services/iaas/CHANGELOG.md +++ b/services/iaas/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.4.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v1.3.0 - **Feature:** Add `cascade` parameter to `delete_volume` API call - **Feature:** Add `config_drive` attribute to ModelClass `Server` and `CreateServerPayload` diff --git a/services/iaas/pyproject.toml b/services/iaas/pyproject.toml index 10c2a9baa..49483edcd 100644 --- a/services/iaas/pyproject.toml +++ b/services/iaas/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-iaas" -version = "v1.3.0" +version = "v1.4.0" description = "IaaS-API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/iaas/src/stackit/iaas/api_client.py b/services/iaas/src/stackit/iaas/api_client.py index 9e10f6635..a41580db0 100644 --- a/services/iaas/src/stackit/iaas/api_client.py +++ b/services/iaas/src/stackit/iaas/api_client.py @@ -67,6 +67,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -266,7 +267,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -327,25 +328,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -418,6 +414,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/iaas/src/stackit/iaas/models/add_routes_to_routing_table_payload.py b/services/iaas/src/stackit/iaas/models/add_routes_to_routing_table_payload.py index 2df7be3d0..ac6d66031 100644 --- a/services/iaas/src/stackit/iaas/models/add_routes_to_routing_table_payload.py +++ b/services/iaas/src/stackit/iaas/models/add_routes_to_routing_table_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.route import Route @@ -33,7 +34,8 @@ class AddRoutesToRoutingTablePayload(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/add_routing_table_to_area_payload.py b/services/iaas/src/stackit/iaas/models/add_routing_table_to_area_payload.py index e0583528a..984e6f12e 100644 --- a/services/iaas/src/stackit/iaas/models/add_routing_table_to_area_payload.py +++ b/services/iaas/src/stackit/iaas/models/add_routing_table_to_area_payload.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -92,6 +93,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -101,6 +105,9 @@ def id_validate_regular_expression(cls, value): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value @@ -119,7 +126,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -130,8 +138,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/add_volume_to_server_payload.py b/services/iaas/src/stackit/iaas/models/add_volume_to_server_payload.py index 1b5676722..9c74a452f 100644 --- a/services/iaas/src/stackit/iaas/models/add_volume_to_server_payload.py +++ b/services/iaas/src/stackit/iaas/models/add_volume_to_server_payload.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -48,6 +49,9 @@ def server_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -60,6 +64,9 @@ def volume_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -67,7 +74,8 @@ def volume_id_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -78,8 +86,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/affinity_group.py b/services/iaas/src/stackit/iaas/models/affinity_group.py index 4e810657c..d76f7b50c 100644 --- a/services/iaas/src/stackit/iaas/models/affinity_group.py +++ b/services/iaas/src/stackit/iaas/models/affinity_group.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -45,6 +46,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -54,12 +58,16 @@ def id_validate_regular_expression(cls, value): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -70,8 +78,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/affinity_group_list_response.py b/services/iaas/src/stackit/iaas/models/affinity_group_list_response.py index 334a1c829..153f9ad8a 100644 --- a/services/iaas/src/stackit/iaas/models/affinity_group_list_response.py +++ b/services/iaas/src/stackit/iaas/models/affinity_group_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.affinity_group import AffinityGroup @@ -33,7 +34,8 @@ class AffinityGroupListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/availability_zone_list_response.py b/services/iaas/src/stackit/iaas/models/availability_zone_list_response.py index 4378025f2..59b68c2e8 100644 --- a/services/iaas/src/stackit/iaas/models/availability_zone_list_response.py +++ b/services/iaas/src/stackit/iaas/models/availability_zone_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class AvailabilityZoneListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/backup.py b/services/iaas/src/stackit/iaas/models/backup.py index 72f7f44aa..84c5429aa 100644 --- a/services/iaas/src/stackit/iaas/models/backup.py +++ b/services/iaas/src/stackit/iaas/models/backup.py @@ -30,6 +30,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -104,6 +105,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -116,6 +120,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value @@ -126,6 +133,9 @@ def snapshot_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -151,6 +161,9 @@ def volume_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -158,7 +171,8 @@ def volume_id_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -169,8 +183,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/backup_list_response.py b/services/iaas/src/stackit/iaas/models/backup_list_response.py index 105bc55f2..c469cb052 100644 --- a/services/iaas/src/stackit/iaas/models/backup_list_response.py +++ b/services/iaas/src/stackit/iaas/models/backup_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.backup import Backup @@ -33,7 +34,8 @@ class BackupListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/backup_source.py b/services/iaas/src/stackit/iaas/models/backup_source.py index 95ac58026..4fcc173e5 100644 --- a/services/iaas/src/stackit/iaas/models/backup_source.py +++ b/services/iaas/src/stackit/iaas/models/backup_source.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -36,6 +37,9 @@ class BackupSource(BaseModel): @field_validator("id") def id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -43,7 +47,8 @@ def id_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -54,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/base_security_group_rule.py b/services/iaas/src/stackit/iaas/models/base_security_group_rule.py index 9b0872bea..c023f7b6b 100644 --- a/services/iaas/src/stackit/iaas/models/base_security_group_rule.py +++ b/services/iaas/src/stackit/iaas/models/base_security_group_rule.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.icmp_parameters import ICMPParameters @@ -95,6 +96,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -107,6 +111,9 @@ def ip_range_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match( r"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/(3[0-2]|2[0-9]|1[0-9]|[0-9]))$|^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))(\/((1(1[0-9]|2[0-8]))|([0-9][0-9])|([0-9])))?$", value, @@ -122,6 +129,9 @@ def remote_security_group_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -134,6 +144,9 @@ def security_group_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -154,7 +167,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -165,8 +179,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/boot_volume.py b/services/iaas/src/stackit/iaas/models/boot_volume.py index 7f4e5a539..b93078830 100644 --- a/services/iaas/src/stackit/iaas/models/boot_volume.py +++ b/services/iaas/src/stackit/iaas/models/boot_volume.py @@ -28,6 +28,7 @@ StrictInt, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.boot_volume_source import BootVolumeSource @@ -59,6 +60,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -71,12 +75,16 @@ def performance_class_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -87,8 +95,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/boot_volume_source.py b/services/iaas/src/stackit/iaas/models/boot_volume_source.py index 6a224a767..8fb12fe31 100644 --- a/services/iaas/src/stackit/iaas/models/boot_volume_source.py +++ b/services/iaas/src/stackit/iaas/models/boot_volume_source.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -36,6 +37,9 @@ class BootVolumeSource(BaseModel): @field_validator("id") def id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -43,7 +47,8 @@ def id_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -54,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_affinity_group_payload.py b/services/iaas/src/stackit/iaas/models/create_affinity_group_payload.py index 12182f904..59e6a3a6f 100644 --- a/services/iaas/src/stackit/iaas/models/create_affinity_group_payload.py +++ b/services/iaas/src/stackit/iaas/models/create_affinity_group_payload.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -45,6 +46,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -54,12 +58,16 @@ def id_validate_regular_expression(cls, value): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -70,8 +78,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_backup_payload.py b/services/iaas/src/stackit/iaas/models/create_backup_payload.py index 3e479353b..def0f8b40 100644 --- a/services/iaas/src/stackit/iaas/models/create_backup_payload.py +++ b/services/iaas/src/stackit/iaas/models/create_backup_payload.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.backup_source import BackupSource @@ -49,12 +50,16 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -65,8 +70,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_image_payload.py b/services/iaas/src/stackit/iaas/models/create_image_payload.py index 273873bf8..92a7a40be 100644 --- a/services/iaas/src/stackit/iaas/models/create_image_payload.py +++ b/services/iaas/src/stackit/iaas/models/create_image_payload.py @@ -30,6 +30,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.image_agent import ImageAgent @@ -118,6 +119,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -127,6 +131,9 @@ def id_validate_regular_expression(cls, value): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value @@ -137,6 +144,9 @@ def owner_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -157,7 +167,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -168,8 +179,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_isolated_network_payload.py b/services/iaas/src/stackit/iaas/models/create_isolated_network_payload.py index 2ac8dee67..4d7684012 100644 --- a/services/iaas/src/stackit/iaas/models/create_isolated_network_payload.py +++ b/services/iaas/src/stackit/iaas/models/create_isolated_network_payload.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.create_network_ipv4 import CreateNetworkIPv4 @@ -44,12 +45,16 @@ class CreateIsolatedNetworkPayload(BaseModel): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +65,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_key_pair_payload.py b/services/iaas/src/stackit/iaas/models/create_key_pair_payload.py index 2716e1242..65c5c7a5f 100644 --- a/services/iaas/src/stackit/iaas/models/create_key_pair_payload.py +++ b/services/iaas/src/stackit/iaas/models/create_key_pair_payload.py @@ -21,6 +21,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -70,6 +71,9 @@ def fingerprint_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^([0-9A-Fa-f]{2}[:-]){15}([0-9A-Fa-f]{2})$", value): raise ValueError(r"must validate the regular expression /^([0-9A-Fa-f]{2}[:-]){15}([0-9A-Fa-f]{2})$/") return value @@ -80,6 +84,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9@._-]*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9@._-]*$/") return value @@ -87,6 +94,9 @@ def name_validate_regular_expression(cls, value): @field_validator("public_key") def public_key_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match( r"^(ssh-rsa|ssh-ed25519|ecdsa-sha2-nistp(256|384|521))\s+[A-Za-z0-9+\/]+[=]{0,3}(\s+.+)?\s*$", value ): @@ -109,7 +119,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -120,8 +131,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_network_area_payload.py b/services/iaas/src/stackit/iaas/models/create_network_area_payload.py index b18b060ea..cd8e1cc63 100644 --- a/services/iaas/src/stackit/iaas/models/create_network_area_payload.py +++ b/services/iaas/src/stackit/iaas/models/create_network_area_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -35,7 +36,8 @@ class CreateNetworkAreaPayload(BaseModel): __properties: ClassVar[List[str]] = ["labels", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_network_area_range_payload.py b/services/iaas/src/stackit/iaas/models/create_network_area_range_payload.py index fc735f16b..08a4ecc4b 100644 --- a/services/iaas/src/stackit/iaas/models/create_network_area_range_payload.py +++ b/services/iaas/src/stackit/iaas/models/create_network_area_range_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.network_range import NetworkRange @@ -35,7 +36,8 @@ class CreateNetworkAreaRangePayload(BaseModel): __properties: ClassVar[List[str]] = ["ipv4"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_network_area_region_payload.py b/services/iaas/src/stackit/iaas/models/create_network_area_region_payload.py index 1a487f690..e50ad04ba 100644 --- a/services/iaas/src/stackit/iaas/models/create_network_area_region_payload.py +++ b/services/iaas/src/stackit/iaas/models/create_network_area_region_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.regional_area_ipv4 import RegionalAreaIPv4 @@ -37,7 +38,8 @@ class CreateNetworkAreaRegionPayload(BaseModel): __properties: ClassVar[List[str]] = ["ipv4", "status"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_network_area_route_payload.py b/services/iaas/src/stackit/iaas/models/create_network_area_route_payload.py index 9043de361..1ab0ea1f4 100644 --- a/services/iaas/src/stackit/iaas/models/create_network_area_route_payload.py +++ b/services/iaas/src/stackit/iaas/models/create_network_area_route_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.route import Route @@ -33,7 +34,8 @@ class CreateNetworkAreaRoutePayload(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_network_ipv4_with_prefix.py b/services/iaas/src/stackit/iaas/models/create_network_ipv4_with_prefix.py index a9252b58c..e22412b08 100644 --- a/services/iaas/src/stackit/iaas/models/create_network_ipv4_with_prefix.py +++ b/services/iaas/src/stackit/iaas/models/create_network_ipv4_with_prefix.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -44,6 +45,9 @@ def gateway_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match( r"^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$", value, @@ -56,6 +60,9 @@ def gateway_validate_regular_expression(cls, value): @field_validator("prefix") def prefix_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match( r"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/(3[0-2]|2[0-9]|1[0-9]|[0-9]))$", value, @@ -66,7 +73,8 @@ def prefix_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -77,8 +85,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_network_ipv4_with_prefix_length.py b/services/iaas/src/stackit/iaas/models/create_network_ipv4_with_prefix_length.py index 8a1e4c71e..463bcd02f 100644 --- a/services/iaas/src/stackit/iaas/models/create_network_ipv4_with_prefix_length.py +++ b/services/iaas/src/stackit/iaas/models/create_network_ipv4_with_prefix_length.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -34,7 +35,8 @@ class CreateNetworkIPv4WithPrefixLength(BaseModel): __properties: ClassVar[List[str]] = ["nameservers", "prefixLength"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_network_ipv6_with_prefix.py b/services/iaas/src/stackit/iaas/models/create_network_ipv6_with_prefix.py index 76dc6dfcb..9c3e9ba7c 100644 --- a/services/iaas/src/stackit/iaas/models/create_network_ipv6_with_prefix.py +++ b/services/iaas/src/stackit/iaas/models/create_network_ipv6_with_prefix.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -44,6 +45,9 @@ def gateway_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match( r"^\s*((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$", value, @@ -56,6 +60,9 @@ def gateway_validate_regular_expression(cls, value): @field_validator("prefix") def prefix_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match( r"^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))(\/((1(1[0-9]|2[0-8]))|([0-9][0-9])|([0-9])))?$", value, @@ -66,7 +73,8 @@ def prefix_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -77,8 +85,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_network_ipv6_with_prefix_length.py b/services/iaas/src/stackit/iaas/models/create_network_ipv6_with_prefix_length.py index 68a79a989..8696f5cad 100644 --- a/services/iaas/src/stackit/iaas/models/create_network_ipv6_with_prefix_length.py +++ b/services/iaas/src/stackit/iaas/models/create_network_ipv6_with_prefix_length.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -34,7 +35,8 @@ class CreateNetworkIPv6WithPrefixLength(BaseModel): __properties: ClassVar[List[str]] = ["nameservers", "prefixLength"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_network_payload.py b/services/iaas/src/stackit/iaas/models/create_network_payload.py index 7d6357d0c..d6e932255 100644 --- a/services/iaas/src/stackit/iaas/models/create_network_payload.py +++ b/services/iaas/src/stackit/iaas/models/create_network_payload.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.create_network_ipv4 import CreateNetworkIPv4 @@ -53,6 +54,9 @@ class CreateNetworkPayload(BaseModel): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value @@ -63,6 +67,9 @@ def routing_table_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -70,7 +77,8 @@ def routing_table_id_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -81,8 +89,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_nic_payload.py b/services/iaas/src/stackit/iaas/models/create_nic_payload.py index 12d636bcc..c01866de8 100644 --- a/services/iaas/src/stackit/iaas/models/create_nic_payload.py +++ b/services/iaas/src/stackit/iaas/models/create_nic_payload.py @@ -28,6 +28,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.allowed_addresses_inner import AllowedAddressesInner @@ -98,6 +99,9 @@ def device_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -110,6 +114,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -122,6 +129,9 @@ def ipv4_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match( r"((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$)|(^\s*((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$))", value, @@ -137,6 +147,9 @@ def ipv6_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match( r"^\s*((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$", value, @@ -152,6 +165,9 @@ def mac_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$", value): raise ValueError(r"must validate the regular expression /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/") return value @@ -162,6 +178,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value @@ -172,6 +191,9 @@ def network_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -179,7 +201,8 @@ def network_id_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -190,8 +213,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_public_ip_payload.py b/services/iaas/src/stackit/iaas/models/create_public_ip_payload.py index e76856cd1..7af4294bc 100644 --- a/services/iaas/src/stackit/iaas/models/create_public_ip_payload.py +++ b/services/iaas/src/stackit/iaas/models/create_public_ip_payload.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -48,6 +49,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -60,6 +64,9 @@ def ip_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match( r"^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$", value, @@ -75,6 +82,9 @@ def network_interface_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -82,7 +92,8 @@ def network_interface_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -93,8 +104,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_security_group_payload.py b/services/iaas/src/stackit/iaas/models/create_security_group_payload.py index 8426791a3..a5e097984 100644 --- a/services/iaas/src/stackit/iaas/models/create_security_group_payload.py +++ b/services/iaas/src/stackit/iaas/models/create_security_group_payload.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.security_group_rule import SecurityGroupRule @@ -86,6 +87,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -95,6 +99,9 @@ def id_validate_regular_expression(cls, value): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value @@ -113,7 +120,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -124,8 +132,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_security_group_rule_payload.py b/services/iaas/src/stackit/iaas/models/create_security_group_rule_payload.py index ea34c6fd4..7720dfc71 100644 --- a/services/iaas/src/stackit/iaas/models/create_security_group_rule_payload.py +++ b/services/iaas/src/stackit/iaas/models/create_security_group_rule_payload.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.create_protocol import CreateProtocol @@ -98,6 +99,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -110,6 +114,9 @@ def ip_range_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match( r"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/(3[0-2]|2[0-9]|1[0-9]|[0-9]))$|^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))(\/((1(1[0-9]|2[0-8]))|([0-9][0-9])|([0-9])))?$", value, @@ -125,6 +132,9 @@ def remote_security_group_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -137,6 +147,9 @@ def security_group_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -157,7 +170,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -168,8 +182,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_security_group_rule_protocol.py b/services/iaas/src/stackit/iaas/models/create_security_group_rule_protocol.py index 707f81220..c711a9eae 100644 --- a/services/iaas/src/stackit/iaas/models/create_security_group_rule_protocol.py +++ b/services/iaas/src/stackit/iaas/models/create_security_group_rule_protocol.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.create_protocol import CreateProtocol @@ -33,7 +34,8 @@ class CreateSecurityGroupRuleProtocol(BaseModel): __properties: ClassVar[List[str]] = ["protocol"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_server_networking.py b/services/iaas/src/stackit/iaas/models/create_server_networking.py index c5c4a9b95..f0cba7d05 100644 --- a/services/iaas/src/stackit/iaas/models/create_server_networking.py +++ b/services/iaas/src/stackit/iaas/models/create_server_networking.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -40,6 +41,9 @@ def network_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -47,7 +51,8 @@ def network_id_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -58,8 +63,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_server_networking_with_nics.py b/services/iaas/src/stackit/iaas/models/create_server_networking_with_nics.py index 0f2b9ece3..0e8b1aefd 100644 --- a/services/iaas/src/stackit/iaas/models/create_server_networking_with_nics.py +++ b/services/iaas/src/stackit/iaas/models/create_server_networking_with_nics.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class CreateServerNetworkingWithNics(BaseModel): __properties: ClassVar[List[str]] = ["nicIds"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_server_payload.py b/services/iaas/src/stackit/iaas/models/create_server_payload.py index eed5fd63a..632f7c184 100644 --- a/services/iaas/src/stackit/iaas/models/create_server_payload.py +++ b/services/iaas/src/stackit/iaas/models/create_server_payload.py @@ -30,6 +30,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.boot_volume import BootVolume @@ -151,6 +152,9 @@ def affinity_group_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -176,6 +180,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -188,6 +195,9 @@ def image_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -200,6 +210,9 @@ def keypair_name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9@._-]*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9@._-]*$/") return value @@ -220,6 +233,9 @@ def launched_at_change_year_zero_to_one(cls, value): @field_validator("machine_type") def machine_type_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value @@ -227,6 +243,9 @@ def machine_type_validate_regular_expression(cls, value): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match( r"^(([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$", value, @@ -250,7 +269,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -261,8 +281,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_snapshot_payload.py b/services/iaas/src/stackit/iaas/models/create_snapshot_payload.py index a7161e27d..fe1a587f2 100644 --- a/services/iaas/src/stackit/iaas/models/create_snapshot_payload.py +++ b/services/iaas/src/stackit/iaas/models/create_snapshot_payload.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -84,6 +85,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -96,6 +100,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value @@ -116,6 +123,9 @@ def updated_at_change_year_zero_to_one(cls, value): @field_validator("volume_id") def volume_id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -123,7 +133,8 @@ def volume_id_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -134,8 +145,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/create_volume_payload.py b/services/iaas/src/stackit/iaas/models/create_volume_payload.py index 854f86b4c..cc7f037e9 100644 --- a/services/iaas/src/stackit/iaas/models/create_volume_payload.py +++ b/services/iaas/src/stackit/iaas/models/create_volume_payload.py @@ -30,6 +30,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.image_config import ImageConfig @@ -118,6 +119,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -130,6 +134,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value @@ -140,6 +147,9 @@ def performance_class_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value @@ -150,6 +160,9 @@ def server_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -170,7 +183,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -181,8 +195,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/destination_cidrv4.py b/services/iaas/src/stackit/iaas/models/destination_cidrv4.py index c460b0503..db516f074 100644 --- a/services/iaas/src/stackit/iaas/models/destination_cidrv4.py +++ b/services/iaas/src/stackit/iaas/models/destination_cidrv4.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -35,6 +36,9 @@ class DestinationCIDRv4(BaseModel): @field_validator("value") def value_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match( r"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/(3[0-2]|2[0-9]|1[0-9]|[0-9]))$", value, @@ -45,7 +49,8 @@ def value_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +61,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/destination_cidrv6.py b/services/iaas/src/stackit/iaas/models/destination_cidrv6.py index 2d8ff7b21..852dcb17b 100644 --- a/services/iaas/src/stackit/iaas/models/destination_cidrv6.py +++ b/services/iaas/src/stackit/iaas/models/destination_cidrv6.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -35,6 +36,9 @@ class DestinationCIDRv6(BaseModel): @field_validator("value") def value_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match( r"^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))(\/((1(1[0-9]|2[0-8]))|([0-9][0-9])|([0-9])))?$", value, @@ -45,7 +49,8 @@ def value_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +61,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/error.py b/services/iaas/src/stackit/iaas/models/error.py index baa61c614..5505720fc 100644 --- a/services/iaas/src/stackit/iaas/models/error.py +++ b/services/iaas/src/stackit/iaas/models/error.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class Error(BaseModel): __properties: ClassVar[List[str]] = ["code", "msg"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/get_server_log200_response.py b/services/iaas/src/stackit/iaas/models/get_server_log200_response.py index 6058b020b..f4071cce9 100644 --- a/services/iaas/src/stackit/iaas/models/get_server_log200_response.py +++ b/services/iaas/src/stackit/iaas/models/get_server_log200_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class GetServerLog200Response(BaseModel): __properties: ClassVar[List[str]] = ["output"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/icmp_parameters.py b/services/iaas/src/stackit/iaas/models/icmp_parameters.py index 02f67e82f..4ae83979e 100644 --- a/services/iaas/src/stackit/iaas/models/icmp_parameters.py +++ b/services/iaas/src/stackit/iaas/models/icmp_parameters.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -36,7 +37,8 @@ class ICMPParameters(BaseModel): __properties: ClassVar[List[str]] = ["code", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/image.py b/services/iaas/src/stackit/iaas/models/image.py index 7e01de46d..2ebb45beb 100644 --- a/services/iaas/src/stackit/iaas/models/image.py +++ b/services/iaas/src/stackit/iaas/models/image.py @@ -30,6 +30,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.image_agent import ImageAgent @@ -118,6 +119,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -127,6 +131,9 @@ def id_validate_regular_expression(cls, value): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value @@ -137,6 +144,9 @@ def owner_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -157,7 +167,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -168,8 +179,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/image_agent.py b/services/iaas/src/stackit/iaas/models/image_agent.py index f0899caad..85feab84d 100644 --- a/services/iaas/src/stackit/iaas/models/image_agent.py +++ b/services/iaas/src/stackit/iaas/models/image_agent.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -39,7 +40,8 @@ class ImageAgent(BaseModel): __properties: ClassVar[List[str]] = ["provisionByDefault", "supported"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/image_checksum.py b/services/iaas/src/stackit/iaas/models/image_checksum.py index b66fa4c2c..2923a8976 100644 --- a/services/iaas/src/stackit/iaas/models/image_checksum.py +++ b/services/iaas/src/stackit/iaas/models/image_checksum.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -37,12 +38,16 @@ class ImageChecksum(BaseModel): @field_validator("digest") def digest_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]+$", value): raise ValueError(r"must validate the regular expression /^[0-9a-f]+$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +58,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/image_config.py b/services/iaas/src/stackit/iaas/models/image_config.py index 01f7ae68b..464547ea2 100644 --- a/services/iaas/src/stackit/iaas/models/image_config.py +++ b/services/iaas/src/stackit/iaas/models/image_config.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -110,7 +111,8 @@ class ImageConfig(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -121,8 +123,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/image_create_response.py b/services/iaas/src/stackit/iaas/models/image_create_response.py index 96a3f9a99..c61f93090 100644 --- a/services/iaas/src/stackit/iaas/models/image_create_response.py +++ b/services/iaas/src/stackit/iaas/models/image_create_response.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -36,6 +37,9 @@ class ImageCreateResponse(BaseModel): @field_validator("id") def id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -43,7 +47,8 @@ def id_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -54,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/image_from_volume_payload.py b/services/iaas/src/stackit/iaas/models/image_from_volume_payload.py index 28eb7acd1..c817a748f 100644 --- a/services/iaas/src/stackit/iaas/models/image_from_volume_payload.py +++ b/services/iaas/src/stackit/iaas/models/image_from_volume_payload.py @@ -27,6 +27,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -49,12 +50,16 @@ class ImageFromVolumePayload(BaseModel): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -65,8 +70,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/image_list_response.py b/services/iaas/src/stackit/iaas/models/image_list_response.py index 570ba7c80..41abb08d7 100644 --- a/services/iaas/src/stackit/iaas/models/image_list_response.py +++ b/services/iaas/src/stackit/iaas/models/image_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.image import Image @@ -33,7 +34,8 @@ class ImageListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/image_share.py b/services/iaas/src/stackit/iaas/models/image_share.py index 2430ac04d..56b39875f 100644 --- a/services/iaas/src/stackit/iaas/models/image_share.py +++ b/services/iaas/src/stackit/iaas/models/image_share.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -37,7 +38,8 @@ class ImageShare(BaseModel): __properties: ClassVar[List[str]] = ["parentOrganization", "projects"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/image_share_consumer.py b/services/iaas/src/stackit/iaas/models/image_share_consumer.py index 9b76dd696..a4e08f044 100644 --- a/services/iaas/src/stackit/iaas/models/image_share_consumer.py +++ b/services/iaas/src/stackit/iaas/models/image_share_consumer.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -48,6 +49,9 @@ def consumer_project_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -73,6 +77,9 @@ def image_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -93,7 +100,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -104,8 +112,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/key_pair_list_response.py b/services/iaas/src/stackit/iaas/models/key_pair_list_response.py index 00232a58a..c0d0d8c21 100644 --- a/services/iaas/src/stackit/iaas/models/key_pair_list_response.py +++ b/services/iaas/src/stackit/iaas/models/key_pair_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.keypair import Keypair @@ -33,7 +34,8 @@ class KeyPairListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/keypair.py b/services/iaas/src/stackit/iaas/models/keypair.py index 8803870f9..67921d903 100644 --- a/services/iaas/src/stackit/iaas/models/keypair.py +++ b/services/iaas/src/stackit/iaas/models/keypair.py @@ -21,6 +21,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -70,6 +71,9 @@ def fingerprint_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^([0-9A-Fa-f]{2}[:-]){15}([0-9A-Fa-f]{2})$", value): raise ValueError(r"must validate the regular expression /^([0-9A-Fa-f]{2}[:-]){15}([0-9A-Fa-f]{2})$/") return value @@ -80,6 +84,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9@._-]*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9@._-]*$/") return value @@ -87,6 +94,9 @@ def name_validate_regular_expression(cls, value): @field_validator("public_key") def public_key_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match( r"^(ssh-rsa|ssh-ed25519|ecdsa-sha2-nistp(256|384|521))\s+[A-Za-z0-9+\/]+[=]{0,3}(\s+.+)?\s*$", value ): @@ -109,7 +119,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -120,8 +131,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/machine_type.py b/services/iaas/src/stackit/iaas/models/machine_type.py index 968ac5b93..a21db9727 100644 --- a/services/iaas/src/stackit/iaas/models/machine_type.py +++ b/services/iaas/src/stackit/iaas/models/machine_type.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -47,12 +48,16 @@ class MachineType(BaseModel): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -63,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/machine_type_list_response.py b/services/iaas/src/stackit/iaas/models/machine_type_list_response.py index ba323b336..4f8a7673b 100644 --- a/services/iaas/src/stackit/iaas/models/machine_type_list_response.py +++ b/services/iaas/src/stackit/iaas/models/machine_type_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.machine_type import MachineType @@ -33,7 +34,8 @@ class MachineTypeListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/network.py b/services/iaas/src/stackit/iaas/models/network.py index 33a817fd0..ad56498e3 100644 --- a/services/iaas/src/stackit/iaas/models/network.py +++ b/services/iaas/src/stackit/iaas/models/network.py @@ -29,6 +29,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.network_ipv4 import NetworkIPv4 @@ -94,6 +95,9 @@ def created_at_change_year_zero_to_one(cls, value): @field_validator("id") def id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -106,6 +110,9 @@ def routing_table_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -126,7 +133,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -137,8 +145,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/network_area.py b/services/iaas/src/stackit/iaas/models/network_area.py index 55aff9bd0..a83a5dee0 100644 --- a/services/iaas/src/stackit/iaas/models/network_area.py +++ b/services/iaas/src/stackit/iaas/models/network_area.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -66,6 +67,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -86,7 +90,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -97,8 +102,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/network_area_list_response.py b/services/iaas/src/stackit/iaas/models/network_area_list_response.py index a701d0f1b..f32551e08 100644 --- a/services/iaas/src/stackit/iaas/models/network_area_list_response.py +++ b/services/iaas/src/stackit/iaas/models/network_area_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.network_area import NetworkArea @@ -33,7 +34,8 @@ class NetworkAreaListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/network_ipv4.py b/services/iaas/src/stackit/iaas/models/network_ipv4.py index 1172fc7a3..d3ae80e55 100644 --- a/services/iaas/src/stackit/iaas/models/network_ipv4.py +++ b/services/iaas/src/stackit/iaas/models/network_ipv4.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -47,6 +48,9 @@ def gateway_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match( r"^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$", value, @@ -62,6 +66,9 @@ def public_ip_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match( r"^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$", value, @@ -72,7 +79,8 @@ def public_ip_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -83,8 +91,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/network_ipv6.py b/services/iaas/src/stackit/iaas/models/network_ipv6.py index 59c42932a..7a138a34d 100644 --- a/services/iaas/src/stackit/iaas/models/network_ipv6.py +++ b/services/iaas/src/stackit/iaas/models/network_ipv6.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -44,6 +45,9 @@ def gateway_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match( r"^\s*((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$", value, @@ -54,7 +58,8 @@ def gateway_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -65,8 +70,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/network_list_response.py b/services/iaas/src/stackit/iaas/models/network_list_response.py index ca4d400ff..e2f2c9332 100644 --- a/services/iaas/src/stackit/iaas/models/network_list_response.py +++ b/services/iaas/src/stackit/iaas/models/network_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.network import Network @@ -33,7 +34,8 @@ class NetworkListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/network_range.py b/services/iaas/src/stackit/iaas/models/network_range.py index fbcacefb9..df4281fd9 100644 --- a/services/iaas/src/stackit/iaas/models/network_range.py +++ b/services/iaas/src/stackit/iaas/models/network_range.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -59,6 +60,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -68,6 +72,9 @@ def id_validate_regular_expression(cls, value): @field_validator("prefix") def prefix_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match( r"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/(3[0-2]|2[0-9]|1[0-9]|[0-9]))$|^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))(\/((1(1[0-9]|2[0-8]))|([0-9][0-9])|([0-9])))?$", value, @@ -91,7 +98,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -102,8 +110,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/network_range_list_response.py b/services/iaas/src/stackit/iaas/models/network_range_list_response.py index 4f1ac8bd2..34b774b24 100644 --- a/services/iaas/src/stackit/iaas/models/network_range_list_response.py +++ b/services/iaas/src/stackit/iaas/models/network_range_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.network_range import NetworkRange @@ -35,7 +36,8 @@ class NetworkRangeListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/nexthop_blackhole.py b/services/iaas/src/stackit/iaas/models/nexthop_blackhole.py index 09f51e77f..1dcb48e6f 100644 --- a/services/iaas/src/stackit/iaas/models/nexthop_blackhole.py +++ b/services/iaas/src/stackit/iaas/models/nexthop_blackhole.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class NexthopBlackhole(BaseModel): __properties: ClassVar[List[str]] = ["type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/nexthop_internet.py b/services/iaas/src/stackit/iaas/models/nexthop_internet.py index f06aaf837..17041aa69 100644 --- a/services/iaas/src/stackit/iaas/models/nexthop_internet.py +++ b/services/iaas/src/stackit/iaas/models/nexthop_internet.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class NexthopInternet(BaseModel): __properties: ClassVar[List[str]] = ["type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/nexthop_ipv4.py b/services/iaas/src/stackit/iaas/models/nexthop_ipv4.py index 8f3141dc0..27e84f62f 100644 --- a/services/iaas/src/stackit/iaas/models/nexthop_ipv4.py +++ b/services/iaas/src/stackit/iaas/models/nexthop_ipv4.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -35,6 +36,9 @@ class NexthopIPv4(BaseModel): @field_validator("value") def value_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match( r"^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$", value, @@ -45,7 +49,8 @@ def value_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +61,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/nexthop_ipv6.py b/services/iaas/src/stackit/iaas/models/nexthop_ipv6.py index 9620e8601..a06f452e9 100644 --- a/services/iaas/src/stackit/iaas/models/nexthop_ipv6.py +++ b/services/iaas/src/stackit/iaas/models/nexthop_ipv6.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -35,6 +36,9 @@ class NexthopIPv6(BaseModel): @field_validator("value") def value_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match( r"^\s*((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$", value, @@ -45,7 +49,8 @@ def value_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +61,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/nic.py b/services/iaas/src/stackit/iaas/models/nic.py index 57ca3e9ac..3755753c6 100644 --- a/services/iaas/src/stackit/iaas/models/nic.py +++ b/services/iaas/src/stackit/iaas/models/nic.py @@ -28,6 +28,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.allowed_addresses_inner import AllowedAddressesInner @@ -98,6 +99,9 @@ def device_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -110,6 +114,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -122,6 +129,9 @@ def ipv4_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match( r"((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$)|(^\s*((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$))", value, @@ -137,6 +147,9 @@ def ipv6_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match( r"^\s*((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$", value, @@ -152,6 +165,9 @@ def mac_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$", value): raise ValueError(r"must validate the regular expression /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/") return value @@ -162,6 +178,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value @@ -172,6 +191,9 @@ def network_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -179,7 +201,8 @@ def network_id_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -190,8 +213,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/nic_list_response.py b/services/iaas/src/stackit/iaas/models/nic_list_response.py index 8dbd351e3..dcb9318c5 100644 --- a/services/iaas/src/stackit/iaas/models/nic_list_response.py +++ b/services/iaas/src/stackit/iaas/models/nic_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.nic import NIC @@ -33,7 +34,8 @@ class NICListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/partial_update_network_area_payload.py b/services/iaas/src/stackit/iaas/models/partial_update_network_area_payload.py index 4dc54a62d..506b57225 100644 --- a/services/iaas/src/stackit/iaas/models/partial_update_network_area_payload.py +++ b/services/iaas/src/stackit/iaas/models/partial_update_network_area_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -35,7 +36,8 @@ class PartialUpdateNetworkAreaPayload(BaseModel): __properties: ClassVar[List[str]] = ["labels", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/partial_update_network_payload.py b/services/iaas/src/stackit/iaas/models/partial_update_network_payload.py index eb4348aeb..61d400491 100644 --- a/services/iaas/src/stackit/iaas/models/partial_update_network_payload.py +++ b/services/iaas/src/stackit/iaas/models/partial_update_network_payload.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.update_network_ipv4_body import UpdateNetworkIPv4Body @@ -56,6 +57,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value @@ -66,6 +70,9 @@ def routing_table_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -73,7 +80,8 @@ def routing_table_id_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -84,8 +92,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/port_range.py b/services/iaas/src/stackit/iaas/models/port_range.py index f1efa9ba2..552bbd686 100644 --- a/services/iaas/src/stackit/iaas/models/port_range.py +++ b/services/iaas/src/stackit/iaas/models/port_range.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -36,7 +37,8 @@ class PortRange(BaseModel): __properties: ClassVar[List[str]] = ["max", "min"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/project.py b/services/iaas/src/stackit/iaas/models/project.py index 683203f7e..db247fd95 100644 --- a/services/iaas/src/stackit/iaas/models/project.py +++ b/services/iaas/src/stackit/iaas/models/project.py @@ -29,6 +29,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.area_id import AreaId @@ -69,6 +70,9 @@ def created_at_change_year_zero_to_one(cls, value): @field_validator("id") def id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -89,7 +93,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -100,8 +105,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/project_list_response.py b/services/iaas/src/stackit/iaas/models/project_list_response.py index de132683e..7a1fe6e29 100644 --- a/services/iaas/src/stackit/iaas/models/project_list_response.py +++ b/services/iaas/src/stackit/iaas/models/project_list_response.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class ProjectListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/protocol.py b/services/iaas/src/stackit/iaas/models/protocol.py index 514baead9..dd861238a 100644 --- a/services/iaas/src/stackit/iaas/models/protocol.py +++ b/services/iaas/src/stackit/iaas/models/protocol.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -37,7 +38,8 @@ class Protocol(BaseModel): __properties: ClassVar[List[str]] = ["name", "number"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/public_ip.py b/services/iaas/src/stackit/iaas/models/public_ip.py index 40c124e78..f08630dd1 100644 --- a/services/iaas/src/stackit/iaas/models/public_ip.py +++ b/services/iaas/src/stackit/iaas/models/public_ip.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -48,6 +49,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -60,6 +64,9 @@ def ip_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match( r"^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$", value, @@ -75,6 +82,9 @@ def network_interface_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -82,7 +92,8 @@ def network_interface_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -93,8 +104,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/public_ip_list_response.py b/services/iaas/src/stackit/iaas/models/public_ip_list_response.py index d3f5f6ded..3f2d42f58 100644 --- a/services/iaas/src/stackit/iaas/models/public_ip_list_response.py +++ b/services/iaas/src/stackit/iaas/models/public_ip_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.public_ip import PublicIp @@ -33,7 +34,8 @@ class PublicIpListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/public_network.py b/services/iaas/src/stackit/iaas/models/public_network.py index bde2cd771..2dfcb03c8 100644 --- a/services/iaas/src/stackit/iaas/models/public_network.py +++ b/services/iaas/src/stackit/iaas/models/public_network.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -35,6 +36,9 @@ class PublicNetwork(BaseModel): @field_validator("cidr") def cidr_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match( r"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/(3[0-2]|2[0-9]|1[0-9]|[0-9]))$|^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))(\/((1(1[0-9]|2[0-8]))|([0-9][0-9])|([0-9])))?$", value, @@ -45,7 +49,8 @@ def cidr_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +61,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/public_network_list_response.py b/services/iaas/src/stackit/iaas/models/public_network_list_response.py index 55a607c2f..53db0326f 100644 --- a/services/iaas/src/stackit/iaas/models/public_network_list_response.py +++ b/services/iaas/src/stackit/iaas/models/public_network_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.public_network import PublicNetwork @@ -33,7 +34,8 @@ class PublicNetworkListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/quota.py b/services/iaas/src/stackit/iaas/models/quota.py index 2c264d8fe..0b7ea474e 100644 --- a/services/iaas/src/stackit/iaas/models/quota.py +++ b/services/iaas/src/stackit/iaas/models/quota.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class Quota(BaseModel): __properties: ClassVar[List[str]] = ["limit", "usage"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/quota_list.py b/services/iaas/src/stackit/iaas/models/quota_list.py index c5886debe..257e9bf51 100644 --- a/services/iaas/src/stackit/iaas/models/quota_list.py +++ b/services/iaas/src/stackit/iaas/models/quota_list.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.quota import Quota @@ -57,7 +58,8 @@ class QuotaList(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -68,8 +70,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/quota_list_response.py b/services/iaas/src/stackit/iaas/models/quota_list_response.py index 436c39a40..579d9404a 100644 --- a/services/iaas/src/stackit/iaas/models/quota_list_response.py +++ b/services/iaas/src/stackit/iaas/models/quota_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.quota_list import QuotaList @@ -33,7 +34,8 @@ class QuotaListResponse(BaseModel): __properties: ClassVar[List[str]] = ["quotas"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/regional_area.py b/services/iaas/src/stackit/iaas/models/regional_area.py index d7bcb328b..6894275ac 100644 --- a/services/iaas/src/stackit/iaas/models/regional_area.py +++ b/services/iaas/src/stackit/iaas/models/regional_area.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.regional_area_ipv4 import RegionalAreaIPv4 @@ -37,7 +38,8 @@ class RegionalArea(BaseModel): __properties: ClassVar[List[str]] = ["ipv4", "status"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/regional_area_ipv4.py b/services/iaas/src/stackit/iaas/models/regional_area_ipv4.py index ca837d127..2a4538ce0 100644 --- a/services/iaas/src/stackit/iaas/models/regional_area_ipv4.py +++ b/services/iaas/src/stackit/iaas/models/regional_area_ipv4.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.network_range import NetworkRange @@ -60,6 +61,9 @@ class RegionalAreaIPv4(BaseModel): @field_validator("transfer_network") def transfer_network_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match( r"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/(3[0-2]|2[0-9]|1[0-9]|[0-9]))$", value, @@ -70,7 +74,8 @@ def transfer_network_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -81,8 +86,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/regional_area_list_response.py b/services/iaas/src/stackit/iaas/models/regional_area_list_response.py index b758a3123..40627c180 100644 --- a/services/iaas/src/stackit/iaas/models/regional_area_list_response.py +++ b/services/iaas/src/stackit/iaas/models/regional_area_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.regional_area import RegionalArea @@ -33,7 +34,8 @@ class RegionalAreaListResponse(BaseModel): __properties: ClassVar[List[str]] = ["regions"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/request.py b/services/iaas/src/stackit/iaas/models/request.py index 500c67c20..ac6d2f911 100644 --- a/services/iaas/src/stackit/iaas/models/request.py +++ b/services/iaas/src/stackit/iaas/models/request.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.request_resource import RequestResource @@ -51,12 +52,16 @@ class Request(BaseModel): @field_validator("request_id") def request_id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^req-[0-9a-f]{32}$", value): raise ValueError(r"must validate the regular expression /^req-[0-9a-f]{32}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -67,8 +72,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/request_resource.py b/services/iaas/src/stackit/iaas/models/request_resource.py index cb77ffade..ffbe144d8 100644 --- a/services/iaas/src/stackit/iaas/models/request_resource.py +++ b/services/iaas/src/stackit/iaas/models/request_resource.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -41,6 +42,9 @@ class RequestResource(BaseModel): @field_validator("id") def id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -48,7 +52,8 @@ def id_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -59,8 +64,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/rescue_server_payload.py b/services/iaas/src/stackit/iaas/models/rescue_server_payload.py index 8f16fea79..54c7f8b8e 100644 --- a/services/iaas/src/stackit/iaas/models/rescue_server_payload.py +++ b/services/iaas/src/stackit/iaas/models/rescue_server_payload.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -35,6 +36,9 @@ class RescueServerPayload(BaseModel): @field_validator("image") def image_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -42,7 +46,8 @@ def image_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +58,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/resize_server_payload.py b/services/iaas/src/stackit/iaas/models/resize_server_payload.py index 1e1e08501..2bbd0335d 100644 --- a/services/iaas/src/stackit/iaas/models/resize_server_payload.py +++ b/services/iaas/src/stackit/iaas/models/resize_server_payload.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -36,12 +37,16 @@ class ResizeServerPayload(BaseModel): @field_validator("machine_type") def machine_type_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -52,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/resize_volume_payload.py b/services/iaas/src/stackit/iaas/models/resize_volume_payload.py index d84f9d611..daf5e6f73 100644 --- a/services/iaas/src/stackit/iaas/models/resize_volume_payload.py +++ b/services/iaas/src/stackit/iaas/models/resize_volume_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class ResizeVolumePayload(BaseModel): __properties: ClassVar[List[str]] = ["size"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/route.py b/services/iaas/src/stackit/iaas/models/route.py index c568d2199..095d0762e 100644 --- a/services/iaas/src/stackit/iaas/models/route.py +++ b/services/iaas/src/stackit/iaas/models/route.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.route_destination import RouteDestination @@ -67,6 +68,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -87,7 +91,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -98,8 +103,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/route_list_response.py b/services/iaas/src/stackit/iaas/models/route_list_response.py index 9839e9ae7..55754f7d9 100644 --- a/services/iaas/src/stackit/iaas/models/route_list_response.py +++ b/services/iaas/src/stackit/iaas/models/route_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.route import Route @@ -33,7 +34,8 @@ class RouteListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/routing_table.py b/services/iaas/src/stackit/iaas/models/routing_table.py index 8f3783c31..a9ad199e0 100644 --- a/services/iaas/src/stackit/iaas/models/routing_table.py +++ b/services/iaas/src/stackit/iaas/models/routing_table.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -92,6 +93,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -101,6 +105,9 @@ def id_validate_regular_expression(cls, value): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value @@ -119,7 +126,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -130,8 +138,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/routing_table_list_response.py b/services/iaas/src/stackit/iaas/models/routing_table_list_response.py index af3e0830d..df8a32a2e 100644 --- a/services/iaas/src/stackit/iaas/models/routing_table_list_response.py +++ b/services/iaas/src/stackit/iaas/models/routing_table_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.routing_table import RoutingTable @@ -33,7 +34,8 @@ class RoutingTableListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/security_group.py b/services/iaas/src/stackit/iaas/models/security_group.py index de476eb61..7ce7103f9 100644 --- a/services/iaas/src/stackit/iaas/models/security_group.py +++ b/services/iaas/src/stackit/iaas/models/security_group.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.security_group_rule import SecurityGroupRule @@ -86,6 +87,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -95,6 +99,9 @@ def id_validate_regular_expression(cls, value): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value @@ -113,7 +120,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -124,8 +132,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/security_group_list_response.py b/services/iaas/src/stackit/iaas/models/security_group_list_response.py index d35b6696c..1a1858906 100644 --- a/services/iaas/src/stackit/iaas/models/security_group_list_response.py +++ b/services/iaas/src/stackit/iaas/models/security_group_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.security_group import SecurityGroup @@ -33,7 +34,8 @@ class SecurityGroupListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/security_group_rule.py b/services/iaas/src/stackit/iaas/models/security_group_rule.py index 8e4c7e98b..667c07dee 100644 --- a/services/iaas/src/stackit/iaas/models/security_group_rule.py +++ b/services/iaas/src/stackit/iaas/models/security_group_rule.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.icmp_parameters import ICMPParameters @@ -98,6 +99,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -110,6 +114,9 @@ def ip_range_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match( r"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/(3[0-2]|2[0-9]|1[0-9]|[0-9]))$|^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))(\/((1(1[0-9]|2[0-8]))|([0-9][0-9])|([0-9])))?$", value, @@ -125,6 +132,9 @@ def remote_security_group_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -137,6 +147,9 @@ def security_group_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -157,7 +170,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -168,8 +182,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/security_group_rule_list_response.py b/services/iaas/src/stackit/iaas/models/security_group_rule_list_response.py index bd8efb409..d2751a305 100644 --- a/services/iaas/src/stackit/iaas/models/security_group_rule_list_response.py +++ b/services/iaas/src/stackit/iaas/models/security_group_rule_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.security_group_rule import SecurityGroupRule @@ -33,7 +34,8 @@ class SecurityGroupRuleListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/security_group_rule_protocol.py b/services/iaas/src/stackit/iaas/models/security_group_rule_protocol.py index 490dbed2a..d7cbbc886 100644 --- a/services/iaas/src/stackit/iaas/models/security_group_rule_protocol.py +++ b/services/iaas/src/stackit/iaas/models/security_group_rule_protocol.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.protocol import Protocol @@ -33,7 +34,8 @@ class SecurityGroupRuleProtocol(BaseModel): __properties: ClassVar[List[str]] = ["protocol"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/server.py b/services/iaas/src/stackit/iaas/models/server.py index c12225aff..59460c8e1 100644 --- a/services/iaas/src/stackit/iaas/models/server.py +++ b/services/iaas/src/stackit/iaas/models/server.py @@ -30,6 +30,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.boot_volume import BootVolume @@ -149,6 +150,9 @@ def affinity_group_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -174,6 +178,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -186,6 +193,9 @@ def image_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -198,6 +208,9 @@ def keypair_name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9@._-]*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9@._-]*$/") return value @@ -218,6 +231,9 @@ def launched_at_change_year_zero_to_one(cls, value): @field_validator("machine_type") def machine_type_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value @@ -225,6 +241,9 @@ def machine_type_validate_regular_expression(cls, value): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match( r"^(([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$", value, @@ -248,7 +267,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -259,8 +279,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/server_agent.py b/services/iaas/src/stackit/iaas/models/server_agent.py index cdcc227c2..60db78560 100644 --- a/services/iaas/src/stackit/iaas/models/server_agent.py +++ b/services/iaas/src/stackit/iaas/models/server_agent.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class ServerAgent(BaseModel): __properties: ClassVar[List[str]] = ["provisioned"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/server_console_url.py b/services/iaas/src/stackit/iaas/models/server_console_url.py index ccef234e3..2cd3817de 100644 --- a/services/iaas/src/stackit/iaas/models/server_console_url.py +++ b/services/iaas/src/stackit/iaas/models/server_console_url.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class ServerConsoleUrl(BaseModel): __properties: ClassVar[List[str]] = ["url"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/server_list_response.py b/services/iaas/src/stackit/iaas/models/server_list_response.py index c2feae769..26c4f38a1 100644 --- a/services/iaas/src/stackit/iaas/models/server_list_response.py +++ b/services/iaas/src/stackit/iaas/models/server_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.server import Server @@ -33,7 +34,8 @@ class ServerListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/server_maintenance.py b/services/iaas/src/stackit/iaas/models/server_maintenance.py index a3053f019..555191a52 100644 --- a/services/iaas/src/stackit/iaas/models/server_maintenance.py +++ b/services/iaas/src/stackit/iaas/models/server_maintenance.py @@ -21,6 +21,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -62,7 +63,8 @@ def starts_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -73,8 +75,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/server_network.py b/services/iaas/src/stackit/iaas/models/server_network.py index 8da6dcaad..7c7efcf12 100644 --- a/services/iaas/src/stackit/iaas/models/server_network.py +++ b/services/iaas/src/stackit/iaas/models/server_network.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.allowed_addresses_inner import AllowedAddressesInner @@ -73,6 +74,9 @@ def ipv4_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match( r"((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$)|(^\s*((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$))", value, @@ -88,6 +92,9 @@ def ipv6_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match( r"^\s*((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$", value, @@ -100,6 +107,9 @@ def ipv6_validate_regular_expression(cls, value): @field_validator("mac") def mac_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$", value): raise ValueError(r"must validate the regular expression /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/") return value @@ -107,6 +117,9 @@ def mac_validate_regular_expression(cls, value): @field_validator("network_id") def network_id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -116,6 +129,9 @@ def network_id_validate_regular_expression(cls, value): @field_validator("network_name") def network_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value @@ -123,6 +139,9 @@ def network_name_validate_regular_expression(cls, value): @field_validator("nic_id") def nic_id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -135,6 +154,9 @@ def public_ip_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match( r"((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$)|(^\s*((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$))", value, @@ -145,7 +167,8 @@ def public_ip_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -156,8 +179,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/service_account_mail_list_response.py b/services/iaas/src/stackit/iaas/models/service_account_mail_list_response.py index da3da9092..f55637cc7 100644 --- a/services/iaas/src/stackit/iaas/models/service_account_mail_list_response.py +++ b/services/iaas/src/stackit/iaas/models/service_account_mail_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,7 +34,8 @@ class ServiceAccountMailListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/set_image_share_payload.py b/services/iaas/src/stackit/iaas/models/set_image_share_payload.py index 980a75545..8b867be7a 100644 --- a/services/iaas/src/stackit/iaas/models/set_image_share_payload.py +++ b/services/iaas/src/stackit/iaas/models/set_image_share_payload.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -37,7 +38,8 @@ class SetImageSharePayload(BaseModel): __properties: ClassVar[List[str]] = ["parentOrganization", "projects"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/snapshot.py b/services/iaas/src/stackit/iaas/models/snapshot.py index cbe25b3cd..d30d9549d 100644 --- a/services/iaas/src/stackit/iaas/models/snapshot.py +++ b/services/iaas/src/stackit/iaas/models/snapshot.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -84,6 +85,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -96,6 +100,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value @@ -116,6 +123,9 @@ def updated_at_change_year_zero_to_one(cls, value): @field_validator("volume_id") def volume_id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -123,7 +133,8 @@ def volume_id_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -134,8 +145,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/snapshot_list_response.py b/services/iaas/src/stackit/iaas/models/snapshot_list_response.py index e7383e599..e3dcabc9b 100644 --- a/services/iaas/src/stackit/iaas/models/snapshot_list_response.py +++ b/services/iaas/src/stackit/iaas/models/snapshot_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.snapshot import Snapshot @@ -33,7 +34,8 @@ class SnapshotListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/update_attached_volume_payload.py b/services/iaas/src/stackit/iaas/models/update_attached_volume_payload.py index 53c7d34b9..4563f223d 100644 --- a/services/iaas/src/stackit/iaas/models/update_attached_volume_payload.py +++ b/services/iaas/src/stackit/iaas/models/update_attached_volume_payload.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -48,6 +49,9 @@ def server_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -60,6 +64,9 @@ def volume_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -67,7 +74,8 @@ def volume_id_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -78,8 +86,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/update_backup_payload.py b/services/iaas/src/stackit/iaas/models/update_backup_payload.py index 34df41e31..714d04e81 100644 --- a/services/iaas/src/stackit/iaas/models/update_backup_payload.py +++ b/services/iaas/src/stackit/iaas/models/update_backup_payload.py @@ -30,6 +30,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -104,6 +105,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -116,6 +120,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value @@ -126,6 +133,9 @@ def snapshot_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -151,6 +161,9 @@ def volume_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -158,7 +171,8 @@ def volume_id_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -169,8 +183,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/update_image_payload.py b/services/iaas/src/stackit/iaas/models/update_image_payload.py index 607d50aee..627220aff 100644 --- a/services/iaas/src/stackit/iaas/models/update_image_payload.py +++ b/services/iaas/src/stackit/iaas/models/update_image_payload.py @@ -28,6 +28,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.image_agent import ImageAgent @@ -75,12 +76,16 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -91,8 +96,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/update_image_share_payload.py b/services/iaas/src/stackit/iaas/models/update_image_share_payload.py index a353e8492..ea68b11a3 100644 --- a/services/iaas/src/stackit/iaas/models/update_image_share_payload.py +++ b/services/iaas/src/stackit/iaas/models/update_image_share_payload.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -37,7 +38,8 @@ class UpdateImageSharePayload(BaseModel): __properties: ClassVar[List[str]] = ["parentOrganization", "projects"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/update_key_pair_payload.py b/services/iaas/src/stackit/iaas/models/update_key_pair_payload.py index 5062c877f..e103ea346 100644 --- a/services/iaas/src/stackit/iaas/models/update_key_pair_payload.py +++ b/services/iaas/src/stackit/iaas/models/update_key_pair_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class UpdateKeyPairPayload(BaseModel): __properties: ClassVar[List[str]] = ["labels"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/update_network_area_region_payload.py b/services/iaas/src/stackit/iaas/models/update_network_area_region_payload.py index 8e6a80a94..5744ef2fe 100644 --- a/services/iaas/src/stackit/iaas/models/update_network_area_region_payload.py +++ b/services/iaas/src/stackit/iaas/models/update_network_area_region_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.update_regional_area_ipv4 import UpdateRegionalAreaIPv4 @@ -33,7 +34,8 @@ class UpdateNetworkAreaRegionPayload(BaseModel): __properties: ClassVar[List[str]] = ["ipv4"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/update_network_area_route_payload.py b/services/iaas/src/stackit/iaas/models/update_network_area_route_payload.py index ba7e441f5..943d4a4a0 100644 --- a/services/iaas/src/stackit/iaas/models/update_network_area_route_payload.py +++ b/services/iaas/src/stackit/iaas/models/update_network_area_route_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class UpdateNetworkAreaRoutePayload(BaseModel): __properties: ClassVar[List[str]] = ["labels"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/update_network_ipv4_body.py b/services/iaas/src/stackit/iaas/models/update_network_ipv4_body.py index 8dd5a6b90..871ee4531 100644 --- a/services/iaas/src/stackit/iaas/models/update_network_ipv4_body.py +++ b/services/iaas/src/stackit/iaas/models/update_network_ipv4_body.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -43,6 +44,9 @@ def gateway_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match( r"^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$", value, @@ -53,7 +57,8 @@ def gateway_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -64,8 +69,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/update_network_ipv6_body.py b/services/iaas/src/stackit/iaas/models/update_network_ipv6_body.py index dc792d17b..e5b358488 100644 --- a/services/iaas/src/stackit/iaas/models/update_network_ipv6_body.py +++ b/services/iaas/src/stackit/iaas/models/update_network_ipv6_body.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -43,6 +44,9 @@ def gateway_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match( r"^\s*((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$", value, @@ -53,7 +57,8 @@ def gateway_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -64,8 +69,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/update_nic_payload.py b/services/iaas/src/stackit/iaas/models/update_nic_payload.py index b8b42e824..dcfc7c9c1 100644 --- a/services/iaas/src/stackit/iaas/models/update_nic_payload.py +++ b/services/iaas/src/stackit/iaas/models/update_nic_payload.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.allowed_addresses_inner import AllowedAddressesInner @@ -65,12 +66,16 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -81,8 +86,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/update_public_ip_payload.py b/services/iaas/src/stackit/iaas/models/update_public_ip_payload.py index 7477dff48..9ec582a86 100644 --- a/services/iaas/src/stackit/iaas/models/update_public_ip_payload.py +++ b/services/iaas/src/stackit/iaas/models/update_public_ip_payload.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -48,6 +49,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -60,6 +64,9 @@ def ip_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match( r"^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$", value, @@ -75,6 +82,9 @@ def network_interface_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -82,7 +92,8 @@ def network_interface_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -93,8 +104,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/update_regional_area_ipv4.py b/services/iaas/src/stackit/iaas/models/update_regional_area_ipv4.py index e996001ad..c1fa5e036 100644 --- a/services/iaas/src/stackit/iaas/models/update_regional_area_ipv4.py +++ b/services/iaas/src/stackit/iaas/models/update_regional_area_ipv4.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -44,7 +45,8 @@ class UpdateRegionalAreaIPv4(BaseModel): __properties: ClassVar[List[str]] = ["defaultNameservers", "defaultPrefixLen", "maxPrefixLen", "minPrefixLen"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/update_route_of_routing_table_payload.py b/services/iaas/src/stackit/iaas/models/update_route_of_routing_table_payload.py index 71dc199c1..bbc5340a2 100644 --- a/services/iaas/src/stackit/iaas/models/update_route_of_routing_table_payload.py +++ b/services/iaas/src/stackit/iaas/models/update_route_of_routing_table_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class UpdateRouteOfRoutingTablePayload(BaseModel): __properties: ClassVar[List[str]] = ["labels"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/update_routing_table_of_area_payload.py b/services/iaas/src/stackit/iaas/models/update_routing_table_of_area_payload.py index 8818acd25..01215dd0e 100644 --- a/services/iaas/src/stackit/iaas/models/update_routing_table_of_area_payload.py +++ b/services/iaas/src/stackit/iaas/models/update_routing_table_of_area_payload.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -56,12 +57,16 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -72,8 +77,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/update_security_group_payload.py b/services/iaas/src/stackit/iaas/models/update_security_group_payload.py index 6bcf8cf73..4b0aed59c 100644 --- a/services/iaas/src/stackit/iaas/models/update_security_group_payload.py +++ b/services/iaas/src/stackit/iaas/models/update_security_group_payload.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -46,12 +47,16 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -62,8 +67,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/update_server_payload.py b/services/iaas/src/stackit/iaas/models/update_server_payload.py index 4f71b3def..9a2874f66 100644 --- a/services/iaas/src/stackit/iaas/models/update_server_payload.py +++ b/services/iaas/src/stackit/iaas/models/update_server_payload.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -47,6 +48,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match( r"^(([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$", value, @@ -57,7 +61,8 @@ def name_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -68,8 +73,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/update_snapshot_payload.py b/services/iaas/src/stackit/iaas/models/update_snapshot_payload.py index 75a34bb5e..e5cafbc9b 100644 --- a/services/iaas/src/stackit/iaas/models/update_snapshot_payload.py +++ b/services/iaas/src/stackit/iaas/models/update_snapshot_payload.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -46,12 +47,16 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -62,8 +67,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/update_volume_payload.py b/services/iaas/src/stackit/iaas/models/update_volume_payload.py index 449698bdb..7a7854a06 100644 --- a/services/iaas/src/stackit/iaas/models/update_volume_payload.py +++ b/services/iaas/src/stackit/iaas/models/update_volume_payload.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.image_config import ImageConfig @@ -50,12 +51,16 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -66,8 +71,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/volume.py b/services/iaas/src/stackit/iaas/models/volume.py index 42e00ecc2..f6f660a72 100644 --- a/services/iaas/src/stackit/iaas/models/volume.py +++ b/services/iaas/src/stackit/iaas/models/volume.py @@ -30,6 +30,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.iaas.models.image_config import ImageConfig @@ -118,6 +119,9 @@ def id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -130,6 +134,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value @@ -140,6 +147,9 @@ def performance_class_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value @@ -150,6 +160,9 @@ def server_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -170,7 +183,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -181,8 +195,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/volume_attachment.py b/services/iaas/src/stackit/iaas/models/volume_attachment.py index ba0311056..16fc31c1f 100644 --- a/services/iaas/src/stackit/iaas/models/volume_attachment.py +++ b/services/iaas/src/stackit/iaas/models/volume_attachment.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -48,6 +49,9 @@ def server_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -60,6 +64,9 @@ def volume_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -67,7 +74,8 @@ def volume_id_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -78,8 +86,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/volume_attachment_list_response.py b/services/iaas/src/stackit/iaas/models/volume_attachment_list_response.py index 7390b9811..b1c12b7d2 100644 --- a/services/iaas/src/stackit/iaas/models/volume_attachment_list_response.py +++ b/services/iaas/src/stackit/iaas/models/volume_attachment_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.volume_attachment import VolumeAttachment @@ -33,7 +34,8 @@ class VolumeAttachmentListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/volume_encryption_parameter.py b/services/iaas/src/stackit/iaas/models/volume_encryption_parameter.py index 1714f5317..4af7a2cb2 100644 --- a/services/iaas/src/stackit/iaas/models/volume_encryption_parameter.py +++ b/services/iaas/src/stackit/iaas/models/volume_encryption_parameter.py @@ -29,6 +29,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -71,6 +72,9 @@ class VolumeEncryptionParameter(BaseModel): @field_validator("kek_key_id") def kek_key_id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -80,6 +84,9 @@ def kek_key_id_validate_regular_expression(cls, value): @field_validator("kek_keyring_id") def kek_keyring_id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -92,6 +99,9 @@ def kek_project_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -101,6 +111,9 @@ def kek_project_id_validate_regular_expression(cls, value): @field_validator("service_account") def service_account_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match( r"[a-z0-9-]+(?:\.[a-z0-9]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", value ): @@ -110,7 +123,8 @@ def service_account_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -121,8 +135,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/volume_list_response.py b/services/iaas/src/stackit/iaas/models/volume_list_response.py index 40d54e04c..d2f16a5e4 100644 --- a/services/iaas/src/stackit/iaas/models/volume_list_response.py +++ b/services/iaas/src/stackit/iaas/models/volume_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.volume import Volume @@ -33,7 +34,8 @@ class VolumeListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/volume_performance_class.py b/services/iaas/src/stackit/iaas/models/volume_performance_class.py index 243abf70e..535bca85d 100644 --- a/services/iaas/src/stackit/iaas/models/volume_performance_class.py +++ b/services/iaas/src/stackit/iaas/models/volume_performance_class.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -45,12 +46,16 @@ class VolumePerformanceClass(BaseModel): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[A-Za-z0-9]+([ \/._-]*[A-Za-z0-9]+)*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -61,8 +66,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/volume_performance_class_list_response.py b/services/iaas/src/stackit/iaas/models/volume_performance_class_list_response.py index b6257d398..d458b0127 100644 --- a/services/iaas/src/stackit/iaas/models/volume_performance_class_list_response.py +++ b/services/iaas/src/stackit/iaas/models/volume_performance_class_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.iaas.models.volume_performance_class import VolumePerformanceClass @@ -33,7 +34,8 @@ class VolumePerformanceClassListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/iaas/src/stackit/iaas/models/volume_source.py b/services/iaas/src/stackit/iaas/models/volume_source.py index 3495ed061..4f778fd45 100644 --- a/services/iaas/src/stackit/iaas/models/volume_source.py +++ b/services/iaas/src/stackit/iaas/models/volume_source.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -38,6 +39,9 @@ class VolumeSource(BaseModel): @field_validator("id") def id_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/" @@ -45,7 +49,8 @@ def id_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +61,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/intake/CHANGELOG.md b/services/intake/CHANGELOG.md index 059c76c2e..1c7c45e6e 100644 --- a/services/intake/CHANGELOG.md +++ b/services/intake/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.6.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.5.1 - **Feature:** client now supports UUID and decimal types - **Bugfix:** timeouts now passed to requests library diff --git a/services/intake/pyproject.toml b/services/intake/pyproject.toml index 624acf027..681553f41 100644 --- a/services/intake/pyproject.toml +++ b/services/intake/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-intake" -version = "v0.5.1" +version = "v0.6.0" description = "STACKIT Intake API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4" diff --git a/services/intake/src/stackit/intake/api_client.py b/services/intake/src/stackit/intake/api_client.py index 2a04a4a68..463e7519d 100644 --- a/services/intake/src/stackit/intake/api_client.py +++ b/services/intake/src/stackit/intake/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/intake/src/stackit/intake/models/catalog_auth.py b/services/intake/src/stackit/intake/models/catalog_auth.py index bfbe1bb8d..ede58decc 100644 --- a/services/intake/src/stackit/intake/models/catalog_auth.py +++ b/services/intake/src/stackit/intake/models/catalog_auth.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.intake.models.catalog_auth_type import CatalogAuthType @@ -34,7 +35,8 @@ class CatalogAuth(BaseModel): __properties: ClassVar[List[str]] = ["dremio", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/intake/src/stackit/intake/models/catalog_auth_patch.py b/services/intake/src/stackit/intake/models/catalog_auth_patch.py index fdd532f68..c05883ab4 100644 --- a/services/intake/src/stackit/intake/models/catalog_auth_patch.py +++ b/services/intake/src/stackit/intake/models/catalog_auth_patch.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.intake.models.catalog_auth_type import CatalogAuthType @@ -34,7 +35,8 @@ class CatalogAuthPatch(BaseModel): __properties: ClassVar[List[str]] = ["dremio", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/intake/src/stackit/intake/models/client_config.py b/services/intake/src/stackit/intake/models/client_config.py index 08d4cef1d..df038a0c0 100644 --- a/services/intake/src/stackit/intake/models/client_config.py +++ b/services/intake/src/stackit/intake/models/client_config.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class ClientConfig(BaseModel): __properties: ClassVar[List[str]] = ["java", "librdkafka"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/intake/src/stackit/intake/models/create_intake_payload.py b/services/intake/src/stackit/intake/models/create_intake_payload.py index a8a7e57e8..8daeebd4b 100644 --- a/services/intake/src/stackit/intake/models/create_intake_payload.py +++ b/services/intake/src/stackit/intake/models/create_intake_payload.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.intake.models.intake_catalog import IntakeCatalog @@ -49,12 +50,16 @@ class CreateIntakePayload(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[\p{L}\p{N} -]{1,32}$", value): raise ValueError(r"must validate the regular expression /^[\p{L}\p{N} -]{1,32}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -65,8 +70,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/intake/src/stackit/intake/models/create_intake_runner_payload.py b/services/intake/src/stackit/intake/models/create_intake_runner_payload.py index e2b021eb2..f0403aaba 100644 --- a/services/intake/src/stackit/intake/models/create_intake_runner_payload.py +++ b/services/intake/src/stackit/intake/models/create_intake_runner_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -54,12 +55,16 @@ class CreateIntakeRunnerPayload(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[\p{L}\p{N} -]{1,32}$", value): raise ValueError(r"must validate the regular expression /^[\p{L}\p{N} -]{1,32}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -70,8 +75,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/intake/src/stackit/intake/models/create_intake_user_payload.py b/services/intake/src/stackit/intake/models/create_intake_user_payload.py index 9388cdafd..a264e952c 100644 --- a/services/intake/src/stackit/intake/models/create_intake_user_payload.py +++ b/services/intake/src/stackit/intake/models/create_intake_user_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.intake.models.user_type import UserType @@ -48,12 +49,16 @@ class CreateIntakeUserPayload(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[\p{L}\p{N} -]{1,32}$", value): raise ValueError(r"must validate the regular expression /^[\p{L}\p{N} -]{1,32}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -64,8 +69,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/intake/src/stackit/intake/models/dremio_auth.py b/services/intake/src/stackit/intake/models/dremio_auth.py index f5e7046f7..072a68355 100644 --- a/services/intake/src/stackit/intake/models/dremio_auth.py +++ b/services/intake/src/stackit/intake/models/dremio_auth.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -35,7 +36,8 @@ class DremioAuth(BaseModel): __properties: ClassVar[List[str]] = ["personalAccessToken", "tokenEndpoint"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/intake/src/stackit/intake/models/dremio_auth_patch.py b/services/intake/src/stackit/intake/models/dremio_auth_patch.py index 2b520e7eb..2f512f1b0 100644 --- a/services/intake/src/stackit/intake/models/dremio_auth_patch.py +++ b/services/intake/src/stackit/intake/models/dremio_auth_patch.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -35,7 +36,8 @@ class DremioAuthPatch(BaseModel): __properties: ClassVar[List[str]] = ["personalAccessToken", "tokenEndpoint"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/intake/src/stackit/intake/models/intake_catalog.py b/services/intake/src/stackit/intake/models/intake_catalog.py index 96fd14b7b..ee9ccdfbc 100644 --- a/services/intake/src/stackit/intake/models/intake_catalog.py +++ b/services/intake/src/stackit/intake/models/intake_catalog.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.intake.models.catalog_auth import CatalogAuth @@ -62,7 +63,8 @@ class IntakeCatalog(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -73,8 +75,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/intake/src/stackit/intake/models/intake_catalog_patch.py b/services/intake/src/stackit/intake/models/intake_catalog_patch.py index 7d273172a..8047b9360 100644 --- a/services/intake/src/stackit/intake/models/intake_catalog_patch.py +++ b/services/intake/src/stackit/intake/models/intake_catalog_patch.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.intake.models.catalog_auth_patch import CatalogAuthPatch @@ -63,7 +64,8 @@ class IntakeCatalogPatch(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -74,8 +76,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/intake/src/stackit/intake/models/intake_response.py b/services/intake/src/stackit/intake/models/intake_response.py index bef138d14..47f249f93 100644 --- a/services/intake/src/stackit/intake/models/intake_response.py +++ b/services/intake/src/stackit/intake/models/intake_response.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.intake.models.intake_catalog import IntakeCatalog @@ -98,7 +99,8 @@ def state_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -109,8 +111,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/intake/src/stackit/intake/models/intake_runner_response.py b/services/intake/src/stackit/intake/models/intake_runner_response.py index 7e9d45f50..b5092feda 100644 --- a/services/intake/src/stackit/intake/models/intake_runner_response.py +++ b/services/intake/src/stackit/intake/models/intake_runner_response.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -82,7 +83,8 @@ def state_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -93,8 +95,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/intake/src/stackit/intake/models/intake_user_response.py b/services/intake/src/stackit/intake/models/intake_user_response.py index e595709be..5a12f4ec8 100644 --- a/services/intake/src/stackit/intake/models/intake_user_response.py +++ b/services/intake/src/stackit/intake/models/intake_user_response.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.intake.models.client_config import ClientConfig @@ -81,7 +82,8 @@ def state_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -92,8 +94,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/intake/src/stackit/intake/models/list_intake_runners_response.py b/services/intake/src/stackit/intake/models/list_intake_runners_response.py index 49dd93e14..122780e76 100644 --- a/services/intake/src/stackit/intake/models/list_intake_runners_response.py +++ b/services/intake/src/stackit/intake/models/list_intake_runners_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.intake.models.intake_runner_response import IntakeRunnerResponse @@ -35,7 +36,8 @@ class ListIntakeRunnersResponse(BaseModel): __properties: ClassVar[List[str]] = ["intakeRunners", "nextPageToken"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/intake/src/stackit/intake/models/list_intake_users_response.py b/services/intake/src/stackit/intake/models/list_intake_users_response.py index 016e5962c..beb8107f8 100644 --- a/services/intake/src/stackit/intake/models/list_intake_users_response.py +++ b/services/intake/src/stackit/intake/models/list_intake_users_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.intake.models.intake_user_response import IntakeUserResponse @@ -35,7 +36,8 @@ class ListIntakeUsersResponse(BaseModel): __properties: ClassVar[List[str]] = ["intakeUsers", "nextPageToken"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/intake/src/stackit/intake/models/list_intakes_response.py b/services/intake/src/stackit/intake/models/list_intakes_response.py index 03c5040da..f9e7d5cd1 100644 --- a/services/intake/src/stackit/intake/models/list_intakes_response.py +++ b/services/intake/src/stackit/intake/models/list_intakes_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.intake.models.intake_response import IntakeResponse @@ -35,7 +36,8 @@ class ListIntakesResponse(BaseModel): __properties: ClassVar[List[str]] = ["intakes", "nextPageToken"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/intake/src/stackit/intake/models/update_intake_payload.py b/services/intake/src/stackit/intake/models/update_intake_payload.py index 16eea58a2..534fd53f5 100644 --- a/services/intake/src/stackit/intake/models/update_intake_payload.py +++ b/services/intake/src/stackit/intake/models/update_intake_payload.py @@ -19,6 +19,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.intake.models.intake_catalog_patch import IntakeCatalogPatch @@ -49,7 +50,8 @@ class UpdateIntakePayload(BaseModel): __properties: ClassVar[List[str]] = ["catalog", "description", "displayName", "intakeRunnerId", "labels"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +62,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/intake/src/stackit/intake/models/update_intake_runner_payload.py b/services/intake/src/stackit/intake/models/update_intake_runner_payload.py index 93c292bf5..62cad46d9 100644 --- a/services/intake/src/stackit/intake/models/update_intake_runner_payload.py +++ b/services/intake/src/stackit/intake/models/update_intake_runner_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -56,7 +57,8 @@ class UpdateIntakeRunnerPayload(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -67,8 +69,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/intake/src/stackit/intake/models/update_intake_user_payload.py b/services/intake/src/stackit/intake/models/update_intake_user_payload.py index 69c471673..52f2cefb4 100644 --- a/services/intake/src/stackit/intake/models/update_intake_user_payload.py +++ b/services/intake/src/stackit/intake/models/update_intake_user_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.intake.models.user_type import UserType @@ -48,7 +49,8 @@ class UpdateIntakeUserPayload(BaseModel): __properties: ClassVar[List[str]] = ["description", "displayName", "labels", "password", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -59,8 +61,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/kms/CHANGELOG.md b/services/kms/CHANGELOG.md index 4fdd7af51..d7c984513 100644 --- a/services/kms/CHANGELOG.md +++ b/services/kms/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.10.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.9.0 - Set field `public_key` optional in `WrappingKey` model diff --git a/services/kms/pyproject.toml b/services/kms/pyproject.toml index 5c925e133..3ab3fdac0 100644 --- a/services/kms/pyproject.toml +++ b/services/kms/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-kms" -version = "v0.9.0" +version = "v0.10.0" description = "STACKIT Key Management Service API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/kms/src/stackit/kms/api_client.py b/services/kms/src/stackit/kms/api_client.py index 0037f1120..00d834d57 100644 --- a/services/kms/src/stackit/kms/api_client.py +++ b/services/kms/src/stackit/kms/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/kms/src/stackit/kms/models/create_key_payload.py b/services/kms/src/stackit/kms/models/create_key_payload.py index 4b37d2c20..ff48009f8 100644 --- a/services/kms/src/stackit/kms/models/create_key_payload.py +++ b/services/kms/src/stackit/kms/models/create_key_payload.py @@ -26,6 +26,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.kms.models.access_scope import AccessScope @@ -66,12 +67,16 @@ class CreateKeyPayload(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9_-]+$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9_-]+$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -82,8 +87,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/kms/src/stackit/kms/models/create_key_ring_payload.py b/services/kms/src/stackit/kms/models/create_key_ring_payload.py index b9f8f3956..3d98d39b1 100644 --- a/services/kms/src/stackit/kms/models/create_key_ring_payload.py +++ b/services/kms/src/stackit/kms/models/create_key_ring_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -39,12 +40,16 @@ class CreateKeyRingPayload(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9_-]+$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9_-]+$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -55,8 +60,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/kms/src/stackit/kms/models/create_wrapping_key_payload.py b/services/kms/src/stackit/kms/models/create_wrapping_key_payload.py index cbb42ce0a..c49fb3c1a 100644 --- a/services/kms/src/stackit/kms/models/create_wrapping_key_payload.py +++ b/services/kms/src/stackit/kms/models/create_wrapping_key_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.kms.models.access_scope import AccessScope @@ -55,12 +56,16 @@ class CreateWrappingKeyPayload(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9_-]+$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9_-]+$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -71,8 +76,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/kms/src/stackit/kms/models/decrypt_payload.py b/services/kms/src/stackit/kms/models/decrypt_payload.py index 53d97f0b7..8a8d330e9 100644 --- a/services/kms/src/stackit/kms/models/decrypt_payload.py +++ b/services/kms/src/stackit/kms/models/decrypt_payload.py @@ -24,6 +24,7 @@ StrictBytes, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -36,7 +37,8 @@ class DecryptPayload(BaseModel): __properties: ClassVar[List[str]] = ["data"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/kms/src/stackit/kms/models/decrypted_data.py b/services/kms/src/stackit/kms/models/decrypted_data.py index 3d6099f2d..0b0197702 100644 --- a/services/kms/src/stackit/kms/models/decrypted_data.py +++ b/services/kms/src/stackit/kms/models/decrypted_data.py @@ -24,6 +24,7 @@ StrictBytes, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -36,7 +37,8 @@ class DecryptedData(BaseModel): __properties: ClassVar[List[str]] = ["data"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/kms/src/stackit/kms/models/encrypt_payload.py b/services/kms/src/stackit/kms/models/encrypt_payload.py index 43574df1a..369eb4f17 100644 --- a/services/kms/src/stackit/kms/models/encrypt_payload.py +++ b/services/kms/src/stackit/kms/models/encrypt_payload.py @@ -24,6 +24,7 @@ StrictBytes, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -36,7 +37,8 @@ class EncryptPayload(BaseModel): __properties: ClassVar[List[str]] = ["data"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/kms/src/stackit/kms/models/encrypted_data.py b/services/kms/src/stackit/kms/models/encrypted_data.py index f7e1122dc..097011722 100644 --- a/services/kms/src/stackit/kms/models/encrypted_data.py +++ b/services/kms/src/stackit/kms/models/encrypted_data.py @@ -24,6 +24,7 @@ StrictBytes, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -36,7 +37,8 @@ class EncryptedData(BaseModel): __properties: ClassVar[List[str]] = ["data"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/kms/src/stackit/kms/models/http_error.py b/services/kms/src/stackit/kms/models/http_error.py index d939f0018..384ccb549 100644 --- a/services/kms/src/stackit/kms/models/http_error.py +++ b/services/kms/src/stackit/kms/models/http_error.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class HttpError(BaseModel): __properties: ClassVar[List[str]] = ["message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/kms/src/stackit/kms/models/import_key_payload.py b/services/kms/src/stackit/kms/models/import_key_payload.py index 5da52f65b..6d84fa42c 100644 --- a/services/kms/src/stackit/kms/models/import_key_payload.py +++ b/services/kms/src/stackit/kms/models/import_key_payload.py @@ -19,6 +19,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -36,7 +37,8 @@ class ImportKeyPayload(BaseModel): __properties: ClassVar[List[str]] = ["wrappedKey", "wrappingKeyId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/kms/src/stackit/kms/models/key.py b/services/kms/src/stackit/kms/models/key.py index 3f44e2f32..76d57ed61 100644 --- a/services/kms/src/stackit/kms/models/key.py +++ b/services/kms/src/stackit/kms/models/key.py @@ -28,6 +28,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.kms.models.access_scope import AccessScope @@ -116,7 +117,8 @@ def state_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -127,8 +129,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/kms/src/stackit/kms/models/key_list.py b/services/kms/src/stackit/kms/models/key_list.py index d78be2d30..11f4f0b68 100644 --- a/services/kms/src/stackit/kms/models/key_list.py +++ b/services/kms/src/stackit/kms/models/key_list.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.kms.models.key import Key @@ -32,7 +33,8 @@ class KeyList(BaseModel): __properties: ClassVar[List[str]] = ["keys"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/kms/src/stackit/kms/models/key_ring.py b/services/kms/src/stackit/kms/models/key_ring.py index d327d3a8a..452860e1b 100644 --- a/services/kms/src/stackit/kms/models/key_ring.py +++ b/services/kms/src/stackit/kms/models/key_ring.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -63,7 +64,8 @@ def state_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -74,8 +76,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/kms/src/stackit/kms/models/key_ring_list.py b/services/kms/src/stackit/kms/models/key_ring_list.py index e8da6fcd8..2a29043a2 100644 --- a/services/kms/src/stackit/kms/models/key_ring_list.py +++ b/services/kms/src/stackit/kms/models/key_ring_list.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.kms.models.key_ring import KeyRing @@ -32,7 +33,8 @@ class KeyRingList(BaseModel): __properties: ClassVar[List[str]] = ["keyRings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/kms/src/stackit/kms/models/sign_payload.py b/services/kms/src/stackit/kms/models/sign_payload.py index af0a3759d..fc8311dde 100644 --- a/services/kms/src/stackit/kms/models/sign_payload.py +++ b/services/kms/src/stackit/kms/models/sign_payload.py @@ -24,6 +24,7 @@ StrictBytes, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -36,7 +37,8 @@ class SignPayload(BaseModel): __properties: ClassVar[List[str]] = ["data"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/kms/src/stackit/kms/models/signed_data.py b/services/kms/src/stackit/kms/models/signed_data.py index 5670c82d4..e6852ba2c 100644 --- a/services/kms/src/stackit/kms/models/signed_data.py +++ b/services/kms/src/stackit/kms/models/signed_data.py @@ -24,6 +24,7 @@ StrictBytes, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -37,7 +38,8 @@ class SignedData(BaseModel): __properties: ClassVar[List[str]] = ["data", "signature"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/kms/src/stackit/kms/models/verified_data.py b/services/kms/src/stackit/kms/models/verified_data.py index e7a544b84..3d1aa5cbb 100644 --- a/services/kms/src/stackit/kms/models/verified_data.py +++ b/services/kms/src/stackit/kms/models/verified_data.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class VerifiedData(BaseModel): __properties: ClassVar[List[str]] = ["valid"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/kms/src/stackit/kms/models/verify_payload.py b/services/kms/src/stackit/kms/models/verify_payload.py index 9aaaa3150..a61d2bc12 100644 --- a/services/kms/src/stackit/kms/models/verify_payload.py +++ b/services/kms/src/stackit/kms/models/verify_payload.py @@ -24,6 +24,7 @@ StrictBytes, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -37,7 +38,8 @@ class VerifyPayload(BaseModel): __properties: ClassVar[List[str]] = ["data", "signature"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/kms/src/stackit/kms/models/version.py b/services/kms/src/stackit/kms/models/version.py index cd1377bc0..2227933ea 100644 --- a/services/kms/src/stackit/kms/models/version.py +++ b/services/kms/src/stackit/kms/models/version.py @@ -29,6 +29,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -106,7 +107,8 @@ def state_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -117,8 +119,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/kms/src/stackit/kms/models/version_list.py b/services/kms/src/stackit/kms/models/version_list.py index 5d6d86287..7ef5a9826 100644 --- a/services/kms/src/stackit/kms/models/version_list.py +++ b/services/kms/src/stackit/kms/models/version_list.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.kms.models.version import Version @@ -32,7 +33,8 @@ class VersionList(BaseModel): __properties: ClassVar[List[str]] = ["versions"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/kms/src/stackit/kms/models/wrapping_key.py b/services/kms/src/stackit/kms/models/wrapping_key.py index c72e9f428..aacef537b 100644 --- a/services/kms/src/stackit/kms/models/wrapping_key.py +++ b/services/kms/src/stackit/kms/models/wrapping_key.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.kms.models.access_scope import AccessScope @@ -107,7 +108,8 @@ def state_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -118,8 +120,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/kms/src/stackit/kms/models/wrapping_key_list.py b/services/kms/src/stackit/kms/models/wrapping_key_list.py index 5810aae30..777f6b24f 100644 --- a/services/kms/src/stackit/kms/models/wrapping_key_list.py +++ b/services/kms/src/stackit/kms/models/wrapping_key_list.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.kms.models.wrapping_key import WrappingKey @@ -32,7 +33,8 @@ class WrappingKeyList(BaseModel): __properties: ClassVar[List[str]] = ["wrappingKeys"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/CHANGELOG.md b/services/loadbalancer/CHANGELOG.md index 96588826e..56b6bb03e 100644 --- a/services/loadbalancer/CHANGELOG.md +++ b/services/loadbalancer/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.10.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.9.3 - Add HTTP 429 status code to some API client methods diff --git a/services/loadbalancer/pyproject.toml b/services/loadbalancer/pyproject.toml index fa238f85b..5897f1ab0 100644 --- a/services/loadbalancer/pyproject.toml +++ b/services/loadbalancer/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-loadbalancer" -version = "v0.9.3" +version = "v0.10.0" description = "Load Balancer API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/loadbalancer/src/stackit/loadbalancer/api_client.py b/services/loadbalancer/src/stackit/loadbalancer/api_client.py index 24f82624c..fac03ecfa 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/api_client.py +++ b/services/loadbalancer/src/stackit/loadbalancer/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/active_health_check.py b/services/loadbalancer/src/stackit/loadbalancer/models/active_health_check.py index 4b105af9a..0e8e4dd6e 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/active_health_check.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/active_health_check.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.loadbalancer.models.http_health_checks import HttpHealthChecks @@ -66,6 +67,9 @@ def interval_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$", value): raise ValueError(r"must validate the regular expression /^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$/") return value @@ -76,6 +80,9 @@ def interval_jitter_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$", value): raise ValueError(r"must validate the regular expression /^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$/") return value @@ -86,12 +93,16 @@ def timeout_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$", value): raise ValueError(r"must validate the regular expression /^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -102,8 +113,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/create_credentials_payload.py b/services/loadbalancer/src/stackit/loadbalancer/models/create_credentials_payload.py index c29d62b31..37e54e7f4 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/create_credentials_payload.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/create_credentials_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -46,12 +47,16 @@ def display_name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,251}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,251}[0-9a-z])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -62,8 +67,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/create_credentials_response.py b/services/loadbalancer/src/stackit/loadbalancer/models/create_credentials_response.py index 936daf15e..1c3b85479 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/create_credentials_response.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/create_credentials_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.loadbalancer.models.credentials_response import CredentialsResponse @@ -32,7 +33,8 @@ class CreateCredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["credential"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/create_load_balancer_payload.py b/services/loadbalancer/src/stackit/loadbalancer/models/create_load_balancer_payload.py index 49881d842..91562d70a 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/create_load_balancer_payload.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/create_load_balancer_payload.py @@ -26,6 +26,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.loadbalancer.models.listener import Listener @@ -126,6 +127,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value @@ -145,7 +149,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -156,8 +161,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/credentials_response.py b/services/loadbalancer/src/stackit/loadbalancer/models/credentials_response.py index 6557fcaf3..35a6d1aaf 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/credentials_response.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/credentials_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -47,12 +48,16 @@ def display_name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -63,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/get_credentials_response.py b/services/loadbalancer/src/stackit/loadbalancer/models/get_credentials_response.py index fd8589a85..80535204d 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/get_credentials_response.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/get_credentials_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.loadbalancer.models.credentials_response import CredentialsResponse @@ -32,7 +33,8 @@ class GetCredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["credential"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/get_quota_response.py b/services/loadbalancer/src/stackit/loadbalancer/models/get_quota_response.py index 0c7b4dece..1ae5094fc 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/get_quota_response.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/get_quota_response.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -65,6 +66,9 @@ def project_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/" @@ -77,12 +81,16 @@ def region_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z]{2,4}[0-9]{2}$", value): raise ValueError(r"must validate the regular expression /^[a-z]{2,4}[0-9]{2}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -93,8 +101,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/google_protobuf_any.py b/services/loadbalancer/src/stackit/loadbalancer/models/google_protobuf_any.py index ed8c61f67..8ae8ce244 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/google_protobuf_any.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/google_protobuf_any.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class GoogleProtobufAny(BaseModel): __properties: ClassVar[List[str]] = ["@type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/http_health_checks.py b/services/loadbalancer/src/stackit/loadbalancer/models/http_health_checks.py index 06b06894d..f99746bea 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/http_health_checks.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/http_health_checks.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.loadbalancer.models.tls_config import TlsConfig @@ -36,7 +37,8 @@ class HttpHealthChecks(BaseModel): __properties: ClassVar[List[str]] = ["okStatuses", "path", "tls"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/list_credentials_response.py b/services/loadbalancer/src/stackit/loadbalancer/models/list_credentials_response.py index 5b35c9227..9e265f4df 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/list_credentials_response.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/list_credentials_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.loadbalancer.models.credentials_response import CredentialsResponse @@ -32,7 +33,8 @@ class ListCredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["credentials"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/list_load_balancers_response.py b/services/loadbalancer/src/stackit/loadbalancer/models/list_load_balancers_response.py index bd586cfc5..147f3b5ce 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/list_load_balancers_response.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/list_load_balancers_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.loadbalancer.models.load_balancer import LoadBalancer @@ -43,12 +44,16 @@ def next_page_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -59,8 +64,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/list_plans_response.py b/services/loadbalancer/src/stackit/loadbalancer/models/list_plans_response.py index 70bcb8d6b..6ef87fd9e 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/list_plans_response.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/list_plans_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.loadbalancer.models.plan_details import PlanDetails @@ -32,7 +33,8 @@ class ListPlansResponse(BaseModel): __properties: ClassVar[List[str]] = ["validPlans"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/listener.py b/services/loadbalancer/src/stackit/loadbalancer/models/listener.py index 9161b9a79..96084a327 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/listener.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/listener.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.loadbalancer.models.options_tcp import OptionsTCP @@ -78,7 +79,8 @@ def protocol_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -89,8 +91,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer.py b/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer.py index 966f829c9..5f4c80638 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer.py @@ -26,6 +26,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.loadbalancer.models.listener import Listener @@ -126,6 +127,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value @@ -145,7 +149,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -156,8 +161,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer_error.py b/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer_error.py index d61db3331..8b94401aa 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer_error.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer_error.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -62,7 +63,8 @@ def type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -73,8 +75,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer_options.py b/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer_options.py index f6c58f69b..18778d168 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer_options.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer_options.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.loadbalancer.models.loadbalancer_option_access_control import ( @@ -44,7 +45,8 @@ class LoadBalancerOptions(BaseModel): __properties: ClassVar[List[str]] = ["accessControl", "ephemeralAddress", "observability", "privateNetworkOnly"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_access_control.py b/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_access_control.py index 300ff1c12..800d75739 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_access_control.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_access_control.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class LoadbalancerOptionAccessControl(BaseModel): __properties: ClassVar[List[str]] = ["allowedSourceRanges"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_logs.py b/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_logs.py index db99f1100..cbd83141b 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_logs.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_logs.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -39,7 +40,8 @@ class LoadbalancerOptionLogs(BaseModel): __properties: ClassVar[List[str]] = ["credentialsRef", "pushUrl"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_metrics.py b/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_metrics.py index 79df3f633..9fadc03f5 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_metrics.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_metrics.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -39,7 +40,8 @@ class LoadbalancerOptionMetrics(BaseModel): __properties: ClassVar[List[str]] = ["credentialsRef", "pushUrl"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_observability.py b/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_observability.py index b3e8abac1..30f2f3a41 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_observability.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_observability.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.loadbalancer.models.loadbalancer_option_logs import LoadbalancerOptionLogs @@ -36,7 +37,8 @@ class LoadbalancerOptionObservability(BaseModel): __properties: ClassVar[List[str]] = ["logs", "metrics"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/network.py b/services/loadbalancer/src/stackit/loadbalancer/models/network.py index 00d2499de..d93e94f10 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/network.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/network.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -41,6 +42,9 @@ def network_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/" @@ -60,7 +64,8 @@ def role_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -71,8 +76,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/options_tcp.py b/services/loadbalancer/src/stackit/loadbalancer/models/options_tcp.py index 1963f89bf..8e93b3f3d 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/options_tcp.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/options_tcp.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -40,12 +41,16 @@ def idle_timeout_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$", value): raise ValueError(r"must validate the regular expression /^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +61,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/options_udp.py b/services/loadbalancer/src/stackit/loadbalancer/models/options_udp.py index 80c8e8129..3ca2ac87b 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/options_udp.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/options_udp.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -40,12 +41,16 @@ def idle_timeout_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$", value): raise ValueError(r"must validate the regular expression /^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +61,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/plan_details.py b/services/loadbalancer/src/stackit/loadbalancer/models/plan_details.py index dd9639bf3..ea97fdf45 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/plan_details.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/plan_details.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -39,7 +40,8 @@ class PlanDetails(BaseModel): __properties: ClassVar[List[str]] = ["description", "flavorName", "maxConnections", "name", "planId", "region"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/security_group.py b/services/loadbalancer/src/stackit/loadbalancer/models/security_group.py index 4bc8b6312..cc983012a 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/security_group.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/security_group.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class SecurityGroup(BaseModel): __properties: ClassVar[List[str]] = ["id", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/server_name_indicator.py b/services/loadbalancer/src/stackit/loadbalancer/models/server_name_indicator.py index 031d8d9bd..cc26d5f76 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/server_name_indicator.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/server_name_indicator.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class ServerNameIndicator(BaseModel): __properties: ClassVar[List[str]] = ["name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/session_persistence.py b/services/loadbalancer/src/stackit/loadbalancer/models/session_persistence.py index 49c96fbb9..12f41132a 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/session_persistence.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/session_persistence.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class SessionPersistence(BaseModel): __properties: ClassVar[List[str]] = ["useSourceIpAddress"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/status.py b/services/loadbalancer/src/stackit/loadbalancer/models/status.py index dc73b49b8..f546fd880 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/status.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/status.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.loadbalancer.models.google_protobuf_any import GoogleProtobufAny @@ -43,7 +44,8 @@ class Status(BaseModel): __properties: ClassVar[List[str]] = ["code", "details", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/target.py b/services/loadbalancer/src/stackit/loadbalancer/models/target.py index d54a34059..108a9dec7 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/target.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/target.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -39,6 +40,9 @@ def display_name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z](?:(?:[0-9a-zA-Z]|-){0,61}[0-9a-zA-Z])?$", value): raise ValueError( r"must validate the regular expression /^[0-9a-zA-Z](?:(?:[0-9a-zA-Z]|-){0,61}[0-9a-zA-Z])?$/" @@ -46,7 +50,8 @@ def display_name_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -57,8 +62,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/target_pool.py b/services/loadbalancer/src/stackit/loadbalancer/models/target_pool.py index 69e47e01a..dce51d54b 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/target_pool.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/target_pool.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.loadbalancer.models.active_health_check import ActiveHealthCheck @@ -50,12 +51,16 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -66,8 +71,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/tls_config.py b/services/loadbalancer/src/stackit/loadbalancer/models/tls_config.py index 812f4dba4..cb96bc7d8 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/tls_config.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/tls_config.py @@ -24,6 +24,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -49,7 +50,8 @@ class TlsConfig(BaseModel): __properties: ClassVar[List[str]] = ["customCa", "enabled", "skipCertificateValidation"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +62,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/update_credentials_payload.py b/services/loadbalancer/src/stackit/loadbalancer/models/update_credentials_payload.py index 7892a5710..8b4ba419c 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/update_credentials_payload.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/update_credentials_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -46,12 +47,16 @@ def display_name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,251}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,251}[0-9a-z])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -62,8 +67,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/update_credentials_response.py b/services/loadbalancer/src/stackit/loadbalancer/models/update_credentials_response.py index a0837b6cb..7ed14eb75 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/update_credentials_response.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/update_credentials_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.loadbalancer.models.credentials_response import CredentialsResponse @@ -32,7 +33,8 @@ class UpdateCredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["credential"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/update_load_balancer_payload.py b/services/loadbalancer/src/stackit/loadbalancer/models/update_load_balancer_payload.py index 33a328942..139ce4f70 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/update_load_balancer_payload.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/update_load_balancer_payload.py @@ -26,6 +26,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.loadbalancer.models.listener import Listener @@ -126,6 +127,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value @@ -145,7 +149,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -156,8 +161,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/update_target_pool_payload.py b/services/loadbalancer/src/stackit/loadbalancer/models/update_target_pool_payload.py index c513ebf4f..053577c25 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/update_target_pool_payload.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/update_target_pool_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.loadbalancer.models.active_health_check import ActiveHealthCheck @@ -50,12 +51,16 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -66,8 +71,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/CHANGELOG.md b/services/logme/CHANGELOG.md index 1b87cda41..6028f9aec 100644 --- a/services/logme/CHANGELOG.md +++ b/services/logme/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.5.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.4.1 - **Feature:** client now supports UUID and decimal types - **Bugfix:** timeouts now passed to requests library diff --git a/services/logme/pyproject.toml b/services/logme/pyproject.toml index 05874caa2..503972b7d 100644 --- a/services/logme/pyproject.toml +++ b/services/logme/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-logme" -version = "v0.4.1" +version = "v0.5.0" description = "STACKIT LogMe API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/logme/src/stackit/logme/api/default_api.py b/services/logme/src/stackit/logme/api/default_api.py index 7fd1ba875..5f455bd82 100644 --- a/services/logme/src/stackit/logme/api/default_api.py +++ b/services/logme/src/stackit/logme/api/default_api.py @@ -1332,7 +1332,7 @@ def download_backup( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> bytearray: + ) -> bytes: """download backup @@ -1375,7 +1375,7 @@ def download_backup( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "bytearray", + "200": "bytes", "500": "Error", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -1400,7 +1400,7 @@ def download_backup_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[bytearray]: + ) -> ApiResponse[bytes]: """download backup @@ -1443,7 +1443,7 @@ def download_backup_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "bytearray", + "200": "bytes", "500": "Error", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -1511,7 +1511,7 @@ def download_backup_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "bytearray", + "200": "bytes", "500": "Error", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) diff --git a/services/logme/src/stackit/logme/api_client.py b/services/logme/src/stackit/logme/api_client.py index 20ed13664..9c36aef57 100644 --- a/services/logme/src/stackit/logme/api_client.py +++ b/services/logme/src/stackit/logme/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/logme/src/stackit/logme/models/backup.py b/services/logme/src/stackit/logme/models/backup.py index 86c5974de..63de1cc03 100644 --- a/services/logme/src/stackit/logme/models/backup.py +++ b/services/logme/src/stackit/logme/models/backup.py @@ -24,6 +24,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -41,7 +42,8 @@ class Backup(BaseModel): __properties: ClassVar[List[str]] = ["downloadable", "finished_at", "id", "size", "status", "triggered_at"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -52,8 +54,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/create_backup_response_item.py b/services/logme/src/stackit/logme/models/create_backup_response_item.py index bd4005966..865c19e9b 100644 --- a/services/logme/src/stackit/logme/models/create_backup_response_item.py +++ b/services/logme/src/stackit/logme/models/create_backup_response_item.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class CreateBackupResponseItem(BaseModel): __properties: ClassVar[List[str]] = ["id", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/create_instance_payload.py b/services/logme/src/stackit/logme/models/create_instance_payload.py index 0c3ae8be6..22dd48b5f 100644 --- a/services/logme/src/stackit/logme/models/create_instance_payload.py +++ b/services/logme/src/stackit/logme/models/create_instance_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.logme.models.instance_parameters import InstanceParameters @@ -34,7 +35,8 @@ class CreateInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["instanceName", "parameters", "planId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/create_instance_response.py b/services/logme/src/stackit/logme/models/create_instance_response.py index 039d82df8..90a948e62 100644 --- a/services/logme/src/stackit/logme/models/create_instance_response.py +++ b/services/logme/src/stackit/logme/models/create_instance_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class CreateInstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["instanceId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/credentials.py b/services/logme/src/stackit/logme/models/credentials.py index ebc5bdf1d..d8c3ad702 100644 --- a/services/logme/src/stackit/logme/models/credentials.py +++ b/services/logme/src/stackit/logme/models/credentials.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -35,7 +36,8 @@ class Credentials(BaseModel): __properties: ClassVar[List[str]] = ["host", "password", "port", "syslog_drain_url", "uri", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/credentials_list_item.py b/services/logme/src/stackit/logme/models/credentials_list_item.py index 0b4d196fb..e7a3284d6 100644 --- a/services/logme/src/stackit/logme/models/credentials_list_item.py +++ b/services/logme/src/stackit/logme/models/credentials_list_item.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class CredentialsListItem(BaseModel): __properties: ClassVar[List[str]] = ["id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/credentials_response.py b/services/logme/src/stackit/logme/models/credentials_response.py index d4e95c95d..d6f09cd5f 100644 --- a/services/logme/src/stackit/logme/models/credentials_response.py +++ b/services/logme/src/stackit/logme/models/credentials_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.logme.models.raw_credentials import RawCredentials @@ -34,7 +35,8 @@ class CredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["id", "raw", "uri"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/error.py b/services/logme/src/stackit/logme/models/error.py index 670059b3d..bb4935bcc 100644 --- a/services/logme/src/stackit/logme/models/error.py +++ b/services/logme/src/stackit/logme/models/error.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class Error(BaseModel): __properties: ClassVar[List[str]] = ["description", "error"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/get_metrics_response.py b/services/logme/src/stackit/logme/models/get_metrics_response.py index f8fb1505b..906ddb243 100644 --- a/services/logme/src/stackit/logme/models/get_metrics_response.py +++ b/services/logme/src/stackit/logme/models/get_metrics_response.py @@ -26,6 +26,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -86,7 +87,8 @@ class GetMetricsResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -97,8 +99,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/instance.py b/services/logme/src/stackit/logme/models/instance.py index bf3be3548..9ef2c05fa 100644 --- a/services/logme/src/stackit/logme/models/instance.py +++ b/services/logme/src/stackit/logme/models/instance.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.logme.models.instance_last_operation import InstanceLastOperation @@ -72,7 +73,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -83,8 +85,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/instance_last_operation.py b/services/logme/src/stackit/logme/models/instance_last_operation.py index 8eef57f3f..333a6ac03 100644 --- a/services/logme/src/stackit/logme/models/instance_last_operation.py +++ b/services/logme/src/stackit/logme/models/instance_last_operation.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -46,7 +47,8 @@ def type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -57,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/instance_parameters.py b/services/logme/src/stackit/logme/models/instance_parameters.py index 46b705ed1..da5a4d3f4 100644 --- a/services/logme/src/stackit/logme/models/instance_parameters.py +++ b/services/logme/src/stackit/logme/models/instance_parameters.py @@ -27,6 +27,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.logme.models.instance_parameters_groks_inner import ( @@ -122,7 +123,8 @@ def opensearch_tls_ciphers_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -133,8 +135,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/instance_parameters_groks_inner.py b/services/logme/src/stackit/logme/models/instance_parameters_groks_inner.py index 646771da5..99b458d6e 100644 --- a/services/logme/src/stackit/logme/models/instance_parameters_groks_inner.py +++ b/services/logme/src/stackit/logme/models/instance_parameters_groks_inner.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class InstanceParametersGroksInner(BaseModel): __properties: ClassVar[List[str]] = ["pattern"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/instance_schema.py b/services/logme/src/stackit/logme/models/instance_schema.py index 03b54ddbc..25962571b 100644 --- a/services/logme/src/stackit/logme/models/instance_schema.py +++ b/services/logme/src/stackit/logme/models/instance_schema.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.logme.models.model_schema import ModelSchema @@ -33,7 +34,8 @@ class InstanceSchema(BaseModel): __properties: ClassVar[List[str]] = ["create", "update"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/list_backups_response.py b/services/logme/src/stackit/logme/models/list_backups_response.py index 79cac1404..9b038bc85 100644 --- a/services/logme/src/stackit/logme/models/list_backups_response.py +++ b/services/logme/src/stackit/logme/models/list_backups_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.logme.models.backup import Backup @@ -32,7 +33,8 @@ class ListBackupsResponse(BaseModel): __properties: ClassVar[List[str]] = ["instanceBackups"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/list_credentials_response.py b/services/logme/src/stackit/logme/models/list_credentials_response.py index 5d518b6a7..5eba81f3f 100644 --- a/services/logme/src/stackit/logme/models/list_credentials_response.py +++ b/services/logme/src/stackit/logme/models/list_credentials_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.logme.models.credentials_list_item import CredentialsListItem @@ -32,7 +33,8 @@ class ListCredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["credentialsList"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/list_instances_response.py b/services/logme/src/stackit/logme/models/list_instances_response.py index 8cb59feb6..dcfd0efff 100644 --- a/services/logme/src/stackit/logme/models/list_instances_response.py +++ b/services/logme/src/stackit/logme/models/list_instances_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.logme.models.instance import Instance @@ -32,7 +33,8 @@ class ListInstancesResponse(BaseModel): __properties: ClassVar[List[str]] = ["instances"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/list_offerings_response.py b/services/logme/src/stackit/logme/models/list_offerings_response.py index 52c92faa4..3b35edd05 100644 --- a/services/logme/src/stackit/logme/models/list_offerings_response.py +++ b/services/logme/src/stackit/logme/models/list_offerings_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.logme.models.offering import Offering @@ -32,7 +33,8 @@ class ListOfferingsResponse(BaseModel): __properties: ClassVar[List[str]] = ["offerings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/list_restores_response.py b/services/logme/src/stackit/logme/models/list_restores_response.py index ca9bcaa54..65257fd9a 100644 --- a/services/logme/src/stackit/logme/models/list_restores_response.py +++ b/services/logme/src/stackit/logme/models/list_restores_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.logme.models.restore import Restore @@ -32,7 +33,8 @@ class ListRestoresResponse(BaseModel): __properties: ClassVar[List[str]] = ["instanceRestores"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/model_schema.py b/services/logme/src/stackit/logme/models/model_schema.py index 4279fdc9c..26290f58b 100644 --- a/services/logme/src/stackit/logme/models/model_schema.py +++ b/services/logme/src/stackit/logme/models/model_schema.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class ModelSchema(BaseModel): __properties: ClassVar[List[str]] = ["parameters"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/offering.py b/services/logme/src/stackit/logme/models/offering.py index c7e52c8d7..25d137e4d 100644 --- a/services/logme/src/stackit/logme/models/offering.py +++ b/services/logme/src/stackit/logme/models/offering.py @@ -25,6 +25,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.logme.models.instance_schema import InstanceSchema @@ -60,7 +61,8 @@ class Offering(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -71,8 +73,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/partial_update_instance_payload.py b/services/logme/src/stackit/logme/models/partial_update_instance_payload.py index fec483b25..0f97098c7 100644 --- a/services/logme/src/stackit/logme/models/partial_update_instance_payload.py +++ b/services/logme/src/stackit/logme/models/partial_update_instance_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.logme.models.instance_parameters import InstanceParameters @@ -34,7 +35,8 @@ class PartialUpdateInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["instanceName", "parameters", "planId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/plan.py b/services/logme/src/stackit/logme/models/plan.py index 46ba0e4bb..deae94728 100644 --- a/services/logme/src/stackit/logme/models/plan.py +++ b/services/logme/src/stackit/logme/models/plan.py @@ -24,6 +24,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -40,7 +41,8 @@ class Plan(BaseModel): __properties: ClassVar[List[str]] = ["description", "free", "id", "name", "skuName"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/raw_credentials.py b/services/logme/src/stackit/logme/models/raw_credentials.py index 4c03016e0..b3f07600f 100644 --- a/services/logme/src/stackit/logme/models/raw_credentials.py +++ b/services/logme/src/stackit/logme/models/raw_credentials.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.logme.models.credentials import Credentials @@ -32,7 +33,8 @@ class RawCredentials(BaseModel): __properties: ClassVar[List[str]] = ["credentials"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/restore.py b/services/logme/src/stackit/logme/models/restore.py index fddf8b7b0..82f2a7ff5 100644 --- a/services/logme/src/stackit/logme/models/restore.py +++ b/services/logme/src/stackit/logme/models/restore.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class Restore(BaseModel): __properties: ClassVar[List[str]] = ["backup_id", "finished_at", "id", "status", "triggered_at"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/trigger_restore_response.py b/services/logme/src/stackit/logme/models/trigger_restore_response.py index 58d7e8c65..2dd02194a 100644 --- a/services/logme/src/stackit/logme/models/trigger_restore_response.py +++ b/services/logme/src/stackit/logme/models/trigger_restore_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class TriggerRestoreResponse(BaseModel): __properties: ClassVar[List[str]] = ["id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/update_backups_config_payload.py b/services/logme/src/stackit/logme/models/update_backups_config_payload.py index 4290dce1d..43e31aa9f 100644 --- a/services/logme/src/stackit/logme/models/update_backups_config_payload.py +++ b/services/logme/src/stackit/logme/models/update_backups_config_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class UpdateBackupsConfigPayload(BaseModel): __properties: ClassVar[List[str]] = ["encryption_key"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logme/src/stackit/logme/models/update_backups_config_response.py b/services/logme/src/stackit/logme/models/update_backups_config_response.py index 7175b5b65..f314ad757 100644 --- a/services/logme/src/stackit/logme/models/update_backups_config_response.py +++ b/services/logme/src/stackit/logme/models/update_backups_config_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class UpdateBackupsConfigResponse(BaseModel): __properties: ClassVar[List[str]] = ["message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logs/CHANGELOG.md b/services/logs/CHANGELOG.md index 52c4dfde7..23730bb15 100644 --- a/services/logs/CHANGELOG.md +++ b/services/logs/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.3.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.2.1 - **Feature:** client now supports UUID and decimal types - **Bugfix:** timeouts now passed to requests library @@ -6,4 +9,4 @@ - **Feature:** Switch from `v1beta` version to `v1` version of the API. ## v0.1.0 -- **New**: STACKIT Logs service \ No newline at end of file +- **New**: STACKIT Logs service diff --git a/services/logs/pyproject.toml b/services/logs/pyproject.toml index ba320ef4c..4b6a63c63 100644 --- a/services/logs/pyproject.toml +++ b/services/logs/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-logs" -version = "v0.2.1" +version = "v0.3.0" description = "STACKIT Logs API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4" diff --git a/services/logs/src/stackit/logs/api_client.py b/services/logs/src/stackit/logs/api_client.py index 07bd934b4..936ac52c6 100644 --- a/services/logs/src/stackit/logs/api_client.py +++ b/services/logs/src/stackit/logs/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/logs/src/stackit/logs/models/access_token.py b/services/logs/src/stackit/logs/models/access_token.py index 4dc83b2d8..76001033e 100644 --- a/services/logs/src/stackit/logs/models/access_token.py +++ b/services/logs/src/stackit/logs/models/access_token.py @@ -28,6 +28,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -70,6 +71,9 @@ class AccessToken(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z][\w -]*$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z][\w -]*$/") return value @@ -103,7 +107,8 @@ def valid_until_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -114,8 +119,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logs/src/stackit/logs/models/access_token_list.py b/services/logs/src/stackit/logs/models/access_token_list.py index 60f6fe16b..07a80ca2d 100644 --- a/services/logs/src/stackit/logs/models/access_token_list.py +++ b/services/logs/src/stackit/logs/models/access_token_list.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.logs.models.access_token import AccessToken @@ -32,7 +33,8 @@ class AccessTokenList(BaseModel): __properties: ClassVar[List[str]] = ["tokens"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logs/src/stackit/logs/models/create_access_token_payload.py b/services/logs/src/stackit/logs/models/create_access_token_payload.py index 7d6235e60..24d2ac8ed 100644 --- a/services/logs/src/stackit/logs/models/create_access_token_payload.py +++ b/services/logs/src/stackit/logs/models/create_access_token_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -42,6 +43,9 @@ class CreateAccessTokenPayload(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z][\w -]*$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z][\w -]*$/") return value @@ -55,7 +59,8 @@ def permissions_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -66,8 +71,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logs/src/stackit/logs/models/create_logs_instance_payload.py b/services/logs/src/stackit/logs/models/create_logs_instance_payload.py index 7452c8a33..f6cd14dee 100644 --- a/services/logs/src/stackit/logs/models/create_logs_instance_payload.py +++ b/services/logs/src/stackit/logs/models/create_logs_instance_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -42,12 +43,16 @@ class CreateLogsInstancePayload(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z][\w -]*$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z][\w -]*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -58,8 +63,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logs/src/stackit/logs/models/logs_instance.py b/services/logs/src/stackit/logs/models/logs_instance.py index 056f19f4f..36ef629c2 100644 --- a/services/logs/src/stackit/logs/models/logs_instance.py +++ b/services/logs/src/stackit/logs/models/logs_instance.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -88,6 +89,9 @@ def created_change_year_zero_to_one(cls, value): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z][\w -]*$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z][\w -]*$/") return value @@ -100,7 +104,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -111,8 +116,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logs/src/stackit/logs/models/logs_instances_list.py b/services/logs/src/stackit/logs/models/logs_instances_list.py index 029676079..e8691f2a9 100644 --- a/services/logs/src/stackit/logs/models/logs_instances_list.py +++ b/services/logs/src/stackit/logs/models/logs_instances_list.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.logs.models.logs_instance import LogsInstance @@ -32,7 +33,8 @@ class LogsInstancesList(BaseModel): __properties: ClassVar[List[str]] = ["instances"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logs/src/stackit/logs/models/update_access_token_payload.py b/services/logs/src/stackit/logs/models/update_access_token_payload.py index ecf5fb35d..0e2c9a0f1 100644 --- a/services/logs/src/stackit/logs/models/update_access_token_payload.py +++ b/services/logs/src/stackit/logs/models/update_access_token_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -41,12 +42,16 @@ def display_name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z][\w -]*$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z][\w -]*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -57,8 +62,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/logs/src/stackit/logs/models/update_logs_instance_payload.py b/services/logs/src/stackit/logs/models/update_logs_instance_payload.py index 2a35324c1..9d74933db 100644 --- a/services/logs/src/stackit/logs/models/update_logs_instance_payload.py +++ b/services/logs/src/stackit/logs/models/update_logs_instance_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -45,12 +46,16 @@ def display_name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z][\w -]*$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z][\w -]*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -61,8 +66,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/CHANGELOG.md b/services/mariadb/CHANGELOG.md index 2993725e1..af2d9dd9c 100644 --- a/services/mariadb/CHANGELOG.md +++ b/services/mariadb/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.4.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.3.1 - **Feature:** client now supports UUID and decimal types - **Bugfix:** timeouts now passed to requests library diff --git a/services/mariadb/pyproject.toml b/services/mariadb/pyproject.toml index 6885cafc7..69a80202b 100644 --- a/services/mariadb/pyproject.toml +++ b/services/mariadb/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-mariadb" -version = "v0.3.1" +version = "v0.4.0" description = "STACKIT MariaDB API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/mariadb/src/stackit/mariadb/api/default_api.py b/services/mariadb/src/stackit/mariadb/api/default_api.py index b2274d1b3..a30afece3 100644 --- a/services/mariadb/src/stackit/mariadb/api/default_api.py +++ b/services/mariadb/src/stackit/mariadb/api/default_api.py @@ -1332,7 +1332,7 @@ def download_backup( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> bytearray: + ) -> bytes: """download backup @@ -1375,7 +1375,7 @@ def download_backup( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "bytearray", + "200": "bytes", "500": "Error", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -1400,7 +1400,7 @@ def download_backup_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[bytearray]: + ) -> ApiResponse[bytes]: """download backup @@ -1443,7 +1443,7 @@ def download_backup_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "bytearray", + "200": "bytes", "500": "Error", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -1511,7 +1511,7 @@ def download_backup_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "bytearray", + "200": "bytes", "500": "Error", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) diff --git a/services/mariadb/src/stackit/mariadb/api_client.py b/services/mariadb/src/stackit/mariadb/api_client.py index 642946cc3..33ddf3156 100644 --- a/services/mariadb/src/stackit/mariadb/api_client.py +++ b/services/mariadb/src/stackit/mariadb/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/mariadb/src/stackit/mariadb/models/backup.py b/services/mariadb/src/stackit/mariadb/models/backup.py index 12a5deb32..c713dc608 100644 --- a/services/mariadb/src/stackit/mariadb/models/backup.py +++ b/services/mariadb/src/stackit/mariadb/models/backup.py @@ -24,6 +24,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -41,7 +42,8 @@ class Backup(BaseModel): __properties: ClassVar[List[str]] = ["downloadable", "finished_at", "id", "size", "status", "triggered_at"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -52,8 +54,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/create_backup_response_item.py b/services/mariadb/src/stackit/mariadb/models/create_backup_response_item.py index 78f745003..049d51b94 100644 --- a/services/mariadb/src/stackit/mariadb/models/create_backup_response_item.py +++ b/services/mariadb/src/stackit/mariadb/models/create_backup_response_item.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class CreateBackupResponseItem(BaseModel): __properties: ClassVar[List[str]] = ["id", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/create_instance_payload.py b/services/mariadb/src/stackit/mariadb/models/create_instance_payload.py index 9339f6b12..c1dc1371b 100644 --- a/services/mariadb/src/stackit/mariadb/models/create_instance_payload.py +++ b/services/mariadb/src/stackit/mariadb/models/create_instance_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mariadb.models.instance_parameters import InstanceParameters @@ -34,7 +35,8 @@ class CreateInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["instanceName", "parameters", "planId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/create_instance_response.py b/services/mariadb/src/stackit/mariadb/models/create_instance_response.py index c9ce1dc36..a2cc1ae65 100644 --- a/services/mariadb/src/stackit/mariadb/models/create_instance_response.py +++ b/services/mariadb/src/stackit/mariadb/models/create_instance_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class CreateInstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["instanceId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/credentials.py b/services/mariadb/src/stackit/mariadb/models/credentials.py index 6e72de36a..acaf13556 100644 --- a/services/mariadb/src/stackit/mariadb/models/credentials.py +++ b/services/mariadb/src/stackit/mariadb/models/credentials.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -36,7 +37,8 @@ class Credentials(BaseModel): __properties: ClassVar[List[str]] = ["host", "hosts", "name", "password", "port", "uri", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/credentials_list_item.py b/services/mariadb/src/stackit/mariadb/models/credentials_list_item.py index 436204b52..517e47cda 100644 --- a/services/mariadb/src/stackit/mariadb/models/credentials_list_item.py +++ b/services/mariadb/src/stackit/mariadb/models/credentials_list_item.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class CredentialsListItem(BaseModel): __properties: ClassVar[List[str]] = ["id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/credentials_response.py b/services/mariadb/src/stackit/mariadb/models/credentials_response.py index a98a6f3e5..35575f6ff 100644 --- a/services/mariadb/src/stackit/mariadb/models/credentials_response.py +++ b/services/mariadb/src/stackit/mariadb/models/credentials_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mariadb.models.raw_credentials import RawCredentials @@ -34,7 +35,8 @@ class CredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["id", "raw", "uri"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/error.py b/services/mariadb/src/stackit/mariadb/models/error.py index 660852b79..ab80ed3c6 100644 --- a/services/mariadb/src/stackit/mariadb/models/error.py +++ b/services/mariadb/src/stackit/mariadb/models/error.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class Error(BaseModel): __properties: ClassVar[List[str]] = ["description", "error"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/get_metrics_response.py b/services/mariadb/src/stackit/mariadb/models/get_metrics_response.py index 6a310e122..b69443b1a 100644 --- a/services/mariadb/src/stackit/mariadb/models/get_metrics_response.py +++ b/services/mariadb/src/stackit/mariadb/models/get_metrics_response.py @@ -25,6 +25,7 @@ StrictFloat, StrictInt, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -83,7 +84,8 @@ class GetMetricsResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -94,8 +96,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/instance.py b/services/mariadb/src/stackit/mariadb/models/instance.py index 4af4cb4a6..bf90476d5 100644 --- a/services/mariadb/src/stackit/mariadb/models/instance.py +++ b/services/mariadb/src/stackit/mariadb/models/instance.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mariadb.models.instance_last_operation import InstanceLastOperation @@ -72,7 +73,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -83,8 +85,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/instance_last_operation.py b/services/mariadb/src/stackit/mariadb/models/instance_last_operation.py index b13b1bd34..acc8a32a4 100644 --- a/services/mariadb/src/stackit/mariadb/models/instance_last_operation.py +++ b/services/mariadb/src/stackit/mariadb/models/instance_last_operation.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -46,7 +47,8 @@ def type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -57,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/instance_parameters.py b/services/mariadb/src/stackit/mariadb/models/instance_parameters.py index f33c2326a..4bf13fe60 100644 --- a/services/mariadb/src/stackit/mariadb/models/instance_parameters.py +++ b/services/mariadb/src/stackit/mariadb/models/instance_parameters.py @@ -25,6 +25,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -67,7 +68,8 @@ class InstanceParameters(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -78,8 +80,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/instance_schema.py b/services/mariadb/src/stackit/mariadb/models/instance_schema.py index 9efb96231..b7bea09a7 100644 --- a/services/mariadb/src/stackit/mariadb/models/instance_schema.py +++ b/services/mariadb/src/stackit/mariadb/models/instance_schema.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mariadb.models.model_schema import ModelSchema @@ -33,7 +34,8 @@ class InstanceSchema(BaseModel): __properties: ClassVar[List[str]] = ["create", "update"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/list_backups_response.py b/services/mariadb/src/stackit/mariadb/models/list_backups_response.py index 9f862d9df..88265ebd8 100644 --- a/services/mariadb/src/stackit/mariadb/models/list_backups_response.py +++ b/services/mariadb/src/stackit/mariadb/models/list_backups_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mariadb.models.backup import Backup @@ -32,7 +33,8 @@ class ListBackupsResponse(BaseModel): __properties: ClassVar[List[str]] = ["instanceBackups"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/list_credentials_response.py b/services/mariadb/src/stackit/mariadb/models/list_credentials_response.py index d076242f9..ca7d30c8a 100644 --- a/services/mariadb/src/stackit/mariadb/models/list_credentials_response.py +++ b/services/mariadb/src/stackit/mariadb/models/list_credentials_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mariadb.models.credentials_list_item import CredentialsListItem @@ -32,7 +33,8 @@ class ListCredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["credentialsList"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/list_instances_response.py b/services/mariadb/src/stackit/mariadb/models/list_instances_response.py index c8c76c163..3a6ada16d 100644 --- a/services/mariadb/src/stackit/mariadb/models/list_instances_response.py +++ b/services/mariadb/src/stackit/mariadb/models/list_instances_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mariadb.models.instance import Instance @@ -32,7 +33,8 @@ class ListInstancesResponse(BaseModel): __properties: ClassVar[List[str]] = ["instances"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/list_offerings_response.py b/services/mariadb/src/stackit/mariadb/models/list_offerings_response.py index 0fa796bd0..a331109fe 100644 --- a/services/mariadb/src/stackit/mariadb/models/list_offerings_response.py +++ b/services/mariadb/src/stackit/mariadb/models/list_offerings_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mariadb.models.offering import Offering @@ -32,7 +33,8 @@ class ListOfferingsResponse(BaseModel): __properties: ClassVar[List[str]] = ["offerings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/list_restores_response.py b/services/mariadb/src/stackit/mariadb/models/list_restores_response.py index c3ac15323..fed54ccac 100644 --- a/services/mariadb/src/stackit/mariadb/models/list_restores_response.py +++ b/services/mariadb/src/stackit/mariadb/models/list_restores_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mariadb.models.restore import Restore @@ -32,7 +33,8 @@ class ListRestoresResponse(BaseModel): __properties: ClassVar[List[str]] = ["instanceRestores"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/model_schema.py b/services/mariadb/src/stackit/mariadb/models/model_schema.py index 221cd3bfb..3455811a6 100644 --- a/services/mariadb/src/stackit/mariadb/models/model_schema.py +++ b/services/mariadb/src/stackit/mariadb/models/model_schema.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class ModelSchema(BaseModel): __properties: ClassVar[List[str]] = ["parameters"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/offering.py b/services/mariadb/src/stackit/mariadb/models/offering.py index df3911246..68e7114ba 100644 --- a/services/mariadb/src/stackit/mariadb/models/offering.py +++ b/services/mariadb/src/stackit/mariadb/models/offering.py @@ -25,6 +25,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mariadb.models.instance_schema import InstanceSchema @@ -60,7 +61,8 @@ class Offering(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -71,8 +73,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/partial_update_instance_payload.py b/services/mariadb/src/stackit/mariadb/models/partial_update_instance_payload.py index 5aab8e1f7..1dd2fbb7f 100644 --- a/services/mariadb/src/stackit/mariadb/models/partial_update_instance_payload.py +++ b/services/mariadb/src/stackit/mariadb/models/partial_update_instance_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mariadb.models.instance_parameters import InstanceParameters @@ -34,7 +35,8 @@ class PartialUpdateInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["instanceName", "parameters", "planId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/plan.py b/services/mariadb/src/stackit/mariadb/models/plan.py index 4e5722585..732ace6cd 100644 --- a/services/mariadb/src/stackit/mariadb/models/plan.py +++ b/services/mariadb/src/stackit/mariadb/models/plan.py @@ -24,6 +24,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -40,7 +41,8 @@ class Plan(BaseModel): __properties: ClassVar[List[str]] = ["description", "free", "id", "name", "skuName"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/raw_credentials.py b/services/mariadb/src/stackit/mariadb/models/raw_credentials.py index d9b1f4a6f..63b7ca9e0 100644 --- a/services/mariadb/src/stackit/mariadb/models/raw_credentials.py +++ b/services/mariadb/src/stackit/mariadb/models/raw_credentials.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mariadb.models.credentials import Credentials @@ -32,7 +33,8 @@ class RawCredentials(BaseModel): __properties: ClassVar[List[str]] = ["credentials"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/restore.py b/services/mariadb/src/stackit/mariadb/models/restore.py index 3b8bf6385..be96fad37 100644 --- a/services/mariadb/src/stackit/mariadb/models/restore.py +++ b/services/mariadb/src/stackit/mariadb/models/restore.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class Restore(BaseModel): __properties: ClassVar[List[str]] = ["backup_id", "finished_at", "id", "status", "triggered_at"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/trigger_restore_response.py b/services/mariadb/src/stackit/mariadb/models/trigger_restore_response.py index f5cb70a0d..1a9cd4914 100644 --- a/services/mariadb/src/stackit/mariadb/models/trigger_restore_response.py +++ b/services/mariadb/src/stackit/mariadb/models/trigger_restore_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class TriggerRestoreResponse(BaseModel): __properties: ClassVar[List[str]] = ["id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/update_backups_config_payload.py b/services/mariadb/src/stackit/mariadb/models/update_backups_config_payload.py index 5990aca7e..a865243f4 100644 --- a/services/mariadb/src/stackit/mariadb/models/update_backups_config_payload.py +++ b/services/mariadb/src/stackit/mariadb/models/update_backups_config_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class UpdateBackupsConfigPayload(BaseModel): __properties: ClassVar[List[str]] = ["encryption_key"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mariadb/src/stackit/mariadb/models/update_backups_config_response.py b/services/mariadb/src/stackit/mariadb/models/update_backups_config_response.py index 2a081e72b..2307a070d 100644 --- a/services/mariadb/src/stackit/mariadb/models/update_backups_config_response.py +++ b/services/mariadb/src/stackit/mariadb/models/update_backups_config_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class UpdateBackupsConfigResponse(BaseModel): __properties: ClassVar[List[str]] = ["message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/modelserving/CHANGELOG.md b/services/modelserving/CHANGELOG.md index a547fe1cc..0465a9d40 100644 --- a/services/modelserving/CHANGELOG.md +++ b/services/modelserving/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.3.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.2.3 - **Feature:** client now supports UUID and decimal types - **Bugfix:** timeouts now passed to requests library diff --git a/services/modelserving/pyproject.toml b/services/modelserving/pyproject.toml index 71eb3f857..2690ac732 100644 --- a/services/modelserving/pyproject.toml +++ b/services/modelserving/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-modelserving" -version = "v0.2.3" +version = "v0.3.0" description = "STACKIT Model Serving API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/modelserving/src/stackit/modelserving/api_client.py b/services/modelserving/src/stackit/modelserving/api_client.py index b0dfa8cfe..9480be331 100644 --- a/services/modelserving/src/stackit/modelserving/api_client.py +++ b/services/modelserving/src/stackit/modelserving/api_client.py @@ -67,6 +67,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -266,7 +267,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -327,25 +328,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -418,6 +414,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/modelserving/src/stackit/modelserving/models/chat_model_details.py b/services/modelserving/src/stackit/modelserving/models/chat_model_details.py index 06cba434c..56045ce21 100644 --- a/services/modelserving/src/stackit/modelserving/models/chat_model_details.py +++ b/services/modelserving/src/stackit/modelserving/models/chat_model_details.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.modelserving.models.sku import SKU @@ -80,6 +81,9 @@ def category_validate_enum(cls, value): @field_validator("description") def description_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z\s.:\/\-]+$", value): raise ValueError(r"must validate the regular expression /^[0-9a-zA-Z\s.:\/\-]+$/") return value @@ -87,6 +91,9 @@ def description_validate_regular_expression(cls, value): @field_validator("displayed_name") def displayed_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z\s_-]+$", value): raise ValueError(r"must validate the regular expression /^[0-9a-zA-Z\s_-]+$/") return value @@ -94,6 +101,9 @@ def displayed_name_validate_regular_expression(cls, value): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z\s.:\/\-]+$", value): raise ValueError(r"must validate the regular expression /^[0-9a-zA-Z\s.:\/\-]+$/") return value @@ -111,12 +121,16 @@ def quantization_method_validate_enum(cls, value): @field_validator("url") def url_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z\s.:\/\-]+$", value): raise ValueError(r"must validate the regular expression /^[0-9a-zA-Z\s.:\/\-]+$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -127,8 +141,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/modelserving/src/stackit/modelserving/models/create_token_payload.py b/services/modelserving/src/stackit/modelserving/models/create_token_payload.py index 45fa1425a..ce99cccc5 100644 --- a/services/modelserving/src/stackit/modelserving/models/create_token_payload.py +++ b/services/modelserving/src/stackit/modelserving/models/create_token_payload.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -43,6 +44,9 @@ def description_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z\s.:\/\-]+$", value): raise ValueError(r"must validate the regular expression /^[0-9a-zA-Z\s.:\/\-]+$/") return value @@ -50,12 +54,16 @@ def description_validate_regular_expression(cls, value): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z\s_-]+$", value): raise ValueError(r"must validate the regular expression /^[0-9a-zA-Z\s_-]+$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -66,8 +74,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/modelserving/src/stackit/modelserving/models/create_token_response.py b/services/modelserving/src/stackit/modelserving/models/create_token_response.py index cbcda46bb..716ff126c 100644 --- a/services/modelserving/src/stackit/modelserving/models/create_token_response.py +++ b/services/modelserving/src/stackit/modelserving/models/create_token_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.modelserving.models.token_created import TokenCreated @@ -34,7 +35,8 @@ class CreateTokenResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "token"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/modelserving/src/stackit/modelserving/models/embedding_model_details.py b/services/modelserving/src/stackit/modelserving/models/embedding_model_details.py index e83acd824..561d8268b 100644 --- a/services/modelserving/src/stackit/modelserving/models/embedding_model_details.py +++ b/services/modelserving/src/stackit/modelserving/models/embedding_model_details.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.modelserving.models.sku import SKU @@ -64,6 +65,9 @@ def category_validate_enum(cls, value): @field_validator("description") def description_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z\s.:\/\-]+$", value): raise ValueError(r"must validate the regular expression /^[0-9a-zA-Z\s.:\/\-]+$/") return value @@ -71,6 +75,9 @@ def description_validate_regular_expression(cls, value): @field_validator("displayed_name") def displayed_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z\s_-]+$", value): raise ValueError(r"must validate the regular expression /^[0-9a-zA-Z\s_-]+$/") return value @@ -78,6 +85,9 @@ def displayed_name_validate_regular_expression(cls, value): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z\s.:\/\-]+$", value): raise ValueError(r"must validate the regular expression /^[0-9a-zA-Z\s.:\/\-]+$/") return value @@ -85,12 +95,16 @@ def name_validate_regular_expression(cls, value): @field_validator("url") def url_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z\s.:\/\-]+$", value): raise ValueError(r"must validate the regular expression /^[0-9a-zA-Z\s.:\/\-]+$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -101,8 +115,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/modelserving/src/stackit/modelserving/models/error_message_response.py b/services/modelserving/src/stackit/modelserving/models/error_message_response.py index 381da810f..565ed24ca 100644 --- a/services/modelserving/src/stackit/modelserving/models/error_message_response.py +++ b/services/modelserving/src/stackit/modelserving/models/error_message_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class ErrorMessageResponse(BaseModel): __properties: ClassVar[List[str]] = ["error", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/modelserving/src/stackit/modelserving/models/get_chat_model_response.py b/services/modelserving/src/stackit/modelserving/models/get_chat_model_response.py index 100e28437..8cddfce17 100644 --- a/services/modelserving/src/stackit/modelserving/models/get_chat_model_response.py +++ b/services/modelserving/src/stackit/modelserving/models/get_chat_model_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.modelserving.models.chat_model_details import ChatModelDetails @@ -34,7 +35,8 @@ class GetChatModelResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "model"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/modelserving/src/stackit/modelserving/models/get_embeddings_model_resp.py b/services/modelserving/src/stackit/modelserving/models/get_embeddings_model_resp.py index faf5ccc1e..b86028255 100644 --- a/services/modelserving/src/stackit/modelserving/models/get_embeddings_model_resp.py +++ b/services/modelserving/src/stackit/modelserving/models/get_embeddings_model_resp.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.modelserving.models.embedding_model_details import EmbeddingModelDetails @@ -34,7 +35,8 @@ class GetEmbeddingsModelResp(BaseModel): __properties: ClassVar[List[str]] = ["message", "model"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/modelserving/src/stackit/modelserving/models/get_token_response.py b/services/modelserving/src/stackit/modelserving/models/get_token_response.py index e60afca93..b769b2ddb 100644 --- a/services/modelserving/src/stackit/modelserving/models/get_token_response.py +++ b/services/modelserving/src/stackit/modelserving/models/get_token_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.modelserving.models.token import Token @@ -34,7 +35,8 @@ class GetTokenResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "token"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/modelserving/src/stackit/modelserving/models/list_models_response.py b/services/modelserving/src/stackit/modelserving/models/list_models_response.py index 7a9c5e880..135b6ebb2 100644 --- a/services/modelserving/src/stackit/modelserving/models/list_models_response.py +++ b/services/modelserving/src/stackit/modelserving/models/list_models_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.modelserving.models.model import Model @@ -34,7 +35,8 @@ class ListModelsResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "models"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/modelserving/src/stackit/modelserving/models/list_token_resp.py b/services/modelserving/src/stackit/modelserving/models/list_token_resp.py index 678c57d68..6603373d6 100644 --- a/services/modelserving/src/stackit/modelserving/models/list_token_resp.py +++ b/services/modelserving/src/stackit/modelserving/models/list_token_resp.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.modelserving.models.token import Token @@ -34,7 +35,8 @@ class ListTokenResp(BaseModel): __properties: ClassVar[List[str]] = ["message", "tokens"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/modelserving/src/stackit/modelserving/models/message_response.py b/services/modelserving/src/stackit/modelserving/models/message_response.py index 64e49b5ed..bf0f9a8a7 100644 --- a/services/modelserving/src/stackit/modelserving/models/message_response.py +++ b/services/modelserving/src/stackit/modelserving/models/message_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class MessageResponse(BaseModel): __properties: ClassVar[List[str]] = ["message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/modelserving/src/stackit/modelserving/models/model.py b/services/modelserving/src/stackit/modelserving/models/model.py index 8018d86fe..b2d45ac16 100644 --- a/services/modelserving/src/stackit/modelserving/models/model.py +++ b/services/modelserving/src/stackit/modelserving/models/model.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.modelserving.models.sku import SKU @@ -64,6 +65,9 @@ def category_validate_enum(cls, value): @field_validator("description") def description_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z\s.:\/\-]+$", value): raise ValueError(r"must validate the regular expression /^[0-9a-zA-Z\s.:\/\-]+$/") return value @@ -71,6 +75,9 @@ def description_validate_regular_expression(cls, value): @field_validator("displayed_name") def displayed_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z\s_-]+$", value): raise ValueError(r"must validate the regular expression /^[0-9a-zA-Z\s_-]+$/") return value @@ -83,7 +90,8 @@ def type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -94,8 +102,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/modelserving/src/stackit/modelserving/models/partial_update_token_payload.py b/services/modelserving/src/stackit/modelserving/models/partial_update_token_payload.py index 50315194b..b21f6193e 100644 --- a/services/modelserving/src/stackit/modelserving/models/partial_update_token_payload.py +++ b/services/modelserving/src/stackit/modelserving/models/partial_update_token_payload.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -38,6 +39,9 @@ def description_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z\s.:\/\-]+$", value): raise ValueError(r"must validate the regular expression /^[0-9a-zA-Z\s.:\/\-]+$/") return value @@ -48,12 +52,16 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z\s_-]+$", value): raise ValueError(r"must validate the regular expression /^[0-9a-zA-Z\s_-]+$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -64,8 +72,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/modelserving/src/stackit/modelserving/models/sku.py b/services/modelserving/src/stackit/modelserving/models/sku.py index ef5a56d51..e92ee21a6 100644 --- a/services/modelserving/src/stackit/modelserving/models/sku.py +++ b/services/modelserving/src/stackit/modelserving/models/sku.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -33,7 +34,8 @@ class SKU(BaseModel): __properties: ClassVar[List[str]] = ["description", "id", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/modelserving/src/stackit/modelserving/models/token.py b/services/modelserving/src/stackit/modelserving/models/token.py index 62b055753..fe06db148 100644 --- a/services/modelserving/src/stackit/modelserving/models/token.py +++ b/services/modelserving/src/stackit/modelserving/models/token.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -44,6 +45,9 @@ def description_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z\s.:\/\-]+$", value): raise ValueError(r"must validate the regular expression /^[0-9a-zA-Z\s.:\/\-]+$/") return value @@ -51,6 +55,9 @@ def description_validate_regular_expression(cls, value): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z\s_-]+$", value): raise ValueError(r"must validate the regular expression /^[0-9a-zA-Z\s_-]+$/") return value @@ -76,7 +83,8 @@ def valid_until_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -87,8 +95,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/modelserving/src/stackit/modelserving/models/token_created.py b/services/modelserving/src/stackit/modelserving/models/token_created.py index 3984b297b..4de56d8aa 100644 --- a/services/modelserving/src/stackit/modelserving/models/token_created.py +++ b/services/modelserving/src/stackit/modelserving/models/token_created.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -42,6 +43,9 @@ class TokenCreated(BaseModel): @field_validator("content") def content_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z\s_-]+$", value): raise ValueError(r"must validate the regular expression /^[0-9a-zA-Z\s_-]+$/") return value @@ -52,6 +56,9 @@ def description_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z\s.:\/\-]+$", value): raise ValueError(r"must validate the regular expression /^[0-9a-zA-Z\s.:\/\-]+$/") return value @@ -59,6 +66,9 @@ def description_validate_regular_expression(cls, value): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z\s_-]+$", value): raise ValueError(r"must validate the regular expression /^[0-9a-zA-Z\s_-]+$/") return value @@ -84,7 +94,8 @@ def valid_until_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -95,8 +106,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/modelserving/src/stackit/modelserving/models/update_token_response.py b/services/modelserving/src/stackit/modelserving/models/update_token_response.py index 7a649c5de..fe11beb86 100644 --- a/services/modelserving/src/stackit/modelserving/models/update_token_response.py +++ b/services/modelserving/src/stackit/modelserving/models/update_token_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.modelserving.models.token import Token @@ -34,7 +35,8 @@ class UpdateTokenResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "token"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/CHANGELOG.md b/services/mongodbflex/CHANGELOG.md index 35265b7bd..3c6932071 100644 --- a/services/mongodbflex/CHANGELOG.md +++ b/services/mongodbflex/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.3.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v1.2.3 - **Feature:** client now supports UUID and decimal types - **Bugfix:** timeouts now passed to requests library diff --git a/services/mongodbflex/pyproject.toml b/services/mongodbflex/pyproject.toml index 541cab38f..0a4a1fe84 100644 --- a/services/mongodbflex/pyproject.toml +++ b/services/mongodbflex/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-mongodbflex" -version = "v1.2.3" +version = "v1.3.0" description = "STACKIT MongoDB Service API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/mongodbflex/src/stackit/mongodbflex/api_client.py b/services/mongodbflex/src/stackit/mongodbflex/api_client.py index 6e913bf39..c847e5bc7 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/api_client.py +++ b/services/mongodbflex/src/stackit/mongodbflex/api_client.py @@ -67,6 +67,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -266,7 +267,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -327,25 +328,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -418,6 +414,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/acl.py b/services/mongodbflex/src/stackit/mongodbflex/models/acl.py index 69b633d46..2eda950e6 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/acl.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/acl.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class ACL(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/backup.py b/services/mongodbflex/src/stackit/mongodbflex/models/backup.py index 528239573..fd3078cff 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/backup.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/backup.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -38,7 +39,8 @@ class Backup(BaseModel): __properties: ClassVar[List[str]] = ["endTime", "error", "id", "labels", "name", "options", "size", "startTime"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/backup_schedule.py b/services/mongodbflex/src/stackit/mongodbflex/models/backup_schedule.py index 6fa3ad66d..ceb6ea687 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/backup_schedule.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/backup_schedule.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -43,7 +44,8 @@ class BackupSchedule(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/clone_instance_payload.py b/services/mongodbflex/src/stackit/mongodbflex/models/clone_instance_payload.py index 3d980322e..b814ff22d 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/clone_instance_payload.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/clone_instance_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class CloneInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["instanceId", "timestamp"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/clone_instance_response.py b/services/mongodbflex/src/stackit/mongodbflex/models/clone_instance_response.py index dd17da38d..7e1348c5c 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/clone_instance_response.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/clone_instance_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class CloneInstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["instanceId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/create_instance_payload.py b/services/mongodbflex/src/stackit/mongodbflex/models/create_instance_payload.py index e7846d711..fd439cacb 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/create_instance_payload.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/create_instance_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.acl import ACL @@ -54,7 +55,8 @@ class CreateInstancePayload(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -65,8 +67,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/create_instance_response.py b/services/mongodbflex/src/stackit/mongodbflex/models/create_instance_response.py index 6a68772fb..323b3acfe 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/create_instance_response.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/create_instance_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class CreateInstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/create_user_payload.py b/services/mongodbflex/src/stackit/mongodbflex/models/create_user_payload.py index f03b4e90e..80ed77eb0 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/create_user_payload.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/create_user_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -35,7 +36,8 @@ class CreateUserPayload(BaseModel): __properties: ClassVar[List[str]] = ["database", "roles", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/create_user_response.py b/services/mongodbflex/src/stackit/mongodbflex/models/create_user_response.py index 207b9f66f..8bb0aa6d7 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/create_user_response.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/create_user_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.user import User @@ -33,7 +34,8 @@ class CreateUserResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/data_point.py b/services/mongodbflex/src/stackit/mongodbflex/models/data_point.py index ec9111a87..155662142 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/data_point.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/data_point.py @@ -25,6 +25,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -38,7 +39,8 @@ class DataPoint(BaseModel): __properties: ClassVar[List[str]] = ["timestamp", "value"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/error.py b/services/mongodbflex/src/stackit/mongodbflex/models/error.py index ec6524643..24a74db4b 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/error.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/error.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class Error(BaseModel): __properties: ClassVar[List[str]] = ["code", "fields", "message", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/flavor.py b/services/mongodbflex/src/stackit/mongodbflex/models/flavor.py index 81b637ed0..eb33128b9 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/flavor.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/flavor.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class Flavor(BaseModel): __properties: ClassVar[List[str]] = ["cpu", "description", "id", "memory"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/get_backup_response.py b/services/mongodbflex/src/stackit/mongodbflex/models/get_backup_response.py index afe680462..3a5594f87 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/get_backup_response.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/get_backup_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.backup import Backup @@ -33,7 +34,8 @@ class GetBackupResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/get_user_response.py b/services/mongodbflex/src/stackit/mongodbflex/models/get_user_response.py index 02bfedb5e..e55bbc5d8 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/get_user_response.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/get_user_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.instance_response_user import InstanceResponseUser @@ -33,7 +34,8 @@ class GetUserResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/handlers_instances_slow_queries_response.py b/services/mongodbflex/src/stackit/mongodbflex/models/handlers_instances_slow_queries_response.py index bbde5dbd9..16c6dc4ff 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/handlers_instances_slow_queries_response.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/handlers_instances_slow_queries_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.slow_query import SlowQuery @@ -37,7 +38,8 @@ class HandlersInstancesSlowQueriesResponse(BaseModel): __properties: ClassVar[List[str]] = ["slowQueries"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/handlers_instances_suggested_indexes_response.py b/services/mongodbflex/src/stackit/mongodbflex/models/handlers_instances_suggested_indexes_response.py index 8614abb58..300ddfdc2 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/handlers_instances_suggested_indexes_response.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/handlers_instances_suggested_indexes_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.shape import Shape @@ -42,7 +43,8 @@ class HandlersInstancesSuggestedIndexesResponse(BaseModel): __properties: ClassVar[List[str]] = ["shapes", "suggestedIndexes"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/host.py b/services/mongodbflex/src/stackit/mongodbflex/models/host.py index 136f8ba2f..613a1ad42 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/host.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/host.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.host_metric import HostMetric @@ -34,7 +35,8 @@ class Host(BaseModel): __properties: ClassVar[List[str]] = ["hostMetrics", "id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/host_metric.py b/services/mongodbflex/src/stackit/mongodbflex/models/host_metric.py index 62cf661e8..196d643d3 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/host_metric.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/host_metric.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.data_point import DataPoint @@ -35,7 +36,8 @@ class HostMetric(BaseModel): __properties: ClassVar[List[str]] = ["datapoints", "name", "units"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/instance.py b/services/mongodbflex/src/stackit/mongodbflex/models/instance.py index 51ab4820d..2869d240e 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/instance.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/instance.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.acl import ACL @@ -65,7 +66,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -76,8 +78,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/instance_flavor.py b/services/mongodbflex/src/stackit/mongodbflex/models/instance_flavor.py index 91117dc55..48a8d3151 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/instance_flavor.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/instance_flavor.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -35,7 +36,8 @@ class InstanceFlavor(BaseModel): __properties: ClassVar[List[str]] = ["categories", "cpu", "description", "id", "memory"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/instance_list_instance.py b/services/mongodbflex/src/stackit/mongodbflex/models/instance_list_instance.py index 507579a7f..e4ecd9d07 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/instance_list_instance.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/instance_list_instance.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -43,7 +44,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/instance_response.py b/services/mongodbflex/src/stackit/mongodbflex/models/instance_response.py index 5ed6ae040..e276fa044 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/instance_response.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/instance_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.instance import Instance @@ -33,7 +34,8 @@ class InstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/instance_response_user.py b/services/mongodbflex/src/stackit/mongodbflex/models/instance_response_user.py index 7f883a64b..4cb87f6dd 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/instance_response_user.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/instance_response_user.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -39,7 +40,8 @@ class InstanceResponseUser(BaseModel): __properties: ClassVar[List[str]] = ["database", "host", "id", "port", "roles", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/list_backups_response.py b/services/mongodbflex/src/stackit/mongodbflex/models/list_backups_response.py index 563de3898..f23f770aa 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/list_backups_response.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/list_backups_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.backup import Backup @@ -34,7 +35,8 @@ class ListBackupsResponse(BaseModel): __properties: ClassVar[List[str]] = ["count", "items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/list_flavors_response.py b/services/mongodbflex/src/stackit/mongodbflex/models/list_flavors_response.py index 9822a8279..f4339d256 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/list_flavors_response.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/list_flavors_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.instance_flavor import InstanceFlavor @@ -33,7 +34,8 @@ class ListFlavorsResponse(BaseModel): __properties: ClassVar[List[str]] = ["flavors"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/list_instances_response.py b/services/mongodbflex/src/stackit/mongodbflex/models/list_instances_response.py index 587878ad9..30855eea3 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/list_instances_response.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/list_instances_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.instance_list_instance import InstanceListInstance @@ -34,7 +35,8 @@ class ListInstancesResponse(BaseModel): __properties: ClassVar[List[str]] = ["count", "items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/list_metrics_response.py b/services/mongodbflex/src/stackit/mongodbflex/models/list_metrics_response.py index e7fbe0329..086e866e3 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/list_metrics_response.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/list_metrics_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.host import Host @@ -33,7 +34,8 @@ class ListMetricsResponse(BaseModel): __properties: ClassVar[List[str]] = ["hosts"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/list_restore_jobs_response.py b/services/mongodbflex/src/stackit/mongodbflex/models/list_restore_jobs_response.py index 38074eaaa..449fa6286 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/list_restore_jobs_response.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/list_restore_jobs_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.restore_instance_status import RestoreInstanceStatus @@ -33,7 +34,8 @@ class ListRestoreJobsResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/list_storages_response.py b/services/mongodbflex/src/stackit/mongodbflex/models/list_storages_response.py index 0a90804fd..700616799 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/list_storages_response.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/list_storages_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.storage_range import StorageRange @@ -34,7 +35,8 @@ class ListStoragesResponse(BaseModel): __properties: ClassVar[List[str]] = ["storageClasses", "storageRange"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/list_user.py b/services/mongodbflex/src/stackit/mongodbflex/models/list_user.py index 4eeb4ebc3..a3f2f5351 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/list_user.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/list_user.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class ListUser(BaseModel): __properties: ClassVar[List[str]] = ["id", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/list_users_response.py b/services/mongodbflex/src/stackit/mongodbflex/models/list_users_response.py index 2e859039b..8b556a849 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/list_users_response.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/list_users_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.list_user import ListUser @@ -34,7 +35,8 @@ class ListUsersResponse(BaseModel): __properties: ClassVar[List[str]] = ["count", "items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/list_versions_response.py b/services/mongodbflex/src/stackit/mongodbflex/models/list_versions_response.py index df16cbcaf..630d2616b 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/list_versions_response.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/list_versions_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class ListVersionsResponse(BaseModel): __properties: ClassVar[List[str]] = ["versions"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/mongodbatlas_operation.py b/services/mongodbflex/src/stackit/mongodbflex/models/mongodbatlas_operation.py index e9b1adf2c..14fbcaef0 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/mongodbatlas_operation.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/mongodbatlas_operation.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.mongodbatlas_stats import MongodbatlasStats @@ -37,7 +38,8 @@ class MongodbatlasOperation(BaseModel): __properties: ClassVar[List[str]] = ["predicates", "raw", "stats"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/mongodbatlas_stats.py b/services/mongodbflex/src/stackit/mongodbflex/models/mongodbatlas_stats.py index 02469ba21..77978e3f7 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/mongodbatlas_stats.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/mongodbatlas_stats.py @@ -25,6 +25,7 @@ StrictFloat, StrictInt, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -46,7 +47,8 @@ class MongodbatlasStats(BaseModel): __properties: ClassVar[List[str]] = ["ms", "nReturned", "nScanned", "ts"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -57,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/partial_update_instance_payload.py b/services/mongodbflex/src/stackit/mongodbflex/models/partial_update_instance_payload.py index 60ad4ea3b..1dc71b94c 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/partial_update_instance_payload.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/partial_update_instance_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.acl import ACL @@ -52,7 +53,8 @@ class PartialUpdateInstancePayload(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -63,8 +65,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/partial_update_user_payload.py b/services/mongodbflex/src/stackit/mongodbflex/models/partial_update_user_payload.py index 311b60afd..6a7421a45 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/partial_update_user_payload.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/partial_update_user_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -35,7 +36,8 @@ class PartialUpdateUserPayload(BaseModel): __properties: ClassVar[List[str]] = ["database", "roles"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/restore_instance_payload.py b/services/mongodbflex/src/stackit/mongodbflex/models/restore_instance_payload.py index e5df7c65b..d852fb558 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/restore_instance_payload.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/restore_instance_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class RestoreInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["backupId", "instanceId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/restore_instance_response.py b/services/mongodbflex/src/stackit/mongodbflex/models/restore_instance_response.py index c1189c7a0..ad1be3ea7 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/restore_instance_response.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/restore_instance_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.restore_instance_status import RestoreInstanceStatus @@ -33,7 +34,8 @@ class RestoreInstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/restore_instance_status.py b/services/mongodbflex/src/stackit/mongodbflex/models/restore_instance_status.py index 0ac67b28d..1764021b8 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/restore_instance_status.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/restore_instance_status.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -35,7 +36,8 @@ class RestoreInstanceStatus(BaseModel): __properties: ClassVar[List[str]] = ["backupID", "date", "id", "instanceId", "status"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/shape.py b/services/mongodbflex/src/stackit/mongodbflex/models/shape.py index 98fbda93a..4cb66267b 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/shape.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/shape.py @@ -26,6 +26,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.mongodbatlas_operation import MongodbatlasOperation @@ -58,7 +59,8 @@ class Shape(BaseModel): __properties: ClassVar[List[str]] = ["avgMs", "count", "id", "inefficiencyScore", "namespace", "operations"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -69,8 +71,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/slow_query.py b/services/mongodbflex/src/stackit/mongodbflex/models/slow_query.py index d24ec22d7..c14f19088 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/slow_query.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/slow_query.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class SlowQuery(BaseModel): __properties: ClassVar[List[str]] = ["line", "namespace"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/storage.py b/services/mongodbflex/src/stackit/mongodbflex/models/storage.py index 5f01b0ab2..9375f4405 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/storage.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/storage.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class Storage(BaseModel): __properties: ClassVar[List[str]] = ["class", "size"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/storage_range.py b/services/mongodbflex/src/stackit/mongodbflex/models/storage_range.py index 2d7fbaa32..1c2db164a 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/storage_range.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/storage_range.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class StorageRange(BaseModel): __properties: ClassVar[List[str]] = ["max", "min"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/suggested_index.py b/services/mongodbflex/src/stackit/mongodbflex/models/suggested_index.py index b23a33347..e855218d3 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/suggested_index.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/suggested_index.py @@ -26,6 +26,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -50,7 +51,8 @@ class SuggestedIndex(BaseModel): __properties: ClassVar[List[str]] = ["id", "impact", "index", "namespace", "weight"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -61,8 +63,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/update_backup_schedule_payload.py b/services/mongodbflex/src/stackit/mongodbflex/models/update_backup_schedule_payload.py index eae84e23f..bd92099e1 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/update_backup_schedule_payload.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/update_backup_schedule_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -43,7 +44,8 @@ class UpdateBackupSchedulePayload(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/update_instance_payload.py b/services/mongodbflex/src/stackit/mongodbflex/models/update_instance_payload.py index 7477585b6..fbcc101a0 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/update_instance_payload.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/update_instance_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.acl import ACL @@ -52,7 +53,8 @@ class UpdateInstancePayload(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -63,8 +65,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/update_instance_response.py b/services/mongodbflex/src/stackit/mongodbflex/models/update_instance_response.py index e64230828..a11a69f8d 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/update_instance_response.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/update_instance_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.mongodbflex.models.instance import Instance @@ -33,7 +34,8 @@ class UpdateInstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/update_user_payload.py b/services/mongodbflex/src/stackit/mongodbflex/models/update_user_payload.py index be3239525..ee826b1be 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/update_user_payload.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/update_user_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class UpdateUserPayload(BaseModel): __properties: ClassVar[List[str]] = ["database", "roles"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/mongodbflex/src/stackit/mongodbflex/models/user.py b/services/mongodbflex/src/stackit/mongodbflex/models/user.py index 23f45e68d..236d56ca8 100644 --- a/services/mongodbflex/src/stackit/mongodbflex/models/user.py +++ b/services/mongodbflex/src/stackit/mongodbflex/models/user.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -41,7 +42,8 @@ class User(BaseModel): __properties: ClassVar[List[str]] = ["database", "host", "id", "password", "port", "roles", "uri", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -52,8 +54,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/CHANGELOG.md b/services/objectstorage/CHANGELOG.md index eba713a5a..8e27d0eb3 100644 --- a/services/objectstorage/CHANGELOG.md +++ b/services/objectstorage/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.4.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v1.3.0 - **Feature:** New models: `SetDefaultRetentionPayload`, `GetCredentialsGroupResponse`, `DeleteDefaultRetentionResponse`, `DefaultRetentionResponse`, `CredentialsGroupExtended`, `ComplianceLockResponse` - **Feature:** New enum type `RetentionMode` diff --git a/services/objectstorage/pyproject.toml b/services/objectstorage/pyproject.toml index 40bf61993..e2a6227ef 100644 --- a/services/objectstorage/pyproject.toml +++ b/services/objectstorage/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-objectstorage" -version = "v1.3.0" +version = "v1.4.0" description = "STACKIT Object Storage API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/objectstorage/src/stackit/objectstorage/api_client.py b/services/objectstorage/src/stackit/objectstorage/api_client.py index 0133d64f3..a0eea488c 100644 --- a/services/objectstorage/src/stackit/objectstorage/api_client.py +++ b/services/objectstorage/src/stackit/objectstorage/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/objectstorage/src/stackit/objectstorage/models/access_key.py b/services/objectstorage/src/stackit/objectstorage/models/access_key.py index 495316bde..69780a9f6 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/access_key.py +++ b/services/objectstorage/src/stackit/objectstorage/models/access_key.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class AccessKey(BaseModel): __properties: ClassVar[List[str]] = ["displayName", "expires", "keyId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/bucket.py b/services/objectstorage/src/stackit/objectstorage/models/bucket.py index 632bd707d..23d5c58c0 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/bucket.py +++ b/services/objectstorage/src/stackit/objectstorage/models/bucket.py @@ -24,6 +24,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -44,7 +45,8 @@ class Bucket(BaseModel): __properties: ClassVar[List[str]] = ["name", "objectLockEnabled", "region", "urlPathStyle", "urlVirtualHostedStyle"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/compliance_lock_response.py b/services/objectstorage/src/stackit/objectstorage/models/compliance_lock_response.py index f628b9c37..974220d93 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/compliance_lock_response.py +++ b/services/objectstorage/src/stackit/objectstorage/models/compliance_lock_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class ComplianceLockResponse(BaseModel): __properties: ClassVar[List[str]] = ["maxRetentionDays", "project"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/create_access_key_payload.py b/services/objectstorage/src/stackit/objectstorage/models/create_access_key_payload.py index 521f6d0d3..5eb938d19 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/create_access_key_payload.py +++ b/services/objectstorage/src/stackit/objectstorage/models/create_access_key_payload.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -45,7 +46,8 @@ def expires_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +58,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/create_access_key_response.py b/services/objectstorage/src/stackit/objectstorage/models/create_access_key_response.py index bc49da76c..04c7690d2 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/create_access_key_response.py +++ b/services/objectstorage/src/stackit/objectstorage/models/create_access_key_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -37,7 +38,8 @@ class CreateAccessKeyResponse(BaseModel): __properties: ClassVar[List[str]] = ["accessKey", "displayName", "expires", "keyId", "project", "secretAccessKey"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/create_bucket_response.py b/services/objectstorage/src/stackit/objectstorage/models/create_bucket_response.py index e2ffc02f9..46d8ba7f0 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/create_bucket_response.py +++ b/services/objectstorage/src/stackit/objectstorage/models/create_bucket_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class CreateBucketResponse(BaseModel): __properties: ClassVar[List[str]] = ["bucket", "project"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/create_credentials_group_payload.py b/services/objectstorage/src/stackit/objectstorage/models/create_credentials_group_payload.py index 0d106d562..f15b6b923 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/create_credentials_group_payload.py +++ b/services/objectstorage/src/stackit/objectstorage/models/create_credentials_group_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -32,7 +33,8 @@ class CreateCredentialsGroupPayload(BaseModel): __properties: ClassVar[List[str]] = ["displayName"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/create_credentials_group_response.py b/services/objectstorage/src/stackit/objectstorage/models/create_credentials_group_response.py index 28357d6a0..8f5a00e2e 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/create_credentials_group_response.py +++ b/services/objectstorage/src/stackit/objectstorage/models/create_credentials_group_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.objectstorage.models.credentials_group import CredentialsGroup @@ -33,7 +34,8 @@ class CreateCredentialsGroupResponse(BaseModel): __properties: ClassVar[List[str]] = ["credentialsGroup", "project"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/credentials_group.py b/services/objectstorage/src/stackit/objectstorage/models/credentials_group.py index 31e0c6988..39b3fff93 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/credentials_group.py +++ b/services/objectstorage/src/stackit/objectstorage/models/credentials_group.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class CredentialsGroup(BaseModel): __properties: ClassVar[List[str]] = ["credentialsGroupId", "displayName", "urn"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/credentials_group_extended.py b/services/objectstorage/src/stackit/objectstorage/models/credentials_group_extended.py index 80dbb4308..a9b4554d3 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/credentials_group_extended.py +++ b/services/objectstorage/src/stackit/objectstorage/models/credentials_group_extended.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -33,7 +34,8 @@ class CredentialsGroupExtended(BaseModel): __properties: ClassVar[List[str]] = ["credentialsGroupId", "displayName", "urn", "userUrn"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/default_retention_response.py b/services/objectstorage/src/stackit/objectstorage/models/default_retention_response.py index c9346d084..00a27628a 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/default_retention_response.py +++ b/services/objectstorage/src/stackit/objectstorage/models/default_retention_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.objectstorage.models.retention_mode import RetentionMode @@ -35,7 +36,8 @@ class DefaultRetentionResponse(BaseModel): __properties: ClassVar[List[str]] = ["bucket", "days", "mode", "project"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/delete_access_key_response.py b/services/objectstorage/src/stackit/objectstorage/models/delete_access_key_response.py index d99f2ee6d..6fd69ded5 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/delete_access_key_response.py +++ b/services/objectstorage/src/stackit/objectstorage/models/delete_access_key_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -33,7 +34,8 @@ class DeleteAccessKeyResponse(BaseModel): __properties: ClassVar[List[str]] = ["keyId", "project"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/delete_bucket_response.py b/services/objectstorage/src/stackit/objectstorage/models/delete_bucket_response.py index f0021c509..20c747f2e 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/delete_bucket_response.py +++ b/services/objectstorage/src/stackit/objectstorage/models/delete_bucket_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class DeleteBucketResponse(BaseModel): __properties: ClassVar[List[str]] = ["bucket", "project"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/delete_credentials_group_response.py b/services/objectstorage/src/stackit/objectstorage/models/delete_credentials_group_response.py index 9fe24e222..a42be15e7 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/delete_credentials_group_response.py +++ b/services/objectstorage/src/stackit/objectstorage/models/delete_credentials_group_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class DeleteCredentialsGroupResponse(BaseModel): __properties: ClassVar[List[str]] = ["credentialsGroupId", "project"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/delete_default_retention_response.py b/services/objectstorage/src/stackit/objectstorage/models/delete_default_retention_response.py index 2c97baade..0565d1ca8 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/delete_default_retention_response.py +++ b/services/objectstorage/src/stackit/objectstorage/models/delete_default_retention_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class DeleteDefaultRetentionResponse(BaseModel): __properties: ClassVar[List[str]] = ["bucket", "project"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/detailed_error.py b/services/objectstorage/src/stackit/objectstorage/models/detailed_error.py index 41d719031..12ee6fc1a 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/detailed_error.py +++ b/services/objectstorage/src/stackit/objectstorage/models/detailed_error.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class DetailedError(BaseModel): __properties: ClassVar[List[str]] = ["key", "msg"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/error_message.py b/services/objectstorage/src/stackit/objectstorage/models/error_message.py index 800cdcac6..9c26038bf 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/error_message.py +++ b/services/objectstorage/src/stackit/objectstorage/models/error_message.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.objectstorage.models.detailed_error import DetailedError @@ -32,7 +33,8 @@ class ErrorMessage(BaseModel): __properties: ClassVar[List[str]] = ["detail"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/get_bucket_response.py b/services/objectstorage/src/stackit/objectstorage/models/get_bucket_response.py index 7a8a47dfd..e25fa096a 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/get_bucket_response.py +++ b/services/objectstorage/src/stackit/objectstorage/models/get_bucket_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.objectstorage.models.bucket import Bucket @@ -33,7 +34,8 @@ class GetBucketResponse(BaseModel): __properties: ClassVar[List[str]] = ["bucket", "project"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/get_credentials_group_response.py b/services/objectstorage/src/stackit/objectstorage/models/get_credentials_group_response.py index 1fc94f1d1..6bf65fd43 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/get_credentials_group_response.py +++ b/services/objectstorage/src/stackit/objectstorage/models/get_credentials_group_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.objectstorage.models.credentials_group_extended import ( @@ -35,7 +36,8 @@ class GetCredentialsGroupResponse(BaseModel): __properties: ClassVar[List[str]] = ["credentialsGroup", "project"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/http_validation_error.py b/services/objectstorage/src/stackit/objectstorage/models/http_validation_error.py index 5593cafb1..808ca30f5 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/http_validation_error.py +++ b/services/objectstorage/src/stackit/objectstorage/models/http_validation_error.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.objectstorage.models.validation_error import ValidationError @@ -32,7 +33,8 @@ class HTTPValidationError(BaseModel): __properties: ClassVar[List[str]] = ["detail"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/list_access_keys_response.py b/services/objectstorage/src/stackit/objectstorage/models/list_access_keys_response.py index 16735896e..7383385a0 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/list_access_keys_response.py +++ b/services/objectstorage/src/stackit/objectstorage/models/list_access_keys_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.objectstorage.models.access_key import AccessKey @@ -33,7 +34,8 @@ class ListAccessKeysResponse(BaseModel): __properties: ClassVar[List[str]] = ["accessKeys", "project"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/list_buckets_response.py b/services/objectstorage/src/stackit/objectstorage/models/list_buckets_response.py index f3b255788..0394ca0d2 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/list_buckets_response.py +++ b/services/objectstorage/src/stackit/objectstorage/models/list_buckets_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.objectstorage.models.bucket import Bucket @@ -33,7 +34,8 @@ class ListBucketsResponse(BaseModel): __properties: ClassVar[List[str]] = ["buckets", "project"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/list_credentials_groups_response.py b/services/objectstorage/src/stackit/objectstorage/models/list_credentials_groups_response.py index d8ed3bd55..d32ba0e89 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/list_credentials_groups_response.py +++ b/services/objectstorage/src/stackit/objectstorage/models/list_credentials_groups_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.objectstorage.models.credentials_group import CredentialsGroup @@ -33,7 +34,8 @@ class ListCredentialsGroupsResponse(BaseModel): __properties: ClassVar[List[str]] = ["credentialsGroups", "project"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/project_status.py b/services/objectstorage/src/stackit/objectstorage/models/project_status.py index 9570ba9f3..30308e410 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/project_status.py +++ b/services/objectstorage/src/stackit/objectstorage/models/project_status.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.objectstorage.models.project_scope import ProjectScope @@ -33,7 +34,8 @@ class ProjectStatus(BaseModel): __properties: ClassVar[List[str]] = ["project", "scope"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/set_default_retention_payload.py b/services/objectstorage/src/stackit/objectstorage/models/set_default_retention_payload.py index 8105f5526..a331ac4f2 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/set_default_retention_payload.py +++ b/services/objectstorage/src/stackit/objectstorage/models/set_default_retention_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.objectstorage.models.retention_mode import RetentionMode @@ -33,7 +34,8 @@ class SetDefaultRetentionPayload(BaseModel): __properties: ClassVar[List[str]] = ["days", "mode"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/objectstorage/src/stackit/objectstorage/models/validation_error.py b/services/objectstorage/src/stackit/objectstorage/models/validation_error.py index fc6bc8509..b698802e3 100644 --- a/services/objectstorage/src/stackit/objectstorage/models/validation_error.py +++ b/services/objectstorage/src/stackit/objectstorage/models/validation_error.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.objectstorage.models.location_inner import LocationInner @@ -34,7 +35,8 @@ class ValidationError(BaseModel): __properties: ClassVar[List[str]] = ["loc", "msg", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/CHANGELOG.md b/services/observability/CHANGELOG.md index b2437ed52..2c794b1fb 100644 --- a/services/observability/CHANGELOG.md +++ b/services/observability/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.15.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.14.0 - **Feature:** Add attribute `otlp_http_logs_url` to `InstanceSensitiveData` model class diff --git a/services/observability/pyproject.toml b/services/observability/pyproject.toml index 3a7875758..cfc57b836 100644 --- a/services/observability/pyproject.toml +++ b/services/observability/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-observability" -version = "v0.14.0" +version = "v0.15.0" description = "STACKIT Observability API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/observability/src/stackit/observability/api_client.py b/services/observability/src/stackit/observability/api_client.py index 03da1bfa3..eb21c82ad 100644 --- a/services/observability/src/stackit/observability/api_client.py +++ b/services/observability/src/stackit/observability/api_client.py @@ -67,6 +67,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -266,7 +267,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -327,25 +328,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -418,6 +414,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/observability/src/stackit/observability/models/alert.py b/services/observability/src/stackit/observability/models/alert.py index ad5626a5e..f44c7a6e0 100644 --- a/services/observability/src/stackit/observability/models/alert.py +++ b/services/observability/src/stackit/observability/models/alert.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.observability.models.inhibit_rules import InhibitRules @@ -39,7 +40,8 @@ class Alert(BaseModel): __properties: ClassVar[List[str]] = ["global", "inhibitRules", "receivers", "route"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/alert_config_receivers_response.py b/services/observability/src/stackit/observability/models/alert_config_receivers_response.py index 899b80f56..654a99c0f 100644 --- a/services/observability/src/stackit/observability/models/alert_config_receivers_response.py +++ b/services/observability/src/stackit/observability/models/alert_config_receivers_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.receivers import Receivers @@ -34,7 +35,8 @@ class AlertConfigReceiversResponse(BaseModel): __properties: ClassVar[List[str]] = ["data", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/alert_config_route_response.py b/services/observability/src/stackit/observability/models/alert_config_route_response.py index 2e5eceece..2d91ede03 100644 --- a/services/observability/src/stackit/observability/models/alert_config_route_response.py +++ b/services/observability/src/stackit/observability/models/alert_config_route_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.route import Route @@ -34,7 +35,8 @@ class AlertConfigRouteResponse(BaseModel): __properties: ClassVar[List[str]] = ["data", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/alert_group.py b/services/observability/src/stackit/observability/models/alert_group.py index 17914b1f1..efaf1ec93 100644 --- a/services/observability/src/stackit/observability/models/alert_group.py +++ b/services/observability/src/stackit/observability/models/alert_group.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.alert_rule_record import AlertRuleRecord @@ -35,7 +36,8 @@ class AlertGroup(BaseModel): __properties: ClassVar[List[str]] = ["interval", "name", "rules"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/alert_group_response.py b/services/observability/src/stackit/observability/models/alert_group_response.py index f2069074b..7ba22c1b2 100644 --- a/services/observability/src/stackit/observability/models/alert_group_response.py +++ b/services/observability/src/stackit/observability/models/alert_group_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.alert_group import AlertGroup @@ -34,7 +35,8 @@ class AlertGroupResponse(BaseModel): __properties: ClassVar[List[str]] = ["data", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/alert_groups_response.py b/services/observability/src/stackit/observability/models/alert_groups_response.py index f4380286a..977ecabae 100644 --- a/services/observability/src/stackit/observability/models/alert_groups_response.py +++ b/services/observability/src/stackit/observability/models/alert_groups_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.alert_group import AlertGroup @@ -34,7 +35,8 @@ class AlertGroupsResponse(BaseModel): __properties: ClassVar[List[str]] = ["data", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/alert_record.py b/services/observability/src/stackit/observability/models/alert_record.py index a5a5b4cbd..eac7299d7 100644 --- a/services/observability/src/stackit/observability/models/alert_record.py +++ b/services/observability/src/stackit/observability/models/alert_record.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,7 +34,8 @@ class AlertRecord(BaseModel): __properties: ClassVar[List[str]] = ["expr", "labels", "record"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/alert_record_response.py b/services/observability/src/stackit/observability/models/alert_record_response.py index fffd02284..6fc91ac1f 100644 --- a/services/observability/src/stackit/observability/models/alert_record_response.py +++ b/services/observability/src/stackit/observability/models/alert_record_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.alert_record import AlertRecord @@ -34,7 +35,8 @@ class AlertRecordResponse(BaseModel): __properties: ClassVar[List[str]] = ["data", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/alert_records_response.py b/services/observability/src/stackit/observability/models/alert_records_response.py index dc973ed57..3db7b7f85 100644 --- a/services/observability/src/stackit/observability/models/alert_records_response.py +++ b/services/observability/src/stackit/observability/models/alert_records_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.alert_record import AlertRecord @@ -34,7 +35,8 @@ class AlertRecordsResponse(BaseModel): __properties: ClassVar[List[str]] = ["data", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/alert_rule.py b/services/observability/src/stackit/observability/models/alert_rule.py index 257aeed93..b15ab1df2 100644 --- a/services/observability/src/stackit/observability/models/alert_rule.py +++ b/services/observability/src/stackit/observability/models/alert_rule.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -35,7 +36,8 @@ class AlertRule(BaseModel): __properties: ClassVar[List[str]] = ["alert", "annotations", "expr", "for", "labels"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/alert_rule_record.py b/services/observability/src/stackit/observability/models/alert_rule_record.py index cc652cb6a..ca79b9b2f 100644 --- a/services/observability/src/stackit/observability/models/alert_rule_record.py +++ b/services/observability/src/stackit/observability/models/alert_rule_record.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -36,7 +37,8 @@ class AlertRuleRecord(BaseModel): __properties: ClassVar[List[str]] = ["alert", "annotations", "expr", "for", "labels", "record"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/alert_rule_response.py b/services/observability/src/stackit/observability/models/alert_rule_response.py index b2a1aaefd..ba42ad344 100644 --- a/services/observability/src/stackit/observability/models/alert_rule_response.py +++ b/services/observability/src/stackit/observability/models/alert_rule_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.alert_rule import AlertRule @@ -34,7 +35,8 @@ class AlertRuleResponse(BaseModel): __properties: ClassVar[List[str]] = ["data", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/alert_rules_response.py b/services/observability/src/stackit/observability/models/alert_rules_response.py index 78016637b..d627574df 100644 --- a/services/observability/src/stackit/observability/models/alert_rules_response.py +++ b/services/observability/src/stackit/observability/models/alert_rules_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.alert_rule import AlertRule @@ -34,7 +35,8 @@ class AlertRulesResponse(BaseModel): __properties: ClassVar[List[str]] = ["data", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/backup_response.py b/services/observability/src/stackit/observability/models/backup_response.py index a82cc4a07..d95dc3621 100644 --- a/services/observability/src/stackit/observability/models/backup_response.py +++ b/services/observability/src/stackit/observability/models/backup_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -41,7 +42,8 @@ class BackupResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -52,8 +54,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/backup_retention_response.py b/services/observability/src/stackit/observability/models/backup_retention_response.py index 2366d1d76..4f42c1a2c 100644 --- a/services/observability/src/stackit/observability/models/backup_retention_response.py +++ b/services/observability/src/stackit/observability/models/backup_retention_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -49,7 +50,8 @@ class BackupRetentionResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +62,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/backup_schedule.py b/services/observability/src/stackit/observability/models/backup_schedule.py index 4887c97d4..8113a645e 100644 --- a/services/observability/src/stackit/observability/models/backup_schedule.py +++ b/services/observability/src/stackit/observability/models/backup_schedule.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,7 +34,8 @@ class BackupSchedule(BaseModel): __properties: ClassVar[List[str]] = ["schedule", "scheduleId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/backup_schedule_post_response.py b/services/observability/src/stackit/observability/models/backup_schedule_post_response.py index 537b01001..0f1c3ad4d 100644 --- a/services/observability/src/stackit/observability/models/backup_schedule_post_response.py +++ b/services/observability/src/stackit/observability/models/backup_schedule_post_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -32,7 +33,8 @@ class BackupSchedulePostResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "schedule"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/backup_schedule_response.py b/services/observability/src/stackit/observability/models/backup_schedule_response.py index 9bb9fff44..ddf8dbc6b 100644 --- a/services/observability/src/stackit/observability/models/backup_schedule_response.py +++ b/services/observability/src/stackit/observability/models/backup_schedule_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.backup_schedule import BackupSchedule @@ -49,7 +50,8 @@ class BackupScheduleResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +62,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/basic_auth.py b/services/observability/src/stackit/observability/models/basic_auth.py index 1462ce81c..abb50640a 100644 --- a/services/observability/src/stackit/observability/models/basic_auth.py +++ b/services/observability/src/stackit/observability/models/basic_auth.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -32,7 +33,8 @@ class BasicAuth(BaseModel): __properties: ClassVar[List[str]] = ["password", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/cert_check_child_response.py b/services/observability/src/stackit/observability/models/cert_check_child_response.py index 5f6f5635a..63ddba1ce 100644 --- a/services/observability/src/stackit/observability/models/cert_check_child_response.py +++ b/services/observability/src/stackit/observability/models/cert_check_child_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -32,7 +33,8 @@ class CertCheckChildResponse(BaseModel): __properties: ClassVar[List[str]] = ["id", "source"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/cert_check_response.py b/services/observability/src/stackit/observability/models/cert_check_response.py index 8284ec57f..5e7cd6272 100644 --- a/services/observability/src/stackit/observability/models/cert_check_response.py +++ b/services/observability/src/stackit/observability/models/cert_check_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.cert_check_child_response import ( @@ -37,7 +38,8 @@ class CertCheckResponse(BaseModel): __properties: ClassVar[List[str]] = ["certCheck", "certChecks", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_alert_config_receiver_payload.py b/services/observability/src/stackit/observability/models/create_alert_config_receiver_payload.py index 82f0d2ce1..fa7b5b059 100644 --- a/services/observability/src/stackit/observability/models/create_alert_config_receiver_payload.py +++ b/services/observability/src/stackit/observability/models/create_alert_config_receiver_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.create_alert_config_receiver_payload_email_configs_inner import ( @@ -52,7 +53,8 @@ class CreateAlertConfigReceiverPayload(BaseModel): __properties: ClassVar[List[str]] = ["emailConfigs", "name", "opsgenieConfigs", "webHookConfigs"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -63,8 +65,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_alert_config_receiver_payload_email_configs_inner.py b/services/observability/src/stackit/observability/models/create_alert_config_receiver_payload_email_configs_inner.py index 42d527e94..485b07b7f 100644 --- a/services/observability/src/stackit/observability/models/create_alert_config_receiver_payload_email_configs_inner.py +++ b/services/observability/src/stackit/observability/models/create_alert_config_receiver_payload_email_configs_inner.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -65,7 +66,8 @@ class CreateAlertConfigReceiverPayloadEmailConfigsInner(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -76,8 +78,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_alert_config_receiver_payload_opsgenie_configs_inner.py b/services/observability/src/stackit/observability/models/create_alert_config_receiver_payload_opsgenie_configs_inner.py index 704cdf28f..e839fb9de 100644 --- a/services/observability/src/stackit/observability/models/create_alert_config_receiver_payload_opsgenie_configs_inner.py +++ b/services/observability/src/stackit/observability/models/create_alert_config_receiver_payload_opsgenie_configs_inner.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -49,7 +50,8 @@ class CreateAlertConfigReceiverPayloadOpsgenieConfigsInner(BaseModel): __properties: ClassVar[List[str]] = ["apiKey", "apiUrl", "priority", "sendResolved", "tags"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +62,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_alert_config_receiver_payload_web_hook_configs_inner.py b/services/observability/src/stackit/observability/models/create_alert_config_receiver_payload_web_hook_configs_inner.py index 96c7a9bb8..6b1db1c1c 100644 --- a/services/observability/src/stackit/observability/models/create_alert_config_receiver_payload_web_hook_configs_inner.py +++ b/services/observability/src/stackit/observability/models/create_alert_config_receiver_payload_web_hook_configs_inner.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -47,7 +48,8 @@ class CreateAlertConfigReceiverPayloadWebHookConfigsInner(BaseModel): __properties: ClassVar[List[str]] = ["googleChat", "msTeams", "sendResolved", "url"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -58,8 +60,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_alert_config_route_payload.py b/services/observability/src/stackit/observability/models/create_alert_config_route_payload.py index ec758afb7..98c41371a 100644 --- a/services/observability/src/stackit/observability/models/create_alert_config_route_payload.py +++ b/services/observability/src/stackit/observability/models/create_alert_config_route_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.create_alert_config_route_payload_routes_inner import ( @@ -89,7 +90,8 @@ class CreateAlertConfigRoutePayload(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -100,8 +102,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_alert_config_route_payload_routes_inner.py b/services/observability/src/stackit/observability/models/create_alert_config_route_payload_routes_inner.py index 12201bfaf..0858b7d87 100644 --- a/services/observability/src/stackit/observability/models/create_alert_config_route_payload_routes_inner.py +++ b/services/observability/src/stackit/observability/models/create_alert_config_route_payload_routes_inner.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -67,7 +68,8 @@ class CreateAlertConfigRoutePayloadRoutesInner(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -78,8 +80,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_alert_record_payload.py b/services/observability/src/stackit/observability/models/create_alert_record_payload.py index 25e0dd63b..bd22d59b8 100644 --- a/services/observability/src/stackit/observability/models/create_alert_record_payload.py +++ b/services/observability/src/stackit/observability/models/create_alert_record_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -40,7 +41,8 @@ class CreateAlertRecordPayload(BaseModel): __properties: ClassVar[List[str]] = ["expr", "labels", "record"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_alertgroups_payload.py b/services/observability/src/stackit/observability/models/create_alertgroups_payload.py index ca0df7006..f63b044ac 100644 --- a/services/observability/src/stackit/observability/models/create_alertgroups_payload.py +++ b/services/observability/src/stackit/observability/models/create_alertgroups_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.update_alertgroups_request_inner_rules_inner import ( @@ -42,7 +43,8 @@ class CreateAlertgroupsPayload(BaseModel): __properties: ClassVar[List[str]] = ["interval", "name", "rules"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_alertrules_payload.py b/services/observability/src/stackit/observability/models/create_alertrules_payload.py index b4a0bdcd8..3c504517b 100644 --- a/services/observability/src/stackit/observability/models/create_alertrules_payload.py +++ b/services/observability/src/stackit/observability/models/create_alertrules_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -49,7 +50,8 @@ class CreateAlertrulesPayload(BaseModel): __properties: ClassVar[List[str]] = ["alert", "annotations", "expr", "for", "labels"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +62,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_backup_schedule_payload.py b/services/observability/src/stackit/observability/models/create_backup_schedule_payload.py index f9722b949..f42b7db75 100644 --- a/services/observability/src/stackit/observability/models/create_backup_schedule_payload.py +++ b/services/observability/src/stackit/observability/models/create_backup_schedule_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,7 +34,8 @@ class CreateBackupSchedulePayload(BaseModel): __properties: ClassVar[List[str]] = ["schedule"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_cert_check_payload.py b/services/observability/src/stackit/observability/models/create_cert_check_payload.py index d7b9228e5..9c5460b09 100644 --- a/services/observability/src/stackit/observability/models/create_cert_check_payload.py +++ b/services/observability/src/stackit/observability/models/create_cert_check_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -31,7 +32,8 @@ class CreateCertCheckPayload(BaseModel): __properties: ClassVar[List[str]] = ["source"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_credentials_payload.py b/services/observability/src/stackit/observability/models/create_credentials_payload.py index bb85c9fd2..cc0091518 100644 --- a/services/observability/src/stackit/observability/models/create_credentials_payload.py +++ b/services/observability/src/stackit/observability/models/create_credentials_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,7 +34,8 @@ class CreateCredentialsPayload(BaseModel): __properties: ClassVar[List[str]] = ["description"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_credentials_response.py b/services/observability/src/stackit/observability/models/create_credentials_response.py index f13ac87d9..66a297063 100644 --- a/services/observability/src/stackit/observability/models/create_credentials_response.py +++ b/services/observability/src/stackit/observability/models/create_credentials_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.credentials import Credentials @@ -34,7 +35,8 @@ class CreateCredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["credentials", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_elasticsearch_check_payload.py b/services/observability/src/stackit/observability/models/create_elasticsearch_check_payload.py index 4745f5875..11dd51da0 100644 --- a/services/observability/src/stackit/observability/models/create_elasticsearch_check_payload.py +++ b/services/observability/src/stackit/observability/models/create_elasticsearch_check_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,7 +34,8 @@ class CreateElasticsearchCheckPayload(BaseModel): __properties: ClassVar[List[str]] = ["password", "server", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_http_check_payload.py b/services/observability/src/stackit/observability/models/create_http_check_payload.py index be4441e92..70effea2e 100644 --- a/services/observability/src/stackit/observability/models/create_http_check_payload.py +++ b/services/observability/src/stackit/observability/models/create_http_check_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -31,7 +32,8 @@ class CreateHttpCheckPayload(BaseModel): __properties: ClassVar[List[str]] = ["url"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_instance_payload.py b/services/observability/src/stackit/observability/models/create_instance_payload.py index 144926399..922d1a26b 100644 --- a/services/observability/src/stackit/observability/models/create_instance_payload.py +++ b/services/observability/src/stackit/observability/models/create_instance_payload.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -46,7 +47,8 @@ class CreateInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["grafanaAdminEnabled", "name", "parameter", "planId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -57,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_instance_response.py b/services/observability/src/stackit/observability/models/create_instance_response.py index 1b42eda40..d535e9132 100644 --- a/services/observability/src/stackit/observability/models/create_instance_response.py +++ b/services/observability/src/stackit/observability/models/create_instance_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,7 +34,8 @@ class CreateInstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["dashboardUrl", "instanceId", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_logs_alertgroups_payload.py b/services/observability/src/stackit/observability/models/create_logs_alertgroups_payload.py index 4a20f1015..94afe33d9 100644 --- a/services/observability/src/stackit/observability/models/create_logs_alertgroups_payload.py +++ b/services/observability/src/stackit/observability/models/create_logs_alertgroups_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.create_logs_alertgroups_payload_rules_inner import ( @@ -42,7 +43,8 @@ class CreateLogsAlertgroupsPayload(BaseModel): __properties: ClassVar[List[str]] = ["interval", "name", "rules"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_logs_alertgroups_payload_rules_inner.py b/services/observability/src/stackit/observability/models/create_logs_alertgroups_payload_rules_inner.py index 3dd654b85..7ebc24382 100644 --- a/services/observability/src/stackit/observability/models/create_logs_alertgroups_payload_rules_inner.py +++ b/services/observability/src/stackit/observability/models/create_logs_alertgroups_payload_rules_inner.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -54,7 +55,8 @@ class CreateLogsAlertgroupsPayloadRulesInner(BaseModel): __properties: ClassVar[List[str]] = ["alert", "annotations", "expr", "for", "labels", "record"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -65,8 +67,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_mongodb_check_payload.py b/services/observability/src/stackit/observability/models/create_mongodb_check_payload.py index a3258aaaf..17e4e280e 100644 --- a/services/observability/src/stackit/observability/models/create_mongodb_check_payload.py +++ b/services/observability/src/stackit/observability/models/create_mongodb_check_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -31,7 +32,8 @@ class CreateMongodbCheckPayload(BaseModel): __properties: ClassVar[List[str]] = ["server"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_mysql_check_payload.py b/services/observability/src/stackit/observability/models/create_mysql_check_payload.py index aacdd4a05..990d7d1bf 100644 --- a/services/observability/src/stackit/observability/models/create_mysql_check_payload.py +++ b/services/observability/src/stackit/observability/models/create_mysql_check_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -31,7 +32,8 @@ class CreateMysqlCheckPayload(BaseModel): __properties: ClassVar[List[str]] = ["server"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_network_check_payload.py b/services/observability/src/stackit/observability/models/create_network_check_payload.py index 749c54da5..7ed8af960 100644 --- a/services/observability/src/stackit/observability/models/create_network_check_payload.py +++ b/services/observability/src/stackit/observability/models/create_network_check_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -31,7 +32,8 @@ class CreateNetworkCheckPayload(BaseModel): __properties: ClassVar[List[str]] = ["address"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_ping_check_payload.py b/services/observability/src/stackit/observability/models/create_ping_check_payload.py index 4d94985a8..ad9c49bf8 100644 --- a/services/observability/src/stackit/observability/models/create_ping_check_payload.py +++ b/services/observability/src/stackit/observability/models/create_ping_check_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -31,7 +32,8 @@ class CreatePingCheckPayload(BaseModel): __properties: ClassVar[List[str]] = ["url"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_postgresql_check_payload.py b/services/observability/src/stackit/observability/models/create_postgresql_check_payload.py index 3ba27f306..18e34829d 100644 --- a/services/observability/src/stackit/observability/models/create_postgresql_check_payload.py +++ b/services/observability/src/stackit/observability/models/create_postgresql_check_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -31,7 +32,8 @@ class CreatePostgresqlCheckPayload(BaseModel): __properties: ClassVar[List[str]] = ["address"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_rabbitmq_check_payload.py b/services/observability/src/stackit/observability/models/create_rabbitmq_check_payload.py index 8bbbea7c0..efab8c5f0 100644 --- a/services/observability/src/stackit/observability/models/create_rabbitmq_check_payload.py +++ b/services/observability/src/stackit/observability/models/create_rabbitmq_check_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,7 +34,8 @@ class CreateRabbitmqCheckPayload(BaseModel): __properties: ClassVar[List[str]] = ["password", "url", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_redis_check_payload.py b/services/observability/src/stackit/observability/models/create_redis_check_payload.py index f8530b6ce..e62976a1d 100644 --- a/services/observability/src/stackit/observability/models/create_redis_check_payload.py +++ b/services/observability/src/stackit/observability/models/create_redis_check_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,7 +34,8 @@ class CreateRedisCheckPayload(BaseModel): __properties: ClassVar[List[str]] = ["password", "server", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/create_scrape_config_payload.py b/services/observability/src/stackit/observability/models/create_scrape_config_payload.py index e50871d58..1ee847293 100644 --- a/services/observability/src/stackit/observability/models/create_scrape_config_payload.py +++ b/services/observability/src/stackit/observability/models/create_scrape_config_payload.py @@ -28,6 +28,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.partial_update_scrape_configs_request_inner_basic_auth import ( @@ -140,7 +141,8 @@ def scheme_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -151,8 +153,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/credentials.py b/services/observability/src/stackit/observability/models/credentials.py index 53b479621..c6274fab6 100644 --- a/services/observability/src/stackit/observability/models/credentials.py +++ b/services/observability/src/stackit/observability/models/credentials.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,7 +34,8 @@ class Credentials(BaseModel): __properties: ClassVar[List[str]] = ["description", "password", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/credentials_remote_write_config.py b/services/observability/src/stackit/observability/models/credentials_remote_write_config.py index ac47031f2..adbaf4afd 100644 --- a/services/observability/src/stackit/observability/models/credentials_remote_write_config.py +++ b/services/observability/src/stackit/observability/models/credentials_remote_write_config.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,7 +34,8 @@ class CredentialsRemoteWriteConfig(BaseModel): __properties: ClassVar[List[str]] = ["credentialsMaxLimit", "maxLimit", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/credentials_remote_write_delete_response.py b/services/observability/src/stackit/observability/models/credentials_remote_write_delete_response.py index 5f314dfa6..cf163202f 100644 --- a/services/observability/src/stackit/observability/models/credentials_remote_write_delete_response.py +++ b/services/observability/src/stackit/observability/models/credentials_remote_write_delete_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -32,7 +33,8 @@ class CredentialsRemoteWriteDeleteResponse(BaseModel): __properties: ClassVar[List[str]] = ["maxLimit", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/delete_scrape_config_response.py b/services/observability/src/stackit/observability/models/delete_scrape_config_response.py index c6882a669..e0085f605 100644 --- a/services/observability/src/stackit/observability/models/delete_scrape_config_response.py +++ b/services/observability/src/stackit/observability/models/delete_scrape_config_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.job import Job @@ -34,7 +35,8 @@ class DeleteScrapeConfigResponse(BaseModel): __properties: ClassVar[List[str]] = ["data", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/elasticsearch_check_child_response.py b/services/observability/src/stackit/observability/models/elasticsearch_check_child_response.py index 647c689d7..99c1c37e7 100644 --- a/services/observability/src/stackit/observability/models/elasticsearch_check_child_response.py +++ b/services/observability/src/stackit/observability/models/elasticsearch_check_child_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -34,7 +35,8 @@ class ElasticsearchCheckChildResponse(BaseModel): __properties: ClassVar[List[str]] = ["id", "password", "server", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/elasticsearch_check_response.py b/services/observability/src/stackit/observability/models/elasticsearch_check_response.py index c293ef053..ab88dc68a 100644 --- a/services/observability/src/stackit/observability/models/elasticsearch_check_response.py +++ b/services/observability/src/stackit/observability/models/elasticsearch_check_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.elasticsearch_check_child_response import ( @@ -39,7 +40,8 @@ class ElasticsearchCheckResponse(BaseModel): __properties: ClassVar[List[str]] = ["elasticsearchCheck", "elasticsearchChecks", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/email_config.py b/services/observability/src/stackit/observability/models/email_config.py index dca92e68d..cf524981f 100644 --- a/services/observability/src/stackit/observability/models/email_config.py +++ b/services/observability/src/stackit/observability/models/email_config.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -53,7 +54,8 @@ class EmailConfig(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -64,8 +66,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/error.py b/services/observability/src/stackit/observability/models/error.py index 8f04197f4..0a24e2d68 100644 --- a/services/observability/src/stackit/observability/models/error.py +++ b/services/observability/src/stackit/observability/models/error.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -32,7 +33,8 @@ class Error(BaseModel): __properties: ClassVar[List[str]] = ["errors", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/get_alert_configs_response.py b/services/observability/src/stackit/observability/models/get_alert_configs_response.py index 8534b2f02..6986156cd 100644 --- a/services/observability/src/stackit/observability/models/get_alert_configs_response.py +++ b/services/observability/src/stackit/observability/models/get_alert_configs_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.alert import Alert @@ -34,7 +35,8 @@ class GetAlertConfigsResponse(BaseModel): __properties: ClassVar[List[str]] = ["data", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/get_credentials_response.py b/services/observability/src/stackit/observability/models/get_credentials_response.py index a53cb0236..ea6aec7dd 100644 --- a/services/observability/src/stackit/observability/models/get_credentials_response.py +++ b/services/observability/src/stackit/observability/models/get_credentials_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -34,7 +35,8 @@ class GetCredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["credentialsInfo", "id", "message", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/get_instance_response.py b/services/observability/src/stackit/observability/models/get_instance_response.py index 86c55e671..c9daed351 100644 --- a/services/observability/src/stackit/observability/models/get_instance_response.py +++ b/services/observability/src/stackit/observability/models/get_instance_response.py @@ -26,6 +26,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.instance_sensitive_data import InstanceSensitiveData @@ -87,7 +88,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -98,8 +100,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/get_metrics_storage_retention_response.py b/services/observability/src/stackit/observability/models/get_metrics_storage_retention_response.py index 933549f9d..3d1b7b77e 100644 --- a/services/observability/src/stackit/observability/models/get_metrics_storage_retention_response.py +++ b/services/observability/src/stackit/observability/models/get_metrics_storage_retention_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -45,7 +46,8 @@ class GetMetricsStorageRetentionResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +58,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/get_scrape_config_response.py b/services/observability/src/stackit/observability/models/get_scrape_config_response.py index a79389e57..26fb1ca04 100644 --- a/services/observability/src/stackit/observability/models/get_scrape_config_response.py +++ b/services/observability/src/stackit/observability/models/get_scrape_config_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.job import Job @@ -34,7 +35,8 @@ class GetScrapeConfigResponse(BaseModel): __properties: ClassVar[List[str]] = ["data", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/grafana_configs.py b/services/observability/src/stackit/observability/models/grafana_configs.py index 7dce48af3..6d303b918 100644 --- a/services/observability/src/stackit/observability/models/grafana_configs.py +++ b/services/observability/src/stackit/observability/models/grafana_configs.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.grafana_oauth import GrafanaOauth @@ -36,7 +37,8 @@ class GrafanaConfigs(BaseModel): __properties: ClassVar[List[str]] = ["genericOauth", "message", "publicReadAccess", "useStackitSso"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/grafana_oauth.py b/services/observability/src/stackit/observability/models/grafana_oauth.py index b18aea651..b7e59de5e 100644 --- a/services/observability/src/stackit/observability/models/grafana_oauth.py +++ b/services/observability/src/stackit/observability/models/grafana_oauth.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -59,7 +60,8 @@ class GrafanaOauth(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -70,8 +72,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/http_check_child_response.py b/services/observability/src/stackit/observability/models/http_check_child_response.py index 92270922f..dd3def041 100644 --- a/services/observability/src/stackit/observability/models/http_check_child_response.py +++ b/services/observability/src/stackit/observability/models/http_check_child_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -32,7 +33,8 @@ class HttpCheckChildResponse(BaseModel): __properties: ClassVar[List[str]] = ["id", "url"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/http_check_response.py b/services/observability/src/stackit/observability/models/http_check_response.py index b1ea7f426..65c68a050 100644 --- a/services/observability/src/stackit/observability/models/http_check_response.py +++ b/services/observability/src/stackit/observability/models/http_check_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.http_check_child_response import ( @@ -37,7 +38,8 @@ class HttpCheckResponse(BaseModel): __properties: ClassVar[List[str]] = ["httpCheck", "httpChecks", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/http_service_sd.py b/services/observability/src/stackit/observability/models/http_service_sd.py index 6a6d4e276..2a44778a9 100644 --- a/services/observability/src/stackit/observability/models/http_service_sd.py +++ b/services/observability/src/stackit/observability/models/http_service_sd.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.basic_auth import BasicAuth @@ -41,7 +42,8 @@ class HTTPServiceSD(BaseModel): __properties: ClassVar[List[str]] = ["basicAuth", "oauth2", "refreshInterval", "tlsConfig", "url"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -52,8 +54,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/inhibit_rules.py b/services/observability/src/stackit/observability/models/inhibit_rules.py index 3be92229c..c90769f87 100644 --- a/services/observability/src/stackit/observability/models/inhibit_rules.py +++ b/services/observability/src/stackit/observability/models/inhibit_rules.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -59,7 +60,8 @@ class InhibitRules(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -70,8 +72,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/instance.py b/services/observability/src/stackit/observability/models/instance.py index e5f08d909..468c523ab 100644 --- a/services/observability/src/stackit/observability/models/instance.py +++ b/services/observability/src/stackit/observability/models/instance.py @@ -26,6 +26,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.plan_model import PlanModel @@ -88,7 +89,8 @@ def state_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -99,8 +101,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/instance_response.py b/services/observability/src/stackit/observability/models/instance_response.py index f7835c990..d3129850b 100644 --- a/services/observability/src/stackit/observability/models/instance_response.py +++ b/services/observability/src/stackit/observability/models/instance_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -31,7 +32,8 @@ class InstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/instance_sensitive_data.py b/services/observability/src/stackit/observability/models/instance_sensitive_data.py index ffc3163af..f3b2aab7a 100644 --- a/services/observability/src/stackit/observability/models/instance_sensitive_data.py +++ b/services/observability/src/stackit/observability/models/instance_sensitive_data.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.plan_model import PlanModel @@ -95,7 +96,8 @@ class InstanceSensitiveData(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -106,8 +108,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/job.py b/services/observability/src/stackit/observability/models/job.py index 6e3feb455..e0eb6a10d 100644 --- a/services/observability/src/stackit/observability/models/job.py +++ b/services/observability/src/stackit/observability/models/job.py @@ -26,6 +26,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.basic_auth import BasicAuth @@ -95,7 +96,8 @@ def scheme_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -106,8 +108,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/list_acl_response.py b/services/observability/src/stackit/observability/models/list_acl_response.py index c977d3cea..0cb5cab32 100644 --- a/services/observability/src/stackit/observability/models/list_acl_response.py +++ b/services/observability/src/stackit/observability/models/list_acl_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -32,7 +33,8 @@ class ListACLResponse(BaseModel): __properties: ClassVar[List[str]] = ["acl", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/list_credentials_response.py b/services/observability/src/stackit/observability/models/list_credentials_response.py index 72e233678..3f4718106 100644 --- a/services/observability/src/stackit/observability/models/list_credentials_response.py +++ b/services/observability/src/stackit/observability/models/list_credentials_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.service_keys_list import ServiceKeysList @@ -34,7 +35,8 @@ class ListCredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["credentials", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/list_instances_response.py b/services/observability/src/stackit/observability/models/list_instances_response.py index 14967e853..d40af7e81 100644 --- a/services/observability/src/stackit/observability/models/list_instances_response.py +++ b/services/observability/src/stackit/observability/models/list_instances_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.project_instance_full import ProjectInstanceFull @@ -34,7 +35,8 @@ class ListInstancesResponse(BaseModel): __properties: ClassVar[List[str]] = ["instances", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/list_scrape_configs_response.py b/services/observability/src/stackit/observability/models/list_scrape_configs_response.py index b4255e62b..d3acae880 100644 --- a/services/observability/src/stackit/observability/models/list_scrape_configs_response.py +++ b/services/observability/src/stackit/observability/models/list_scrape_configs_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.job import Job @@ -34,7 +35,8 @@ class ListScrapeConfigsResponse(BaseModel): __properties: ClassVar[List[str]] = ["data", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/logs_config.py b/services/observability/src/stackit/observability/models/logs_config.py index e7db18fb1..043426e68 100644 --- a/services/observability/src/stackit/observability/models/logs_config.py +++ b/services/observability/src/stackit/observability/models/logs_config.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -31,7 +32,8 @@ class LogsConfig(BaseModel): __properties: ClassVar[List[str]] = ["retention"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/logs_config_response.py b/services/observability/src/stackit/observability/models/logs_config_response.py index e16b78647..3267c8c38 100644 --- a/services/observability/src/stackit/observability/models/logs_config_response.py +++ b/services/observability/src/stackit/observability/models/logs_config_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.logs_config import LogsConfig @@ -34,7 +35,8 @@ class LogsConfigResponse(BaseModel): __properties: ClassVar[List[str]] = ["config", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/message.py b/services/observability/src/stackit/observability/models/message.py index 4bdc419d8..2295a5a20 100644 --- a/services/observability/src/stackit/observability/models/message.py +++ b/services/observability/src/stackit/observability/models/message.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -31,7 +32,8 @@ class Message(BaseModel): __properties: ClassVar[List[str]] = ["message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/metrics_relabel_config.py b/services/observability/src/stackit/observability/models/metrics_relabel_config.py index 3349fa346..4644dab44 100644 --- a/services/observability/src/stackit/observability/models/metrics_relabel_config.py +++ b/services/observability/src/stackit/observability/models/metrics_relabel_config.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -61,7 +62,8 @@ def action_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -72,8 +74,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/model_global.py b/services/observability/src/stackit/observability/models/model_global.py index 9ddb3746f..b59079005 100644 --- a/services/observability/src/stackit/observability/models/model_global.py +++ b/services/observability/src/stackit/observability/models/model_global.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -63,7 +64,8 @@ class ModelGlobal(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -74,8 +76,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/mongodb_check_child_response.py b/services/observability/src/stackit/observability/models/mongodb_check_child_response.py index a209cf2e6..b64eff427 100644 --- a/services/observability/src/stackit/observability/models/mongodb_check_child_response.py +++ b/services/observability/src/stackit/observability/models/mongodb_check_child_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -32,7 +33,8 @@ class MongodbCheckChildResponse(BaseModel): __properties: ClassVar[List[str]] = ["id", "server"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/mongodb_check_response.py b/services/observability/src/stackit/observability/models/mongodb_check_response.py index 754bc1071..95fb4bf01 100644 --- a/services/observability/src/stackit/observability/models/mongodb_check_response.py +++ b/services/observability/src/stackit/observability/models/mongodb_check_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.mongodb_check_child_response import ( @@ -37,7 +38,8 @@ class MongodbCheckResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "mongodbCheck", "mongodbChecks"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/mysql_check_child_response.py b/services/observability/src/stackit/observability/models/mysql_check_child_response.py index 99e3a5bb2..b6b433944 100644 --- a/services/observability/src/stackit/observability/models/mysql_check_child_response.py +++ b/services/observability/src/stackit/observability/models/mysql_check_child_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -32,7 +33,8 @@ class MysqlCheckChildResponse(BaseModel): __properties: ClassVar[List[str]] = ["id", "server"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/mysql_check_response.py b/services/observability/src/stackit/observability/models/mysql_check_response.py index 8eacdebcb..7b70beafa 100644 --- a/services/observability/src/stackit/observability/models/mysql_check_response.py +++ b/services/observability/src/stackit/observability/models/mysql_check_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.mysql_check_child_response import ( @@ -37,7 +38,8 @@ class MysqlCheckResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "mysqlCheck", "mysqlChecks"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/network_check_child_response.py b/services/observability/src/stackit/observability/models/network_check_child_response.py index f0eed108f..65acf0829 100644 --- a/services/observability/src/stackit/observability/models/network_check_child_response.py +++ b/services/observability/src/stackit/observability/models/network_check_child_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -32,7 +33,8 @@ class NetworkCheckChildResponse(BaseModel): __properties: ClassVar[List[str]] = ["address", "id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/network_check_response.py b/services/observability/src/stackit/observability/models/network_check_response.py index b08d468c1..d36966780 100644 --- a/services/observability/src/stackit/observability/models/network_check_response.py +++ b/services/observability/src/stackit/observability/models/network_check_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.network_check_child_response import ( @@ -37,7 +38,8 @@ class NetworkCheckResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "networkCheck", "networkChecks"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/o_auth2.py b/services/observability/src/stackit/observability/models/o_auth2.py index 4adec4cb5..42d473373 100644 --- a/services/observability/src/stackit/observability/models/o_auth2.py +++ b/services/observability/src/stackit/observability/models/o_auth2.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.tls_config import TLSConfig @@ -39,7 +40,8 @@ class OAuth2(BaseModel): __properties: ClassVar[List[str]] = ["clientId", "clientSecret", "scopes", "tlsConfig", "tokenUrl"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/offerings.py b/services/observability/src/stackit/observability/models/offerings.py index f466c70e0..edcd472eb 100644 --- a/services/observability/src/stackit/observability/models/offerings.py +++ b/services/observability/src/stackit/observability/models/offerings.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.plan import Plan @@ -40,7 +41,8 @@ class Offerings(BaseModel): __properties: ClassVar[List[str]] = ["description", "documentationUrl", "imageUrl", "name", "plans", "tags"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/opsgenie_config.py b/services/observability/src/stackit/observability/models/opsgenie_config.py index 0fcc786f0..346ec59db 100644 --- a/services/observability/src/stackit/observability/models/opsgenie_config.py +++ b/services/observability/src/stackit/observability/models/opsgenie_config.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -39,7 +40,8 @@ class OpsgenieConfig(BaseModel): __properties: ClassVar[List[str]] = ["apiKey", "apiUrl", "priority", "sendResolved", "tags"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/partial_update_alert_records_request_inner.py b/services/observability/src/stackit/observability/models/partial_update_alert_records_request_inner.py index 06db88c8f..00383937d 100644 --- a/services/observability/src/stackit/observability/models/partial_update_alert_records_request_inner.py +++ b/services/observability/src/stackit/observability/models/partial_update_alert_records_request_inner.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -40,7 +41,8 @@ class PartialUpdateAlertRecordsRequestInner(BaseModel): __properties: ClassVar[List[str]] = ["expr", "labels", "record"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/partial_update_alertrules_request_inner.py b/services/observability/src/stackit/observability/models/partial_update_alertrules_request_inner.py index 4c7f24890..b9fc0b518 100644 --- a/services/observability/src/stackit/observability/models/partial_update_alertrules_request_inner.py +++ b/services/observability/src/stackit/observability/models/partial_update_alertrules_request_inner.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -49,7 +50,8 @@ class PartialUpdateAlertrulesRequestInner(BaseModel): __properties: ClassVar[List[str]] = ["alert", "annotations", "expr", "for", "labels"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +62,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner.py b/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner.py index 3b66d6857..a509326b8 100644 --- a/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner.py +++ b/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner.py @@ -28,6 +28,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.partial_update_scrape_configs_request_inner_basic_auth import ( @@ -140,7 +141,8 @@ def scheme_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -151,8 +153,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_basic_auth.py b/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_basic_auth.py index 0429be2fb..949d78997 100644 --- a/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_basic_auth.py +++ b/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_basic_auth.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -36,7 +37,8 @@ class PartialUpdateScrapeConfigsRequestInnerBasicAuth(BaseModel): __properties: ClassVar[List[str]] = ["password", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_http_sd_configs_inner.py b/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_http_sd_configs_inner.py index 5c918b608..dba9219c6 100644 --- a/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_http_sd_configs_inner.py +++ b/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_http_sd_configs_inner.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.partial_update_scrape_configs_request_inner_basic_auth import ( @@ -53,7 +54,8 @@ class PartialUpdateScrapeConfigsRequestInnerHttpSdConfigsInner(BaseModel): __properties: ClassVar[List[str]] = ["basicAuth", "oauth2", "refreshInterval", "tlsConfig", "url"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -64,8 +66,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_http_sd_configs_inner_oauth2.py b/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_http_sd_configs_inner_oauth2.py index e4897e699..f6fd8714b 100644 --- a/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_http_sd_configs_inner_oauth2.py +++ b/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_http_sd_configs_inner_oauth2.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.partial_update_scrape_configs_request_inner_http_sd_configs_inner_oauth2_tls_config import ( @@ -49,7 +50,8 @@ class PartialUpdateScrapeConfigsRequestInnerHttpSdConfigsInnerOauth2(BaseModel): __properties: ClassVar[List[str]] = ["clientId", "clientSecret", "scopes", "tlsConfig", "tokenUrl"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +62,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_http_sd_configs_inner_oauth2_tls_config.py b/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_http_sd_configs_inner_oauth2_tls_config.py index 1fc2e9d9a..bc7088013 100644 --- a/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_http_sd_configs_inner_oauth2_tls_config.py +++ b/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_http_sd_configs_inner_oauth2_tls_config.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -33,7 +34,8 @@ class PartialUpdateScrapeConfigsRequestInnerHttpSdConfigsInnerOauth2TlsConfig(Ba __properties: ClassVar[List[str]] = ["insecureSkipVerify"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_metrics_relabel_configs_inner.py b/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_metrics_relabel_configs_inner.py index b2b90fdbb..a9ea6d588 100644 --- a/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_metrics_relabel_configs_inner.py +++ b/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_metrics_relabel_configs_inner.py @@ -27,6 +27,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -85,7 +86,8 @@ def action_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -96,8 +98,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_static_configs_inner.py b/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_static_configs_inner.py index b05b8000c..980e93460 100644 --- a/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_static_configs_inner.py +++ b/services/observability/src/stackit/observability/models/partial_update_scrape_configs_request_inner_static_configs_inner.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -37,7 +38,8 @@ class PartialUpdateScrapeConfigsRequestInnerStaticConfigsInner(BaseModel): __properties: ClassVar[List[str]] = ["labels", "targets"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/permission_denied.py b/services/observability/src/stackit/observability/models/permission_denied.py index 71dc55d64..bfb7c6045 100644 --- a/services/observability/src/stackit/observability/models/permission_denied.py +++ b/services/observability/src/stackit/observability/models/permission_denied.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -31,7 +32,8 @@ class PermissionDenied(BaseModel): __properties: ClassVar[List[str]] = ["detail"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/ping_check_child_response.py b/services/observability/src/stackit/observability/models/ping_check_child_response.py index c72136783..ae0f8c2c3 100644 --- a/services/observability/src/stackit/observability/models/ping_check_child_response.py +++ b/services/observability/src/stackit/observability/models/ping_check_child_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -32,7 +33,8 @@ class PingCheckChildResponse(BaseModel): __properties: ClassVar[List[str]] = ["id", "url"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/ping_check_response.py b/services/observability/src/stackit/observability/models/ping_check_response.py index a0ff5c214..07034fe7f 100644 --- a/services/observability/src/stackit/observability/models/ping_check_response.py +++ b/services/observability/src/stackit/observability/models/ping_check_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.ping_check_child_response import ( @@ -37,7 +38,8 @@ class PingCheckResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "pingCheck", "pingChecks"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/plan.py b/services/observability/src/stackit/observability/models/plan.py index 31103f741..83e343e20 100644 --- a/services/observability/src/stackit/observability/models/plan.py +++ b/services/observability/src/stackit/observability/models/plan.py @@ -26,6 +26,7 @@ StrictBool, StrictInt, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -87,7 +88,8 @@ class Plan(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -98,8 +100,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/plan_model.py b/services/observability/src/stackit/observability/models/plan_model.py index 4dc63f6af..c633864f0 100644 --- a/services/observability/src/stackit/observability/models/plan_model.py +++ b/services/observability/src/stackit/observability/models/plan_model.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -75,7 +76,8 @@ class PlanModel(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -86,8 +88,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/plans_response.py b/services/observability/src/stackit/observability/models/plans_response.py index d798cae89..8334d3ce9 100644 --- a/services/observability/src/stackit/observability/models/plans_response.py +++ b/services/observability/src/stackit/observability/models/plans_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.plan import Plan @@ -34,7 +35,8 @@ class PlansResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "plans"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/postgresql_check_child_response.py b/services/observability/src/stackit/observability/models/postgresql_check_child_response.py index 43425d33c..f664d897d 100644 --- a/services/observability/src/stackit/observability/models/postgresql_check_child_response.py +++ b/services/observability/src/stackit/observability/models/postgresql_check_child_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -32,7 +33,8 @@ class PostgresqlCheckChildResponse(BaseModel): __properties: ClassVar[List[str]] = ["address", "id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/postgresql_check_response.py b/services/observability/src/stackit/observability/models/postgresql_check_response.py index e37f1a140..dccdb0a34 100644 --- a/services/observability/src/stackit/observability/models/postgresql_check_response.py +++ b/services/observability/src/stackit/observability/models/postgresql_check_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.postgresql_check_child_response import ( @@ -39,7 +40,8 @@ class PostgresqlCheckResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "postgresqlCheck", "postgresqlChecks"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/project_instance_full.py b/services/observability/src/stackit/observability/models/project_instance_full.py index 28ec205ff..9010f95ab 100644 --- a/services/observability/src/stackit/observability/models/project_instance_full.py +++ b/services/observability/src/stackit/observability/models/project_instance_full.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -58,7 +59,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -69,8 +71,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/rabbit_mq_check_child_response.py b/services/observability/src/stackit/observability/models/rabbit_mq_check_child_response.py index d6f75956a..98249382a 100644 --- a/services/observability/src/stackit/observability/models/rabbit_mq_check_child_response.py +++ b/services/observability/src/stackit/observability/models/rabbit_mq_check_child_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -34,7 +35,8 @@ class RabbitMQCheckChildResponse(BaseModel): __properties: ClassVar[List[str]] = ["id", "password", "url", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/rabbitmq_check_response.py b/services/observability/src/stackit/observability/models/rabbitmq_check_response.py index de0468f4c..1b9fe7b70 100644 --- a/services/observability/src/stackit/observability/models/rabbitmq_check_response.py +++ b/services/observability/src/stackit/observability/models/rabbitmq_check_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.rabbit_mq_check_child_response import ( @@ -37,7 +38,8 @@ class RabbitmqCheckResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "rabbitmqCheck", "rabbitmqChecks"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/receiver.py b/services/observability/src/stackit/observability/models/receiver.py index 28ed13c28..bcd01d769 100644 --- a/services/observability/src/stackit/observability/models/receiver.py +++ b/services/observability/src/stackit/observability/models/receiver.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.receivers import Receivers @@ -34,7 +35,8 @@ class Receiver(BaseModel): __properties: ClassVar[List[str]] = ["data", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/receivers.py b/services/observability/src/stackit/observability/models/receivers.py index e02c48d80..1e5902919 100644 --- a/services/observability/src/stackit/observability/models/receivers.py +++ b/services/observability/src/stackit/observability/models/receivers.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.email_config import EmailConfig @@ -38,7 +39,8 @@ class Receivers(BaseModel): __properties: ClassVar[List[str]] = ["emailConfigs", "name", "opsgenieConfigs", "webHookConfigs"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/redis_check_child_response.py b/services/observability/src/stackit/observability/models/redis_check_child_response.py index 18e1b71fc..e477e948a 100644 --- a/services/observability/src/stackit/observability/models/redis_check_child_response.py +++ b/services/observability/src/stackit/observability/models/redis_check_child_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -34,7 +35,8 @@ class RedisCheckChildResponse(BaseModel): __properties: ClassVar[List[str]] = ["id", "password", "server", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/redis_check_response.py b/services/observability/src/stackit/observability/models/redis_check_response.py index 2f9f7d9d5..77afe9a19 100644 --- a/services/observability/src/stackit/observability/models/redis_check_response.py +++ b/services/observability/src/stackit/observability/models/redis_check_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.redis_check_child_response import ( @@ -37,7 +38,8 @@ class RedisCheckResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "redisCheck", "redisChecks"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/route.py b/services/observability/src/stackit/observability/models/route.py index ef0c191ea..b92bf8005 100644 --- a/services/observability/src/stackit/observability/models/route.py +++ b/services/observability/src/stackit/observability/models/route.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.route_serializer import RouteSerializer @@ -65,7 +66,8 @@ class Route(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -76,8 +78,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/route_serializer.py b/services/observability/src/stackit/observability/models/route_serializer.py index 6321be9d9..6eb9211c0 100644 --- a/services/observability/src/stackit/observability/models/route_serializer.py +++ b/services/observability/src/stackit/observability/models/route_serializer.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -69,7 +70,8 @@ class RouteSerializer(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -80,8 +82,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/scrape_configs_response.py b/services/observability/src/stackit/observability/models/scrape_configs_response.py index 23427cd28..3fd2d9c48 100644 --- a/services/observability/src/stackit/observability/models/scrape_configs_response.py +++ b/services/observability/src/stackit/observability/models/scrape_configs_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.job import Job @@ -34,7 +35,8 @@ class ScrapeConfigsResponse(BaseModel): __properties: ClassVar[List[str]] = ["data", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/service_keys_list.py b/services/observability/src/stackit/observability/models/service_keys_list.py index dc118a509..cb39f9de9 100644 --- a/services/observability/src/stackit/observability/models/service_keys_list.py +++ b/services/observability/src/stackit/observability/models/service_keys_list.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -34,7 +35,8 @@ class ServiceKeysList(BaseModel): __properties: ClassVar[List[str]] = ["credentialsInfo", "description", "id", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/static_configs.py b/services/observability/src/stackit/observability/models/static_configs.py index 1e7fe41db..71b3d792a 100644 --- a/services/observability/src/stackit/observability/models/static_configs.py +++ b/services/observability/src/stackit/observability/models/static_configs.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -32,7 +33,8 @@ class StaticConfigs(BaseModel): __properties: ClassVar[List[str]] = ["labels", "targets"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/tls_config.py b/services/observability/src/stackit/observability/models/tls_config.py index f65a9a07e..d85a2538c 100644 --- a/services/observability/src/stackit/observability/models/tls_config.py +++ b/services/observability/src/stackit/observability/models/tls_config.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class TLSConfig(BaseModel): __properties: ClassVar[List[str]] = ["insecureSkipVerify"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/trace_config.py b/services/observability/src/stackit/observability/models/trace_config.py index 4ba97f8a4..4005511bb 100644 --- a/services/observability/src/stackit/observability/models/trace_config.py +++ b/services/observability/src/stackit/observability/models/trace_config.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -31,7 +32,8 @@ class TraceConfig(BaseModel): __properties: ClassVar[List[str]] = ["retention"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/traces_config_response.py b/services/observability/src/stackit/observability/models/traces_config_response.py index 2d2dd2aec..535e0fee1 100644 --- a/services/observability/src/stackit/observability/models/traces_config_response.py +++ b/services/observability/src/stackit/observability/models/traces_config_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.trace_config import TraceConfig @@ -34,7 +35,8 @@ class TracesConfigResponse(BaseModel): __properties: ClassVar[List[str]] = ["config", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_acl_payload.py b/services/observability/src/stackit/observability/models/update_acl_payload.py index aacccfc1f..3c3522e60 100644 --- a/services/observability/src/stackit/observability/models/update_acl_payload.py +++ b/services/observability/src/stackit/observability/models/update_acl_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -31,7 +32,8 @@ class UpdateACLPayload(BaseModel): __properties: ClassVar[List[str]] = ["acl"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_alert_config_receiver_payload.py b/services/observability/src/stackit/observability/models/update_alert_config_receiver_payload.py index ebfac06b7..6ce978c57 100644 --- a/services/observability/src/stackit/observability/models/update_alert_config_receiver_payload.py +++ b/services/observability/src/stackit/observability/models/update_alert_config_receiver_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.create_alert_config_receiver_payload_email_configs_inner import ( @@ -52,7 +53,8 @@ class UpdateAlertConfigReceiverPayload(BaseModel): __properties: ClassVar[List[str]] = ["emailConfigs", "name", "opsgenieConfigs", "webHookConfigs"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -63,8 +65,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_alert_config_route_payload.py b/services/observability/src/stackit/observability/models/update_alert_config_route_payload.py index 3fe0a4434..d3f64713a 100644 --- a/services/observability/src/stackit/observability/models/update_alert_config_route_payload.py +++ b/services/observability/src/stackit/observability/models/update_alert_config_route_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.create_alert_config_route_payload_routes_inner import ( @@ -89,7 +90,8 @@ class UpdateAlertConfigRoutePayload(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -100,8 +102,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_alert_configs_payload.py b/services/observability/src/stackit/observability/models/update_alert_configs_payload.py index 5ff92707f..4a729b8b4 100644 --- a/services/observability/src/stackit/observability/models/update_alert_configs_payload.py +++ b/services/observability/src/stackit/observability/models/update_alert_configs_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.observability.models.update_alert_configs_payload_global import ( @@ -47,7 +48,8 @@ class UpdateAlertConfigsPayload(BaseModel): __properties: ClassVar[List[str]] = ["global", "inhibitRules", "receivers", "route"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -58,8 +60,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_alert_configs_payload_global.py b/services/observability/src/stackit/observability/models/update_alert_configs_payload_global.py index 4f8cbefdc..fcc40a595 100644 --- a/services/observability/src/stackit/observability/models/update_alert_configs_payload_global.py +++ b/services/observability/src/stackit/observability/models/update_alert_configs_payload_global.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -77,7 +78,8 @@ class UpdateAlertConfigsPayloadGlobal(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -88,8 +90,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_alert_configs_payload_inhibit_rules.py b/services/observability/src/stackit/observability/models/update_alert_configs_payload_inhibit_rules.py index f8e22046f..e019e1dd0 100644 --- a/services/observability/src/stackit/observability/models/update_alert_configs_payload_inhibit_rules.py +++ b/services/observability/src/stackit/observability/models/update_alert_configs_payload_inhibit_rules.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -54,7 +55,8 @@ class UpdateAlertConfigsPayloadInhibitRules(BaseModel): __properties: ClassVar[List[str]] = ["equal", "sourceMatch", "sourceMatchRe", "targetMatch", "targetMatchRe"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -65,8 +67,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_alert_configs_payload_receivers_inner.py b/services/observability/src/stackit/observability/models/update_alert_configs_payload_receivers_inner.py index 48fbcb81e..f2456b98b 100644 --- a/services/observability/src/stackit/observability/models/update_alert_configs_payload_receivers_inner.py +++ b/services/observability/src/stackit/observability/models/update_alert_configs_payload_receivers_inner.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.create_alert_config_receiver_payload_email_configs_inner import ( @@ -52,7 +53,8 @@ class UpdateAlertConfigsPayloadReceiversInner(BaseModel): __properties: ClassVar[List[str]] = ["emailConfigs", "name", "opsgenieConfigs", "webHookConfigs"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -63,8 +65,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_alert_configs_payload_route.py b/services/observability/src/stackit/observability/models/update_alert_configs_payload_route.py index a22b8dfab..21a2d2901 100644 --- a/services/observability/src/stackit/observability/models/update_alert_configs_payload_route.py +++ b/services/observability/src/stackit/observability/models/update_alert_configs_payload_route.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.update_alert_configs_payload_route_routes_inner import ( @@ -84,7 +85,8 @@ class UpdateAlertConfigsPayloadRoute(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -95,8 +97,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_alert_configs_payload_route_routes_inner.py b/services/observability/src/stackit/observability/models/update_alert_configs_payload_route_routes_inner.py index ec6034c8f..9d458a484 100644 --- a/services/observability/src/stackit/observability/models/update_alert_configs_payload_route_routes_inner.py +++ b/services/observability/src/stackit/observability/models/update_alert_configs_payload_route_routes_inner.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -68,7 +69,8 @@ class UpdateAlertConfigsPayloadRouteRoutesInner(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -79,8 +81,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_alert_configs_response.py b/services/observability/src/stackit/observability/models/update_alert_configs_response.py index 9d955fca0..239e897e2 100644 --- a/services/observability/src/stackit/observability/models/update_alert_configs_response.py +++ b/services/observability/src/stackit/observability/models/update_alert_configs_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.alert import Alert @@ -34,7 +35,8 @@ class UpdateAlertConfigsResponse(BaseModel): __properties: ClassVar[List[str]] = ["data", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_alert_record_payload.py b/services/observability/src/stackit/observability/models/update_alert_record_payload.py index f76e1d756..6a80d4dc8 100644 --- a/services/observability/src/stackit/observability/models/update_alert_record_payload.py +++ b/services/observability/src/stackit/observability/models/update_alert_record_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -37,7 +38,8 @@ class UpdateAlertRecordPayload(BaseModel): __properties: ClassVar[List[str]] = ["expr", "labels"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_alertgroup_payload.py b/services/observability/src/stackit/observability/models/update_alertgroup_payload.py index 0577b8dd9..531c64fc0 100644 --- a/services/observability/src/stackit/observability/models/update_alertgroup_payload.py +++ b/services/observability/src/stackit/observability/models/update_alertgroup_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.update_alertgroups_request_inner_rules_inner import ( @@ -39,7 +40,8 @@ class UpdateAlertgroupPayload(BaseModel): __properties: ClassVar[List[str]] = ["interval", "rules"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_alertgroups_request_inner.py b/services/observability/src/stackit/observability/models/update_alertgroups_request_inner.py index d29bc9f8f..5ef1c8bfd 100644 --- a/services/observability/src/stackit/observability/models/update_alertgroups_request_inner.py +++ b/services/observability/src/stackit/observability/models/update_alertgroups_request_inner.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.update_alertgroups_request_inner_rules_inner import ( @@ -42,7 +43,8 @@ class UpdateAlertgroupsRequestInner(BaseModel): __properties: ClassVar[List[str]] = ["interval", "name", "rules"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_alertgroups_request_inner_rules_inner.py b/services/observability/src/stackit/observability/models/update_alertgroups_request_inner_rules_inner.py index 208118183..0a6556cfe 100644 --- a/services/observability/src/stackit/observability/models/update_alertgroups_request_inner_rules_inner.py +++ b/services/observability/src/stackit/observability/models/update_alertgroups_request_inner_rules_inner.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -54,7 +55,8 @@ class UpdateAlertgroupsRequestInnerRulesInner(BaseModel): __properties: ClassVar[List[str]] = ["alert", "annotations", "expr", "for", "labels", "record"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -65,8 +67,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_alertrule_payload.py b/services/observability/src/stackit/observability/models/update_alertrule_payload.py index 7aedf57a3..64190170b 100644 --- a/services/observability/src/stackit/observability/models/update_alertrule_payload.py +++ b/services/observability/src/stackit/observability/models/update_alertrule_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -46,7 +47,8 @@ class UpdateAlertrulePayload(BaseModel): __properties: ClassVar[List[str]] = ["annotations", "expr", "for", "labels"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -57,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_credentials_remote_write_config_payload.py b/services/observability/src/stackit/observability/models/update_credentials_remote_write_config_payload.py index e82332e42..81cbea9f3 100644 --- a/services/observability/src/stackit/observability/models/update_credentials_remote_write_config_payload.py +++ b/services/observability/src/stackit/observability/models/update_credentials_remote_write_config_payload.py @@ -25,6 +25,7 @@ StrictFloat, StrictInt, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -41,7 +42,8 @@ class UpdateCredentialsRemoteWriteConfigPayload(BaseModel): __properties: ClassVar[List[str]] = ["maxLimit"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -52,8 +54,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_grafana_configs_payload.py b/services/observability/src/stackit/observability/models/update_grafana_configs_payload.py index 2ee8eed29..9a823ef35 100644 --- a/services/observability/src/stackit/observability/models/update_grafana_configs_payload.py +++ b/services/observability/src/stackit/observability/models/update_grafana_configs_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.observability.models.update_grafana_configs_payload_generic_oauth import ( @@ -45,7 +46,8 @@ class UpdateGrafanaConfigsPayload(BaseModel): __properties: ClassVar[List[str]] = ["genericOauth", "publicReadAccess", "useStackitSso"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +58,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_grafana_configs_payload_generic_oauth.py b/services/observability/src/stackit/observability/models/update_grafana_configs_payload_generic_oauth.py index 0548c0a05..87b94867d 100644 --- a/services/observability/src/stackit/observability/models/update_grafana_configs_payload_generic_oauth.py +++ b/services/observability/src/stackit/observability/models/update_grafana_configs_payload_generic_oauth.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -80,7 +81,8 @@ class UpdateGrafanaConfigsPayloadGenericOauth(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -91,8 +93,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_instance_payload.py b/services/observability/src/stackit/observability/models/update_instance_payload.py index 4869564d8..1579895a9 100644 --- a/services/observability/src/stackit/observability/models/update_instance_payload.py +++ b/services/observability/src/stackit/observability/models/update_instance_payload.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -46,7 +47,8 @@ class UpdateInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["grafanaAdminEnabled", "name", "parameter", "planId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -57,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_logs_alertgroup_payload.py b/services/observability/src/stackit/observability/models/update_logs_alertgroup_payload.py index bd9d292f8..5547d1ef3 100644 --- a/services/observability/src/stackit/observability/models/update_logs_alertgroup_payload.py +++ b/services/observability/src/stackit/observability/models/update_logs_alertgroup_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.create_logs_alertgroups_payload_rules_inner import ( @@ -39,7 +40,8 @@ class UpdateLogsAlertgroupPayload(BaseModel): __properties: ClassVar[List[str]] = ["interval", "rules"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_logs_configs_payload.py b/services/observability/src/stackit/observability/models/update_logs_configs_payload.py index 0f0c428a4..0b9c200b5 100644 --- a/services/observability/src/stackit/observability/models/update_logs_configs_payload.py +++ b/services/observability/src/stackit/observability/models/update_logs_configs_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,7 +34,8 @@ class UpdateLogsConfigsPayload(BaseModel): __properties: ClassVar[List[str]] = ["retention"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_metrics_storage_retention_payload.py b/services/observability/src/stackit/observability/models/update_metrics_storage_retention_payload.py index e9d130e66..089685955 100644 --- a/services/observability/src/stackit/observability/models/update_metrics_storage_retention_payload.py +++ b/services/observability/src/stackit/observability/models/update_metrics_storage_retention_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -42,7 +43,8 @@ class UpdateMetricsStorageRetentionPayload(BaseModel): __properties: ClassVar[List[str]] = ["metricsRetentionTime1h", "metricsRetentionTime5m", "metricsRetentionTimeRaw"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_scrape_config_payload.py b/services/observability/src/stackit/observability/models/update_scrape_config_payload.py index 25662e9f7..504676a9e 100644 --- a/services/observability/src/stackit/observability/models/update_scrape_config_payload.py +++ b/services/observability/src/stackit/observability/models/update_scrape_config_payload.py @@ -28,6 +28,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.observability.models.partial_update_scrape_configs_request_inner_basic_auth import ( @@ -119,7 +120,8 @@ def scheme_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -130,8 +132,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_scrape_config_payload_static_configs_inner.py b/services/observability/src/stackit/observability/models/update_scrape_config_payload_static_configs_inner.py index c33363a98..9d1cd8154 100644 --- a/services/observability/src/stackit/observability/models/update_scrape_config_payload_static_configs_inner.py +++ b/services/observability/src/stackit/observability/models/update_scrape_config_payload_static_configs_inner.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -37,7 +38,8 @@ class UpdateScrapeConfigPayloadStaticConfigsInner(BaseModel): __properties: ClassVar[List[str]] = ["labels", "targets"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/update_traces_configs_payload.py b/services/observability/src/stackit/observability/models/update_traces_configs_payload.py index 3a630fa61..61a126401 100644 --- a/services/observability/src/stackit/observability/models/update_traces_configs_payload.py +++ b/services/observability/src/stackit/observability/models/update_traces_configs_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,7 +34,8 @@ class UpdateTracesConfigsPayload(BaseModel): __properties: ClassVar[List[str]] = ["retention"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/observability/src/stackit/observability/models/web_hook.py b/services/observability/src/stackit/observability/models/web_hook.py index d9958d881..f52ace50e 100644 --- a/services/observability/src/stackit/observability/models/web_hook.py +++ b/services/observability/src/stackit/observability/models/web_hook.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -34,7 +35,8 @@ class WebHook(BaseModel): __properties: ClassVar[List[str]] = ["googleChat", "msTeams", "sendResolved", "url"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/CHANGELOG.md b/services/opensearch/CHANGELOG.md index 0e46caac9..cc367b8d9 100644 --- a/services/opensearch/CHANGELOG.md +++ b/services/opensearch/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.5.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.4.0 - **Version**: Minimal version is now python 3.9 diff --git a/services/opensearch/pyproject.toml b/services/opensearch/pyproject.toml index 8f60b222e..df65fafaf 100644 --- a/services/opensearch/pyproject.toml +++ b/services/opensearch/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-opensearch" -version = "v0.4.0" +version = "v0.5.0" description = "STACKIT Opensearch API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/opensearch/src/stackit/opensearch/api/default_api.py b/services/opensearch/src/stackit/opensearch/api/default_api.py index 8dabfd95d..da1e13f2d 100644 --- a/services/opensearch/src/stackit/opensearch/api/default_api.py +++ b/services/opensearch/src/stackit/opensearch/api/default_api.py @@ -1334,7 +1334,7 @@ def download_backup( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> bytearray: + ) -> bytes: """download backup @@ -1377,7 +1377,7 @@ def download_backup( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "bytearray", + "200": "bytes", "500": "Error", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -1402,7 +1402,7 @@ def download_backup_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[bytearray]: + ) -> ApiResponse[bytes]: """download backup @@ -1445,7 +1445,7 @@ def download_backup_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "bytearray", + "200": "bytes", "500": "Error", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -1513,7 +1513,7 @@ def download_backup_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "bytearray", + "200": "bytes", "500": "Error", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) diff --git a/services/opensearch/src/stackit/opensearch/api_client.py b/services/opensearch/src/stackit/opensearch/api_client.py index 4ee59f1ac..2c35e862c 100644 --- a/services/opensearch/src/stackit/opensearch/api_client.py +++ b/services/opensearch/src/stackit/opensearch/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/opensearch/src/stackit/opensearch/models/backup.py b/services/opensearch/src/stackit/opensearch/models/backup.py index 0b5f4a7f1..77e65dcae 100644 --- a/services/opensearch/src/stackit/opensearch/models/backup.py +++ b/services/opensearch/src/stackit/opensearch/models/backup.py @@ -24,6 +24,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -41,7 +42,8 @@ class Backup(BaseModel): __properties: ClassVar[List[str]] = ["downloadable", "finished_at", "id", "size", "status", "triggered_at"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -52,8 +54,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/create_backup_response_item.py b/services/opensearch/src/stackit/opensearch/models/create_backup_response_item.py index 1f60ae488..512512935 100644 --- a/services/opensearch/src/stackit/opensearch/models/create_backup_response_item.py +++ b/services/opensearch/src/stackit/opensearch/models/create_backup_response_item.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class CreateBackupResponseItem(BaseModel): __properties: ClassVar[List[str]] = ["id", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/create_instance_payload.py b/services/opensearch/src/stackit/opensearch/models/create_instance_payload.py index 6c235dcbc..06a59c746 100644 --- a/services/opensearch/src/stackit/opensearch/models/create_instance_payload.py +++ b/services/opensearch/src/stackit/opensearch/models/create_instance_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.opensearch.models.instance_parameters import InstanceParameters @@ -34,7 +35,8 @@ class CreateInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["instanceName", "parameters", "planId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/create_instance_response.py b/services/opensearch/src/stackit/opensearch/models/create_instance_response.py index 75abed57d..d68583221 100644 --- a/services/opensearch/src/stackit/opensearch/models/create_instance_response.py +++ b/services/opensearch/src/stackit/opensearch/models/create_instance_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class CreateInstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["instanceId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/credentials.py b/services/opensearch/src/stackit/opensearch/models/credentials.py index 6222f090e..2b7709161 100644 --- a/services/opensearch/src/stackit/opensearch/models/credentials.py +++ b/services/opensearch/src/stackit/opensearch/models/credentials.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -36,7 +37,8 @@ class Credentials(BaseModel): __properties: ClassVar[List[str]] = ["host", "hosts", "password", "port", "scheme", "uri", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/credentials_list_item.py b/services/opensearch/src/stackit/opensearch/models/credentials_list_item.py index debc34f61..8c0e37b2e 100644 --- a/services/opensearch/src/stackit/opensearch/models/credentials_list_item.py +++ b/services/opensearch/src/stackit/opensearch/models/credentials_list_item.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class CredentialsListItem(BaseModel): __properties: ClassVar[List[str]] = ["id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/credentials_response.py b/services/opensearch/src/stackit/opensearch/models/credentials_response.py index 330334916..4869deaa1 100644 --- a/services/opensearch/src/stackit/opensearch/models/credentials_response.py +++ b/services/opensearch/src/stackit/opensearch/models/credentials_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.opensearch.models.raw_credentials import RawCredentials @@ -34,7 +35,8 @@ class CredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["id", "raw", "uri"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/error.py b/services/opensearch/src/stackit/opensearch/models/error.py index d8c463de3..5efd6f359 100644 --- a/services/opensearch/src/stackit/opensearch/models/error.py +++ b/services/opensearch/src/stackit/opensearch/models/error.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class Error(BaseModel): __properties: ClassVar[List[str]] = ["description", "error"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/get_metrics_response.py b/services/opensearch/src/stackit/opensearch/models/get_metrics_response.py index d11495f30..51391aaaa 100644 --- a/services/opensearch/src/stackit/opensearch/models/get_metrics_response.py +++ b/services/opensearch/src/stackit/opensearch/models/get_metrics_response.py @@ -25,6 +25,7 @@ StrictFloat, StrictInt, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -83,7 +84,8 @@ class GetMetricsResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -94,8 +96,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/instance.py b/services/opensearch/src/stackit/opensearch/models/instance.py index 1a349a5d7..2fa1dc496 100644 --- a/services/opensearch/src/stackit/opensearch/models/instance.py +++ b/services/opensearch/src/stackit/opensearch/models/instance.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.opensearch.models.instance_last_operation import InstanceLastOperation @@ -72,7 +73,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -83,8 +85,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/instance_last_operation.py b/services/opensearch/src/stackit/opensearch/models/instance_last_operation.py index d0b6a0d95..e291376a3 100644 --- a/services/opensearch/src/stackit/opensearch/models/instance_last_operation.py +++ b/services/opensearch/src/stackit/opensearch/models/instance_last_operation.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -46,7 +47,8 @@ def type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -57,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/instance_parameters.py b/services/opensearch/src/stackit/opensearch/models/instance_parameters.py index 5a145f509..0c50f7906 100644 --- a/services/opensearch/src/stackit/opensearch/models/instance_parameters.py +++ b/services/opensearch/src/stackit/opensearch/models/instance_parameters.py @@ -26,6 +26,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -126,7 +127,8 @@ def tls_protocols_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -137,8 +139,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/instance_schema.py b/services/opensearch/src/stackit/opensearch/models/instance_schema.py index 9f59459ff..78b95801f 100644 --- a/services/opensearch/src/stackit/opensearch/models/instance_schema.py +++ b/services/opensearch/src/stackit/opensearch/models/instance_schema.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.opensearch.models.model_schema import ModelSchema @@ -33,7 +34,8 @@ class InstanceSchema(BaseModel): __properties: ClassVar[List[str]] = ["create", "update"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/list_backups_response.py b/services/opensearch/src/stackit/opensearch/models/list_backups_response.py index 0b7d8e1a6..c3ccd226b 100644 --- a/services/opensearch/src/stackit/opensearch/models/list_backups_response.py +++ b/services/opensearch/src/stackit/opensearch/models/list_backups_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.opensearch.models.backup import Backup @@ -32,7 +33,8 @@ class ListBackupsResponse(BaseModel): __properties: ClassVar[List[str]] = ["instanceBackups"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/list_credentials_response.py b/services/opensearch/src/stackit/opensearch/models/list_credentials_response.py index a7c2b5fc7..d1a84d9e7 100644 --- a/services/opensearch/src/stackit/opensearch/models/list_credentials_response.py +++ b/services/opensearch/src/stackit/opensearch/models/list_credentials_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.opensearch.models.credentials_list_item import CredentialsListItem @@ -32,7 +33,8 @@ class ListCredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["credentialsList"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/list_instances_response.py b/services/opensearch/src/stackit/opensearch/models/list_instances_response.py index fd3a42815..a96df12e7 100644 --- a/services/opensearch/src/stackit/opensearch/models/list_instances_response.py +++ b/services/opensearch/src/stackit/opensearch/models/list_instances_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.opensearch.models.instance import Instance @@ -32,7 +33,8 @@ class ListInstancesResponse(BaseModel): __properties: ClassVar[List[str]] = ["instances"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/list_offerings_response.py b/services/opensearch/src/stackit/opensearch/models/list_offerings_response.py index f7bf401c4..ff3b9ec75 100644 --- a/services/opensearch/src/stackit/opensearch/models/list_offerings_response.py +++ b/services/opensearch/src/stackit/opensearch/models/list_offerings_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.opensearch.models.offering import Offering @@ -32,7 +33,8 @@ class ListOfferingsResponse(BaseModel): __properties: ClassVar[List[str]] = ["offerings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/list_restores_response.py b/services/opensearch/src/stackit/opensearch/models/list_restores_response.py index 48fb22ca6..0aa5435c8 100644 --- a/services/opensearch/src/stackit/opensearch/models/list_restores_response.py +++ b/services/opensearch/src/stackit/opensearch/models/list_restores_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.opensearch.models.restore import Restore @@ -32,7 +33,8 @@ class ListRestoresResponse(BaseModel): __properties: ClassVar[List[str]] = ["instanceRestores"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/model_schema.py b/services/opensearch/src/stackit/opensearch/models/model_schema.py index 787ba9503..45963a740 100644 --- a/services/opensearch/src/stackit/opensearch/models/model_schema.py +++ b/services/opensearch/src/stackit/opensearch/models/model_schema.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class ModelSchema(BaseModel): __properties: ClassVar[List[str]] = ["parameters"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/offering.py b/services/opensearch/src/stackit/opensearch/models/offering.py index 5165bf9bc..ae538ea7f 100644 --- a/services/opensearch/src/stackit/opensearch/models/offering.py +++ b/services/opensearch/src/stackit/opensearch/models/offering.py @@ -25,6 +25,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.opensearch.models.instance_schema import InstanceSchema @@ -60,7 +61,8 @@ class Offering(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -71,8 +73,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/partial_update_instance_payload.py b/services/opensearch/src/stackit/opensearch/models/partial_update_instance_payload.py index 25c2a7048..0d88e2d49 100644 --- a/services/opensearch/src/stackit/opensearch/models/partial_update_instance_payload.py +++ b/services/opensearch/src/stackit/opensearch/models/partial_update_instance_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.opensearch.models.instance_parameters import InstanceParameters @@ -34,7 +35,8 @@ class PartialUpdateInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["instanceName", "parameters", "planId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/plan.py b/services/opensearch/src/stackit/opensearch/models/plan.py index 080987cdd..f2d1be1fd 100644 --- a/services/opensearch/src/stackit/opensearch/models/plan.py +++ b/services/opensearch/src/stackit/opensearch/models/plan.py @@ -24,6 +24,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -40,7 +41,8 @@ class Plan(BaseModel): __properties: ClassVar[List[str]] = ["description", "free", "id", "name", "skuName"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/raw_credentials.py b/services/opensearch/src/stackit/opensearch/models/raw_credentials.py index ed82169ce..ebf720076 100644 --- a/services/opensearch/src/stackit/opensearch/models/raw_credentials.py +++ b/services/opensearch/src/stackit/opensearch/models/raw_credentials.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.opensearch.models.credentials import Credentials @@ -32,7 +33,8 @@ class RawCredentials(BaseModel): __properties: ClassVar[List[str]] = ["credentials"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/restore.py b/services/opensearch/src/stackit/opensearch/models/restore.py index 37537ac43..d95f7e8f7 100644 --- a/services/opensearch/src/stackit/opensearch/models/restore.py +++ b/services/opensearch/src/stackit/opensearch/models/restore.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class Restore(BaseModel): __properties: ClassVar[List[str]] = ["backup_id", "finished_at", "id", "status", "triggered_at"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/trigger_restore_response.py b/services/opensearch/src/stackit/opensearch/models/trigger_restore_response.py index 93cb5fd2b..8ba3dc239 100644 --- a/services/opensearch/src/stackit/opensearch/models/trigger_restore_response.py +++ b/services/opensearch/src/stackit/opensearch/models/trigger_restore_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class TriggerRestoreResponse(BaseModel): __properties: ClassVar[List[str]] = ["id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/update_backups_config_payload.py b/services/opensearch/src/stackit/opensearch/models/update_backups_config_payload.py index 7d5782d92..8466a30f4 100644 --- a/services/opensearch/src/stackit/opensearch/models/update_backups_config_payload.py +++ b/services/opensearch/src/stackit/opensearch/models/update_backups_config_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class UpdateBackupsConfigPayload(BaseModel): __properties: ClassVar[List[str]] = ["encryption_key"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/opensearch/src/stackit/opensearch/models/update_backups_config_response.py b/services/opensearch/src/stackit/opensearch/models/update_backups_config_response.py index 57b3f7efa..0f59a893d 100644 --- a/services/opensearch/src/stackit/opensearch/models/update_backups_config_response.py +++ b/services/opensearch/src/stackit/opensearch/models/update_backups_config_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class UpdateBackupsConfigResponse(BaseModel): __properties: ClassVar[List[str]] = ["message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/CHANGELOG.md b/services/postgresflex/CHANGELOG.md index 3fa15fd13..4ea284fed 100644 --- a/services/postgresflex/CHANGELOG.md +++ b/services/postgresflex/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.3.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v1.2.2 - **Feature:** client now supports UUID and decimal types - **Bugfix:** timeouts now passed to requests library diff --git a/services/postgresflex/pyproject.toml b/services/postgresflex/pyproject.toml index 7e619e599..9e8e9215e 100644 --- a/services/postgresflex/pyproject.toml +++ b/services/postgresflex/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-postgresflex" -version = "v1.2.2" +version = "v1.3.0" description = "STACKIT PostgreSQL Flex API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/postgresflex/src/stackit/postgresflex/api_client.py b/services/postgresflex/src/stackit/postgresflex/api_client.py index 7d529c80d..993ad5c99 100644 --- a/services/postgresflex/src/stackit/postgresflex/api_client.py +++ b/services/postgresflex/src/stackit/postgresflex/api_client.py @@ -67,6 +67,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -266,7 +267,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -327,25 +328,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -418,6 +414,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/postgresflex/src/stackit/postgresflex/models/acl.py b/services/postgresflex/src/stackit/postgresflex/models/acl.py index 2820eccd2..775545308 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/acl.py +++ b/services/postgresflex/src/stackit/postgresflex/models/acl.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class ACL(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/api_configuration.py b/services/postgresflex/src/stackit/postgresflex/models/api_configuration.py index ce288d1f5..7b88394e6 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/api_configuration.py +++ b/services/postgresflex/src/stackit/postgresflex/models/api_configuration.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class ApiConfiguration(BaseModel): __properties: ClassVar[List[str]] = ["name", "setting"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/api_extension_config_load_response.py b/services/postgresflex/src/stackit/postgresflex/models/api_extension_config_load_response.py index e80d6ce40..f896ec03e 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/api_extension_config_load_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/api_extension_config_load_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.api_configuration import ApiConfiguration @@ -35,7 +36,8 @@ class ApiExtensionConfigLoadResponse(BaseModel): __properties: ClassVar[List[str]] = ["configuration"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/api_extension_configure_response.py b/services/postgresflex/src/stackit/postgresflex/models/api_extension_configure_response.py index 3f408fca9..c50285748 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/api_extension_configure_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/api_extension_configure_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.api_configuration import ApiConfiguration @@ -35,7 +36,8 @@ class ApiExtensionConfigureResponse(BaseModel): __properties: ClassVar[List[str]] = ["configuration"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/api_extension_delete_response.py b/services/postgresflex/src/stackit/postgresflex/models/api_extension_delete_response.py index 6cb9750ef..aaecb8b83 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/api_extension_delete_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/api_extension_delete_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class ApiExtensionDeleteResponse(BaseModel): __properties: ClassVar[List[str]] = ["isSucceded"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/api_extension_list.py b/services/postgresflex/src/stackit/postgresflex/models/api_extension_list.py index c4314a200..e299f18bb 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/api_extension_list.py +++ b/services/postgresflex/src/stackit/postgresflex/models/api_extension_list.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -33,7 +34,8 @@ class ApiExtensionList(BaseModel): __properties: ClassVar[List[str]] = ["ID", "description", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/api_extension_load_response.py b/services/postgresflex/src/stackit/postgresflex/models/api_extension_load_response.py index b62c5fc21..27dc49566 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/api_extension_load_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/api_extension_load_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.api_extension_list import ApiExtensionList @@ -33,7 +34,8 @@ class ApiExtensionLoadResponse(BaseModel): __properties: ClassVar[List[str]] = ["extension"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/api_install_response.py b/services/postgresflex/src/stackit/postgresflex/models/api_install_response.py index 225e27323..b4acb41c4 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/api_install_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/api_install_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.api_extension_list import ApiExtensionList @@ -33,7 +34,8 @@ class ApiInstallResponse(BaseModel): __properties: ClassVar[List[str]] = ["extension"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/api_installed_list_response.py b/services/postgresflex/src/stackit/postgresflex/models/api_installed_list_response.py index 87c9694be..79f81365c 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/api_installed_list_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/api_installed_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.api_extension_list import ApiExtensionList @@ -33,7 +34,8 @@ class ApiInstalledListResponse(BaseModel): __properties: ClassVar[List[str]] = ["installed"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/backup.py b/services/postgresflex/src/stackit/postgresflex/models/backup.py index 8cb8cdf06..30997b482 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/backup.py +++ b/services/postgresflex/src/stackit/postgresflex/models/backup.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -38,7 +39,8 @@ class Backup(BaseModel): __properties: ClassVar[List[str]] = ["endTime", "error", "id", "labels", "name", "options", "size", "startTime"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/clone_instance_payload.py b/services/postgresflex/src/stackit/postgresflex/models/clone_instance_payload.py index 03511bd36..63c404a06 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/clone_instance_payload.py +++ b/services/postgresflex/src/stackit/postgresflex/models/clone_instance_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -36,7 +37,8 @@ class CloneInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["class", "size", "timestamp"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/clone_instance_response.py b/services/postgresflex/src/stackit/postgresflex/models/clone_instance_response.py index 5a9d53430..b7d68ecc6 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/clone_instance_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/clone_instance_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class CloneInstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["instanceId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/create_database_payload.py b/services/postgresflex/src/stackit/postgresflex/models/create_database_payload.py index 08e5e0978..117dc67ce 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/create_database_payload.py +++ b/services/postgresflex/src/stackit/postgresflex/models/create_database_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class CreateDatabasePayload(BaseModel): __properties: ClassVar[List[str]] = ["name", "options"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/create_instance_payload.py b/services/postgresflex/src/stackit/postgresflex/models/create_instance_payload.py index 7745c9a8a..759ba551d 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/create_instance_payload.py +++ b/services/postgresflex/src/stackit/postgresflex/models/create_instance_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.acl import ACL @@ -52,7 +53,8 @@ class CreateInstancePayload(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -63,8 +65,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/create_instance_response.py b/services/postgresflex/src/stackit/postgresflex/models/create_instance_response.py index 2dcaf5375..c6fe88e65 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/create_instance_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/create_instance_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class CreateInstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/create_user_payload.py b/services/postgresflex/src/stackit/postgresflex/models/create_user_payload.py index 3318ee397..a8c8147c7 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/create_user_payload.py +++ b/services/postgresflex/src/stackit/postgresflex/models/create_user_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class CreateUserPayload(BaseModel): __properties: ClassVar[List[str]] = ["roles", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/create_user_response.py b/services/postgresflex/src/stackit/postgresflex/models/create_user_response.py index 5bd1a015d..1740eb378 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/create_user_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/create_user_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.user import User @@ -33,7 +34,8 @@ class CreateUserResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/error.py b/services/postgresflex/src/stackit/postgresflex/models/error.py index f32c1e866..a3888d1d9 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/error.py +++ b/services/postgresflex/src/stackit/postgresflex/models/error.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class Error(BaseModel): __properties: ClassVar[List[str]] = ["code", "fields", "message", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/extensions_configuration.py b/services/postgresflex/src/stackit/postgresflex/models/extensions_configuration.py index 5631666ca..d61db576b 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/extensions_configuration.py +++ b/services/postgresflex/src/stackit/postgresflex/models/extensions_configuration.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class ExtensionsConfiguration(BaseModel): __properties: ClassVar[List[str]] = ["name", "setting"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/extensions_extension_list_response.py b/services/postgresflex/src/stackit/postgresflex/models/extensions_extension_list_response.py index 2ef9ab5b6..9f29da046 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/extensions_extension_list_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/extensions_extension_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.api_extension_list import ApiExtensionList @@ -33,7 +34,8 @@ class ExtensionsExtensionListResponse(BaseModel): __properties: ClassVar[List[str]] = ["list"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/extensions_new_config.py b/services/postgresflex/src/stackit/postgresflex/models/extensions_new_config.py index 269db363f..61446afe3 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/extensions_new_config.py +++ b/services/postgresflex/src/stackit/postgresflex/models/extensions_new_config.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.extensions_configuration import ExtensionsConfiguration @@ -33,7 +34,8 @@ class ExtensionsNewConfig(BaseModel): __properties: ClassVar[List[str]] = ["configuration"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/flavor.py b/services/postgresflex/src/stackit/postgresflex/models/flavor.py index 77efd2ac7..2ecdb6386 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/flavor.py +++ b/services/postgresflex/src/stackit/postgresflex/models/flavor.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class Flavor(BaseModel): __properties: ClassVar[List[str]] = ["cpu", "description", "id", "memory"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/get_backup_response.py b/services/postgresflex/src/stackit/postgresflex/models/get_backup_response.py index 5e6b619e1..6b04ae765 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/get_backup_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/get_backup_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.backup import Backup @@ -33,7 +34,8 @@ class GetBackupResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/get_user_response.py b/services/postgresflex/src/stackit/postgresflex/models/get_user_response.py index 85f782495..00483a761 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/get_user_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/get_user_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.user_response import UserResponse @@ -33,7 +34,8 @@ class GetUserResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/instance.py b/services/postgresflex/src/stackit/postgresflex/models/instance.py index 2c5656425..0601bf945 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/instance.py +++ b/services/postgresflex/src/stackit/postgresflex/models/instance.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.acl import ACL @@ -55,7 +56,8 @@ class Instance(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -66,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/instance_create_database_response.py b/services/postgresflex/src/stackit/postgresflex/models/instance_create_database_response.py index ce9af7026..f9eb5f7f9 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/instance_create_database_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/instance_create_database_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class InstanceCreateDatabaseResponse(BaseModel): __properties: ClassVar[List[str]] = ["id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/instance_data_point.py b/services/postgresflex/src/stackit/postgresflex/models/instance_data_point.py index 8ebb41645..9c82bb602 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/instance_data_point.py +++ b/services/postgresflex/src/stackit/postgresflex/models/instance_data_point.py @@ -25,6 +25,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -38,7 +39,8 @@ class InstanceDataPoint(BaseModel): __properties: ClassVar[List[str]] = ["timestamp", "value"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/instance_database.py b/services/postgresflex/src/stackit/postgresflex/models/instance_database.py index bccc7cf4f..a98ab82a0 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/instance_database.py +++ b/services/postgresflex/src/stackit/postgresflex/models/instance_database.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -33,7 +34,8 @@ class InstanceDatabase(BaseModel): __properties: ClassVar[List[str]] = ["id", "name", "options"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/instance_host.py b/services/postgresflex/src/stackit/postgresflex/models/instance_host.py index a55a421ad..d41c48f60 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/instance_host.py +++ b/services/postgresflex/src/stackit/postgresflex/models/instance_host.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.instance_host_metric import InstanceHostMetric @@ -34,7 +35,8 @@ class InstanceHost(BaseModel): __properties: ClassVar[List[str]] = ["hostMetrics", "id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/instance_host_metric.py b/services/postgresflex/src/stackit/postgresflex/models/instance_host_metric.py index 89f74e085..f58c7c8fe 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/instance_host_metric.py +++ b/services/postgresflex/src/stackit/postgresflex/models/instance_host_metric.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.instance_data_point import InstanceDataPoint @@ -35,7 +36,8 @@ class InstanceHostMetric(BaseModel): __properties: ClassVar[List[str]] = ["datapoints", "name", "units"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/instance_list_databases_response.py b/services/postgresflex/src/stackit/postgresflex/models/instance_list_databases_response.py index 5c23325ee..9c3fd7020 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/instance_list_databases_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/instance_list_databases_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.instance_database import InstanceDatabase @@ -33,7 +34,8 @@ class InstanceListDatabasesResponse(BaseModel): __properties: ClassVar[List[str]] = ["databases"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/instance_list_instance.py b/services/postgresflex/src/stackit/postgresflex/models/instance_list_instance.py index 304e665fa..b382e9a09 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/instance_list_instance.py +++ b/services/postgresflex/src/stackit/postgresflex/models/instance_list_instance.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -33,7 +34,8 @@ class InstanceListInstance(BaseModel): __properties: ClassVar[List[str]] = ["id", "name", "status"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/instance_metrics_response.py b/services/postgresflex/src/stackit/postgresflex/models/instance_metrics_response.py index 9c4ebd18b..97a580ac1 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/instance_metrics_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/instance_metrics_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.instance_host import InstanceHost @@ -33,7 +34,8 @@ class InstanceMetricsResponse(BaseModel): __properties: ClassVar[List[str]] = ["hosts"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/instance_response.py b/services/postgresflex/src/stackit/postgresflex/models/instance_response.py index 4577bd6b8..09e6b3717 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/instance_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/instance_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.instance import Instance @@ -33,7 +34,8 @@ class InstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/list_backups_response.py b/services/postgresflex/src/stackit/postgresflex/models/list_backups_response.py index 59e179cdd..b3c65fa5d 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/list_backups_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/list_backups_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.backup import Backup @@ -34,7 +35,8 @@ class ListBackupsResponse(BaseModel): __properties: ClassVar[List[str]] = ["count", "items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/list_flavors_response.py b/services/postgresflex/src/stackit/postgresflex/models/list_flavors_response.py index fd725fc60..d3c64117e 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/list_flavors_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/list_flavors_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.flavor import Flavor @@ -33,7 +34,8 @@ class ListFlavorsResponse(BaseModel): __properties: ClassVar[List[str]] = ["flavors"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/list_instances_response.py b/services/postgresflex/src/stackit/postgresflex/models/list_instances_response.py index 259e4233e..024a3bdf3 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/list_instances_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/list_instances_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.instance_list_instance import InstanceListInstance @@ -34,7 +35,8 @@ class ListInstancesResponse(BaseModel): __properties: ClassVar[List[str]] = ["count", "items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/list_storages_response.py b/services/postgresflex/src/stackit/postgresflex/models/list_storages_response.py index 625ceb2c3..1a032b614 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/list_storages_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/list_storages_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.storage_range import StorageRange @@ -34,7 +35,8 @@ class ListStoragesResponse(BaseModel): __properties: ClassVar[List[str]] = ["storageClasses", "storageRange"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/list_users_response.py b/services/postgresflex/src/stackit/postgresflex/models/list_users_response.py index 32bf7bf87..71833e34c 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/list_users_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/list_users_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.list_users_response_item import ListUsersResponseItem @@ -34,7 +35,8 @@ class ListUsersResponse(BaseModel): __properties: ClassVar[List[str]] = ["count", "items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/list_users_response_item.py b/services/postgresflex/src/stackit/postgresflex/models/list_users_response_item.py index 7640d4b93..8ba333a35 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/list_users_response_item.py +++ b/services/postgresflex/src/stackit/postgresflex/models/list_users_response_item.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class ListUsersResponseItem(BaseModel): __properties: ClassVar[List[str]] = ["id", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/list_versions_response.py b/services/postgresflex/src/stackit/postgresflex/models/list_versions_response.py index 68de74b71..863dd8bdd 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/list_versions_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/list_versions_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class ListVersionsResponse(BaseModel): __properties: ClassVar[List[str]] = ["versions"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/partial_update_instance_payload.py b/services/postgresflex/src/stackit/postgresflex/models/partial_update_instance_payload.py index b90ddd023..8a5c1d783 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/partial_update_instance_payload.py +++ b/services/postgresflex/src/stackit/postgresflex/models/partial_update_instance_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.acl import ACL @@ -52,7 +53,8 @@ class PartialUpdateInstancePayload(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -63,8 +65,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/partial_update_instance_response.py b/services/postgresflex/src/stackit/postgresflex/models/partial_update_instance_response.py index 64c658163..2607e2f3f 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/partial_update_instance_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/partial_update_instance_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.instance import Instance @@ -33,7 +34,8 @@ class PartialUpdateInstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/partial_update_user_payload.py b/services/postgresflex/src/stackit/postgresflex/models/partial_update_user_payload.py index 65dfef9de..0ee64813c 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/partial_update_user_payload.py +++ b/services/postgresflex/src/stackit/postgresflex/models/partial_update_user_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class PartialUpdateUserPayload(BaseModel): __properties: ClassVar[List[str]] = ["database", "roles"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/postgres_database_parameter.py b/services/postgresflex/src/stackit/postgresflex/models/postgres_database_parameter.py index a4a14f17b..e4f3320cb 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/postgres_database_parameter.py +++ b/services/postgresflex/src/stackit/postgresflex/models/postgres_database_parameter.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -77,7 +78,8 @@ class PostgresDatabaseParameter(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -88,8 +90,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/postgres_database_parameter_response.py b/services/postgresflex/src/stackit/postgresflex/models/postgres_database_parameter_response.py index 6838a60ee..73d7220f4 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/postgres_database_parameter_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/postgres_database_parameter_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.postgres_database_parameter import ( @@ -35,7 +36,8 @@ class PostgresDatabaseParameterResponse(BaseModel): __properties: ClassVar[List[str]] = ["parameter"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/reset_user_response.py b/services/postgresflex/src/stackit/postgresflex/models/reset_user_response.py index 96cd9f360..45359d35b 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/reset_user_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/reset_user_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.user import User @@ -33,7 +34,8 @@ class ResetUserResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/storage.py b/services/postgresflex/src/stackit/postgresflex/models/storage.py index e904ce69c..121d571fc 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/storage.py +++ b/services/postgresflex/src/stackit/postgresflex/models/storage.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class Storage(BaseModel): __properties: ClassVar[List[str]] = ["class", "size"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/storage_range.py b/services/postgresflex/src/stackit/postgresflex/models/storage_range.py index d044eeb59..f88c3af27 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/storage_range.py +++ b/services/postgresflex/src/stackit/postgresflex/models/storage_range.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class StorageRange(BaseModel): __properties: ClassVar[List[str]] = ["max", "min"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/storage_update.py b/services/postgresflex/src/stackit/postgresflex/models/storage_update.py index d7dc0de24..6dc0ff629 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/storage_update.py +++ b/services/postgresflex/src/stackit/postgresflex/models/storage_update.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -36,7 +37,8 @@ class StorageUpdate(BaseModel): __properties: ClassVar[List[str]] = ["class", "size"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/update_backup_schedule_payload.py b/services/postgresflex/src/stackit/postgresflex/models/update_backup_schedule_payload.py index b1a172e01..a77dbf80d 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/update_backup_schedule_payload.py +++ b/services/postgresflex/src/stackit/postgresflex/models/update_backup_schedule_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class UpdateBackupSchedulePayload(BaseModel): __properties: ClassVar[List[str]] = ["backupSchedule"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/update_instance_payload.py b/services/postgresflex/src/stackit/postgresflex/models/update_instance_payload.py index bd7e8a93a..510959014 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/update_instance_payload.py +++ b/services/postgresflex/src/stackit/postgresflex/models/update_instance_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.postgresflex.models.acl import ACL @@ -52,7 +53,8 @@ class UpdateInstancePayload(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -63,8 +65,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/update_user_payload.py b/services/postgresflex/src/stackit/postgresflex/models/update_user_payload.py index 57722fba6..660abf505 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/update_user_payload.py +++ b/services/postgresflex/src/stackit/postgresflex/models/update_user_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class UpdateUserPayload(BaseModel): __properties: ClassVar[List[str]] = ["database", "roles"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/user.py b/services/postgresflex/src/stackit/postgresflex/models/user.py index 5aeede49f..3691eae89 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/user.py +++ b/services/postgresflex/src/stackit/postgresflex/models/user.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -38,7 +39,8 @@ class User(BaseModel): __properties: ClassVar[List[str]] = ["database", "host", "id", "password", "port", "roles", "uri", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/postgresflex/src/stackit/postgresflex/models/user_response.py b/services/postgresflex/src/stackit/postgresflex/models/user_response.py index abd85fdd9..c49c3f68d 100644 --- a/services/postgresflex/src/stackit/postgresflex/models/user_response.py +++ b/services/postgresflex/src/stackit/postgresflex/models/user_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -35,7 +36,8 @@ class UserResponse(BaseModel): __properties: ClassVar[List[str]] = ["host", "id", "port", "roles", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/CHANGELOG.md b/services/rabbitmq/CHANGELOG.md index bb9459d24..40879c8bb 100644 --- a/services/rabbitmq/CHANGELOG.md +++ b/services/rabbitmq/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.5.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.4.1 - **Feature:** client now supports UUID and decimal types - **Bugfix:** timeouts now passed to requests library diff --git a/services/rabbitmq/pyproject.toml b/services/rabbitmq/pyproject.toml index e81720efb..e1569d4fc 100644 --- a/services/rabbitmq/pyproject.toml +++ b/services/rabbitmq/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-rabbitmq" -version = "v0.4.1" +version = "v0.5.0" description = "STACKIT RabbitMQ API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/rabbitmq/src/stackit/rabbitmq/api/default_api.py b/services/rabbitmq/src/stackit/rabbitmq/api/default_api.py index 80697994b..d255634a4 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/api/default_api.py +++ b/services/rabbitmq/src/stackit/rabbitmq/api/default_api.py @@ -1332,7 +1332,7 @@ def download_backup( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> bytearray: + ) -> bytes: """download backup @@ -1375,7 +1375,7 @@ def download_backup( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "bytearray", + "200": "bytes", "500": "Error", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -1400,7 +1400,7 @@ def download_backup_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[bytearray]: + ) -> ApiResponse[bytes]: """download backup @@ -1443,7 +1443,7 @@ def download_backup_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "bytearray", + "200": "bytes", "500": "Error", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -1511,7 +1511,7 @@ def download_backup_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "bytearray", + "200": "bytes", "500": "Error", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) diff --git a/services/rabbitmq/src/stackit/rabbitmq/api_client.py b/services/rabbitmq/src/stackit/rabbitmq/api_client.py index 8dbb39e75..8459a2ee1 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/api_client.py +++ b/services/rabbitmq/src/stackit/rabbitmq/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/backup.py b/services/rabbitmq/src/stackit/rabbitmq/models/backup.py index 59d153598..cecddf1e2 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/backup.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/backup.py @@ -24,6 +24,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -41,7 +42,8 @@ class Backup(BaseModel): __properties: ClassVar[List[str]] = ["downloadable", "finished_at", "id", "size", "status", "triggered_at"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -52,8 +54,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/create_backup_response_item.py b/services/rabbitmq/src/stackit/rabbitmq/models/create_backup_response_item.py index c0c4eed25..6d928d5a3 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/create_backup_response_item.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/create_backup_response_item.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class CreateBackupResponseItem(BaseModel): __properties: ClassVar[List[str]] = ["id", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/create_instance_payload.py b/services/rabbitmq/src/stackit/rabbitmq/models/create_instance_payload.py index 3971b02d1..93c08e812 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/create_instance_payload.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/create_instance_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.rabbitmq.models.instance_parameters import InstanceParameters @@ -34,7 +35,8 @@ class CreateInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["instanceName", "parameters", "planId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/create_instance_response.py b/services/rabbitmq/src/stackit/rabbitmq/models/create_instance_response.py index 25d84e8e0..da9f9993e 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/create_instance_response.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/create_instance_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class CreateInstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["instanceId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/credentials.py b/services/rabbitmq/src/stackit/rabbitmq/models/credentials.py index ca57899d3..c5d504d33 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/credentials.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/credentials.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -54,7 +55,8 @@ class Credentials(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -65,8 +67,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/credentials_list_item.py b/services/rabbitmq/src/stackit/rabbitmq/models/credentials_list_item.py index 999d264fe..295a1b288 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/credentials_list_item.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/credentials_list_item.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class CredentialsListItem(BaseModel): __properties: ClassVar[List[str]] = ["id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/credentials_response.py b/services/rabbitmq/src/stackit/rabbitmq/models/credentials_response.py index 0351a8c35..516f02ccc 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/credentials_response.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/credentials_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.rabbitmq.models.raw_credentials import RawCredentials @@ -34,7 +35,8 @@ class CredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["id", "raw", "uri"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/error.py b/services/rabbitmq/src/stackit/rabbitmq/models/error.py index 8a737ddbe..d0800f2a2 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/error.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/error.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class Error(BaseModel): __properties: ClassVar[List[str]] = ["description", "error"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/get_metrics_response.py b/services/rabbitmq/src/stackit/rabbitmq/models/get_metrics_response.py index 1b44fc908..5e27f1cb9 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/get_metrics_response.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/get_metrics_response.py @@ -25,6 +25,7 @@ StrictFloat, StrictInt, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -83,7 +84,8 @@ class GetMetricsResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -94,8 +96,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/instance.py b/services/rabbitmq/src/stackit/rabbitmq/models/instance.py index 439e0d01c..d71d6c89e 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/instance.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/instance.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.rabbitmq.models.instance_last_operation import InstanceLastOperation @@ -72,7 +73,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -83,8 +85,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/instance_last_operation.py b/services/rabbitmq/src/stackit/rabbitmq/models/instance_last_operation.py index 8c5ed27c5..05bac326c 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/instance_last_operation.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/instance_last_operation.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -46,7 +47,8 @@ def type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -57,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/instance_parameters.py b/services/rabbitmq/src/stackit/rabbitmq/models/instance_parameters.py index f9ebf3464..817e1f770 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/instance_parameters.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/instance_parameters.py @@ -26,6 +26,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -117,7 +118,8 @@ def tls_protocols_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -128,8 +130,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/instance_schema.py b/services/rabbitmq/src/stackit/rabbitmq/models/instance_schema.py index 28f195b2d..a3de89132 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/instance_schema.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/instance_schema.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.rabbitmq.models.model_schema import ModelSchema @@ -33,7 +34,8 @@ class InstanceSchema(BaseModel): __properties: ClassVar[List[str]] = ["create", "update"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/list_backups_response.py b/services/rabbitmq/src/stackit/rabbitmq/models/list_backups_response.py index 41401a163..526453e79 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/list_backups_response.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/list_backups_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.rabbitmq.models.backup import Backup @@ -32,7 +33,8 @@ class ListBackupsResponse(BaseModel): __properties: ClassVar[List[str]] = ["instanceBackups"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/list_credentials_response.py b/services/rabbitmq/src/stackit/rabbitmq/models/list_credentials_response.py index 93f322035..fbf065edc 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/list_credentials_response.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/list_credentials_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.rabbitmq.models.credentials_list_item import CredentialsListItem @@ -32,7 +33,8 @@ class ListCredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["credentialsList"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/list_instances_response.py b/services/rabbitmq/src/stackit/rabbitmq/models/list_instances_response.py index 9d7879428..47834f088 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/list_instances_response.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/list_instances_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.rabbitmq.models.instance import Instance @@ -32,7 +33,8 @@ class ListInstancesResponse(BaseModel): __properties: ClassVar[List[str]] = ["instances"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/list_offerings_response.py b/services/rabbitmq/src/stackit/rabbitmq/models/list_offerings_response.py index 16451aeae..6731c30f9 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/list_offerings_response.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/list_offerings_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.rabbitmq.models.offering import Offering @@ -32,7 +33,8 @@ class ListOfferingsResponse(BaseModel): __properties: ClassVar[List[str]] = ["offerings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/list_restores_response.py b/services/rabbitmq/src/stackit/rabbitmq/models/list_restores_response.py index 4c8b53c8b..5d69806bc 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/list_restores_response.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/list_restores_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.rabbitmq.models.restore import Restore @@ -32,7 +33,8 @@ class ListRestoresResponse(BaseModel): __properties: ClassVar[List[str]] = ["instanceRestores"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/model_schema.py b/services/rabbitmq/src/stackit/rabbitmq/models/model_schema.py index 36cf95911..1672195d1 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/model_schema.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/model_schema.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class ModelSchema(BaseModel): __properties: ClassVar[List[str]] = ["parameters"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/offering.py b/services/rabbitmq/src/stackit/rabbitmq/models/offering.py index cce0c440c..d3b38a2f0 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/offering.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/offering.py @@ -25,6 +25,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.rabbitmq.models.instance_schema import InstanceSchema @@ -60,7 +61,8 @@ class Offering(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -71,8 +73,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/partial_update_instance_payload.py b/services/rabbitmq/src/stackit/rabbitmq/models/partial_update_instance_payload.py index 7b848cd6a..386215197 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/partial_update_instance_payload.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/partial_update_instance_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.rabbitmq.models.instance_parameters import InstanceParameters @@ -34,7 +35,8 @@ class PartialUpdateInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["instanceName", "parameters", "planId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/plan.py b/services/rabbitmq/src/stackit/rabbitmq/models/plan.py index 4e22ed2fe..48760d43d 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/plan.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/plan.py @@ -24,6 +24,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -40,7 +41,8 @@ class Plan(BaseModel): __properties: ClassVar[List[str]] = ["description", "free", "id", "name", "skuName"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/raw_credentials.py b/services/rabbitmq/src/stackit/rabbitmq/models/raw_credentials.py index 7a308a820..783e2fe75 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/raw_credentials.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/raw_credentials.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.rabbitmq.models.credentials import Credentials @@ -32,7 +33,8 @@ class RawCredentials(BaseModel): __properties: ClassVar[List[str]] = ["credentials"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/restore.py b/services/rabbitmq/src/stackit/rabbitmq/models/restore.py index 716bba557..0b9e80c02 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/restore.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/restore.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class Restore(BaseModel): __properties: ClassVar[List[str]] = ["backup_id", "finished_at", "id", "status", "triggered_at"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/trigger_restore_response.py b/services/rabbitmq/src/stackit/rabbitmq/models/trigger_restore_response.py index 0074db901..225df6207 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/trigger_restore_response.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/trigger_restore_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class TriggerRestoreResponse(BaseModel): __properties: ClassVar[List[str]] = ["id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/update_backups_config_payload.py b/services/rabbitmq/src/stackit/rabbitmq/models/update_backups_config_payload.py index ac6a6121d..66faaddf8 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/update_backups_config_payload.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/update_backups_config_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class UpdateBackupsConfigPayload(BaseModel): __properties: ClassVar[List[str]] = ["encryption_key"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/rabbitmq/src/stackit/rabbitmq/models/update_backups_config_response.py b/services/rabbitmq/src/stackit/rabbitmq/models/update_backups_config_response.py index 71a34f068..208401c80 100644 --- a/services/rabbitmq/src/stackit/rabbitmq/models/update_backups_config_response.py +++ b/services/rabbitmq/src/stackit/rabbitmq/models/update_backups_config_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class UpdateBackupsConfigResponse(BaseModel): __properties: ClassVar[List[str]] = ["message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/CHANGELOG.md b/services/redis/CHANGELOG.md index 8ca7565fc..efaa4aaf7 100644 --- a/services/redis/CHANGELOG.md +++ b/services/redis/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.4.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.3.1 - **Feature:** client now supports UUID and decimal types - **Bugfix:** timeouts now passed to requests library diff --git a/services/redis/pyproject.toml b/services/redis/pyproject.toml index b1ae95bbe..10683748e 100644 --- a/services/redis/pyproject.toml +++ b/services/redis/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-redis" -version = "v0.3.1" +version = "v0.4.0" description = "STACKIT Redis API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/redis/src/stackit/redis/api/default_api.py b/services/redis/src/stackit/redis/api/default_api.py index 4eb2e3387..e03da7a98 100644 --- a/services/redis/src/stackit/redis/api/default_api.py +++ b/services/redis/src/stackit/redis/api/default_api.py @@ -1332,7 +1332,7 @@ def download_backup( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> bytearray: + ) -> bytes: """download backup @@ -1375,7 +1375,7 @@ def download_backup( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "bytearray", + "200": "bytes", "500": "Error", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -1400,7 +1400,7 @@ def download_backup_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[bytearray]: + ) -> ApiResponse[bytes]: """download backup @@ -1443,7 +1443,7 @@ def download_backup_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "bytearray", + "200": "bytes", "500": "Error", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -1511,7 +1511,7 @@ def download_backup_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - "200": "bytearray", + "200": "bytes", "500": "Error", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) diff --git a/services/redis/src/stackit/redis/api_client.py b/services/redis/src/stackit/redis/api_client.py index f06ee0eb1..d2178eaef 100644 --- a/services/redis/src/stackit/redis/api_client.py +++ b/services/redis/src/stackit/redis/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/redis/src/stackit/redis/models/backup.py b/services/redis/src/stackit/redis/models/backup.py index cb5dec453..3d7c08dd5 100644 --- a/services/redis/src/stackit/redis/models/backup.py +++ b/services/redis/src/stackit/redis/models/backup.py @@ -24,6 +24,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -41,7 +42,8 @@ class Backup(BaseModel): __properties: ClassVar[List[str]] = ["downloadable", "finished_at", "id", "size", "status", "triggered_at"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -52,8 +54,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/create_backup_response_item.py b/services/redis/src/stackit/redis/models/create_backup_response_item.py index 8445a5ff7..b34c88411 100644 --- a/services/redis/src/stackit/redis/models/create_backup_response_item.py +++ b/services/redis/src/stackit/redis/models/create_backup_response_item.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class CreateBackupResponseItem(BaseModel): __properties: ClassVar[List[str]] = ["id", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/create_instance_payload.py b/services/redis/src/stackit/redis/models/create_instance_payload.py index 86bd7d31e..e771d20a0 100644 --- a/services/redis/src/stackit/redis/models/create_instance_payload.py +++ b/services/redis/src/stackit/redis/models/create_instance_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.redis.models.instance_parameters import InstanceParameters @@ -34,7 +35,8 @@ class CreateInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["instanceName", "parameters", "planId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/create_instance_response.py b/services/redis/src/stackit/redis/models/create_instance_response.py index ce53731d6..8a6db2b68 100644 --- a/services/redis/src/stackit/redis/models/create_instance_response.py +++ b/services/redis/src/stackit/redis/models/create_instance_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class CreateInstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["instanceId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/credentials.py b/services/redis/src/stackit/redis/models/credentials.py index 1bf1d8e6f..5c426b20e 100644 --- a/services/redis/src/stackit/redis/models/credentials.py +++ b/services/redis/src/stackit/redis/models/credentials.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -36,7 +37,8 @@ class Credentials(BaseModel): __properties: ClassVar[List[str]] = ["host", "hosts", "load_balanced_host", "password", "port", "uri", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/credentials_list_item.py b/services/redis/src/stackit/redis/models/credentials_list_item.py index 2fb40133f..4fb6503b1 100644 --- a/services/redis/src/stackit/redis/models/credentials_list_item.py +++ b/services/redis/src/stackit/redis/models/credentials_list_item.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class CredentialsListItem(BaseModel): __properties: ClassVar[List[str]] = ["id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/credentials_response.py b/services/redis/src/stackit/redis/models/credentials_response.py index 9ba217679..ef66370ba 100644 --- a/services/redis/src/stackit/redis/models/credentials_response.py +++ b/services/redis/src/stackit/redis/models/credentials_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.redis.models.raw_credentials import RawCredentials @@ -34,7 +35,8 @@ class CredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["id", "raw", "uri"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/error.py b/services/redis/src/stackit/redis/models/error.py index be31830a4..3b50194a5 100644 --- a/services/redis/src/stackit/redis/models/error.py +++ b/services/redis/src/stackit/redis/models/error.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class Error(BaseModel): __properties: ClassVar[List[str]] = ["description", "error"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/get_metrics_response.py b/services/redis/src/stackit/redis/models/get_metrics_response.py index 8bce2eb22..f09637bee 100644 --- a/services/redis/src/stackit/redis/models/get_metrics_response.py +++ b/services/redis/src/stackit/redis/models/get_metrics_response.py @@ -25,6 +25,7 @@ StrictFloat, StrictInt, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -83,7 +84,8 @@ class GetMetricsResponse(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -94,8 +96,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/instance.py b/services/redis/src/stackit/redis/models/instance.py index 8fb05296d..e469d6987 100644 --- a/services/redis/src/stackit/redis/models/instance.py +++ b/services/redis/src/stackit/redis/models/instance.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.redis.models.instance_last_operation import InstanceLastOperation @@ -72,7 +73,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -83,8 +85,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/instance_last_operation.py b/services/redis/src/stackit/redis/models/instance_last_operation.py index d07f71ec4..ebe574941 100644 --- a/services/redis/src/stackit/redis/models/instance_last_operation.py +++ b/services/redis/src/stackit/redis/models/instance_last_operation.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -46,7 +47,8 @@ def type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -57,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/instance_parameters.py b/services/redis/src/stackit/redis/models/instance_parameters.py index f1c778c3d..32f82d55d 100644 --- a/services/redis/src/stackit/redis/models/instance_parameters.py +++ b/services/redis/src/stackit/redis/models/instance_parameters.py @@ -26,6 +26,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -150,7 +151,8 @@ def tls_protocols_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -161,8 +163,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/instance_schema.py b/services/redis/src/stackit/redis/models/instance_schema.py index bdb20428d..447600b31 100644 --- a/services/redis/src/stackit/redis/models/instance_schema.py +++ b/services/redis/src/stackit/redis/models/instance_schema.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.redis.models.model_schema import ModelSchema @@ -33,7 +34,8 @@ class InstanceSchema(BaseModel): __properties: ClassVar[List[str]] = ["create", "update"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/list_backups_response.py b/services/redis/src/stackit/redis/models/list_backups_response.py index 9d3ce2f34..54c00ab7a 100644 --- a/services/redis/src/stackit/redis/models/list_backups_response.py +++ b/services/redis/src/stackit/redis/models/list_backups_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.redis.models.backup import Backup @@ -32,7 +33,8 @@ class ListBackupsResponse(BaseModel): __properties: ClassVar[List[str]] = ["instanceBackups"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/list_credentials_response.py b/services/redis/src/stackit/redis/models/list_credentials_response.py index bf70d862e..cdd5cb70f 100644 --- a/services/redis/src/stackit/redis/models/list_credentials_response.py +++ b/services/redis/src/stackit/redis/models/list_credentials_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.redis.models.credentials_list_item import CredentialsListItem @@ -32,7 +33,8 @@ class ListCredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["credentialsList"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/list_instances_response.py b/services/redis/src/stackit/redis/models/list_instances_response.py index c783c97f0..8d06eeb6e 100644 --- a/services/redis/src/stackit/redis/models/list_instances_response.py +++ b/services/redis/src/stackit/redis/models/list_instances_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.redis.models.instance import Instance @@ -32,7 +33,8 @@ class ListInstancesResponse(BaseModel): __properties: ClassVar[List[str]] = ["instances"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/list_offerings_response.py b/services/redis/src/stackit/redis/models/list_offerings_response.py index d0e6f2034..24a4fb6d6 100644 --- a/services/redis/src/stackit/redis/models/list_offerings_response.py +++ b/services/redis/src/stackit/redis/models/list_offerings_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.redis.models.offering import Offering @@ -32,7 +33,8 @@ class ListOfferingsResponse(BaseModel): __properties: ClassVar[List[str]] = ["offerings"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/list_restores_response.py b/services/redis/src/stackit/redis/models/list_restores_response.py index c2b1a1971..b4fd82669 100644 --- a/services/redis/src/stackit/redis/models/list_restores_response.py +++ b/services/redis/src/stackit/redis/models/list_restores_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.redis.models.restore import Restore @@ -32,7 +33,8 @@ class ListRestoresResponse(BaseModel): __properties: ClassVar[List[str]] = ["instanceRestores"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/model_schema.py b/services/redis/src/stackit/redis/models/model_schema.py index da461c083..a153bfeca 100644 --- a/services/redis/src/stackit/redis/models/model_schema.py +++ b/services/redis/src/stackit/redis/models/model_schema.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class ModelSchema(BaseModel): __properties: ClassVar[List[str]] = ["parameters"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/offering.py b/services/redis/src/stackit/redis/models/offering.py index 0feb33406..5f0450552 100644 --- a/services/redis/src/stackit/redis/models/offering.py +++ b/services/redis/src/stackit/redis/models/offering.py @@ -25,6 +25,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.redis.models.instance_schema import InstanceSchema @@ -60,7 +61,8 @@ class Offering(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -71,8 +73,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/partial_update_instance_payload.py b/services/redis/src/stackit/redis/models/partial_update_instance_payload.py index 9b72e74b1..14ca8d73c 100644 --- a/services/redis/src/stackit/redis/models/partial_update_instance_payload.py +++ b/services/redis/src/stackit/redis/models/partial_update_instance_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.redis.models.instance_parameters import InstanceParameters @@ -34,7 +35,8 @@ class PartialUpdateInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["instanceName", "parameters", "planId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/plan.py b/services/redis/src/stackit/redis/models/plan.py index fe21dfbef..bbda5301d 100644 --- a/services/redis/src/stackit/redis/models/plan.py +++ b/services/redis/src/stackit/redis/models/plan.py @@ -24,6 +24,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -40,7 +41,8 @@ class Plan(BaseModel): __properties: ClassVar[List[str]] = ["description", "free", "id", "name", "skuName"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/raw_credentials.py b/services/redis/src/stackit/redis/models/raw_credentials.py index 81fa60953..30a7f9bf8 100644 --- a/services/redis/src/stackit/redis/models/raw_credentials.py +++ b/services/redis/src/stackit/redis/models/raw_credentials.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.redis.models.credentials import Credentials @@ -32,7 +33,8 @@ class RawCredentials(BaseModel): __properties: ClassVar[List[str]] = ["credentials"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/restore.py b/services/redis/src/stackit/redis/models/restore.py index 02fa431e5..29a90b377 100644 --- a/services/redis/src/stackit/redis/models/restore.py +++ b/services/redis/src/stackit/redis/models/restore.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class Restore(BaseModel): __properties: ClassVar[List[str]] = ["backup_id", "finished_at", "id", "status", "triggered_at"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/trigger_restore_response.py b/services/redis/src/stackit/redis/models/trigger_restore_response.py index 7da520d0a..ee5880510 100644 --- a/services/redis/src/stackit/redis/models/trigger_restore_response.py +++ b/services/redis/src/stackit/redis/models/trigger_restore_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class TriggerRestoreResponse(BaseModel): __properties: ClassVar[List[str]] = ["id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/update_backups_config_payload.py b/services/redis/src/stackit/redis/models/update_backups_config_payload.py index 5dcc66894..2b2e184cc 100644 --- a/services/redis/src/stackit/redis/models/update_backups_config_payload.py +++ b/services/redis/src/stackit/redis/models/update_backups_config_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class UpdateBackupsConfigPayload(BaseModel): __properties: ClassVar[List[str]] = ["encryption_key"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/redis/src/stackit/redis/models/update_backups_config_response.py b/services/redis/src/stackit/redis/models/update_backups_config_response.py index 643eef0fd..e5df52a4f 100644 --- a/services/redis/src/stackit/redis/models/update_backups_config_response.py +++ b/services/redis/src/stackit/redis/models/update_backups_config_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class UpdateBackupsConfigResponse(BaseModel): __properties: ClassVar[List[str]] = ["message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/resourcemanager/CHANGELOG.md b/services/resourcemanager/CHANGELOG.md index 8747dcd65..d1c031bdb 100644 --- a/services/resourcemanager/CHANGELOG.md +++ b/services/resourcemanager/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.8.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.7.1 - **Feature:** client now supports UUID and decimal types - **Bugfix:** timeouts now passed to requests library diff --git a/services/resourcemanager/pyproject.toml b/services/resourcemanager/pyproject.toml index d203f6f50..25145aad1 100644 --- a/services/resourcemanager/pyproject.toml +++ b/services/resourcemanager/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-resourcemanager" -version = "v0.7.1" +version = "v0.8.0" description = "Resource Manager API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/resourcemanager/src/stackit/resourcemanager/api_client.py b/services/resourcemanager/src/stackit/resourcemanager/api_client.py index 7fbee6159..3852619ae 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/api_client.py +++ b/services/resourcemanager/src/stackit/resourcemanager/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/resourcemanager/src/stackit/resourcemanager/models/container_search_result.py b/services/resourcemanager/src/stackit/resourcemanager/models/container_search_result.py index 7d94e9614..406503082 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/container_search_result.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/container_search_result.py @@ -19,6 +19,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.resourcemanager.models.lifecycle_state import LifecycleState @@ -54,7 +55,8 @@ def container_type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -65,8 +67,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/resourcemanager/src/stackit/resourcemanager/models/create_folder_payload.py b/services/resourcemanager/src/stackit/resourcemanager/models/create_folder_payload.py index 23e27d51d..a5642e246 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/create_folder_payload.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/create_folder_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.resourcemanager.models.member import Member @@ -49,6 +50,9 @@ class CreateFolderPayload(BaseModel): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-ZäüöÄÜÖ0-9]( ?[a-zA-ZäüöÄÜÖß0-9_+&-]){0,39}$", value): raise ValueError( r"must validate the regular expression /^[a-zA-ZäüöÄÜÖ0-9]( ?[a-zA-ZäüöÄÜÖß0-9_+&-]){0,39}$/" @@ -56,7 +60,8 @@ def name_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -67,8 +72,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/resourcemanager/src/stackit/resourcemanager/models/create_project_payload.py b/services/resourcemanager/src/stackit/resourcemanager/models/create_project_payload.py index 0b4a6d76b..51a530966 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/create_project_payload.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/create_project_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.resourcemanager.models.member import Member @@ -48,6 +49,9 @@ class CreateProjectPayload(BaseModel): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-ZäüöÄÜÖ0-9]( ?[a-zA-ZäüöÄÜÖß0-9_+&-]){0,39}$", value): raise ValueError( r"must validate the regular expression /^[a-zA-ZäüöÄÜÖ0-9]( ?[a-zA-ZäüöÄÜÖß0-9_+&-]){0,39}$/" @@ -55,7 +59,8 @@ def name_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -66,8 +71,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/resourcemanager/src/stackit/resourcemanager/models/error_response.py b/services/resourcemanager/src/stackit/resourcemanager/models/error_response.py index fa5caf846..e2ba3723e 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/error_response.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/error_response.py @@ -28,6 +28,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -57,7 +58,8 @@ def time_stamp_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -68,8 +70,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/resourcemanager/src/stackit/resourcemanager/models/folder_response.py b/services/resourcemanager/src/stackit/resourcemanager/models/folder_response.py index 96be85086..df19421fb 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/folder_response.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/folder_response.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.resourcemanager.models.parent import Parent @@ -78,7 +79,8 @@ def update_time_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -89,8 +91,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: 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 6a5215e39..1e89cbaea 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 @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.resourcemanager.models.parent import Parent @@ -81,7 +82,8 @@ def update_time_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -92,8 +94,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: 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 056772c96..944f48665 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/get_project_response.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/get_project_response.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.resourcemanager.models.lifecycle_state import LifecycleState @@ -84,7 +85,8 @@ def update_time_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -95,8 +97,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/resourcemanager/src/stackit/resourcemanager/models/list_folders_response.py b/services/resourcemanager/src/stackit/resourcemanager/models/list_folders_response.py index 12bfe7ec1..46da00195 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/list_folders_response.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/list_folders_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set, Union from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.resourcemanager.models.list_folders_response_items_inner import ( @@ -42,7 +43,8 @@ class ListFoldersResponse(BaseModel): __properties: ClassVar[List[str]] = ["items", "limit", "offset"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: 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 b7f7b9eda..828497e2c 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 @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.resourcemanager.models.parent import Parent @@ -78,7 +79,8 @@ def update_time_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -89,8 +91,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/resourcemanager/src/stackit/resourcemanager/models/list_organizations_response.py b/services/resourcemanager/src/stackit/resourcemanager/models/list_organizations_response.py index d26bdf690..a0a3558d2 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/list_organizations_response.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/list_organizations_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set, Union from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.resourcemanager.models.list_organizations_response_items_inner import ( @@ -42,7 +43,8 @@ class ListOrganizationsResponse(BaseModel): __properties: ClassVar[List[str]] = ["items", "limit", "offset"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: 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 b5ef0e099..4c0de3cc6 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 @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.resourcemanager.models.lifecycle_state import LifecycleState @@ -82,7 +83,8 @@ def update_time_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -93,8 +95,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/resourcemanager/src/stackit/resourcemanager/models/list_projects_response.py b/services/resourcemanager/src/stackit/resourcemanager/models/list_projects_response.py index e893e1ed0..2d4a956f4 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/list_projects_response.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/list_projects_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set, Union from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.resourcemanager.models.project import Project @@ -40,7 +41,8 @@ class ListProjectsResponse(BaseModel): __properties: ClassVar[List[str]] = ["items", "limit", "offset"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/resourcemanager/src/stackit/resourcemanager/models/member.py b/services/resourcemanager/src/stackit/resourcemanager/models/member.py index 4fb594675..328711f12 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/member.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/member.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class Member(BaseModel): __properties: ClassVar[List[str]] = ["role", "subject"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/resourcemanager/src/stackit/resourcemanager/models/organization_response.py b/services/resourcemanager/src/stackit/resourcemanager/models/organization_response.py index cf9e52ff1..e69788fb3 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/organization_response.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/organization_response.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.resourcemanager.models.lifecycle_state import LifecycleState @@ -82,7 +83,8 @@ def update_time_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -93,8 +95,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/resourcemanager/src/stackit/resourcemanager/models/parent.py b/services/resourcemanager/src/stackit/resourcemanager/models/parent.py index 208962294..19e0ae5d9 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/parent.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/parent.py @@ -19,6 +19,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -42,7 +43,8 @@ def type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/resourcemanager/src/stackit/resourcemanager/models/parent_list_inner.py b/services/resourcemanager/src/stackit/resourcemanager/models/parent_list_inner.py index 6484436a5..b30230276 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/parent_list_inner.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/parent_list_inner.py @@ -19,6 +19,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -51,7 +52,8 @@ def type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -62,8 +64,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/resourcemanager/src/stackit/resourcemanager/models/partial_update_folder_payload.py b/services/resourcemanager/src/stackit/resourcemanager/models/partial_update_folder_payload.py index b0b8fe7b7..cc958a704 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/partial_update_folder_payload.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/partial_update_folder_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -48,6 +49,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-ZäüöÄÜÖ0-9]( ?[a-zA-ZäüöÄÜÖß0-9_+&-]){0,39}$", value): raise ValueError( r"must validate the regular expression /^[a-zA-ZäüöÄÜÖ0-9]( ?[a-zA-ZäüöÄÜÖß0-9_+&-]){0,39}$/" @@ -55,7 +59,8 @@ def name_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -66,8 +71,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/resourcemanager/src/stackit/resourcemanager/models/partial_update_organization_payload.py b/services/resourcemanager/src/stackit/resourcemanager/models/partial_update_organization_payload.py index 0bf972415..0609f15b7 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/partial_update_organization_payload.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/partial_update_organization_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -43,6 +44,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-ZäüöÄÜÖ0-9]( ?[a-zA-ZäüöÄÜÖß0-9_+&-]){0,39}$", value): raise ValueError( r"must validate the regular expression /^[a-zA-ZäüöÄÜÖ0-9]( ?[a-zA-ZäüöÄÜÖß0-9_+&-]){0,39}$/" @@ -50,7 +54,8 @@ def name_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -61,8 +66,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/resourcemanager/src/stackit/resourcemanager/models/partial_update_project_payload.py b/services/resourcemanager/src/stackit/resourcemanager/models/partial_update_project_payload.py index 327a71134..a45faa7c7 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/partial_update_project_payload.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/partial_update_project_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -48,6 +49,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-ZäüöÄÜÖ0-9]( ?[a-zA-ZäüöÄÜÖß0-9_+&-]){0,39}$", value): raise ValueError( r"must validate the regular expression /^[a-zA-ZäüöÄÜÖ0-9]( ?[a-zA-ZäüöÄÜÖß0-9_+&-]){0,39}$/" @@ -55,7 +59,8 @@ def name_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -66,8 +71,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/resourcemanager/src/stackit/resourcemanager/models/project.py b/services/resourcemanager/src/stackit/resourcemanager/models/project.py index 2c1f58d19..d033e5de3 100644 --- a/services/resourcemanager/src/stackit/resourcemanager/models/project.py +++ b/services/resourcemanager/src/stackit/resourcemanager/models/project.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.resourcemanager.models.lifecycle_state import LifecycleState @@ -81,7 +82,8 @@ def update_time_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -92,8 +94,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/runcommand/CHANGELOG.md b/services/runcommand/CHANGELOG.md index effc1da87..35dce49f1 100644 --- a/services/runcommand/CHANGELOG.md +++ b/services/runcommand/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.2.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v1.1.2 - **Feature:** client now supports UUID and decimal types - **Bugfix:** timeouts now passed to requests library diff --git a/services/runcommand/pyproject.toml b/services/runcommand/pyproject.toml index 7b0569112..8467c2b7c 100644 --- a/services/runcommand/pyproject.toml +++ b/services/runcommand/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-runcommand" -version = "v1.1.2" +version = "v1.2.0" description = "STACKIT Run Commands Service API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/runcommand/src/stackit/runcommand/api_client.py b/services/runcommand/src/stackit/runcommand/api_client.py index 3266ae4c4..a936739de 100644 --- a/services/runcommand/src/stackit/runcommand/api_client.py +++ b/services/runcommand/src/stackit/runcommand/api_client.py @@ -67,6 +67,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -266,7 +267,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -327,25 +328,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -418,6 +414,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/runcommand/src/stackit/runcommand/models/command_details.py b/services/runcommand/src/stackit/runcommand/models/command_details.py index cf6b325c2..9ea71901e 100644 --- a/services/runcommand/src/stackit/runcommand/models/command_details.py +++ b/services/runcommand/src/stackit/runcommand/models/command_details.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -59,7 +60,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -70,8 +72,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/runcommand/src/stackit/runcommand/models/command_template.py b/services/runcommand/src/stackit/runcommand/models/command_template.py index b02cd1cd8..22c70f623 100644 --- a/services/runcommand/src/stackit/runcommand/models/command_template.py +++ b/services/runcommand/src/stackit/runcommand/models/command_template.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -33,7 +34,8 @@ class CommandTemplate(BaseModel): __properties: ClassVar[List[str]] = ["name", "osType", "title"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/runcommand/src/stackit/runcommand/models/command_template_response.py b/services/runcommand/src/stackit/runcommand/models/command_template_response.py index 7e8310979..bcb6ec2db 100644 --- a/services/runcommand/src/stackit/runcommand/models/command_template_response.py +++ b/services/runcommand/src/stackit/runcommand/models/command_template_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.runcommand.models.command_template import CommandTemplate @@ -33,7 +34,8 @@ class CommandTemplateResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/runcommand/src/stackit/runcommand/models/command_template_schema.py b/services/runcommand/src/stackit/runcommand/models/command_template_schema.py index 58b4a644f..7343ddf02 100644 --- a/services/runcommand/src/stackit/runcommand/models/command_template_schema.py +++ b/services/runcommand/src/stackit/runcommand/models/command_template_schema.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.runcommand.models.parameters_schema import ParametersSchema @@ -37,7 +38,8 @@ class CommandTemplateSchema(BaseModel): __properties: ClassVar[List[str]] = ["description", "name", "osType", "parametersSchema", "title"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/runcommand/src/stackit/runcommand/models/commands.py b/services/runcommand/src/stackit/runcommand/models/commands.py index cddd29b98..629ff1396 100644 --- a/services/runcommand/src/stackit/runcommand/models/commands.py +++ b/services/runcommand/src/stackit/runcommand/models/commands.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -53,7 +54,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -64,8 +66,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/runcommand/src/stackit/runcommand/models/create_command_payload.py b/services/runcommand/src/stackit/runcommand/models/create_command_payload.py index 19875b7ee..3b5e62cc6 100644 --- a/services/runcommand/src/stackit/runcommand/models/create_command_payload.py +++ b/services/runcommand/src/stackit/runcommand/models/create_command_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class CreateCommandPayload(BaseModel): __properties: ClassVar[List[str]] = ["commandTemplateName", "parameters"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/runcommand/src/stackit/runcommand/models/error_response.py b/services/runcommand/src/stackit/runcommand/models/error_response.py index 14b357657..011e38fe3 100644 --- a/services/runcommand/src/stackit/runcommand/models/error_response.py +++ b/services/runcommand/src/stackit/runcommand/models/error_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class ErrorResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "status"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/runcommand/src/stackit/runcommand/models/get_commands_response.py b/services/runcommand/src/stackit/runcommand/models/get_commands_response.py index 6b71cf998..6806ecb0e 100644 --- a/services/runcommand/src/stackit/runcommand/models/get_commands_response.py +++ b/services/runcommand/src/stackit/runcommand/models/get_commands_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.runcommand.models.commands import Commands @@ -33,7 +34,8 @@ class GetCommandsResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/runcommand/src/stackit/runcommand/models/model_field.py b/services/runcommand/src/stackit/runcommand/models/model_field.py index fd9065390..9303e176f 100644 --- a/services/runcommand/src/stackit/runcommand/models/model_field.py +++ b/services/runcommand/src/stackit/runcommand/models/model_field.py @@ -26,6 +26,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -44,7 +45,8 @@ class ModelField(BaseModel): __properties: ClassVar[List[str]] = ["default", "description", "maxLen", "minLen", "readOnly", "title", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/runcommand/src/stackit/runcommand/models/new_command_response.py b/services/runcommand/src/stackit/runcommand/models/new_command_response.py index fa5b7f7c7..dae63ab81 100644 --- a/services/runcommand/src/stackit/runcommand/models/new_command_response.py +++ b/services/runcommand/src/stackit/runcommand/models/new_command_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class NewCommandResponse(BaseModel): __properties: ClassVar[List[str]] = ["id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/runcommand/src/stackit/runcommand/models/parameters_schema.py b/services/runcommand/src/stackit/runcommand/models/parameters_schema.py index cffe6a4bf..d44f8899b 100644 --- a/services/runcommand/src/stackit/runcommand/models/parameters_schema.py +++ b/services/runcommand/src/stackit/runcommand/models/parameters_schema.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.runcommand.models.properties import Properties @@ -33,7 +34,8 @@ class ParametersSchema(BaseModel): __properties: ClassVar[List[str]] = ["properties"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/runcommand/src/stackit/runcommand/models/properties.py b/services/runcommand/src/stackit/runcommand/models/properties.py index e00cd995b..0b1ec92f8 100644 --- a/services/runcommand/src/stackit/runcommand/models/properties.py +++ b/services/runcommand/src/stackit/runcommand/models/properties.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.runcommand.models.model_field import ModelField @@ -38,7 +39,8 @@ class Properties(BaseModel): __properties: ClassVar[List[str]] = ["ConfirmPassword", "Password", "Script", "Username", "required", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/CHANGELOG.md b/services/scf/CHANGELOG.md index 85e4d6de6..390cbc7de 100644 --- a/services/scf/CHANGELOG.md +++ b/services/scf/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.5.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.4.1 - **Feature:** client now supports UUID and decimal types - **Bugfix:** timeouts now passed to requests library diff --git a/services/scf/pyproject.toml b/services/scf/pyproject.toml index 8d4b2a773..0f1ba522d 100644 --- a/services/scf/pyproject.toml +++ b/services/scf/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-scf" -version = "v0.4.1" +version = "v0.5.0" description = "STACKIT Cloud Foundry API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4" diff --git a/services/scf/src/stackit/scf/api_client.py b/services/scf/src/stackit/scf/api_client.py index de0489cc6..80cdc3330 100644 --- a/services/scf/src/stackit/scf/api_client.py +++ b/services/scf/src/stackit/scf/api_client.py @@ -67,6 +67,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -266,7 +267,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -327,25 +328,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -418,6 +414,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/scf/src/stackit/scf/models/apply_organization_quota_payload.py b/services/scf/src/stackit/scf/models/apply_organization_quota_payload.py index 76e90b6a0..44af036ad 100644 --- a/services/scf/src/stackit/scf/models/apply_organization_quota_payload.py +++ b/services/scf/src/stackit/scf/models/apply_organization_quota_payload.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class ApplyOrganizationQuotaPayload(BaseModel): __properties: ClassVar[List[str]] = ["quotaId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/create_org_role_payload.py b/services/scf/src/stackit/scf/models/create_org_role_payload.py index 60a9a7ae7..ed0b34a7f 100644 --- a/services/scf/src/stackit/scf/models/create_org_role_payload.py +++ b/services/scf/src/stackit/scf/models/create_org_role_payload.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.scf.models.org_role_type import OrgRoleType @@ -36,7 +37,8 @@ class CreateOrgRolePayload(BaseModel): __properties: ClassVar[List[str]] = ["type", "userGuid", "userName"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/create_organization_payload.py b/services/scf/src/stackit/scf/models/create_organization_payload.py index 84011d8ec..0d7ce3285 100644 --- a/services/scf/src/stackit/scf/models/create_organization_payload.py +++ b/services/scf/src/stackit/scf/models/create_organization_payload.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,7 +34,8 @@ class CreateOrganizationPayload(BaseModel): __properties: ClassVar[List[str]] = ["name", "platformId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/create_space_payload.py b/services/scf/src/stackit/scf/models/create_space_payload.py index 304e766c3..9c10c2ba8 100644 --- a/services/scf/src/stackit/scf/models/create_space_payload.py +++ b/services/scf/src/stackit/scf/models/create_space_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -31,7 +32,8 @@ class CreateSpacePayload(BaseModel): __properties: ClassVar[List[str]] = ["name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/create_space_role_payload.py b/services/scf/src/stackit/scf/models/create_space_role_payload.py index 1022d67fb..065a4c16f 100644 --- a/services/scf/src/stackit/scf/models/create_space_role_payload.py +++ b/services/scf/src/stackit/scf/models/create_space_role_payload.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.scf.models.space_role_type import SpaceRoleType @@ -36,7 +37,8 @@ class CreateSpaceRolePayload(BaseModel): __properties: ClassVar[List[str]] = ["type", "userGuid", "userName"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/error_response.py b/services/scf/src/stackit/scf/models/error_response.py index bb6f640de..c466ebffd 100644 --- a/services/scf/src/stackit/scf/models/error_response.py +++ b/services/scf/src/stackit/scf/models/error_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class ErrorResponse(BaseModel): __properties: ClassVar[List[str]] = ["code", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/isolation_segment.py b/services/scf/src/stackit/scf/models/isolation_segment.py index 267979ac2..cd7cefcc5 100644 --- a/services/scf/src/stackit/scf/models/isolation_segment.py +++ b/services/scf/src/stackit/scf/models/isolation_segment.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -76,7 +77,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -87,8 +89,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/isolation_segments_list.py b/services/scf/src/stackit/scf/models/isolation_segments_list.py index d8f13184c..213330b60 100644 --- a/services/scf/src/stackit/scf/models/isolation_segments_list.py +++ b/services/scf/src/stackit/scf/models/isolation_segments_list.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.scf.models.isolation_segment import IsolationSegment @@ -35,7 +36,8 @@ class IsolationSegmentsList(BaseModel): __properties: ClassVar[List[str]] = ["pagination", "resources"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/org_manager.py b/services/scf/src/stackit/scf/models/org_manager.py index 5a51e6d49..7030e9da4 100644 --- a/services/scf/src/stackit/scf/models/org_manager.py +++ b/services/scf/src/stackit/scf/models/org_manager.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -76,7 +77,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -87,8 +89,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/org_manager_delete_response.py b/services/scf/src/stackit/scf/models/org_manager_delete_response.py index 45d71bfaa..747f82d9a 100644 --- a/services/scf/src/stackit/scf/models/org_manager_delete_response.py +++ b/services/scf/src/stackit/scf/models/org_manager_delete_response.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -34,12 +35,16 @@ class OrgManagerDeleteResponse(BaseModel): @field_validator("message") def message_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9\/_]+$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9\/_]+$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/org_manager_response.py b/services/scf/src/stackit/scf/models/org_manager_response.py index 16073955d..925e82941 100644 --- a/services/scf/src/stackit/scf/models/org_manager_response.py +++ b/services/scf/src/stackit/scf/models/org_manager_response.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -78,7 +79,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -89,8 +91,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/org_role_create_bff_request.py b/services/scf/src/stackit/scf/models/org_role_create_bff_request.py index a3da7c0c4..8effd0c5c 100644 --- a/services/scf/src/stackit/scf/models/org_role_create_bff_request.py +++ b/services/scf/src/stackit/scf/models/org_role_create_bff_request.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.scf.models.org_role_type import OrgRoleType @@ -33,7 +34,8 @@ class OrgRoleCreateBffRequest(BaseModel): __properties: ClassVar[List[str]] = ["type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/org_role_response.py b/services/scf/src/stackit/scf/models/org_role_response.py index 3dcaa6711..d662fe442 100644 --- a/services/scf/src/stackit/scf/models/org_role_response.py +++ b/services/scf/src/stackit/scf/models/org_role_response.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.scf.models.org_role_type import OrgRoleType @@ -39,7 +40,8 @@ class OrgRoleResponse(BaseModel): __properties: ClassVar[List[str]] = ["guid", "orgId", "platformId", "projectId", "region", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/organization.py b/services/scf/src/stackit/scf/models/organization.py index 4dab8b219..2cea040d9 100644 --- a/services/scf/src/stackit/scf/models/organization.py +++ b/services/scf/src/stackit/scf/models/organization.py @@ -29,6 +29,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -89,7 +90,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -100,8 +102,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/organization_create_bff_response.py b/services/scf/src/stackit/scf/models/organization_create_bff_response.py index a5845abb6..9e2129d42 100644 --- a/services/scf/src/stackit/scf/models/organization_create_bff_response.py +++ b/services/scf/src/stackit/scf/models/organization_create_bff_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.scf.models.org_role_response import OrgRoleResponse @@ -35,7 +36,8 @@ class OrganizationCreateBffResponse(BaseModel): __properties: ClassVar[List[str]] = ["org", "roles"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/organization_create_response.py b/services/scf/src/stackit/scf/models/organization_create_response.py index e589fad4d..858b75699 100644 --- a/services/scf/src/stackit/scf/models/organization_create_response.py +++ b/services/scf/src/stackit/scf/models/organization_create_response.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -35,7 +36,8 @@ class OrganizationCreateResponse(BaseModel): __properties: ClassVar[List[str]] = ["guid", "platformId", "projectId", "region"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/organization_delete_response.py b/services/scf/src/stackit/scf/models/organization_delete_response.py index 5ce1edd24..bb16ce822 100644 --- a/services/scf/src/stackit/scf/models/organization_delete_response.py +++ b/services/scf/src/stackit/scf/models/organization_delete_response.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -35,7 +36,8 @@ class OrganizationDeleteResponse(BaseModel): __properties: ClassVar[List[str]] = ["guid", "platformId", "projectId", "region"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/organization_quota.py b/services/scf/src/stackit/scf/models/organization_quota.py index 50636f46e..ac5d55838 100644 --- a/services/scf/src/stackit/scf/models/organization_quota.py +++ b/services/scf/src/stackit/scf/models/organization_quota.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -36,7 +37,8 @@ class OrganizationQuota(BaseModel): __properties: ClassVar[List[str]] = ["orgId", "platformId", "projectId", "quotaId", "region"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/organization_usage_summary.py b/services/scf/src/stackit/scf/models/organization_usage_summary.py index 28eb53429..3998ca2d4 100644 --- a/services/scf/src/stackit/scf/models/organization_usage_summary.py +++ b/services/scf/src/stackit/scf/models/organization_usage_summary.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.scf.models.usage_summary import UsageSummary @@ -38,7 +39,8 @@ class OrganizationUsageSummary(BaseModel): __properties: ClassVar[List[str]] = ["orgId", "platformId", "projectId", "region", "usageSummary"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/organizations_list.py b/services/scf/src/stackit/scf/models/organizations_list.py index fcc2c1108..9e9cd12dc 100644 --- a/services/scf/src/stackit/scf/models/organizations_list.py +++ b/services/scf/src/stackit/scf/models/organizations_list.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.scf.models.organizations_list_item import OrganizationsListItem @@ -35,7 +36,8 @@ class OrganizationsList(BaseModel): __properties: ClassVar[List[str]] = ["pagination", "resources"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/organizations_list_item.py b/services/scf/src/stackit/scf/models/organizations_list_item.py index 4b540964c..67d2eee73 100644 --- a/services/scf/src/stackit/scf/models/organizations_list_item.py +++ b/services/scf/src/stackit/scf/models/organizations_list_item.py @@ -29,6 +29,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -89,7 +90,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -100,8 +102,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/pagination.py b/services/scf/src/stackit/scf/models/pagination.py index 70ba83fab..892f8a3eb 100644 --- a/services/scf/src/stackit/scf/models/pagination.py +++ b/services/scf/src/stackit/scf/models/pagination.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -32,7 +33,8 @@ class Pagination(BaseModel): __properties: ClassVar[List[str]] = ["totalPages", "totalResults"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/platform_list.py b/services/scf/src/stackit/scf/models/platform_list.py index f973e2ab7..21e0c3d02 100644 --- a/services/scf/src/stackit/scf/models/platform_list.py +++ b/services/scf/src/stackit/scf/models/platform_list.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.scf.models.pagination import Pagination @@ -35,7 +36,8 @@ class PlatformList(BaseModel): __properties: ClassVar[List[str]] = ["pagination", "resources"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/platforms.py b/services/scf/src/stackit/scf/models/platforms.py index 1df65a51d..9b3359261 100644 --- a/services/scf/src/stackit/scf/models/platforms.py +++ b/services/scf/src/stackit/scf/models/platforms.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -37,7 +38,8 @@ class Platforms(BaseModel): __properties: ClassVar[List[str]] = ["apiUrl", "consoleUrl", "displayName", "guid", "region", "systemId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/quota.py b/services/scf/src/stackit/scf/models/quota.py index c2c60bc87..23cf1dbc3 100644 --- a/services/scf/src/stackit/scf/models/quota.py +++ b/services/scf/src/stackit/scf/models/quota.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.scf.models.quota_apps import QuotaApps @@ -89,7 +90,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -100,8 +102,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/quota_apps.py b/services/scf/src/stackit/scf/models/quota_apps.py index b3ebcece7..37506c3ff 100644 --- a/services/scf/src/stackit/scf/models/quota_apps.py +++ b/services/scf/src/stackit/scf/models/quota_apps.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -51,7 +52,8 @@ class QuotaApps(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -62,8 +64,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/quota_domains.py b/services/scf/src/stackit/scf/models/quota_domains.py index 03111e3ca..1152fe898 100644 --- a/services/scf/src/stackit/scf/models/quota_domains.py +++ b/services/scf/src/stackit/scf/models/quota_domains.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,7 +34,8 @@ class QuotaDomains(BaseModel): __properties: ClassVar[List[str]] = ["totalDomains"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/quota_routes.py b/services/scf/src/stackit/scf/models/quota_routes.py index 09bb3934b..81a8c334b 100644 --- a/services/scf/src/stackit/scf/models/quota_routes.py +++ b/services/scf/src/stackit/scf/models/quota_routes.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -36,7 +37,8 @@ class QuotaRoutes(BaseModel): __properties: ClassVar[List[str]] = ["totalReservedPorts", "totalRoutes"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/quota_services.py b/services/scf/src/stackit/scf/models/quota_services.py index cebe59255..6aafb88da 100644 --- a/services/scf/src/stackit/scf/models/quota_services.py +++ b/services/scf/src/stackit/scf/models/quota_services.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -37,7 +38,8 @@ class QuotaServices(BaseModel): __properties: ClassVar[List[str]] = ["paidServicesAllowed", "totalServiceInstances", "totalServiceKeys"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/space.py b/services/scf/src/stackit/scf/models/space.py index c01fcea5f..a391cd8fc 100644 --- a/services/scf/src/stackit/scf/models/space.py +++ b/services/scf/src/stackit/scf/models/space.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -76,7 +77,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -87,8 +89,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/space_created_bff_response.py b/services/scf/src/stackit/scf/models/space_created_bff_response.py index f1d668ff8..b82232bf9 100644 --- a/services/scf/src/stackit/scf/models/space_created_bff_response.py +++ b/services/scf/src/stackit/scf/models/space_created_bff_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.scf.models.org_role_response import OrgRoleResponse @@ -37,7 +38,8 @@ class SpaceCreatedBffResponse(BaseModel): __properties: ClassVar[List[str]] = ["orgRole", "space", "spaceRole"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/space_delete_response.py b/services/scf/src/stackit/scf/models/space_delete_response.py index 1c79d93a3..640b90a16 100644 --- a/services/scf/src/stackit/scf/models/space_delete_response.py +++ b/services/scf/src/stackit/scf/models/space_delete_response.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -34,12 +35,16 @@ class SpaceDeleteResponse(BaseModel): @field_validator("message") def message_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9\/_]+$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9\/_]+$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/space_role_create_bff_request.py b/services/scf/src/stackit/scf/models/space_role_create_bff_request.py index 6949a3b89..b29801f36 100644 --- a/services/scf/src/stackit/scf/models/space_role_create_bff_request.py +++ b/services/scf/src/stackit/scf/models/space_role_create_bff_request.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.scf.models.space_role_type import SpaceRoleType @@ -33,7 +34,8 @@ class SpaceRoleCreateBffRequest(BaseModel): __properties: ClassVar[List[str]] = ["type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/space_role_create_bff_response.py b/services/scf/src/stackit/scf/models/space_role_create_bff_response.py index 40a471e0b..4487549ac 100644 --- a/services/scf/src/stackit/scf/models/space_role_create_bff_response.py +++ b/services/scf/src/stackit/scf/models/space_role_create_bff_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.scf.models.org_role_response import OrgRoleResponse @@ -35,7 +36,8 @@ class SpaceRoleCreateBffResponse(BaseModel): __properties: ClassVar[List[str]] = ["orgRole", "spaceRole"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/space_role_create_response.py b/services/scf/src/stackit/scf/models/space_role_create_response.py index 1b8515919..95e27e16a 100644 --- a/services/scf/src/stackit/scf/models/space_role_create_response.py +++ b/services/scf/src/stackit/scf/models/space_role_create_response.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.scf.models.space_role_type import SpaceRoleType @@ -40,7 +41,8 @@ class SpaceRoleCreateResponse(BaseModel): __properties: ClassVar[List[str]] = ["guid", "orgId", "platformId", "projectId", "region", "spaceId", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/space_with_isolation_segment.py b/services/scf/src/stackit/scf/models/space_with_isolation_segment.py index 5174126de..99dec646e 100644 --- a/services/scf/src/stackit/scf/models/space_with_isolation_segment.py +++ b/services/scf/src/stackit/scf/models/space_with_isolation_segment.py @@ -22,6 +22,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -78,7 +79,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -89,8 +91,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/spaces_list.py b/services/scf/src/stackit/scf/models/spaces_list.py index fb07c25e7..c9ef6f242 100644 --- a/services/scf/src/stackit/scf/models/spaces_list.py +++ b/services/scf/src/stackit/scf/models/spaces_list.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.scf.models.pagination import Pagination @@ -35,7 +36,8 @@ class SpacesList(BaseModel): __properties: ClassVar[List[str]] = ["pagination", "resources"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/update_organization_payload.py b/services/scf/src/stackit/scf/models/update_organization_payload.py index 84b83f2b9..93e640422 100644 --- a/services/scf/src/stackit/scf/models/update_organization_payload.py +++ b/services/scf/src/stackit/scf/models/update_organization_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -34,7 +35,8 @@ class UpdateOrganizationPayload(BaseModel): __properties: ClassVar[List[str]] = ["name", "suspended"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/update_space_payload.py b/services/scf/src/stackit/scf/models/update_space_payload.py index 3fb23b86e..87c127fe4 100644 --- a/services/scf/src/stackit/scf/models/update_space_payload.py +++ b/services/scf/src/stackit/scf/models/update_space_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -31,7 +32,8 @@ class UpdateSpacePayload(BaseModel): __properties: ClassVar[List[str]] = ["name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/scf/src/stackit/scf/models/usage_summary.py b/services/scf/src/stackit/scf/models/usage_summary.py index e8268388e..7dc0c1356 100644 --- a/services/scf/src/stackit/scf/models/usage_summary.py +++ b/services/scf/src/stackit/scf/models/usage_summary.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -47,7 +48,8 @@ class UsageSummary(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -58,8 +60,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/secretsmanager/CHANGELOG.md b/services/secretsmanager/CHANGELOG.md index 5309927b2..bb728d445 100644 --- a/services/secretsmanager/CHANGELOG.md +++ b/services/secretsmanager/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.5.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.4.1 - **Feature:** client now supports UUID and decimal types - **Bugfix:** timeouts now passed to requests library diff --git a/services/secretsmanager/pyproject.toml b/services/secretsmanager/pyproject.toml index 1c6550b1a..35d241238 100644 --- a/services/secretsmanager/pyproject.toml +++ b/services/secretsmanager/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-secretsmanager" -version = "v0.4.1" +version = "v0.5.0" description = "STACKIT Secrets Manager API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/secretsmanager/src/stackit/secretsmanager/api_client.py b/services/secretsmanager/src/stackit/secretsmanager/api_client.py index d79029b32..54430f77d 100644 --- a/services/secretsmanager/src/stackit/secretsmanager/api_client.py +++ b/services/secretsmanager/src/stackit/secretsmanager/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/secretsmanager/src/stackit/secretsmanager/models/acl.py b/services/secretsmanager/src/stackit/secretsmanager/models/acl.py index 5e8fe2460..4baad123a 100644 --- a/services/secretsmanager/src/stackit/secretsmanager/models/acl.py +++ b/services/secretsmanager/src/stackit/secretsmanager/models/acl.py @@ -19,6 +19,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class ACL(BaseModel): __properties: ClassVar[List[str]] = ["cidr", "id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/secretsmanager/src/stackit/secretsmanager/models/bad_request.py b/services/secretsmanager/src/stackit/secretsmanager/models/bad_request.py index a2550abff..3e2ed1a54 100644 --- a/services/secretsmanager/src/stackit/secretsmanager/models/bad_request.py +++ b/services/secretsmanager/src/stackit/secretsmanager/models/bad_request.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class BadRequest(BaseModel): __properties: ClassVar[List[str]] = ["message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/secretsmanager/src/stackit/secretsmanager/models/conflict.py b/services/secretsmanager/src/stackit/secretsmanager/models/conflict.py index c55a6ef01..ea5b75f7f 100644 --- a/services/secretsmanager/src/stackit/secretsmanager/models/conflict.py +++ b/services/secretsmanager/src/stackit/secretsmanager/models/conflict.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class Conflict(BaseModel): __properties: ClassVar[List[str]] = ["message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/secretsmanager/src/stackit/secretsmanager/models/create_acl_payload.py b/services/secretsmanager/src/stackit/secretsmanager/models/create_acl_payload.py index 24859996d..1cabf4a51 100644 --- a/services/secretsmanager/src/stackit/secretsmanager/models/create_acl_payload.py +++ b/services/secretsmanager/src/stackit/secretsmanager/models/create_acl_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class CreateACLPayload(BaseModel): __properties: ClassVar[List[str]] = ["cidr"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/secretsmanager/src/stackit/secretsmanager/models/create_instance_payload.py b/services/secretsmanager/src/stackit/secretsmanager/models/create_instance_payload.py index b4915b7de..7fe81d565 100644 --- a/services/secretsmanager/src/stackit/secretsmanager/models/create_instance_payload.py +++ b/services/secretsmanager/src/stackit/secretsmanager/models/create_instance_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.secretsmanager.models.kms_key_payload import KmsKeyPayload @@ -33,7 +34,8 @@ class CreateInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["kmsKey", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/secretsmanager/src/stackit/secretsmanager/models/create_user_payload.py b/services/secretsmanager/src/stackit/secretsmanager/models/create_user_payload.py index 7aa0a6197..8fc2f835e 100644 --- a/services/secretsmanager/src/stackit/secretsmanager/models/create_user_payload.py +++ b/services/secretsmanager/src/stackit/secretsmanager/models/create_user_payload.py @@ -24,6 +24,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -39,7 +40,8 @@ class CreateUserPayload(BaseModel): __properties: ClassVar[List[str]] = ["description", "write"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/secretsmanager/src/stackit/secretsmanager/models/instance.py b/services/secretsmanager/src/stackit/secretsmanager/models/instance.py index 927d115c1..d8ebbd9f8 100644 --- a/services/secretsmanager/src/stackit/secretsmanager/models/instance.py +++ b/services/secretsmanager/src/stackit/secretsmanager/models/instance.py @@ -19,6 +19,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.secretsmanager.models.kms_key_payload import KmsKeyPayload @@ -65,7 +66,8 @@ class Instance(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -76,8 +78,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/secretsmanager/src/stackit/secretsmanager/models/kms_key_payload.py b/services/secretsmanager/src/stackit/secretsmanager/models/kms_key_payload.py index d088cfeca..80807c318 100644 --- a/services/secretsmanager/src/stackit/secretsmanager/models/kms_key_payload.py +++ b/services/secretsmanager/src/stackit/secretsmanager/models/kms_key_payload.py @@ -19,6 +19,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -37,7 +38,8 @@ class KmsKeyPayload(BaseModel): __properties: ClassVar[List[str]] = ["keyId", "keyRingId", "keyVersion", "serviceAccountEmail"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/secretsmanager/src/stackit/secretsmanager/models/list_acls_response.py b/services/secretsmanager/src/stackit/secretsmanager/models/list_acls_response.py index 695bd4bef..0a23c2559 100644 --- a/services/secretsmanager/src/stackit/secretsmanager/models/list_acls_response.py +++ b/services/secretsmanager/src/stackit/secretsmanager/models/list_acls_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.secretsmanager.models.acl import ACL @@ -32,7 +33,8 @@ class ListACLsResponse(BaseModel): __properties: ClassVar[List[str]] = ["acls"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/secretsmanager/src/stackit/secretsmanager/models/list_instances_response.py b/services/secretsmanager/src/stackit/secretsmanager/models/list_instances_response.py index b1769e910..ed048e3f5 100644 --- a/services/secretsmanager/src/stackit/secretsmanager/models/list_instances_response.py +++ b/services/secretsmanager/src/stackit/secretsmanager/models/list_instances_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.secretsmanager.models.instance import Instance @@ -32,7 +33,8 @@ class ListInstancesResponse(BaseModel): __properties: ClassVar[List[str]] = ["instances"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/secretsmanager/src/stackit/secretsmanager/models/list_users_response.py b/services/secretsmanager/src/stackit/secretsmanager/models/list_users_response.py index e690b4e75..87ec6addb 100644 --- a/services/secretsmanager/src/stackit/secretsmanager/models/list_users_response.py +++ b/services/secretsmanager/src/stackit/secretsmanager/models/list_users_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.secretsmanager.models.user import User @@ -32,7 +33,8 @@ class ListUsersResponse(BaseModel): __properties: ClassVar[List[str]] = ["users"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/secretsmanager/src/stackit/secretsmanager/models/not_found.py b/services/secretsmanager/src/stackit/secretsmanager/models/not_found.py index 749ebece6..68bc69fd5 100644 --- a/services/secretsmanager/src/stackit/secretsmanager/models/not_found.py +++ b/services/secretsmanager/src/stackit/secretsmanager/models/not_found.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class NotFound(BaseModel): __properties: ClassVar[List[str]] = ["message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/secretsmanager/src/stackit/secretsmanager/models/update_acl_payload.py b/services/secretsmanager/src/stackit/secretsmanager/models/update_acl_payload.py index 664b34069..49b76ad26 100644 --- a/services/secretsmanager/src/stackit/secretsmanager/models/update_acl_payload.py +++ b/services/secretsmanager/src/stackit/secretsmanager/models/update_acl_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class UpdateACLPayload(BaseModel): __properties: ClassVar[List[str]] = ["cidr"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/secretsmanager/src/stackit/secretsmanager/models/update_acls_payload.py b/services/secretsmanager/src/stackit/secretsmanager/models/update_acls_payload.py index 4eb534e12..1292939d2 100644 --- a/services/secretsmanager/src/stackit/secretsmanager/models/update_acls_payload.py +++ b/services/secretsmanager/src/stackit/secretsmanager/models/update_acls_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.secretsmanager.models.update_acl_payload import UpdateACLPayload @@ -32,7 +33,8 @@ class UpdateACLsPayload(BaseModel): __properties: ClassVar[List[str]] = ["cidrs"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/secretsmanager/src/stackit/secretsmanager/models/update_instance_payload.py b/services/secretsmanager/src/stackit/secretsmanager/models/update_instance_payload.py index 91aefd7be..2ec7d9508 100644 --- a/services/secretsmanager/src/stackit/secretsmanager/models/update_instance_payload.py +++ b/services/secretsmanager/src/stackit/secretsmanager/models/update_instance_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.secretsmanager.models.kms_key_payload import KmsKeyPayload @@ -33,7 +34,8 @@ class UpdateInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["kmsKey", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/secretsmanager/src/stackit/secretsmanager/models/update_user_payload.py b/services/secretsmanager/src/stackit/secretsmanager/models/update_user_payload.py index 2aadba226..9759d7353 100644 --- a/services/secretsmanager/src/stackit/secretsmanager/models/update_user_payload.py +++ b/services/secretsmanager/src/stackit/secretsmanager/models/update_user_payload.py @@ -24,6 +24,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -42,7 +43,8 @@ class UpdateUserPayload(BaseModel): __properties: ClassVar[List[str]] = ["description", "write"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/secretsmanager/src/stackit/secretsmanager/models/user.py b/services/secretsmanager/src/stackit/secretsmanager/models/user.py index 44b957ca3..d6bc1f007 100644 --- a/services/secretsmanager/src/stackit/secretsmanager/models/user.py +++ b/services/secretsmanager/src/stackit/secretsmanager/models/user.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -43,7 +44,8 @@ class User(BaseModel): __properties: ClassVar[List[str]] = ["description", "id", "password", "username", "write"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/CHANGELOG.md b/services/serverbackup/CHANGELOG.md index 7cb67926a..e144c1498 100644 --- a/services/serverbackup/CHANGELOG.md +++ b/services/serverbackup/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.2.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v1.1.2 - **Feature:** client now supports UUID and decimal types - **Bugfix:** timeouts now passed to requests library diff --git a/services/serverbackup/pyproject.toml b/services/serverbackup/pyproject.toml index 42c314a69..a7ffbbfe4 100644 --- a/services/serverbackup/pyproject.toml +++ b/services/serverbackup/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-serverbackup" -version = "v1.1.2" +version = "v1.2.0" description = "STACKIT Server Backup Management API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/serverbackup/src/stackit/serverbackup/api_client.py b/services/serverbackup/src/stackit/serverbackup/api_client.py index 4584a1511..eeec2719b 100644 --- a/services/serverbackup/src/stackit/serverbackup/api_client.py +++ b/services/serverbackup/src/stackit/serverbackup/api_client.py @@ -67,6 +67,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -266,7 +267,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -327,25 +328,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -418,6 +414,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/serverbackup/src/stackit/serverbackup/models/backup.py b/services/serverbackup/src/stackit/serverbackup/models/backup.py index 199c86e2d..23e29b80e 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/backup.py +++ b/services/serverbackup/src/stackit/serverbackup/models/backup.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serverbackup.models.backup_volume_backups_inner import ( @@ -71,7 +72,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -82,8 +84,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/backup_job.py b/services/serverbackup/src/stackit/serverbackup/models/backup_job.py index 8ac516282..c0de5332c 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/backup_job.py +++ b/services/serverbackup/src/stackit/serverbackup/models/backup_job.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class BackupJob(BaseModel): __properties: ClassVar[List[str]] = ["id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/backup_policy.py b/services/serverbackup/src/stackit/serverbackup/models/backup_policy.py index 7010ced57..695c94368 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/backup_policy.py +++ b/services/serverbackup/src/stackit/serverbackup/models/backup_policy.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serverbackup.models.backup_policy_backup_properties import ( @@ -50,7 +51,8 @@ class BackupPolicy(BaseModel): __properties: ClassVar[List[str]] = ["backupProperties", "default", "description", "enabled", "id", "name", "rrule"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -61,8 +63,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/backup_policy_backup_properties.py b/services/serverbackup/src/stackit/serverbackup/models/backup_policy_backup_properties.py index 21c0dcfe7..462ea104d 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/backup_policy_backup_properties.py +++ b/services/serverbackup/src/stackit/serverbackup/models/backup_policy_backup_properties.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class BackupPolicyBackupProperties(BaseModel): __properties: ClassVar[List[str]] = ["name", "retentionPeriod"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/backup_properties.py b/services/serverbackup/src/stackit/serverbackup/models/backup_properties.py index 7938cf284..edd6bc869 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/backup_properties.py +++ b/services/serverbackup/src/stackit/serverbackup/models/backup_properties.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -35,7 +36,8 @@ class BackupProperties(BaseModel): __properties: ClassVar[List[str]] = ["name", "retentionPeriod", "volumeIds"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/backup_schedule.py b/services/serverbackup/src/stackit/serverbackup/models/backup_schedule.py index 27668dbb0..368e8809f 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/backup_schedule.py +++ b/services/serverbackup/src/stackit/serverbackup/models/backup_schedule.py @@ -26,6 +26,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serverbackup.models.backup_properties import BackupProperties @@ -46,7 +47,8 @@ class BackupSchedule(BaseModel): __properties: ClassVar[List[str]] = ["backupProperties", "enabled", "id", "name", "rrule"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -57,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/backup_volume_backups_inner.py b/services/serverbackup/src/stackit/serverbackup/models/backup_volume_backups_inner.py index cb14421bd..76444030f 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/backup_volume_backups_inner.py +++ b/services/serverbackup/src/stackit/serverbackup/models/backup_volume_backups_inner.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -60,7 +61,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -71,8 +73,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/create_backup_payload.py b/services/serverbackup/src/stackit/serverbackup/models/create_backup_payload.py index a47a5eeca..efe82a2a4 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/create_backup_payload.py +++ b/services/serverbackup/src/stackit/serverbackup/models/create_backup_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -35,7 +36,8 @@ class CreateBackupPayload(BaseModel): __properties: ClassVar[List[str]] = ["name", "retentionPeriod", "volumeIds"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/create_backup_schedule_payload.py b/services/serverbackup/src/stackit/serverbackup/models/create_backup_schedule_payload.py index 7fe3654c8..33f7ebb46 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/create_backup_schedule_payload.py +++ b/services/serverbackup/src/stackit/serverbackup/models/create_backup_schedule_payload.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serverbackup.models.backup_properties import BackupProperties @@ -44,7 +45,8 @@ class CreateBackupSchedulePayload(BaseModel): __properties: ClassVar[List[str]] = ["backupProperties", "enabled", "name", "rrule"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/enable_service_resource_payload.py b/services/serverbackup/src/stackit/serverbackup/models/enable_service_resource_payload.py index 2a6cef81a..d85063504 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/enable_service_resource_payload.py +++ b/services/serverbackup/src/stackit/serverbackup/models/enable_service_resource_payload.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class EnableServiceResourcePayload(BaseModel): __properties: ClassVar[List[str]] = ["backupPolicyId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/error_response.py b/services/serverbackup/src/stackit/serverbackup/models/error_response.py index e7d73adb1..40efab8f6 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/error_response.py +++ b/services/serverbackup/src/stackit/serverbackup/models/error_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class ErrorResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "status"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/get_backup_policies_response.py b/services/serverbackup/src/stackit/serverbackup/models/get_backup_policies_response.py index 257b003cc..22a786844 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/get_backup_policies_response.py +++ b/services/serverbackup/src/stackit/serverbackup/models/get_backup_policies_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serverbackup.models.backup_policy import BackupPolicy @@ -33,7 +34,8 @@ class GetBackupPoliciesResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/get_backup_schedules_response.py b/services/serverbackup/src/stackit/serverbackup/models/get_backup_schedules_response.py index d29eed1e1..a0aa63490 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/get_backup_schedules_response.py +++ b/services/serverbackup/src/stackit/serverbackup/models/get_backup_schedules_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serverbackup.models.backup_schedule import BackupSchedule @@ -33,7 +34,8 @@ class GetBackupSchedulesResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/get_backup_service_response.py b/services/serverbackup/src/stackit/serverbackup/models/get_backup_service_response.py index dec3e28fb..422712d71 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/get_backup_service_response.py +++ b/services/serverbackup/src/stackit/serverbackup/models/get_backup_service_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class GetBackupServiceResponse(BaseModel): __properties: ClassVar[List[str]] = ["enabled"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/get_backups_list_response.py b/services/serverbackup/src/stackit/serverbackup/models/get_backups_list_response.py index 1c389101c..1b8a3605a 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/get_backups_list_response.py +++ b/services/serverbackup/src/stackit/serverbackup/models/get_backups_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serverbackup.models.backup import Backup @@ -33,7 +34,8 @@ class GetBackupsListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/restore_backup_payload.py b/services/serverbackup/src/stackit/serverbackup/models/restore_backup_payload.py index 9e050336f..1700a8a57 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/restore_backup_payload.py +++ b/services/serverbackup/src/stackit/serverbackup/models/restore_backup_payload.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -38,7 +39,8 @@ class RestoreBackupPayload(BaseModel): __properties: ClassVar[List[str]] = ["startServerAfterRestore", "volumeIds"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/restore_volume_backup_payload.py b/services/serverbackup/src/stackit/serverbackup/models/restore_volume_backup_payload.py index b5e23e58b..9b4d93f9e 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/restore_volume_backup_payload.py +++ b/services/serverbackup/src/stackit/serverbackup/models/restore_volume_backup_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class RestoreVolumeBackupPayload(BaseModel): __properties: ClassVar[List[str]] = ["restoreVolumeId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverbackup/src/stackit/serverbackup/models/update_backup_schedule_payload.py b/services/serverbackup/src/stackit/serverbackup/models/update_backup_schedule_payload.py index fe6802512..ac3887bb6 100644 --- a/services/serverbackup/src/stackit/serverbackup/models/update_backup_schedule_payload.py +++ b/services/serverbackup/src/stackit/serverbackup/models/update_backup_schedule_payload.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serverbackup.models.backup_properties import BackupProperties @@ -44,7 +45,8 @@ class UpdateBackupSchedulePayload(BaseModel): __properties: ClassVar[List[str]] = ["backupProperties", "enabled", "name", "rrule"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverupdate/CHANGELOG.md b/services/serverupdate/CHANGELOG.md index e176b0b2f..5515b88f3 100644 --- a/services/serverupdate/CHANGELOG.md +++ b/services/serverupdate/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.2.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v1.1.1 - **Feature:** client now supports UUID and decimal types - **Bugfix:** timeouts now passed to requests library diff --git a/services/serverupdate/pyproject.toml b/services/serverupdate/pyproject.toml index 3ea85639e..73371d1cc 100644 --- a/services/serverupdate/pyproject.toml +++ b/services/serverupdate/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-serverupdate" -version = "v1.1.1" +version = "v1.2.0" description = "STACKIT Server Update Management API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/serverupdate/src/stackit/serverupdate/api_client.py b/services/serverupdate/src/stackit/serverupdate/api_client.py index 5e4603fbd..c1fa148b3 100644 --- a/services/serverupdate/src/stackit/serverupdate/api_client.py +++ b/services/serverupdate/src/stackit/serverupdate/api_client.py @@ -67,6 +67,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -266,7 +267,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -327,25 +328,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -418,6 +414,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/serverupdate/src/stackit/serverupdate/models/create_update_payload.py b/services/serverupdate/src/stackit/serverupdate/models/create_update_payload.py index 011869f9c..d8379657d 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/create_update_payload.py +++ b/services/serverupdate/src/stackit/serverupdate/models/create_update_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -35,7 +36,8 @@ class CreateUpdatePayload(BaseModel): __properties: ClassVar[List[str]] = ["backupBeforeUpdate", "maintenanceWindow"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverupdate/src/stackit/serverupdate/models/create_update_schedule_payload.py b/services/serverupdate/src/stackit/serverupdate/models/create_update_schedule_payload.py index 64f4651c2..c8c0299ec 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/create_update_schedule_payload.py +++ b/services/serverupdate/src/stackit/serverupdate/models/create_update_schedule_payload.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -45,7 +46,8 @@ class CreateUpdateSchedulePayload(BaseModel): __properties: ClassVar[List[str]] = ["enabled", "maintenanceWindow", "name", "rrule"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +58,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverupdate/src/stackit/serverupdate/models/enable_service_resource_payload.py b/services/serverupdate/src/stackit/serverupdate/models/enable_service_resource_payload.py index 25b01c9e9..61d463767 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/enable_service_resource_payload.py +++ b/services/serverupdate/src/stackit/serverupdate/models/enable_service_resource_payload.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class EnableServiceResourcePayload(BaseModel): __properties: ClassVar[List[str]] = ["updatePolicyId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverupdate/src/stackit/serverupdate/models/error_response.py b/services/serverupdate/src/stackit/serverupdate/models/error_response.py index 15adb7bd8..d4b939156 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/error_response.py +++ b/services/serverupdate/src/stackit/serverupdate/models/error_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class ErrorResponse(BaseModel): __properties: ClassVar[List[str]] = ["message", "status"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverupdate/src/stackit/serverupdate/models/get_update_policies_response.py b/services/serverupdate/src/stackit/serverupdate/models/get_update_policies_response.py index ec274af33..6864dae44 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/get_update_policies_response.py +++ b/services/serverupdate/src/stackit/serverupdate/models/get_update_policies_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serverupdate.models.update_policy import UpdatePolicy @@ -33,7 +34,8 @@ class GetUpdatePoliciesResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverupdate/src/stackit/serverupdate/models/get_update_schedules_response.py b/services/serverupdate/src/stackit/serverupdate/models/get_update_schedules_response.py index 902896790..ebe805a31 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/get_update_schedules_response.py +++ b/services/serverupdate/src/stackit/serverupdate/models/get_update_schedules_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serverupdate.models.update_schedule import UpdateSchedule @@ -33,7 +34,8 @@ class GetUpdateSchedulesResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverupdate/src/stackit/serverupdate/models/get_update_service_response.py b/services/serverupdate/src/stackit/serverupdate/models/get_update_service_response.py index a6f7303ab..16054fca4 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/get_update_service_response.py +++ b/services/serverupdate/src/stackit/serverupdate/models/get_update_service_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class GetUpdateServiceResponse(BaseModel): __properties: ClassVar[List[str]] = ["enabled"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverupdate/src/stackit/serverupdate/models/get_updates_list_response.py b/services/serverupdate/src/stackit/serverupdate/models/get_updates_list_response.py index cef6fbf93..107d9bd41 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/get_updates_list_response.py +++ b/services/serverupdate/src/stackit/serverupdate/models/get_updates_list_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serverupdate.models.update import Update @@ -33,7 +34,8 @@ class GetUpdatesListResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverupdate/src/stackit/serverupdate/models/update.py b/services/serverupdate/src/stackit/serverupdate/models/update.py index 214052e15..10de83a0c 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/update.py +++ b/services/serverupdate/src/stackit/serverupdate/models/update.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -45,7 +46,8 @@ class Update(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +58,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverupdate/src/stackit/serverupdate/models/update_policy.py b/services/serverupdate/src/stackit/serverupdate/models/update_policy.py index 75d93d2a5..5c68697e0 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/update_policy.py +++ b/services/serverupdate/src/stackit/serverupdate/models/update_policy.py @@ -26,6 +26,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -59,7 +60,8 @@ class UpdatePolicy(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -70,8 +72,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverupdate/src/stackit/serverupdate/models/update_schedule.py b/services/serverupdate/src/stackit/serverupdate/models/update_schedule.py index 19632b3d3..559c01793 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/update_schedule.py +++ b/services/serverupdate/src/stackit/serverupdate/models/update_schedule.py @@ -26,6 +26,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -47,7 +48,8 @@ class UpdateSchedule(BaseModel): __properties: ClassVar[List[str]] = ["enabled", "maintenanceWindow", "name", "rrule", "id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -58,8 +60,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverupdate/src/stackit/serverupdate/models/update_schedule_create_request.py b/services/serverupdate/src/stackit/serverupdate/models/update_schedule_create_request.py index bafba1111..dcfdd51b8 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/update_schedule_create_request.py +++ b/services/serverupdate/src/stackit/serverupdate/models/update_schedule_create_request.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -45,7 +46,8 @@ class UpdateScheduleCreateRequest(BaseModel): __properties: ClassVar[List[str]] = ["enabled", "maintenanceWindow", "name", "rrule"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +58,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serverupdate/src/stackit/serverupdate/models/update_update_schedule_payload.py b/services/serverupdate/src/stackit/serverupdate/models/update_update_schedule_payload.py index 1c6f00a76..ec46a726a 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/update_update_schedule_payload.py +++ b/services/serverupdate/src/stackit/serverupdate/models/update_update_schedule_payload.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -45,7 +46,8 @@ class UpdateUpdateSchedulePayload(BaseModel): __properties: ClassVar[List[str]] = ["enabled", "maintenanceWindow", "name", "rrule"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +58,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceaccount/CHANGELOG.md b/services/serviceaccount/CHANGELOG.md index 1d67188f8..af50186f0 100644 --- a/services/serviceaccount/CHANGELOG.md +++ b/services/serviceaccount/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.9.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.8.0 - **Feature:** New API client method `get_federated_identity_provider` diff --git a/services/serviceaccount/pyproject.toml b/services/serviceaccount/pyproject.toml index 902e01a65..2672ea8b5 100644 --- a/services/serviceaccount/pyproject.toml +++ b/services/serviceaccount/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-serviceaccount" -version = "v0.8.0" +version = "v0.9.0" description = "Service Account API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/serviceaccount/src/stackit/serviceaccount/api_client.py b/services/serviceaccount/src/stackit/serviceaccount/api_client.py index e73bad820..303ff6fad 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/api_client.py +++ b/services/serviceaccount/src/stackit/serviceaccount/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/access_token.py b/services/serviceaccount/src/stackit/serviceaccount/models/access_token.py index 4d761925e..5fe8987dd 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/access_token.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/access_token.py @@ -28,6 +28,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -75,7 +76,8 @@ def valid_until_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -86,8 +88,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: 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 56fd00c4b..400cb6d95 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/access_token_metadata.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/access_token_metadata.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -67,7 +68,8 @@ def valid_until_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -78,8 +80,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/auth_error.py b/services/serviceaccount/src/stackit/serviceaccount/models/auth_error.py index 92fd91a52..dc8893a93 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/auth_error.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/auth_error.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serviceaccount.models.auth_error_error import AuthErrorError @@ -32,7 +33,8 @@ class AuthError(BaseModel): __properties: ClassVar[List[str]] = ["error"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/auth_error_error.py b/services/serviceaccount/src/stackit/serviceaccount/models/auth_error_error.py index d2ce6cae3..b19754e01 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/auth_error_error.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/auth_error_error.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class AuthErrorError(BaseModel): __properties: ClassVar[List[str]] = ["code", "message", "status"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/create_access_token_payload.py b/services/serviceaccount/src/stackit/serviceaccount/models/create_access_token_payload.py index 593eea83f..6ff26ca2f 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/create_access_token_payload.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/create_access_token_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -32,7 +33,8 @@ class CreateAccessTokenPayload(BaseModel): __properties: ClassVar[List[str]] = ["ttlDays"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/create_federated_identity_provider_payload.py b/services/serviceaccount/src/stackit/serviceaccount/models/create_federated_identity_provider_payload.py index 9ff747b84..1910034e5 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/create_federated_identity_provider_payload.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/create_federated_identity_provider_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serviceaccount.models.create_federated_identity_provider_payload_assertions_inner import ( @@ -38,7 +39,8 @@ class CreateFederatedIdentityProviderPayload(BaseModel): __properties: ClassVar[List[str]] = ["assertions", "issuer", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/create_federated_identity_provider_payload_assertions_inner.py b/services/serviceaccount/src/stackit/serviceaccount/models/create_federated_identity_provider_payload_assertions_inner.py index 5f5c017d3..d6dff8190 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/create_federated_identity_provider_payload_assertions_inner.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/create_federated_identity_provider_payload_assertions_inner.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class CreateFederatedIdentityProviderPayloadAssertionsInner(BaseModel): __properties: ClassVar[List[str]] = ["item", "operator", "value"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: 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 12d80314c..30f3f83fa 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 @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -68,7 +69,8 @@ def valid_until_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -79,8 +81,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: 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 768839677..2ad1cba27 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 @@ -28,6 +28,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serviceaccount.models.create_service_account_key_response_credentials import ( @@ -113,7 +114,8 @@ def valid_until_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -124,8 +126,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_response_credentials.py b/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_response_credentials.py index 9ae869b1f..9a5344f1c 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_response_credentials.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_response_credentials.py @@ -19,6 +19,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -44,7 +45,8 @@ class CreateServiceAccountKeyResponseCredentials(BaseModel): __properties: ClassVar[List[str]] = ["aud", "iss", "kid", "privateKey", "sub", "tokenEndpoint"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_payload.py b/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_payload.py index be040942d..7d96f7a6d 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_payload.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -35,12 +36,16 @@ class CreateServiceAccountPayload(BaseModel): @field_validator("name") def name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z](?:-?[a-z0-9]+)*$", value): raise ValueError(r"must validate the regular expression /^[a-z](?:-?[a-z0-9]+)*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -51,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/create_short_lived_access_token_response.py b/services/serviceaccount/src/stackit/serviceaccount/models/create_short_lived_access_token_response.py index 4ba3d9764..601266b5c 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/create_short_lived_access_token_response.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/create_short_lived_access_token_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -43,7 +44,8 @@ def token_type_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/error.py b/services/serviceaccount/src/stackit/serviceaccount/models/error.py index 5a650f6f1..e436c52a7 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/error.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/error.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -49,7 +50,8 @@ def time_stamp_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +62,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/federated_identity_provider.py b/services/serviceaccount/src/stackit/serviceaccount/models/federated_identity_provider.py index 977fa4c8d..ad6d2cddf 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/federated_identity_provider.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/federated_identity_provider.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serviceaccount.models.federated_identity_provider_assertions_inner import ( @@ -70,7 +71,8 @@ def updated_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -81,8 +83,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/federated_identity_provider_assertions_inner.py b/services/serviceaccount/src/stackit/serviceaccount/models/federated_identity_provider_assertions_inner.py index 13e8ffb4b..16bc34f3a 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/federated_identity_provider_assertions_inner.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/federated_identity_provider_assertions_inner.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class FederatedIdentityProviderAssertionsInner(BaseModel): __properties: ClassVar[List[str]] = ["item", "operator", "value"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/federated_list_federated_identity_providers_response.py b/services/serviceaccount/src/stackit/serviceaccount/models/federated_list_federated_identity_providers_response.py index a9c3e4425..f044ae8b0 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/federated_list_federated_identity_providers_response.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/federated_list_federated_identity_providers_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set, Union from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.serviceaccount.models.federated_identity_provider import ( @@ -43,7 +44,8 @@ class FederatedListFederatedIdentityProvidersResponse(BaseModel): __properties: ClassVar[List[str]] = ["itemsPerPage", "resources", "startIndex", "totalResults"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: 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 77b82710f..0e6ef4d2c 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 @@ -28,6 +28,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serviceaccount.models.get_service_account_key_response_credentials import ( @@ -113,7 +114,8 @@ def valid_until_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -124,8 +126,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/get_service_account_key_response_credentials.py b/services/serviceaccount/src/stackit/serviceaccount/models/get_service_account_key_response_credentials.py index 884212c7d..884b8fde0 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/get_service_account_key_response_credentials.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/get_service_account_key_response_credentials.py @@ -19,6 +19,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class GetServiceAccountKeyResponseCredentials(BaseModel): __properties: ClassVar[List[str]] = ["aud", "iss", "kid", "sub"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/jwk.py b/services/serviceaccount/src/stackit/serviceaccount/models/jwk.py index 15a3de3c2..86954f08c 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/jwk.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/jwk.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -40,7 +41,8 @@ class JWK(BaseModel): __properties: ClassVar[List[str]] = ["alg", "e", "kid", "ks", "n", "ops", "use", "x5c", "x5t", "x5t256", "x5u"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/jwks.py b/services/serviceaccount/src/stackit/serviceaccount/models/jwks.py index 81d077190..f37a1f576 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/jwks.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/jwks.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serviceaccount.models.jwk import JWK @@ -32,7 +33,8 @@ class JWKS(BaseModel): __properties: ClassVar[List[str]] = ["keys"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/list_access_tokens_response.py b/services/serviceaccount/src/stackit/serviceaccount/models/list_access_tokens_response.py index 252b2c54d..5f216f943 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/list_access_tokens_response.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/list_access_tokens_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serviceaccount.models.access_token_metadata import AccessTokenMetadata @@ -32,7 +33,8 @@ class ListAccessTokensResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/list_service_account_keys_response.py b/services/serviceaccount/src/stackit/serviceaccount/models/list_service_account_keys_response.py index e1b9743c8..0f24f741f 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/list_service_account_keys_response.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/list_service_account_keys_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serviceaccount.models.service_account_key_list_response import ( @@ -34,7 +35,8 @@ class ListServiceAccountKeysResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/list_service_accounts_response.py b/services/serviceaccount/src/stackit/serviceaccount/models/list_service_accounts_response.py index 890b3b25b..733230623 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/list_service_accounts_response.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/list_service_accounts_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serviceaccount.models.service_account import ServiceAccount @@ -32,7 +33,8 @@ class ListServiceAccountsResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_federated_identity_provider_payload.py b/services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_federated_identity_provider_payload.py index e9a9db727..c93d18c2e 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_federated_identity_provider_payload.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_federated_identity_provider_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serviceaccount.models.create_federated_identity_provider_payload_assertions_inner import ( @@ -38,7 +39,8 @@ class PartialUpdateServiceAccountFederatedIdentityProviderPayload(BaseModel): __properties: ClassVar[List[str]] = ["assertions", "issuer", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: 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 0ca304ea3..037698393 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 @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -52,7 +53,8 @@ def valid_until_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -63,8 +65,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: 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 de0208662..cfeb54dd1 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 @@ -28,6 +28,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -103,7 +104,8 @@ def valid_until_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -114,8 +116,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/service_account.py b/services/serviceaccount/src/stackit/serviceaccount/models/service_account.py index e086e2644..f9d920ed9 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/service_account.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/service_account.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -44,7 +45,8 @@ class ServiceAccount(BaseModel): __properties: ClassVar[List[str]] = ["email", "id", "internal", "projectId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[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 5f805269b..44158308e 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 @@ -28,6 +28,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -103,7 +104,8 @@ def valid_until_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -114,8 +116,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceenablement/CHANGELOG.md b/services/serviceenablement/CHANGELOG.md index 65f9233c9..baa1007ef 100644 --- a/services/serviceenablement/CHANGELOG.md +++ b/services/serviceenablement/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.2.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v1.1.2 - **Feature:** client now supports UUID and decimal types - **Bugfix:** timeouts now passed to requests library diff --git a/services/serviceenablement/pyproject.toml b/services/serviceenablement/pyproject.toml index f9bcb6e05..d37b1e1e1 100644 --- a/services/serviceenablement/pyproject.toml +++ b/services/serviceenablement/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-serviceenablement" -version = "v1.1.2" +version = "v1.2.0" description = "STACKIT Service Enablement API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/serviceenablement/src/stackit/serviceenablement/api_client.py b/services/serviceenablement/src/stackit/serviceenablement/api_client.py index 6df395eb3..a37013fd0 100644 --- a/services/serviceenablement/src/stackit/serviceenablement/api_client.py +++ b/services/serviceenablement/src/stackit/serviceenablement/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/serviceenablement/src/stackit/serviceenablement/models/action_error.py b/services/serviceenablement/src/stackit/serviceenablement/models/action_error.py index 5e33bcf68..cb99d9abb 100644 --- a/services/serviceenablement/src/stackit/serviceenablement/models/action_error.py +++ b/services/serviceenablement/src/stackit/serviceenablement/models/action_error.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -42,7 +43,8 @@ def action_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceenablement/src/stackit/serviceenablement/models/check_service.py b/services/serviceenablement/src/stackit/serviceenablement/models/check_service.py index bccdf41f7..640e29d0e 100644 --- a/services/serviceenablement/src/stackit/serviceenablement/models/check_service.py +++ b/services/serviceenablement/src/stackit/serviceenablement/models/check_service.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -50,12 +51,16 @@ def service_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9][a-zA-Z0-9._-]{1,254}$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9][a-zA-Z0-9._-]{1,254}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -66,8 +71,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceenablement/src/stackit/serviceenablement/models/cloud_service.py b/services/serviceenablement/src/stackit/serviceenablement/models/cloud_service.py index 3ea90523f..666b4d095 100644 --- a/services/serviceenablement/src/stackit/serviceenablement/models/cloud_service.py +++ b/services/serviceenablement/src/stackit/serviceenablement/models/cloud_service.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.serviceenablement.models.dependencies import Dependencies @@ -53,12 +54,16 @@ def service_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9][a-zA-Z0-9._-]{1,254}$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9][a-zA-Z0-9._-]{1,254}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -69,8 +74,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceenablement/src/stackit/serviceenablement/models/dependencies.py b/services/serviceenablement/src/stackit/serviceenablement/models/dependencies.py index 460ddae1d..8b9cf3c7e 100644 --- a/services/serviceenablement/src/stackit/serviceenablement/models/dependencies.py +++ b/services/serviceenablement/src/stackit/serviceenablement/models/dependencies.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -37,7 +38,8 @@ class Dependencies(BaseModel): __properties: ClassVar[List[str]] = ["hard", "soft"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceenablement/src/stackit/serviceenablement/models/error_response.py b/services/serviceenablement/src/stackit/serviceenablement/models/error_response.py index d907adc82..f3bb3fb9d 100644 --- a/services/serviceenablement/src/stackit/serviceenablement/models/error_response.py +++ b/services/serviceenablement/src/stackit/serviceenablement/models/error_response.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -49,7 +50,8 @@ def timestamp_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +62,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceenablement/src/stackit/serviceenablement/models/list_service_status_regional200_response.py b/services/serviceenablement/src/stackit/serviceenablement/models/list_service_status_regional200_response.py index 25cb50727..20a483287 100644 --- a/services/serviceenablement/src/stackit/serviceenablement/models/list_service_status_regional200_response.py +++ b/services/serviceenablement/src/stackit/serviceenablement/models/list_service_status_regional200_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serviceenablement.models.service_status import ServiceStatus @@ -33,7 +34,8 @@ class ListServiceStatusRegional200Response(BaseModel): __properties: ClassVar[List[str]] = ["items", "nextCursor"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceenablement/src/stackit/serviceenablement/models/parameters.py b/services/serviceenablement/src/stackit/serviceenablement/models/parameters.py index 228cd00da..ca622f085 100644 --- a/services/serviceenablement/src/stackit/serviceenablement/models/parameters.py +++ b/services/serviceenablement/src/stackit/serviceenablement/models/parameters.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.serviceenablement.models.parameters_general import ParametersGeneral @@ -33,7 +34,8 @@ class Parameters(BaseModel): __properties: ClassVar[List[str]] = ["general"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceenablement/src/stackit/serviceenablement/models/parameters_general.py b/services/serviceenablement/src/stackit/serviceenablement/models/parameters_general.py index 918526308..80ade9105 100644 --- a/services/serviceenablement/src/stackit/serviceenablement/models/parameters_general.py +++ b/services/serviceenablement/src/stackit/serviceenablement/models/parameters_general.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -42,7 +43,8 @@ def project_scope_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/serviceenablement/src/stackit/serviceenablement/models/service_status.py b/services/serviceenablement/src/stackit/serviceenablement/models/service_status.py index 1819e16e7..4c16c919d 100644 --- a/services/serviceenablement/src/stackit/serviceenablement/models/service_status.py +++ b/services/serviceenablement/src/stackit/serviceenablement/models/service_status.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.serviceenablement.models.action_error import ActionError @@ -90,6 +91,9 @@ def service_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9][a-zA-Z0-9._-]{1,254}$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9][a-zA-Z0-9._-]{1,254}$/") return value @@ -105,7 +109,8 @@ def state_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -116,8 +121,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/CHANGELOG.md b/services/sfs/CHANGELOG.md index c972eb684..d0757cb7e 100644 --- a/services/sfs/CHANGELOG.md +++ b/services/sfs/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.6.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.5.0 - **Deprecation:** deprecated field `schedules` in model `SnapshotPolicy` - **Feature:** new field `snapshotSchedules` in model `SnapshotPolicy` @@ -28,4 +31,4 @@ - **Breaking change:** Remove field `SnapshotSchedule` from `CreateResourcePoolResponseResourcePool`, `GetResourcePoolResponseResourcePool`, `UpdateResourcePoolResponseResourcePoolGetStateRetType` and `ResourcePool` model ## v0.1.0 -- **New**: STACKIT File Storage (SFS) service \ No newline at end of file +- **New**: STACKIT File Storage (SFS) service diff --git a/services/sfs/pyproject.toml b/services/sfs/pyproject.toml index dfe19b900..a971b3a19 100644 --- a/services/sfs/pyproject.toml +++ b/services/sfs/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-sfs" -version = "v0.5.0" +version = "v0.6.0" description = "STACKIT File Storage (SFS)" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4" diff --git a/services/sfs/src/stackit/sfs/api_client.py b/services/sfs/src/stackit/sfs/api_client.py index 7fb861461..3f5763593 100644 --- a/services/sfs/src/stackit/sfs/api_client.py +++ b/services/sfs/src/stackit/sfs/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/sfs/src/stackit/sfs/models/create_resource_pool_payload.py b/services/sfs/src/stackit/sfs/models/create_resource_pool_payload.py index 138038474..14f3f1501 100644 --- a/services/sfs/src/stackit/sfs/models/create_resource_pool_payload.py +++ b/services/sfs/src/stackit/sfs/models/create_resource_pool_payload.py @@ -25,6 +25,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -67,7 +68,8 @@ class CreateResourcePoolPayload(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -78,8 +80,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/create_resource_pool_response.py b/services/sfs/src/stackit/sfs/models/create_resource_pool_response.py index 772dfc2ff..04fa8e631 100644 --- a/services/sfs/src/stackit/sfs/models/create_resource_pool_response.py +++ b/services/sfs/src/stackit/sfs/models/create_resource_pool_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.resource_pool import ResourcePool @@ -34,7 +35,8 @@ class CreateResourcePoolResponse(BaseModel): __properties: ClassVar[List[str]] = ["resourcePool"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/create_resource_pool_snapshot_payload.py b/services/sfs/src/stackit/sfs/models/create_resource_pool_snapshot_payload.py index 6acfd64a1..bb291ebce 100644 --- a/services/sfs/src/stackit/sfs/models/create_resource_pool_snapshot_payload.py +++ b/services/sfs/src/stackit/sfs/models/create_resource_pool_snapshot_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -38,7 +39,8 @@ class CreateResourcePoolSnapshotPayload(BaseModel): __properties: ClassVar[List[str]] = ["comment", "name", "snaplockRetentionHours"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/create_resource_pool_snapshot_response.py b/services/sfs/src/stackit/sfs/models/create_resource_pool_snapshot_response.py index 9eddbf977..224a90e11 100644 --- a/services/sfs/src/stackit/sfs/models/create_resource_pool_snapshot_response.py +++ b/services/sfs/src/stackit/sfs/models/create_resource_pool_snapshot_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.resource_pool_snapshot import ResourcePoolSnapshot @@ -34,7 +35,8 @@ class CreateResourcePoolSnapshotResponse(BaseModel): __properties: ClassVar[List[str]] = ["resourcePoolSnapshot"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/create_share_export_policy_payload.py b/services/sfs/src/stackit/sfs/models/create_share_export_policy_payload.py index ee63de25b..e6ceee2d5 100644 --- a/services/sfs/src/stackit/sfs/models/create_share_export_policy_payload.py +++ b/services/sfs/src/stackit/sfs/models/create_share_export_policy_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.create_share_export_policy_request_rule import ( @@ -42,7 +43,8 @@ class CreateShareExportPolicyPayload(BaseModel): __properties: ClassVar[List[str]] = ["labels", "name", "rules"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/create_share_export_policy_request_rule.py b/services/sfs/src/stackit/sfs/models/create_share_export_policy_request_rule.py index 7a60bf1fb..7780c9f8d 100644 --- a/services/sfs/src/stackit/sfs/models/create_share_export_policy_request_rule.py +++ b/services/sfs/src/stackit/sfs/models/create_share_export_policy_request_rule.py @@ -25,6 +25,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -59,7 +60,8 @@ class CreateShareExportPolicyRequestRule(BaseModel): __properties: ClassVar[List[str]] = ["description", "ipAcl", "order", "readOnly", "setUuid", "superUser"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -70,8 +72,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/create_share_export_policy_response.py b/services/sfs/src/stackit/sfs/models/create_share_export_policy_response.py index 8806c4571..f0e8eabc5 100644 --- a/services/sfs/src/stackit/sfs/models/create_share_export_policy_response.py +++ b/services/sfs/src/stackit/sfs/models/create_share_export_policy_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.share_export_policy import ShareExportPolicy @@ -34,7 +35,8 @@ class CreateShareExportPolicyResponse(BaseModel): __properties: ClassVar[List[str]] = ["shareExportPolicy"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/create_share_payload.py b/services/sfs/src/stackit/sfs/models/create_share_payload.py index 12c029c35..2ec2cb147 100644 --- a/services/sfs/src/stackit/sfs/models/create_share_payload.py +++ b/services/sfs/src/stackit/sfs/models/create_share_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -43,7 +44,8 @@ class CreateSharePayload(BaseModel): __properties: ClassVar[List[str]] = ["exportPolicyName", "labels", "name", "spaceHardLimitGigabytes"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/create_share_response.py b/services/sfs/src/stackit/sfs/models/create_share_response.py index c1e797e7a..cde9cf3b2 100644 --- a/services/sfs/src/stackit/sfs/models/create_share_response.py +++ b/services/sfs/src/stackit/sfs/models/create_share_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.share import Share @@ -32,7 +33,8 @@ class CreateShareResponse(BaseModel): __properties: ClassVar[List[str]] = ["share"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/enable_lock_response.py b/services/sfs/src/stackit/sfs/models/enable_lock_response.py index 80b7b3b22..a5a7b5b0a 100644 --- a/services/sfs/src/stackit/sfs/models/enable_lock_response.py +++ b/services/sfs/src/stackit/sfs/models/enable_lock_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class EnableLockResponse(BaseModel): __properties: ClassVar[List[str]] = ["lockId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/error.py b/services/sfs/src/stackit/sfs/models/error.py index 5c10569ff..19ffa9cce 100644 --- a/services/sfs/src/stackit/sfs/models/error.py +++ b/services/sfs/src/stackit/sfs/models/error.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -36,7 +37,8 @@ class Error(BaseModel): __properties: ClassVar[List[str]] = ["error_description", "title", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/get_lock_response.py b/services/sfs/src/stackit/sfs/models/get_lock_response.py index cdf302121..9faab3e0a 100644 --- a/services/sfs/src/stackit/sfs/models/get_lock_response.py +++ b/services/sfs/src/stackit/sfs/models/get_lock_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class GetLockResponse(BaseModel): __properties: ClassVar[List[str]] = ["lockId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/get_resource_pool_response.py b/services/sfs/src/stackit/sfs/models/get_resource_pool_response.py index 0752294f8..c93de4ea3 100644 --- a/services/sfs/src/stackit/sfs/models/get_resource_pool_response.py +++ b/services/sfs/src/stackit/sfs/models/get_resource_pool_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.resource_pool import ResourcePool @@ -32,7 +33,8 @@ class GetResourcePoolResponse(BaseModel): __properties: ClassVar[List[str]] = ["resourcePool"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/get_resource_pool_snapshot_response.py b/services/sfs/src/stackit/sfs/models/get_resource_pool_snapshot_response.py index f041cecb9..6b9389c11 100644 --- a/services/sfs/src/stackit/sfs/models/get_resource_pool_snapshot_response.py +++ b/services/sfs/src/stackit/sfs/models/get_resource_pool_snapshot_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.resource_pool_snapshot import ResourcePoolSnapshot @@ -34,7 +35,8 @@ class GetResourcePoolSnapshotResponse(BaseModel): __properties: ClassVar[List[str]] = ["resourcePoolSnapshot"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/get_schedule_response.py b/services/sfs/src/stackit/sfs/models/get_schedule_response.py index 5e4d8f157..1027f8411 100644 --- a/services/sfs/src/stackit/sfs/models/get_schedule_response.py +++ b/services/sfs/src/stackit/sfs/models/get_schedule_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.schedule import Schedule @@ -32,7 +33,8 @@ class GetScheduleResponse(BaseModel): __properties: ClassVar[List[str]] = ["schedule"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/get_share_export_policy_response.py b/services/sfs/src/stackit/sfs/models/get_share_export_policy_response.py index 0e87af86b..412e5d4a1 100644 --- a/services/sfs/src/stackit/sfs/models/get_share_export_policy_response.py +++ b/services/sfs/src/stackit/sfs/models/get_share_export_policy_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.share_export_policy import ShareExportPolicy @@ -34,7 +35,8 @@ class GetShareExportPolicyResponse(BaseModel): __properties: ClassVar[List[str]] = ["shareExportPolicy"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/get_share_response.py b/services/sfs/src/stackit/sfs/models/get_share_response.py index 6df7c9fff..594338f2c 100644 --- a/services/sfs/src/stackit/sfs/models/get_share_response.py +++ b/services/sfs/src/stackit/sfs/models/get_share_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.share import Share @@ -32,7 +33,8 @@ class GetShareResponse(BaseModel): __properties: ClassVar[List[str]] = ["share"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/get_snapshot_policy_response.py b/services/sfs/src/stackit/sfs/models/get_snapshot_policy_response.py index 3bc9d30a3..a991086e3 100644 --- a/services/sfs/src/stackit/sfs/models/get_snapshot_policy_response.py +++ b/services/sfs/src/stackit/sfs/models/get_snapshot_policy_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.snapshot_policy import SnapshotPolicy @@ -34,7 +35,8 @@ class GetSnapshotPolicyResponse(BaseModel): __properties: ClassVar[List[str]] = ["snapshotPolicy"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/google_protobuf_any.py b/services/sfs/src/stackit/sfs/models/google_protobuf_any.py index 0e1fa318c..ab842e1a5 100644 --- a/services/sfs/src/stackit/sfs/models/google_protobuf_any.py +++ b/services/sfs/src/stackit/sfs/models/google_protobuf_any.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class GoogleProtobufAny(BaseModel): __properties: ClassVar[List[str]] = ["@type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/list_performance_classes_response.py b/services/sfs/src/stackit/sfs/models/list_performance_classes_response.py index 0fd72e378..0eea95397 100644 --- a/services/sfs/src/stackit/sfs/models/list_performance_classes_response.py +++ b/services/sfs/src/stackit/sfs/models/list_performance_classes_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.performance_class import PerformanceClass @@ -34,7 +35,8 @@ class ListPerformanceClassesResponse(BaseModel): __properties: ClassVar[List[str]] = ["performanceClasses"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/list_resource_pool_snapshots_response.py b/services/sfs/src/stackit/sfs/models/list_resource_pool_snapshots_response.py index e7354a760..b1f79b3c9 100644 --- a/services/sfs/src/stackit/sfs/models/list_resource_pool_snapshots_response.py +++ b/services/sfs/src/stackit/sfs/models/list_resource_pool_snapshots_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.resource_pool_snapshot import ResourcePoolSnapshot @@ -34,7 +35,8 @@ class ListResourcePoolSnapshotsResponse(BaseModel): __properties: ClassVar[List[str]] = ["resourcePoolSnapshots"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/list_resource_pools_response.py b/services/sfs/src/stackit/sfs/models/list_resource_pools_response.py index df4f7025e..ec41d50fb 100644 --- a/services/sfs/src/stackit/sfs/models/list_resource_pools_response.py +++ b/services/sfs/src/stackit/sfs/models/list_resource_pools_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.resource_pool import ResourcePool @@ -34,7 +35,8 @@ class ListResourcePoolsResponse(BaseModel): __properties: ClassVar[List[str]] = ["resourcePools"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/list_schedules_response.py b/services/sfs/src/stackit/sfs/models/list_schedules_response.py index 595a22ace..44540aa12 100644 --- a/services/sfs/src/stackit/sfs/models/list_schedules_response.py +++ b/services/sfs/src/stackit/sfs/models/list_schedules_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.schedule import Schedule @@ -32,7 +33,8 @@ class ListSchedulesResponse(BaseModel): __properties: ClassVar[List[str]] = ["schedules"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/list_share_export_policies_response.py b/services/sfs/src/stackit/sfs/models/list_share_export_policies_response.py index cf1f04e05..e8d11d7b1 100644 --- a/services/sfs/src/stackit/sfs/models/list_share_export_policies_response.py +++ b/services/sfs/src/stackit/sfs/models/list_share_export_policies_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.share_export_policy import ShareExportPolicy @@ -34,7 +35,8 @@ class ListShareExportPoliciesResponse(BaseModel): __properties: ClassVar[List[str]] = ["shareExportPolicies"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/list_shares_response.py b/services/sfs/src/stackit/sfs/models/list_shares_response.py index ec470338f..c3a462c71 100644 --- a/services/sfs/src/stackit/sfs/models/list_shares_response.py +++ b/services/sfs/src/stackit/sfs/models/list_shares_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.share import Share @@ -32,7 +33,8 @@ class ListSharesResponse(BaseModel): __properties: ClassVar[List[str]] = ["shares"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/list_snapshot_policies_response.py b/services/sfs/src/stackit/sfs/models/list_snapshot_policies_response.py index ef09717e9..a4b1e8ee4 100644 --- a/services/sfs/src/stackit/sfs/models/list_snapshot_policies_response.py +++ b/services/sfs/src/stackit/sfs/models/list_snapshot_policies_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.snapshot_policy import SnapshotPolicy @@ -34,7 +35,8 @@ class ListSnapshotPoliciesResponse(BaseModel): __properties: ClassVar[List[str]] = ["snapshotPolicies"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/performance_class.py b/services/sfs/src/stackit/sfs/models/performance_class.py index 0908a9dea..b08ae2401 100644 --- a/services/sfs/src/stackit/sfs/models/performance_class.py +++ b/services/sfs/src/stackit/sfs/models/performance_class.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class PerformanceClass(BaseModel): __properties: ClassVar[List[str]] = ["iops", "name", "throughput"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/resource_pool.py b/services/sfs/src/stackit/sfs/models/resource_pool.py index 8c1b2f3cc..f4ee10191 100644 --- a/services/sfs/src/stackit/sfs/models/resource_pool.py +++ b/services/sfs/src/stackit/sfs/models/resource_pool.py @@ -28,6 +28,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.resource_pool_performance_class import ( @@ -144,7 +145,8 @@ def size_reducible_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -155,8 +157,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/resource_pool_performance_class.py b/services/sfs/src/stackit/sfs/models/resource_pool_performance_class.py index 1cd0e593a..aef64747c 100644 --- a/services/sfs/src/stackit/sfs/models/resource_pool_performance_class.py +++ b/services/sfs/src/stackit/sfs/models/resource_pool_performance_class.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -36,7 +37,8 @@ class ResourcePoolPerformanceClass(BaseModel): __properties: ClassVar[List[str]] = ["name", "peakIops", "throughput"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/resource_pool_snapshot.py b/services/sfs/src/stackit/sfs/models/resource_pool_snapshot.py index e395a6488..835e5e53d 100644 --- a/services/sfs/src/stackit/sfs/models/resource_pool_snapshot.py +++ b/services/sfs/src/stackit/sfs/models/resource_pool_snapshot.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -90,7 +91,8 @@ def snaplock_expiry_time_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -101,8 +103,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/resource_pool_snapshot_policy.py b/services/sfs/src/stackit/sfs/models/resource_pool_snapshot_policy.py index 33aab6217..ed3057dc6 100644 --- a/services/sfs/src/stackit/sfs/models/resource_pool_snapshot_policy.py +++ b/services/sfs/src/stackit/sfs/models/resource_pool_snapshot_policy.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class ResourcePoolSnapshotPolicy(BaseModel): __properties: ClassVar[List[str]] = ["id", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/resource_pool_space.py b/services/sfs/src/stackit/sfs/models/resource_pool_space.py index 85b67770e..ea2fe2d68 100644 --- a/services/sfs/src/stackit/sfs/models/resource_pool_space.py +++ b/services/sfs/src/stackit/sfs/models/resource_pool_space.py @@ -24,6 +24,7 @@ StrictFloat, StrictInt, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -58,7 +59,8 @@ class ResourcePoolSpace(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -69,8 +71,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/schedule.py b/services/sfs/src/stackit/sfs/models/schedule.py index 3c7e08d64..9ad345bc4 100644 --- a/services/sfs/src/stackit/sfs/models/schedule.py +++ b/services/sfs/src/stackit/sfs/models/schedule.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -50,7 +51,8 @@ def created_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -61,8 +63,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/share.py b/services/sfs/src/stackit/sfs/models/share.py index 4ed6f38ad..fe92636f3 100644 --- a/services/sfs/src/stackit/sfs/models/share.py +++ b/services/sfs/src/stackit/sfs/models/share.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.share_export_policy import ShareExportPolicy @@ -79,7 +80,8 @@ def created_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -90,8 +92,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/share_export_policy.py b/services/sfs/src/stackit/sfs/models/share_export_policy.py index 36863e58f..26b817a03 100644 --- a/services/sfs/src/stackit/sfs/models/share_export_policy.py +++ b/services/sfs/src/stackit/sfs/models/share_export_policy.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.share_export_policy_rule import ShareExportPolicyRule @@ -60,7 +61,8 @@ def created_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -71,8 +73,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/share_export_policy_rule.py b/services/sfs/src/stackit/sfs/models/share_export_policy_rule.py index 63f7bbfac..06a95c665 100644 --- a/services/sfs/src/stackit/sfs/models/share_export_policy_rule.py +++ b/services/sfs/src/stackit/sfs/models/share_export_policy_rule.py @@ -28,6 +28,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -86,7 +87,8 @@ def created_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -97,8 +99,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/snapshot_policy.py b/services/sfs/src/stackit/sfs/models/snapshot_policy.py index 6853d5f04..fa9a133a1 100644 --- a/services/sfs/src/stackit/sfs/models/snapshot_policy.py +++ b/services/sfs/src/stackit/sfs/models/snapshot_policy.py @@ -27,6 +27,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.snapshot_policy_schedule import SnapshotPolicySchedule @@ -75,7 +76,8 @@ def created_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -86,8 +88,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/snapshot_policy_schedule.py b/services/sfs/src/stackit/sfs/models/snapshot_policy_schedule.py index 0a4284066..f8ab60a71 100644 --- a/services/sfs/src/stackit/sfs/models/snapshot_policy_schedule.py +++ b/services/sfs/src/stackit/sfs/models/snapshot_policy_schedule.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -40,7 +41,8 @@ class SnapshotPolicySchedule(BaseModel): __properties: ClassVar[List[str]] = ["count", "interval", "prefix", "retentionPeriod", "scheduleId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/snapshot_policy_snapshot_policy_schedule.py b/services/sfs/src/stackit/sfs/models/snapshot_policy_snapshot_policy_schedule.py index d4706545d..3c71592c8 100644 --- a/services/sfs/src/stackit/sfs/models/snapshot_policy_snapshot_policy_schedule.py +++ b/services/sfs/src/stackit/sfs/models/snapshot_policy_snapshot_policy_schedule.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -65,7 +66,8 @@ def created_at_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -76,8 +78,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/status.py b/services/sfs/src/stackit/sfs/models/status.py index 98da8f1b5..06b30e607 100644 --- a/services/sfs/src/stackit/sfs/models/status.py +++ b/services/sfs/src/stackit/sfs/models/status.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.google_protobuf_any import GoogleProtobufAny @@ -43,7 +44,8 @@ class Status(BaseModel): __properties: ClassVar[List[str]] = ["code", "details", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/update_resource_pool_payload.py b/services/sfs/src/stackit/sfs/models/update_resource_pool_payload.py index 54ccbc930..2f31305eb 100644 --- a/services/sfs/src/stackit/sfs/models/update_resource_pool_payload.py +++ b/services/sfs/src/stackit/sfs/models/update_resource_pool_payload.py @@ -25,6 +25,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -68,7 +69,8 @@ class UpdateResourcePoolPayload(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -79,8 +81,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/update_resource_pool_response.py b/services/sfs/src/stackit/sfs/models/update_resource_pool_response.py index 455bea7aa..bef5209fb 100644 --- a/services/sfs/src/stackit/sfs/models/update_resource_pool_response.py +++ b/services/sfs/src/stackit/sfs/models/update_resource_pool_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.resource_pool import ResourcePool @@ -34,7 +35,8 @@ class UpdateResourcePoolResponse(BaseModel): __properties: ClassVar[List[str]] = ["resourcePool"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/update_resource_pool_snapshot_payload.py b/services/sfs/src/stackit/sfs/models/update_resource_pool_snapshot_payload.py index bd7f1e583..a2b80daf7 100644 --- a/services/sfs/src/stackit/sfs/models/update_resource_pool_snapshot_payload.py +++ b/services/sfs/src/stackit/sfs/models/update_resource_pool_snapshot_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -33,7 +34,8 @@ class UpdateResourcePoolSnapshotPayload(BaseModel): __properties: ClassVar[List[str]] = ["comment", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/update_resource_pool_snapshot_response.py b/services/sfs/src/stackit/sfs/models/update_resource_pool_snapshot_response.py index 1120d7543..5e3139dd4 100644 --- a/services/sfs/src/stackit/sfs/models/update_resource_pool_snapshot_response.py +++ b/services/sfs/src/stackit/sfs/models/update_resource_pool_snapshot_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.resource_pool_snapshot import ResourcePoolSnapshot @@ -34,7 +35,8 @@ class UpdateResourcePoolSnapshotResponse(BaseModel): __properties: ClassVar[List[str]] = ["resourcePoolSnapshot"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/update_share_export_policy_body_rule.py b/services/sfs/src/stackit/sfs/models/update_share_export_policy_body_rule.py index d9bf536c0..2bb12c1ca 100644 --- a/services/sfs/src/stackit/sfs/models/update_share_export_policy_body_rule.py +++ b/services/sfs/src/stackit/sfs/models/update_share_export_policy_body_rule.py @@ -25,6 +25,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -59,7 +60,8 @@ class UpdateShareExportPolicyBodyRule(BaseModel): __properties: ClassVar[List[str]] = ["description", "ipAcl", "order", "readOnly", "setUuid", "superUser"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -70,8 +72,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/update_share_export_policy_payload.py b/services/sfs/src/stackit/sfs/models/update_share_export_policy_payload.py index a00e80860..0c509c115 100644 --- a/services/sfs/src/stackit/sfs/models/update_share_export_policy_payload.py +++ b/services/sfs/src/stackit/sfs/models/update_share_export_policy_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.update_share_export_policy_body_rule import ( @@ -41,7 +42,8 @@ class UpdateShareExportPolicyPayload(BaseModel): __properties: ClassVar[List[str]] = ["labels", "rules"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -52,8 +54,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/update_share_export_policy_response.py b/services/sfs/src/stackit/sfs/models/update_share_export_policy_response.py index 985c3e745..1832e86b4 100644 --- a/services/sfs/src/stackit/sfs/models/update_share_export_policy_response.py +++ b/services/sfs/src/stackit/sfs/models/update_share_export_policy_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.share_export_policy import ShareExportPolicy @@ -32,7 +33,8 @@ class UpdateShareExportPolicyResponse(BaseModel): __properties: ClassVar[List[str]] = ["shareExportPolicy"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/update_share_payload.py b/services/sfs/src/stackit/sfs/models/update_share_payload.py index e4a42f90c..875e71edf 100644 --- a/services/sfs/src/stackit/sfs/models/update_share_payload.py +++ b/services/sfs/src/stackit/sfs/models/update_share_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -43,7 +44,8 @@ class UpdateSharePayload(BaseModel): __properties: ClassVar[List[str]] = ["exportPolicyName", "labels", "spaceHardLimitGigabytes"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -54,8 +56,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/update_share_response.py b/services/sfs/src/stackit/sfs/models/update_share_response.py index f11f12a56..ed5e86b0e 100644 --- a/services/sfs/src/stackit/sfs/models/update_share_response.py +++ b/services/sfs/src/stackit/sfs/models/update_share_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.share import Share @@ -32,7 +33,8 @@ class UpdateShareResponse(BaseModel): __properties: ClassVar[List[str]] = ["share"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/validation_error.py b/services/sfs/src/stackit/sfs/models/validation_error.py index 00af91d02..6cf322a5b 100644 --- a/services/sfs/src/stackit/sfs/models/validation_error.py +++ b/services/sfs/src/stackit/sfs/models/validation_error.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sfs.models.validation_error_field import ValidationErrorField @@ -39,7 +40,8 @@ class ValidationError(BaseModel): __properties: ClassVar[List[str]] = ["error_description", "title", "type", "fields"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sfs/src/stackit/sfs/models/validation_error_field.py b/services/sfs/src/stackit/sfs/models/validation_error_field.py index d4fde9a32..908b06ff9 100644 --- a/services/sfs/src/stackit/sfs/models/validation_error_field.py +++ b/services/sfs/src/stackit/sfs/models/validation_error_field.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -33,7 +34,8 @@ class ValidationErrorField(BaseModel): __properties: ClassVar[List[str]] = ["field", "reason"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/CHANGELOG.md b/services/ske/CHANGELOG.md index bff188255..9bf1a5580 100644 --- a/services/ske/CHANGELOG.md +++ b/services/ske/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.9.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v1.8.0 - **Breaking Change:** Change status codes: remove 200, change response type of 202 and add 400 in some API calls - **Breaking Change:** Aligned CRI name validation with the API side validation (removed docker) diff --git a/services/ske/pyproject.toml b/services/ske/pyproject.toml index a2b47806b..e0da02a6a 100644 --- a/services/ske/pyproject.toml +++ b/services/ske/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-ske" -version = "v1.8.0" +version = "v1.9.0" description = "SKE-API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/ske/src/stackit/ske/api_client.py b/services/ske/src/stackit/ske/api_client.py index 8f8cb852e..93aaccb90 100644 --- a/services/ske/src/stackit/ske/api_client.py +++ b/services/ske/src/stackit/ske/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/ske/src/stackit/ske/models/access.py b/services/ske/src/stackit/ske/models/access.py index 7e96d233f..93f5ae657 100644 --- a/services/ske/src/stackit/ske/models/access.py +++ b/services/ske/src/stackit/ske/models/access.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.ske.models.idp import IDP @@ -32,7 +33,8 @@ class Access(BaseModel): __properties: ClassVar[List[str]] = ["idp"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/acl.py b/services/ske/src/stackit/ske/models/acl.py index 43d97a93a..049ccd449 100644 --- a/services/ske/src/stackit/ske/models/acl.py +++ b/services/ske/src/stackit/ske/models/acl.py @@ -24,6 +24,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -39,7 +40,8 @@ class ACL(BaseModel): __properties: ClassVar[List[str]] = ["allowedCidrs", "enabled"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/availability_zone.py b/services/ske/src/stackit/ske/models/availability_zone.py index dad007bc0..4bb7327ab 100644 --- a/services/ske/src/stackit/ske/models/availability_zone.py +++ b/services/ske/src/stackit/ske/models/availability_zone.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class AvailabilityZone(BaseModel): __properties: ClassVar[List[str]] = ["name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/cluster.py b/services/ske/src/stackit/ske/models/cluster.py index 84a32f94c..5bfbbd603 100644 --- a/services/ske/src/stackit/ske/models/cluster.py +++ b/services/ske/src/stackit/ske/models/cluster.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.ske.models.access import Access @@ -57,7 +58,8 @@ class Cluster(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -68,8 +70,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/cluster_error.py b/services/ske/src/stackit/ske/models/cluster_error.py index c75d8ec84..fca795507 100644 --- a/services/ske/src/stackit/ske/models/cluster_error.py +++ b/services/ske/src/stackit/ske/models/cluster_error.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class ClusterError(BaseModel): __properties: ClassVar[List[str]] = ["code", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/cluster_status.py b/services/ske/src/stackit/ske/models/cluster_status.py index 8547d63ab..f0029f9fe 100644 --- a/services/ske/src/stackit/ske/models/cluster_status.py +++ b/services/ske/src/stackit/ske/models/cluster_status.py @@ -27,6 +27,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.ske.models.cluster_error import ClusterError @@ -88,7 +89,8 @@ def creation_time_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -99,8 +101,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/create_kubeconfig_payload.py b/services/ske/src/stackit/ske/models/create_kubeconfig_payload.py index 3bd0d8956..f396395bb 100644 --- a/services/ske/src/stackit/ske/models/create_kubeconfig_payload.py +++ b/services/ske/src/stackit/ske/models/create_kubeconfig_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class CreateKubeconfigPayload(BaseModel): __properties: ClassVar[List[str]] = ["expirationSeconds"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/create_or_update_cluster_payload.py b/services/ske/src/stackit/ske/models/create_or_update_cluster_payload.py index 6e3272251..d6e9e03d4 100644 --- a/services/ske/src/stackit/ske/models/create_or_update_cluster_payload.py +++ b/services/ske/src/stackit/ske/models/create_or_update_cluster_payload.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.ske.models.access import Access @@ -55,7 +56,8 @@ class CreateOrUpdateClusterPayload(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -66,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/credentials_rotation_state.py b/services/ske/src/stackit/ske/models/credentials_rotation_state.py index 0af820510..76ebe5f9f 100644 --- a/services/ske/src/stackit/ske/models/credentials_rotation_state.py +++ b/services/ske/src/stackit/ske/models/credentials_rotation_state.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -77,7 +78,8 @@ def phase_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -88,8 +90,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/cri.py b/services/ske/src/stackit/ske/models/cri.py index 9a0c0e94e..6aa0dea95 100644 --- a/services/ske/src/stackit/ske/models/cri.py +++ b/services/ske/src/stackit/ske/models/cri.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -40,7 +41,8 @@ def name_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/dns.py b/services/ske/src/stackit/ske/models/dns.py index b7348ded8..3643b2fad 100644 --- a/services/ske/src/stackit/ske/models/dns.py +++ b/services/ske/src/stackit/ske/models/dns.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,7 +34,8 @@ class DNS(BaseModel): __properties: ClassVar[List[str]] = ["enabled", "zones"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/expiration_status.py b/services/ske/src/stackit/ske/models/expiration_status.py index c64ab3e22..af42bc701 100644 --- a/services/ske/src/stackit/ske/models/expiration_status.py +++ b/services/ske/src/stackit/ske/models/expiration_status.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.ske.models.expiration_status_kubernetes import ExpirationStatusKubernetes @@ -34,7 +35,8 @@ class ExpirationStatus(BaseModel): __properties: ClassVar[List[str]] = ["kubernetes", "nodepools"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/expiration_status_kubernetes.py b/services/ske/src/stackit/ske/models/expiration_status_kubernetes.py index 1710fa07e..ca62a5340 100644 --- a/services/ske/src/stackit/ske/models/expiration_status_kubernetes.py +++ b/services/ske/src/stackit/ske/models/expiration_status_kubernetes.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -46,7 +47,8 @@ def expiration_date_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -57,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/expiration_status_nodepool.py b/services/ske/src/stackit/ske/models/expiration_status_nodepool.py index 10190f203..5cef32ee9 100644 --- a/services/ske/src/stackit/ske/models/expiration_status_nodepool.py +++ b/services/ske/src/stackit/ske/models/expiration_status_nodepool.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -70,7 +71,8 @@ def os_expiration_date_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -81,8 +83,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/extension.py b/services/ske/src/stackit/ske/models/extension.py index a22771384..7f84c926b 100644 --- a/services/ske/src/stackit/ske/models/extension.py +++ b/services/ske/src/stackit/ske/models/extension.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.ske.models.acl import ACL @@ -36,7 +37,8 @@ class Extension(BaseModel): __properties: ClassVar[List[str]] = ["acl", "dns", "observability"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/hibernation.py b/services/ske/src/stackit/ske/models/hibernation.py index 8adfc480e..14e21d303 100644 --- a/services/ske/src/stackit/ske/models/hibernation.py +++ b/services/ske/src/stackit/ske/models/hibernation.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.ske.models.hibernation_schedule import HibernationSchedule @@ -32,7 +33,8 @@ class Hibernation(BaseModel): __properties: ClassVar[List[str]] = ["schedules"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/hibernation_schedule.py b/services/ske/src/stackit/ske/models/hibernation_schedule.py index bbb20b262..de6983af2 100644 --- a/services/ske/src/stackit/ske/models/hibernation_schedule.py +++ b/services/ske/src/stackit/ske/models/hibernation_schedule.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -35,6 +36,9 @@ class HibernationSchedule(BaseModel): @field_validator("end") def end_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match( r"(@(annually|yearly|monthly|weekly|daily|hourly|reboot))|(@every (\\d+(ns|us|µs|ms|s|m|h))+)|((((\\d+,)+\\d+|(\\d+(\\/|-)\\d+)|\\d+|\\*) ?){5,7})", value, @@ -47,6 +51,9 @@ def end_validate_regular_expression(cls, value): @field_validator("start") def start_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match( r"(@(annually|yearly|monthly|weekly|daily|hourly|reboot))|(@every (\\d+(ns|us|µs|ms|s|m|h))+)|((((\\d+,)+\\d+|(\\d+(\\/|-)\\d+)|\\d+|\\*) ?){5,7})", value, @@ -57,7 +64,8 @@ def start_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -68,8 +76,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/idp.py b/services/ske/src/stackit/ske/models/idp.py index 296dab7e1..9feb120de 100644 --- a/services/ske/src/stackit/ske/models/idp.py +++ b/services/ske/src/stackit/ske/models/idp.py @@ -24,6 +24,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -37,7 +38,8 @@ class IDP(BaseModel): __properties: ClassVar[List[str]] = ["enabled", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/idp_kubeconfig.py b/services/ske/src/stackit/ske/models/idp_kubeconfig.py index 8714cfbda..c1895903a 100644 --- a/services/ske/src/stackit/ske/models/idp_kubeconfig.py +++ b/services/ske/src/stackit/ske/models/idp_kubeconfig.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class IDPKubeconfig(BaseModel): __properties: ClassVar[List[str]] = ["kubeconfig"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/image.py b/services/ske/src/stackit/ske/models/image.py index c230ee890..35b6be469 100644 --- a/services/ske/src/stackit/ske/models/image.py +++ b/services/ske/src/stackit/ske/models/image.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class Image(BaseModel): __properties: ClassVar[List[str]] = ["name", "version"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/kubeconfig.py b/services/ske/src/stackit/ske/models/kubeconfig.py index 6d984c8cc..4f0a6fcd3 100644 --- a/services/ske/src/stackit/ske/models/kubeconfig.py +++ b/services/ske/src/stackit/ske/models/kubeconfig.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -46,7 +47,8 @@ def expiration_timestamp_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -57,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/kubernetes.py b/services/ske/src/stackit/ske/models/kubernetes.py index 8ccf7be63..1bd7547d3 100644 --- a/services/ske/src/stackit/ske/models/kubernetes.py +++ b/services/ske/src/stackit/ske/models/kubernetes.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,12 +34,16 @@ class Kubernetes(BaseModel): @field_validator("version") def version_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^\d+\.\d+\.\d+$", value): raise ValueError(r"must validate the regular expression /^\d+\.\d+\.\d+$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +54,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/kubernetes_version.py b/services/ske/src/stackit/ske/models/kubernetes_version.py index b454121ca..09eb90630 100644 --- a/services/ske/src/stackit/ske/models/kubernetes_version.py +++ b/services/ske/src/stackit/ske/models/kubernetes_version.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -53,12 +54,16 @@ def version_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^\d+\.\d+\.\d+$", value): raise ValueError(r"must validate the regular expression /^\d+\.\d+\.\d+$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -69,8 +74,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/list_clusters_response.py b/services/ske/src/stackit/ske/models/list_clusters_response.py index 428e1b0ed..9568fb975 100644 --- a/services/ske/src/stackit/ske/models/list_clusters_response.py +++ b/services/ske/src/stackit/ske/models/list_clusters_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.ske.models.cluster import Cluster @@ -32,7 +33,8 @@ class ListClustersResponse(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/login_kubeconfig.py b/services/ske/src/stackit/ske/models/login_kubeconfig.py index e28b75909..9804cd5fa 100644 --- a/services/ske/src/stackit/ske/models/login_kubeconfig.py +++ b/services/ske/src/stackit/ske/models/login_kubeconfig.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class LoginKubeconfig(BaseModel): __properties: ClassVar[List[str]] = ["kubeconfig"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/machine.py b/services/ske/src/stackit/ske/models/machine.py index f4c8cef0f..1269f8e5a 100644 --- a/services/ske/src/stackit/ske/models/machine.py +++ b/services/ske/src/stackit/ske/models/machine.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.ske.models.image import Image @@ -35,7 +36,8 @@ class Machine(BaseModel): __properties: ClassVar[List[str]] = ["image", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/machine_image.py b/services/ske/src/stackit/ske/models/machine_image.py index 082d9b4a9..e16f0adee 100644 --- a/services/ske/src/stackit/ske/models/machine_image.py +++ b/services/ske/src/stackit/ske/models/machine_image.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.ske.models.machine_image_version import MachineImageVersion @@ -33,7 +34,8 @@ class MachineImage(BaseModel): __properties: ClassVar[List[str]] = ["name", "versions"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/machine_image_version.py b/services/ske/src/stackit/ske/models/machine_image_version.py index 489c28ab0..1396fa772 100644 --- a/services/ske/src/stackit/ske/models/machine_image_version.py +++ b/services/ske/src/stackit/ske/models/machine_image_version.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.ske.models.cri import CRI @@ -55,12 +56,16 @@ def version_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^\d+\.\d+\.\d+$", value): raise ValueError(r"must validate the regular expression /^\d+\.\d+\.\d+$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -71,8 +76,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/machine_type.py b/services/ske/src/stackit/ske/models/machine_type.py index 7dfcf7ccc..e4b4db2af 100644 --- a/services/ske/src/stackit/ske/models/machine_type.py +++ b/services/ske/src/stackit/ske/models/machine_type.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class MachineType(BaseModel): __properties: ClassVar[List[str]] = ["architecture", "cpu", "gpu", "memory", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/maintenance.py b/services/ske/src/stackit/ske/models/maintenance.py index 31e2d0ee8..dc2d89611 100644 --- a/services/ske/src/stackit/ske/models/maintenance.py +++ b/services/ske/src/stackit/ske/models/maintenance.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.ske.models.maintenance_auto_update import MaintenanceAutoUpdate @@ -34,7 +35,8 @@ class Maintenance(BaseModel): __properties: ClassVar[List[str]] = ["autoUpdate", "timeWindow"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/maintenance_auto_update.py b/services/ske/src/stackit/ske/models/maintenance_auto_update.py index 32277d6de..75a4efa34 100644 --- a/services/ske/src/stackit/ske/models/maintenance_auto_update.py +++ b/services/ske/src/stackit/ske/models/maintenance_auto_update.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class MaintenanceAutoUpdate(BaseModel): __properties: ClassVar[List[str]] = ["kubernetesVersion", "machineImageVersion"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/network.py b/services/ske/src/stackit/ske/models/network.py index 3a1915e12..a9f0ee9a8 100644 --- a/services/ske/src/stackit/ske/models/network.py +++ b/services/ske/src/stackit/ske/models/network.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.ske.models.v2_control_plane_network import V2ControlPlaneNetwork @@ -33,7 +34,8 @@ class Network(BaseModel): __properties: ClassVar[List[str]] = ["controlPlane", "id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/nodepool.py b/services/ske/src/stackit/ske/models/nodepool.py index 1ff8e7e54..c181559c7 100644 --- a/services/ske/src/stackit/ske/models/nodepool.py +++ b/services/ske/src/stackit/ske/models/nodepool.py @@ -25,6 +25,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.ske.models.cri import CRI @@ -75,7 +76,8 @@ class Nodepool(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -86,8 +88,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/nodepool_kubernetes.py b/services/ske/src/stackit/ske/models/nodepool_kubernetes.py index fdac8139b..10d9cd2fa 100644 --- a/services/ske/src/stackit/ske/models/nodepool_kubernetes.py +++ b/services/ske/src/stackit/ske/models/nodepool_kubernetes.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -39,12 +40,16 @@ def version_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^\d+\.\d+\.\d+$", value): raise ValueError(r"must validate the regular expression /^\d+\.\d+\.\d+$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -55,8 +60,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/observability.py b/services/ske/src/stackit/ske/models/observability.py index cef11e4bc..1e47a74e0 100644 --- a/services/ske/src/stackit/ske/models/observability.py +++ b/services/ske/src/stackit/ske/models/observability.py @@ -24,6 +24,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -39,7 +40,8 @@ class Observability(BaseModel): __properties: ClassVar[List[str]] = ["enabled", "instanceId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/provider_options.py b/services/ske/src/stackit/ske/models/provider_options.py index 125fdeafc..a678da171 100644 --- a/services/ske/src/stackit/ske/models/provider_options.py +++ b/services/ske/src/stackit/ske/models/provider_options.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.ske.models.availability_zone import AvailabilityZone @@ -46,7 +47,8 @@ class ProviderOptions(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -57,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/runtime_error.py b/services/ske/src/stackit/ske/models/runtime_error.py index 7c09f9a9f..2c2f25e1a 100644 --- a/services/ske/src/stackit/ske/models/runtime_error.py +++ b/services/ske/src/stackit/ske/models/runtime_error.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -61,7 +62,8 @@ def code_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -72,8 +74,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/taint.py b/services/ske/src/stackit/ske/models/taint.py index 70b85c88d..1a851b821 100644 --- a/services/ske/src/stackit/ske/models/taint.py +++ b/services/ske/src/stackit/ske/models/taint.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -39,7 +40,8 @@ def effect_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/time_window.py b/services/ske/src/stackit/ske/models/time_window.py index a0d93dba3..fc84cb973 100644 --- a/services/ske/src/stackit/ske/models/time_window.py +++ b/services/ske/src/stackit/ske/models/time_window.py @@ -20,6 +20,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -59,7 +60,8 @@ def start_change_year_zero_to_one(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -70,8 +72,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/v2_control_plane_network.py b/services/ske/src/stackit/ske/models/v2_control_plane_network.py index d36932b10..8652d1b99 100644 --- a/services/ske/src/stackit/ske/models/v2_control_plane_network.py +++ b/services/ske/src/stackit/ske/models/v2_control_plane_network.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.ske.models.access_scope import AccessScope @@ -32,7 +33,8 @@ class V2ControlPlaneNetwork(BaseModel): __properties: ClassVar[List[str]] = ["accessScope"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/volume.py b/services/ske/src/stackit/ske/models/volume.py index 26ce855ac..d5c7ffb59 100644 --- a/services/ske/src/stackit/ske/models/volume.py +++ b/services/ske/src/stackit/ske/models/volume.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -34,7 +35,8 @@ class Volume(BaseModel): __properties: ClassVar[List[str]] = ["size", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/ske/src/stackit/ske/models/volume_type.py b/services/ske/src/stackit/ske/models/volume_type.py index 5f501f30b..e8c6e2ade 100644 --- a/services/ske/src/stackit/ske/models/volume_type.py +++ b/services/ske/src/stackit/ske/models/volume_type.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class VolumeType(BaseModel): __properties: ClassVar[List[str]] = ["name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/CHANGELOG.md b/services/sqlserverflex/CHANGELOG.md index 825df6912..a64f0b460 100644 --- a/services/sqlserverflex/CHANGELOG.md +++ b/services/sqlserverflex/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.2.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v1.1.2 - **Feature:** client now supports UUID and decimal types - **Bugfix:** timeouts now passed to requests library diff --git a/services/sqlserverflex/pyproject.toml b/services/sqlserverflex/pyproject.toml index 65c8f145c..785f454c9 100644 --- a/services/sqlserverflex/pyproject.toml +++ b/services/sqlserverflex/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-sqlserverflex" -version = "v1.1.2" +version = "v1.2.0" description = "STACKIT MSSQL Service API" authors = [{ name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud" }] requires-python = ">=3.9,<4.0" diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/api_client.py b/services/sqlserverflex/src/stackit/sqlserverflex/api_client.py index c423aefea..8b060759d 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/api_client.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/api_client.py @@ -67,6 +67,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -266,7 +267,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -327,25 +328,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -418,6 +414,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/acl.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/acl.py index 233126053..552e458a4 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/acl.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/acl.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class ACL(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/backup.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/backup.py index 6f912aec0..6f2bc7909 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/backup.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/backup.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -38,7 +39,8 @@ class Backup(BaseModel): __properties: ClassVar[List[str]] = ["endTime", "error", "id", "labels", "name", "options", "size", "startTime"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/backup_list_backups_response_grouped.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/backup_list_backups_response_grouped.py index cead1a3b5..da633a685 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/backup_list_backups_response_grouped.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/backup_list_backups_response_grouped.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.backup import Backup @@ -34,7 +35,8 @@ class BackupListBackupsResponseGrouped(BaseModel): __properties: ClassVar[List[str]] = ["backups", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/create_database_payload.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/create_database_payload.py index 884ab96d3..e355d5311 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/create_database_payload.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/create_database_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.database_documentation_create_database_request_options import ( @@ -36,7 +37,8 @@ class CreateDatabasePayload(BaseModel): __properties: ClassVar[List[str]] = ["name", "options"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/create_database_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/create_database_response.py index 16a58ece7..d7ced1e77 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/create_database_response.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/create_database_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class CreateDatabaseResponse(BaseModel): __properties: ClassVar[List[str]] = ["id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/create_instance_payload.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/create_instance_payload.py index cd4de47a0..661ba16c4 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/create_instance_payload.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/create_instance_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.instance_documentation_acl import ( @@ -66,7 +67,8 @@ class CreateInstancePayload(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -77,8 +79,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/create_instance_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/create_instance_response.py index 1fb60f011..73d777d46 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/create_instance_response.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/create_instance_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class CreateInstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/create_user_payload.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/create_user_payload.py index dfa7bb9b3..1cbb53c1e 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/create_user_payload.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/create_user_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -33,7 +34,8 @@ class CreateUserPayload(BaseModel): __properties: ClassVar[List[str]] = ["default_database", "roles", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/create_user_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/create_user_response.py index b52d2287e..0ff82fad9 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/create_user_response.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/create_user_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.single_user import SingleUser @@ -33,7 +34,8 @@ class CreateUserResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/data_point.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/data_point.py index d5968e81c..0112d748f 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/data_point.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/data_point.py @@ -25,6 +25,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -38,7 +39,8 @@ class DataPoint(BaseModel): __properties: ClassVar[List[str]] = ["timestamp", "value"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/database.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/database.py index ef580dacb..0d2dfdb65 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/database.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/database.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -33,7 +34,8 @@ class Database(BaseModel): __properties: ClassVar[List[str]] = ["id", "name", "options"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/database_documentation_create_database_request_options.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/database_documentation_create_database_request_options.py index 79e3ca3dc..e11b6137d 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/database_documentation_create_database_request_options.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/database_documentation_create_database_request_options.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -35,7 +36,8 @@ class DatabaseDocumentationCreateDatabaseRequestOptions(BaseModel): __properties: ClassVar[List[str]] = ["collation", "compatibilityLevel", "owner"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/database_options.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/database_options.py index 9a18857b0..0db92d52f 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/database_options.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/database_options.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -37,7 +38,8 @@ class DatabaseOptions(BaseModel): __properties: ClassVar[List[str]] = ["collationName", "compatibilityLevel", "owner"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/flavor.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/flavor.py index dbe47ca3a..c02c1540b 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/flavor.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/flavor.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class Flavor(BaseModel): __properties: ClassVar[List[str]] = ["cpu", "description", "id", "memory"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/get_backup_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/get_backup_response.py index 5f0ec42eb..85bb2b585 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/get_backup_response.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/get_backup_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -42,7 +43,8 @@ class GetBackupResponse(BaseModel): __properties: ClassVar[List[str]] = ["endTime", "error", "id", "labels", "name", "options", "size", "startTime"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/get_database_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/get_database_response.py index 9e51ccdc0..c6ef3b79d 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/get_database_response.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/get_database_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.single_database import SingleDatabase @@ -33,7 +34,8 @@ class GetDatabaseResponse(BaseModel): __properties: ClassVar[List[str]] = ["database"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/get_instance_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/get_instance_response.py index 5669108c5..07a98fec3 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/get_instance_response.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/get_instance_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.instance import Instance @@ -33,7 +34,8 @@ class GetInstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/get_user_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/get_user_response.py index 371316137..b303b3f17 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/get_user_response.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/get_user_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.user_response_user import UserResponseUser @@ -33,7 +34,8 @@ class GetUserResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/host.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/host.py index f9af2fb08..7baaa5630 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/host.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/host.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.host_metric import HostMetric @@ -34,7 +35,8 @@ class Host(BaseModel): __properties: ClassVar[List[str]] = ["hostMetrics", "id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/host_metric.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/host_metric.py index 0b148248a..19366a03e 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/host_metric.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/host_metric.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.data_point import DataPoint @@ -35,7 +36,8 @@ class HostMetric(BaseModel): __properties: ClassVar[List[str]] = ["datapoints", "name", "units"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/instance.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/instance.py index b235a4e10..cb019f594 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/instance.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/instance.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.acl import ACL @@ -55,7 +56,8 @@ class Instance(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -66,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_documentation_acl.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_documentation_acl.py index 80c351379..862d6b23d 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_documentation_acl.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_documentation_acl.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class InstanceDocumentationACL(BaseModel): __properties: ClassVar[List[str]] = ["items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_documentation_options.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_documentation_options.py index aa1bdacff..94eb2bdd7 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_documentation_options.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_documentation_options.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -36,7 +37,8 @@ class InstanceDocumentationOptions(BaseModel): __properties: ClassVar[List[str]] = ["edition", "retentionDays"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_documentation_storage.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_documentation_storage.py index 1429b09ff..b8d4c32ac 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_documentation_storage.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_documentation_storage.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class InstanceDocumentationStorage(BaseModel): __properties: ClassVar[List[str]] = ["class", "size"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_error.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_error.py index c17315409..794a66ce3 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_error.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_error.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.type import Type @@ -36,7 +37,8 @@ class InstanceError(BaseModel): __properties: ClassVar[List[str]] = ["code", "fields", "message", "type"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_flavor_entry.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_flavor_entry.py index 191cfd2ca..b4a1abf86 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_flavor_entry.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_flavor_entry.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -35,7 +36,8 @@ class InstanceFlavorEntry(BaseModel): __properties: ClassVar[List[str]] = ["categories", "cpu", "description", "id", "memory"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_list_instance.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_list_instance.py index 9b7e11b74..61ff3bc59 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_list_instance.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_list_instance.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -33,7 +34,8 @@ class InstanceListInstance(BaseModel): __properties: ClassVar[List[str]] = ["id", "name", "status"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_list_user.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_list_user.py index 8a396207d..53f11ccdd 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_list_user.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/instance_list_user.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class InstanceListUser(BaseModel): __properties: ClassVar[List[str]] = ["id", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_backups_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_backups_response.py index 7c1d6a20e..b442fda68 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_backups_response.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_backups_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.backup_list_backups_response_grouped import ( @@ -35,7 +36,8 @@ class ListBackupsResponse(BaseModel): __properties: ClassVar[List[str]] = ["databases"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_collations_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_collations_response.py index 867dcf05e..43b22edae 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_collations_response.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_collations_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.mssql_database_collation import MssqlDatabaseCollation @@ -33,7 +34,8 @@ class ListCollationsResponse(BaseModel): __properties: ClassVar[List[str]] = ["collations"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_compatibility_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_compatibility_response.py index 35526a045..f4f47d6cf 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_compatibility_response.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_compatibility_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.mssql_database_compatibility import ( @@ -35,7 +36,8 @@ class ListCompatibilityResponse(BaseModel): __properties: ClassVar[List[str]] = ["compatibilities"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_databases_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_databases_response.py index a5e8ef136..9da93a845 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_databases_response.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_databases_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.database import Database @@ -33,7 +34,8 @@ class ListDatabasesResponse(BaseModel): __properties: ClassVar[List[str]] = ["databases"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_flavors_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_flavors_response.py index 687444510..8a77d199e 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_flavors_response.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_flavors_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.instance_flavor_entry import InstanceFlavorEntry @@ -33,7 +34,8 @@ class ListFlavorsResponse(BaseModel): __properties: ClassVar[List[str]] = ["flavors"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_instances_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_instances_response.py index 493abbfdf..48365a8cb 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_instances_response.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_instances_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.instance_list_instance import InstanceListInstance @@ -34,7 +35,8 @@ class ListInstancesResponse(BaseModel): __properties: ClassVar[List[str]] = ["count", "items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_metrics_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_metrics_response.py index 1f2bc02b0..9760bad6c 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_metrics_response.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_metrics_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.host import Host @@ -33,7 +34,8 @@ class ListMetricsResponse(BaseModel): __properties: ClassVar[List[str]] = ["hosts"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_restore_jobs_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_restore_jobs_response.py index 39d2433c3..65e79a43f 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_restore_jobs_response.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_restore_jobs_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.restore_running_restore import RestoreRunningRestore @@ -33,7 +34,8 @@ class ListRestoreJobsResponse(BaseModel): __properties: ClassVar[List[str]] = ["runningRestores"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_roles_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_roles_response.py index 4cb47243f..790957120 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_roles_response.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_roles_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class ListRolesResponse(BaseModel): __properties: ClassVar[List[str]] = ["roles"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_storages_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_storages_response.py index 8d06af931..20d545456 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_storages_response.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_storages_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.storage_range import StorageRange @@ -34,7 +35,8 @@ class ListStoragesResponse(BaseModel): __properties: ClassVar[List[str]] = ["storageClasses", "storageRange"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_users_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_users_response.py index 58bf780b8..faeea7510 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_users_response.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_users_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.instance_list_user import InstanceListUser @@ -34,7 +35,8 @@ class ListUsersResponse(BaseModel): __properties: ClassVar[List[str]] = ["count", "items"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_versions_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_versions_response.py index 38ef02c7a..76687d45e 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/list_versions_response.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/list_versions_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class ListVersionsResponse(BaseModel): __properties: ClassVar[List[str]] = ["versions"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/mssql_database_collation.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/mssql_database_collation.py index 65ce2d35a..17e6a0716 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/mssql_database_collation.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/mssql_database_collation.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class MssqlDatabaseCollation(BaseModel): __properties: ClassVar[List[str]] = ["collation_name", "description"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/mssql_database_compatibility.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/mssql_database_compatibility.py index 835050833..e704b4271 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/mssql_database_compatibility.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/mssql_database_compatibility.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class MssqlDatabaseCompatibility(BaseModel): __properties: ClassVar[List[str]] = ["compatibility_level", "description"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/partial_update_instance_payload.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/partial_update_instance_payload.py index a2593fdcc..a4fbfc5d2 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/partial_update_instance_payload.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/partial_update_instance_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.instance_documentation_acl import ( @@ -47,7 +48,8 @@ class PartialUpdateInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["acl", "backupSchedule", "flavorId", "labels", "name", "version"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -58,8 +60,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/reset_user_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/reset_user_response.py index 8b206c14a..74f706024 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/reset_user_response.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/reset_user_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.single_user import SingleUser @@ -33,7 +34,8 @@ class ResetUserResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/restore_running_restore.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/restore_running_restore.py index 552d4c679..1519e5c3e 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/restore_running_restore.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/restore_running_restore.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -41,7 +42,8 @@ class RestoreRunningRestore(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -52,8 +54,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/single_database.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/single_database.py index e76c0703e..e42d01a5e 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/single_database.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/single_database.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.database_options import DatabaseOptions @@ -35,7 +36,8 @@ class SingleDatabase(BaseModel): __properties: ClassVar[List[str]] = ["id", "name", "options"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/single_user.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/single_user.py index 04ee99c2c..5d83d724d 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/single_user.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/single_user.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -47,7 +48,8 @@ class SingleUser(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -58,8 +60,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/storage.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/storage.py index 84853e48d..8f1d2ab10 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/storage.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/storage.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class Storage(BaseModel): __properties: ClassVar[List[str]] = ["class", "size"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/storage_range.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/storage_range.py index 75885acf7..ab1ceff7d 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/storage_range.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/storage_range.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class StorageRange(BaseModel): __properties: ClassVar[List[str]] = ["max", "min"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/trigger_database_restore_payload.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/trigger_database_restore_payload.py index 147fd2142..6519725f1 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/trigger_database_restore_payload.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/trigger_database_restore_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class TriggerDatabaseRestorePayload(BaseModel): __properties: ClassVar[List[str]] = ["name", "restoreDateTime"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/update_instance_payload.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/update_instance_payload.py index fd437e3ef..580ac6633 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/update_instance_payload.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/update_instance_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.instance_documentation_acl import ( @@ -45,7 +46,8 @@ class UpdateInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["acl", "backupSchedule", "flavorId", "labels", "name", "version"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +58,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/update_instance_response.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/update_instance_response.py index ab276ffc5..f7782e5cd 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/update_instance_response.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/update_instance_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.sqlserverflex.models.instance import Instance @@ -33,7 +34,8 @@ class UpdateInstanceResponse(BaseModel): __properties: ClassVar[List[str]] = ["item"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/user.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/user.py index 070629c47..e8864ebc7 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/user.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/user.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -38,7 +39,8 @@ class User(BaseModel): __properties: ClassVar[List[str]] = ["database", "host", "id", "password", "port", "roles", "uri", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/sqlserverflex/src/stackit/sqlserverflex/models/user_response_user.py b/services/sqlserverflex/src/stackit/sqlserverflex/models/user_response_user.py index b5b6a1960..97b70f574 100644 --- a/services/sqlserverflex/src/stackit/sqlserverflex/models/user_response_user.py +++ b/services/sqlserverflex/src/stackit/sqlserverflex/models/user_response_user.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -36,7 +37,8 @@ class UserResponseUser(BaseModel): __properties: ClassVar[List[str]] = ["default_database", "host", "id", "port", "roles", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/CHANGELOG.md b/services/telemetryrouter/CHANGELOG.md index e4bd5f66a..acb21b803 100644 --- a/services/telemetryrouter/CHANGELOG.md +++ b/services/telemetryrouter/CHANGELOG.md @@ -1,2 +1,5 @@ +## v0.2.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.1.0 -- **New**: API for STACKIT Telemetry Router \ No newline at end of file +- **New**: API for STACKIT Telemetry Router diff --git a/services/telemetryrouter/pyproject.toml b/services/telemetryrouter/pyproject.toml index 3d24f58a6..d4f28d0db 100644 --- a/services/telemetryrouter/pyproject.toml +++ b/services/telemetryrouter/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-telemetryrouter" -version = "v0.1.0" +version = "v0.2.0" description = "STACKIT Telemetry Router API" authors = [{name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud"}] requires-python = ">=3.9,<4.0" diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/api_client.py b/services/telemetryrouter/src/stackit/telemetryrouter/api_client.py index f0fb0eec8..43873e9d2 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/api_client.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/access_token_base_request.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/access_token_base_request.py index 3a0d193cc..734720a3d 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/access_token_base_request.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/access_token_base_request.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -42,12 +43,16 @@ class AccessTokenBaseRequest(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9][a-zA-Z0-9 \-]*$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9][a-zA-Z0-9 \-]*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -58,8 +63,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/access_token_base_response.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/access_token_base_response.py index 8b19f381f..8c6c84f6c 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/access_token_base_response.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/access_token_base_response.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -48,6 +49,9 @@ class AccessTokenBaseResponse(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9][a-zA-Z0-9 ]*$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9][a-zA-Z0-9 ]*$/") return value @@ -73,7 +77,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -84,8 +89,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/config_filter.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/config_filter.py index d566011f6..d3bb149bd 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/config_filter.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/config_filter.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.telemetryrouter.models.config_filter_attributes import ( @@ -34,7 +35,8 @@ class ConfigFilter(BaseModel): __properties: ClassVar[List[str]] = ["attributes"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/config_filter_attributes.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/config_filter_attributes.py index 61d0045d1..ed397ec22 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/config_filter_attributes.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/config_filter_attributes.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.telemetryrouter.models.config_filter_level import ConfigFilterLevel @@ -38,7 +39,8 @@ class ConfigFilterAttributes(BaseModel): __properties: ClassVar[List[str]] = ["key", "level", "matcher", "values"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/create_access_token_payload.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/create_access_token_payload.py index d175f14a3..24258826f 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/create_access_token_payload.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/create_access_token_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -42,12 +43,16 @@ class CreateAccessTokenPayload(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9][a-zA-Z0-9 \-]*$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9][a-zA-Z0-9 \-]*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -58,8 +63,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/create_access_token_response.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/create_access_token_response.py index 4717c225e..6875fe6a1 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/create_access_token_response.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/create_access_token_response.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -57,6 +58,9 @@ class CreateAccessTokenResponse(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9][a-zA-Z0-9 ]*$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9][a-zA-Z0-9 ]*$/") return value @@ -82,7 +86,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -93,8 +98,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/create_destination_payload.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/create_destination_payload.py index 0471ec075..8d5dc5506 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/create_destination_payload.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/create_destination_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.telemetryrouter.models.destination_config import DestinationConfig @@ -42,12 +43,16 @@ class CreateDestinationPayload(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9][a-zA-Z0-9 \-]*$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9][a-zA-Z0-9 \-]*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -58,8 +63,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/create_telemetry_router_payload.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/create_telemetry_router_payload.py index 3b889590c..4d5b81951 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/create_telemetry_router_payload.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/create_telemetry_router_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.telemetryrouter.models.config_filter import ConfigFilter @@ -42,12 +43,16 @@ class CreateTelemetryRouterPayload(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9][a-zA-Z0-9 \-]*$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9][a-zA-Z0-9 \-]*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -58,8 +63,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_config.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_config.py index 2ca34dd88..6efe7e9fd 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_config.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_config.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.telemetryrouter.models.config_filter import ConfigFilter @@ -40,7 +41,8 @@ class DestinationConfig(BaseModel): __properties: ClassVar[List[str]] = ["configType", "filter", "openTelemetry", "s3"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -51,8 +53,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_config_open_telemetry.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_config_open_telemetry.py index caf05665b..9081426d0 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_config_open_telemetry.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_config_open_telemetry.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.telemetryrouter.models.destination_config_open_telemetry_basic_auth import ( @@ -38,7 +39,8 @@ class DestinationConfigOpenTelemetry(BaseModel): __properties: ClassVar[List[str]] = ["basicAuth", "bearerToken", "uri"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_config_open_telemetry_basic_auth.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_config_open_telemetry_basic_auth.py index 703e72817..e2854de02 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_config_open_telemetry_basic_auth.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_config_open_telemetry_basic_auth.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -31,7 +32,8 @@ class DestinationConfigOpenTelemetryBasicAuth(BaseModel): __properties: ClassVar[List[str]] = ["password", "username"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_config_s3.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_config_s3.py index 67c68d2d1..704b9948f 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_config_s3.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_config_s3.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.telemetryrouter.models.destination_config_s3_access_key import ( @@ -38,7 +39,8 @@ class DestinationConfigS3(BaseModel): __properties: ClassVar[List[str]] = ["accessKey", "bucket", "endpoint"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -49,8 +51,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_config_s3_access_key.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_config_s3_access_key.py index 175b27214..26d96fbc2 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_config_s3_access_key.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_config_s3_access_key.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -31,7 +32,8 @@ class DestinationConfigS3AccessKey(BaseModel): __properties: ClassVar[List[str]] = ["id", "secret"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_response.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_response.py index c893898a6..dd03b7f55 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_response.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/destination_response.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.telemetryrouter.models.destination_config import DestinationConfig @@ -76,6 +77,9 @@ def credential_type_validate_enum(cls, value): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9][a-zA-Z0-9 \-]*$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9][a-zA-Z0-9 \-]*$/") return value @@ -88,7 +92,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -99,8 +104,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/get_access_token_response.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/get_access_token_response.py index abafbd076..c5d24d4db 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/get_access_token_response.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/get_access_token_response.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -48,6 +49,9 @@ class GetAccessTokenResponse(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9][a-zA-Z0-9 ]*$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9][a-zA-Z0-9 ]*$/") return value @@ -73,7 +77,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -84,8 +89,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/list_access_tokens_response.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/list_access_tokens_response.py index 90d903c6b..eb82f2956 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/list_access_tokens_response.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/list_access_tokens_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.telemetryrouter.models.get_access_token_response import ( @@ -37,7 +38,8 @@ class ListAccessTokensResponse(BaseModel): __properties: ClassVar[List[str]] = ["accessTokens", "nextPageToken"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/list_destinations_response.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/list_destinations_response.py index cbef204c5..cf6ad70f4 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/list_destinations_response.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/list_destinations_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.telemetryrouter.models.destination_response import DestinationResponse @@ -35,7 +36,8 @@ class ListDestinationsResponse(BaseModel): __properties: ClassVar[List[str]] = ["destinations", "nextPageToken"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/list_telemetry_routers_response.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/list_telemetry_routers_response.py index b9a776c65..2769a761b 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/list_telemetry_routers_response.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/list_telemetry_routers_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.telemetryrouter.models.telemetry_router_response import ( @@ -37,7 +38,8 @@ class ListTelemetryRoutersResponse(BaseModel): __properties: ClassVar[List[str]] = ["nextPageToken", "telemetryRouters"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/response4xx.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/response4xx.py index e87c98255..275a17b63 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/response4xx.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/response4xx.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,7 +31,8 @@ class Response4xx(BaseModel): __properties: ClassVar[List[str]] = ["message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/telemetry_router_response.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/telemetry_router_response.py index 3fe3e6b58..afacdf595 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/telemetry_router_response.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/telemetry_router_response.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.telemetryrouter.models.config_filter import ConfigFilter @@ -61,6 +62,9 @@ def creation_time_change_year_zero_to_one(cls, value): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9][a-zA-Z0-9 \-]*$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9][a-zA-Z0-9 \-]*$/") return value @@ -73,7 +77,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -84,8 +89,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/update_access_token_payload.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/update_access_token_payload.py index b2a5bb1b7..6009e167a 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/update_access_token_payload.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/update_access_token_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -39,12 +40,16 @@ def display_name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9][a-zA-Z0-9 \-]*$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9][a-zA-Z0-9 \-]*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -55,8 +60,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/update_access_token_response.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/update_access_token_response.py index b93ae593a..e01117b21 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/update_access_token_response.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/update_access_token_response.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -48,6 +49,9 @@ class UpdateAccessTokenResponse(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9][a-zA-Z0-9 ]*$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9][a-zA-Z0-9 ]*$/") return value @@ -73,7 +77,8 @@ def status_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -84,8 +89,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/update_destination_payload.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/update_destination_payload.py index 1bf44a163..c4c041590 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/update_destination_payload.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/update_destination_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.telemetryrouter.models.destination_config import DestinationConfig @@ -47,12 +48,16 @@ def display_name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9][a-zA-Z0-9 \-]*$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9][a-zA-Z0-9 \-]*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -63,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/telemetryrouter/src/stackit/telemetryrouter/models/update_telemetry_router_payload.py b/services/telemetryrouter/src/stackit/telemetryrouter/models/update_telemetry_router_payload.py index 23d0fe7d0..c1e95f39a 100644 --- a/services/telemetryrouter/src/stackit/telemetryrouter/models/update_telemetry_router_payload.py +++ b/services/telemetryrouter/src/stackit/telemetryrouter/models/update_telemetry_router_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.telemetryrouter.models.config_filter import ConfigFilter @@ -47,12 +48,16 @@ def display_name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9][a-zA-Z0-9 \-]*$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9][a-zA-Z0-9 \-]*$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -63,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/CHANGELOG.md b/services/vpn/CHANGELOG.md index 285a5042b..1d63d784c 100644 --- a/services/vpn/CHANGELOG.md +++ b/services/vpn/CHANGELOG.md @@ -1,2 +1,5 @@ +## v0.2.0 +- **Feature:** regenerate with openapi-generator v7.22.0 + ## v0.1.0 - Initial publication of STACKIT Python SDK module for STACKIT VPN service diff --git a/services/vpn/pyproject.toml b/services/vpn/pyproject.toml index 10c25876e..c8550dcd5 100644 --- a/services/vpn/pyproject.toml +++ b/services/vpn/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stackit-vpn" -version = "v0.1.0" +version = "v0.2.0" description = "STACKIT VPN API" authors = [{name = "STACKIT Developer Tools", email = "developer-tools@stackit.cloud"}] requires-python = ">=3.9,<4.0" diff --git a/services/vpn/src/stackit/vpn/api_client.py b/services/vpn/src/stackit/vpn/api_client.py index 9d5053fa5..d43b49902 100644 --- a/services/vpn/src/stackit/vpn/api_client.py +++ b/services/vpn/src/stackit/vpn/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,7 @@ def response_deserialize( response_text = None return_data = None try: - if response_type == "bytearray": + if response_type in ("bytearray", "bytes"): return_data = response_data.data elif response_type == "file": return_data = self.__deserialize_file(response_data) @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) - elif isinstance(obj, dict): - obj_dict = obj + return {key: self.sanitize_for_serialization(val) for key, val in obj.items()} + + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 + obj_dict = obj.to_dict() else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009 - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - if isinstance(obj_dict, list): - # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501 - return self.sanitize_for_serialization(obj_dict) + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} + return self.sanitize_for_serialization(obj_dict) def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -417,6 +413,8 @@ def __deserialize(self, data, klass): return self.__deserialize_datetime(data) elif klass is decimal.Decimal: return decimal.Decimal(data) + elif klass is uuid.UUID: + return uuid.UUID(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: diff --git a/services/vpn/src/stackit/vpn/models/api_error.py b/services/vpn/src/stackit/vpn/models/api_error.py index 5eaefdca8..09a91dd7b 100644 --- a/services/vpn/src/stackit/vpn/models/api_error.py +++ b/services/vpn/src/stackit/vpn/models/api_error.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.vpn.models.api_error_detail import APIErrorDetail @@ -35,7 +36,8 @@ class APIError(BaseModel): __properties: ClassVar[List[str]] = ["code", "details", "message", "status"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/api_error_detail.py b/services/vpn/src/stackit/vpn/models/api_error_detail.py index b0a61ec6e..7feacd81e 100644 --- a/services/vpn/src/stackit/vpn/models/api_error_detail.py +++ b/services/vpn/src/stackit/vpn/models/api_error_detail.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -42,7 +43,8 @@ def reason_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/api_error_response.py b/services/vpn/src/stackit/vpn/models/api_error_response.py index 340d4d387..0f3890fe1 100644 --- a/services/vpn/src/stackit/vpn/models/api_error_response.py +++ b/services/vpn/src/stackit/vpn/models/api_error_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.vpn.models.api_error import APIError @@ -32,7 +33,8 @@ class APIErrorResponse(BaseModel): __properties: ClassVar[List[str]] = ["error"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/bgp_gateway_config.py b/services/vpn/src/stackit/vpn/models/bgp_gateway_config.py index c7a909047..e5623135f 100644 --- a/services/vpn/src/stackit/vpn/models/bgp_gateway_config.py +++ b/services/vpn/src/stackit/vpn/models/bgp_gateway_config.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -41,7 +42,8 @@ class BGPGatewayConfig(BaseModel): __properties: ClassVar[List[str]] = ["localAsn", "overrideAdvertisedRoutes"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -52,8 +54,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/bgp_status.py b/services/vpn/src/stackit/vpn/models/bgp_status.py index 07b7fc994..418eb4c0a 100644 --- a/services/vpn/src/stackit/vpn/models/bgp_status.py +++ b/services/vpn/src/stackit/vpn/models/bgp_status.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.vpn.models.bgp_status_peers import BGPStatusPeers @@ -34,7 +35,8 @@ class BGPStatus(BaseModel): __properties: ClassVar[List[str]] = ["peers", "routes"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/bgp_status_peers.py b/services/vpn/src/stackit/vpn/models/bgp_status_peers.py index 7ff7cf26f..d8da83afc 100644 --- a/services/vpn/src/stackit/vpn/models/bgp_status_peers.py +++ b/services/vpn/src/stackit/vpn/models/bgp_status_peers.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -36,7 +37,8 @@ class BGPStatusPeers(BaseModel): __properties: ClassVar[List[str]] = ["localAs", "peerUptime", "pfxRcd", "pfxSnt", "remoteAs", "remoteIP", "state"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -47,8 +49,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/bgp_status_routes.py b/services/vpn/src/stackit/vpn/models/bgp_status_routes.py index 4281e4c58..e959da471 100644 --- a/services/vpn/src/stackit/vpn/models/bgp_status_routes.py +++ b/services/vpn/src/stackit/vpn/models/bgp_status_routes.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -34,7 +35,8 @@ class BGPStatusRoutes(BaseModel): __properties: ClassVar[List[str]] = ["network", "origin", "path", "peerId", "weight"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -45,8 +47,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/bgp_tunnel_config.py b/services/vpn/src/stackit/vpn/models/bgp_tunnel_config.py index b815e9463..c34fa07ef 100644 --- a/services/vpn/src/stackit/vpn/models/bgp_tunnel_config.py +++ b/services/vpn/src/stackit/vpn/models/bgp_tunnel_config.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -33,7 +34,8 @@ class BGPTunnelConfig(BaseModel): __properties: ClassVar[List[str]] = ["remoteAsn"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -44,8 +46,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/connection_list.py b/services/vpn/src/stackit/vpn/models/connection_list.py index a93c36ebf..79a32246e 100644 --- a/services/vpn/src/stackit/vpn/models/connection_list.py +++ b/services/vpn/src/stackit/vpn/models/connection_list.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.vpn.models.connection_response import ConnectionResponse @@ -32,7 +33,8 @@ class ConnectionList(BaseModel): __properties: ClassVar[List[str]] = ["connections"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/connection_response.py b/services/vpn/src/stackit/vpn/models/connection_response.py index 38d1a1774..f76bbc4d3 100644 --- a/services/vpn/src/stackit/vpn/models/connection_response.py +++ b/services/vpn/src/stackit/vpn/models/connection_response.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.vpn.models.tunnel_configuration import TunnelConfiguration @@ -75,12 +76,16 @@ class ConnectionResponse(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -91,8 +96,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/connection_status_response.py b/services/vpn/src/stackit/vpn/models/connection_status_response.py index b2590f036..5cde99f69 100644 --- a/services/vpn/src/stackit/vpn/models/connection_status_response.py +++ b/services/vpn/src/stackit/vpn/models/connection_status_response.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.vpn.models.tunnel_status import TunnelStatus @@ -44,7 +45,8 @@ class ConnectionStatusResponse(BaseModel): __properties: ClassVar[List[str]] = ["displayName", "enabled", "id", "tunnels"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/create_gateway_connection_payload.py b/services/vpn/src/stackit/vpn/models/create_gateway_connection_payload.py index 7e637d74f..444265fa0 100644 --- a/services/vpn/src/stackit/vpn/models/create_gateway_connection_payload.py +++ b/services/vpn/src/stackit/vpn/models/create_gateway_connection_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.vpn.models.tunnel_configuration import TunnelConfiguration @@ -67,12 +68,16 @@ class CreateGatewayConnectionPayload(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -83,8 +88,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/create_vpn_gateway_payload.py b/services/vpn/src/stackit/vpn/models/create_vpn_gateway_payload.py index 95bc7e664..79e649049 100644 --- a/services/vpn/src/stackit/vpn/models/create_vpn_gateway_payload.py +++ b/services/vpn/src/stackit/vpn/models/create_vpn_gateway_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.vpn.models.bgp_gateway_config import BGPGatewayConfig @@ -49,12 +50,16 @@ class CreateVPNGatewayPayload(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -65,8 +70,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/create_vpn_gateway_payload_availability_zones.py b/services/vpn/src/stackit/vpn/models/create_vpn_gateway_payload_availability_zones.py index e35134648..9450d1b56 100644 --- a/services/vpn/src/stackit/vpn/models/create_vpn_gateway_payload_availability_zones.py +++ b/services/vpn/src/stackit/vpn/models/create_vpn_gateway_payload_availability_zones.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class CreateVPNGatewayPayloadAvailabilityZones(BaseModel): __properties: ClassVar[List[str]] = ["tunnel1", "tunnel2"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/gateway.py b/services/vpn/src/stackit/vpn/models/gateway.py index 6ca3d44fd..3c541df35 100644 --- a/services/vpn/src/stackit/vpn/models/gateway.py +++ b/services/vpn/src/stackit/vpn/models/gateway.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.vpn.models.bgp_gateway_config import BGPGatewayConfig @@ -49,12 +50,16 @@ class Gateway(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -65,8 +70,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/gateway_list.py b/services/vpn/src/stackit/vpn/models/gateway_list.py index 0f22b8494..64695bd36 100644 --- a/services/vpn/src/stackit/vpn/models/gateway_list.py +++ b/services/vpn/src/stackit/vpn/models/gateway_list.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.vpn.models.gateway_response import GatewayResponse @@ -32,7 +33,8 @@ class GatewayList(BaseModel): __properties: ClassVar[List[str]] = ["gateways"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/gateway_response.py b/services/vpn/src/stackit/vpn/models/gateway_response.py index cc2694e02..e252b93c0 100644 --- a/services/vpn/src/stackit/vpn/models/gateway_response.py +++ b/services/vpn/src/stackit/vpn/models/gateway_response.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.vpn.models.bgp_gateway_config import BGPGatewayConfig @@ -62,12 +63,16 @@ class GatewayResponse(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -78,8 +83,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/gateway_status_response.py b/services/vpn/src/stackit/vpn/models/gateway_status_response.py index f61d1238c..4642fe460 100644 --- a/services/vpn/src/stackit/vpn/models/gateway_status_response.py +++ b/services/vpn/src/stackit/vpn/models/gateway_status_response.py @@ -19,6 +19,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.vpn.models.connection_status_response import ConnectionStatusResponse @@ -41,7 +42,8 @@ class GatewayStatusResponse(BaseModel): __properties: ClassVar[List[str]] = ["connections", "displayName", "gatewayStatus", "id", "tunnels"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -52,8 +54,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/peering_config.py b/services/vpn/src/stackit/vpn/models/peering_config.py index a9d42d1c0..acd601f20 100644 --- a/services/vpn/src/stackit/vpn/models/peering_config.py +++ b/services/vpn/src/stackit/vpn/models/peering_config.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -37,6 +38,9 @@ def local_address_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$", value): raise ValueError(r"must validate the regular expression /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$/") return value @@ -47,12 +51,16 @@ def remote_address_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$", value): raise ValueError(r"must validate the regular expression /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -63,8 +71,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/phase.py b/services/vpn/src/stackit/vpn/models/phase.py index 3a74c5ba6..8422861be 100644 --- a/services/vpn/src/stackit/vpn/models/phase.py +++ b/services/vpn/src/stackit/vpn/models/phase.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -65,7 +66,8 @@ def integrity_algorithms_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -76,8 +78,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/phase1_status.py b/services/vpn/src/stackit/vpn/models/phase1_status.py index ff75e6a95..e1e4c7b25 100644 --- a/services/vpn/src/stackit/vpn/models/phase1_status.py +++ b/services/vpn/src/stackit/vpn/models/phase1_status.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -41,7 +42,8 @@ class Phase1Status(BaseModel): __properties: ClassVar[List[str]] = ["dhGroup", "encryptionAlgorithm", "integrityAlgorithm", "state"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -52,8 +54,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/phase2_status.py b/services/vpn/src/stackit/vpn/models/phase2_status.py index 750590746..85a05eac6 100644 --- a/services/vpn/src/stackit/vpn/models/phase2_status.py +++ b/services/vpn/src/stackit/vpn/models/phase2_status.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -79,7 +80,8 @@ class Phase2Status(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -90,8 +92,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/plan.py b/services/vpn/src/stackit/vpn/models/plan.py index f53285358..34031f9c6 100644 --- a/services/vpn/src/stackit/vpn/models/plan.py +++ b/services/vpn/src/stackit/vpn/models/plan.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -42,7 +43,8 @@ class Plan(BaseModel): __properties: ClassVar[List[str]] = ["maxBandwidth", "maxConnections", "name", "planId", "sku"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -53,8 +55,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/plan_list.py b/services/vpn/src/stackit/vpn/models/plan_list.py index 67f23f32f..9c7063f24 100644 --- a/services/vpn/src/stackit/vpn/models/plan_list.py +++ b/services/vpn/src/stackit/vpn/models/plan_list.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.vpn.models.plan import Plan @@ -35,7 +36,8 @@ class PlanList(BaseModel): __properties: ClassVar[List[str]] = ["defaultPlanId", "plans"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -46,8 +48,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/quota.py b/services/vpn/src/stackit/vpn/models/quota.py index cfe67dd19..3d4a6790f 100644 --- a/services/vpn/src/stackit/vpn/models/quota.py +++ b/services/vpn/src/stackit/vpn/models/quota.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictInt +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -31,7 +32,8 @@ class Quota(BaseModel): __properties: ClassVar[List[str]] = ["limit", "usage"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -42,8 +44,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/quota_list.py b/services/vpn/src/stackit/vpn/models/quota_list.py index 9527ccbe2..3e09a978c 100644 --- a/services/vpn/src/stackit/vpn/models/quota_list.py +++ b/services/vpn/src/stackit/vpn/models/quota_list.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.vpn.models.quota import Quota @@ -32,7 +33,8 @@ class QuotaList(BaseModel): __properties: ClassVar[List[str]] = ["gateways"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/quota_list_response.py b/services/vpn/src/stackit/vpn/models/quota_list_response.py index c3b4d6f11..fda1752ea 100644 --- a/services/vpn/src/stackit/vpn/models/quota_list_response.py +++ b/services/vpn/src/stackit/vpn/models/quota_list_response.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.vpn.models.quota_list import QuotaList @@ -32,7 +33,8 @@ class QuotaListResponse(BaseModel): __properties: ClassVar[List[str]] = ["quotas"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -43,8 +45,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/tunnel_configuration.py b/services/vpn/src/stackit/vpn/models/tunnel_configuration.py index 1209d700d..1084572b9 100644 --- a/services/vpn/src/stackit/vpn/models/tunnel_configuration.py +++ b/services/vpn/src/stackit/vpn/models/tunnel_configuration.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.vpn.models.bgp_tunnel_config import BGPTunnelConfig @@ -47,12 +48,16 @@ class TunnelConfiguration(BaseModel): @field_validator("remote_address") def remote_address_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$", value): raise ValueError(r"must validate the regular expression /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -63,8 +68,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/tunnel_configuration_phase1.py b/services/vpn/src/stackit/vpn/models/tunnel_configuration_phase1.py index 882089d99..80fd644f3 100644 --- a/services/vpn/src/stackit/vpn/models/tunnel_configuration_phase1.py +++ b/services/vpn/src/stackit/vpn/models/tunnel_configuration_phase1.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -68,7 +69,8 @@ def integrity_algorithms_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -79,8 +81,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/tunnel_configuration_phase2.py b/services/vpn/src/stackit/vpn/models/tunnel_configuration_phase2.py index 10fb60137..e9748f639 100644 --- a/services/vpn/src/stackit/vpn/models/tunnel_configuration_phase2.py +++ b/services/vpn/src/stackit/vpn/models/tunnel_configuration_phase2.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -105,7 +106,8 @@ def start_action_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -116,8 +118,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/tunnel_status.py b/services/vpn/src/stackit/vpn/models/tunnel_status.py index 7441d8da8..a733ef35e 100644 --- a/services/vpn/src/stackit/vpn/models/tunnel_status.py +++ b/services/vpn/src/stackit/vpn/models/tunnel_status.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.vpn.models.phase1_status import Phase1Status @@ -46,7 +47,8 @@ def name_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -57,8 +59,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/update_gateway_connection_payload.py b/services/vpn/src/stackit/vpn/models/update_gateway_connection_payload.py index ae16885a7..0444199b5 100644 --- a/services/vpn/src/stackit/vpn/models/update_gateway_connection_payload.py +++ b/services/vpn/src/stackit/vpn/models/update_gateway_connection_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.vpn.models.tunnel_configuration import TunnelConfiguration @@ -67,12 +68,16 @@ class UpdateGatewayConnectionPayload(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -83,8 +88,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/update_vpn_gateway_payload.py b/services/vpn/src/stackit/vpn/models/update_vpn_gateway_payload.py index 25a1420a0..be9139dc9 100644 --- a/services/vpn/src/stackit/vpn/models/update_vpn_gateway_payload.py +++ b/services/vpn/src/stackit/vpn/models/update_vpn_gateway_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.vpn.models.bgp_gateway_config import BGPGatewayConfig @@ -49,12 +50,16 @@ class UpdateVPNGatewayPayload(BaseModel): @field_validator("display_name") def display_name_validate_regular_expression(cls, value): """Validates the regular expression""" + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$", value): raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -65,8 +70,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/vpn/src/stackit/vpn/models/vpn_tunnels.py b/services/vpn/src/stackit/vpn/models/vpn_tunnels.py index 6b49121d5..9b9028e09 100644 --- a/services/vpn/src/stackit/vpn/models/vpn_tunnels.py +++ b/services/vpn/src/stackit/vpn/models/vpn_tunnels.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self from stackit.vpn.models.bgp_status import BGPStatus @@ -48,7 +49,8 @@ def name_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -59,8 +61,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: