2010-12-21 14:08:44 -05:00
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class IAM
|
|
|
|
class Real
|
|
|
|
|
|
|
|
require 'fog/aws/parsers/iam/get_user'
|
|
|
|
|
|
|
|
# Get User
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * options<~Hash>:
|
|
|
|
# * 'UserName'<~String>: Name of the User. Defaults to current user
|
|
|
|
#
|
|
|
|
# ==== Returns
|
|
|
|
# * response<~Excon::Response>:
|
|
|
|
# * body<~Hash>:
|
|
|
|
# * 'User'<~Hash> - User
|
|
|
|
# * Arn<~String> -
|
|
|
|
# * UserId<~String> -
|
|
|
|
# * UserName<~String> -
|
|
|
|
# * Path<~String> -
|
|
|
|
#
|
|
|
|
# ==== See Also
|
|
|
|
# http://docs.amazonwebservices.com/IAM/latest/APIReference/API_Getuser.html
|
|
|
|
#
|
|
|
|
def get_user(options = {})
|
|
|
|
request({
|
|
|
|
'Action' => 'GetUser',
|
|
|
|
:parser => Fog::Parsers::AWS::IAM::GetUser.new
|
|
|
|
}.merge!(options))
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2012-06-04 14:34:58 -04:00
|
|
|
|
|
|
|
class Mock
|
|
|
|
def get_user(options = {})
|
|
|
|
user = options['UserName']
|
|
|
|
raise Fog::AWS::IAM::NotFound.new("The user with name #{user} cannot be found.") unless self.data[:users].key?(user)
|
|
|
|
Excon::Response.new.tap do |response|
|
|
|
|
response.body = {'User' => {
|
|
|
|
'UserId' => data[:users][user][:user_id],
|
|
|
|
'Path' => data[:users][user][:path],
|
|
|
|
'UserName' => user,
|
|
|
|
'Arn' => (data[:users][user][:arn]).strip
|
|
|
|
},
|
|
|
|
'IsTruncated' => false,
|
|
|
|
'RequestId' => Fog::AWS::Mock.request_id }
|
|
|
|
response.status = 200
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2010-12-21 14:08:44 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|