Skip to content

Commit

Permalink
Added ListGroupsForUser support to Fog::AWS::IAM
Browse files Browse the repository at this point in the history
  • Loading branch information
crazed authored and Wesley Beary committed Jan 31, 2011
1 parent 9f65b09 commit a91afd3
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/fog/aws/iam.rb
Expand Up @@ -19,6 +19,7 @@ class IAM < Fog::Service
request :get_user
request :list_access_keys
request :list_groups
request :list_groups_for_user
request :list_group_policies
request :list_signing_certificates
request :list_user_policies
Expand Down
32 changes: 32 additions & 0 deletions lib/fog/aws/parsers/iam/list_groups_for_user.rb
@@ -0,0 +1,32 @@
module Fog
module Parsers
module AWS
module IAM

class ListGroupsForUser < Fog::Parsers::Base

def reset
@group_for_user = {}
@response = { 'GroupsForUser' => [] }
end

def end_element(name)
case name
when 'Path', 'GroupName', 'GroupId', 'Arn'
@group_for_user[name] = @value
when 'member'
@response['GroupsForUser'] << @group_for_user
@group_for_user = {}
when 'IsTruncated'
response[name] = (@value == 'true')
when 'Marker', 'RequestId'
response[name] = @value
end
end

end

end
end
end
end
51 changes: 51 additions & 0 deletions lib/fog/aws/requests/iam/list_groups_for_user.rb
@@ -0,0 +1,51 @@
module Fog
module AWS
class IAM
class Real

require 'fog/aws/parsers/iam/list_groups_for_user'

# List groups_for_user
#
# ==== Parameters
# * user_name<~String> - the username you want to look up group membership for
# * options<~Hash>:
# * 'Marker'<~String> - used to paginate subsequent requests
# * 'MaxItems'<~Integer> - limit results to this number per page
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'GroupsForUser'<~Array> - Groups for a user
# * group_for_user<~Hash>:
# * 'Arn' -
# * 'GroupId' -
# * 'GroupName' -
# * 'Path' -
# * 'IsTruncated'<~Boolean> - Whether or not results were truncated
# * 'Marker'<~String> - appears when IsTruncated is true as the next marker to use
# * 'RequestId'<~String> - Id of the request
#
# ==== See Also
# http://docs.amazonwebservices.com/IAM/latest/APIReference/API_ListGroupsForUser.html
#
def list_groups_for_user(user_name, options = {})
request({
'Action' => 'ListGroupsForUser',
'UserName' => user_name,
:parser => Fog::Parsers::AWS::IAM::ListGroupsForUser.new
}.merge!(options))
end

end

class Mock

def list_groups_for_user(user_name = nil)
Fog::Mock.not_implemented
end

end
end
end
end

0 comments on commit a91afd3

Please sign in to comment.