line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::DigitalOcean::Role::DropletActions; |
2
|
|
|
|
|
|
|
# ABSTRACT: Droplet Actions role for DigitalOcean WebService |
3
|
2
|
|
|
2
|
|
1076
|
use utf8; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
12
|
|
4
|
2
|
|
|
2
|
|
57
|
use Moo::Role; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
13
|
|
5
|
2
|
|
|
2
|
|
501
|
use feature 'state'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
132
|
|
6
|
2
|
|
|
2
|
|
8
|
use Types::Standard qw/Str Enum Object Dict Int Bool/; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
12
|
|
7
|
2
|
|
|
2
|
|
1481
|
use Type::Utils; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
11
|
|
8
|
2
|
|
|
2
|
|
2000
|
use Type::Params qw/compile multisig/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
11
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
requires 'make_request'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.026'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub droplet_resize { |
15
|
0
|
|
|
0
|
1
|
|
state $check = compile( |
16
|
|
|
|
|
|
|
Object, |
17
|
|
|
|
|
|
|
Dict[ |
18
|
|
|
|
|
|
|
droplet => Int, |
19
|
|
|
|
|
|
|
disk => Bool, |
20
|
|
|
|
|
|
|
size => Str, |
21
|
|
|
|
|
|
|
], |
22
|
|
|
|
|
|
|
); |
23
|
0
|
|
|
|
|
|
my ($self, $opts) = $check->(@_); |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
$opts->{type} = 'resize'; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
return $self->_droplet_action_start($opts); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub droplet_change_kernel { |
31
|
0
|
|
|
0
|
1
|
|
state $check = compile( |
32
|
|
|
|
|
|
|
Object, |
33
|
|
|
|
|
|
|
Dict[ |
34
|
|
|
|
|
|
|
droplet => Int, |
35
|
|
|
|
|
|
|
kernel => Int, |
36
|
|
|
|
|
|
|
], |
37
|
|
|
|
|
|
|
); |
38
|
0
|
|
|
|
|
|
my ($self, $opts) = $check->(@_); |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
$opts->{type} = 'change_kernel'; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
return $self->_droplet_action_start($opts); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub droplet_rebuild { |
46
|
0
|
|
|
0
|
1
|
|
state $check = compile( |
47
|
|
|
|
|
|
|
Object, |
48
|
|
|
|
|
|
|
Dict[ |
49
|
|
|
|
|
|
|
droplet => Int, |
50
|
|
|
|
|
|
|
image => Str, |
51
|
|
|
|
|
|
|
], |
52
|
|
|
|
|
|
|
); |
53
|
0
|
|
|
|
|
|
my ($self, $opts) = $check->(@_); |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$opts->{type} = 'rebuild'; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
return $self->_droplet_action_start($opts); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub droplet_restore { |
61
|
0
|
|
|
0
|
1
|
|
state $check = compile( |
62
|
|
|
|
|
|
|
Object, |
63
|
|
|
|
|
|
|
Dict[ |
64
|
|
|
|
|
|
|
droplet => Int, |
65
|
|
|
|
|
|
|
image => Str, |
66
|
|
|
|
|
|
|
], |
67
|
|
|
|
|
|
|
); |
68
|
0
|
|
|
|
|
|
my ($self, $opts) = $check->(@_); |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
$opts->{type} = 'restore'; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
return $self->_droplet_action_start($opts); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub droplet_rename { |
76
|
0
|
|
|
0
|
1
|
|
state $check = compile( |
77
|
|
|
|
|
|
|
Object, |
78
|
|
|
|
|
|
|
Dict[ |
79
|
|
|
|
|
|
|
droplet => Int, |
80
|
|
|
|
|
|
|
name => Str, |
81
|
|
|
|
|
|
|
], |
82
|
|
|
|
|
|
|
); |
83
|
0
|
|
|
|
|
|
my ($self, $opts) = $check->(@_); |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
$opts->{type} = 'rename'; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
return $self->_droplet_action_start($opts); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub droplet_snapshot { |
91
|
0
|
|
|
0
|
1
|
|
state $check = compile( |
92
|
|
|
|
|
|
|
Object, |
93
|
|
|
|
|
|
|
Dict[ |
94
|
|
|
|
|
|
|
droplet => Int, |
95
|
|
|
|
|
|
|
name => Str, |
96
|
|
|
|
|
|
|
], |
97
|
|
|
|
|
|
|
); |
98
|
0
|
|
|
|
|
|
my ($self, $opts) = $check->(@_); |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
$opts->{type} = 'snapshot'; |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
return $self->_droplet_action_start($opts); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
{ |
106
|
|
|
|
|
|
|
my $Check_Self_and_ID = compile( Object, Int ); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub droplet_reboot { |
109
|
0
|
|
|
0
|
1
|
|
my ($self, $id) = $Check_Self_and_ID->(@_); |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
return $self->_droplet_action_start({ |
112
|
|
|
|
|
|
|
droplet => $id, |
113
|
|
|
|
|
|
|
type => 'reboot', |
114
|
|
|
|
|
|
|
}); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub droplet_power_cycle { |
118
|
0
|
|
|
0
|
1
|
|
my ($self, $id) = $Check_Self_and_ID->(@_); |
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
return $self->_droplet_action_start({ |
121
|
|
|
|
|
|
|
droplet => $id, |
122
|
|
|
|
|
|
|
type => 'power_cycle', |
123
|
|
|
|
|
|
|
}); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub droplet_power_on { |
127
|
0
|
|
|
0
|
1
|
|
my ($self, $id) = $Check_Self_and_ID->(@_); |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
return $self->_droplet_action_start({ |
130
|
|
|
|
|
|
|
droplet => $id, |
131
|
|
|
|
|
|
|
type => 'power_on', |
132
|
|
|
|
|
|
|
}); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub droplet_power_off { |
136
|
0
|
|
|
0
|
1
|
|
my ($self, $id) = $Check_Self_and_ID->(@_); |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
return $self->_droplet_action_start({ |
139
|
|
|
|
|
|
|
droplet => $id, |
140
|
|
|
|
|
|
|
type => 'power_off', |
141
|
|
|
|
|
|
|
}); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub droplet_password_reset { |
145
|
0
|
|
|
0
|
1
|
|
my ($self, $id) = $Check_Self_and_ID->(@_); |
146
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
return $self->_droplet_action_start({ |
148
|
|
|
|
|
|
|
droplet => $id, |
149
|
|
|
|
|
|
|
type => 'password_reset', |
150
|
|
|
|
|
|
|
}); |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub droplet_shutdown { |
154
|
0
|
|
|
0
|
1
|
|
my ($self, $id) = $Check_Self_and_ID->(@_); |
155
|
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
|
return $self->_droplet_action_start({ |
157
|
|
|
|
|
|
|
droplet => $id, |
158
|
|
|
|
|
|
|
type => 'shutdown', |
159
|
|
|
|
|
|
|
}); |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub droplet_enable_ipv6 { |
163
|
0
|
|
|
0
|
1
|
|
my ($self, $id) = $Check_Self_and_ID->(@_); |
164
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
return $self->_droplet_action_start({ |
166
|
|
|
|
|
|
|
droplet => $id, |
167
|
|
|
|
|
|
|
type => 'enable_ipv6', |
168
|
|
|
|
|
|
|
}); |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub droplet_enable_private_networking { |
172
|
0
|
|
|
0
|
1
|
|
my ($self, $id) = $Check_Self_and_ID->(@_); |
173
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
return $self->_droplet_action_start({ |
175
|
|
|
|
|
|
|
droplet => $id, |
176
|
|
|
|
|
|
|
type => 'enable_private_networking', |
177
|
|
|
|
|
|
|
}); |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub droplet_disable_backups { |
181
|
0
|
|
|
0
|
1
|
|
my ($self, $id) = $Check_Self_and_ID->(@_); |
182
|
|
|
|
|
|
|
|
183
|
0
|
|
|
|
|
|
return $self->_droplet_action_start({ |
184
|
|
|
|
|
|
|
droplet => $id, |
185
|
|
|
|
|
|
|
type => 'disable_backups', |
186
|
|
|
|
|
|
|
}); |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub droplet_action_get { |
191
|
0
|
|
|
0
|
1
|
|
state $check = compile( |
192
|
|
|
|
|
|
|
Object, |
193
|
|
|
|
|
|
|
Dict[ |
194
|
|
|
|
|
|
|
droplet => Int, |
195
|
|
|
|
|
|
|
action => Int, |
196
|
|
|
|
|
|
|
], |
197
|
|
|
|
|
|
|
); |
198
|
|
|
|
|
|
|
|
199
|
0
|
|
|
|
|
|
my ($self, $opts) = $check->(@_); |
200
|
|
|
|
|
|
|
|
201
|
0
|
|
|
|
|
|
return $self->make_request(GET => "/droplets/$opts->{droplet}/actions/$opts->{action}"); |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub _droplet_action_start { |
205
|
0
|
|
|
0
|
|
|
my ($self, $opts) = @_; |
206
|
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
|
my $droplet = delete $opts->{droplet}; |
208
|
|
|
|
|
|
|
|
209
|
0
|
|
|
|
|
|
return $self->make_request(POST => "/droplets/$droplet/actions", $opts); |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
1; |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
__END__ |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=pod |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=encoding UTF-8 |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head1 NAME |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
WebService::DigitalOcean::Role::DropletActions - Droplet Actions role for DigitalOcean WebService |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 VERSION |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
version 0.026 |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head1 DESCRIPTION |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Implements the droplets actions methods. |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 METHODS |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head2 droplet_action_get |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head2 droplet_resize |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head2 droplet_change_kernel |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head2 droplet_rebuild |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head2 droplet_restore |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=head2 droplet_rename |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head2 droplet_snapshot |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=head2 droplet_reboot |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head2 droplet_power_cycle |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head2 droplet_power_on |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=head2 droplet_power_off |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head2 droplet_password_reset |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=head2 droplet_shutdown |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=head2 droplet_enable_ipv6 |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=head2 droplet_enable_private_networking |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=head2 droplet_disable_backups |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
See main documentation in L<WebService::DigitalOcean>. |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head1 AUTHOR |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
André Walker <andre@cpan.org> |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
This software is Copyright (c) 2015 by André Walker. |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
This is free software, licensed under: |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
The GNU General Public License, Version 2, June 1991 |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=cut |