| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
4
|
|
|
4
|
|
26084
|
use utf8; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
21
|
|
|
2
|
|
|
|
|
|
|
package Etcd3::Role::Actions; |
|
3
|
|
|
|
|
|
|
|
|
4
|
4
|
|
|
4
|
|
137
|
use strict; |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
65
|
|
|
5
|
4
|
|
|
4
|
|
11
|
use warnings; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
87
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
15
|
use Moo::Role; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
27
|
|
|
8
|
4
|
|
|
4
|
|
879
|
use JSON; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
15
|
|
|
9
|
4
|
|
|
4
|
|
345
|
use HTTP::Tiny; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
70
|
|
|
10
|
4
|
|
|
4
|
|
13
|
use MIME::Base64; |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
173
|
|
|
11
|
4
|
|
|
4
|
|
15
|
use Types::Standard qw(InstanceOf); |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
22
|
|
|
12
|
4
|
|
|
4
|
|
1238
|
use Data::Dumper; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
142
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
13
|
use namespace::clean; |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
19
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=encoding utf8 |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Etcd3::Role::Actions |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our $VERSION = '0.005'; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has _client => ( |
|
27
|
|
|
|
|
|
|
is => 'ro', |
|
28
|
|
|
|
|
|
|
isa => InstanceOf ['Etcd3::Client'], |
|
29
|
|
|
|
|
|
|
); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 headers |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has headers => ( is => 'ro' ); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 request |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
has request => ( is => 'lazy', ); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _build_request { |
|
44
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
|
45
|
|
|
|
|
|
|
my $request = HTTP::Tiny->new->request( |
|
46
|
|
|
|
|
|
|
'POST', |
|
47
|
|
|
|
|
|
|
$self->_client->api_path |
|
48
|
|
|
|
|
|
|
. $self->{endpoint} => { |
|
49
|
|
|
|
|
|
|
content => $self->{json_args}, |
|
50
|
0
|
|
|
|
|
|
headers => $self->headers |
|
51
|
|
|
|
|
|
|
}, |
|
52
|
|
|
|
|
|
|
); |
|
53
|
0
|
|
|
|
|
|
return $request; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 get_value |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
returns single decoded value or the first. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub get_value { |
|
63
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
64
|
0
|
|
|
|
|
|
my $response = $self->request; |
|
65
|
0
|
|
|
|
|
|
my $content = from_json( $response->{content} ); |
|
66
|
|
|
|
|
|
|
# print STDERR Dumper($content); |
|
67
|
0
|
|
|
|
|
|
my $value = $content->{kvs}->[0]->{value}; |
|
68
|
0
|
0
|
|
|
|
|
$value or return; |
|
69
|
0
|
|
|
|
|
|
return decode_base64($value); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 all |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
returns list containing for example: |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
{ |
|
77
|
|
|
|
|
|
|
'mod_revision' => '3', |
|
78
|
|
|
|
|
|
|
'version' => '1', |
|
79
|
|
|
|
|
|
|
'value' => 'bar', |
|
80
|
|
|
|
|
|
|
'create_revision' => '3', |
|
81
|
|
|
|
|
|
|
'key' => 'foo0' |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
where key and value have been decoded for your pleasure. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub all { |
|
89
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
90
|
0
|
|
|
|
|
|
my $response = $self->request; |
|
91
|
0
|
|
|
|
|
|
my $content = from_json( $response->{content} ); |
|
92
|
0
|
|
|
|
|
|
my $kvs = $content->{kvs}; |
|
93
|
0
|
|
|
|
|
|
for my $row (@$kvs) { |
|
94
|
0
|
|
|
|
|
|
$row->{value} = decode_base64( $row->{value} ); |
|
95
|
0
|
|
|
|
|
|
$row->{key} = decode_base64( $row->{key} ); |
|
96
|
|
|
|
|
|
|
} |
|
97
|
0
|
|
|
|
|
|
return $kvs; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 authenticate |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
returns an Etcd3::Auth::Authenticate object |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub authenticate { |
|
107
|
0
|
|
|
0
|
1
|
|
my ( $self, $options ) = @_; |
|
108
|
0
|
0
|
|
|
|
|
return Etcd3::Auth::Authenticate->new( |
|
109
|
|
|
|
|
|
|
_client => $self, |
|
110
|
|
|
|
|
|
|
( $options ? %$options : () ), |
|
111
|
|
|
|
|
|
|
)->init; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |
|
115
|
|
|
|
|
|
|
|