lib/hcloud/image.rb in hcloud-0.1.0.pre.alpha2 vs lib/hcloud/image.rb in hcloud-0.1.0.pre.alpha3
- old
+ new
@@ -16,7 +16,27 @@
rapid_deploy: nil,
}
include EntryLoader
+ def to_snapshot
+ update(type: "snapshot")
+ end
+
+ 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
+
+ def destory
+ request("images/#{id.to_i}", method: :delete).run
+ true
+ end
end
end