1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00
fog--fog-aws/lib/fog/aws/models/iam/groups.rb
Josh Lane 0cc4279333 model managed policies
* list attached group/user policies
* fix policy paging
* default managed policy listing
2015-05-29 13:01:25 -07:00

39 lines
1 KiB
Ruby

require 'fog/aws/models/iam/group'
require 'fog/aws/iam/paged_collection'
module Fog
module AWS
class IAM
class Groups < Fog::AWS::IAM::PagedCollection
attribute :username
model Fog::AWS::IAM::Group
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
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
end
end
end
end