Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

update modify_snapshot_attribute to modern API #752

Open
wants to merge 1 commit into from

1 participant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 15, 2012
  1. @sievlev
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 8 deletions.
  1. +11 −8 boto/ec2/connection.py
View
19 boto/ec2/connection.py
@@ -1758,7 +1758,7 @@ def get_snapshot_attribute(self, snapshot_id,
SnapshotAttribute, verb='POST')
def modify_snapshot_attribute(self, snapshot_id,
- attribute='createVolumePermission',
+ attribute=None,
operation='add', user_ids=None, groups=None):
"""
Changes an attribute of an image.
@@ -1767,8 +1767,7 @@ def modify_snapshot_attribute(self, snapshot_id,
:param snapshot_id: The snapshot id you wish to change
:type attribute: string
- :param attribute: The attribute you wish to change. Valid values are:
- createVolumePermission
+ :param attribute: Ignored, for backward compatibility
:type operation: string
:param operation: Either add or remove (this is required for changing
@@ -1782,13 +1781,17 @@ def modify_snapshot_attribute(self, snapshot_id,
value at this time is 'all'.
"""
- params = {'SnapshotId' : snapshot_id,
- 'Attribute' : attribute,
- 'OperationType' : operation}
+ params = {'SnapshotId' : snapshot_id}
+
+ if not operation and (user_ids or groups):
+ raise BotoClientError('No operation type was specified')
+
if user_ids:
- self.build_list_params(params, user_ids, 'UserId')
+ for i,user_id in enumerate(user_ids):
+ params['CreateVolumePermission.%s.%d.UserId' % (operation.title(),i+1)] = user_id
if groups:
- self.build_list_params(params, groups, 'UserGroup')
+ for i,group in enumerate(groups):
+ params['CreateVolumePermission.%s.%d.Group' % (operation.title(),i+1)] = group
return self.get_status('ModifySnapshotAttribute', params, verb='POST')
def reset_snapshot_attribute(self, snapshot_id,
Something went wrong with that request. Please try again.