diff --git a/services/loadbalancer/oas_commit b/services/loadbalancer/oas_commit index 31950d47..f1fc529e 100644 --- a/services/loadbalancer/oas_commit +++ b/services/loadbalancer/oas_commit @@ -1 +1 @@ -9916269dab33d42aa2f1a5f30c80b954b6c1221f +a0507fbc8a743f261058ef285885928d2e8e0355 diff --git a/services/loadbalancer/src/stackit/loadbalancer/__init__.py b/services/loadbalancer/src/stackit/loadbalancer/__init__.py index fbeeaf2c..6fa036f8 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/__init__.py +++ b/services/loadbalancer/src/stackit/loadbalancer/__init__.py @@ -36,6 +36,7 @@ "GetCredentialsResponse", "GetQuotaResponse", "GoogleProtobufAny", + "HttpHealthChecks", "ListCredentialsResponse", "ListLoadBalancersResponse", "ListPlansResponse", @@ -57,6 +58,7 @@ "Status", "Target", "TargetPool", + "TlsConfig", "UpdateCredentialsPayload", "UpdateCredentialsResponse", "UpdateLoadBalancerPayload", @@ -102,6 +104,9 @@ from stackit.loadbalancer.models.google_protobuf_any import ( GoogleProtobufAny as GoogleProtobufAny, ) +from stackit.loadbalancer.models.http_health_checks import ( + HttpHealthChecks as HttpHealthChecks, +) from stackit.loadbalancer.models.list_credentials_response import ( ListCredentialsResponse as ListCredentialsResponse, ) @@ -145,6 +150,7 @@ from stackit.loadbalancer.models.status import Status as Status from stackit.loadbalancer.models.target import Target as Target from stackit.loadbalancer.models.target_pool import TargetPool as TargetPool +from stackit.loadbalancer.models.tls_config import TlsConfig as TlsConfig from stackit.loadbalancer.models.update_credentials_payload import ( UpdateCredentialsPayload as UpdateCredentialsPayload, ) diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/__init__.py b/services/loadbalancer/src/stackit/loadbalancer/models/__init__.py index e8f4836c..602aae8e 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/__init__.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/__init__.py @@ -28,6 +28,7 @@ from stackit.loadbalancer.models.get_credentials_response import GetCredentialsResponse from stackit.loadbalancer.models.get_quota_response import GetQuotaResponse from stackit.loadbalancer.models.google_protobuf_any import GoogleProtobufAny +from stackit.loadbalancer.models.http_health_checks import HttpHealthChecks from stackit.loadbalancer.models.list_credentials_response import ( ListCredentialsResponse, ) @@ -59,6 +60,7 @@ from stackit.loadbalancer.models.status import Status from stackit.loadbalancer.models.target import Target from stackit.loadbalancer.models.target_pool import TargetPool +from stackit.loadbalancer.models.tls_config import TlsConfig from stackit.loadbalancer.models.update_credentials_payload import ( UpdateCredentialsPayload, ) diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/active_health_check.py b/services/loadbalancer/src/stackit/loadbalancer/models/active_health_check.py index 74bdbcbd..4b105af9 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/active_health_check.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/active_health_check.py @@ -18,18 +18,24 @@ import re # noqa: F401 from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic import BaseModel, ConfigDict, Field, StrictInt, field_validator from typing_extensions import Annotated, Self +from stackit.loadbalancer.models.http_health_checks import HttpHealthChecks + class ActiveHealthCheck(BaseModel): """ ActiveHealthCheck """ # noqa: E501 + alt_port: Optional[StrictInt] = Field( + default=None, description="Overrides the default port used for health check probes.", alias="altPort" + ) healthy_threshold: Optional[Annotated[int, Field(le=1000000, strict=True, ge=1)]] = Field( default=None, description="Healthy threshold of the health checking", alias="healthyThreshold" ) + http_health_checks: Optional[HttpHealthChecks] = Field(default=None, alias="httpHealthChecks") interval: Optional[Annotated[str, Field(strict=True)]] = Field( default=None, description="Interval duration of health checking in seconds" ) @@ -45,7 +51,9 @@ class ActiveHealthCheck(BaseModel): default=None, description="Unhealthy threshold of the health checking", alias="unhealthyThreshold" ) __properties: ClassVar[List[str]] = [ + "altPort", "healthyThreshold", + "httpHealthChecks", "interval", "intervalJitter", "timeout", @@ -119,6 +127,9 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of http_health_checks + if self.http_health_checks: + _dict["httpHealthChecks"] = self.http_health_checks.to_dict() return _dict @classmethod @@ -132,7 +143,13 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate( { + "altPort": obj.get("altPort"), "healthyThreshold": obj.get("healthyThreshold"), + "httpHealthChecks": ( + HttpHealthChecks.from_dict(obj["httpHealthChecks"]) + if obj.get("httpHealthChecks") is not None + else None + ), "interval": obj.get("interval"), "intervalJitter": obj.get("intervalJitter"), "timeout": obj.get("timeout"), diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/http_health_checks.py b/services/loadbalancer/src/stackit/loadbalancer/models/http_health_checks.py new file mode 100644 index 00000000..06b06894 --- /dev/null +++ b/services/loadbalancer/src/stackit/loadbalancer/models/http_health_checks.py @@ -0,0 +1,96 @@ +# coding: utf-8 + +""" + STACKIT Network 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 + +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 + +from stackit.loadbalancer.models.tls_config import TlsConfig + + +class HttpHealthChecks(BaseModel): + """ + Options for the HTTP health checking. + """ # noqa: E501 + + ok_statuses: Optional[List[StrictStr]] = Field( + default=None, description="List of HTTP status codes that indicate a healthy response", alias="okStatuses" + ) + path: Optional[StrictStr] = Field(default=None, description="Path to send the health check request to") + tls: Optional[TlsConfig] = None + __properties: ClassVar[List[str]] = ["okStatuses", "path", "tls"] + + 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 HttpHealthChecks 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, + ) + # override the default output from pydantic by calling `to_dict()` of tls + if self.tls: + _dict["tls"] = self.tls.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HttpHealthChecks from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "okStatuses": obj.get("okStatuses"), + "path": obj.get("path"), + "tls": TlsConfig.from_dict(obj["tls"]) if obj.get("tls") is not None else None, + } + ) + return _obj diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/tls_config.py b/services/loadbalancer/src/stackit/loadbalancer/models/tls_config.py new file mode 100644 index 00000000..812f4dba --- /dev/null +++ b/services/loadbalancer/src/stackit/loadbalancer/models/tls_config.py @@ -0,0 +1,106 @@ +# coding: utf-8 + +""" + STACKIT Network 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 + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictStr, +) +from typing_extensions import Self + + +class TlsConfig(BaseModel): + """ + Set this to configure TLS settings. + """ # noqa: E501 + + custom_ca: Optional[StrictStr] = Field( + default=None, + description="Specifies a custom Certificate Authority (CA). When provided, the target pool will trust certificates signed by this CA, in addition to any system-trusted CAs. This is useful for scenarios where the target pool needs to communicate with servers using self-signed or internally-issued certificates. Enabled needs to be set to true and skip validation to false for this option.", + alias="customCa", + ) + enabled: Optional[StrictBool] = Field( + default=None, + description="Enable TLS (Transport Layer Security) bridging for the connection between Application Load Balancer and targets in this pool. When enabled, public CAs are trusted. Can be used in tandem with the options either custom CA or skip validation or alone.", + ) + skip_certificate_validation: Optional[StrictBool] = Field( + default=None, + description="Bypass certificate validation for TLS bridging in this target pool. This option is insecure and can only be used with public CAs by setting enabled true. Meant to be used for testing purposes only!", + alias="skipCertificateValidation", + ) + __properties: ClassVar[List[str]] = ["customCa", "enabled", "skipCertificateValidation"] + + 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 TlsConfig 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 TlsConfig from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "customCa": obj.get("customCa"), + "enabled": obj.get("enabled"), + "skipCertificateValidation": obj.get("skipCertificateValidation"), + } + ) + return _obj