class AWS::EC2::PermissionCollection
that use this interface.
{Image} and {Snapshot} classes are currently the only ones
user who has permission to use the resource in question. The
Each permission is a string containing the AWS account ID of a
Represents the collection of permissions for an EC2 resource.
def add(*users)
-
(nil)
-
Parameters:
-
users
(Array of Strings
) -- The AWS account IDs of the
def add(*users) modify(:add, *users) end
def describe_call
def describe_call "describe_#{resource_name}_attribute" end
def describe_params
def describe_params Hash[[["#{resource_name}_id".to_sym, @resource.send(:__resource_id__)], [:attribute, permissions_attribute]]] end
def each(&block)
- Yield: - Each user ID that has explicit
def each(&block) resp = client.send(describe_call, describe_params) resp.send(inflected_permissions_attribute).each do |permission| if permission.respond_to?(:user_id) user_id = permission.user_id yield(user_id) end end end
def empty?
-
(Boolean)
- True if the collection is empty.
def empty? size == 0 end
def inflected_permissions_attribute
def inflected_permissions_attribute Core::Inflection.ruby_name(permissions_attribute).to_sym end
def initialize(resource, opts = {})
- Private: -
def initialize(resource, opts = {}) @resource = resource super(opts) end
def modify(action, *users)
def modify(action, *users) return if users.empty? opts = modify_params(Hash[[[action, users.map do |user_id| { :user_id => user_id } end]]]) client.send(modify_call, opts) nil end
def modify_call
def modify_call "modify_#{resource_name}_attribute" end
def modify_params(modifications)
def modify_params(modifications) Hash[[["#{resource_name}_id".to_sym, @resource.send(:__resource_id__)], [inflected_permissions_attribute, modifications]]] end
def permissions_attribute
def permissions_attribute @resource.__permissions_attribute__ end
def private?
-
(Boolean)
- True if the resource is private (i.e. not
def private? !public? end
def public= value
-
(nil)
-
Parameters:
-
value
(Boolean
) -- If true, the resource is made public,
def public= value params = value ? { :add => [{ :group => "all" }] } : { :remove => [{ :group => "all" }] } client.send(modify_call, modify_params(params)) nil end
def public?
-
(Boolean)
- True if the resource is public.
def public? resp = client.send(describe_call, describe_params) resp.send(inflected_permissions_attribute).any? do |permission| permission.respond_to?(:group) and permission.group == "all" end end
def remove(*users)
-
(nil)
-
Parameters:
-
users
(Array of Strings
) -- The AWS account IDs of the
def remove(*users) modify(:remove, *users) end
def reset
-
(nil)
-
def reset client.send(reset_call, reset_params) end
def reset_call
def reset_call "reset_#{resource_name}_attribute" end
def resource_name
def resource_name @resource.send(:inflected_name) end
def size
-
(Integer)
- The number of users that have explicit
def size inject(0) { |sum, i| sum + 1 } end