diff --git a/CHANGELOG.md b/CHANGELOG.md index 928ab448..f6282978 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## Release (2025-XX-YY) - `core`: [v0.2.0](core/CHANGELOG.md#v020-2025-06-12) - **Feature:** Allow setting custom token endpoint url in configuration +- `alb`: [v0.3.0](services/alb/CHANGELOG.md#v030-2025-06-12) + - **Feature:** Add new fields `disable_target_security_group_assignment` and `target_security_group` in `LoadBalancer`, `CreateLoadBalancerPayload` and `UpdateLoadBalancerPayload` Models - `iaas`: [v0.5.3](services/iaas/CHANGELOG.md#v053-2025-06-12) - Increase max length of description from 127 to 255 for - Security groups: `BaseSecurityGroupRule`, `CreateSecurityGroupPayload`, `CreateSecurityGroupRulePayload`, `SecurityGroup`, `SecurityGroupRule`, `UpdateSecurityGroupPayload` diff --git a/services/alb/CHANGELOG.md b/services/alb/CHANGELOG.md index 680d3425..1a5696c9 100644 --- a/services/alb/CHANGELOG.md +++ b/services/alb/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.3.0 (2025-06-12) +- **Feature:** Add new fields `disable_target_security_group_assignment` and `target_security_group` in `LoadBalancer`, `CreateLoadBalancerPayload` and `UpdateLoadBalancerPayload` Models + ## v0.2.1 (2025-06-02) - **Improvement:** Adjusted `GetQuotaResponse` and `RESTResponseType` message diff --git a/services/alb/pyproject.toml b/services/alb/pyproject.toml index d14ba501..7f45c13e 100644 --- a/services/alb/pyproject.toml +++ b/services/alb/pyproject.toml @@ -3,7 +3,7 @@ name = "stackit-alb" [tool.poetry] name = "stackit-alb" -version = "v0.2.1" +version = "v0.3.0" authors = [ "STACKIT Developer Tools ", ] @@ -105,4 +105,4 @@ per-file-ignores = """ # E501: long descriptions/string values might lead to lines that are too long # B028: stacklevel for deprecation warning is irrelevant ./src/stackit/*/api/default_api.py: F841,B028,E501 -""" \ No newline at end of file +""" diff --git a/services/alb/src/stackit/alb/__init__.py b/services/alb/src/stackit/alb/__init__.py index 71e37e80..d9b53c72 100644 --- a/services/alb/src/stackit/alb/__init__.py +++ b/services/alb/src/stackit/alb/__init__.py @@ -68,6 +68,7 @@ from stackit.alb.models.protocol_options_https import ProtocolOptionsHTTPS from stackit.alb.models.query_parameter import QueryParameter from stackit.alb.models.rule import Rule +from stackit.alb.models.security_group import SecurityGroup from stackit.alb.models.status import Status from stackit.alb.models.target import Target from stackit.alb.models.target_pool import TargetPool diff --git a/services/alb/src/stackit/alb/models/__init__.py b/services/alb/src/stackit/alb/models/__init__.py index 55bedd8d..8d47f4fd 100644 --- a/services/alb/src/stackit/alb/models/__init__.py +++ b/services/alb/src/stackit/alb/models/__init__.py @@ -49,6 +49,7 @@ from stackit.alb.models.protocol_options_https import ProtocolOptionsHTTPS from stackit.alb.models.query_parameter import QueryParameter from stackit.alb.models.rule import Rule +from stackit.alb.models.security_group import SecurityGroup from stackit.alb.models.status import Status from stackit.alb.models.target import Target from stackit.alb.models.target_pool import TargetPool diff --git a/services/alb/src/stackit/alb/models/create_load_balancer_payload.py b/services/alb/src/stackit/alb/models/create_load_balancer_payload.py index ed4d2ffb..a3c180fa 100644 --- a/services/alb/src/stackit/alb/models/create_load_balancer_payload.py +++ b/services/alb/src/stackit/alb/models/create_load_balancer_payload.py @@ -18,13 +18,21 @@ import re from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictStr, + field_validator, +) from typing_extensions import Annotated, Self from stackit.alb.models.listener import Listener from stackit.alb.models.load_balancer_error import LoadBalancerError from stackit.alb.models.load_balancer_options import LoadBalancerOptions from stackit.alb.models.network import Network +from stackit.alb.models.security_group import SecurityGroup from stackit.alb.models.target_pool import TargetPool @@ -33,6 +41,11 @@ class CreateLoadBalancerPayload(BaseModel): CreateLoadBalancerPayload """ + disable_target_security_group_assignment: Optional[StrictBool] = Field( + default=None, + 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.", + alias="disableTargetSecurityGroupAssignment", + ) errors: Optional[List[LoadBalancerError]] = Field( default=None, description="Reports all errors a application load balancer has." ) @@ -67,11 +80,17 @@ class CreateLoadBalancerPayload(BaseModel): description="List of all target pools which will be used in the application 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. Useful when disableTargetSecurityGroupAssignment=true to manually assign target security groups to targets.", + alias="targetSecurityGroup", + ) version: Optional[StrictStr] = Field( default=None, 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.", ) __properties: ClassVar[List[str]] = [ + "disableTargetSecurityGroupAssignment", "errors", "externalAddress", "listeners", @@ -83,6 +102,7 @@ class CreateLoadBalancerPayload(BaseModel): "region", "status", "targetPools", + "targetSecurityGroup", "version", ] @@ -143,6 +163,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( [ @@ -150,6 +171,7 @@ def to_dict(self) -> Dict[str, Any]: "private_address", "region", "status", + "target_security_group", ] ) @@ -189,6 +211,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 @@ -202,6 +227,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate( { + "disableTargetSecurityGroupAssignment": obj.get("disableTargetSecurityGroupAssignment"), "errors": ( [LoadBalancerError.from_dict(_item) for _item in obj["errors"]] if obj.get("errors") is not None @@ -227,6 +253,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/alb/src/stackit/alb/models/load_balancer.py b/services/alb/src/stackit/alb/models/load_balancer.py index ac523d33..b174e34b 100644 --- a/services/alb/src/stackit/alb/models/load_balancer.py +++ b/services/alb/src/stackit/alb/models/load_balancer.py @@ -18,13 +18,21 @@ import re from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictStr, + field_validator, +) from typing_extensions import Annotated, Self from stackit.alb.models.listener import Listener from stackit.alb.models.load_balancer_error import LoadBalancerError from stackit.alb.models.load_balancer_options import LoadBalancerOptions from stackit.alb.models.network import Network +from stackit.alb.models.security_group import SecurityGroup from stackit.alb.models.target_pool import TargetPool @@ -33,6 +41,11 @@ class LoadBalancer(BaseModel): LoadBalancer """ + disable_target_security_group_assignment: Optional[StrictBool] = Field( + default=None, + 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.", + alias="disableTargetSecurityGroupAssignment", + ) errors: Optional[List[LoadBalancerError]] = Field( default=None, description="Reports all errors a application load balancer has." ) @@ -67,11 +80,17 @@ class LoadBalancer(BaseModel): description="List of all target pools which will be used in the application 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. Useful when disableTargetSecurityGroupAssignment=true to manually assign target security groups to targets.", + alias="targetSecurityGroup", + ) version: Optional[StrictStr] = Field( default=None, 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.", ) __properties: ClassVar[List[str]] = [ + "disableTargetSecurityGroupAssignment", "errors", "externalAddress", "listeners", @@ -83,6 +102,7 @@ class LoadBalancer(BaseModel): "region", "status", "targetPools", + "targetSecurityGroup", "version", ] @@ -143,6 +163,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( [ @@ -150,6 +171,7 @@ def to_dict(self) -> Dict[str, Any]: "private_address", "region", "status", + "target_security_group", ] ) @@ -189,6 +211,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 @@ -202,6 +227,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate( { + "disableTargetSecurityGroupAssignment": obj.get("disableTargetSecurityGroupAssignment"), "errors": ( [LoadBalancerError.from_dict(_item) for _item in obj["errors"]] if obj.get("errors") is not None @@ -227,6 +253,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/alb/src/stackit/alb/models/security_group.py b/services/alb/src/stackit/alb/models/security_group.py new file mode 100644 index 00000000..3aecdffd --- /dev/null +++ b/services/alb/src/stackit/alb/models/security_group.py @@ -0,0 +1,82 @@ +# 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 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/alb/src/stackit/alb/models/update_load_balancer_payload.py b/services/alb/src/stackit/alb/models/update_load_balancer_payload.py index 543e5d59..fec9cdd2 100644 --- a/services/alb/src/stackit/alb/models/update_load_balancer_payload.py +++ b/services/alb/src/stackit/alb/models/update_load_balancer_payload.py @@ -18,13 +18,21 @@ import re from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictStr, + field_validator, +) from typing_extensions import Annotated, Self from stackit.alb.models.listener import Listener from stackit.alb.models.load_balancer_error import LoadBalancerError from stackit.alb.models.load_balancer_options import LoadBalancerOptions from stackit.alb.models.network import Network +from stackit.alb.models.security_group import SecurityGroup from stackit.alb.models.target_pool import TargetPool @@ -33,6 +41,11 @@ class UpdateLoadBalancerPayload(BaseModel): UpdateLoadBalancerPayload """ + disable_target_security_group_assignment: Optional[StrictBool] = Field( + default=None, + 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.", + alias="disableTargetSecurityGroupAssignment", + ) errors: Optional[List[LoadBalancerError]] = Field( default=None, description="Reports all errors a application load balancer has." ) @@ -67,11 +80,17 @@ class UpdateLoadBalancerPayload(BaseModel): description="List of all target pools which will be used in the application 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. Useful when disableTargetSecurityGroupAssignment=true to manually assign target security groups to targets.", + alias="targetSecurityGroup", + ) version: Optional[StrictStr] = Field( default=None, 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.", ) __properties: ClassVar[List[str]] = [ + "disableTargetSecurityGroupAssignment", "errors", "externalAddress", "listeners", @@ -83,6 +102,7 @@ class UpdateLoadBalancerPayload(BaseModel): "region", "status", "targetPools", + "targetSecurityGroup", "version", ] @@ -143,6 +163,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( [ @@ -150,6 +171,7 @@ def to_dict(self) -> Dict[str, Any]: "private_address", "region", "status", + "target_security_group", ] ) @@ -189,6 +211,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 @@ -202,6 +227,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate( { + "disableTargetSecurityGroupAssignment": obj.get("disableTargetSecurityGroupAssignment"), "errors": ( [LoadBalancerError.from_dict(_item) for _item in obj["errors"]] if obj.get("errors") is not None @@ -227,6 +253,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"), } )