| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::Hetzner::Robot::API::Reset; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: Hetzner Robot Server Reset API |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.100'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
24
|
|
|
24
|
|
163
|
use Moo; |
|
|
24
|
|
|
|
|
55
|
|
|
|
24
|
|
|
|
|
157
|
|
|
7
|
24
|
|
|
24
|
|
9997
|
use Carp qw(croak); |
|
|
24
|
|
|
|
|
66
|
|
|
|
24
|
|
|
|
|
1735
|
|
|
8
|
24
|
|
|
24
|
|
146
|
use namespace::clean; |
|
|
24
|
|
|
|
|
45
|
|
|
|
24
|
|
|
|
|
165
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has client => ( |
|
12
|
|
|
|
|
|
|
is => 'ro', |
|
13
|
|
|
|
|
|
|
required => 1, |
|
14
|
|
|
|
|
|
|
weak_ref => 1, |
|
15
|
|
|
|
|
|
|
); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub get { |
|
18
|
1
|
|
|
1
|
1
|
1622
|
my ($self, $server_number) = @_; |
|
19
|
1
|
50
|
|
|
|
5
|
croak "Server number required" unless $server_number; |
|
20
|
1
|
|
|
|
|
13
|
my $result = $self->client->get("/reset/$server_number"); |
|
21
|
1
|
|
|
|
|
5
|
return $result->{reset}; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub execute { |
|
26
|
2
|
|
|
2
|
1
|
6513
|
my ($self, $server_number, $type) = @_; |
|
27
|
2
|
50
|
|
|
|
11
|
croak "Server number required" unless $server_number; |
|
28
|
2
|
|
50
|
|
|
7
|
$type //= 'sw'; |
|
29
|
2
|
50
|
|
|
|
12
|
croak "Invalid reset type: $type (must be sw, hw, or man)" |
|
30
|
|
|
|
|
|
|
unless $type =~ /^(sw|hw|man)$/; |
|
31
|
|
|
|
|
|
|
|
|
32
|
2
|
|
|
|
|
20
|
my $result = $self->client->post("/reset/$server_number", { type => $type }); |
|
33
|
2
|
|
|
|
|
11
|
return $result->{reset}; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub software { |
|
38
|
1
|
|
|
1
|
1
|
5812
|
my ($self, $server_number) = @_; |
|
39
|
1
|
|
|
|
|
6
|
return $self->execute($server_number, 'sw'); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub hardware { |
|
44
|
0
|
|
|
0
|
1
|
0
|
my ($self, $server_number) = @_; |
|
45
|
0
|
|
|
|
|
0
|
return $self->execute($server_number, 'hw'); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub manual { |
|
50
|
0
|
|
|
0
|
1
|
0
|
my ($self, $server_number) = @_; |
|
51
|
0
|
|
|
|
|
0
|
return $self->execute($server_number, 'man'); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub wol { |
|
56
|
1
|
|
|
1
|
1
|
4746
|
my ($self, $server_number) = @_; |
|
57
|
1
|
50
|
|
|
|
6
|
croak "Server number required" unless $server_number; |
|
58
|
1
|
|
|
|
|
11
|
my $result = $self->client->post("/wol/$server_number", {}); |
|
59
|
1
|
|
|
|
|
6
|
return $result->{wol}; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |