From 10551d958891250b3a6463bffbe4d8b883504799 Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Tue, 12 May 2026 12:38:49 +0000 Subject: [PATCH] Generate certificates --- services/certificates/oas_commit | 2 +- .../src/stackit/certificates/api_client.py | 32 +++++++++---------- .../certificates/models/certificates_quota.py | 7 ++-- .../models/create_certificate_payload.py | 23 ++++++++++--- .../models/get_certificate_response.py | 20 +++++++++--- .../certificates/models/get_quota_response.py | 13 ++++++-- .../models/google_protobuf_any.py | 7 ++-- .../models/list_certificates_response.py | 10 ++++-- .../src/stackit/certificates/models/quotas.py | 7 ++-- .../src/stackit/certificates/models/status.py | 7 ++-- 10 files changed, 84 insertions(+), 44 deletions(-) diff --git a/services/certificates/oas_commit b/services/certificates/oas_commit index 36076afe8..f4a2ce25c 100644 --- a/services/certificates/oas_commit +++ b/services/certificates/oas_commit @@ -1 +1 @@ -87a3ad63dec0a953ff5c6072ad9a15fddd8ec5f8 +8f43ed707da765654e4427642c9d978f80d504e1 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..8bbfb486d 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 @@ -28,6 +29,10 @@ class CreateCertificatePayload(BaseModel): Uploads a PEM encoded X509 public/private key pair """ # noqa: E501 + labels: Optional[Dict[str, StrictStr]] = Field( + default=None, + description="Labels represent user-defined metadata as key-value pairs. Label count should not exceed 64 per Certificate. **Key Formatting Rules:** Length: 1-63 characters. Characters: Must begin and end with [a-zA-Z0-9]. May contain dashes (-), underscores (_), dots (.), and alphanumerics in between. Keys starting with 'stackit-' are system-reserved; users MUST NOT manage them. **Value Formatting Rules:** Length: 0-63 characters (empty string explicitly allowed). Characters (for non-empty values): Must begin and end with [a-zA-Z0-9]. May contain dashes (-), underscores (_), dots (.), and alphanumerics in between. ", + ) name: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="TLS certificate name") private_key: Optional[StrictStr] = Field( default=None, description="The PEM encoded private key part", alias="privateKey" @@ -37,7 +42,7 @@ class CreateCertificatePayload(BaseModel): default=None, description="The PEM encoded public key part", alias="publicKey" ) region: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="Region") - __properties: ClassVar[List[str]] = ["name", "privateKey", "projectId", "publicKey", "region"] + __properties: ClassVar[List[str]] = ["labels", "name", "privateKey", "projectId", "publicKey", "region"] @field_validator("name") def name_validate_regular_expression(cls, value): @@ -45,6 +50,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 +63,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 +78,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 +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]: @@ -128,6 +142,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate( { + "labels": obj.get("labels"), "name": obj.get("name"), "privateKey": obj.get("privateKey"), "projectId": obj.get("projectId"), 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..9ba9b4239 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 @@ -28,12 +29,16 @@ class GetCertificateResponse(BaseModel): """ # noqa: E501 id: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="The certificates resource id") + labels: Optional[Dict[str, StrictStr]] = Field( + default=None, + description="Labels represent user-defined metadata as key-value pairs. Label count should not exceed 64 per Certificate. **Key Formatting Rules:** Length: 1-63 characters. Characters: Must begin and end with [a-zA-Z0-9]. May contain dashes (-), underscores (_), dots (.), and alphanumerics in between. Keys starting with 'stackit-' are system-reserved; users MUST NOT manage them. **Value Formatting Rules:** Length: 0-63 characters (empty string explicitly allowed). Characters (for non-empty values): Must begin and end with [a-zA-Z0-9]. May contain dashes (-), underscores (_), dots (.), and alphanumerics in between. ", + ) name: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="TLS certificate name") public_key: Optional[StrictStr] = Field( default=None, description="The PEM encoded public key part", alias="publicKey" ) region: Optional[StrictStr] = Field(default=None, description="Region of the LoadBalancer") - __properties: ClassVar[List[str]] = ["id", "name", "publicKey", "region"] + __properties: ClassVar[List[str]] = ["id", "labels", "name", "publicKey", "region"] @field_validator("id") def id_validate_regular_expression(cls, value): @@ -41,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-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 +59,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 +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]: @@ -106,6 +117,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate( { "id": obj.get("id"), + "labels": obj.get("labels"), "name": obj.get("name"), "publicKey": obj.get("publicKey"), "region": obj.get("region"), 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]: