1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[compute|aws] update modify image/snapshot attribute to match latest API

This commit is contained in:
geemus 2011-08-04 10:12:02 -05:00
parent 3a6c9f1979
commit 1708c475f8
2 changed files with 23 additions and 21 deletions

View file

@ -9,23 +9,25 @@ module Fog
#
# ==== Parameters
# * image_id<~String> - Id of machine image to modify
# * attribute<~String> - Attribute to modify, in ['launchPermission', 'productCodes']
# * operation_type<~String> - Operation to perform on attribute, in ['add', 'remove']
#
#
# * attributes<~Hash>:
# * 'Add.Group'<~Array> - One or more groups to grant launch permission to
# * 'Add.UserId'<~Array> - One or more account ids to grant launch permission to
# * 'Description.Value'<String> - New description for image
# * 'ProductCode'<~Array> - One or more product codes to add to image (these can not be removed)
# * 'Remove.Group'<~Array> - One or more groups to revoke launch permission from
# * 'Remove.UserId'<~Array> - One or more account ids to revoke launch permission from
#
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html]
#
def modify_image_attribute(image_id, attribute, operation_type, options = {})
def modify_image_attribute(image_id, attributes)
params = {}
params.merge!(Fog::AWS.indexed_param('UserId', options['UserId']))
params.merge!(Fog::AWS.indexed_param('UserGroup', options['UserGroup']))
params.merge!(Fog::AWS.indexed_param('ProductCode', options['ProductCode']))
params.merge!(Fog::AWS.indexed_param('LaunchPermission.Add.%d.Group', attributes['Add.Group'] || []))
params.merge!(Fog::AWS.indexed_param('LaunchPermission.Add.%d.UserId', attributes['Add.UserId'] || []))
params.merge!(Fog::AWS.indexed_param('LaunchPermission.Remove.%d.Group', attributes['Remove.Group'] || []))
params.merge!(Fog::AWS.indexed_param('LaunchPermission.Remove.%d.UserId', attributes['Remove.UserId'] || []))
params.merge!(Fog::AWS.indexed_param('ProductCode', attributes['ProductCode'] || []))
request({
'Action' => 'ModifyImageAttribute',
'Attribute' => attribute,
'ImageId' => image_id,
'OperationType' => operation_type,
:idempotent => true,
:parser => Fog::Parsers::Compute::AWS::Basic.new
}.merge!(params))

View file

@ -9,22 +9,22 @@ module Fog
#
# ==== Parameters
# * snapshot_id<~String> - Id of snapshot to modify
# * attribute<~String> - Attribute to modify, in ['createVolumePermission']
# * operation_type<~String> - Operation to perform on attribute, in ['add', 'remove']
#
#
# * attributes<~Hash>:
# * 'Add.Group'<~Array> - One or more groups to grant volume create permission to
# * 'Add.UserId'<~Array> - One or more account ids to grant volume create permission to
# * 'Remove.Group'<~Array> - One or more groups to revoke volume create permission from
# * 'Remove.UserId'<~Array> - One or more account ids to revoke volume create permission from
#
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifySnapshotAttribute.html]
#
def modify_snapshot_attribute(snapshot_id, attribute, operation_type, options = {})
def modify_snapshot_attribute(snapshot_id, attributes)
params = {}
params.merge!(Fog::AWS.indexed_param('UserId', options['UserId']))
params.merge!(Fog::AWS.indexed_param('UserGroup', options['UserGroup']))
params.merge!(Fog::AWS.indexed_param('CreateVolumePermission.Add.%d.Group', attributes['Add.Group'] || []))
params.merge!(Fog::AWS.indexed_param('CreateVolumePermission.Add.%d.UserId', attributes['Add.UserId'] || []))
params.merge!(Fog::AWS.indexed_param('CreateVolumePermission.Remove.%d.Group', attributes['Remove.Group'] || []))
params.merge!(Fog::AWS.indexed_param('CreateVolumePermission.Remove.%d.UserId', attributes['Remove.UserId'] || []))
request({
'Action' => 'ModifySnapshotAttribute',
'Attribute' => attribute,
'SnapshotId' => snapshot_id,
'OperationType' => operation_type,
:idempotent => true,
:parser => Fog::Parsers::Compute::AWS::Basic.new
}.merge!(params))