Skip to content

Generator: Update SDK /services/alb #1177

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

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions services/alb/src/stackit/alb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
LoadbalancerOptionObservability,
)
from stackit.alb.models.network import Network
from stackit.alb.models.path import Path
from stackit.alb.models.plan_details import PlanDetails
from stackit.alb.models.protocol_options_http import ProtocolOptionsHTTP
from stackit.alb.models.protocol_options_https import ProtocolOptionsHTTPS
Expand Down
1 change: 1 addition & 0 deletions services/alb/src/stackit/alb/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
LoadbalancerOptionObservability,
)
from stackit.alb.models.network import Network
from stackit.alb.models.path import Path
from stackit.alb.models.plan_details import PlanDetails
from stackit.alb.models.protocol_options_http import ProtocolOptionsHTTP
from stackit.alb.models.protocol_options_https import ProtocolOptionsHTTPS
Expand Down
88 changes: 88 additions & 0 deletions services/alb/src/stackit/alb/models/path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# coding: utf-8

"""
Application Load Balancer API

This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each application load balancer provided, two VMs are deployed in your OpenStack project subject to a fee.

The version of the OpenAPI document: 2beta2.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, StrictStr
from typing_extensions import Self


class Path(BaseModel):
"""
Path
"""

exact: Optional[StrictStr] = Field(
default=None,
description="Exact path match. Only a request path exactly equal to the value will match, e.g. '/foo' matches only '/foo', not '/foo/bar' or '/foobar'.",
)
prefix: Optional[StrictStr] = Field(
default=None,
description="Prefix path match. Only matches on full segment boundaries, e.g. '/foo' matches '/foo' and '/foo/bar' but NOT '/foobar'.",
)
__properties: ClassVar[List[str]] = ["exact", "prefix"]

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

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

_obj = cls.model_validate({"exact": obj.get("exact"), "prefix": obj.get("prefix")})
return _obj
9 changes: 8 additions & 1 deletion services/alb/src/stackit/alb/models/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

from stackit.alb.models.cookie_persistence import CookiePersistence
from stackit.alb.models.http_header import HttpHeader
from stackit.alb.models.path import Path
from stackit.alb.models.query_parameter import QueryParameter


Expand All @@ -32,9 +33,10 @@ class Rule(BaseModel):

cookie_persistence: Optional[CookiePersistence] = Field(default=None, alias="cookiePersistence")
headers: Optional[List[HttpHeader]] = Field(default=None, description="Headers for the rule.")
path: Optional[Path] = None
path_prefix: Optional[StrictStr] = Field(
default=None,
description="Path prefix for the rule. If empty or '/', it matches the root path.",
description="Legacy path prefix match. Optional. If not set, defaults to root path '/'. Cannot be set if 'path' is used. Prefer using 'path.prefix' instead. Only matches on full segment boundaries, e.g. '/foo' matches '/foo' and '/foo/bar' but NOT '/foobar'.",
alias="pathPrefix",
)
query_parameters: Optional[List[QueryParameter]] = Field(
Expand All @@ -51,6 +53,7 @@ class Rule(BaseModel):
__properties: ClassVar[List[str]] = [
"cookiePersistence",
"headers",
"path",
"pathPrefix",
"queryParameters",
"targetPool",
Expand Down Expand Up @@ -104,6 +107,9 @@ def to_dict(self) -> Dict[str, Any]:
if _item:
_items.append(_item.to_dict())
_dict["headers"] = _items
# override the default output from pydantic by calling `to_dict()` of path
if self.path:
_dict["path"] = self.path.to_dict()
# override the default output from pydantic by calling `to_dict()` of each item in query_parameters (list)
_items = []
if self.query_parameters:
Expand Down Expand Up @@ -134,6 +140,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
if obj.get("headers") is not None
else None
),
"path": Path.from_dict(obj["path"]) if obj.get("path") is not None else None,
"pathPrefix": obj.get("pathPrefix"),
"queryParameters": (
[QueryParameter.from_dict(_item) for _item in obj["queryParameters"]]
Expand Down
Loading