|
@@ 3619-3661 (lines=43) @@
|
| 3616 |
|
|
| 3617 |
|
return self._send_xml_command(cmd) |
| 3618 |
|
|
| 3619 |
|
def modify_permission(self, permission_id, comment=None, name=None, |
| 3620 |
|
resource_id=None, resource_type=None, |
| 3621 |
|
subject_id=None, subject_type=None): |
| 3622 |
|
"""Modifies an existing permission. |
| 3623 |
|
|
| 3624 |
|
Arguments: |
| 3625 |
|
permission_id (str): UUID of permission to be modified. |
| 3626 |
|
comment (str, optional): The comment on the permission. |
| 3627 |
|
name (str, optional): Permission name, currently the name of |
| 3628 |
|
a command. |
| 3629 |
|
subject_id (str, optional): UUID of subject to whom the permission |
| 3630 |
|
is granted |
| 3631 |
|
subject_type (str, optional): Type of the subject user, group or |
| 3632 |
|
role |
| 3633 |
|
resource_id (str, optional): UUID of entity to which the permission |
| 3634 |
|
applies |
| 3635 |
|
resource_type (str, optional): Type of the resource. For Super |
| 3636 |
|
permissions user, group or role |
| 3637 |
|
|
| 3638 |
|
Returns: |
| 3639 |
|
The response. See :py:meth:`send_command` for details. |
| 3640 |
|
""" |
| 3641 |
|
if not permission_id: |
| 3642 |
|
raise RequiredArgument('modify_permission requires ' |
| 3643 |
|
'a permission_id element') |
| 3644 |
|
|
| 3645 |
|
cmd = XmlCommand('modify_permission') |
| 3646 |
|
cmd.set_attribute('permission_id', permission_id) |
| 3647 |
|
|
| 3648 |
|
if comment: |
| 3649 |
|
cmd.add_element('comment', comment) |
| 3650 |
|
|
| 3651 |
|
if name: |
| 3652 |
|
cmd.add_element('name', name) |
| 3653 |
|
|
| 3654 |
|
if resource_id and resource_type: |
| 3655 |
|
_xmlresource = cmd.add_element('resource', |
| 3656 |
|
attrs={'id': resource_id}) |
| 3657 |
|
_xmlresource.add_element('type', resource_type) |
| 3658 |
|
|
| 3659 |
|
if subject_id and subject_type: |
| 3660 |
|
_xmlsubject = cmd.add_element('subject', |
| 3661 |
|
attrs={'id': subject_id}) |
| 3662 |
|
_xmlsubject.add_element('type', subject_type) |
| 3663 |
|
|
| 3664 |
|
return self._send_xml_command(cmd) |
|
@@ 743-788 (lines=46) @@
|
| 740 |
|
cmd.add_element('copy', override_id) |
| 741 |
|
return self._send_xml_command(cmd) |
| 742 |
|
|
| 743 |
|
def create_permission(self, name, subject_id, subject_type, |
| 744 |
|
resource_id=None, resource_type=None, |
| 745 |
|
comment=None): |
| 746 |
|
"""Create a new permission |
| 747 |
|
|
| 748 |
|
Arguments: |
| 749 |
|
name (str): Name of the new permission |
| 750 |
|
subject_id (str): UUID of subject to whom the permission is granted |
| 751 |
|
subject_type (str): Type of the subject user, group or role |
| 752 |
|
comment (str, optional): Comment for the permission |
| 753 |
|
resource_id (str, optional): UUID of entity to which the permission |
| 754 |
|
applies |
| 755 |
|
resource_type (str, optional): Type of the resource. For Super |
| 756 |
|
permissions user, group or role |
| 757 |
|
|
| 758 |
|
Returns: |
| 759 |
|
The response. See :py:meth:`send_command` for details. |
| 760 |
|
""" |
| 761 |
|
if not name: |
| 762 |
|
raise RequiredArgument('create_permission requires a name argument') |
| 763 |
|
|
| 764 |
|
if not subject_id: |
| 765 |
|
raise RequiredArgument( |
| 766 |
|
'create_permission requires a subject_id argument') |
| 767 |
|
|
| 768 |
|
if subject_type not in ('user', 'group', 'role'): |
| 769 |
|
raise InvalidArgument( |
| 770 |
|
'create_permission requires subject_type to be either user, ' |
| 771 |
|
'group or role') |
| 772 |
|
|
| 773 |
|
cmd = XmlCommand('create_permission') |
| 774 |
|
cmd.add_element('name', name) |
| 775 |
|
|
| 776 |
|
_xmlsubject = cmd.add_element('subject', attrs={'id': subject_id}) |
| 777 |
|
_xmlsubject.add_element('type', type) |
| 778 |
|
|
| 779 |
|
if comment: |
| 780 |
|
cmd.add_element('comment', comment) |
| 781 |
|
|
| 782 |
|
if resource_id and resource_type: |
| 783 |
|
_xmlresource = cmd.add_element('resource', |
| 784 |
|
attrs={'id': resource_id}) |
| 785 |
|
_xmlresource.add_element('type', resource_type) |
| 786 |
|
|
| 787 |
|
|
| 788 |
|
return self._send_xml_command(cmd) |
| 789 |
|
|
| 790 |
|
def clone_permission(self, permission_id): |
| 791 |
|
"""Clone an existing permission |