Sha256: 448424a8fd755876274af804566ee6ff68a8f92e1900e5516be6c4cf975e1585

Contents?: true

Size: 1.83 KB

Versions: 25

Compression:

Stored size: 1.83 KB

Contents

module Fog
  module AWS
    class IAM
      class Real
        require 'fog/aws/parsers/iam/get_user'

        # Get User
        #
        # ==== Parameters
        # * username<String>
        # * 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(username, options = {})
          request({
            'Action'    => 'GetUser',
            'UserName'  => username,
            :parser     => Fog::Parsers::AWS::IAM::GetUser.new
          }.merge!(options))
        end
      end

      class Mock
        def get_user(user, options = {})
          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,
                                          'CreateDate' => data[:users][user][:created_at]
                                        },
                             'RequestId'   => Fog::AWS::Mock.request_id }
            response.status = 200
          end
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 5 rubygems

Version Path
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/aws/requests/iam/get_user.rb
fog-aws-0.2.2 lib/fog/aws/requests/iam/get_user.rb
fog-aws-0.2.0 lib/fog/aws/requests/iam/get_user.rb
fog-aws-0.1.2 lib/fog/aws/requests/iam/get_user.rb
fog-aws-0.1.1 lib/fog/aws/requests/iam/get_user.rb
fog-aws-0.1.0 lib/fog/aws/requests/iam/get_user.rb
fog-aws-0.0.8 lib/fog/aws/requests/iam/get_user.rb
fog-aws-0.0.7 lib/fog/aws/requests/iam/get_user.rb
fog-aws-0.0.6 lib/fog/aws/requests/iam/get_user.rb
fog-aws-0.0.5 lib/fog/aws/requests/iam/get_user.rb
fog-1.26.0 lib/fog/aws/requests/iam/get_user.rb
fog-1.25.0 lib/fog/aws/requests/iam/get_user.rb
nsidc-fog-1.24.1 lib/fog/aws/requests/iam/get_user.rb
fog-1.24.0 lib/fog/aws/requests/iam/get_user.rb
ns-fog-1.22.11 lib/fog/aws/requests/iam/get_user.rb
ns-fog-1.22.10 lib/fog/aws/requests/iam/get_user.rb
ns-fog-1.22.9 lib/fog/aws/requests/iam/get_user.rb
ns-fog-1.22.8 lib/fog/aws/requests/iam/get_user.rb
ns-fog-1.22.7 lib/fog/aws/requests/iam/get_user.rb
ns-fog-1.22.6 lib/fog/aws/requests/iam/get_user.rb