|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | + STACKIT Application Load Balancer Certificates API |
| 5 | +
|
| 6 | + This API offers the ability to store TLS certificates, which can be used by load balancing servers in STACKIT. They can be between consumer and load balancing server and/or between load balancing server and endpoint server. |
| 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 | +import re # noqa: F401 |
| 19 | +from typing import Any, ClassVar, Dict, List, Optional, Set |
| 20 | + |
| 21 | +from pydantic import ( |
| 22 | + BaseModel, |
| 23 | + ConfigDict, |
| 24 | + Field, |
| 25 | + StrictBool, |
| 26 | + StrictStr, |
| 27 | + field_validator, |
| 28 | +) |
| 29 | +from pydantic_core import to_jsonable_python |
| 30 | +from typing_extensions import Annotated, Self |
| 31 | + |
| 32 | + |
| 33 | +class Data(BaseModel): |
| 34 | + """ |
| 35 | + Data |
| 36 | + """ # noqa: E501 |
| 37 | + |
| 38 | + dns_names: Optional[StrictStr] = Field( |
| 39 | + default=None, |
| 40 | + description="Comma-separated list of all domains and IP addresses the certificate is valid for (Subject Alternative Names).", |
| 41 | + alias="dnsNames", |
| 42 | + ) |
| 43 | + extended_key_usage: Optional[StrictStr] = Field( |
| 44 | + default=None, |
| 45 | + description="Comma-separated list of purposes the cert is valid for. 'Server Auth' is required for Load Balancer use.", |
| 46 | + alias="extendedKeyUsage", |
| 47 | + ) |
| 48 | + fingerprint_sha1: Optional[Annotated[str, Field(strict=True)]] = Field( |
| 49 | + default=None, |
| 50 | + description="The legacy SHA1 thumbprint. Provided for cross-referencing with older systems and browsers.", |
| 51 | + alias="fingerprintSha1", |
| 52 | + ) |
| 53 | + fingerprint_sha256: Optional[Annotated[str, Field(strict=True)]] = Field( |
| 54 | + default=None, |
| 55 | + description="The unique SHA256 hash of the raw certificate bytes. Use this as the primary unique identifier.", |
| 56 | + alias="fingerprintSha256", |
| 57 | + ) |
| 58 | + is_ca: Optional[StrictBool] = Field( |
| 59 | + default=None, |
| 60 | + description="Indicates if the certificate is a Certificate Authority, meaning it can sign other certificates.", |
| 61 | + alias="isCa", |
| 62 | + ) |
| 63 | + is_self_signed: Optional[StrictBool] = Field( |
| 64 | + default=None, |
| 65 | + description="Indicates if the certificate was signed by its own private key rather than a trusted third-party CA.", |
| 66 | + alias="isSelfSigned", |
| 67 | + ) |
| 68 | + issuer_cn: Optional[StrictStr] = Field( |
| 69 | + default=None, |
| 70 | + description="The Common Name of the Certificate Authority (CA) that signed and issued the certificate.", |
| 71 | + alias="issuerCn", |
| 72 | + ) |
| 73 | + key_strength: Optional[StrictStr] = Field( |
| 74 | + default=None, |
| 75 | + description="Human-readable summary of the public key's algorithm and bit-length or curve name.", |
| 76 | + alias="keyStrength", |
| 77 | + ) |
| 78 | + not_after: Optional[StrictStr] = Field( |
| 79 | + default=None, |
| 80 | + description="The expiration timestamp. After this date, browsers will show security warnings (RFC3339 format).", |
| 81 | + alias="notAfter", |
| 82 | + ) |
| 83 | + not_before: Optional[StrictStr] = Field( |
| 84 | + default=None, |
| 85 | + description="The timestamp indicating when the certificate starts being valid (RFC3339 format).", |
| 86 | + alias="notBefore", |
| 87 | + ) |
| 88 | + organization: Optional[StrictStr] = Field( |
| 89 | + default=None, description="Organization name associated with the certificate subject." |
| 90 | + ) |
| 91 | + public_key_algorithm: Optional[StrictStr] = Field( |
| 92 | + default=None, |
| 93 | + description="The cryptographic algorithm used to generate the public/private key pair.", |
| 94 | + alias="publicKeyAlgorithm", |
| 95 | + ) |
| 96 | + serial_number: Optional[StrictStr] = Field( |
| 97 | + default=None, |
| 98 | + description="The unique serial number assigned by the CA, represented in uppercase hexadecimal format.", |
| 99 | + alias="serialNumber", |
| 100 | + ) |
| 101 | + signature_algorithm: Optional[StrictStr] = Field( |
| 102 | + default=None, description="The algorithm used by the CA to sign this certificate.", alias="signatureAlgorithm" |
| 103 | + ) |
| 104 | + subject_cn: Optional[StrictStr] = Field( |
| 105 | + default=None, |
| 106 | + description="The primary identity of the certificate. Fallback sequence: Common Name -> First DNS Name -> Full Subject String.", |
| 107 | + alias="subjectCn", |
| 108 | + ) |
| 109 | + __properties: ClassVar[List[str]] = [ |
| 110 | + "dnsNames", |
| 111 | + "extendedKeyUsage", |
| 112 | + "fingerprintSha1", |
| 113 | + "fingerprintSha256", |
| 114 | + "isCa", |
| 115 | + "isSelfSigned", |
| 116 | + "issuerCn", |
| 117 | + "keyStrength", |
| 118 | + "notAfter", |
| 119 | + "notBefore", |
| 120 | + "organization", |
| 121 | + "publicKeyAlgorithm", |
| 122 | + "serialNumber", |
| 123 | + "signatureAlgorithm", |
| 124 | + "subjectCn", |
| 125 | + ] |
| 126 | + |
| 127 | + @field_validator("fingerprint_sha1") |
| 128 | + def fingerprint_sha1_validate_regular_expression(cls, value): |
| 129 | + """Validates the regular expression""" |
| 130 | + if value is None: |
| 131 | + return value |
| 132 | + |
| 133 | + if not isinstance(value, str): |
| 134 | + value = str(value) |
| 135 | + |
| 136 | + if not re.match(r"^[a-fA-F0-9]{40}$", value): |
| 137 | + raise ValueError(r"must validate the regular expression /^[a-fA-F0-9]{40}$/") |
| 138 | + return value |
| 139 | + |
| 140 | + @field_validator("fingerprint_sha256") |
| 141 | + def fingerprint_sha256_validate_regular_expression(cls, value): |
| 142 | + """Validates the regular expression""" |
| 143 | + if value is None: |
| 144 | + return value |
| 145 | + |
| 146 | + if not isinstance(value, str): |
| 147 | + value = str(value) |
| 148 | + |
| 149 | + if not re.match(r"^[a-fA-F0-9]{64}$", value): |
| 150 | + raise ValueError(r"must validate the regular expression /^[a-fA-F0-9]{64}$/") |
| 151 | + return value |
| 152 | + |
| 153 | + model_config = ConfigDict( |
| 154 | + validate_by_name=True, |
| 155 | + validate_by_alias=True, |
| 156 | + validate_assignment=True, |
| 157 | + protected_namespaces=(), |
| 158 | + ) |
| 159 | + |
| 160 | + def to_str(self) -> str: |
| 161 | + """Returns the string representation of the model using alias""" |
| 162 | + return pprint.pformat(self.model_dump(by_alias=True)) |
| 163 | + |
| 164 | + def to_json(self) -> str: |
| 165 | + """Returns the JSON representation of the model using alias""" |
| 166 | + return json.dumps(to_jsonable_python(self.to_dict())) |
| 167 | + |
| 168 | + @classmethod |
| 169 | + def from_json(cls, json_str: str) -> Optional[Self]: |
| 170 | + """Create an instance of Data from a JSON string""" |
| 171 | + return cls.from_dict(json.loads(json_str)) |
| 172 | + |
| 173 | + def to_dict(self) -> Dict[str, Any]: |
| 174 | + """Return the dictionary representation of the model using alias. |
| 175 | +
|
| 176 | + This has the following differences from calling pydantic's |
| 177 | + `self.model_dump(by_alias=True)`: |
| 178 | +
|
| 179 | + * `None` is only added to the output dict for nullable fields that |
| 180 | + were set at model initialization. Other fields with value `None` |
| 181 | + are ignored. |
| 182 | + """ |
| 183 | + excluded_fields: Set[str] = set([]) |
| 184 | + |
| 185 | + _dict = self.model_dump( |
| 186 | + by_alias=True, |
| 187 | + exclude=excluded_fields, |
| 188 | + exclude_none=True, |
| 189 | + ) |
| 190 | + return _dict |
| 191 | + |
| 192 | + @classmethod |
| 193 | + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: |
| 194 | + """Create an instance of Data from a dict""" |
| 195 | + if obj is None: |
| 196 | + return None |
| 197 | + |
| 198 | + if not isinstance(obj, dict): |
| 199 | + return cls.model_validate(obj) |
| 200 | + |
| 201 | + _obj = cls.model_validate( |
| 202 | + { |
| 203 | + "dnsNames": obj.get("dnsNames"), |
| 204 | + "extendedKeyUsage": obj.get("extendedKeyUsage"), |
| 205 | + "fingerprintSha1": obj.get("fingerprintSha1"), |
| 206 | + "fingerprintSha256": obj.get("fingerprintSha256"), |
| 207 | + "isCa": obj.get("isCa"), |
| 208 | + "isSelfSigned": obj.get("isSelfSigned"), |
| 209 | + "issuerCn": obj.get("issuerCn"), |
| 210 | + "keyStrength": obj.get("keyStrength"), |
| 211 | + "notAfter": obj.get("notAfter"), |
| 212 | + "notBefore": obj.get("notBefore"), |
| 213 | + "organization": obj.get("organization"), |
| 214 | + "publicKeyAlgorithm": obj.get("publicKeyAlgorithm"), |
| 215 | + "serialNumber": obj.get("serialNumber"), |
| 216 | + "signatureAlgorithm": obj.get("signatureAlgorithm"), |
| 217 | + "subjectCn": obj.get("subjectCn"), |
| 218 | + } |
| 219 | + ) |
| 220 | + return _obj |
0 commit comments