Sha256: 85e11c03638c65bd5afcbe91bc00890eef097ee0379f513e6bbdf85366fe8fba

Contents?: true

Size: 1.53 KB

Versions: 37

Compression:

Stored size: 1.53 KB

Contents

module Fog
  module AWS
    class Compute
      class Real

        require 'fog/aws/parsers/compute/allocate_address'

        # Acquire an elastic IP address.
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'publicIp'<~String> - The acquired address
        #     * 'requestId'<~String> - Id of the request
        def allocate_address
          request(
            'Action'  => 'AllocateAddress',
            :parser   => Fog::Parsers::AWS::Compute::AllocateAddress.new
          )
        end

      end

      class Mock

        def allocate_address
          response = Excon::Response.new
          if describe_addresses.body['addressesSet'].size < @data[:limits][:addresses]
            response.status = 200
            public_ip = Fog::AWS::Mock.ip_address
            data ={
              'instanceId' => nil,
              'publicIp'   => public_ip
            }
            @data[:addresses][public_ip] = data
            response.body = {
              'publicIp'  => public_ip,
              'requestId' => Fog::AWS::Mock.request_id
            }
            response
          else
            response.status = 400
            response.body = "<?xml version=\"1.0\"?><Response><Errors><Error><Code>AddressLimitExceeded</Code><Message>Too many addresses allocated</Message></Error></Errors><RequestID>#{Fog::AWS::Mock.request_id}</RequestID></Response>"
            raise(Excon::Errors.status_error({:expects => 200}, response))
          end
        end

      end
    end
  end
end

Version data entries

37 entries across 37 versions & 2 rubygems

Version Path
fog-0.4.0 lib/fog/aws/requests/compute/allocate_address.rb
fog-0.3.34 lib/fog/aws/requests/compute/allocate_address.rb
fog-0.3.33 lib/fog/aws/requests/compute/allocate_address.rb
fog-0.3.32 lib/fog/aws/requests/compute/allocate_address.rb
fog-0.3.31 lib/fog/aws/requests/compute/allocate_address.rb
fog-0.3.30 lib/fog/aws/requests/compute/allocate_address.rb
fog-0.3.29 lib/fog/aws/requests/compute/allocate_address.rb
fog-0.3.28 lib/fog/aws/requests/compute/allocate_address.rb
fog-0.3.27 lib/fog/aws/requests/compute/allocate_address.rb
fog-0.3.26 lib/fog/aws/requests/compute/allocate_address.rb
fog-0.3.25 lib/fog/aws/requests/compute/allocate_address.rb
fog-0.3.24 lib/fog/aws/requests/compute/allocate_address.rb
bbcloud-0.8.1 lib/bbcloud/vendor/fog-0.3.23/lib/fog/aws/requests/compute/allocate_address.rb
fog-0.3.23 lib/fog/aws/requests/compute/allocate_address.rb
fog-0.3.22 lib/fog/aws/requests/compute/allocate_address.rb
fog-0.3.21 lib/fog/aws/requests/compute/allocate_address.rb
fog-0.3.20 lib/fog/aws/requests/compute/allocate_address.rb
fog-0.3.19 lib/fog/aws/requests/compute/allocate_address.rb
fog-0.3.18 lib/fog/aws/requests/compute/allocate_address.rb
fog-0.3.17 lib/fog/aws/requests/compute/allocate_address.rb