forked from fog/fog
/
update_ssh_key.rb
46 lines (40 loc) · 1.25 KB
/
update_ssh_key.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
module Fog
module Compute
class DigitalOceanV2
# noinspection RubyStringKeysInHashInspection
class Real
def update_ssh_key(key_id, name)
update_options = {
:name => name,
}
encoded_body = Fog::JSON.encode(update_options)
request(
:expects => [200],
:headers => {
'Content-Type' => "application/json; charset=UTF-8",
},
:method => 'PUT',
:path => "/v2/account/keys/#{key_id}",
:body => encoded_body,
)
end
end
# noinspection RubyStringKeysInHashInspection
class Mock
def update_ssh_key(key_id, name)
response = Excon::Response.new
response.status = 200
response.body ={
'ssh_key' => {
'id' => 512190,
'fingerprint' => "3b:16:bf:e4:8b:00:8b:b8:59:8c:a9:d3:f0:19:45:fa",
'public_key' => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example",
'name' => "My SSH Public Key"
}
}
response
end
end
end
end
end