Skip to content

Generator: Update SDK /services/cdn #1022

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions services/cdn/src/stackit/cdn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from stackit.cdn.models.delete_custom_domain_response import DeleteCustomDomainResponse
from stackit.cdn.models.delete_distribution_response import DeleteDistributionResponse
from stackit.cdn.models.distribution import Distribution
from stackit.cdn.models.distribution_logs_record import DistributionLogsRecord
from stackit.cdn.models.distribution_statistics_record import (
DistributionStatisticsRecord,
)
Expand All @@ -54,20 +55,19 @@
)
from stackit.cdn.models.domain import Domain
from stackit.cdn.models.domain_status import DomainStatus
from stackit.cdn.models.error_details import ErrorDetails
from stackit.cdn.models.find_cache_paths_response import FindCachePathsResponse
from stackit.cdn.models.find_cache_paths_response_entry import (
FindCachePathsResponseEntry,
)
from stackit.cdn.models.generic_json_response import GenericJSONResponse
from stackit.cdn.models.generic_json_response_details_inner import (
GenericJSONResponseDetailsInner,
)
from stackit.cdn.models.get_cache_info_response import GetCacheInfoResponse
from stackit.cdn.models.get_cache_info_response_history_entry import (
GetCacheInfoResponseHistoryEntry,
)
from stackit.cdn.models.get_custom_domain_response import GetCustomDomainResponse
from stackit.cdn.models.get_distribution_response import GetDistributionResponse
from stackit.cdn.models.get_logs_response import GetLogsResponse
from stackit.cdn.models.get_statistics_response import GetStatisticsResponse
from stackit.cdn.models.http_backend import HttpBackend
from stackit.cdn.models.http_backend_patch import HttpBackendPatch
Expand Down
594 changes: 507 additions & 87 deletions services/cdn/src/stackit/cdn/api/default_api.py

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions services/cdn/src/stackit/cdn/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from stackit.cdn.models.delete_custom_domain_response import DeleteCustomDomainResponse
from stackit.cdn.models.delete_distribution_response import DeleteDistributionResponse
from stackit.cdn.models.distribution import Distribution
from stackit.cdn.models.distribution_logs_record import DistributionLogsRecord
from stackit.cdn.models.distribution_statistics_record import (
DistributionStatisticsRecord,
)
Expand All @@ -35,20 +36,19 @@
)
from stackit.cdn.models.domain import Domain
from stackit.cdn.models.domain_status import DomainStatus
from stackit.cdn.models.error_details import ErrorDetails
from stackit.cdn.models.find_cache_paths_response import FindCachePathsResponse
from stackit.cdn.models.find_cache_paths_response_entry import (
FindCachePathsResponseEntry,
)
from stackit.cdn.models.generic_json_response import GenericJSONResponse
from stackit.cdn.models.generic_json_response_details_inner import (
GenericJSONResponseDetailsInner,
)
from stackit.cdn.models.get_cache_info_response import GetCacheInfoResponse
from stackit.cdn.models.get_cache_info_response_history_entry import (
GetCacheInfoResponseHistoryEntry,
)
from stackit.cdn.models.get_custom_domain_response import GetCustomDomainResponse
from stackit.cdn.models.get_distribution_response import GetDistributionResponse
from stackit.cdn.models.get_logs_response import GetLogsResponse
from stackit.cdn.models.get_statistics_response import GetStatisticsResponse
from stackit.cdn.models.http_backend import HttpBackend
from stackit.cdn.models.http_backend_patch import HttpBackendPatch
Expand Down
25 changes: 23 additions & 2 deletions services/cdn/src/stackit/cdn/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set

from pydantic import BaseModel, ConfigDict, Field
from pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing_extensions import Annotated, Self

from stackit.cdn.models.config_backend import ConfigBackend
Expand All @@ -30,8 +30,21 @@ class Config(BaseModel):
"""

backend: ConfigBackend
blocked_countries: List[StrictStr] = Field(
description="Restricts access to your content based on country. We use the ISO 3166-1 alpha-2 standard for country codes (e.g., DE, ES, GB). This setting blocks users from the specified countries. ",
alias="blockedCountries",
)
blocked_ips: List[StrictStr] = Field(
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",
)
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. ",
alias="monthlyLimitBytes",
)
regions: Annotated[List[Region], Field(min_length=1)]
__properties: ClassVar[List[str]] = ["backend", "regions"]
__properties: ClassVar[List[str]] = ["backend", "blockedCountries", "blockedIPs", "monthlyLimitBytes", "regions"]

model_config = ConfigDict(
populate_by_name=True,
Expand Down Expand Up @@ -73,6 +86,11 @@ 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()
# 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:
_dict["monthlyLimitBytes"] = None

return _dict

@classmethod
Expand All @@ -87,6 +105,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
_obj = cls.model_validate(
{
"backend": ConfigBackend.from_dict(obj["backend"]) if obj.get("backend") is not None else None,
"blockedCountries": obj.get("blockedCountries"),
"blockedIPs": obj.get("blockedIPs"),
"monthlyLimitBytes": obj.get("monthlyLimitBytes"),
"regions": obj.get("regions"),
}
)
Expand Down
27 changes: 25 additions & 2 deletions services/cdn/src/stackit/cdn/models/config_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set

from pydantic import BaseModel, ConfigDict, Field
from pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing_extensions import Annotated, Self

from stackit.cdn.models.config_patch_backend import ConfigPatchBackend
Expand All @@ -30,8 +30,23 @@ class ConfigPatch(BaseModel):
"""

