Skip to content

Commit 5282ccd

Browse files
Generate alb
1 parent 415d2dc commit 5282ccd

File tree

4 files changed

+98
-1
lines changed

4 files changed

+98
-1
lines changed

services/alb/src/stackit/alb/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
LoadbalancerOptionObservability,
6363
)
6464
from stackit.alb.models.network import Network
65+
from stackit.alb.models.path import Path
6566
from stackit.alb.models.plan_details import PlanDetails
6667
from stackit.alb.models.protocol_options_http import ProtocolOptionsHTTP
6768
from stackit.alb.models.protocol_options_https import ProtocolOptionsHTTPS

services/alb/src/stackit/alb/models/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
LoadbalancerOptionObservability,
4444
)
4545
from stackit.alb.models.network import Network
46+
from stackit.alb.models.path import Path
4647
from stackit.alb.models.plan_details import PlanDetails
4748
from stackit.alb.models.protocol_options_http import ProtocolOptionsHTTP
4849
from stackit.alb.models.protocol_options_https import ProtocolOptionsHTTPS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# coding: utf-8
2+
3+
"""
4+
Application Load Balancer API
5+
6+
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.
7+
8+
The version of the OpenAPI document: 2beta2.0.0
9+
Generated by OpenAPI Generator (https://openapi-generator.tech)
10+
11+
Do not edit the class manually.
12+
""" # noqa: E501 docstring might be too long
13+
14+
from __future__ import annotations
15+
16+
import json
17+
import pprint
18+
from typing import Any, ClassVar, Dict, List, Optional, Set
19+
20+
from pydantic import BaseModel, ConfigDict, Field, StrictStr
21+
from typing_extensions import Self
22+
23+
24+
class Path(BaseModel):
25+
"""
26+
Path
27+
"""
28+
29+
exact: Optional[StrictStr] = Field(
30+
default=None,
31+
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'.",
32+
)
33+
prefix: Optional[StrictStr] = Field(
34+
default=None,
35+
description="Prefix path match. Only matches on full segment boundaries, e.g. '/foo' matches '/foo' and '/foo/bar' but NOT '/foobar'.",
36+
)
37+
__properties: ClassVar[List[str]] = ["exact", "prefix"]
38+
39+
model_config = ConfigDict(
40+
populate_by_name=True,
41+
validate_assignment=True,
42+
protected_namespaces=(),
43+
)
44+
45+
def to_str(self) -> str:
46+
"""Returns the string representation of the model using alias"""
47+
return pprint.pformat(self.model_dump(by_alias=True))
48+
49+
def to_json(self) -> str:
50+
"""Returns the JSON representation of the model using alias"""
51+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
52+
return json.dumps(self.to_dict())
53+
54+
@classmethod
55+
def from_json(cls, json_str: str) -> Optional[Self]:
56+
"""Create an instance of Path from a JSON string"""
57+
return cls.from_dict(json.loads(json_str))
58+
59+
def to_dict(self) -> Dict[str, Any]:
60+
"""Return the dictionary representation of the model using alias.
61+
62+
This has the following differences from calling pydantic's
63+
`self.model_dump(by_alias=True)`:
64+
65+
* `None` is only added to the output dict for nullable fields that
66+
were set at model initialization. Other fields with value `None`
67+
are ignored.
68+
"""
69+
excluded_fields: Set[str] = set([])
70+
71+
_dict = self.model_dump(
72+
by_alias=True,
73+
exclude=excluded_fields,
74+
exclude_none=True,
75+
)
76+
return _dict
77+
78+
@classmethod
79+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
80+
"""Create an instance of Path from a dict"""
81+
if obj is None:
82+
return None
83+
84+
if not isinstance(obj, dict):
85+
return cls.model_validate(obj)
86+
87+
_obj = cls.model_validate({"exact": obj.get("exact"), "prefix": obj.get("prefix")})
88+
return _obj

services/alb/src/stackit/alb/models/rule.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
from stackit.alb.models.cookie_persistence import CookiePersistence
2424
from stackit.alb.models.http_header import HttpHeader
25+
from stackit.alb.models.path import Path
2526
from stackit.alb.models.query_parameter import QueryParameter
2627

2728

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

3334
cookie_persistence: Optional[CookiePersistence] = Field(default=None, alias="cookiePersistence")
3435
headers: Optional[List[HttpHeader]] = Field(default=None, description="Headers for the rule.")
36+
path: Optional[Path] = None
3537
path_prefix: Optional[StrictStr] = Field(
3638
default=None,
37-
description="Path prefix for the rule. If empty or '/', it matches the root path.",
39+
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'.",
3840
alias="pathPrefix",
3941
)
4042
query_parameters: Optional[List[QueryParameter]] = Field(
@@ -51,6 +53,7 @@ class Rule(BaseModel):
5153
__properties: ClassVar[List[str]] = [
5254
"cookiePersistence",
5355
"headers",
56+
"path",
5457
"pathPrefix",
5558
"queryParameters",
5659
"targetPool",
@@ -104,6 +107,9 @@ def to_dict(self) -> Dict[str, Any]:
104107
if _item:
105108
_items.append(_item.to_dict())
106109
_dict["headers"] = _items
110+
# override the default output from pydantic by calling `to_dict()` of path
111+
if self.path:
112+
_dict["path"] = self.path.to_dict()
107113
# override the default output from pydantic by calling `to_dict()` of each item in query_parameters (list)
108114
_items = []
109115
if self.query_parameters:
@@ -134,6 +140,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
134140
if obj.get("headers") is not None
135141
else None
136142
),
143+
"path": Path.from_dict(obj["path"]) if obj.get("path") is not None else None,
137144
"pathPrefix": obj.get("pathPrefix"),
138145
"queryParameters": (
139146
[QueryParameter.from_dict(_item) for _item in obj["queryParameters"]]

0 commit comments

Comments
 (0)