Sha256: 9df4d7e51d72bfa3a4e428e1154afff6e03f65cde6847f484ca8f25f676fa153

Contents?: true

Size: 1.77 KB

Versions: 73

Compression:

Stored size: 1.77 KB

Contents

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

        # Create a new user
        #
        # ==== Parameters
        # * user_name<~String>: name of the user to create (do not include path)
        # * path<~String>: optional path to group, defaults to '/'
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'User'<~Hash>:
        #       * 'Arn'<~String> -
        #       * 'Path'<~String> -
        #       * 'UserId'<~String> -
        #       * 'UserName'<~String> -
        #     * 'RequestId'<~String> - Id of the request
        #
        # ==== See Also
        # http://docs.amazonwebservices.com/IAM/latest/APIReference/API_CreateUser.html
        #
        def create_user(user_name, path = '/')
          request(
            'Action'    => 'CreateUser',
            'UserName'  => user_name,
            'Path'      => path,
            :parser     => Fog::Parsers::AWS::IAM::CreateUser.new
          )
        end
      end

      class Mock
        def create_user(user_name, path='/')
          if data[:users].key?(user_name)
            raise Fog::AWS::IAM::EntityAlreadyExists.new "User with name #{user_name} already exists."
          end

          data[:users][user_name][:path] = path

          Excon::Response.new.tap do |response|
            response.status = 200
            response.body = { 'User' => {
              "UserId"     => data[:users][user_name][:user_id],
              "Path"       => path,
              "UserName"   => user_name,
              "Arn"        => (data[:users][user_name][:arn]).strip,
            },
            'RequestId' => Fog::AWS::Mock.request_id
            }
          end
        end
      end
    end
  end
end

Version data entries

73 entries across 71 versions & 3 rubygems

Version Path
fog-aws-3.30.0 lib/fog/aws/requests/iam/create_user.rb
fog-aws-3.29.0 lib/fog/aws/requests/iam/create_user.rb
fog-aws-3.28.0 lib/fog/aws/requests/iam/create_user.rb
fog-aws-3.27.0 lib/fog/aws/requests/iam/create_user.rb
fog-aws-3.26.0 lib/fog/aws/requests/iam/create_user.rb
fog-aws-3.25.0 lib/fog/aws/requests/iam/create_user.rb
fog-aws-3.24.0 lib/fog/aws/requests/iam/create_user.rb
fog-aws-3.23.0 lib/fog/aws/requests/iam/create_user.rb
fog-aws-3.22.0 lib/fog/aws/requests/iam/create_user.rb
fog-aws-3.21.1 lib/fog/aws/requests/iam/create_user.rb
fog-aws-3.21.0 lib/fog/aws/requests/iam/create_user.rb
fog-aws-3.20.0 lib/fog/aws/requests/iam/create_user.rb
fog-aws-3.19.0 lib/fog/aws/requests/iam/create_user.rb
fog-aws-3.18.0 lib/fog/aws/requests/iam/create_user.rb
fog-aws-3.17.0 lib/fog/aws/requests/iam/create_user.rb
fog-aws-3.16.0 lib/fog/aws/requests/iam/create_user.rb
fog-aws-3.15.0 lib/fog/aws/requests/iam/create_user.rb
fog-aws-3.14.0 lib/fog/aws/requests/iam/create_user.rb
fog-aws-3.13.0 lib/fog/aws/requests/iam/create_user.rb
fog-aws-3.12.0 lib/fog/aws/requests/iam/create_user.rb