/usr/lib/ruby/vendor_ruby/AWS/EC2/image_attributes.rb is in ruby-amazon-ec2 0.9.17-3build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | module AWS
module EC2
class Base < AWS::Base
# The ModifyImageAttribute operation modifies an attribute of an AMI. The following attributes may
# currently be modified:
#
# 'launchPermission' : Controls who has permission to launch the AMI. Launch permissions can be
# granted to specific users by adding userIds. The AMI can be made public by adding the 'all' group.
#
# 'productCodes' : Associates product codes with AMIs. This allows a developer to charge a user extra
# for using the AMIs. productCodes is a write once attribute - once it has been set it can not be
# changed or removed. Currently only one product code is supported per AMI.
#
# @option options [String] :image_id ("")
# @option options [String] :attribute ("launchPermission") An attribute to modify, "launchPermission" or "productCodes"
# @option options [String] :operation_type ("")
# @option options [optional, Array] :user_id ([])
# @option options [optional, Array] :group ([])
# @option options [optional, Array] :product_code ([])
#
def modify_image_attribute( options = {} )
# defaults
options = { :image_id => "",
:attribute => "launchPermission",
:operation_type => "",
:user_id => [],
:group => [],
:product_code => [] }.merge(options)
raise ArgumentError, "No ':image_id' provided" if options[:image_id].nil? || options[:image_id].empty?
raise ArgumentError, "No ':attribute' provided" if options[:attribute].nil? || options[:attribute].empty?
# OperationType is not required if modifying a product code.
unless options[:attribute] == 'productCodes'
raise ArgumentError, "No ':operation_type' provided" if options[:operation_type].nil? || options[:operation_type].empty?
end
params = {
"ImageId" => options[:image_id],
"Attribute" => options[:attribute],
"OperationType" => options[:operation_type]
}
# test options provided and make sure they are valid
case options[:attribute]
when "launchPermission"
unless options[:operation_type] == "add" || options[:operation_type] == "remove"
raise ArgumentError, ":operation_type was #{options[:operation_type].to_s} but must be either 'add' or 'remove'"
end
if (options[:user_id].nil? || options[:user_id].empty?) && (options[:group].nil? || options[:group].empty?)
raise ArgumentError, "Option :attribute=>'launchPermission' requires ':user_id' or ':group' options to also be specified"
end
params.merge!(pathlist("UserId", options[:user_id])) unless options[:user_id].nil?
params.merge!(pathlist("Group", options[:group])) unless options[:group].nil?
when "productCodes"
if (options[:product_code].nil? || options[:product_code].empty?)
raise ArgumentError, "Option :attribute=>'productCodes' requires ':product_code' to be specified"
end
params.merge!(pathlist("ProductCode", options[:product_code])) unless options[:product_code].nil?
else
raise ArgumentError, "attribute : #{options[:attribute].to_s} is not an known attribute."
end
return response_generator(:action => "ModifyImageAttribute", :params => params)
end
# The DescribeImageAttribute operation returns information about an attribute of an AMI.
#
# @option options [String] :image_id ("")
# @option options [String] :attribute ("launchPermission") An attribute to describe, "launchPermission" or "productCodes"
#
def describe_image_attribute( options = {} )
# defaults
options = {:image_id => "",
:attribute => "launchPermission"
}.merge(options)
raise ArgumentError, "No ':image_id' provided" if options[:image_id].nil? || options[:image_id].empty?
raise ArgumentError, "No ':attribute' provided" if options[:attribute].nil? || options[:attribute].empty?
params = { "ImageId" => options[:image_id], "Attribute" => options[:attribute] }
# test options provided and make sure they are valid
case options[:attribute]
when "launchPermission", "productCodes"
# these args are ok
else
raise ArgumentError, "attribute : #{options[:attribute].to_s} is not an known attribute."
end
return response_generator(:action => "DescribeImageAttribute", :params => params)
end
# The ResetImageAttribute operation resets an attribute of an AMI to its default value.
#
# @option options [String] :image_id ("")
# @option options [String] :attribute ("launchPermission") An attribute to reset
#
def reset_image_attribute( options = {} )
# defaults
options = {:image_id => "",
:attribute => "launchPermission"}.merge(options)
raise ArgumentError, "No ':image_id' provided" if options[:image_id].nil? || options[:image_id].empty?
raise ArgumentError, "No ':attribute' provided" if options[:attribute].nil? || options[:attribute].empty?
params = {"ImageId" => options[:image_id],
"Attribute" => options[:attribute] }
# test options provided and make sure they are valid
case options[:attribute]
when "launchPermission"
# these args are ok
else
raise ArgumentError, "attribute : #{options[:attribute].to_s} is not an known attribute."
end
return response_generator(:action => "ResetImageAttribute", :params => params)
end
end
end
end
|