Skip to content

Commit e0f51d8

Browse files
Generate alb
1 parent 8f71ab5 commit e0f51d8

File tree

6 files changed

+180
-3
lines changed

6 files changed

+180
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
from stackit.alb.models.protocol_options_https import ProtocolOptionsHTTPS
6969
from stackit.alb.models.query_parameter import QueryParameter
7070
from stackit.alb.models.rule import Rule
71+
from stackit.alb.models.security_group import SecurityGroup
7172
from stackit.alb.models.status import Status
7273
from stackit.alb.models.target import Target
7374
from stackit.alb.models.target_pool import TargetPool

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
from stackit.alb.models.protocol_options_https import ProtocolOptionsHTTPS
5050
from stackit.alb.models.query_parameter import QueryParameter
5151
from stackit.alb.models.rule import Rule
52+
from stackit.alb.models.security_group import SecurityGroup
5253
from stackit.alb.models.status import Status
5354
from stackit.alb.models.target import Target
5455
from stackit.alb.models.target_pool import TargetPool

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

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,21 @@
1818
import re
1919
from typing import Any, ClassVar, Dict, List, Optional, Set
2020

21-
from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
21+
from pydantic import (
22+
BaseModel,
23+
ConfigDict,
24+
Field,
25+
StrictBool,
26+
StrictStr,
27+
field_validator,
28+
)
2229
from typing_extensions import Annotated, Self
2330

2431
from stackit.alb.models.listener import Listener
2532
from stackit.alb.models.load_balancer_error import LoadBalancerError
2633
from stackit.alb.models.load_balancer_options import LoadBalancerOptions
2734
from stackit.alb.models.network import Network
35+
from stackit.alb.models.security_group import SecurityGroup
2836
from stackit.alb.models.target_pool import TargetPool
2937

3038

@@ -33,6 +41,11 @@ class CreateLoadBalancerPayload(BaseModel):
3341
CreateLoadBalancerPayload
3442
"""
3543

44+
disable_target_security_group_assignment: Optional[StrictBool] = Field(
45+
default=None,
46+
description="Disable target security group assignemt to allow targets outside of the given network. Connectivity to targets need to be ensured by the customer, including routing and Security Groups (targetSecurityGroup can be assigned). Not changeable after creation.",
47+
alias="disableTargetSecurityGroupAssignment",
48+
)
3649
errors: Optional[List[LoadBalancerError]] = Field(
3750
default=None, description="Reports all errors a application load balancer has."
3851
)
@@ -67,11 +80,17 @@ class CreateLoadBalancerPayload(BaseModel):
6780
description="List of all target pools which will be used in the application load balancer. Limited to 20.",
6881
alias="targetPools",
6982
)
83+
target_security_group: Optional[SecurityGroup] = Field(
84+
default=None,
85+
description="Security Group permitting network traffic from the LoadBalancer to the targets. Useful when disableTargetSecurityGroupAssignment=true to manually assign target security groups to targets.",
86+
alias="targetSecurityGroup",
87+
)
7088
version: Optional[StrictStr] = Field(
7189
default=None,
7290
description="Application Load Balancer resource version. Must be empty or unset for creating load balancers, non-empty for updating load balancers. Semantics: While retrieving load balancers, this is the current version of this application load balancer resource that changes during updates of the load balancers. On updates this field specified the application load balancer version you calculated your update for instead of the future version to enable concurrency safe updates. Update calls will then report the new version in their result as you would see with a application load balancer retrieval call later. There exist no total order of the version, so you can only compare it for equality, but not for less/greater than another version. Since the creation of application load balancer is always intended to create the first version of it, there should be no existing version. That's why this field must by empty of not present in that case.",
7391
)
7492
__properties: ClassVar[List[str]] = [
93+
"disableTargetSecurityGroupAssignment",
7594
"errors",
7695
"externalAddress",
7796
"listeners",
@@ -83,6 +102,7 @@ class CreateLoadBalancerPayload(BaseModel):
83102
"region",
84103
"status",
85104
"targetPools",
105+
"targetSecurityGroup",
86106
"version",
87107
]
88108

@@ -143,13 +163,15 @@ def to_dict(self) -> Dict[str, Any]:
143163
* OpenAPI `readOnly` fields are excluded.
144164
* OpenAPI `readOnly` fields are excluded.
145165
* OpenAPI `readOnly` fields are excluded.
166+
* OpenAPI `readOnly` fields are excluded.
146167
"""
147168
excluded_fields: Set[str] = set(
148169
[
149170
"errors",
150171
"private_address",
151172
"region",
152173
"status",
174+
"target_security_group",
153175
]
154176
)
155177

