| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::VastAI::API::SSHKeys; |
|
2
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: Account SSH key management for Vast.ai |
|
4
|
|
|
|
|
|
|
|
|
5
|
10
|
|
|
10
|
|
69
|
use Moo; |
|
|
10
|
|
|
|
|
23
|
|
|
|
10
|
|
|
|
|
61
|
|
|
6
|
10
|
|
|
10
|
|
3933
|
use Carp qw(croak); |
|
|
10
|
|
|
|
|
38
|
|
|
|
10
|
|
|
|
|
842
|
|
|
7
|
10
|
|
|
10
|
|
5186
|
use WWW::VastAI::SSHKey; |
|
|
10
|
|
|
|
|
38
|
|
|
|
10
|
|
|
|
|
335
|
|
|
8
|
10
|
|
|
10
|
|
63
|
use namespace::clean; |
|
|
10
|
|
|
|
|
21
|
|
|
|
10
|
|
|
|
|
83
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has client => ( |
|
11
|
|
|
|
|
|
|
is => 'ro', |
|
12
|
|
|
|
|
|
|
required => 1, |
|
13
|
|
|
|
|
|
|
weak_ref => 1, |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _wrap { |
|
17
|
3
|
|
|
3
|
|
9
|
my ($self, $data) = @_; |
|
18
|
3
|
|
|
|
|
73
|
return WWW::VastAI::SSHKey->new( |
|
19
|
|
|
|
|
|
|
client => $self->client, |
|
20
|
|
|
|
|
|
|
data => $data, |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub list { |
|
25
|
1
|
|
|
1
|
1
|
1529
|
my ($self) = @_; |
|
26
|
1
|
|
|
|
|
11
|
my $result = $self->client->request_op('listSSHKeys'); |
|
27
|
1
|
50
|
0
|
|
|
9
|
my $keys = ref $result eq 'HASH' ? ($result->{ssh_keys} || $result->{results} || []) : ($result || []); |
|
|
|
|
0
|
|
|
|
|
|
28
|
1
|
|
|
|
|
2
|
return [ map { $self->_wrap($_) } @{$keys} ]; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
3
|
|
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub create { |
|
32
|
1
|
|
|
1
|
1
|
14
|
my ($self, $ssh_key) = @_; |
|
33
|
1
|
50
|
|
|
|
5
|
croak "ssh key required" unless $ssh_key; |
|
34
|
1
|
|
|
|
|
11
|
my $result = $self->client->request_op('createSSHKey', body => { ssh_key => $ssh_key }); |
|
35
|
1
|
50
|
33
|
|
|
10
|
my $key = ref $result eq 'HASH' ? ($result->{ssh_key} || $result) : $result; |
|
36
|
1
|
|
|
|
|
5
|
return $self->_wrap($key); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub update { |
|
40
|
1
|
|
|
1
|
1
|
5
|
my ($self, $id, $ssh_key) = @_; |
|
41
|
1
|
50
|
|
|
|
4
|
croak "ssh key id required" unless defined $id; |
|
42
|
1
|
50
|
|
|
|
5
|
croak "ssh key required" unless $ssh_key; |
|
43
|
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
9
|
my $result = $self->client->request_op( |
|
45
|
|
|
|
|
|
|
'updateSSHKey', |
|
46
|
|
|
|
|
|
|
path => { id => $id }, |
|
47
|
|
|
|
|
|
|
body => { ssh_key => $ssh_key }, |
|
48
|
|
|
|
|
|
|
); |
|
49
|
|
|
|
|
|
|
|
|
50
|
1
|
50
|
33
|
|
|
9
|
my $key = ref $result eq 'HASH' ? ($result->{ssh_key} || $result) : $result; |
|
51
|
1
|
|
|
|
|
5
|
return $self->_wrap($key); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub delete { |
|
55
|
1
|
|
|
1
|
1
|
3
|
my ($self, $id) = @_; |
|
56
|
1
|
50
|
|
|
|
8
|
croak "ssh key id required" unless defined $id; |
|
57
|
1
|
|
|
|
|
8
|
return $self->client->request_op('deleteSSHKey', path => { id => $id }); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |