From 7b5a11285e221925d745ed9240af4313fa621633 Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Mon, 7 Sep 2026 13:34:33 +0000 Subject: [PATCH] Generate cdn --- services/cdn/oas_commit | 2 +- services/cdn/src/stackit/cdn/__init__.py | 32 ++++ .../cdn/src/stackit/cdn/models/__init__.py | 18 +++ .../src/stackit/cdn/models/cache_config.py | 99 ++++++++++++ .../stackit/cdn/models/cache_config_create.py | 104 ++++++++++++ .../stackit/cdn/models/cache_config_patch.py | 102 ++++++++++++ services/cdn/src/stackit/cdn/models/config.py | 9 ++ .../src/stackit/cdn/models/config_log_sink.py | 28 +++- .../src/stackit/cdn/models/config_patch.py | 9 ++ .../cdn/models/config_patch_log_sink.py | 28 +++- .../cdn/models/create_distribution_payload.py | 9 ++ .../create_distribution_payload_log_sink.py | 28 +++- .../src/stackit/cdn/models/otlp_log_sink.py | 93 +++++++++++ .../models/otlp_log_sink_basic_credentials.py | 93 +++++++++++ .../otlp_log_sink_bearer_credentials.py | 90 +++++++++++ .../cdn/models/otlp_log_sink_create.py | 111 +++++++++++++ .../otlp_log_sink_create_credentials.py | 153 ++++++++++++++++++ .../stackit/cdn/models/otlp_log_sink_patch.py | 112 +++++++++++++ .../models/otlp_log_sink_patch_credentials.py | 153 ++++++++++++++++++ 19 files changed, 1251 insertions(+), 22 deletions(-) create mode 100644 services/cdn/src/stackit/cdn/models/cache_config.py create mode 100644 services/cdn/src/stackit/cdn/models/cache_config_create.py create mode 100644 services/cdn/src/stackit/cdn/models/cache_config_patch.py create mode 100644 services/cdn/src/stackit/cdn/models/otlp_log_sink.py create mode 100644 services/cdn/src/stackit/cdn/models/otlp_log_sink_basic_credentials.py create mode 100644 services/cdn/src/stackit/cdn/models/otlp_log_sink_bearer_credentials.py create mode 100644 services/cdn/src/stackit/cdn/models/otlp_log_sink_create.py create mode 100644 services/cdn/src/stackit/cdn/models/otlp_log_sink_create_credentials.py create mode 100644 services/cdn/src/stackit/cdn/models/otlp_log_sink_patch.py create mode 100644 services/cdn/src/stackit/cdn/models/otlp_log_sink_patch_credentials.py diff --git a/services/cdn/oas_commit b/services/cdn/oas_commit index ec6f0b9d6..d5d15003c 100644 --- a/services/cdn/oas_commit +++ b/services/cdn/oas_commit @@ -1 +1 @@ -b7d1b614138d667d378a5fd45e2a91539a7fb02e +f385f3b154cb566b3c9e5156c29b28150f2af4a2 diff --git a/services/cdn/src/stackit/cdn/__init__.py b/services/cdn/src/stackit/cdn/__init__.py index 108ff0ac8..4931309a1 100644 --- a/services/cdn/src/stackit/cdn/__init__.py +++ b/services/cdn/src/stackit/cdn/__init__.py @@ -31,6 +31,9 @@ "BucketBackendCreate", "BucketBackendPatch", "BucketCredentials", + "CacheConfig", + "CacheConfigCreate", + "CacheConfigPatch", "Config", "ConfigBackend", "ConfigLogSink", @@ -81,6 +84,13 @@ "Matcher", "Optimizer", "OptimizerPatch", + "OtlpLogSink", + "OtlpLogSinkBasicCredentials", + "OtlpLogSinkBearerCredentials", + "OtlpLogSinkCreate", + "OtlpLogSinkCreateCredentials", + "OtlpLogSinkPatch", + "OtlpLogSinkPatchCredentials", "PatchDistributionPayload", "PatchDistributionResponse", "PurgeCachePayload", @@ -138,6 +148,11 @@ BucketBackendPatch as BucketBackendPatch, ) from stackit.cdn.models.bucket_credentials import BucketCredentials as BucketCredentials +from stackit.cdn.models.cache_config import CacheConfig as CacheConfig +from stackit.cdn.models.cache_config_create import ( + CacheConfigCreate as CacheConfigCreate, +) +from stackit.cdn.models.cache_config_patch import CacheConfigPatch as CacheConfigPatch 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 @@ -250,6 +265,23 @@ from stackit.cdn.models.matcher import Matcher as Matcher from stackit.cdn.models.optimizer import Optimizer as Optimizer from stackit.cdn.models.optimizer_patch import OptimizerPatch as OptimizerPatch +from stackit.cdn.models.otlp_log_sink import OtlpLogSink as OtlpLogSink +from stackit.cdn.models.otlp_log_sink_basic_credentials import ( + OtlpLogSinkBasicCredentials as OtlpLogSinkBasicCredentials, +) +from stackit.cdn.models.otlp_log_sink_bearer_credentials import ( + OtlpLogSinkBearerCredentials as OtlpLogSinkBearerCredentials, +) +from stackit.cdn.models.otlp_log_sink_create import ( + OtlpLogSinkCreate as OtlpLogSinkCreate, +) +from stackit.cdn.models.otlp_log_sink_create_credentials import ( + OtlpLogSinkCreateCredentials as OtlpLogSinkCreateCredentials, +) +from stackit.cdn.models.otlp_log_sink_patch import OtlpLogSinkPatch as OtlpLogSinkPatch +from stackit.cdn.models.otlp_log_sink_patch_credentials import ( + OtlpLogSinkPatchCredentials as OtlpLogSinkPatchCredentials, +) from stackit.cdn.models.patch_distribution_payload import ( PatchDistributionPayload as PatchDistributionPayload, ) diff --git a/services/cdn/src/stackit/cdn/models/__init__.py b/services/cdn/src/stackit/cdn/models/__init__.py index e8ebfe4cb..d61505540 100644 --- a/services/cdn/src/stackit/cdn/models/__init__.py +++ b/services/cdn/src/stackit/cdn/models/__init__.py @@ -17,6 +17,9 @@ from stackit.cdn.models.bucket_backend_create import BucketBackendCreate from stackit.cdn.models.bucket_backend_patch import BucketBackendPatch from stackit.cdn.models.bucket_credentials import BucketCredentials +from stackit.cdn.models.cache_config import CacheConfig +from stackit.cdn.models.cache_config_create import CacheConfigCreate +from stackit.cdn.models.cache_config_patch import CacheConfigPatch from stackit.cdn.models.config import Config from stackit.cdn.models.config_backend import ConfigBackend from stackit.cdn.models.config_log_sink import ConfigLogSink @@ -93,6 +96,21 @@ from stackit.cdn.models.matcher import Matcher from stackit.cdn.models.optimizer import Optimizer from stackit.cdn.models.optimizer_patch import OptimizerPatch +from stackit.cdn.models.otlp_log_sink import OtlpLogSink +from stackit.cdn.models.otlp_log_sink_basic_credentials import ( + OtlpLogSinkBasicCredentials, +) +from stackit.cdn.models.otlp_log_sink_bearer_credentials import ( + OtlpLogSinkBearerCredentials, +) +from stackit.cdn.models.otlp_log_sink_create import OtlpLogSinkCreate +from stackit.cdn.models.otlp_log_sink_create_credentials import ( + OtlpLogSinkCreateCredentials, +) +from stackit.cdn.models.otlp_log_sink_patch import OtlpLogSinkPatch +from stackit.cdn.models.otlp_log_sink_patch_credentials import ( + OtlpLogSinkPatchCredentials, +) from stackit.cdn.models.patch_distribution_payload import PatchDistributionPayload from stackit.cdn.models.patch_distribution_response import PatchDistributionResponse from stackit.cdn.models.purge_cache_payload import PurgeCachePayload diff --git a/services/cdn/src/stackit/cdn/models/cache_config.py b/services/cdn/src/stackit/cdn/models/cache_config.py new file mode 100644 index 000000000..9b701040a --- /dev/null +++ b/services/cdn/src/stackit/cdn/models/cache_config.py @@ -0,0 +1,99 @@ +# 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, 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 + + +class CacheConfig(BaseModel): + """ + Groups the cache options that influence how the CDN builds its cache key. **Cache cardinality warning:** enabling query-string vary produces one cache entry per unique query-string combination (**unbounded** when `queryStringVaryParameters` is empty). Each entry in `cacheKeyHeaders` multiplies the number of cache variants by the number of distinct values observed for that header. Use these settings sparingly. `queryStringVaryParameters` is stored independently of `queryStringVaryEnabled` so that this feature can be toggled on and off without losing the configured allowlist. Only `queryStringVaryEnabled` gates whether the parameter allowlist actually varies the cache. **Optimizer interaction:** when the Optimizer is enabled, the CDN automatically enables query-string vary for image responses regardless of this setting. + """ # noqa: E501 + + cache_key_headers: List[Annotated[str, Field(strict=True)]] = Field( + description="HTTP request header names whose values participate in the cache key. Each entry multiplies the number of cache variants by the number of distinct values observed for that header. ", + alias="cacheKeyHeaders", + ) + query_string_vary_enabled: StrictBool = Field( + description="When true, the CDN varies its cache by the request query string. If `queryStringVaryParameters` is empty, every unique query-string combination produces its own cache entry; if non-empty, only the listed parameters influence the cache key. ", + alias="queryStringVaryEnabled", + ) + query_string_vary_parameters: List[Annotated[str, Field(strict=True)]] = Field( + description="Allowlist of query-string parameter names that participate in the cache key when `queryStringVaryEnabled` is true. Ignored while `queryStringVaryEnabled` is false, but still stored so it can be re-activated without losing the list. ", + alias="queryStringVaryParameters", + ) + __properties: ClassVar[List[str]] = ["cacheKeyHeaders", "queryStringVaryEnabled", "queryStringVaryParameters"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CacheConfig from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CacheConfig from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "cacheKeyHeaders": obj.get("cacheKeyHeaders"), + "queryStringVaryEnabled": obj.get("queryStringVaryEnabled"), + "queryStringVaryParameters": obj.get("queryStringVaryParameters"), + } + ) + return _obj diff --git a/services/cdn/src/stackit/cdn/models/cache_config_create.py b/services/cdn/src/stackit/cdn/models/cache_config_create.py new file mode 100644 index 000000000..532e0108e --- /dev/null +++ b/services/cdn/src/stackit/cdn/models/cache_config_create.py @@ -0,0 +1,104 @@ +# 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, 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 + + +class CacheConfigCreate(BaseModel): + """ + Groups the cache options that influence how the CDN builds its cache key on distribution creation. **Cache cardinality warning:** enabling query-string vary produces one cache entry per unique query-string combination (**unbounded** when `queryStringVaryParameters` is empty). Each entry in `cacheKeyHeaders` multiplies the number of cache variants by the number of distinct values observed for that header. Use these settings sparingly. `queryStringVaryParameters` is stored independently of `queryStringVaryEnabled` so that this feature can be toggled on and off without losing the configured allowlist. Only `queryStringVaryEnabled` gates whether the parameter allowlist actually varies the cache. **Optimizer interaction:** when the Optimizer is enabled, the CDN automatically enables query-string vary for image responses regardless of this setting. + """ # noqa: E501 + + cache_key_headers: Optional[List[Annotated[str, Field(strict=True)]]] = Field( + default=None, + description="HTTP request header names whose values participate in the cache key. Each entry multiplies the number of cache variants by the number of distinct values observed for that header. ", + alias="cacheKeyHeaders", + ) + query_string_vary_enabled: Optional[StrictBool] = Field( + default=False, + description="When true, the CDN varies its cache by the request query string. If `queryStringVaryParameters` is empty, every unique query-string combination produces its own cache entry; if non-empty, only the listed parameters influence the cache key. ", + alias="queryStringVaryEnabled", + ) + query_string_vary_parameters: Optional[List[Annotated[str, Field(strict=True)]]] = Field( + default=None, + description="Allowlist of query-string parameter names that participate in the cache key when `queryStringVaryEnabled` is true. Ignored while `queryStringVaryEnabled` is false, but still stored so it can be re-activated without losing the list. ", + alias="queryStringVaryParameters", + ) + __properties: ClassVar[List[str]] = ["cacheKeyHeaders", "queryStringVaryEnabled", "queryStringVaryParameters"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CacheConfigCreate from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CacheConfigCreate from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "cacheKeyHeaders": obj.get("cacheKeyHeaders"), + "queryStringVaryEnabled": ( + obj.get("queryStringVaryEnabled") if obj.get("queryStringVaryEnabled") is not None else False + ), + "queryStringVaryParameters": obj.get("queryStringVaryParameters"), + } + ) + return _obj diff --git a/services/cdn/src/stackit/cdn/models/cache_config_patch.py b/services/cdn/src/stackit/cdn/models/cache_config_patch.py new file mode 100644 index 000000000..e92e71c07 --- /dev/null +++ b/services/cdn/src/stackit/cdn/models/cache_config_patch.py @@ -0,0 +1,102 @@ +# 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, 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 + + +class CacheConfigPatch(BaseModel): + """ + PATCH variant of `CacheConfig`. Follows the standard PATCH conventions for this API: - Field omitted from the request: current value is left unchanged. - Array field sent as `[]`: current list is cleared. - `queryStringVaryEnabled` is a plain boolean (non-nullable); omit it to leave unchanged. `queryStringVaryParameters` is stored independently of `queryStringVaryEnabled`. Sending a non-empty `queryStringVaryParameters` together with `queryStringVaryEnabled=false` is accepted: the list is persisted for later re-activation but does not affect the cache while the flag is false. + """ # noqa: E501 + + cache_key_headers: Optional[List[Annotated[str, Field(strict=True)]]] = Field( + default=None, + description="HTTP request header names that participate in the cache key. Omit to leave unchanged; send `[]` to clear. ", + alias="cacheKeyHeaders", + ) + query_string_vary_enabled: Optional[StrictBool] = Field( + default=None, + description="When true, the CDN varies its cache by the request query string. Omit to leave unchanged. ", + alias="queryStringVaryEnabled", + ) + query_string_vary_parameters: Optional[List[Annotated[str, Field(strict=True)]]] = Field( + default=None, + description="Allowlist of query-string parameter names. Omit to leave unchanged; send `[]` to clear. ", + alias="queryStringVaryParameters", + ) + __properties: ClassVar[List[str]] = ["cacheKeyHeaders", "queryStringVaryEnabled", "queryStringVaryParameters"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CacheConfigPatch from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CacheConfigPatch from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "cacheKeyHeaders": obj.get("cacheKeyHeaders"), + "queryStringVaryEnabled": obj.get("queryStringVaryEnabled"), + "queryStringVaryParameters": obj.get("queryStringVaryParameters"), + } + ) + return _obj diff --git a/services/cdn/src/stackit/cdn/models/config.py b/services/cdn/src/stackit/cdn/models/config.py index 722871f0a..ad5912504 100644 --- a/services/cdn/src/stackit/cdn/models/config.py +++ b/services/cdn/src/stackit/cdn/models/config.py @@ -27,6 +27,7 @@ from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self +from stackit.cdn.models.cache_config import CacheConfig from stackit.cdn.models.config_backend import ConfigBackend from stackit.cdn.models.config_log_sink import ConfigLogSink from stackit.cdn.models.optimizer import Optimizer @@ -50,6 +51,7 @@ class Config(BaseModel): description="Restricts access to your content by specifying a list of blocked IPv4 addresses. This feature enhances security and privacy by preventing these addresses from accessing your distribution. ", alias="blockedIps", ) + cache_config: CacheConfig = Field(alias="cacheConfig") default_cache_duration: Optional[StrictStr] = Field( default=None, description="Sets the default cache duration for the distribution. The default cache duration is applied when a 'Cache-Control' header is not presented in the origin's response. We use ISO8601 duration format for cache duration (e.g. P1DT2H30M) ", @@ -81,6 +83,7 @@ class Config(BaseModel): "backend", "blockedCountries", "blockedIps", + "cacheConfig", "defaultCacheDuration", "forwardHostHeader", "labels", @@ -134,6 +137,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of backend if self.backend: _dict["backend"] = self.backend.to_dict() + # override the default output from pydantic by calling `to_dict()` of cache_config + if self.cache_config: + _dict["cacheConfig"] = self.cache_config.to_dict() # override the default output from pydantic by calling `to_dict()` of log_sink if self.log_sink: _dict["logSink"] = self.log_sink.to_dict() @@ -175,6 +181,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "backend": ConfigBackend.from_dict(obj["backend"]) if obj.get("backend") is not None else None, "blockedCountries": obj.get("blockedCountries"), "blockedIps": obj.get("blockedIps"), + "cacheConfig": ( + CacheConfig.from_dict(obj["cacheConfig"]) if obj.get("cacheConfig") is not None else None + ), "defaultCacheDuration": obj.get("defaultCacheDuration"), "forwardHostHeader": obj.get("forwardHostHeader"), "labels": obj.get("labels"), diff --git a/services/cdn/src/stackit/cdn/models/config_log_sink.py b/services/cdn/src/stackit/cdn/models/config_log_sink.py index 20a96a416..800d6e891 100644 --- a/services/cdn/src/stackit/cdn/models/config_log_sink.py +++ b/services/cdn/src/stackit/cdn/models/config_log_sink.py @@ -26,8 +26,9 @@ from typing_extensions import Self from stackit.cdn.models.loki_log_sink import LokiLogSink +from stackit.cdn.models.otlp_log_sink import OtlpLogSink -CONFIGLOGSINK_ONE_OF_SCHEMAS = ["LokiLogSink"] +CONFIGLOGSINK_ONE_OF_SCHEMAS = ["LokiLogSink", "OtlpLogSink"] class ConfigLogSink(BaseModel): @@ -37,8 +38,10 @@ class ConfigLogSink(BaseModel): # data type: LokiLogSink oneof_schema_1_validator: Optional[LokiLogSink] = None - actual_instance: Optional[Union[LokiLogSink]] = None - one_of_schemas: Set[str] = {"LokiLogSink"} + # data type: OtlpLogSink + oneof_schema_2_validator: Optional[OtlpLogSink] = None + actual_instance: Optional[Union[LokiLogSink, OtlpLogSink]] = None + one_of_schemas: Set[str] = {"LokiLogSink", "OtlpLogSink"} model_config = ConfigDict( validate_assignment=True, @@ -67,10 +70,15 @@ def actual_instance_must_validate_oneof(cls, v): error_messages.append(f"Error! Input type `{type(v)}` is not `LokiLogSink`") else: match += 1 + # validate data type: OtlpLogSink + if not isinstance(v, OtlpLogSink): + error_messages.append(f"Error! Input type `{type(v)}` is not `OtlpLogSink`") + else: + match += 1 if match == 0: # no match raise ValueError( - "No match found when setting `actual_instance` in ConfigLogSink with oneOf schemas: LokiLogSink. Details: " + "No match found when setting `actual_instance` in ConfigLogSink with oneOf schemas: LokiLogSink, OtlpLogSink. Details: " + ", ".join(error_messages) ) else: @@ -93,17 +101,23 @@ def from_json(cls, json_str: str) -> Self: match += 1 except (ValidationError, ValueError) as e: error_messages.append(str(e)) + # deserialize data into OtlpLogSink + try: + instance.actual_instance = OtlpLogSink.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: " + "Multiple matches found when deserializing the JSON string into ConfigLogSink with oneOf schemas: LokiLogSink, OtlpLogSink. 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: " + "No match found when deserializing the JSON string into ConfigLogSink with oneOf schemas: LokiLogSink, OtlpLogSink. Details: " + ", ".join(error_messages) ) else: @@ -119,7 +133,7 @@ def to_json(self) -> str: else: return json.dumps(self.actual_instance) - def to_dict(self) -> Optional[Union[Dict[str, Any], LokiLogSink]]: + def to_dict(self) -> Optional[Union[Dict[str, Any], LokiLogSink, OtlpLogSink]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: return None diff --git a/services/cdn/src/stackit/cdn/models/config_patch.py b/services/cdn/src/stackit/cdn/models/config_patch.py index c84756951..02c01ee28 100644 --- a/services/cdn/src/stackit/cdn/models/config_patch.py +++ b/services/cdn/src/stackit/cdn/models/config_patch.py @@ -27,6 +27,7 @@ from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self +from stackit.cdn.models.cache_config_patch import CacheConfigPatch from stackit.cdn.models.config_patch_backend import ConfigPatchBackend from stackit.cdn.models.config_patch_log_sink import ConfigPatchLogSink from stackit.cdn.models.optimizer_patch import OptimizerPatch @@ -52,6 +53,7 @@ class ConfigPatch(BaseModel): description="Restricts access to your content by specifying a list of blocked IPv4 addresses. This feature enhances security and privacy by preventing these addresses from accessing your distribution. ", alias="blockedIps", ) + cache_config: Optional[CacheConfigPatch] = Field(default=None, alias="cacheConfig") default_cache_duration: Optional[StrictStr] = Field( default=None, description="Sets the default cache duration for the distribution. The default cache duration is applied when a 'Cache-Control' header is not presented in the origin's response. We use ISO8601 duration format for cache duration (e.g. P1DT2H30M) ", @@ -86,6 +88,7 @@ class ConfigPatch(BaseModel): "backend", "blockedCountries", "blockedIps", + "cacheConfig", "defaultCacheDuration", "forwardHostHeader", "labels", @@ -139,6 +142,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of backend if self.backend: _dict["backend"] = self.backend.to_dict() + # override the default output from pydantic by calling `to_dict()` of cache_config + if self.cache_config: + _dict["cacheConfig"] = self.cache_config.to_dict() # override the default output from pydantic by calling `to_dict()` of log_sink if self.log_sink: _dict["logSink"] = self.log_sink.to_dict() @@ -185,6 +191,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "backend": ConfigPatchBackend.from_dict(obj["backend"]) if obj.get("backend") is not None else None, "blockedCountries": obj.get("blockedCountries"), "blockedIps": obj.get("blockedIps"), + "cacheConfig": ( + CacheConfigPatch.from_dict(obj["cacheConfig"]) if obj.get("cacheConfig") is not None else None + ), "defaultCacheDuration": obj.get("defaultCacheDuration"), "forwardHostHeader": obj.get("forwardHostHeader"), "labels": obj.get("labels"), 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 index 67c0bf767..bc6baf7d8 100644 --- a/services/cdn/src/stackit/cdn/models/config_patch_log_sink.py +++ b/services/cdn/src/stackit/cdn/models/config_patch_log_sink.py @@ -26,8 +26,9 @@ from typing_extensions import Self from stackit.cdn.models.loki_log_sink_patch import LokiLogSinkPatch +from stackit.cdn.models.otlp_log_sink_patch import OtlpLogSinkPatch -CONFIGPATCHLOGSINK_ONE_OF_SCHEMAS = ["LokiLogSinkPatch"] +CONFIGPATCHLOGSINK_ONE_OF_SCHEMAS = ["LokiLogSinkPatch", "OtlpLogSinkPatch"] class ConfigPatchLogSink(BaseModel): @@ -37,8 +38,10 @@ class ConfigPatchLogSink(BaseModel): # data type: LokiLogSinkPatch oneof_schema_1_validator: Optional[LokiLogSinkPatch] = None - actual_instance: Optional[Union[LokiLogSinkPatch]] = None - one_of_schemas: Set[str] = {"LokiLogSinkPatch"} + # data type: OtlpLogSinkPatch + oneof_schema_2_validator: Optional[OtlpLogSinkPatch] = None + actual_instance: Optional[Union[LokiLogSinkPatch, OtlpLogSinkPatch]] = None + one_of_schemas: Set[str] = {"LokiLogSinkPatch", "OtlpLogSinkPatch"} model_config = ConfigDict( validate_assignment=True, @@ -70,10 +73,15 @@ def actual_instance_must_validate_oneof(cls, v): error_messages.append(f"Error! Input type `{type(v)}` is not `LokiLogSinkPatch`") else: match += 1 + # validate data type: OtlpLogSinkPatch + if not isinstance(v, OtlpLogSinkPatch): + error_messages.append(f"Error! Input type `{type(v)}` is not `OtlpLogSinkPatch`") + else: + match += 1 if match == 0: # no match raise ValueError( - "No match found when setting `actual_instance` in ConfigPatchLogSink with oneOf schemas: LokiLogSinkPatch. Details: " + "No match found when setting `actual_instance` in ConfigPatchLogSink with oneOf schemas: LokiLogSinkPatch, OtlpLogSinkPatch. Details: " + ", ".join(error_messages) ) else: @@ -99,17 +107,23 @@ def from_json(cls, json_str: Optional[str]) -> Self: match += 1 except (ValidationError, ValueError) as e: error_messages.append(str(e)) + # deserialize data into OtlpLogSinkPatch + try: + instance.actual_instance = OtlpLogSinkPatch.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: " + "Multiple matches found when deserializing the JSON string into ConfigPatchLogSink with oneOf schemas: LokiLogSinkPatch, OtlpLogSinkPatch. 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: " + "No match found when deserializing the JSON string into ConfigPatchLogSink with oneOf schemas: LokiLogSinkPatch, OtlpLogSinkPatch. Details: " + ", ".join(error_messages) ) else: @@ -125,7 +139,7 @@ def to_json(self) -> str: else: return json.dumps(self.actual_instance) - def to_dict(self) -> Optional[Union[Dict[str, Any], LokiLogSinkPatch]]: + def to_dict(self) -> Optional[Union[Dict[str, Any], LokiLogSinkPatch, OtlpLogSinkPatch]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: return None 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 bc0d680c2..1b6ea38f0 100644 --- a/services/cdn/src/stackit/cdn/models/create_distribution_payload.py +++ b/services/cdn/src/stackit/cdn/models/create_distribution_payload.py @@ -27,6 +27,7 @@ from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self +from stackit.cdn.models.cache_config_create import CacheConfigCreate from stackit.cdn.models.create_distribution_payload_backend import ( CreateDistributionPayloadBackend, ) @@ -56,6 +57,7 @@ class CreateDistributionPayload(BaseModel): description="Restricts access to your content by specifying a list of blocked IPv4 addresses. This feature enhances security and privacy by preventing these addresses from accessing your distribution. ", alias="blockedIps", ) + cache_config: Optional[CacheConfigCreate] = Field(default=None, alias="cacheConfig") default_cache_duration: Optional[StrictStr] = Field( default=None, description="Sets the default cache duration for the distribution. The default cache duration is applied when a 'Cache-Control' header is not presented in the origin's response. We use ISO8601 duration format for cache duration (e.g. P1DT2H30M) ", @@ -96,6 +98,7 @@ class CreateDistributionPayload(BaseModel): "backend", "blockedCountries", "blockedIps", + "cacheConfig", "defaultCacheDuration", "forwardHostHeader", "intentId", @@ -150,6 +153,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of backend if self.backend: _dict["backend"] = self.backend.to_dict() + # override the default output from pydantic by calling `to_dict()` of cache_config + if self.cache_config: + _dict["cacheConfig"] = self.cache_config.to_dict() # override the default output from pydantic by calling `to_dict()` of log_sink if self.log_sink: _dict["logSink"] = self.log_sink.to_dict() @@ -185,6 +191,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: ), "blockedCountries": obj.get("blockedCountries"), "blockedIps": obj.get("blockedIps"), + "cacheConfig": ( + CacheConfigCreate.from_dict(obj["cacheConfig"]) if obj.get("cacheConfig") is not None else None + ), "defaultCacheDuration": obj.get("defaultCacheDuration"), "forwardHostHeader": obj.get("forwardHostHeader"), "intentId": obj.get("intentId"), 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 index 1d8e67fc6..c93c69ec1 100644 --- 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 @@ -26,8 +26,9 @@ from typing_extensions import Self from stackit.cdn.models.loki_log_sink_create import LokiLogSinkCreate +from stackit.cdn.models.otlp_log_sink_create import OtlpLogSinkCreate -CREATEDISTRIBUTIONPAYLOADLOGSINK_ONE_OF_SCHEMAS = ["LokiLogSinkCreate"] +CREATEDISTRIBUTIONPAYLOADLOGSINK_ONE_OF_SCHEMAS = ["LokiLogSinkCreate", "OtlpLogSinkCreate"] class CreateDistributionPayloadLogSink(BaseModel): @@ -37,8 +38,10 @@ class CreateDistributionPayloadLogSink(BaseModel): # data type: LokiLogSinkCreate oneof_schema_1_validator: Optional[LokiLogSinkCreate] = None - actual_instance: Optional[Union[LokiLogSinkCreate]] = None - one_of_schemas: Set[str] = {"LokiLogSinkCreate"} + # data type: OtlpLogSinkCreate + oneof_schema_2_validator: Optional[OtlpLogSinkCreate] = None + actual_instance: Optional[Union[LokiLogSinkCreate, OtlpLogSinkCreate]] = None + one_of_schemas: Set[str] = {"LokiLogSinkCreate", "OtlpLogSinkCreate"} model_config = ConfigDict( validate_assignment=True, @@ -67,10 +70,15 @@ def actual_instance_must_validate_oneof(cls, v): error_messages.append(f"Error! Input type `{type(v)}` is not `LokiLogSinkCreate`") else: match += 1 + # validate data type: OtlpLogSinkCreate + if not isinstance(v, OtlpLogSinkCreate): + error_messages.append(f"Error! Input type `{type(v)}` is not `OtlpLogSinkCreate`") + else: + match += 1 if match == 0: # no match raise ValueError( - "No match found when setting `actual_instance` in CreateDistributionPayloadLogSink with oneOf schemas: LokiLogSinkCreate. Details: " + "No match found when setting `actual_instance` in CreateDistributionPayloadLogSink with oneOf schemas: LokiLogSinkCreate, OtlpLogSinkCreate. Details: " + ", ".join(error_messages) ) else: @@ -93,17 +101,23 @@ def from_json(cls, json_str: str) -> Self: match += 1 except (ValidationError, ValueError) as e: error_messages.append(str(e)) + # deserialize data into OtlpLogSinkCreate + try: + instance.actual_instance = OtlpLogSinkCreate.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: " + "Multiple matches found when deserializing the JSON string into CreateDistributionPayloadLogSink with oneOf schemas: LokiLogSinkCreate, OtlpLogSinkCreate. 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: " + "No match found when deserializing the JSON string into CreateDistributionPayloadLogSink with oneOf schemas: LokiLogSinkCreate, OtlpLogSinkCreate. Details: " + ", ".join(error_messages) ) else: @@ -119,7 +133,7 @@ def to_json(self) -> str: else: return json.dumps(self.actual_instance) - def to_dict(self) -> Optional[Union[Dict[str, Any], LokiLogSinkCreate]]: + def to_dict(self) -> Optional[Union[Dict[str, Any], LokiLogSinkCreate, OtlpLogSinkCreate]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: return None diff --git a/services/cdn/src/stackit/cdn/models/otlp_log_sink.py b/services/cdn/src/stackit/cdn/models/otlp_log_sink.py new file mode 100644 index 000000000..57b8eb6ba --- /dev/null +++ b/services/cdn/src/stackit/cdn/models/otlp_log_sink.py @@ -0,0 +1,93 @@ +# 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, 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 + + +class OtlpLogSink(BaseModel): + """ + OtlpLogSink + """ # noqa: E501 + + push_url: StrictStr = Field( + description="The fully qualified URL where the CDN should push logs to your OTLP endpoint (for example, `https://otlp.example.com/otlp/v1/logs`).", + 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(["otlp"]): + raise ValueError("must be one of enum values ('otlp')") + return value + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of OtlpLogSink from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of OtlpLogSink from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"pushUrl": obj.get("pushUrl"), "type": obj.get("type")}) + return _obj diff --git a/services/cdn/src/stackit/cdn/models/otlp_log_sink_basic_credentials.py b/services/cdn/src/stackit/cdn/models/otlp_log_sink_basic_credentials.py new file mode 100644 index 000000000..bb47031d2 --- /dev/null +++ b/services/cdn/src/stackit/cdn/models/otlp_log_sink_basic_credentials.py @@ -0,0 +1,93 @@ +# 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, 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 + + +class OtlpLogSinkBasicCredentials(BaseModel): + """ + Basic authentication credentials for OTLP. + """ # noqa: E501 + + password: StrictStr = Field(description="The password corresponding to your username.") + type: StrictStr = Field(description="Defines basic authentication.") + username: StrictStr = Field(description="The username used to authenticate against your OTLP endpoint.") + __properties: ClassVar[List[str]] = ["password", "type", "username"] + + @field_validator("type") + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["basic"]): + raise ValueError("must be one of enum values ('basic')") + return value + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of OtlpLogSinkBasicCredentials from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of OtlpLogSinkBasicCredentials from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + {"password": obj.get("password"), "type": obj.get("type"), "username": obj.get("username")} + ) + return _obj diff --git a/services/cdn/src/stackit/cdn/models/otlp_log_sink_bearer_credentials.py b/services/cdn/src/stackit/cdn/models/otlp_log_sink_bearer_credentials.py new file mode 100644 index 000000000..e4549f3cf --- /dev/null +++ b/services/cdn/src/stackit/cdn/models/otlp_log_sink_bearer_credentials.py @@ -0,0 +1,90 @@ +# 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, 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 + + +class OtlpLogSinkBearerCredentials(BaseModel): + """ + Bearer token authentication credentials for OTLP. + """ # noqa: E501 + + token: StrictStr = Field(description="The bearer token used to authenticate against your OTLP endpoint.") + type: StrictStr = Field(description="Defines bearer token authentication.") + __properties: ClassVar[List[str]] = ["token", "type"] + + @field_validator("type") + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["bearer"]): + raise ValueError("must be one of enum values ('bearer')") + return value + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of OtlpLogSinkBearerCredentials from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of OtlpLogSinkBearerCredentials from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"token": obj.get("token"), "type": obj.get("type")}) + return _obj diff --git a/services/cdn/src/stackit/cdn/models/otlp_log_sink_create.py b/services/cdn/src/stackit/cdn/models/otlp_log_sink_create.py new file mode 100644 index 000000000..9d3bd815a --- /dev/null +++ b/services/cdn/src/stackit/cdn/models/otlp_log_sink_create.py @@ -0,0 +1,111 @@ +# 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, 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.cdn.models.otlp_log_sink_create_credentials import ( + OtlpLogSinkCreateCredentials, +) + + +class OtlpLogSinkCreate(BaseModel): + """ + OtlpLogSinkCreate + """ # noqa: E501 + + credentials: OtlpLogSinkCreateCredentials + push_url: StrictStr = Field( + description="The fully qualified URL where the CDN should push logs to your OTLP endpoint (for example, `https://otlp.example.com/otlp/v1/logs`).", + alias="pushUrl", + ) + type: StrictStr = Field(description="Defines the type of the log sink.") + __properties: ClassVar[List[str]] = ["credentials", "pushUrl", "type"] + + @field_validator("type") + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["otlp"]): + raise ValueError("must be one of enum values ('otlp')") + return value + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of OtlpLogSinkCreate from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of credentials + if self.credentials: + _dict["credentials"] = self.credentials.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of OtlpLogSinkCreate from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "credentials": ( + OtlpLogSinkCreateCredentials.from_dict(obj["credentials"]) + if obj.get("credentials") is not None + else None + ), + "pushUrl": obj.get("pushUrl"), + "type": obj.get("type"), + } + ) + return _obj diff --git a/services/cdn/src/stackit/cdn/models/otlp_log_sink_create_credentials.py b/services/cdn/src/stackit/cdn/models/otlp_log_sink_create_credentials.py new file mode 100644 index 000000000..3f4ed4bd3 --- /dev/null +++ b/services/cdn/src/stackit/cdn/models/otlp_log_sink_create_credentials.py @@ -0,0 +1,153 @@ +# 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.otlp_log_sink_basic_credentials import ( + OtlpLogSinkBasicCredentials, +) +from stackit.cdn.models.otlp_log_sink_bearer_credentials import ( + OtlpLogSinkBearerCredentials, +) + +OTLPLOGSINKCREATECREDENTIALS_ONE_OF_SCHEMAS = ["OtlpLogSinkBasicCredentials", "OtlpLogSinkBearerCredentials"] + + +class OtlpLogSinkCreateCredentials(BaseModel): + """ + The authentication credentials required for the CDN to push logs to your OTLP endpoint. + """ + + # data type: OtlpLogSinkBearerCredentials + oneof_schema_1_validator: Optional[OtlpLogSinkBearerCredentials] = None + # data type: OtlpLogSinkBasicCredentials + oneof_schema_2_validator: Optional[OtlpLogSinkBasicCredentials] = None + actual_instance: Optional[Union[OtlpLogSinkBasicCredentials, OtlpLogSinkBearerCredentials]] = None + one_of_schemas: Set[str] = {"OtlpLogSinkBasicCredentials", "OtlpLogSinkBearerCredentials"} + + 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 = OtlpLogSinkCreateCredentials.model_construct() + error_messages = [] + match = 0 + # validate data type: OtlpLogSinkBearerCredentials + if not isinstance(v, OtlpLogSinkBearerCredentials): + error_messages.append(f"Error! Input type `{type(v)}` is not `OtlpLogSinkBearerCredentials`") + else: + match += 1 + # validate data type: OtlpLogSinkBasicCredentials + if not isinstance(v, OtlpLogSinkBasicCredentials): + error_messages.append(f"Error! Input type `{type(v)}` is not `OtlpLogSinkBasicCredentials`") + else: + match += 1 + if match == 0: + # no match + raise ValueError( + "No match found when setting `actual_instance` in OtlpLogSinkCreateCredentials with oneOf schemas: OtlpLogSinkBasicCredentials, OtlpLogSinkBearerCredentials. 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 OtlpLogSinkBearerCredentials + try: + instance.actual_instance = OtlpLogSinkBearerCredentials.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into OtlpLogSinkBasicCredentials + try: + instance.actual_instance = OtlpLogSinkBasicCredentials.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 OtlpLogSinkCreateCredentials with oneOf schemas: OtlpLogSinkBasicCredentials, OtlpLogSinkBearerCredentials. Details: " + + ", ".join(error_messages) + ) + elif match == 0: + # no match + raise ValueError( + "No match found when deserializing the JSON string into OtlpLogSinkCreateCredentials with oneOf schemas: OtlpLogSinkBasicCredentials, OtlpLogSinkBearerCredentials. 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], OtlpLogSinkBasicCredentials, OtlpLogSinkBearerCredentials]]: + """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/otlp_log_sink_patch.py b/services/cdn/src/stackit/cdn/models/otlp_log_sink_patch.py new file mode 100644 index 000000000..310d44a00 --- /dev/null +++ b/services/cdn/src/stackit/cdn/models/otlp_log_sink_patch.py @@ -0,0 +1,112 @@ +# 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, 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.cdn.models.otlp_log_sink_patch_credentials import ( + OtlpLogSinkPatchCredentials, +) + + +class OtlpLogSinkPatch(BaseModel): + """ + OtlpLogSinkPatch + """ # noqa: E501 + + credentials: Optional[OtlpLogSinkPatchCredentials] = None + push_url: Optional[StrictStr] = Field( + default=None, + description="The fully qualified URL where the CDN should push logs to your OTLP endpoint (for example, `https://otlp.example.com/otlp/v1/logs`).", + alias="pushUrl", + ) + type: StrictStr = Field(description="Defines the type of the log sink.") + __properties: ClassVar[List[str]] = ["credentials", "pushUrl", "type"] + + @field_validator("type") + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["otlp"]): + raise ValueError("must be one of enum values ('otlp')") + return value + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of OtlpLogSinkPatch from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of credentials + if self.credentials: + _dict["credentials"] = self.credentials.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of OtlpLogSinkPatch from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "credentials": ( + OtlpLogSinkPatchCredentials.from_dict(obj["credentials"]) + if obj.get("credentials") is not None + else None + ), + "pushUrl": obj.get("pushUrl"), + "type": obj.get("type"), + } + ) + return _obj diff --git a/services/cdn/src/stackit/cdn/models/otlp_log_sink_patch_credentials.py b/services/cdn/src/stackit/cdn/models/otlp_log_sink_patch_credentials.py new file mode 100644 index 000000000..e518128ef --- /dev/null +++ b/services/cdn/src/stackit/cdn/models/otlp_log_sink_patch_credentials.py @@ -0,0 +1,153 @@ +# 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.otlp_log_sink_basic_credentials import ( + OtlpLogSinkBasicCredentials, +) +from stackit.cdn.models.otlp_log_sink_bearer_credentials import ( + OtlpLogSinkBearerCredentials, +) + +OTLPLOGSINKPATCHCREDENTIALS_ONE_OF_SCHEMAS = ["OtlpLogSinkBasicCredentials", "OtlpLogSinkBearerCredentials"] + + +class OtlpLogSinkPatchCredentials(BaseModel): + """ + The authentication credentials required for the CDN to push logs to your OTLP endpoint. + """ + + # data type: OtlpLogSinkBearerCredentials + oneof_schema_1_validator: Optional[OtlpLogSinkBearerCredentials] = None + # data type: OtlpLogSinkBasicCredentials + oneof_schema_2_validator: Optional[OtlpLogSinkBasicCredentials] = None + actual_instance: Optional[Union[OtlpLogSinkBasicCredentials, OtlpLogSinkBearerCredentials]] = None + one_of_schemas: Set[str] = {"OtlpLogSinkBasicCredentials", "OtlpLogSinkBearerCredentials"} + + 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 = OtlpLogSinkPatchCredentials.model_construct() + error_messages = [] + match = 0 + # validate data type: OtlpLogSinkBearerCredentials + if not isinstance(v, OtlpLogSinkBearerCredentials): + error_messages.append(f"Error! Input type `{type(v)}` is not `OtlpLogSinkBearerCredentials`") + else: + match += 1 + # validate data type: OtlpLogSinkBasicCredentials + if not isinstance(v, OtlpLogSinkBasicCredentials): + error_messages.append(f"Error! Input type `{type(v)}` is not `OtlpLogSinkBasicCredentials`") + else: + match += 1 + if match == 0: + # no match + raise ValueError( + "No match found when setting `actual_instance` in OtlpLogSinkPatchCredentials with oneOf schemas: OtlpLogSinkBasicCredentials, OtlpLogSinkBearerCredentials. 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 OtlpLogSinkBearerCredentials + try: + instance.actual_instance = OtlpLogSinkBearerCredentials.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into OtlpLogSinkBasicCredentials + try: + instance.actual_instance = OtlpLogSinkBasicCredentials.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 OtlpLogSinkPatchCredentials with oneOf schemas: OtlpLogSinkBasicCredentials, OtlpLogSinkBearerCredentials. Details: " + + ", ".join(error_messages) + ) + elif match == 0: + # no match + raise ValueError( + "No match found when deserializing the JSON string into OtlpLogSinkPatchCredentials with oneOf schemas: OtlpLogSinkBasicCredentials, OtlpLogSinkBearerCredentials. 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], OtlpLogSinkBasicCredentials, OtlpLogSinkBearerCredentials]]: + """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())