| @@ 202-247 (lines=46) @@ | ||
| 199 | preferences=preferences, |
|
| 200 | ) |
|
| 201 | ||
| 202 | def create_tls_certificate( |
|
| 203 | self, |
|
| 204 | name: str, |
|
| 205 | certificate: str, |
|
| 206 | *, |
|
| 207 | comment: Optional[str] = None, |
|
| 208 | copy: Optional[str] = None, |
|
| 209 | trust: Optional[bool] = None |
|
| 210 | ) -> Any: |
|
| 211 | """Create a new TLS certificate |
|
| 212 | ||
| 213 | Arguments: |
|
| 214 | comment: Comment for the TLS certificate. |
|
| 215 | name: Name of the TLS certificate, defaulting to the MD5 fingerprint |
|
| 216 | copy: The UUID of an existing TLS certificate |
|
| 217 | trust: Whether the certificate is trusted. |
|
| 218 | certificate: The Base64 encoded certificate data (x.509 DER or PEM). |
|
| 219 | ||
| 220 | Returns: |
|
| 221 | The response. See :py:meth:`send_command`for details. |
|
| 222 | """ |
|
| 223 | if not name: |
|
| 224 | raise RequiredArgument( |
|
| 225 | argument='name', function=self.create_tls_certificate.__name__ |
|
| 226 | ) |
|
| 227 | if not certificate: |
|
| 228 | raise RequiredArgument( |
|
| 229 | argument="certificate", |
|
| 230 | function=self.create_tls_certificate.__name__, |
|
| 231 | ) |
|
| 232 | ||
| 233 | cmd = XmlCommand("create_tls_certificate") |
|
| 234 | ||
| 235 | if comment: |
|
| 236 | cmd.add_element("comment", comment) |
|
| 237 | ||
| 238 | if copy: |
|
| 239 | cmd.add_element("copy", copy) |
|
| 240 | ||
| 241 | cmd.add_element("name", name) |
|
| 242 | cmd.add_element("certificate", certificate) |
|
| 243 | ||
| 244 | if trust: |
|
| 245 | cmd.add_element("trust", _to_bool(trust)) |
|
| 246 | ||
| 247 | return self._send_xml_command(cmd) |
|
| 248 | ||
| 249 | def get_tls_certificates( |
|
| 250 | self, |
|
| @@ 277-314 (lines=38) @@ | ||
| 274 | ||
| 275 | return self._send_xml_command(cmd) |
|
| 276 | ||
| 277 | def modify_tls_certificate( |
|
| 278 | self, |
|
| 279 | tls_certificate_id: str, |
|
| 280 | *, |
|
| 281 | name: Optional[str] = None, |
|
| 282 | comment: Optional[str] = None, |
|
| 283 | trust: Optional[bool] = None |
|
| 284 | ) -> Any: |
|
| 285 | """Modifies an existing TLS certificate. |
|
| 286 | ||
| 287 | Arguments: |
|
| 288 | tls_certificate_id: UUID of the TLS certificate to be modified. |
|
| 289 | name: Name of the TLS certificate, defaulting to the MD5 fingerprint |
|
| 290 | comment: Comment for the TLS certificate. |
|
| 291 | trust: Whether the certificate is trusted. |
|
| 292 | ||
| 293 | Returns: |
|
| 294 | The response. See :py:meth:`send_command` for details. |
|
| 295 | """ |
|
| 296 | if not tls_certificate_id: |
|
| 297 | raise RequiredArgument( |
|
| 298 | argument="tls_certificate_id", |
|
| 299 | function=self.modify_tls_certificate.__name__, |
|
| 300 | ) |
|
| 301 | ||
| 302 | cmd = XmlCommand("modify_tls_certificate") |
|
| 303 | cmd.set_attribute("tls_certificate_id", str(tls_certificate_id)) |
|
| 304 | ||
| 305 | if comment: |
|
| 306 | cmd.add_element("comment", comment) |
|
| 307 | ||
| 308 | if name: |
|
| 309 | cmd.add_element("name", name) |
|
| 310 | ||
| 311 | if trust: |
|
| 312 | cmd.add_element("trust", _to_bool(trust)) |
|
| 313 | ||
| 314 | return self._send_xml_command(cmd) |
|
| 315 | ||
| 316 | def clone_tls_certificate(self, tls_certificate_id: str) -> Any: |
|
| 317 | """Modifies an existing TLS certificate. |
|