Sha256: 471e5a6c84d4daa960e87998baa3cf337aee9a74e4c93ea1624fedbc2de6e7e3

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

module Hcloud
  class FloatingIP
    Attributes = {
      id: nil,
      description: nil,
      ip: nil,
      type: nil,
      dns_ptr: nil,
      home_location: Location,
      blocked: nil,
    }
    include EntryLoader

    def update(description:)
      j = Oj.load(request("floating_ips/#{id.to_i}", 
                          j: {description: description}, 
                          method: :put).run.body)
      FloatingIP.new(j["floating_ip"], self, client)
    end
    
    def assign(server:)
      j = Oj.load(request("floating_ips/#{id.to_i}/actions/assign", 
                          j: {server: server}).run.body)
      Action.new(j["action"], self, client)
    end
    
    def unassign
      j = Oj.load(request("floating_ips/#{id.to_i}/actions/unassign", 
                          method: :post).run.body)
      Action.new(j["action"], self, client)
    end
   
    def actions
      ActionResource.new(client: client, parent: self, base_path: "floating_ips/#{id.to_i}")
    end

    def destroy
      request("floating_ips/#{id}", method: :delete).run.body
      true
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hcloud-0.1.0 lib/hcloud/floating_ip.rb
hcloud-0.1.0.pre.alpha4 lib/hcloud/floating_ip.rb