Module: Packet::Client::SshKeys
- Included in:
- Packet::Client
- Defined in:
- lib/packet/client/ssh_keys.rb
Instance Method Summary collapse
- #create_ssh_key(ssh_key) ⇒ Object
- #delete_ssh_key(ssh_key_or_id) ⇒ Object
- #get_ssh_key(id, *args) ⇒ Object
- #list_ssh_keys(*args) ⇒ Object
- #update_ssh_key(ssh_key) ⇒ Object
Instance Method Details
#create_ssh_key(ssh_key) ⇒ Object
12 13 14 15 16 |
# File 'lib/packet/client/ssh_keys.rb', line 12 def create_ssh_key(ssh_key) post('ssh-keys', ssh_key.to_hash).tap do |response| ssh_key.update_attributes(response.body) end end |
#delete_ssh_key(ssh_key_or_id) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/packet/client/ssh_keys.rb', line 24 def delete_ssh_key(ssh_key_or_id) id = if ssh_key_or_id.is_a?(Packet::SshKey) ssh_key_or_id.id else ssh_key_or_id end delete("ssh-keys/#{id}") end |
#get_ssh_key(id, *args) ⇒ Object
8 9 10 |
# File 'lib/packet/client/ssh_keys.rb', line 8 def get_ssh_key(id, *args) Packet::SshKey.new(get("ssh-keys/#{id}", *args).body, self) end |
#list_ssh_keys(*args) ⇒ Object
4 5 6 |
# File 'lib/packet/client/ssh_keys.rb', line 4 def list_ssh_keys(*args) get('ssh-keys', *args).body['ssh_keys'].map { |p| Packet::SshKey.new(p, self) } end |
#update_ssh_key(ssh_key) ⇒ Object
18 19 20 21 22 |
# File 'lib/packet/client/ssh_keys.rb', line 18 def update_ssh_key(ssh_key) patch("ssh-keys/#{ssh_key.id}", ssh_key.to_hash).tap do |response| ssh_key.update_attributes(response.body) end end |