From 3ce651d58c1d0e374d7e9772b553f05131e76dd8 Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Thu, 30 Jul 2026 09:38:55 +0000 Subject: [PATCH] Generate cdn --- services/cdn/oas_commit | 2 +- services/cdn/src/stackit/cdn/__init__.py | 10 ++ .../cdn/src/stackit/cdn/models/__init__.py | 5 + .../src/stackit/cdn/models/bucket_backend.py | 22 ++- .../cdn/models/bucket_backend_create.py | 22 ++- .../cdn/models/bucket_backend_patch.py | 24 ++- services/cdn/src/stackit/cdn/models/config.py | 6 +- .../src/stackit/cdn/models/config_log_sink.py | 135 +++++++++++++++++ .../src/stackit/cdn/models/config_patch.py | 6 +- .../cdn/models/config_patch_log_sink.py | 141 ++++++++++++++++++ .../cdn/models/create_distribution_payload.py | 12 +- .../create_distribution_payload_log_sink.py | 135 +++++++++++++++++ .../src/stackit/cdn/models/http_backend.py | 13 +- .../stackit/cdn/models/http_backend_create.py | 13 +- .../stackit/cdn/models/http_backend_patch.py | 19 ++- .../src/stackit/cdn/models/loki_log_sink.py | 16 +- .../cdn/models/loki_log_sink_create.py | 18 ++- .../cdn/models/loki_log_sink_credentials.py | 8 +- .../stackit/cdn/models/loki_log_sink_patch.py | 19 ++- 19 files changed, 584 insertions(+), 42 deletions(-) create mode 100644 services/cdn/src/stackit/cdn/models/config_log_sink.py create mode 100644 services/cdn/src/stackit/cdn/models/config_patch_log_sink.py create mode 100644 services/cdn/src/stackit/cdn/models/create_distribution_payload_log_sink.py diff --git a/services/cdn/oas_commit b/services/cdn/oas_commit index 4b79dc0b4..baa9d7609 100644 --- a/services/cdn/oas_commit +++ b/services/cdn/oas_commit @@ -1 +1 @@ -bda6ad3d9e8850526f25eddcb6589fcc7559c625 +166aed4c740698347e3e1c71e69341f77ebd7abb diff --git a/services/cdn/src/stackit/cdn/__init__.py b/services/cdn/src/stackit/cdn/__init__.py index f426f9aa4..108ff0ac8 100644 --- a/services/cdn/src/stackit/cdn/__init__.py +++ b/services/cdn/src/stackit/cdn/__init__.py @@ -33,10 +33,13 @@ "BucketCredentials", "Config", "ConfigBackend", + "ConfigLogSink", "ConfigPatch", "ConfigPatchBackend", + "ConfigPatchLogSink", "CreateDistributionPayload", "CreateDistributionPayloadBackend", + "CreateDistributionPayloadLogSink", "CreateDistributionResponse", "CustomDomain", "DeleteCustomDomainResponse", @@ -137,16 +140,23 @@ from stackit.cdn.models.bucket_credentials import BucketCredentials as BucketCredentials from stackit.cdn.models.config import Config as Config from stackit.cdn.models.config_backend import ConfigBackend as ConfigBackend +from stackit.cdn.models.config_log_sink import ConfigLogSink as ConfigLogSink from stackit.cdn.models.config_patch import ConfigPatch as ConfigPatch from stackit.cdn.models.config_patch_backend import ( ConfigPatchBackend as ConfigPatchBackend, ) +from stackit.cdn.models.config_patch_log_sink import ( + ConfigPatchLogSink as ConfigPatchLogSink, +) from stackit.cdn.models.create_distribution_payload import ( CreateDistributionPayload as CreateDistributionPayload, ) from stackit.cdn.models.create_distribution_payload_backend import ( CreateDistributionPayloadBackend as CreateDistributionPayloadBackend, ) +from stackit.cdn.models.create_distribution_payload_log_sink import ( + CreateDistributionPayloadLogSink as CreateDistributionPayloadLogSink, +) from stackit.cdn.models.create_distribution_response import ( CreateDistributionResponse as CreateDistributionResponse, ) diff --git a/services/cdn/src/stackit/cdn/models/__init__.py b/services/cdn/src/stackit/cdn/models/__init__.py index dc257362a..e8ebfe4cb 100644 --- a/services/cdn/src/stackit/cdn/models/__init__.py +++ b/services/cdn/src/stackit/cdn/models/__init__.py @@ -19,12 +19,17 @@ from stackit.cdn.models.bucket_credentials import BucketCredentials from stackit.cdn.models.config import Config from stackit.cdn.models.config_backend import ConfigBackend +from stackit.cdn.models.config_log_sink import ConfigLogSink from stackit.cdn.models.config_patch import ConfigPatch from stackit.cdn.models.config_patch_backend import ConfigPatchBackend +from stackit.cdn.models.config_patch_log_sink import ConfigPatchLogSink from stackit.cdn.models.create_distribution_payload import CreateDistributionPayload from stackit.cdn.models.create_distribution_payload_backend import ( CreateDistributionPayloadBackend, ) +from stackit.cdn.models.create_distribution_payload_log_sink import ( + CreateDistributionPayloadLogSink, +) from stackit.cdn.models.create_distribution_response import CreateDistributionResponse from stackit.cdn.models.custom_domain import CustomDomain from stackit.cdn.models.delete_custom_domain_response import DeleteCustomDomainResponse diff --git a/services/cdn/src/stackit/cdn/models/bucket_backend.py b/services/cdn/src/stackit/cdn/models/bucket_backend.py index 03217a281..69abfba38 100644 --- a/services/cdn/src/stackit/cdn/models/bucket_backend.py +++ b/services/cdn/src/stackit/cdn/models/bucket_backend.py @@ -17,7 +17,7 @@ import pprint from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -27,11 +27,25 @@ class BucketBackend(BaseModel): BucketBackend """ # noqa: E501 - bucket_url: StrictStr = Field(alias="bucketUrl") - region: StrictStr - type: StrictStr + bucket_url: StrictStr = Field( + description="The fully qualified URL of your cloud storage bucket (for example, `https://s3.eu-central-1.amazonaws.com/my-bucket`).", + alias="bucketUrl", + ) + region: StrictStr = Field( + description="The cloud provider region where your storage bucket is located (for example, `us-west-1` for AWS or `eu01` for STACKIT)." + ) + type: StrictStr = Field( + description="Defines the type of content origin. For this schema, it must be set to `bucket`." + ) __properties: ClassVar[List[str]] = ["bucketUrl", "region", "type"] + @field_validator("type") + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["bucket"]): + raise ValueError("must be one of enum values ('bucket')") + return value + model_config = ConfigDict( validate_by_name=True, validate_by_alias=True, 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 07192e025..50d7a00ce 100644 --- a/services/cdn/src/stackit/cdn/models/bucket_backend_create.py +++ b/services/cdn/src/stackit/cdn/models/bucket_backend_create.py @@ -17,7 +17,7 @@ import pprint from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -29,12 +29,26 @@ class BucketBackendCreate(BaseModel): BucketBackendCreate """ # noqa: E501 - bucket_url: StrictStr = Field(alias="bucketUrl") + bucket_url: StrictStr = Field( + description="The fully qualified URL of your cloud storage bucket (for example, `https://s3.eu-central-1.amazonaws.com/my-bucket`).", + alias="bucketUrl", + ) credentials: BucketCredentials - region: StrictStr - type: StrictStr + region: StrictStr = Field( + description="The cloud provider region where your storage bucket is located (for example, `us-west-1` for AWS or `eu01` for STACKIT)." + ) + type: StrictStr = Field( + description="Defines the type of content origin. For this schema, it must be set to `bucket`." + ) __properties: ClassVar[List[str]] = ["bucketUrl", "credentials", "region", "type"] + @field_validator("type") + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["bucket"]): + raise ValueError("must be one of enum values ('bucket')") + return value + model_config = ConfigDict( validate_by_name=True, validate_by_alias=True, 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 9a8304a39..1da643d4f 100644 --- a/services/cdn/src/stackit/cdn/models/bucket_backend_patch.py +++ b/services/cdn/src/stackit/cdn/models/bucket_backend_patch.py @@ -17,7 +17,7 @@ import pprint from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -29,12 +29,28 @@ class BucketBackendPatch(BaseModel): BucketBackendPatch """ # noqa: E501 - bucket_url: Optional[StrictStr] = Field(default=None, alias="bucketUrl") + bucket_url: Optional[StrictStr] = Field( + default=None, + description="The fully qualified URL of your cloud storage bucket (for example, `https://s3.eu-central-1.amazonaws.com/my-bucket`).", + alias="bucketUrl", + ) credentials: Optional[BucketCredentials] = None - region: Optional[StrictStr] = None - type: StrictStr + region: Optional[StrictStr] = Field( + default=None, + description="The cloud provider region where your storage bucket is located (for example, `us-west-1` for AWS or `eu01` for STACKIT).", + ) + type: StrictStr = Field( + description="Defines the type of content origin. For this schema, it must be set to `bucket`." + ) __properties: ClassVar[List[str]] = ["bucketUrl", "credentials", "region", "type"] + @field_validator("type") + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["bucket"]): + raise ValueError("must be one of enum values ('bucket')") + return value + model_config = ConfigDict( validate_by_name=True, validate_by_alias=True, diff --git a/services/cdn/src/stackit/cdn/models/config.py b/services/cdn/src/stackit/cdn/models/config.py index eed3c38b8..78d3d9839 100644 --- a/services/cdn/src/stackit/cdn/models/config.py +++ b/services/cdn/src/stackit/cdn/models/config.py @@ -28,7 +28,7 @@ from typing_extensions import Annotated, Self from stackit.cdn.models.config_backend import ConfigBackend -from stackit.cdn.models.loki_log_sink import LokiLogSink +from stackit.cdn.models.config_log_sink import ConfigLogSink from stackit.cdn.models.optimizer import Optimizer from stackit.cdn.models.redirect_config import RedirectConfig from stackit.cdn.models.region import Region @@ -59,7 +59,7 @@ class Config(BaseModel): description="Enabling this allows the 'Host' header to be passed through to the origin. ", alias="forwardHostHeader", ) - log_sink: Optional[LokiLogSink] = Field(default=None, alias="logSink") + log_sink: Optional[ConfigLogSink] = Field(default=None, alias="logSink") monthly_limit_bytes: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field( default=None, description="Sets the monthly limit of bandwidth in bytes that the pullzone is allowed to use. ", @@ -173,7 +173,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "blockedIps": obj.get("blockedIps"), "defaultCacheDuration": obj.get("defaultCacheDuration"), "forwardHostHeader": obj.get("forwardHostHeader"), - "logSink": LokiLogSink.from_dict(obj["logSink"]) if obj.get("logSink") is not None else None, + "logSink": ConfigLogSink.from_dict(obj["logSink"]) if obj.get("logSink") is not None else None, "monthlyLimitBytes": obj.get("monthlyLimitBytes"), "optimizer": Optimizer.from_dict(obj["optimizer"]) if obj.get("optimizer") is not None else None, "redirects": RedirectConfig.from_dict(obj["redirects"]) if obj.get("redirects") is not None else None, diff --git a/services/cdn/src/stackit/cdn/models/config_log_sink.py b/services/cdn/src/stackit/cdn/models/config_log_sink.py new file mode 100644 index 000000000..20a96a416 --- /dev/null +++ b/services/cdn/src/stackit/cdn/models/config_log_sink.py @@ -0,0 +1,135 @@ +# coding: utf-8 + +""" +STACKIT CDN API + +API used to create and manage your CDN distributions. + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +from typing import Any, Dict, Optional, Set, Union + +from pydantic import ( + BaseModel, + ConfigDict, + ValidationError, + field_validator, +) +from typing_extensions import Self + +from stackit.cdn.models.loki_log_sink import LokiLogSink + +CONFIGLOGSINK_ONE_OF_SCHEMAS = ["LokiLogSink"] + + +class ConfigLogSink(BaseModel): + """ + ConfigLogSink + """ + + # data type: LokiLogSink + oneof_schema_1_validator: Optional[LokiLogSink] = None + actual_instance: Optional[Union[LokiLogSink]] = None + one_of_schemas: Set[str] = {"LokiLogSink"} + + model_config = ConfigDict( + validate_assignment=True, + protected_namespaces=(), + ) + + discriminator_value_class_map: Dict[str, str] = {} + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator("actual_instance") + def actual_instance_must_validate_oneof(cls, v): + instance = ConfigLogSink.model_construct() + error_messages = [] + match = 0 + # validate data type: LokiLogSink + if not isinstance(v, LokiLogSink): + error_messages.append(f"Error! Input type `{type(v)}` is not `LokiLogSink`") + else: + match += 1 + if match == 0: + # no match + raise ValueError( + "No match found when setting `actual_instance` in ConfigLogSink with oneOf schemas: LokiLogSink. Details: " + + ", ".join(error_messages) + ) + else: + return v + + @classmethod + def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + error_messages = [] + match = 0 + + # deserialize data into LokiLogSink + try: + instance.actual_instance = LokiLogSink.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when deserializing the JSON string into ConfigLogSink with oneOf schemas: LokiLogSink. Details: " + + ", ".join(error_messages) + ) + elif match == 0: + # no match + raise ValueError( + "No match found when deserializing the JSON string into ConfigLogSink with oneOf schemas: LokiLogSink. Details: " + + ", ".join(error_messages) + ) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> Optional[Union[Dict[str, Any], LokiLogSink]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): + return self.actual_instance.to_dict() + else: + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.model_dump()) diff --git a/services/cdn/src/stackit/cdn/models/config_patch.py b/services/cdn/src/stackit/cdn/models/config_patch.py index 1f9fd9144..f973f9c20 100644 --- a/services/cdn/src/stackit/cdn/models/config_patch.py +++ b/services/cdn/src/stackit/cdn/models/config_patch.py @@ -28,7 +28,7 @@ from typing_extensions import Annotated, Self from stackit.cdn.models.config_patch_backend import ConfigPatchBackend -from stackit.cdn.models.loki_log_sink_patch import LokiLogSinkPatch +from stackit.cdn.models.config_patch_log_sink import ConfigPatchLogSink from stackit.cdn.models.optimizer_patch import OptimizerPatch from stackit.cdn.models.redirect_config import RedirectConfig from stackit.cdn.models.region import Region @@ -62,7 +62,7 @@ class ConfigPatch(BaseModel): description="Enabling this allows the 'Host' header to be passed through to the origin. ", alias="forwardHostHeader", ) - log_sink: Optional[LokiLogSinkPatch] = Field(default=None, alias="logSink") + log_sink: Optional[ConfigPatchLogSink] = Field(default=None, alias="logSink") monthly_limit_bytes: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field( default=None, description="Sets the monthly limit of bandwidth in bytes that the pullzone is allowed to use. ", @@ -182,7 +182,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "blockedIps": obj.get("blockedIps"), "defaultCacheDuration": obj.get("defaultCacheDuration"), "forwardHostHeader": obj.get("forwardHostHeader"), - "logSink": LokiLogSinkPatch.from_dict(obj["logSink"]) if obj.get("logSink") is not None else None, + "logSink": ConfigPatchLogSink.from_dict(obj["logSink"]) if obj.get("logSink") is not None else None, "monthlyLimitBytes": obj.get("monthlyLimitBytes"), "optimizer": OptimizerPatch.from_dict(obj["optimizer"]) if obj.get("optimizer") is not None else None, "redirects": RedirectConfig.from_dict(obj["redirects"]) if obj.get("redirects") is not None else None, diff --git a/services/cdn/src/stackit/cdn/models/config_patch_log_sink.py b/services/cdn/src/stackit/cdn/models/config_patch_log_sink.py new file mode 100644 index 000000000..67c0bf767 --- /dev/null +++ b/services/cdn/src/stackit/cdn/models/config_patch_log_sink.py @@ -0,0 +1,141 @@ +# coding: utf-8 + +""" +STACKIT CDN API + +API used to create and manage your CDN distributions. + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +from typing import Any, Dict, Optional, Set, Union + +from pydantic import ( + BaseModel, + ConfigDict, + ValidationError, + field_validator, +) +from typing_extensions import Self + +from stackit.cdn.models.loki_log_sink_patch import LokiLogSinkPatch + +CONFIGPATCHLOGSINK_ONE_OF_SCHEMAS = ["LokiLogSinkPatch"] + + +class ConfigPatchLogSink(BaseModel): + """ + ConfigPatchLogSink + """ + + # data type: LokiLogSinkPatch + oneof_schema_1_validator: Optional[LokiLogSinkPatch] = None + actual_instance: Optional[Union[LokiLogSinkPatch]] = None + one_of_schemas: Set[str] = {"LokiLogSinkPatch"} + + model_config = ConfigDict( + validate_assignment=True, + protected_namespaces=(), + ) + + discriminator_value_class_map: Dict[str, str] = {} + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator("actual_instance") + def actual_instance_must_validate_oneof(cls, v): + if v is None: + return v + + instance = ConfigPatchLogSink.model_construct() + error_messages = [] + match = 0 + # validate data type: LokiLogSinkPatch + if not isinstance(v, LokiLogSinkPatch): + error_messages.append(f"Error! Input type `{type(v)}` is not `LokiLogSinkPatch`") + else: + match += 1 + if match == 0: + # no match + raise ValueError( + "No match found when setting `actual_instance` in ConfigPatchLogSink with oneOf schemas: LokiLogSinkPatch. Details: " + + ", ".join(error_messages) + ) + else: + return v + + @classmethod + def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: Optional[str]) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + if json_str is None: + return instance + + error_messages = [] + match = 0 + + # deserialize data into LokiLogSinkPatch + try: + instance.actual_instance = LokiLogSinkPatch.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when deserializing the JSON string into ConfigPatchLogSink with oneOf schemas: LokiLogSinkPatch. Details: " + + ", ".join(error_messages) + ) + elif match == 0: + # no match + raise ValueError( + "No match found when deserializing the JSON string into ConfigPatchLogSink with oneOf schemas: LokiLogSinkPatch. Details: " + + ", ".join(error_messages) + ) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> Optional[Union[Dict[str, Any], LokiLogSinkPatch]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): + return self.actual_instance.to_dict() + else: + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.model_dump()) 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 89c6e04e6..bf2c4ef41 100644 --- a/services/cdn/src/stackit/cdn/models/create_distribution_payload.py +++ b/services/cdn/src/stackit/cdn/models/create_distribution_payload.py @@ -30,7 +30,9 @@ from stackit.cdn.models.create_distribution_payload_backend import ( CreateDistributionPayloadBackend, ) -from stackit.cdn.models.loki_log_sink_create import LokiLogSinkCreate +from stackit.cdn.models.create_distribution_payload_log_sink import ( + CreateDistributionPayloadLogSink, +) from stackit.cdn.models.optimizer import Optimizer from stackit.cdn.models.redirect_config import RedirectConfig from stackit.cdn.models.region import Region @@ -69,7 +71,7 @@ class CreateDistributionPayload(BaseModel): description="While optional, it is greatly encouraged to provide an `intentId`. This is used to deduplicate requests. If multiple POST-Requests with the same `intentId` for a given `projectId` are received, all but the first request are dropped. ", alias="intentId", ) - log_sink: Optional[LokiLogSinkCreate] = Field(default=None, alias="logSink") + log_sink: Optional[CreateDistributionPayloadLogSink] = Field(default=None, alias="logSink") monthly_limit_bytes: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field( default=None, description="Sets the monthly limit of bandwidth in bytes that the pullzone is allowed to use. ", @@ -182,7 +184,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "defaultCacheDuration": obj.get("defaultCacheDuration"), "forwardHostHeader": obj.get("forwardHostHeader"), "intentId": obj.get("intentId"), - "logSink": LokiLogSinkCreate.from_dict(obj["logSink"]) if obj.get("logSink") is not None else None, + "logSink": ( + CreateDistributionPayloadLogSink.from_dict(obj["logSink"]) + if obj.get("logSink") is not None + else None + ), "monthlyLimitBytes": obj.get("monthlyLimitBytes"), "optimizer": Optimizer.from_dict(obj["optimizer"]) if obj.get("optimizer") is not None else None, "redirects": RedirectConfig.from_dict(obj["redirects"]) if obj.get("redirects") is not None else None, diff --git a/services/cdn/src/stackit/cdn/models/create_distribution_payload_log_sink.py b/services/cdn/src/stackit/cdn/models/create_distribution_payload_log_sink.py new file mode 100644 index 000000000..1d8e67fc6 --- /dev/null +++ b/services/cdn/src/stackit/cdn/models/create_distribution_payload_log_sink.py @@ -0,0 +1,135 @@ +# coding: utf-8 + +""" +STACKIT CDN API + +API used to create and manage your CDN distributions. + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +from typing import Any, Dict, Optional, Set, Union + +from pydantic import ( + BaseModel, + ConfigDict, + ValidationError, + field_validator, +) +from typing_extensions import Self + +from stackit.cdn.models.loki_log_sink_create import LokiLogSinkCreate + +CREATEDISTRIBUTIONPAYLOADLOGSINK_ONE_OF_SCHEMAS = ["LokiLogSinkCreate"] + + +class CreateDistributionPayloadLogSink(BaseModel): + """ + CreateDistributionPayloadLogSink + """ + + # data type: LokiLogSinkCreate + oneof_schema_1_validator: Optional[LokiLogSinkCreate] = None + actual_instance: Optional[Union[LokiLogSinkCreate]] = None + one_of_schemas: Set[str] = {"LokiLogSinkCreate"} + + model_config = ConfigDict( + validate_assignment=True, + protected_namespaces=(), + ) + + discriminator_value_class_map: Dict[str, str] = {} + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator("actual_instance") + def actual_instance_must_validate_oneof(cls, v): + instance = CreateDistributionPayloadLogSink.model_construct() + error_messages = [] + match = 0 + # validate data type: LokiLogSinkCreate + if not isinstance(v, LokiLogSinkCreate): + error_messages.append(f"Error! Input type `{type(v)}` is not `LokiLogSinkCreate`") + else: + match += 1 + if match == 0: + # no match + raise ValueError( + "No match found when setting `actual_instance` in CreateDistributionPayloadLogSink with oneOf schemas: LokiLogSinkCreate. Details: " + + ", ".join(error_messages) + ) + else: + return v + + @classmethod + def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + error_messages = [] + match = 0 + + # deserialize data into LokiLogSinkCreate + try: + instance.actual_instance = LokiLogSinkCreate.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when deserializing the JSON string into CreateDistributionPayloadLogSink with oneOf schemas: LokiLogSinkCreate. Details: " + + ", ".join(error_messages) + ) + elif match == 0: + # no match + raise ValueError( + "No match found when deserializing the JSON string into CreateDistributionPayloadLogSink with oneOf schemas: LokiLogSinkCreate. Details: " + + ", ".join(error_messages) + ) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> Optional[Union[Dict[str, Any], LokiLogSinkCreate]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): + return self.actual_instance.to_dict() + else: + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.model_dump()) diff --git a/services/cdn/src/stackit/cdn/models/http_backend.py b/services/cdn/src/stackit/cdn/models/http_backend.py index 590299cb5..dd4312152 100644 --- a/services/cdn/src/stackit/cdn/models/http_backend.py +++ b/services/cdn/src/stackit/cdn/models/http_backend.py @@ -17,7 +17,7 @@ import pprint from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -38,9 +38,18 @@ class HttpBackend(BaseModel): description="The origin of the content that should be made available through the CDN. Note that the path and query parameters are ignored. Ports are allowed. If no protocol is provided, `https` is assumed. So `www.example.com:1234/somePath?q=123` is normalized to `https://www.example.com:1234` ", alias="originUrl", ) - type: StrictStr + type: StrictStr = Field( + description="Defines the type of content origin. For this schema, it must be set to `http`." + ) __properties: ClassVar[List[str]] = ["geofencing", "originRequestHeaders", "originUrl", "type"] + @field_validator("type") + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["http"]): + raise ValueError("must be one of enum values ('http')") + return value + model_config = ConfigDict( validate_by_name=True, validate_by_alias=True, 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 ea10bf10e..0af37a6e3 100644 --- a/services/cdn/src/stackit/cdn/models/http_backend_create.py +++ b/services/cdn/src/stackit/cdn/models/http_backend_create.py @@ -17,7 +17,7 @@ import pprint from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -40,9 +40,18 @@ class HttpBackendCreate(BaseModel): description="The origin of the content that should be made available through the CDN. Note that the path and query parameters are ignored. Ports are allowed. If no protocol is provided, `https` is assumed. So `www.example.com:1234/somePath?q=123` is normalized to `https://www.example.com:1234` ", alias="originUrl", ) - type: StrictStr + type: StrictStr = Field( + description="Defines the type of content origin. For this schema, it must be set to `http`." + ) __properties: ClassVar[List[str]] = ["geofencing", "originRequestHeaders", "originUrl", "type"] + @field_validator("type") + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["http"]): + raise ValueError("must be one of enum values ('http')") + return value + model_config = ConfigDict( validate_by_name=True, validate_by_alias=True, 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 94af3c665..8b27f8f6e 100644 --- a/services/cdn/src/stackit/cdn/models/http_backend_patch.py +++ b/services/cdn/src/stackit/cdn/models/http_backend_patch.py @@ -17,7 +17,7 @@ import pprint from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -36,10 +36,23 @@ class HttpBackendPatch(BaseModel): description="Headers that will be sent with every request to the configured origin. **WARNING**: Do not store sensitive values in the headers. The configuration is stored as plain text. ", alias="originRequestHeaders", ) - origin_url: Optional[StrictStr] = Field(default=None, alias="originUrl") - type: StrictStr = Field(description="This property is required to determine the used backend type.") + origin_url: Optional[StrictStr] = Field( + default=None, + description="The origin of the content that should be made available through the CDN. Note that the path and query parameters are ignored. Ports are allowed. If no protocol is provided, `https` is assumed. So `www.example.com:1234/somePath?q=123` is normalized to `https://www.example.com:1234` ", + alias="originUrl", + ) + type: StrictStr = Field( + description="Defines the type of content origin. For this schema, it must be set to `http`." + ) __properties: ClassVar[List[str]] = ["geofencing", "originRequestHeaders", "originUrl", "type"] + @field_validator("type") + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["http"]): + raise ValueError("must be one of enum values ('http')") + return value + model_config = ConfigDict( validate_by_name=True, validate_by_alias=True, 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 22efdbb9b..9d8e414ec 100644 --- a/services/cdn/src/stackit/cdn/models/loki_log_sink.py +++ b/services/cdn/src/stackit/cdn/models/loki_log_sink.py @@ -17,7 +17,7 @@ import pprint from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -27,10 +27,20 @@ class LokiLogSink(BaseModel): LokiLogSink """ # noqa: E501 - push_url: StrictStr = Field(alias="pushUrl") - type: StrictStr + push_url: StrictStr = Field( + description="The fully qualified URL where the CDN should push logs to your Loki instance (for example, `https://loki.example.com/loki/api/v1/push`).", + alias="pushUrl", + ) + type: StrictStr = Field(description="Defines the type of the log sink.") __properties: ClassVar[List[str]] = ["pushUrl", "type"] + @field_validator("type") + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["loki"]): + raise ValueError("must be one of enum values ('loki')") + return value + model_config = ConfigDict( validate_by_name=True, validate_by_alias=True, 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 6c1c1dc98..bdaf90af6 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 @@ -17,7 +17,7 @@ import pprint from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,10 +30,22 @@ class LokiLogSinkCreate(BaseModel): """ # noqa: E501 credentials: LokiLogSinkCredentials - push_url: StrictStr = Field(alias="pushUrl") - type: StrictStr + push_url: StrictStr = Field( + description="The fully qualified URL where the CDN should push logs to your Loki instance (for example, `https://loki.example.com/loki/api/v1/push`).", + alias="pushUrl", + ) + type: StrictStr = Field( + description="Defines the type of the log sink. For Grafana Loki, this must be set to `loki`." + ) __properties: ClassVar[List[str]] = ["credentials", "pushUrl", "type"] + @field_validator("type") + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["loki"]): + raise ValueError("must be one of enum values ('loki')") + return value + model_config = ConfigDict( validate_by_name=True, validate_by_alias=True, 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 0520c1f73..ebdce87c9 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 @@ -17,18 +17,18 @@ import pprint from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictStr from pydantic_core import to_jsonable_python from typing_extensions import Self class LokiLogSinkCredentials(BaseModel): """ - LokiLogSinkCredentials + The authentication credentials required for the CDN to push logs to your Loki instance. """ # noqa: E501 - password: StrictStr - username: StrictStr + password: StrictStr = Field(description="The password corresponding to your username.") + username: StrictStr = Field(description="The username used to authenticate against your Loki instance.") __properties: ClassVar[List[str]] = ["password", "username"] model_config = ConfigDict( 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 97fcb2b69..6679af9fc 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 @@ -17,7 +17,7 @@ import pprint from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -30,10 +30,23 @@ class LokiLogSinkPatch(BaseModel): """ # noqa: E501 credentials: Optional[LokiLogSinkCredentials] = None - push_url: Optional[StrictStr] = Field(default=None, alias="pushUrl") - type: StrictStr + push_url: Optional[StrictStr] = Field( + default=None, + description="The fully qualified URL where the CDN should push logs to your Loki instance (for example, `https://loki.example.com/loki/api/v1/push`).", + alias="pushUrl", + ) + type: StrictStr = Field( + description="Defines the type of the log sink. For Grafana Loki, this must be set to `loki`." + ) __properties: ClassVar[List[str]] = ["credentials", "pushUrl", "type"] + @field_validator("type") + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["loki"]): + raise ValueError("must be one of enum values ('loki')") + return value + model_config = ConfigDict( validate_by_name=True, validate_by_alias=True,