lib/hcloud/floating_ip.rb in hcloud-0.1.2 vs lib/hcloud/floating_ip.rb in hcloud-1.0.0

- old
+ new

@@ -1,43 +1,32 @@ +# frozen_string_literal: true + module Hcloud class FloatingIP - Attributes = { - id: nil, - description: nil, - ip: nil, - type: nil, - dns_ptr: nil, - server: nil, - home_location: Location, - blocked: nil - }.freeze + require 'hcloud/floating_ip_resource' + 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 + schema( + home_location: Location, + created: :time + ) + protectable :delete + updatable :description + destructible + + has_actions + 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) + prepare_request('actions/assign', j: COLLECT_ARGS.call(__method__, binding)) end def unassign - j = Oj.load(request("floating_ips/#{id.to_i}/actions/unassign", - method: :post).run.body) - Action.new(j['action'], self, client) + prepare_request('actions/unassign', method: :post) 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 + def change_dns_ptr(ip:, dns_ptr:) + prepare_request('actions/change_dns_ptr', j: COLLECT_ARGS.call(__method__, binding)) end end end