Skip to content

Generator: Update SDK /services/cdn #1226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
- **Feature:** Added `ClusterError`
- `sqlserverflex`: [v1.0.2](services/sqlserverflex/CHANGELOG.md#v102-2025-05-14)
- **Feature:** Added new method `list_metrics`
- `cdn`: [v1.1.0](services/cdn/CHANGELOG.md#v110-2025-05-27)
- **Feature:** Add support for CDN Optimizer feature

## Release (2025-05-09)
- `stackitmarketplace`:
Expand Down
3 changes: 3 additions & 0 deletions services/cdn/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v1.1.0 (2025-05-27)
- **Feature:** Add support for CDN Optimizer feature

## v1.0.1 (2025-05-09)
- **Feature:** Update user-agent header

Expand Down
2 changes: 1 addition & 1 deletion services/cdn/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "stackit-cdn"

[tool.poetry]
name = "stackit-cdn"
version = "v1.0.1"
version = "v1.1.0"
authors = [
"STACKIT Developer Tools <developer-tools@stackit.cloud>",
]
Expand Down
2 changes: 2 additions & 0 deletions services/cdn/src/stackit/cdn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
from stackit.cdn.models.http_backend import HttpBackend
from stackit.cdn.models.http_backend_patch import HttpBackendPatch
from stackit.cdn.models.list_distributions_response import ListDistributionsResponse
from stackit.cdn.models.optimizer import Optimizer
from stackit.cdn.models.optimizer_patch import OptimizerPatch
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
Expand Down
2 changes: 2 additions & 0 deletions services/cdn/src/stackit/cdn/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
from stackit.cdn.models.http_backend import HttpBackend
from stackit.cdn.models.http_backend_patch import HttpBackendPatch
from stackit.cdn.models.list_distributions_response import ListDistributionsResponse
from stackit.cdn.models.optimizer import Optimizer
from stackit.cdn.models.optimizer_patch import OptimizerPatch
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
Expand Down
15 changes: 14 additions & 1 deletion services/cdn/src/stackit/cdn/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from typing_extensions import Annotated, Self

from stackit.cdn.models.config_backend import ConfigBackend
from stackit.cdn.models.optimizer import Optimizer
from stackit.cdn.models.region import Region


Expand All @@ -43,8 +44,16 @@ class Config(BaseModel):
description="Sets the monthly limit of bandwidth in bytes that the pullzone is allowed to use. ",
alias="monthlyLimitBytes",
)
optimizer: Optional[Optimizer] = None
regions: Annotated[List[Region], Field(min_length=1)]
__properties: ClassVar[List[str]] = ["backend", "blockedCountries", "blockedIPs", "monthlyLimitBytes", "regions"]
__properties: ClassVar[List[str]] = [
"backend",
"blockedCountries",
"blockedIPs",
"monthlyLimitBytes",
"optimizer",
"regions",
]

model_config = ConfigDict(
populate_by_name=True,
Expand Down Expand Up @@ -86,6 +95,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 optimizer
if self.optimizer:
_dict["optimizer"] = self.optimizer.to_dict()
# set to None if monthly_limit_bytes (nullable) is None
# and model_fields_set contains the field
if self.monthly_limit_bytes is None and "monthly_limit_bytes" in self.model_fields_set:
Expand All @@ -108,6 +120,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"blockedCountries": obj.get("blockedCountries"),
"blockedIPs": obj.get("blockedIPs"),
"monthlyLimitBytes": obj.get("monthlyLimitBytes"),
"optimizer": Optimizer.from_dict(obj["optimizer"]) if obj.get("optimizer") is not None else None,
"regions": obj.get("regions"),
}
)
Expand Down
15 changes: 14 additions & 1 deletion services/cdn/src/stackit/cdn/models/config_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from typing_extensions import Annotated, Self

from stackit.cdn.models.config_patch_backend import ConfigPatchBackend
from stackit.cdn.models.optimizer_patch import OptimizerPatch
from stackit.cdn.models.region import Region


Expand All @@ -45,8 +46,16 @@ class ConfigPatch(BaseModel):
description="Sets the monthly limit of bandwidth in bytes that the pullzone is allowed to use. ",
alias="monthlyLimitBytes",
)
optimizer: Optional[OptimizerPatch] = None
regions: Optional[Annotated[List[Region], Field(min_length=1)]] = None
__properties: ClassVar[List[str]] = ["backend", "blockedCountries", "blockedIPs", "monthlyLimitBytes", "regions"]
__properties: ClassVar[List[str]] = [
"backend",
"blockedCountries",
"blockedIPs",
"monthlyLimitBytes",
"optimizer",
"regions",
]

