Class: AWS::EC2::PermissionCollection
- Inherits:
-
Object
- Object
- AWS::EC2::PermissionCollection
- Includes:
- Enumerable
- Defined in:
- lib/aws/ec2/permission_collection.rb
Overview
Instance Method Summary collapse
-
#add(*users) ⇒ nil
Adds permissions for specific users to launch this AMI.
- #each {|user_id| ... } ⇒ Object
-
#empty? ⇒ Boolean
True if the collection is empty.
-
#private? ⇒ Boolean
True if the resource is private (i.e. not public).
-
#public=(value) ⇒ nil
Sets whether the resource is public or not.
-
#public? ⇒ Boolean
True if the resource is public.
-
#remove(*users) ⇒ nil
Removes permissions for specific users to launch this AMI.
-
#reset ⇒ nil
Resets the launch permissions to their default state.
-
#size ⇒ Integer
The number of users that have explicit permissions to launch this AMI.
Instance Method Details
#add(*users) ⇒ nil
Adds permissions for specific users to launch this AMI.
93 94 95 |
# File 'lib/aws/ec2/permission_collection.rb', line 93 def add(*users) modify(:add, *users) end |
#each {|user_id| ... } ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/aws/ec2/permission_collection.rb', line 38 def each(&block) resp = client.send(describe_call, describe_params) resp.send().each do || if .respond_to?(:user_id) user_id = .user_id yield(user_id) end end end |
#empty? ⇒ Boolean
Returns True if the collection is empty.
55 56 57 |
# File 'lib/aws/ec2/permission_collection.rb', line 55 def empty? size == 0 end |
#private? ⇒ Boolean
Returns True if the resource is private (i.e. not public).
69 70 71 |
# File 'lib/aws/ec2/permission_collection.rb', line 69 def private? !public? end |
#public=(value) ⇒ nil
Sets whether the resource is public or not. This has no effect on the explicit AWS account IDs that may already have permissions to use the resource.
80 81 82 83 84 85 86 |
# File 'lib/aws/ec2/permission_collection.rb', line 80 def public= value params = value ? { :add => [{ :group => "all" }] } : { :remove => [{ :group => "all" }] } client.send(modify_call, modify_params(params)) nil end |
#public? ⇒ Boolean
Returns True if the resource is public.
60 61 62 63 64 65 |
# File 'lib/aws/ec2/permission_collection.rb', line 60 def public? resp = client.send(describe_call, describe_params) resp.send().any? do || .respond_to?(:group) and .group == "all" end end |
#remove(*users) ⇒ nil
Removes permissions for specific users to launch this AMI.
101 102 103 |
# File 'lib/aws/ec2/permission_collection.rb', line 101 def remove(*users) modify(:remove, *users) end |
#reset ⇒ nil
Resets the launch permissions to their default state.
107 108 109 |
# File 'lib/aws/ec2/permission_collection.rb', line 107 def reset client.send(reset_call, reset_params) end |
#size ⇒ Integer
Returns The number of users that have explicit permissions to launch this AMI.
50 51 52 |
# File 'lib/aws/ec2/permission_collection.rb', line 50 def size inject(0) { |sum, i| sum + 1 } end |