@@ -189,6 +211,9 @@ def to_dict(self) -> Dict[str, Any]:
189211
if _item:
190212
_items.append(_item.to_dict())
191213
_dict["targetPools"] = _items
214+
# override the default output from pydantic by calling `to_dict()` of target_security_group
215+
if self.target_security_group:
216+
_dict["targetSecurityGroup"] = self.target_security_group.to_dict()
192217
return _dict
193218

194219
@classmethod
@@ -202,6 +227,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
202227

203228
_obj = cls.model_validate(
204229
{
230+
"disableTargetSecurityGroupAssignment": obj.get("disableTargetSecurityGroupAssignment"),
205231
"errors": (
206232
[LoadBalancerError.from_dict(_item) for _item in obj["errors"]]
207233
if obj.get("errors") is not None
@@ -227,6 +253,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
227253
if obj.get("targetPools") is not None
228254
else None
229255
),
256+
"targetSecurityGroup": (
257+
SecurityGroup.from_dict(obj["targetSecurityGroup"])
258+
if obj.get("targetSecurityGroup") is not None
259+
else None
260+
),
230261
"version": obj.get("version"),
231262
}
232263
)

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

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,21 @@
1818
import re
1919
from typing import Any, ClassVar, Dict, List, Optional, Set
2020

21-
from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
21+
from pydantic import (
22+
BaseModel,
23+
ConfigDict,
24+
Field,
25+
StrictBool,
26+
StrictStr,
27+
field_validator,
28+
)
2229
from typing_extensions import Annotated, Self
2330

2431
from stackit.alb.models.listener import Listener
2532
from stackit.alb.models.load_balancer_error import LoadBalancerError
2633
from stackit.alb.models.load_balancer_options import LoadBalancerOptions
2734
from stackit.alb.models.network import Network
35+
from stackit.alb.models.security_group import SecurityGroup
2836
from stackit.alb.models.target_pool import TargetPool
2937

3038

@@ -33,6 +41,11 @@ class LoadBalancer(BaseModel):
3341
LoadBalancer
3442
"""
3543

44+
disable_target_security_group_assignment: Optional[StrictBool] = Field(
45+
default=None,
46+
description="Disable target security group assignemt to allow targets outside of the given network. Connectivity to targets need to be ensured by the customer, including routing and Security Groups (targetSecurityGroup can be assigned). Not changeable after creation.",
47+
alias="disableTargetSecurityGroupAssignment",
48+
)
3649
errors: Optional[List[LoadBalancerError]] = Field(
3750
default=None, description="Reports all errors a application load balancer has."
3851
)
@@ -67,11 +80,17 @@ class LoadBalancer(BaseModel):
6780
description="List of all target pools which will be used in the application load balancer. Limited to 20.",
6881
alias="targetPools",
6982
)
83+
target_security_group: Optional[SecurityGroup] = Field(
84+
default=None,
85+
description="Security Group permitting network traffic from the LoadBalancer to the targets. Useful when disableTargetSecurityGroupAssignment=true to manually assign target security groups to targets.",
86+
alias="targetSecurityGroup",
87+
)
7088
version: Optional[StrictStr] = Field(
7189
default=None,
7290
description="Application Load Balancer resource version. Must be empty or unset for creating load balancers, non-empty for updating load balancers. Semantics: While retrieving load balancers, this is the current version of this application load balancer resource that changes during updates of the load balancers. On updates this field specified the application load balancer version you calculated your update for instead of the future version to enable concurrency safe updates. Update calls will then report the new version in their result as you would see with a application load balancer retrieval call later. There exist no total order of the version, so you can only compare it for equality, but not for less/greater than another version. Since the creation of application load balancer is always intended to create the first version of it, there should be no existing version. That's why this field must by empty of not present in that case.",
7391
)
7492
__properties: ClassVar[List[str]] = [
93+
"disableTargetSecurityGroupAssignment",
7594
"errors",
7695
"externalAddress",
7796
"listeners",
@@ -83,6 +102,7 @@ class LoadBalancer(BaseModel):
83102
"region",
84103
"status",
85104
"targetPools",
105+
"targetSecurityGroup",
86106
"version",
87107
]
88108

@@ -143,13 +163,15 @@ def to_dict(self) -> Dict[str, Any]:
143163
* OpenAPI `readOnly` fields are excluded.
144164
* OpenAPI `readOnly` fields are excluded.
145165
* OpenAPI `readOnly` fields are excluded.
166+
* OpenAPI `readOnly` fields are excluded.
146167
"""
147168
excluded_fields: Set[str] = set(
148169
[
149170
"errors",
150171
"private_address",
151172
"region",
152173
"status",
174+
"target_security_group",
153175
]
154176
)
155177