model_config = ConfigDict(
populate_by_name=True,
Expand Down Expand Up @@ -88,6 +97,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 optimizer
if self.optimizer:
_dict["optimizer"] = self.optimizer.to_dict()
# set to None if monthly_limit_bytes (nullable) is None
# and model_fields_set contains the field
if self.monthly_limit_bytes is None and "monthly_limit_bytes" in self.model_fields_set:
Expand All @@ -110,6 +122,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"blockedCountries": obj.get("blockedCountries"),
"blockedIPs": obj.get("blockedIPs"),
"monthlyLimitBytes": obj.get("monthlyLimitBytes"),
"optimizer": OptimizerPatch.from_dict(obj["optimizer"]) if obj.get("optimizer") is not None else None,
"regions": obj.get("regions"),
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing_extensions import Annotated, Self

from stackit.cdn.models.optimizer import Optimizer
from stackit.cdn.models.region import Region


Expand Down Expand Up @@ -48,6 +49,7 @@ class CreateDistributionPayload(BaseModel):
description="Sets the monthly limit of bandwidth in bytes that the pullzone is allowed to use. ",
alias="monthlyLimitBytes",
)
optimizer: Optional[Optimizer] = None
origin_request_headers: Optional[Dict[str, StrictStr]] = Field(
default=None,
description="Headers that will be sent with every request to the configured origin. WARNING: Do not store sensitive values in the headers. The data is stores as plain text. ",
Expand All @@ -65,6 +67,7 @@ class CreateDistributionPayload(BaseModel):
"blockedIPs",
"intentId",
"monthlyLimitBytes",
"optimizer",
"originRequestHeaders",
"originUrl",
"regions",
Expand Down Expand Up @@ -107,6 +110,9 @@ def to_dict(self) -> Dict[str, Any]:
exclude=excluded_fields,
exclude_none=True,
)
# override the default output from pydantic by calling `to_dict()` of optimizer
if self.optimizer:
_dict["optimizer"] = self.optimizer.to_dict()
return _dict

@classmethod
Expand All @@ -124,6 +130,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"blockedIPs": obj.get("blockedIPs"),
"intentId": obj.get("intentId"),
"monthlyLimitBytes": obj.get("monthlyLimitBytes"),
"optimizer": Optimizer.from_dict(obj["optimizer"]) if obj.get("optimizer") is not None else None,
"originRequestHeaders": obj.get("originRequestHeaders"),
"originUrl": obj.get("originUrl"),
"regions": obj.get("regions"),
Expand Down
83 changes: 83 additions & 0 deletions services/cdn/src/stackit/cdn/models/optimizer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# coding: utf-8

"""
CDN API

API used to create and manage your CDN distributions.

The version of the OpenAPI document: 1beta.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501 docstring might be too long

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 typing_extensions import Self


class Optimizer(BaseModel):
"""
Optimizer is paid feature, a real-time on the fly image manipulation and optimization service that automatically optimizes your images for faster image delivery.
"""

enabled: StrictBool = Field(
description="Determines if the optimizer should be enabled for this distribution and incurs a monthly fee"
)
__properties: ClassVar[List[str]] = ["enabled"]

model_config = ConfigDict(
populate_by_name=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"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())

@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of Optimizer 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 Optimizer from a dict"""
if obj is None:
return None

if not isinstance(obj, dict):
return cls.model_validate(obj)

_obj = cls.model_validate({"enabled": obj.get("enabled")})
return _obj
81 changes: 81 additions & 0 deletions services/cdn/src/stackit/cdn/models/optimizer_patch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# coding: utf-8

"""
CDN API

API used to create and manage your CDN distributions.

The version of the OpenAPI document: 1beta.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501 docstring might be too long

from __future__ import annotations

import json
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set

from pydantic import BaseModel, ConfigDict, StrictBool
from typing_extensions import Self


class OptimizerPatch(BaseModel):
"""
OptimizerPatch
"""

enabled: Optional[StrictBool] = None
__properties: ClassVar[List[str]] = ["enabled"]

model_config = ConfigDict(
populate_by_name=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"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())

@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of OptimizerPatch 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 OptimizerPatch from a dict"""
if obj is None:
return None

if not isinstance(obj, dict):
return cls.model_validate(obj)

_obj = cls.model_validate({"enabled": obj.get("enabled")})
return _obj
Loading