Sha256: 72521abca4e5de6cb06212d6b9becaba068f165771e9ee3435ff9d19dd615371
Contents?: true
Size: 930 Bytes
Versions: 1
Compression:
Stored size: 930 Bytes
Contents
module Hcloud class SSHKeyResource < AbstractResource include Enumerable def all j = Oj.load(request("ssh_keys").run.body) j["ssh_keys"].map{|x| SSHKey.new(x, self, client) } end def create(name:, public_key:) j = Oj.load(request("ssh_keys", j: {name: name, public_key: public_key}).run.body) SSHKey.new(j, 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hcloud-0.1.0.pre.alpha4 | lib/hcloud/ssh_key_resource.rb |