| @@ 404-445 (lines=42) @@ | ||
| 401 | preferences=preferences, |
|
| 402 | ) |
|
| 403 | ||
| 404 | def create_tls_certificate( |
|
| 405 | self, |
|
| 406 | name: str, |
|
| 407 | certificate: str, |
|
| 408 | *, |
|
| 409 | comment: Optional[str] = None, |
|
| 410 | trust: Optional[bool] = None |
|
| 411 | ) -> Any: |
|
| 412 | """Create a new TLS certificate |
|
| 413 | ||
| 414 | Arguments: |
|
| 415 | name: Name of the TLS certificate, defaulting to the MD5 |
|
| 416 | fingerprint. |
|
| 417 | certificate: The Base64 encoded certificate data (x.509 DER or PEM). |
|
| 418 | comment: Comment for the TLS certificate. |
|
| 419 | trust: Whether the certificate is trusted. |
|
| 420 | ||
| 421 | Returns: |
|
| 422 | The response. See :py:meth:`send_command` for details. |
|
| 423 | """ |
|
| 424 | if not name: |
|
| 425 | raise RequiredArgument( |
|
| 426 | function=self.create_tls_certificate.__name__, argument='name' |
|
| 427 | ) |
|
| 428 | if not certificate: |
|
| 429 | raise RequiredArgument( |
|
| 430 | function=self.create_tls_certificate.__name__, |
|
| 431 | argument='certificate', |
|
| 432 | ) |
|
| 433 | ||
| 434 | cmd = XmlCommand("create_tls_certificate") |
|
| 435 | ||
| 436 | if comment: |
|
| 437 | cmd.add_element("comment", comment) |
|
| 438 | ||
| 439 | cmd.add_element("name", name) |
|
| 440 | cmd.add_element("certificate", certificate) |
|
| 441 | ||
| 442 | if trust: |
|
| 443 | cmd.add_element("trust", _to_bool(trust)) |
|
| 444 | ||
| 445 | return self._send_xml_command(cmd) |
|
| 446 | ||
| 447 | def get_tls_certificates( |
|
| 448 | self, |
|
| @@ 607-644 (lines=38) @@ | ||
| 604 | ||
| 605 | return self._send_xml_command(cmd) |
|
| 606 | ||
| 607 | def modify_tls_certificate( |
|
| 608 | self, |
|
| 609 | tls_certificate_id: str, |
|
| 610 | *, |
|
| 611 | name: Optional[str] = None, |
|
| 612 | comment: Optional[str] = None, |
|
| 613 | trust: Optional[bool] = None |
|
| 614 | ) -> Any: |
|
| 615 | """Modifies an existing TLS certificate. |
|
| 616 | ||
| 617 | Arguments: |
|
| 618 | tls_certificate_id: UUID of the TLS certificate to be modified. |
|
| 619 | name: Name of the TLS certificate, defaulting to the MD5 fingerprint |
|
| 620 | comment: Comment for the TLS certificate. |
|
| 621 | trust: Whether the certificate is trusted. |
|
| 622 | ||
| 623 | Returns: |
|
| 624 | The response. See :py:meth:`send_command` for details. |
|
| 625 | """ |
|
| 626 | if not tls_certificate_id: |
|
| 627 | raise RequiredArgument( |
|
| 628 | function=self.modify_tls_certificate.__name__, |
|
| 629 | argument='tls_certificate_id', |
|
| 630 | ) |
|
| 631 | ||
| 632 | cmd = XmlCommand("modify_tls_certificate") |
|
| 633 | cmd.set_attribute("tls_certificate_id", str(tls_certificate_id)) |
|
| 634 | ||
| 635 | if comment: |
|
| 636 | cmd.add_element("comment", comment) |
|
| 637 | ||
| 638 | if name: |
|
| 639 | cmd.add_element("name", name) |
|
| 640 | ||
| 641 | if trust: |
|
| 642 | cmd.add_element("trust", _to_bool(trust)) |
|
| 643 | ||
| 644 | return self._send_xml_command(cmd) |
|
| 645 | ||
| 646 | def clone_tls_certificate(self, tls_certificate_id: str) -> Any: |
|
| 647 | """Modifies an existing TLS certificate. |
|