diff --git a/services/loadbalancer/src/stackit/loadbalancer/__init__.py b/services/loadbalancer/src/stackit/loadbalancer/__init__.py index 6242eb3f..37ec2c5d 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/__init__.py +++ b/services/loadbalancer/src/stackit/loadbalancer/__init__.py @@ -72,6 +72,7 @@ from stackit.loadbalancer.models.options_tcp import OptionsTCP from stackit.loadbalancer.models.options_udp import OptionsUDP from stackit.loadbalancer.models.plan_details import PlanDetails +from stackit.loadbalancer.models.security_group import SecurityGroup from stackit.loadbalancer.models.server_name_indicator import ServerNameIndicator from stackit.loadbalancer.models.session_persistence import SessionPersistence from stackit.loadbalancer.models.status import Status diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/__init__.py b/services/loadbalancer/src/stackit/loadbalancer/models/__init__.py index 5adda514..a04c158f 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/__init__.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/__init__.py @@ -53,6 +53,7 @@ from stackit.loadbalancer.models.options_tcp import OptionsTCP from stackit.loadbalancer.models.options_udp import OptionsUDP from stackit.loadbalancer.models.plan_details import PlanDetails +from stackit.loadbalancer.models.security_group import SecurityGroup from stackit.loadbalancer.models.server_name_indicator import ServerNameIndicator from stackit.loadbalancer.models.session_persistence import SessionPersistence from stackit.loadbalancer.models.status import Status diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/create_load_balancer_payload.py b/services/loadbalancer/src/stackit/loadbalancer/models/create_load_balancer_payload.py index 4b0f8cd2..68470ac9 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/create_load_balancer_payload.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/create_load_balancer_payload.py @@ -25,6 +25,7 @@ from stackit.loadbalancer.models.load_balancer_error import LoadBalancerError from stackit.loadbalancer.models.load_balancer_options import LoadBalancerOptions from stackit.loadbalancer.models.network import Network +from stackit.loadbalancer.models.security_group import SecurityGroup from stackit.loadbalancer.models.target_pool import TargetPool @@ -70,6 +71,11 @@ class CreateLoadBalancerPayload(BaseModel): description="List of all target pools which will be used in the load balancer. Limited to 20.", alias="targetPools", ) + target_security_group: Optional[SecurityGroup] = Field( + default=None, + description="Security Group permitting network traffic from the LoadBalancer to the targets.", + alias="targetSecurityGroup", + ) version: Optional[StrictStr] = Field( default=None, description="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 load balancer resource that changes during updates of the load balancers. On updates this field specified the 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 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 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.", @@ -86,6 +92,7 @@ class CreateLoadBalancerPayload(BaseModel): "region", "status", "targetPools", + "targetSecurityGroup", "version", ] @@ -146,6 +153,7 @@ def to_dict(self) -> Dict[str, Any]: * OpenAPI `readOnly` fields are excluded. * OpenAPI `readOnly` fields are excluded. * OpenAPI `readOnly` fields are excluded. + * OpenAPI `readOnly` fields are excluded. """ excluded_fields: Set[str] = set( [ @@ -153,6 +161,7 @@ def to_dict(self) -> Dict[str, Any]: "private_address", "region", "status", + "target_security_group", ] ) @@ -192,6 +201,9 @@ def to_dict(self) -> Dict[str, Any]: if _item: _items.append(_item.to_dict()) _dict["targetPools"] = _items + # override the default output from pydantic by calling `to_dict()` of target_security_group + if self.target_security_group: + _dict["targetSecurityGroup"] = self.target_security_group.to_dict() return _dict @classmethod @@ -230,6 +242,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if obj.get("targetPools") is not None else None ), + "targetSecurityGroup": ( + SecurityGroup.from_dict(obj["targetSecurityGroup"]) + if obj.get("targetSecurityGroup") is not None + else None + ), "version": obj.get("version"), } ) diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer.py b/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer.py index edd3cdb2..4dc76d84 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer.py @@ -25,6 +25,7 @@ from stackit.loadbalancer.models.load_balancer_error import LoadBalancerError from stackit.loadbalancer.models.load_balancer_options import LoadBalancerOptions from stackit.loadbalancer.models.network import Network +from stackit.loadbalancer.models.security_group import SecurityGroup from stackit.loadbalancer.models.target_pool import TargetPool @@ -70,6 +71,11 @@ class LoadBalancer(BaseModel): description="List of all target pools which will be used in the load balancer. Limited to 20.", alias="targetPools", ) + target_security_group: Optional[SecurityGroup] = Field( + default=None, + description="Security Group permitting network traffic from the LoadBalancer to the targets.", + alias="targetSecurityGroup", + ) version: Optional[StrictStr] = Field( default=None, description="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 load balancer resource that changes during updates of the load balancers. On updates this field specified the 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 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 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.", @@ -86,6 +92,7 @@ class LoadBalancer(BaseModel): "region", "status", "targetPools", + "targetSecurityGroup", "version", ] @@ -146,6 +153,7 @@ def to_dict(self) -> Dict[str, Any]: * OpenAPI `readOnly` fields are excluded. * OpenAPI `readOnly` fields are excluded. * OpenAPI `readOnly` fields are excluded. + * OpenAPI `readOnly` fields are excluded. """ excluded_fields: Set[str] = set( [ @@ -153,6 +161,7 @@ def to_dict(self) -> Dict[str, Any]: "private_address", "region", "status", + "target_security_group", ] ) @@ -192,6 +201,9 @@ def to_dict(self) -> Dict[str, Any]: if _item: _items.append(_item.to_dict()) _dict["targetPools"] = _items + # override the default output from pydantic by calling `to_dict()` of target_security_group + if self.target_security_group: + _dict["targetSecurityGroup"] = self.target_security_group.to_dict() return _dict @classmethod @@ -230,6 +242,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if obj.get("targetPools") is not None else None ), + "targetSecurityGroup": ( + SecurityGroup.from_dict(obj["targetSecurityGroup"]) + if obj.get("targetSecurityGroup") is not None + else None + ), "version": obj.get("version"), } ) diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/security_group.py b/services/loadbalancer/src/stackit/loadbalancer/models/security_group.py new file mode 100644 index 00000000..205abe03 --- /dev/null +++ b/services/loadbalancer/src/stackit/loadbalancer/models/security_group.py @@ -0,0 +1,82 @@ +# coding: utf-8 + +""" + 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 load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + + The version of the OpenAPI document: 2.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 SecurityGroup(BaseModel): + """ + SecurityGroup + """ + + id: Optional[StrictStr] = Field(default=None, description="ID of the security Group") + name: Optional[StrictStr] = Field(default=None, description="Name of the security Group") + __properties: ClassVar[List[str]] = ["id", "name"] + + 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 SecurityGroup 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 SecurityGroup from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"id": obj.get("id"), "name": obj.get("name")}) + return _obj diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/update_load_balancer_payload.py b/services/loadbalancer/src/stackit/loadbalancer/models/update_load_balancer_payload.py index 3ade60ce..d4d324d2 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/update_load_balancer_payload.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/update_load_balancer_payload.py @@ -25,6 +25,7 @@ from stackit.loadbalancer.models.load_balancer_error import LoadBalancerError from stackit.loadbalancer.models.load_balancer_options import LoadBalancerOptions from stackit.loadbalancer.models.network import Network +from stackit.loadbalancer.models.security_group import SecurityGroup from stackit.loadbalancer.models.target_pool import TargetPool @@ -70,6 +71,11 @@ class UpdateLoadBalancerPayload(BaseModel): description="List of all target pools which will be used in the load balancer. Limited to 20.", alias="targetPools", ) + target_security_group: Optional[SecurityGroup] = Field( + default=None, + description="Security Group permitting network traffic from the LoadBalancer to the targets.", + alias="targetSecurityGroup", + ) version: Optional[StrictStr] = Field( default=None, description="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 load balancer resource that changes during updates of the load balancers. On updates this field specified the 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 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 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.", @@ -86,6 +92,7 @@ class UpdateLoadBalancerPayload(BaseModel): "region", "status", "targetPools", + "targetSecurityGroup", "version", ] @@ -146,6 +153,7 @@ def to_dict(self) -> Dict[str, Any]: * OpenAPI `readOnly` fields are excluded. * OpenAPI `readOnly` fields are excluded. * OpenAPI `readOnly` fields are excluded. + * OpenAPI `readOnly` fields are excluded. """ excluded_fields: Set[str] = set( [ @@ -153,6 +161,7 @@ def to_dict(self) -> Dict[str, Any]: "private_address", "region", "status", + "target_security_group", ] ) @@ -192,6 +201,9 @@ def to_dict(self) -> Dict[str, Any]: if _item: _items.append(_item.to_dict()) _dict["targetPools"] = _items + # override the default output from pydantic by calling `to_dict()` of target_security_group + if self.target_security_group: + _dict["targetSecurityGroup"] = self.target_security_group.to_dict() return _dict @classmethod @@ -230,6 +242,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if obj.get("targetPools") is not None else None ), + "targetSecurityGroup": ( + SecurityGroup.from_dict(obj["targetSecurityGroup"]) + if obj.get("targetSecurityGroup") is not None + else None + ), "version": obj.get("version"), } )