Sha256: 0a0db74d294fdc2ec1a487b05b7f231606e6d60706d3844a3e1d7f0844831885

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

module Fog
  module Compute
    class OracleCloud
      class Real
      	def create_ip_reservation (params)
          if !params[:name].nil? && !params[:name].start_with?("/Compute-") then
            # They haven't provided a well formed name, add their name in
            params[:name] = "/Compute-#{@identity_domain}/#{@username}/#{params[:name]}"
          end            

          params = params.reject {|key, value| value.nil?}
          request(
            :method   => 'POST',
            :expects  => 201,
            :path     => "/ip/reservation/",
            :body     => Fog::JSON.encode(params),
            :headers  => {
              'Content-Type' => 'application/oracle-compute-v3+json'
            }
          )
      	end
      end

      class Mock
        def create_ip_reservation (params)
          response = Excon::Response.new
          name = params[:name]
          name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
          self.data[:ip_reservations][name] = {
            'name' => "/Compute-#{@identity_domain}/#{@username}/#{name}",
            'account' => "/Compute-#{@identity_domain}/#{@username}",
            'used' => false,
            'tags' => params[:tags] || [],
            'ip' => '123.123.123.56',
            'uri' => "#{@api_endpoint}ip/reservation/Compute-#{@identity_domain}/#{@username}/#{name}",
            'quota' => nil,
            'parentpool' => params[:parentpool],
            'permanent' => params[:permanent]
          }
          response.status = 201
          response.body = self.data[:ip_reservations][name]
          response
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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