@@ -189,6 +211,9 @@ def to_dict(self) -> Dict[str, Any]:
189211
if _item:
190212
_items.append(_item.to_dict())
191213
_dict["targetPools"] = _items
214+
# override the default output from pydantic by calling `to_dict()` of target_security_group
215+
if self.target_security_group:
216+
_dict["targetSecurityGroup"] = self.target_security_group.to_dict()
192217
return _dict
193218

194219
@classmethod
@@ -202,6 +227,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
202227

203228
_obj = cls.model_validate(
204229
{
230+
"disableTargetSecurityGroupAssignment": obj.get("disableTargetSecurityGroupAssignment"),
205231
"errors": (
206232
[LoadBalancerError.from_dict(_item) for _item in obj["errors"]]
207233
if obj.get("errors") is not None
@@ -227,6 +253,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
227253
if obj.get("targetPools") is not None
228254
else None
229255
),
256+
"targetSecurityGroup": (
257+
SecurityGroup.from_dict(obj["targetSecurityGroup"])
258+
if obj.get("targetSecurityGroup") is not None
259+
else None
260+
),
230261
"version": obj.get("version"),
231262
}
232263
)
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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 SecurityGroup(BaseModel):
25+
"""
26+
SecurityGroup
27+
"""
28+
29+
id: Optional[StrictStr] = Field(default=None, description="ID of the security Group")
30+
name: Optional[StrictStr] = Field(default=None, description="Name of the security Group")
31+
__properties: ClassVar[List[str]] = ["id", "name"]
32+
33+
model_config = ConfigDict(
34+
populate_by_name=True,
35+
validate_assignment=True,
36+
protected_namespaces=(),
37+
)
38+
39+
def to_str(self) -> str:
40+
"""Returns the string representation of the model using alias"""
41+
return pprint.pformat(self.model_dump(by_alias=True))
42+
43+
def to_json(self) -> str:
44+
"""Returns the JSON representation of the model using alias"""
45+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
46+
return json.dumps(self.to_dict())
47+
48+
@classmethod
49+
def from_json(cls, json_str: str) -> Optional[Self]:
50+
"""Create an instance of SecurityGroup from a JSON string"""
51+
return cls.from_dict(json.loads(json_str))
52+
53+
def to_dict(self) -> Dict[str, Any]:
54+
"""Return the dictionary representation of the model using alias.
55+
56+
This has the following differences from calling pydantic's
57+
`self.model_dump(by_alias=True)`:
58+
59+
* `None` is only added to the output dict for nullable fields that
60+
were set at model initialization. Other fields with value `None`
61+
are ignored.
62+
"""
63+
excluded_fields: Set[str] = set([])
64+
65+
_dict = self.model_dump(
66+
by_alias=True,
67+
exclude=excluded_fields,
68+
exclude_none=True,
69+
)
70+
return _dict
71+
72+
@classmethod
73+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
74+
"""Create an instance of SecurityGroup from a dict"""
75+
if obj is None:
76+
return None
77+
78+
if not isinstance(obj, dict):
79+
return cls.model_validate(obj)
80+
81+
_obj = cls.model_validate({"id": obj.get("id"), "name": obj.get("name")})
82+
return _obj

0 commit comments

Comments
 (0)