|
@@ 3686-3728 (lines=43) @@
|
| 3683 |
|
|
| 3684 |
|
return self._send_xml_command(cmd) |
| 3685 |
|
|
| 3686 |
|
def modify_permission(self, permission_id, comment=None, name=None, |
| 3687 |
|
resource_id=None, resource_type=None, |
| 3688 |
|
subject_id=None, subject_type=None): |
| 3689 |
|
"""Modifies an existing permission. |
| 3690 |
|
|
| 3691 |
|
Arguments: |
| 3692 |
|
permission_id (str): UUID of permission to be modified. |
| 3693 |
|
comment (str, optional): The comment on the permission. |
| 3694 |
|
name (str, optional): Permission name, currently the name of |
| 3695 |
|
a command. |
| 3696 |
|
subject_id (str, optional): UUID of subject to whom the permission |
| 3697 |
|
is granted |
| 3698 |
|
subject_type (str, optional): Type of the subject user, group or |
| 3699 |
|
role |
| 3700 |
|
resource_id (str, optional): UUID of entity to which the permission |
| 3701 |
|
applies |
| 3702 |
|
resource_type (str, optional): Type of the resource. For Super |
| 3703 |
|
permissions user, group or role |
| 3704 |
|
|
| 3705 |
|
Returns: |
| 3706 |
|
The response. See :py:meth:`send_command` for details. |
| 3707 |
|
""" |
| 3708 |
|
if not permission_id: |
| 3709 |
|
raise RequiredArgument('modify_permission requires ' |
| 3710 |
|
'a permission_id element') |
| 3711 |
|
|
| 3712 |
|
cmd = XmlCommand('modify_permission') |
| 3713 |
|
cmd.set_attribute('permission_id', permission_id) |
| 3714 |
|
|
| 3715 |
|
if comment: |
| 3716 |
|
cmd.add_element('comment', comment) |
| 3717 |
|
|
| 3718 |
|
if name: |
| 3719 |
|
cmd.add_element('name', name) |
| 3720 |
|
|
| 3721 |
|
if resource_id and resource_type: |
| 3722 |
|
_xmlresource = cmd.add_element('resource', |
| 3723 |
|
attrs={'id': resource_id}) |
| 3724 |
|
_xmlresource.add_element('type', resource_type) |
| 3725 |
|
|
| 3726 |
|
if subject_id and subject_type: |
| 3727 |
|
_xmlsubject = cmd.add_element('subject', |
| 3728 |
|
attrs={'id': subject_id}) |
| 3729 |
|
_xmlsubject.add_element('type', subject_type) |
| 3730 |
|
|
| 3731 |
|
return self._send_xml_command(cmd) |
|
@@ 772-817 (lines=46) @@
|
| 769 |
|
cmd.add_element('copy', override_id) |
| 770 |
|
return self._send_xml_command(cmd) |
| 771 |
|
|
| 772 |
|
def create_permission(self, name, subject_id, subject_type, |
| 773 |
|
resource_id=None, resource_type=None, |
| 774 |
|
comment=None): |
| 775 |
|
"""Create a new permission |
| 776 |
|
|
| 777 |
|
Arguments: |
| 778 |
|
name (str): Name of the new permission |
| 779 |
|
subject_id (str): UUID of subject to whom the permission is granted |
| 780 |
|
subject_type (str): Type of the subject user, group or role |
| 781 |
|
comment (str, optional): Comment for the permission |
| 782 |
|
resource_id (str, optional): UUID of entity to which the permission |
| 783 |
|
applies |
| 784 |
|
resource_type (str, optional): Type of the resource. For Super |
| 785 |
|
permissions user, group or role |
| 786 |
|
|
| 787 |
|
Returns: |
| 788 |
|
The response. See :py:meth:`send_command` for details. |
| 789 |
|
""" |
| 790 |
|
if not name: |
| 791 |
|
raise RequiredArgument('create_permission requires a name argument') |
| 792 |
|
|
| 793 |
|
if not subject_id: |
| 794 |
|
raise RequiredArgument( |
| 795 |
|
'create_permission requires a subject_id argument') |
| 796 |
|
|
| 797 |
|
if subject_type not in ('user', 'group', 'role'): |
| 798 |
|
raise InvalidArgument( |
| 799 |
|
'create_permission requires subject_type to be either user, ' |
| 800 |
|
'group or role') |
| 801 |
|
|
| 802 |
|
cmd = XmlCommand('create_permission') |
| 803 |
|
cmd.add_element('name', name) |
| 804 |
|
|
| 805 |
|
_xmlsubject = cmd.add_element('subject', attrs={'id': subject_id}) |
| 806 |
|
_xmlsubject.add_element('type', type) |
| 807 |
|
|
| 808 |
|
if comment: |
| 809 |
|
cmd.add_element('comment', comment) |
| 810 |
|
|
| 811 |
|
if resource_id and resource_type: |
| 812 |
|
_xmlresource = cmd.add_element('resource', |
| 813 |
|
attrs={'id': resource_id}) |
| 814 |
|
_xmlresource.add_element('type', resource_type) |
| 815 |
|
|
| 816 |
|
|
| 817 |
|
return self._send_xml_command(cmd) |
| 818 |
|
|
| 819 |
|
def clone_permission(self, permission_id): |
| 820 |
|
"""Clone an existing permission |