Class: Fog::AWS::IAM::Groups

Inherits:
PagedCollection show all
Defined in:
lib/fog/aws/models/iam/groups.rb

Instance Method Summary collapse

Methods inherited from PagedCollection

#each, #each_entry, inherited

Instance Method Details

#all(options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/aws/models/iam/groups.rb', line 13

def all(options = {})
  data, records = if self.username
                    response = service.list_groups_for_user(self.username, options)
                    [response.body, response.body['GroupsForUser']]
                  else
                    response = service.list_groups(options)
                    [response.body, response.body['Groups']]
                  end

  merge_attributes(data)
  load(records)
end

#get(identity) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/aws/models/iam/groups.rb', line 26

def get(identity)
  data = service.get_group(identity)

  group = data.body['Group']
  users = data.body['Users'].map { |u| service.users.new(u) }

  new(group.merge(:users => users))
rescue Fog::AWS::IAM::NotFound
  nil
end