You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.
Class: AWS::IAM::UserGroupCollection
- Inherits:
-
Object
- Object
- AWS::IAM::UserGroupCollection
- Includes:
- Collection
- Defined in:
- lib/aws/iam/user_group_collection.rb
Overview
A collection that provides access to IAM groups to which a particular user belongs.
user = AWS::IAM.new.users.first
groups = user.groups
groups.each { |g| puts g.name }
Instance Attribute Summary collapse
-
#user ⇒ Object
readonly
Instance Method Summary collapse
-
#add(group) ⇒ Object
Adds the user to a group.
-
#clear ⇒ nil
Removes this user from all groups.
-
#each(options = {}) {|group| ... } ⇒ nil
Yields once for each group that the user is in.
-
#remove(group) ⇒ Object
Removes the user from a group.
Methods included from Core::Collection
#each_batch, #enum, #first, #in_groups_of, #page
Instance Attribute Details
#user ⇒ Object (readonly)
29 30 31 |
# File 'lib/aws/iam/user_group_collection.rb', line 29 def user @user end |
Instance Method Details
#add(group) ⇒ Object
Adds the user to a group.
40 41 42 43 44 |
# File 'lib/aws/iam/user_group_collection.rb', line 40 def add(group) client.add_user_to_group(:group_name => group.name, :user_name => user.name) nil end |
#clear ⇒ nil
Removes this user from all groups.
57 58 59 60 61 |
# File 'lib/aws/iam/user_group_collection.rb', line 57 def clear each do |group| remove(group) end end |
#each(options = {}) {|group| ... } ⇒ nil
Yields once for each group that the user is in.
76 77 78 |
# File 'lib/aws/iam/user_group_collection.rb', line 76 def each( = {}, &block) super(.merge(:user_name => user.name), &block) end |
#remove(group) ⇒ Object
Removes the user from a group.
49 50 51 52 53 |
# File 'lib/aws/iam/user_group_collection.rb', line 49 def remove(group) client.remove_user_from_group(:group_name => group.name, :user_name => user.name) nil end |