|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | + STACKIT Network 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 load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. |
| 7 | +
|
| 8 | + The version of the OpenAPI document: 2.0.0 |
| 9 | + Generated by OpenAPI Generator (https://openapi-generator.tech) |
| 10 | +
|
| 11 | + Do not edit the class manually. |
| 12 | +""" # noqa: E501 |
| 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 ( |
| 21 | + BaseModel, |
| 22 | + ConfigDict, |
| 23 | + Field, |
| 24 | + StrictBool, |
| 25 | + StrictStr, |
| 26 | +) |
| 27 | +from typing_extensions import Self |
| 28 | + |
| 29 | + |
| 30 | +class TlsConfig(BaseModel): |
| 31 | + """ |
| 32 | + Set this to configure TLS settings. |
| 33 | + """ # noqa: E501 |
| 34 | + |
| 35 | + custom_ca: Optional[StrictStr] = Field( |
| 36 | + default=None, |
| 37 | + 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.", |
| 38 | + alias="customCa", |
| 39 | + ) |
| 40 | + enabled: Optional[StrictBool] = Field( |
| 41 | + default=None, |
| 42 | + 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.", |
| 43 | + ) |
| 44 | + skip_certificate_validation: Optional[StrictBool] = Field( |
| 45 | + default=None, |
| 46 | + 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!", |
| 47 | + alias="skipCertificateValidation", |
| 48 | + ) |
| 49 | + __properties: ClassVar[List[str]] = ["customCa", "enabled", "skipCertificateValidation"] |
| 50 | + |
| 51 | + model_config = ConfigDict( |
| 52 | + populate_by_name=True, |
| 53 | + validate_assignment=True, |
| 54 | + protected_namespaces=(), |
| 55 | + ) |
| 56 | + |
| 57 | + def to_str(self) -> str: |
| 58 | + """Returns the string representation of the model using alias""" |
| 59 | + return pprint.pformat(self.model_dump(by_alias=True)) |
| 60 | + |
| 61 | + def to_json(self) -> str: |
| 62 | + """Returns the JSON representation of the model using alias""" |
| 63 | + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead |
| 64 | + return json.dumps(self.to_dict()) |
| 65 | + |
| 66 | + @classmethod |
| 67 | + def from_json(cls, json_str: str) -> Optional[Self]: |
| 68 | + """Create an instance of TlsConfig from a JSON string""" |
| 69 | + return cls.from_dict(json.loads(json_str)) |
| 70 | + |
| 71 | + def to_dict(self) -> Dict[str, Any]: |
| 72 | + """Return the dictionary representation of the model using alias. |
| 73 | +
|
| 74 | + This has the following differences from calling pydantic's |
| 75 | + `self.model_dump(by_alias=True)`: |
| 76 | +
|
| 77 | + * `None` is only added to the output dict for nullable fields that |
| 78 | + were set at model initialization. Other fields with value `None` |
| 79 | + are ignored. |
| 80 | + """ |
| 81 | + excluded_fields: Set[str] = set([]) |
| 82 | + |
| 83 | + _dict = self.model_dump( |
| 84 | + by_alias=True, |
| 85 | + exclude=excluded_fields, |
| 86 | + exclude_none=True, |
| 87 | + ) |
| 88 | + return _dict |
| 89 | + |
| 90 | + @classmethod |
| 91 | + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: |
| 92 | + """Create an instance of TlsConfig from a dict""" |
| 93 | + if obj is None: |
| 94 | + return None |
| 95 | + |
| 96 | + if not isinstance(obj, dict): |
| 97 | + return cls.model_validate(obj) |
| 98 | + |
| 99 | + _obj = cls.model_validate( |
| 100 | + { |
| 101 | + "customCa": obj.get("customCa"), |
| 102 | + "enabled": obj.get("enabled"), |
| 103 | + "skipCertificateValidation": obj.get("skipCertificateValidation"), |
| 104 | + } |
| 105 | + ) |
| 106 | + return _obj |
0 commit comments