Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added ListGroupsForUser support to Fog::AWS::IAM

  • Loading branch information...
commit a91afd354fb1c2822b692c53121ee49c927fc0b4 1 parent 9f65b09
crazed authored Wesley Beary committed
View
1  lib/fog/aws/iam.rb
@@ -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
View
32 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
View
51 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
Please sign in to comment.
Something went wrong with that request. Please try again.