Sha256: 1dd5a2e3afc293bf6585071c1b3f3bd29f1e7c8ac81c021fb64c0a21ee57e28e

Contents?: true

Size: 1.93 KB

Versions: 3

Compression:

Stored size: 1.93 KB

Contents

module Fog
  module Compute
    class AWS
      class Real

        require 'fog/aws/parsers/compute/basic'

        # Modify image attributes
        #
        # ==== Parameters
        # * image_id<~String> - Id of machine image to modify
        # * 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, attributes)
          raise ArgumentError.new("image_id is required") unless image_id

          params = {}
          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',
            'ImageId'       => image_id,
            :idempotent     => true,
            :parser         => Fog::Parsers::Compute::AWS::Basic.new
          }.merge!(params))
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
brightbox-cli-0.14.1 lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/compute/modify_image_attribute.rb
brightbox-cli-0.14.0 lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/compute/modify_image_attribute.rb
fog-1.0.0 lib/fog/aws/requests/compute/modify_image_attribute.rb