| @@ 2726-2838 (lines=113) @@ | ||
| 2723 | ||
| 2724 | return self._send_xml_command(cmd) |
|
| 2725 | ||
| 2726 | def modify_credential( |
|
| 2727 | self, |
|
| 2728 | credential_id: str, |
|
| 2729 | *, |
|
| 2730 | name: Optional[str] = None, |
|
| 2731 | comment: Optional[str] = None, |
|
| 2732 | allow_insecure: Optional[bool] = None, |
|
| 2733 | certificate: Optional[str] = None, |
|
| 2734 | key_phrase: Optional[str] = None, |
|
| 2735 | private_key: Optional[str] = None, |
|
| 2736 | login: Optional[str] = None, |
|
| 2737 | password: Optional[str] = None, |
|
| 2738 | auth_algorithm: Optional[SnmpAuthAlgorithm] = None, |
|
| 2739 | community: Optional[str] = None, |
|
| 2740 | privacy_algorithm: Optional[SnmpPrivacyAlgorithm] = None, |
|
| 2741 | privacy_password: Optional[str] = None, |
|
| 2742 | public_key: Optional[str] = None, |
|
| 2743 | ) -> Any: |
|
| 2744 | """Modifies an existing credential. |
|
| 2745 | ||
| 2746 | Arguments: |
|
| 2747 | credential_id: UUID of the credential |
|
| 2748 | name: Name of the credential |
|
| 2749 | comment: Comment for the credential |
|
| 2750 | allow_insecure: Whether to allow insecure use of the credential |
|
| 2751 | certificate: Certificate for the credential |
|
| 2752 | key_phrase: Key passphrase for the private key |
|
| 2753 | private_key: Private key to use for login |
|
| 2754 | login: Username for the credential |
|
| 2755 | password: Password for the credential |
|
| 2756 | auth_algorithm: The authentication algorithm for SNMP |
|
| 2757 | community: The SNMP community |
|
| 2758 | privacy_algorithm: The privacy algorithm for SNMP |
|
| 2759 | privacy_password: The SNMP privacy password |
|
| 2760 | public_key: PGP public key in *armor* plain text format |
|
| 2761 | ||
| 2762 | Returns: |
|
| 2763 | The response. See :py:meth:`send_command` for details. |
|
| 2764 | """ |
|
| 2765 | if not credential_id: |
|
| 2766 | raise RequiredArgument( |
|
| 2767 | function=self.modify_credential.__name__, |
|
| 2768 | argument='credential_id', |
|
| 2769 | ) |
|
| 2770 | ||
| 2771 | cmd = XmlCommand("modify_credential") |
|
| 2772 | cmd.set_attribute("credential_id", credential_id) |
|
| 2773 | ||
| 2774 | if comment: |
|
| 2775 | cmd.add_element("comment", comment) |
|
| 2776 | ||
| 2777 | if name: |
|
| 2778 | cmd.add_element("name", name) |
|
| 2779 | ||
| 2780 | if allow_insecure is not None: |
|
| 2781 | cmd.add_element("allow_insecure", _to_bool(allow_insecure)) |
|
| 2782 | ||
| 2783 | if certificate: |
|
| 2784 | cmd.add_element("certificate", certificate) |
|
| 2785 | ||
| 2786 | if key_phrase and private_key: |
|
| 2787 | _xmlkey = cmd.add_element("key") |
|
| 2788 | _xmlkey.add_element("phrase", key_phrase) |
|
| 2789 | _xmlkey.add_element("private", private_key) |
|
| 2790 | elif (not key_phrase and private_key) or ( |
|
| 2791 | key_phrase and not private_key |
|
| 2792 | ): |
|
| 2793 | raise RequiredArgument( |
|
| 2794 | function=self.modify_credential.__name__, |
|
| 2795 | argument='key_phrase and private_key', |
|
| 2796 | ) |
|
| 2797 | ||
| 2798 | if login: |
|
| 2799 | cmd.add_element("login", login) |
|
| 2800 | ||
| 2801 | if password: |
|
| 2802 | cmd.add_element("password", password) |
|
| 2803 | ||
| 2804 | if auth_algorithm: |
|
| 2805 | if not isinstance(auth_algorithm, self.types.SnmpAuthAlgorithm): |
|
| 2806 | raise InvalidArgumentType( |
|
| 2807 | function=self.modify_credential.__name__, |
|
| 2808 | argument='auth_algorithm', |
|
| 2809 | arg_type=SnmpAuthAlgorithm.__name__, |
|
| 2810 | ) |
|
| 2811 | cmd.add_element("auth_algorithm", auth_algorithm.value) |
|
| 2812 | ||
| 2813 | if community: |
|
| 2814 | cmd.add_element("community", community) |
|
| 2815 | ||
| 2816 | if privacy_algorithm is not None or privacy_password is not None: |
|
| 2817 | _xmlprivacy = cmd.add_element("privacy") |
|
| 2818 | ||
| 2819 | if privacy_algorithm is not None: |
|
| 2820 | if not isinstance( |
|
| 2821 | privacy_algorithm, self.types.SnmpPrivacyAlgorithm |
|
| 2822 | ): |
|
| 2823 | raise InvalidArgumentType( |
|
| 2824 | function=self.modify_credential.__name__, |
|
| 2825 | argument='privacy_algorithm', |
|
| 2826 | arg_type=SnmpPrivacyAlgorithm.__name__, |
|
| 2827 | ) |
|
| 2828 | ||
| 2829 | _xmlprivacy.add_element("algorithm", privacy_algorithm.value) |
|
| 2830 | ||
| 2831 | if privacy_password is not None: |
|
| 2832 | _xmlprivacy.add_element("password", privacy_password) |
|
| 2833 | ||
| 2834 | if public_key: |
|
| 2835 | _xmlkey = cmd.add_element("key") |
|
| 2836 | _xmlkey.add_element("public", public_key) |
|
| 2837 | ||
| 2838 | return self._send_xml_command(cmd) |
|
| 2839 | ||
| 2840 | def create_ticket( |
|
| 2841 | self, |
|
| @@ 306-418 (lines=113) @@ | ||
| 303 | ||
| 304 | return self._send_xml_command(cmd) |
|
| 305 | ||
| 306 | def modify_credential( |
|
| 307 | self, |
|
| 308 | credential_id: str, |
|
| 309 | *, |
|
| 310 | name: Optional[str] = None, |
|
| 311 | comment: Optional[str] = None, |
|
| 312 | allow_insecure: Optional[bool] = None, |
|
| 313 | certificate: Optional[str] = None, |
|
| 314 | key_phrase: Optional[str] = None, |
|
| 315 | private_key: Optional[str] = None, |
|
| 316 | login: Optional[str] = None, |
|
| 317 | password: Optional[str] = None, |
|
| 318 | auth_algorithm: Optional[SnmpAuthAlgorithm] = None, |
|
| 319 | community: Optional[str] = None, |
|
| 320 | privacy_algorithm: Optional[SnmpPrivacyAlgorithm] = None, |
|
| 321 | privacy_password: Optional[str] = None, |
|
| 322 | public_key: Optional[str] = None, |
|
| 323 | ) -> Any: |
|
| 324 | """Modifies an existing credential. |
|
| 325 | ||
| 326 | Arguments: |
|
| 327 | credential_id: UUID of the credential |
|
| 328 | name: Name of the credential |
|
| 329 | comment: Comment for the credential |
|
| 330 | allow_insecure: Whether to allow insecure use of the credential |
|
| 331 | certificate: Certificate for the credential |
|
| 332 | key_phrase: Key passphrase for the private key |
|
| 333 | private_key: Private key to use for login |
|
| 334 | login: Username for the credential |
|
| 335 | password: Password for the credential |
|
| 336 | auth_algorithm: The authentication algorithm for SNMP |
|
| 337 | community: The SNMP community |
|
| 338 | privacy_algorithm: The privacy algorithm for SNMP |
|
| 339 | privacy_password: The SNMP privacy password |
|
| 340 | public_key: PGP public key in *armor* plain text format |
|
| 341 | ||
| 342 | Returns: |
|
| 343 | The response. See :py:meth:`send_command` for details. |
|
| 344 | """ |
|
| 345 | if not credential_id: |
|
| 346 | raise RequiredArgument( |
|
| 347 | function=self.modify_credential.__name__, |
|
| 348 | argument='credential_id', |
|
| 349 | ) |
|
| 350 | ||
| 351 | cmd = XmlCommand("modify_credential") |
|
| 352 | cmd.set_attribute("credential_id", credential_id) |
|
| 353 | ||
| 354 | if comment: |
|
| 355 | cmd.add_element("comment", comment) |
|
| 356 | ||
| 357 | if name: |
|
| 358 | cmd.add_element("name", name) |
|
| 359 | ||
| 360 | if allow_insecure is not None: |
|
| 361 | cmd.add_element("allow_insecure", _to_bool(allow_insecure)) |
|
| 362 | ||
| 363 | if certificate: |
|
| 364 | cmd.add_element("certificate", certificate) |
|
| 365 | ||
| 366 | if key_phrase and private_key: |
|
| 367 | _xmlkey = cmd.add_element("key") |
|
| 368 | _xmlkey.add_element("phrase", key_phrase) |
|
| 369 | _xmlkey.add_element("private", private_key) |
|
| 370 | elif (not key_phrase and private_key) or ( |
|
| 371 | key_phrase and not private_key |
|
| 372 | ): |
|
| 373 | raise RequiredArgument( |
|
| 374 | function=self.modify_credential.__name__, |
|
| 375 | argument='key_phrase and private_key', |
|
| 376 | ) |
|
| 377 | ||
| 378 | if login: |
|
| 379 | cmd.add_element("login", login) |
|
| 380 | ||
| 381 | if password: |
|
| 382 | cmd.add_element("password", password) |
|
| 383 | ||
| 384 | if auth_algorithm: |
|
| 385 | if not isinstance(auth_algorithm, self.types.SnmpAuthAlgorithm): |
|
| 386 | raise InvalidArgumentType( |
|
| 387 | function=self.modify_credential.__name__, |
|
| 388 | argument='auth_algorithm', |
|
| 389 | arg_type=SnmpAuthAlgorithm.__name__, |
|
| 390 | ) |
|
| 391 | cmd.add_element("auth_algorithm", auth_algorithm.value) |
|
| 392 | ||
| 393 | if community: |
|
| 394 | cmd.add_element("community", community) |
|
| 395 | ||
| 396 | if privacy_algorithm is not None or privacy_password is not None: |
|
| 397 | _xmlprivacy = cmd.add_element("privacy") |
|
| 398 | ||
| 399 | if privacy_algorithm is not None: |
|
| 400 | if not isinstance( |
|
| 401 | privacy_algorithm, self.types.SnmpPrivacyAlgorithm |
|
| 402 | ): |
|
| 403 | raise InvalidArgumentType( |
|
| 404 | function=self.modify_credential.__name__, |
|
| 405 | argument='privacy_algorithm', |
|
| 406 | arg_type=SnmpPrivacyAlgorithm.__name__, |
|
| 407 | ) |
|
| 408 | ||
| 409 | _xmlprivacy.add_element("algorithm", privacy_algorithm.value) |
|
| 410 | ||
| 411 | if privacy_password is not None: |
|
| 412 | _xmlprivacy.add_element("password", privacy_password) |
|
| 413 | ||
| 414 | if public_key: |
|
| 415 | _xmlkey = cmd.add_element("key") |
|
| 416 | _xmlkey.add_element("public", public_key) |
|
| 417 | ||
| 418 | return self._send_xml_command(cmd) |
|
| 419 | ||
| 420 | def create_tag( |
|
| 421 | self, |
|