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

- old
+ new

@@ -1,42 +1,22 @@ +# frozen_string_literal: true + module Hcloud class Image - Attributes = { - id: nil, - type: nil, - status: nil, - name: nil, - description: nil, - image_size: nil, - disk_size: nil, - created: :time, - created_from: nil, - bound_to: nil, - os_flavor: nil, - os_version: nil, - rapid_deploy: nil - }.freeze + require 'hcloud/image_resource' include EntryLoader - def to_snapshot - update(type: 'snapshot') - end + schema( + created: :time, + deprecated: :time + ) - def update(description: nil, type: nil) - query = {} - method(:update).parameters.inject(query) do |r, x| - (var = eval(x.last.to_s)).nil? ? r : r.merge!(x.last => var) - end - Image.new( - Oj.load(request("images/#{id.to_i}", j: query, method: :put).run.body)['image'], - parent, - client - ) - end + protectable :delete + updatable :description, :type + destructible - def destroy - request("images/#{id.to_i}", method: :delete).run - true + def to_snapshot + update(type: 'snapshot') end end end