Sha256: 3b0f375695f0d4bdedf0d1ef841a0ce9a3315466a2c32f9a8f00040a04692a82

Contents?: true

Size: 1.6 KB

Versions: 2

Compression:

Stored size: 1.6 KB

Contents

module Fog
  module Compute
    class OneAndOne

      class Real

        ##
        # Modify a public IP
        # URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#public_ips__ip_id__put]
        ##
        def update_public_ip(ip_id: nil, reverse_dns: nil)
          
          # Build PUT body
          update_ip = {
            'reverse_dns' => reverse_dns
          }

          # Stringify the PUT body
          string_body = Fog::JSON.encode(update_ip)

          # Request
          params = {
            'method' => :put,
            'endpoint' => "/public_ips/#{ip_id}",
            'body' => string_body
          }

          request(params)

        end

      end # Real

      
      class Mock

        def update_public_ip(ip_id: nil, reverse_dns: nil)
          
          # Search for IP to update
          if ip = self.data[:public_ips].find {
            |hash| hash['id'] == ip_id
          }
            # Create parameter hash 
            params = {
              'reverse_dns' => reverse_dns
            }
            
            # Update the IP we found with new values
            params.each do |key, value|
              if value
                ip[key] = value
              end
            end
          else
            raise Fog::Errors::NotFound.new('The requested resource could
              not be found.')
          end

          # Return Response Object to User
          response = Excon::Response.new
          response.status = 202
          response.body = ip
          response

        end

      end # Mock

    end # OneAndOne
  end # Compute
end # Fog

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-oneandone-1.2 lib/oneandone/requests/compute/update_public_ip.rb
fog-oneandone-1.0 lib/oneandone/requests/compute/update_public_ip.rb