| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::VastAI::API::APIKeys; |
|
2
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: API key management for Vast.ai |
|
4
|
|
|
|
|
|
|
|
|
5
|
10
|
|
|
10
|
|
73
|
use Moo; |
|
|
10
|
|
|
|
|
26
|
|
|
|
10
|
|
|
|
|
61
|
|
|
6
|
10
|
|
|
10
|
|
3596
|
use Carp qw(croak); |
|
|
10
|
|
|
|
|
58
|
|
|
|
10
|
|
|
|
|
745
|
|
|
7
|
10
|
|
|
10
|
|
4670
|
use WWW::VastAI::APIKey; |
|
|
10
|
|
|
|
|
33
|
|
|
|
10
|
|
|
|
|
412
|
|
|
8
|
10
|
|
|
10
|
|
14916
|
use namespace::clean; |
|
|
10
|
|
|
|
|
181801
|
|
|
|
10
|
|
|
|
|
84
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has client => ( |
|
11
|
|
|
|
|
|
|
is => 'ro', |
|
12
|
|
|
|
|
|
|
required => 1, |
|
13
|
|
|
|
|
|
|
weak_ref => 1, |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _wrap { |
|
17
|
2
|
|
|
2
|
|
6
|
my ($self, $data) = @_; |
|
18
|
2
|
|
|
|
|
61
|
return WWW::VastAI::APIKey->new( |
|
19
|
|
|
|
|
|
|
client => $self->client, |
|
20
|
|
|
|
|
|
|
data => $data, |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub list { |
|
25
|
1
|
|
|
1
|
1
|
1513
|
my ($self) = @_; |
|
26
|
1
|
|
|
|
|
8
|
my $result = $self->client->request_op('listAPIKeys'); |
|
27
|
1
|
50
|
0
|
|
|
9
|
my $keys = ref $result eq 'HASH' ? ($result->{api_keys} || $result->{results} || []) : ($result || []); |
|
|
|
|
0
|
|
|
|
|
|
28
|
1
|
|
|
|
|
3
|
return [ map { $self->_wrap($_) } @{$keys} ]; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
4
|
|
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub create { |
|
32
|
1
|
|
|
1
|
1
|
3182
|
my ($self, %params) = @_; |
|
33
|
1
|
50
|
|
|
|
6
|
croak "name required" unless $params{name}; |
|
34
|
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
8
|
my $result = $self->client->request_op('createAPIKey', body => \%params); |
|
36
|
1
|
50
|
33
|
|
|
9
|
my $key = ref $result eq 'HASH' ? ($result->{api_key} || $result) : $result; |
|
37
|
1
|
|
|
|
|
4
|
return $self->_wrap($key); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub delete { |
|
41
|
1
|
|
|
1
|
1
|
4
|
my ($self, $id) = @_; |
|
42
|
1
|
50
|
|
|
|
5
|
croak "api key id required" unless defined $id; |
|
43
|
1
|
|
|
|
|
8
|
return $self->client->request_op('deleteAPIKey', path => { id => $id }); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |