| @@ 424-465 (lines=42) @@ | ||
| 421 | preferences=preferences, |
|
| 422 | ) |
|
| 423 | ||
| 424 | def create_tls_certificate( |
|
| 425 | self, |
|
| 426 | name: str, |
|
| 427 | certificate: str, |
|
| 428 | *, |
|
| 429 | comment: Optional[str] = None, |
|
| 430 | trust: Optional[bool] = None |
|
| 431 | ) -> Any: |
|
| 432 | """Create a new TLS certificate |
|
| 433 | ||
| 434 | Arguments: |
|
| 435 | name: Name of the TLS certificate, defaulting to the MD5 |
|
| 436 | fingerprint. |
|
| 437 | certificate: The Base64 encoded certificate data (x.509 DER or PEM). |
|
| 438 | comment: Comment for the TLS certificate. |
|
| 439 | trust: Whether the certificate is trusted. |
|
| 440 | ||
| 441 | Returns: |
|
| 442 | The response. See :py:meth:`send_command` for details. |
|
| 443 | """ |
|
| 444 | if not name: |
|
| 445 | raise RequiredArgument( |
|
| 446 | function=self.create_tls_certificate.__name__, argument='name' |
|
| 447 | ) |
|
| 448 | if not certificate: |
|
| 449 | raise RequiredArgument( |
|
| 450 | function=self.create_tls_certificate.__name__, |
|
| 451 | argument='certificate', |
|
| 452 | ) |
|
| 453 | ||
| 454 | cmd = XmlCommand("create_tls_certificate") |
|
| 455 | ||
| 456 | if comment: |
|
| 457 | cmd.add_element("comment", comment) |
|
| 458 | ||
| 459 | cmd.add_element("name", name) |
|
| 460 | cmd.add_element("certificate", certificate) |
|
| 461 | ||
| 462 | if trust: |
|
| 463 | cmd.add_element("trust", _to_bool(trust)) |
|
| 464 | ||
| 465 | return self._send_xml_command(cmd) |
|
| 466 | ||
| 467 | def get_tls_certificates( |
|
| 468 | self, |
|
| @@ 636-673 (lines=38) @@ | ||
| 633 | ||
| 634 | return self._send_xml_command(cmd) |
|
| 635 | ||
| 636 | def modify_tls_certificate( |
|
| 637 | self, |
|
| 638 | tls_certificate_id: str, |
|
| 639 | *, |
|
| 640 | name: Optional[str] = None, |
|
| 641 | comment: Optional[str] = None, |
|
| 642 | trust: Optional[bool] = None |
|
| 643 | ) -> Any: |
|
| 644 | """Modifies an existing TLS certificate. |
|
| 645 | ||
| 646 | Arguments: |
|
| 647 | tls_certificate_id: UUID of the TLS certificate to be modified. |
|
| 648 | name: Name of the TLS certificate, defaulting to the MD5 fingerprint |
|
| 649 | comment: Comment for the TLS certificate. |
|
| 650 | trust: Whether the certificate is trusted. |
|
| 651 | ||
| 652 | Returns: |
|
| 653 | The response. See :py:meth:`send_command` for details. |
|
| 654 | """ |
|
| 655 | if not tls_certificate_id: |
|
| 656 | raise RequiredArgument( |
|
| 657 | function=self.modify_tls_certificate.__name__, |
|
| 658 | argument='tls_certificate_id', |
|
| 659 | ) |
|
| 660 | ||
| 661 | cmd = XmlCommand("modify_tls_certificate") |
|
| 662 | cmd.set_attribute("tls_certificate_id", str(tls_certificate_id)) |
|
| 663 | ||
| 664 | if comment: |
|
| 665 | cmd.add_element("comment", comment) |
|
| 666 | ||
| 667 | if name: |
|
| 668 | cmd.add_element("name", name) |
|
| 669 | ||
| 670 | if trust: |
|
| 671 | cmd.add_element("trust", _to_bool(trust)) |
|
| 672 | ||
| 673 | return self._send_xml_command(cmd) |
|
| 674 | ||
| 675 | def clone_tls_certificate(self, tls_certificate_id: str) -> Any: |
|
| 676 | """Modifies an existing TLS certificate. |
|