class AWS::IAM::UserGroupCollection
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 }
Attributes
user[R]
@attr_reader [User] The user.
Public Class Methods
new(user, opts = {})
click to toggle source
@api private
Calls superclass method
# File lib/aws/iam/user_group_collection.rb, line 32 def initialize(user, opts = {}) @user = user super end
Public Instance Methods
add(group)
click to toggle source
Adds the user to a group.
@param [Group] group The group to which the user should be added.
# 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()
click to toggle source
Removes this user from all groups. @return [nil]
# File lib/aws/iam/user_group_collection.rb, line 57 def clear each do |group| remove(group) end end
each(options = {}, &block)
click to toggle source
Yields once for each group that the user is in.
@param [Hash] options
@option options [Integer] :limit Limits the number of groups
that are returned.
@option options [Integer] :batch_size Controls how many groups
are requested from the service at once.
@yieldparam [Group] group
@return [nil]
Calls superclass method
# File lib/aws/iam/user_group_collection.rb, line 76 def each(options = {}, &block) super(options.merge(:user_name => user.name), &block) end
remove(group)
click to toggle source
Removes the user from a group.
@param [Group] group The group from which the user should be removed
# 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
Protected Instance Methods
each_item(response) { |group| ... }
click to toggle source
@api private
# File lib/aws/iam/user_group_collection.rb, line 88 def each_item response response.groups.each do |g| group = Group.new_from(:list_groups_for_user, g, g.group_name, :config => config) yield(group) end end
request_method()
click to toggle source
@api private
# File lib/aws/iam/user_group_collection.rb, line 82 def request_method :list_groups_for_user end