@@ 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 |
@@ 6917-7014 (lines=98) @@ | ||
6914 | ||
6915 | return self._send_xml_command(cmd) |
|
6916 | ||
6917 | def modify_user( |
|
6918 | self, |
|
6919 | user_id: str = None, |
|
6920 | name: str = None, |
|
6921 | *, |
|
6922 | new_name: Optional[str] = None, |
|
6923 | comment: Optional[str] = None, |
|
6924 | password: Optional[str] = None, |
|
6925 | auth_source: Optional[UserAuthType] = None, |
|
6926 | role_ids: Optional[List[str]] = None, |
|
6927 | hosts: Optional[List[str]] = None, |
|
6928 | hosts_allow: Optional[bool] = False, |
|
6929 | ifaces: Optional[List[str]] = None, |
|
6930 | ifaces_allow: Optional[bool] = False, |
|
6931 | group_ids: Optional[List[str]] = None, |
|
6932 | ) -> Any: |
|
6933 | """Modifies an existing user. Most of the fields need to be supplied |
|
6934 | for changing a single field even if no change is wanted for those. |
|
6935 | Else empty values are inserted for the missing fields instead. |
|
6936 | ||
6937 | Arguments: |
|
6938 | user_id: UUID of the user to be modified. Overrides name element |
|
6939 | argument. |
|
6940 | name: The name of the user to be modified. Either user_id or name |
|
6941 | must be passed. |
|
6942 | new_name: The new name for the user. |
|
6943 | comment: Comment on the user. |
|
6944 | password: The password for the user. |
|
6945 | auth_source: Source allowed for authentication for this user. |
|
6946 | roles_id: List of roles UUIDs for the user. |
|
6947 | hosts: User access rules: List of hosts. |
|
6948 | hosts_allow: Defines how the hosts list is to be interpreted. |
|
6949 | If False (default) the list is treated as a deny list. |
|
6950 | All hosts are allowed by default except those provided by |
|
6951 | the hosts parameter. If True the list is treated as a |
|
6952 | allow list. All hosts are denied by default except those |
|
6953 | provided by the hosts parameter. |
|
6954 | ifaces: User access rules: List of ifaces. |
|
6955 | ifaces_allow: Defines how the ifaces list is to be interpreted. |
|
6956 | If False (default) the list is treated as a deny list. |
|
6957 | All ifaces are allowed by default except those provided by |
|
6958 | the ifaces parameter. If True the list is treated as a |
|
6959 | allow list. All ifaces are denied by default except those |
|
6960 | provided by the ifaces parameter. |
|
6961 | group_ids: List of group UUIDs for the user. |
|
6962 | ||
6963 | Returns: |
|
6964 | The response. See :py:meth:`send_command` for details. |
|
6965 | """ |
|
6966 | if not user_id and not name: |
|
6967 | raise RequiredArgument( |
|
6968 | function=self.modify_user.__name__, argument='user_id or name' |
|
6969 | ) |
|
6970 | ||
6971 | cmd = XmlCommand("modify_user") |
|
6972 | ||
6973 | if user_id: |
|
6974 | cmd.set_attribute("user_id", user_id) |
|
6975 | else: |
|
6976 | cmd.add_element("name", name) |
|
6977 | ||
6978 | if new_name: |
|
6979 | cmd.add_element("new_name", new_name) |
|
6980 | ||
6981 | if role_ids: |
|
6982 | for role in role_ids: |
|
6983 | cmd.add_element("role", attrs={"id": role}) |
|
6984 | ||
6985 | if hosts: |
|
6986 | cmd.add_element( |
|
6987 | "hosts", |
|
6988 | _to_comma_list(hosts), |
|
6989 | attrs={"allow": _to_bool(hosts_allow)}, |
|
6990 | ) |
|
6991 | ||
6992 | if ifaces: |
|
6993 | cmd.add_element( |
|
6994 | "ifaces", |
|
6995 | _to_comma_list(ifaces), |
|
6996 | attrs={"allow": _to_bool(ifaces_allow)}, |
|
6997 | ) |
|
6998 | ||
6999 | if comment: |
|
7000 | cmd.add_element("comment", comment) |
|
7001 | ||
7002 | if password: |
|
7003 | cmd.add_element("password", password) |
|
7004 | ||
7005 | if auth_source: |
|
7006 | _xmlauthsrc = cmd.add_element("sources") |
|
7007 | _xmlauthsrc.add_element("source", auth_source.value) |
|
7008 | ||
7009 | if group_ids: |
|
7010 | _xmlgroups = cmd.add_element("groups") |
|
7011 | for group_id in group_ids: |
|
7012 | _xmlgroups.add_element("group", attrs={"id": group_id}) |
|
7013 | ||
7014 | return self._send_xml_command(cmd) |
|
7015 | ||
7016 | def move_task(self, task_id: str, *, slave_id: Optional[str] = None) -> Any: |
|
7017 | """Move an existing task to another GMP slave scanner or the master |