| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::VastAI::API::Volumes; |
|
2
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: Volume creation and deletion for Vast.ai |
|
4
|
|
|
|
|
|
|
|
|
5
|
10
|
|
|
10
|
|
70
|
use Moo; |
|
|
10
|
|
|
|
|
23
|
|
|
|
10
|
|
|
|
|
72
|
|
|
6
|
10
|
|
|
10
|
|
3976
|
use Carp qw(croak); |
|
|
10
|
|
|
|
|
20
|
|
|
|
10
|
|
|
|
|
816
|
|
|
7
|
10
|
|
|
10
|
|
5363
|
use WWW::VastAI::Volume; |
|
|
10
|
|
|
|
|
34
|
|
|
|
10
|
|
|
|
|
344
|
|
|
8
|
10
|
|
|
10
|
|
69
|
use namespace::clean; |
|
|
10
|
|
|
|
|
19
|
|
|
|
10
|
|
|
|
|
72
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has client => ( |
|
11
|
|
|
|
|
|
|
is => 'ro', |
|
12
|
|
|
|
|
|
|
required => 1, |
|
13
|
|
|
|
|
|
|
weak_ref => 1, |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _wrap { |
|
17
|
2
|
|
|
2
|
|
7
|
my ($self, $data) = @_; |
|
18
|
2
|
|
|
|
|
85
|
return WWW::VastAI::Volume->new( |
|
19
|
|
|
|
|
|
|
client => $self->client, |
|
20
|
|
|
|
|
|
|
data => $data, |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub list { |
|
25
|
1
|
|
|
1
|
1
|
1675
|
my ($self) = @_; |
|
26
|
1
|
|
|
|
|
12
|
my $result = $self->client->request_op('listVolumes'); |
|
27
|
1
|
50
|
0
|
|
|
10
|
my $volumes = ref $result eq 'HASH' ? ($result->{volumes} || $result->{results} || []) : ($result || []); |
|
|
|
|
0
|
|
|
|
|
|
28
|
1
|
|
|
|
|
3
|
return [ map { $self->_wrap($_) } @{$volumes} ]; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
4
|
|
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub create { |
|
32
|
1
|
|
|
1
|
1
|
22
|
my ($self, %params) = @_; |
|
33
|
1
|
50
|
|
|
|
7
|
croak "size required" unless defined $params{size}; |
|
34
|
1
|
50
|
|
|
|
4
|
croak "label required" unless defined $params{label}; |
|
35
|
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
12
|
my $result = $self->client->request_op('createVolume', body => \%params); |
|
37
|
1
|
50
|
33
|
|
|
10
|
my $volume = ref $result eq 'HASH' ? ($result->{volume} || $result) : { id => $result }; |
|
38
|
1
|
|
|
|
|
6
|
return $self->_wrap($volume); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub delete { |
|
42
|
1
|
|
|
1
|
1
|
4
|
my ($self, $id) = @_; |
|
43
|
1
|
50
|
|
|
|
5
|
croak "volume id required" unless defined $id; |
|
44
|
1
|
|
|
|
|
9
|
return $self->client->request_op('deleteVolume', body => { id => $id }); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |