Class: AWS::IAM::UserGroupCollection

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#userObject (readonly)



32
33
34
# File 'lib/aws/iam/user_group_collection.rb', line 32

def user
  @user
end

Instance Method Details

#add(group) ⇒ Object

Adds the user to a group.

Parameters:

  • group (Group)

    The group to which the user should be added.



43
44
45
46
47
# File 'lib/aws/iam/user_group_collection.rb', line 43

def add(group)
  client.add_user_to_group(:group_name => group.name,
                           :user_name => user.name)
  nil
end

#clearnil

Removes this user from all groups.

Returns:

  • (nil)


60
61
62
63
64
# File 'lib/aws/iam/user_group_collection.rb', line 60

def clear
  each do |group|
    remove(group)
  end
end

#each(options = {}) {|group| ... } ⇒ nil

Yields once for each group that the user is in.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :limit (Integer)

    Limits the number of groups that are returned.

  • :batch_size (Integer)

    Controls how many groups are requested from the service at once.

Yield Parameters:

Returns:

  • (nil)


79
80
81
# File 'lib/aws/iam/user_group_collection.rb', line 79

def each(options = {}, &block)
  super(options.merge(:user_name => user.name), &block)
end

#remove(group) ⇒ Object

Removes the user from a group.

Parameters:

  • group (Group)

    The group from which the user should be removed



52
53
54
55
56
# File 'lib/aws/iam/user_group_collection.rb', line 52

def remove(group)
  client.remove_user_from_group(:group_name => group.name,
                                :user_name => user.name)
  nil
end