|
| 1 | +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union |
| 2 | + |
| 3 | +from attrs import define as _attrs_define |
| 4 | +from attrs import field as _attrs_field |
| 5 | + |
| 6 | +from ..types import UNSET, Unset |
| 7 | + |
| 8 | +if TYPE_CHECKING: |
| 9 | + from ..models.click_house_parameters_spec_properties import ( |
| 10 | + ClickHouseParametersSpecProperties, |
| 11 | + ) |
| 12 | + |
| 13 | + |
| 14 | +T = TypeVar("T", bound="ClickHouseParametersSpec") |
| 15 | + |
| 16 | + |
| 17 | +@_attrs_define |
| 18 | +class ClickHouseParametersSpec: |
| 19 | + """ |
| 20 | + Attributes: |
| 21 | + host (Union[Unset, str]): ClickHouse host name. Supports also a ${CLICKHOUSE_HOST} configuration with a custom |
| 22 | + environment variable. |
| 23 | + port (Union[Unset, str]): ClickHouse port number. The default port is 30015. Supports also a ${CLICKHOUSE_PORT} |
| 24 | + configuration with a custom environment variable. |
| 25 | + database (Union[Unset, str]): ClickHouse instance number. Supports also a ${CLICKHOUSE_DATABASE_NAME} |
| 26 | + configuration with a custom environment variable. |
| 27 | + user (Union[Unset, str]): ClickHouse user name. The value can be in the ${ENVIRONMENT_VARIABLE_NAME} format to |
| 28 | + use dynamic substitution. |
| 29 | + password (Union[Unset, str]): ClickHouse database password. The value can be in the ${ENVIRONMENT_VARIABLE_NAME} |
| 30 | + format to use dynamic substitution. |
| 31 | + properties (Union[Unset, ClickHouseParametersSpecProperties]): A dictionary of custom JDBC parameters that are |
| 32 | + added to the JDBC connection string, a key/value dictionary. |
| 33 | + """ |
| 34 | + |
| 35 | + host: Union[Unset, str] = UNSET |
| 36 | + port: Union[Unset, str] = UNSET |
| 37 | + database: Union[Unset, str] = UNSET |
| 38 | + user: Union[Unset, str] = UNSET |
| 39 | + password: Union[Unset, str] = UNSET |
| 40 | + properties: Union[Unset, "ClickHouseParametersSpecProperties"] = UNSET |
| 41 | + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) |
| 42 | + |
| 43 | + def to_dict(self) -> Dict[str, Any]: |
| 44 | + host = self.host |
| 45 | + port = self.port |
| 46 | + database = self.database |
| 47 | + user = self.user |
| 48 | + password = self.password |
| 49 | + properties: Union[Unset, Dict[str, Any]] = UNSET |
| 50 | + if not isinstance(self.properties, Unset): |
| 51 | + properties = self.properties.to_dict() |
| 52 | + |
| 53 | + field_dict: Dict[str, Any] = {} |
| 54 | + field_dict.update(self.additional_properties) |
| 55 | + field_dict.update({}) |
| 56 | + if host is not UNSET: |
| 57 | + field_dict["host"] = host |
| 58 | + if port is not UNSET: |
| 59 | + field_dict["port"] = port |
| 60 | + if database is not UNSET: |
| 61 | + field_dict["database"] = database |
| 62 | + if user is not UNSET: |
| 63 | + field_dict["user"] = user |
| 64 | + if password is not UNSET: |
| 65 | + field_dict["password"] = password |
| 66 | + if properties is not UNSET: |
| 67 | + field_dict["properties"] = properties |
| 68 | + |
| 69 | + return field_dict |
| 70 | + |
| 71 | + @classmethod |
| 72 | + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: |
| 73 | + from ..models.click_house_parameters_spec_properties import ( |
| 74 | + ClickHouseParametersSpecProperties, |
| 75 | + ) |
| 76 | + |
| 77 | + d = src_dict.copy() |
| 78 | + host = d.pop("host", UNSET) |
| 79 | + |
| 80 | + port = d.pop("port", UNSET) |
| 81 | + |
| 82 | + database = d.pop("database", UNSET) |
| 83 | + |
| 84 | + user = d.pop("user", UNSET) |
| 85 | + |
| 86 | + password = d.pop("password", UNSET) |
| 87 | + |
| 88 | + _properties = d.pop("properties", UNSET) |
| 89 | + properties: Union[Unset, ClickHouseParametersSpecProperties] |
| 90 | + if isinstance(_properties, Unset): |
| 91 | + properties = UNSET |
| 92 | + else: |
| 93 | + properties = ClickHouseParametersSpecProperties.from_dict(_properties) |
| 94 | + |
| 95 | + click_house_parameters_spec = cls( |
| 96 | + host=host, |
| 97 | + port=port, |
| 98 | + database=database, |
| 99 | + user=user, |
| 100 | + password=password, |
| 101 | + properties=properties, |
| 102 | + ) |
| 103 | + |
| 104 | + click_house_parameters_spec.additional_properties = d |
| 105 | + return click_house_parameters_spec |
| 106 | + |
| 107 | + @property |
| 108 | + def additional_keys(self) -> List[str]: |
| 109 | + return list(self.additional_properties.keys()) |
| 110 | + |
| 111 | + def __getitem__(self, key: str) -> Any: |
| 112 | + return self.additional_properties[key] |
| 113 | + |
| 114 | + def __setitem__(self, key: str, value: Any) -> None: |
| 115 | + self.additional_properties[key] = value |
| 116 | + |
| 117 | + def __delitem__(self, key: str) -> None: |
| 118 | + del self.additional_properties[key] |
| 119 | + |
| 120 | + def __contains__(self, key: str) -> bool: |
| 121 | + return key in self.additional_properties |
0 commit comments