backend: Optional[ConfigPatchBackend] = None
blocked_countries: Optional[List[StrictStr]] = Field(
default=None,
description="Restricts access to your content based on country. We use the ISO 3166-1 alpha-2 standard for country codes (e.g., DE, ES, GB). This setting blocks users from the specified countries. ",
alias="blockedCountries",
)
blocked_ips: Optional[List[StrictStr]] = Field(
default=None,
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",
)
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. ",
alias="monthlyLimitBytes",
)
regions: Optional[Annotated[List[Region], Field(min_length=1)]] = None
__properties: ClassVar[List[str]] = ["backend", "regions"]
__properties: ClassVar[List[str]] = ["backend", "blockedCountries", "blockedIPs", "monthlyLimitBytes", "regions"]

model_config = ConfigDict(
populate_by_name=True,
Expand Down Expand Up @@ -73,6 +88,11 @@ 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()
# 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:
_dict["monthlyLimitBytes"] = None

return _dict

@classmethod
Expand All @@ -87,6 +107,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
_obj = cls.model_validate(
{
"backend": ConfigPatchBackend.from_dict(obj["backend"]) if obj.get("backend") is not None else None,
"blockedCountries": obj.get("blockedCountries"),
"blockedIPs": obj.get("blockedIPs"),
"monthlyLimitBytes": obj.get("monthlyLimitBytes"),
"regions": obj.get("regions"),
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,26 @@ class CreateDistributionPayload(BaseModel):
CreateDistributionPayload
"""

blocked_countries: Optional[List[StrictStr]] = Field(
default=None,
description="Restricts access to your content based on country. We use the ISO 3166-1 alpha-2 standard for country codes (e.g., DE, ES, GB). This setting blocks users from the specified countries. ",
alias="blockedCountries",
)
blocked_ips: Optional[List[StrictStr]] = Field(
default=None,
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",
)
intent_id: Optional[StrictStr] = Field(
default=None,
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",
)
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. ",
alias="monthlyLimitBytes",
)
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 @@ -45,7 +60,15 @@ class CreateDistributionPayload(BaseModel):
regions: Annotated[List[Region], Field(min_length=1)] = Field(
description="Define in which regions you would like your content to be cached. "
)
__properties: ClassVar[List[str]] = ["intentId", "originRequestHeaders", "originUrl", "regions"]
__properties: ClassVar[List[str]] = [
"blockedCountries",
"blockedIPs",
"intentId",
"monthlyLimitBytes",
"originRequestHeaders",
"originUrl",
"regions",
]

model_config = ConfigDict(
populate_by_name=True,
Expand Down Expand Up @@ -97,7 +120,10 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:

_obj = cls.model_validate(
{
"blockedCountries": obj.get("blockedCountries"),
"blockedIPs": obj.get("blockedIPs"),
"intentId": obj.get("intentId"),
"monthlyLimitBytes": obj.get("monthlyLimitBytes"),
"originRequestHeaders": obj.get("originRequestHeaders"),
"originUrl": obj.get("originUrl"),
"regions": obj.get("regions"),
Expand Down
2 changes: 1 addition & 1 deletion services/cdn/src/stackit/cdn/models/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Distribution(BaseModel):
description="- `CREATING`: The distribution was just created. All the relevant resources are created in the background. Once fully reconciled, this switches to `ACTIVE`. If there are any issues, the status changes to `ERROR`. You can look at the `errors` array to get more infos. - `ACTIVE`: The usual state. The desired configuration is synced, there are no errors - `UPDATING`: The state when there is a discrepancy between the desired and actual configuration state. This occurs right after an update. Will switch to `ACTIVE` or `ERROR`, depending on if synchronizing succeeds or not. - `DELETING`: The state right after a delete request was received. The distribution will stay in this status until all resources have been successfully removed, or until we encounter an `ERROR` state. **NOTE:** You can keep fetching the distribution while it is deleting. After successful deletion, trying to get a distribution will return a 404 Not Found response - `ERROR`: The error state. Look at the `errors` array for more info. "
)
updated_at: datetime = Field(
description="RFC3339 string which returns the last time the distribution's configuration was modified. ",
description="RFC3339 string which returns the last time the distribution configuration was modified. ",
alias="updatedAt",
)
__properties: ClassVar[List[str]] = [
Expand Down
114 changes: 114 additions & 0 deletions services/cdn/src/stackit/cdn/models/distribution_logs_record.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# 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 datetime import datetime
from typing import Any, ClassVar, Dict, List, Optional, Set

from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
from typing_extensions import Annotated, Self


class DistributionLogsRecord(BaseModel):
"""
DistributionLogsRecord
"""

cache_hit: StrictBool = Field(alias="cacheHit")
data_center_region: StrictStr = Field(alias="dataCenterRegion")
distribution_id: StrictStr = Field(alias="distributionID")
host: StrictStr
path: StrictStr
request_country_code: Annotated[str, Field(min_length=2, strict=True, max_length=2)] = Field(
description="ISO 3166-1 A2 compliant country code", alias="requestCountryCode"
)
size: Annotated[int, Field(strict=True, ge=0)]
status_code: StrictInt = Field(alias="statusCode")
timestamp: datetime
__properties: ClassVar[List[str]] = [
"cacheHit",
"dataCenterRegion",
"distributionID",
"host",
"path",
"requestCountryCode",
"size",
"statusCode",
"timestamp",
]

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 DistributionLogsRecord 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 DistributionLogsRecord from a dict"""
if obj is None:
return None

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

_obj = cls.model_validate(
{
"cacheHit": obj.get("cacheHit"),
"dataCenterRegion": obj.get("dataCenterRegion"),
"distributionID": obj.get("distributionID"),
"host": obj.get("host"),
"path": obj.get("path"),
"requestCountryCode": obj.get("requestCountryCode"),
"size": obj.get("size"),
"statusCode": obj.get("statusCode"),
"timestamp": obj.get("timestamp"),
}
)
return _obj
Loading
Loading