line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
9
|
|
|
9
|
|
69652
|
use utf8; |
|
9
|
|
|
|
|
155
|
|
|
9
|
|
|
|
|
42
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Net::Etcd; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: Provide access to the etcd v3 API. |
6
|
|
|
|
|
|
|
|
7
|
9
|
|
|
9
|
|
335
|
use strict; |
|
9
|
|
|
|
|
13
|
|
|
9
|
|
|
|
|
151
|
|
8
|
9
|
|
|
9
|
|
35
|
use warnings; |
|
9
|
|
|
|
|
13
|
|
|
9
|
|
|
|
|
177
|
|
9
|
|
|
|
|
|
|
|
10
|
9
|
|
|
9
|
|
4027
|
use Moo; |
|
9
|
|
|
|
|
97320
|
|
|
9
|
|
|
|
|
36
|
|
11
|
9
|
|
|
9
|
|
16245
|
use JSON; |
|
9
|
|
|
|
|
105217
|
|
|
9
|
|
|
|
|
44
|
|
12
|
9
|
|
|
9
|
|
4544
|
use MIME::Base64; |
|
9
|
|
|
|
|
4586
|
|
|
9
|
|
|
|
|
480
|
|
13
|
9
|
|
|
9
|
|
3077
|
use Net::Etcd::Auth; |
|
9
|
|
|
|
|
33
|
|
|
9
|
|
|
|
|
359
|
|
14
|
9
|
|
|
9
|
|
4030
|
use Net::Etcd::Auth::RolePermission; |
|
9
|
|
|
|
|
29
|
|
|
9
|
|
|
|
|
267
|
|
15
|
9
|
|
|
9
|
|
3561
|
use Net::Etcd::Config; |
|
9
|
|
|
|
|
25
|
|
|
9
|
|
|
|
|
245
|
|
16
|
9
|
|
|
9
|
|
3520
|
use Net::Etcd::Watch; |
|
9
|
|
|
|
|
25
|
|
|
9
|
|
|
|
|
287
|
|
17
|
9
|
|
|
9
|
|
3737
|
use Net::Etcd::Lease; |
|
9
|
|
|
|
|
27
|
|
|
9
|
|
|
|
|
295
|
|
18
|
9
|
|
|
9
|
|
3744
|
use Net::Etcd::Maintenance; |
|
9
|
|
|
|
|
23
|
|
|
9
|
|
|
|
|
252
|
|
19
|
9
|
|
|
9
|
|
3389
|
use Net::Etcd::Member; |
|
9
|
|
|
|
|
26
|
|
|
9
|
|
|
|
|
256
|
|
20
|
9
|
|
|
9
|
|
3363
|
use Net::Etcd::User; |
|
9
|
|
|
|
|
28
|
|
|
9
|
|
|
|
|
303
|
|
21
|
9
|
|
|
9
|
|
58
|
use Types::Standard qw(Str Int Bool HashRef); |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
43
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
with('Net::Etcd::KV'); |
24
|
|
|
|
|
|
|
|
25
|
9
|
|
|
9
|
|
7018
|
use namespace::clean; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
37
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=encoding utf8 |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 NAME |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Net::Etcd - etcd v3 REST API. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our $VERSION = '0.020'; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SYNOPSIS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Etcd v3.1.0 or greater is required. To use the v3 API make sure to set environment |
40
|
|
|
|
|
|
|
variable ETCDCTL_API=3. Precompiled binaries can be downloaded at https://github.com/coreos/etcd/releases. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$etcd = Net::Etcd->new(); # host: 127.0.0.1 port: 2379 |
43
|
|
|
|
|
|
|
$etcd = Net::Etcd->new({ host => $host, port => $port, ssl => 1 }); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# put key |
46
|
|
|
|
|
|
|
$put_key = $etcd->put({ key =>'foo1', value => 'bar' }); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# check for success of a transaction |
49
|
|
|
|
|
|
|
$put_key->is_success; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# get single key |
52
|
|
|
|
|
|
|
$key = $etcd->range({ key =>'test0' }); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# return single key value or the first in a list. |
55
|
|
|
|
|
|
|
$key->get_value |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# get range of keys |
58
|
|
|
|
|
|
|
$range = $etcd->range({ key =>'test0', range_end => 'test100' }); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# return array { key => value } pairs from range request. |
61
|
|
|
|
|
|
|
my @users = $range->all |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# delete single key |
64
|
|
|
|
|
|
|
$etcd->deleterange({ key => 'test0' }); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# watch key range, streaming. |
67
|
|
|
|
|
|
|
$watch = $etcd->watch( { key => 'foo', range_end => 'fop'}, sub { |
68
|
|
|
|
|
|
|
my ($result) = @_; |
69
|
|
|
|
|
|
|
print STDERR Dumper($result); |
70
|
|
|
|
|
|
|
})->create; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# create/grant 20 second lease |
73
|
|
|
|
|
|
|
$etcd->lease( { ID => 7587821338341002662, TTL => 20 } )->grant; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# attach lease to put |
76
|
|
|
|
|
|
|
$etcd->put( { key => 'foo2', value => 'bar2', lease => 7587821338341002662 } ); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# add new user |
79
|
|
|
|
|
|
|
$etcd->user( { name => 'samba', password => 'foo' } )->add; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# add new user role |
82
|
|
|
|
|
|
|
$role = $etcd->role( { name => 'myrole' } )->add; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# grant read permission for the foo key to myrole |
85
|
|
|
|
|
|
|
$etcd->role_perm( { name => 'myrole', key => 'foo', permType => 'READWRITE' } )->grant; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# grant role |
88
|
|
|
|
|
|
|
$etcd->user_role( { user => 'samba', role => 'myrole' } )->grant; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# defrag member's backend database |
91
|
|
|
|
|
|
|
$defrag = $etcd->maintenance()->defragment; |
92
|
|
|
|
|
|
|
print "Defrag request complete!" if $defrag->is_success; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# member version |
95
|
|
|
|
|
|
|
$v = $etcd->version; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# list members |
98
|
|
|
|
|
|
|
$etcd->member()->list; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 DESCRIPTION |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
L is object oriented interface to the v3 REST API provided by the etcd L. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 ACCESSORS |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 host |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
The etcd host. Defaults to 127.0.0.1 |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
has host => ( |
113
|
|
|
|
|
|
|
is => 'ro', |
114
|
|
|
|
|
|
|
isa => Str, |
115
|
|
|
|
|
|
|
default => '127.0.0.1' |
116
|
|
|
|
|
|
|
); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 port |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Default 2379. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
has port => ( |
125
|
|
|
|
|
|
|
is => 'ro', |
126
|
|
|
|
|
|
|
isa => Int, |
127
|
|
|
|
|
|
|
default => '2379' |
128
|
|
|
|
|
|
|
); |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 name |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Username for authentication, defaults to $ENV{ETCD_CLIENT_USERNAME} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
has name => ( |
137
|
|
|
|
|
|
|
is => 'ro', |
138
|
|
|
|
|
|
|
default => $ENV{ETCD_CLIENT_USERNAME} |
139
|
|
|
|
|
|
|
); |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 password |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Authentication credentials, defaults to $ENV{ETCD_CLIENT_PASSWORD} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
has password => ( |
148
|
|
|
|
|
|
|
is => 'ro', |
149
|
|
|
|
|
|
|
default => $ENV{ETCD_CLIENT_PASSWORD} |
150
|
|
|
|
|
|
|
); |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 ca_file |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Path to ca_file, defaults to $ENV{ETCD_CLIENT_CA_FILE} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
has ca_file => ( |
159
|
|
|
|
|
|
|
is => 'ro', |
160
|
|
|
|
|
|
|
default => $ENV{ETCD_CLIENT_CA_FILE} |
161
|
|
|
|
|
|
|
); |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 key_file |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Path to key_file, defaults to $ENV{ETCD_CLIENT_KEY_FILE} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
has key_file => ( |
170
|
|
|
|
|
|
|
is => 'ro', |
171
|
|
|
|
|
|
|
default => $ENV{ETCD_CLIENT_KEY_FILE} |
172
|
|
|
|
|
|
|
); |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head2 cert_file |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Path to cert_file, defaults to $ENV{ETCD_CLIENT_CERT_FILE} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
has cert_file => ( |
181
|
|
|
|
|
|
|
is => 'ro', |
182
|
|
|
|
|
|
|
default => $ENV{ETCD_CLIENT_CERT_FILE} |
183
|
|
|
|
|
|
|
); |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head2 cacert |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Path to cacert, defaults to $ENV{ETCD_CLIENT_CACERT_FILE}. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=cut |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
has cacert => ( |
192
|
|
|
|
|
|
|
is => 'ro', |
193
|
|
|
|
|
|
|
default => $ENV{ETCD_CLIENT_CACERT_FILE} |
194
|
|
|
|
|
|
|
); |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head2 ssl |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
To enable set to 1 |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=cut |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
has ssl => ( |
204
|
|
|
|
|
|
|
is => 'ro', |
205
|
|
|
|
|
|
|
isa => Bool, |
206
|
|
|
|
|
|
|
); |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head2 api_version |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
defaults to /v3beta |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=cut |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
has api_version => ( |
215
|
|
|
|
|
|
|
is => 'ro', |
216
|
|
|
|
|
|
|
isa => Str, |
217
|
|
|
|
|
|
|
default => '/v3beta' |
218
|
|
|
|
|
|
|
); |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head2 api_path |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
The full api path. Defaults to http://127.0.0.1:2379/v3alpha |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=cut |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
has api_path => ( is => 'lazy' ); |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub _build_api_path { |
229
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
230
|
|
|
|
|
|
|
return ( $self->{ssl} |
231
|
|
|
|
|
|
|
|| $self->{ca_file} |
232
|
|
|
|
|
|
|
|| $self->{key_file} |
233
|
|
|
|
|
|
|
|| $self->{cafile} |
234
|
0
|
0
|
0
|
|
|
|
|| $self->{cert_file} ? 'https' : 'http' ) |
235
|
|
|
|
|
|
|
. '://' |
236
|
|
|
|
|
|
|
. $self->host . ':' |
237
|
|
|
|
|
|
|
. $self->port |
238
|
|
|
|
|
|
|
. $self->api_version; |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head2 auth_token |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
The token that is passed during authentication. This is generated during the |
244
|
|
|
|
|
|
|
authentication process and stored until no longer valid or username is changed. |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=cut |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
has auth_token => ( |
249
|
|
|
|
|
|
|
is => 'rwp', |
250
|
|
|
|
|
|
|
clearer => 1, |
251
|
|
|
|
|
|
|
); |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=head1 PUBLIC METHODS |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head2 version |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
Returns the etcd member version |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
$etcd->version() |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=cut |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
sub version { |
264
|
0
|
|
|
0
|
1
|
|
my ( $self, $options ) = @_; |
265
|
0
|
0
|
|
|
|
|
my $cb = pop if ref $_[-1] eq 'CODE'; |
266
|
0
|
0
|
|
|
|
|
my $member = Net::Etcd::Maintenance->new( |
267
|
|
|
|
|
|
|
etcd => $self, |
268
|
|
|
|
|
|
|
cb => $cb, |
269
|
|
|
|
|
|
|
( $options ? %$options : () ), |
270
|
|
|
|
|
|
|
); |
271
|
0
|
|
|
|
|
|
return $member->version; |
272
|
|
|
|
|
|
|
} |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=head2 watch |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
See L |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
$etcd->watch({ key =>'foo', range_end => 'fop' }) |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=cut |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
sub watch { |
283
|
0
|
|
|
0
|
1
|
|
my ( $self, $options ) = @_; |
284
|
0
|
0
|
|
|
|
|
my $cb = pop if ref $_[-1] eq 'CODE'; |
285
|
0
|
0
|
|
|
|
|
return Net::Etcd::Watch->new( |
286
|
|
|
|
|
|
|
etcd => $self, |
287
|
|
|
|
|
|
|
cb => $cb, |
288
|
|
|
|
|
|
|
( $options ? %$options : () ), |
289
|
|
|
|
|
|
|
); |
290
|
|
|
|
|
|
|
} |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
=head2 role |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
See L |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
$etcd->role({ role => 'foo' }); |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=cut |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
sub role { |
301
|
0
|
|
|
0
|
1
|
|
my ( $self, $options ) = @_; |
302
|
0
|
0
|
|
|
|
|
my $cb = pop if ref $_[-1] eq 'CODE'; |
303
|
0
|
0
|
|
|
|
|
return Net::Etcd::Auth::Role->new( |
304
|
|
|
|
|
|
|
etcd => $self, |
305
|
|
|
|
|
|
|
cb => $cb, |
306
|
|
|
|
|
|
|
( $options ? %$options : () ), |
307
|
|
|
|
|
|
|
); |
308
|
|
|
|
|
|
|
} |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=head2 role_perm |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
See L |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
Grants or revoke permission of a specified key or range to a specified role. |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
=cut |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
sub role_perm { |
319
|
0
|
|
|
0
|
1
|
|
my ( $self, $options ) = @_; |
320
|
0
|
0
|
|
|
|
|
my $cb = pop if ref $_[-1] eq 'CODE'; |
321
|
0
|
0
|
|
|
|
|
my $perm = Net::Etcd::Auth::RolePermission->new( |
322
|
|
|
|
|
|
|
etcd => $self, |
323
|
|
|
|
|
|
|
cb => $cb, |
324
|
|
|
|
|
|
|
( $options ? %$options : () ), |
325
|
|
|
|
|
|
|
); |
326
|
|
|
|
|
|
|
} |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
=head2 user_role |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
See L |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
$etcd->user_role({ name => 'samba', role => 'foo' }); |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
=cut |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
sub user_role { |
337
|
0
|
|
|
0
|
1
|
|
my ( $self, $options ) = @_; |
338
|
0
|
0
|
|
|
|
|
my $cb = pop if ref $_[-1] eq 'CODE'; |
339
|
0
|
0
|
|
|
|
|
return Net::Etcd::User::Role->new( |
340
|
|
|
|
|
|
|
etcd => $self, |
341
|
|
|
|
|
|
|
cb => $cb, |
342
|
|
|
|
|
|
|
( $options ? %$options : () ), |
343
|
|
|
|
|
|
|
); |
344
|
|
|
|
|
|
|
} |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
=head2 auth |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
See L |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
$etcd->auth({ name => 'samba', password => 'foo' })->authenticate; |
351
|
|
|
|
|
|
|
$etcd->auth()->enable; |
352
|
|
|
|
|
|
|
$etcd->auth()->disable |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
=cut |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
sub auth { |
357
|
0
|
|
|
0
|
1
|
|
my ( $self, $options ) = @_; |
358
|
0
|
0
|
|
|
|
|
my $cb = pop if ref $_[-1] eq 'CODE'; |
359
|
0
|
0
|
|
|
|
|
return Net::Etcd::Auth->new( |
360
|
|
|
|
|
|
|
etcd => $self, |
361
|
|
|
|
|
|
|
cb => $cb, |
362
|
|
|
|
|
|
|
( $options ? %$options : () ), |
363
|
|
|
|
|
|
|
); |
364
|
|
|
|
|
|
|
} |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
=head2 lease |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
See L |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
$etcd->lease( { ID => 7587821338341002662, TTL => 20 } )->grant; |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
=cut |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
sub lease { |
375
|
0
|
|
|
0
|
1
|
|
my ( $self, $options ) = @_; |
376
|
0
|
0
|
|
|
|
|
my $cb = pop if ref $_[-1] eq 'CODE'; |
377
|
0
|
0
|
|
|
|
|
return Net::Etcd::Lease->new( |
378
|
|
|
|
|
|
|
etcd => $self, |
379
|
|
|
|
|
|
|
cb => $cb, |
380
|
|
|
|
|
|
|
( $options ? %$options : () ), |
381
|
|
|
|
|
|
|
); |
382
|
|
|
|
|
|
|
} |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
=head2 maintenance |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
See L |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
$etcd->maintenance()->snapshot |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
=cut |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
sub maintenance { |
393
|
0
|
|
|
0
|
1
|
|
my ( $self, $options ) = @_; |
394
|
0
|
0
|
|
|
|
|
my $cb = pop if ref $_[-1] eq 'CODE'; |
395
|
0
|
0
|
|
|
|
|
return Net::Etcd::Maintenance->new( |
396
|
|
|
|
|
|
|
etcd => $self, |
397
|
|
|
|
|
|
|
cb => $cb, |
398
|
|
|
|
|
|
|
( $options ? %$options : () ), |
399
|
|
|
|
|
|
|
); |
400
|
|
|
|
|
|
|
} |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
=head2 member |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
See L |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
$etcd->member()->list |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
=cut |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
sub member { |
411
|
0
|
|
|
0
|
1
|
|
my ( $self, $options ) = @_; |
412
|
0
|
0
|
|
|
|
|
my $cb = pop if ref $_[-1] eq 'CODE'; |
413
|
0
|
0
|
|
|
|
|
return Net::Etcd::Member->new( |
414
|
|
|
|
|
|
|
etcd => $self, |
415
|
|
|
|
|
|
|
cb => $cb, |
416
|
|
|
|
|
|
|
( $options ? %$options : () ), |
417
|
|
|
|
|
|
|
); |
418
|
|
|
|
|
|
|
} |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
=head2 user |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
See L |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
$etcd->user( { name => 'samba', password => 'foo' } )->add; |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
=cut |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
sub user { |
429
|
0
|
|
|
0
|
1
|
|
my ( $self, $options ) = @_; |
430
|
0
|
0
|
|
|
|
|
my $cb = pop if ref $_[-1] eq 'CODE'; |
431
|
0
|
0
|
|
|
|
|
return Net::Etcd::User->new( |
432
|
|
|
|
|
|
|
etcd => $self, |
433
|
|
|
|
|
|
|
cb => $cb, |
434
|
|
|
|
|
|
|
( $options ? %$options : () ), |
435
|
|
|
|
|
|
|
); |
436
|
|
|
|
|
|
|
} |
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
=head2 put |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
See L |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
$etcd->put({ key =>'foo1', value => 'bar' }); |
443
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
=cut |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
=head2 deleterange |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
See L |
449
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
$etcd->deleterange({ key=>'test0' }); |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
=cut |
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
=head2 range |
455
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
See L |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
$etcd->range({ key =>'test0', range_end => 'test100' }); |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
=cut |
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
=head2 txn |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
See L |
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
$etcd->txn({ compare => \@compare, success => \@op }); |
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
=cut |
469
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
=head2 op |
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
See L |
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
$etcd->op({ request_put => $put }); |
475
|
|
|
|
|
|
|
$etcd->op({ request_delete_range => $range }); |
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
=cut |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
=head2 compare |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
See L |
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
$etcd->compare( { key => 'foo', result => 'EQUAL', target => 'VALUE', value => 'baz' }); |
484
|
|
|
|
|
|
|
$etcd->compare( { key => 'foo', target => 'CREATE', result => 'NOT_EQUAL', create_revision => '2' }); |
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
=cut |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
=head2 configuration |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
Initialize configuration checks to see if etcd is installed locally. |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
=cut |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
sub configuration { |
495
|
0
|
|
|
0
|
1
|
|
Net::Etcd::Config->configuration; |
496
|
|
|
|
|
|
|
} |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
=head1 AUTHOR |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
Sam Batschelet (hexfusion) |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
Ananth Kavuri |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
The L developers and community. |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
=head1 CAVEATS |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
The L v3 API is in heavy development and can change at anytime please see |
513
|
|
|
|
|
|
|
L |
514
|
|
|
|
|
|
|
for latest details. |
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
Authentication provided by this module will only work with etcd v3.3.0+ |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
Copyright 2018 Sam Batschelet (hexfusion). |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
523
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
524
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
525
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
527
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
=cut |
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
1; |