Sha256: 8928deac457bdc4e4f8c0685078ae75b866a354ca2a1db86ec1ad8ef64c9758a
Contents?: true
Size: 927 Bytes
Versions: 2
Compression:
Stored size: 927 Bytes
Contents
module Hcloud class SSHKeyResource < AbstractResource def all mj("ssh_keys") do |j| j.flat_map{|x| x["ssh_keys"].map{ |x| SSHKey.new(x, self, client) } } end end def create(name:, public_key:) j = Oj.load(request("ssh_keys", j: {name: name, public_key: public_key}).run.body) SSHKey.new(j["ssh_key"], self, client) end def find(id) SSHKey.new( Oj.load(request("ssh_keys/#{id}").run.body)["ssh_key"], self, client ) end def find_by(name:) x = Oj.load(request("ssh_keys", q: {name: name}).run.body)["ssh_keys"] return nil if x.none? x.each do |s| return SSHKey.new(s, self, client) end end def [](arg) case arg when Integer begin find(arg) rescue Error::NotFound end when String find_by(name: arg) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hcloud-0.1.1 | lib/hcloud/ssh_key_resource.rb |
hcloud-0.1.0 | lib/hcloud/ssh_key_resource.rb |