| @@ 7008-7105 (lines=98) @@ | ||
| 7005 | ||
| 7006 | return self._send_xml_command(cmd) |
|
| 7007 | ||
| 7008 | def modify_user( |
|
| 7009 | self, |
|
| 7010 | user_id: str = None, |
|
| 7011 | name: str = None, |
|
| 7012 | *, |
|
| 7013 | new_name: Optional[str] = None, |
|
| 7014 | comment: Optional[str] = None, |
|
| 7015 | password: Optional[str] = None, |
|
| 7016 | auth_source: Optional[UserAuthType] = None, |
|
| 7017 | role_ids: Optional[List[str]] = None, |
|
| 7018 | hosts: Optional[List[str]] = None, |
|
| 7019 | hosts_allow: Optional[bool] = False, |
|
| 7020 | ifaces: Optional[List[str]] = None, |
|
| 7021 | ifaces_allow: Optional[bool] = False, |
|
| 7022 | group_ids: Optional[List[str]] = None, |
|
| 7023 | ) -> Any: |
|
| 7024 | """Modifies an existing user. Most of the fields need to be supplied |
|
| 7025 | for changing a single field even if no change is wanted for those. |
|
| 7026 | Else empty values are inserted for the missing fields instead. |
|
| 7027 | ||
| 7028 | Arguments: |
|
| 7029 | user_id: UUID of the user to be modified. Overrides name element |
|
| 7030 | argument. |
|
| 7031 | name: The name of the user to be modified. Either user_id or name |
|
| 7032 | must be passed. |
|
| 7033 | new_name: The new name for the user. |
|
| 7034 | comment: Comment on the user. |
|
| 7035 | password: The password for the user. |
|
| 7036 | auth_source: Source allowed for authentication for this user. |
|
| 7037 | roles_id: List of roles UUIDs for the user. |
|
| 7038 | hosts: User access rules: List of hosts. |
|
| 7039 | hosts_allow: Defines how the hosts list is to be interpreted. |
|
| 7040 | If False (default) the list is treated as a deny list. |
|
| 7041 | All hosts are allowed by default except those provided by |
|
| 7042 | the hosts parameter. If True the list is treated as a |
|
| 7043 | allow list. All hosts are denied by default except those |
|
| 7044 | provided by the hosts parameter. |
|
| 7045 | ifaces: User access rules: List of ifaces. |
|
| 7046 | ifaces_allow: Defines how the ifaces list is to be interpreted. |
|
| 7047 | If False (default) the list is treated as a deny list. |
|
| 7048 | All ifaces are allowed by default except those provided by |
|
| 7049 | the ifaces parameter. If True the list is treated as a |
|
| 7050 | allow list. All ifaces are denied by default except those |
|
| 7051 | provided by the ifaces parameter. |
|
| 7052 | group_ids: List of group UUIDs for the user. |
|
| 7053 | ||
| 7054 | Returns: |
|
| 7055 | The response. See :py:meth:`send_command` for details. |
|
| 7056 | """ |
|
| 7057 | if not user_id and not name: |
|
| 7058 | raise RequiredArgument( |
|
| 7059 | function=self.modify_user.__name__, argument='user_id or name' |
|
| 7060 | ) |
|
| 7061 | ||
| 7062 | cmd = XmlCommand("modify_user") |
|
| 7063 | ||
| 7064 | if user_id: |
|
| 7065 | cmd.set_attribute("user_id", user_id) |
|
| 7066 | else: |
|
| 7067 | cmd.add_element("name", name) |
|
| 7068 | ||
| 7069 | if new_name: |
|
| 7070 | cmd.add_element("new_name", new_name) |
|
| 7071 | ||
| 7072 | if role_ids: |
|
| 7073 | for role in role_ids: |
|
| 7074 | cmd.add_element("role", attrs={"id": role}) |
|
| 7075 | ||
| 7076 | if hosts: |
|
| 7077 | cmd.add_element( |
|
| 7078 | "hosts", |
|
| 7079 | _to_comma_list(hosts), |
|
| 7080 | attrs={"allow": _to_bool(hosts_allow)}, |
|
| 7081 | ) |
|
| 7082 | ||
| 7083 | if ifaces: |
|
| 7084 | cmd.add_element( |
|
| 7085 | "ifaces", |
|
| 7086 | _to_comma_list(ifaces), |
|
| 7087 | attrs={"allow": _to_bool(ifaces_allow)}, |
|
| 7088 | ) |
|
| 7089 | ||
| 7090 | if comment: |
|
| 7091 | cmd.add_element("comment", comment) |
|
| 7092 | ||
| 7093 | if password: |
|
| 7094 | cmd.add_element("password", password) |
|
| 7095 | ||
| 7096 | if auth_source: |
|
| 7097 | _xmlauthsrc = cmd.add_element("sources") |
|
| 7098 | _xmlauthsrc.add_element("source", auth_source.value) |
|
| 7099 | ||
| 7100 | if group_ids: |
|
| 7101 | _xmlgroups = cmd.add_element("groups") |
|
| 7102 | for group_id in group_ids: |
|
| 7103 | _xmlgroups.add_element("group", attrs={"id": group_id}) |
|
| 7104 | ||
| 7105 | return self._send_xml_command(cmd) |
|
| 7106 | ||
| 7107 | def move_task(self, task_id: str, *, slave_id: Optional[str] = None) -> Any: |
|
| 7108 | """Move an existing task to another GMP slave scanner or the master |
|
| @@ 6079-6176 (lines=98) @@ | ||
| 6076 | ||
| 6077 | return self._send_xml_command(cmd) |
|
| 6078 | ||
| 6079 | def modify_user( |
|
| 6080 | self, |
|
| 6081 | user_id: str = None, |
|
| 6082 | name: str = None, |
|
| 6083 | *, |
|
| 6084 | new_name: Optional[str] = None, |
|
| 6085 | comment: Optional[str] = None, |
|
| 6086 | password: Optional[str] = None, |
|
| 6087 | auth_source: Optional[UserAuthType] = None, |
|
| 6088 | role_ids: Optional[List[str]] = None, |
|
| 6089 | hosts: Optional[List[str]] = None, |
|
| 6090 | hosts_allow: Optional[bool] = False, |
|
| 6091 | ifaces: Optional[List[str]] = None, |
|
| 6092 | ifaces_allow: Optional[bool] = False, |
|
| 6093 | group_ids: Optional[List[str]] = None, |
|
| 6094 | ) -> Any: |
|
| 6095 | """Modifies an existing user. Most of the fields need to be supplied |
|
| 6096 | for changing a single field even if no change is wanted for those. |
|
| 6097 | Else empty values are inserted for the missing fields instead. |
|
| 6098 | ||
| 6099 | Arguments: |
|
| 6100 | user_id: UUID of the user to be modified. Overrides name element |
|
| 6101 | argument. |
|
| 6102 | name: The name of the user to be modified. Either user_id or name |
|
| 6103 | must be passed. |
|
| 6104 | new_name: The new name for the user. |
|
| 6105 | comment: Comment on the user. |
|
| 6106 | password: The password for the user. |
|
| 6107 | auth_source: Source allowed for authentication for this user. |
|
| 6108 | roles_id: List of roles UUIDs for the user. |
|
| 6109 | hosts: User access rules: List of hosts. |
|
| 6110 | hosts_allow: Defines how the hosts list is to be interpreted. |
|
| 6111 | If False (default) the list is treated as a deny list. |
|
| 6112 | All hosts are allowed by default except those provided by |
|
| 6113 | the hosts parameter. If True the list is treated as a |
|
| 6114 | allow list. All hosts are denied by default except those |
|
| 6115 | provided by the hosts parameter. |
|
| 6116 | ifaces: User access rules: List of ifaces. |
|
| 6117 | ifaces_allow: Defines how the ifaces list is to be interpreted. |
|
| 6118 | If False (default) the list is treated as a deny list. |
|
| 6119 | All ifaces are allowed by default except those provided by |
|
| 6120 | the ifaces parameter. If True the list is treated as a |
|
| 6121 | allow list. All ifaces are denied by default except those |
|
| 6122 | provided by the ifaces parameter. |
|
| 6123 | group_ids: List of group UUIDs for the user. |
|
| 6124 | ||
| 6125 | Returns: |
|
| 6126 | The response. See :py:meth:`send_command` for details. |
|
| 6127 | """ |
|
| 6128 | if not user_id and not name: |
|
| 6129 | raise RequiredArgument( |
|
| 6130 | function=self.modify_user.__name__, argument='user_id or name' |
|
| 6131 | ) |
|
| 6132 | ||
| 6133 | cmd = XmlCommand("modify_user") |
|
| 6134 | ||
| 6135 | if user_id: |
|
| 6136 | cmd.set_attribute("user_id", user_id) |
|
| 6137 | else: |
|
| 6138 | cmd.add_element("name", name) |
|
| 6139 | ||
| 6140 | if new_name: |
|
| 6141 | cmd.add_element("new_name", new_name) |
|
| 6142 | ||
| 6143 | if role_ids: |
|
| 6144 | for role in role_ids: |
|
| 6145 | cmd.add_element("role", attrs={"id": role}) |
|
| 6146 | ||
| 6147 | if hosts: |
|
| 6148 | cmd.add_element( |
|
| 6149 | "hosts", |
|
| 6150 | _to_comma_list(hosts), |
|
| 6151 | attrs={"allow": _to_bool(hosts_allow)}, |
|
| 6152 | ) |
|
| 6153 | ||
| 6154 | if ifaces: |
|
| 6155 | cmd.add_element( |
|
| 6156 | "ifaces", |
|
| 6157 | _to_comma_list(ifaces), |
|
| 6158 | attrs={"allow": _to_bool(ifaces_allow)}, |
|
| 6159 | ) |
|
| 6160 | ||
| 6161 | if comment: |
|
| 6162 | cmd.add_element("comment", comment) |
|
| 6163 | ||
| 6164 | if password: |
|
| 6165 | cmd.add_element("password", password) |
|
| 6166 | ||
| 6167 | if auth_source: |
|
| 6168 | _xmlauthsrc = cmd.add_element("sources") |
|
| 6169 | _xmlauthsrc.add_element("source", auth_source.value) |
|
| 6170 | ||
| 6171 | if group_ids: |
|
| 6172 | _xmlgroups = cmd.add_element("groups") |
|
| 6173 | for group_id in group_ids: |
|
| 6174 | _xmlgroups.add_element("group", attrs={"id": group_id}) |
|
| 6175 | ||
| 6176 | return self._send_xml_command(cmd) |
|
| 6177 | ||
| 6178 | def move_task(self, task_id: str, *, slave_id: Optional[str] = None) -> Any: |
|
| 6179 | """Move an existing task to another GMP slave scanner or the master |
|
| @@ 628-720 (lines=93) @@ | ||
| 625 | ||
| 626 | return self._send_xml_command(cmd) |
|
| 627 | ||
| 628 | def modify_user( |
|
| 629 | self, |
|
| 630 | user_id: str = None, |
|
| 631 | *, |
|
| 632 | name: Optional[str] = None, |
|
| 633 | comment: Optional[str] = None, |
|
| 634 | password: Optional[str] = None, |
|
| 635 | auth_source: Optional[UserAuthType] = None, |
|
| 636 | role_ids: Optional[List[str]] = None, |
|
| 637 | hosts: Optional[List[str]] = None, |
|
| 638 | hosts_allow: Optional[bool] = False, |
|
| 639 | ifaces: Optional[List[str]] = None, |
|
| 640 | ifaces_allow: Optional[bool] = False, |
|
| 641 | group_ids: Optional[List[str]] = None, |
|
| 642 | ) -> Any: |
|
| 643 | ||
| 644 | """Modifies an existing user. Most of the fields need to be supplied |
|
| 645 | for changing a single field even if no change is wanted for those. |
|
| 646 | Else empty values are inserted for the missing fields instead. |
|
| 647 | ||
| 648 | Arguments: |
|
| 649 | user_id: UUID of the user to be modified. |
|
| 650 | name: The new name for the user. |
|
| 651 | comment: Comment on the user. |
|
| 652 | password: The password for the user. |
|
| 653 | auth_source: Source allowed for authentication for this user. |
|
| 654 | roles_id: List of roles UUIDs for the user. |
|
| 655 | hosts: User access rules: List of hosts. |
|
| 656 | hosts_allow: Defines how the hosts list is to be interpreted. |
|
| 657 | If False (default) the list is treated as a deny list. |
|
| 658 | All hosts are allowed by default except those provided by |
|
| 659 | the hosts parameter. If True the list is treated as a |
|
| 660 | allow list. All hosts are denied by default except those |
|
| 661 | provided by the hosts parameter. |
|
| 662 | ifaces: User access rules: List of ifaces. |
|
| 663 | ifaces_allow: Defines how the ifaces list is to be interpreted. |
|
| 664 | If False (default) the list is treated as a deny list. |
|
| 665 | All ifaces are allowed by default except those provided by |
|
| 666 | the ifaces parameter. If True the list is treated as a |
|
| 667 | allow list. All ifaces are denied by default except those |
|
| 668 | provided by the ifaces parameter. |
|
| 669 | group_ids: List of group UUIDs for the user. |
|
| 670 | ||
| 671 | Returns: |
|
| 672 | The response. See :py:meth:`send_command` for details. |
|
| 673 | """ |
|
| 674 | if not user_id: |
|
| 675 | raise RequiredArgument( |
|
| 676 | function=self.modify_user.__name__, argument='user_id' |
|
| 677 | ) |
|
| 678 | ||
| 679 | cmd = XmlCommand("modify_user") |
|
| 680 | ||
| 681 | if user_id: |
|
| 682 | cmd.set_attribute("user_id", user_id) |
|
| 683 | ||
| 684 | if name: |
|
| 685 | cmd.add_element("new_name", name) |
|
| 686 | ||
| 687 | if role_ids: |
|
| 688 | for role in role_ids: |
|
| 689 | cmd.add_element("role", attrs={"id": role}) |
|
| 690 | ||
| 691 | if hosts: |
|
| 692 | cmd.add_element( |
|
| 693 | "hosts", |
|
| 694 | _to_comma_list(hosts), |
|
| 695 | attrs={"allow": _to_bool(hosts_allow)}, |
|
| 696 | ) |
|
| 697 | ||
| 698 | if ifaces: |
|
| 699 | cmd.add_element( |
|
| 700 | "ifaces", |
|
| 701 | _to_comma_list(ifaces), |
|
| 702 | attrs={"allow": _to_bool(ifaces_allow)}, |
|
| 703 | ) |
|
| 704 | ||
| 705 | if comment: |
|
| 706 | cmd.add_element("comment", comment) |
|
| 707 | ||
| 708 | if password: |
|
| 709 | cmd.add_element("password", password) |
|
| 710 | ||
| 711 | if auth_source: |
|
| 712 | _xmlauthsrc = cmd.add_element("sources") |
|
| 713 | _xmlauthsrc.add_element("source", auth_source.value) |
|
| 714 | ||
| 715 | if group_ids: |
|
| 716 | _xmlgroups = cmd.add_element("groups") |
|
| 717 | for group_id in group_ids: |
|
| 718 | _xmlgroups.add_element("group", attrs={"id": group_id}) |
|
| 719 | ||
| 720 | return self._send_xml_command(cmd) |
|
| 721 | ||