Sha256: ee66c245f5187ba0f3b76be900799e12bf5b2b6a53881561402defaa7e8f94ea

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

require 'active_support/hash_with_indifferent_access'

module Fog
  module Compute
    class OracleCloud
      class Real
      	def update_ip_reservation (params) 
          params[:name].sub! "/Compute-#{@identity_domain}/#{@username}/", ''
          params[:name] = "/Compute-#{@identity_domain}/#{@username}/#{params[:name]}"
          params = params.reject {|key, value| value.nil?}
          request(
            :method   => 'PUT',
            :expects  => 200,
            :path     => "/ip/reservation#{params[:name]}",
            :body     => Fog::JSON.encode(params),
            :headers  => {
              'Content-Type' => 'application/oracle-compute-v3+json'
            }
          )
      	end
      end
      
      class Mock
        def update_ip_reservation (params)
          response = Excon::Response.new
          clean_name = params[:name].sub "/Compute-#{@identity_domain}/#{@username}/", ''
          
          ip = self.data[:ip_reservations][clean_name].merge!(params.stringify_keys)
          if !ip['permanent'] && !ip['used'] then
            # An unused IP reservation that is no longer permanent will be deleted
            self.data[:ip_reservations].delete(clean_name)
          end

          response.status = 200
          response.body = ip
          response
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-oraclecloud-0.1.17 lib/fog/oraclecloud/requests/compute/update_ip_reservation.rb
fog-oraclecloud-0.1.16 lib/fog/oraclecloud/requests/compute/update_ip_reservation.rb