line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
13
|
use utf8; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
15
|
|
2
|
|
|
|
|
|
|
package Etcd3::Put; |
3
|
|
|
|
|
|
|
|
4
|
4
|
|
|
4
|
|
122
|
use strict; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
57
|
|
5
|
4
|
|
|
4
|
|
11
|
use warnings; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
68
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
10
|
use Moo; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
14
|
|
8
|
4
|
|
|
4
|
|
703
|
use Types::Standard qw(Str Int Bool HashRef ArrayRef); |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
17
|
|
9
|
4
|
|
|
4
|
|
2110
|
use MIME::Base64; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
163
|
|
10
|
4
|
|
|
4
|
|
15
|
use JSON; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
20
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Etcd3::Role::Actions'; |
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
338
|
use namespace::clean; |
|
4
|
|
|
|
|
142
|
|
|
4
|
|
|
|
|
21
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Etcd3::Put |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.005'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Put puts the given key into the key-value store. A put request increments |
27
|
|
|
|
|
|
|
the revision of the key-value store and generates one event in the event |
28
|
|
|
|
|
|
|
history. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 endpoint |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has endpoint => ( |
35
|
|
|
|
|
|
|
is => 'ro', |
36
|
|
|
|
|
|
|
isa => Str, |
37
|
|
|
|
|
|
|
default => '/kv/put' |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 key |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
key is the key, in bytes, to put into the key-value store. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
has key => ( |
47
|
|
|
|
|
|
|
is => 'ro', |
48
|
|
|
|
|
|
|
isa => Str, |
49
|
|
|
|
|
|
|
required => 1, |
50
|
|
|
|
|
|
|
coerce => sub { return encode_base64( $_[0], '' ) }, |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 value |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
value is the value, in bytes, to associate with the key in the key-value store. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
has value => ( |
60
|
|
|
|
|
|
|
is => 'ro', |
61
|
|
|
|
|
|
|
isa => Str, |
62
|
|
|
|
|
|
|
required => 1, |
63
|
|
|
|
|
|
|
coerce => sub { return encode_base64( $_[0], '' ) }, |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 lease |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
lease is the lease ID to associate with the key in the key-value store. A lease |
69
|
|
|
|
|
|
|
value of 0 indicates no lease. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
has lease => ( |
74
|
|
|
|
|
|
|
is => 'ro', |
75
|
|
|
|
|
|
|
isa => Int, |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 prev_kv |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
If prev_kv is set, etcd gets the previous key-value pair before changing it. |
81
|
|
|
|
|
|
|
The previous key-value pair will be returned in the put response. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
has prev_kv => ( |
86
|
|
|
|
|
|
|
is => 'ro', |
87
|
|
|
|
|
|
|
isa => Bool, |
88
|
4
|
|
|
4
|
|
1522
|
coerce => sub { no strict 'refs'; return $_[0] ? JSON::true : JSON::false } |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
773
|
|
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 json_args |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
arguments that will be sent to the api |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
has json_args => ( is => 'lazy', ); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub _build_json_args { |
100
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
101
|
0
|
|
|
|
|
|
my $args; |
102
|
0
|
|
|
|
|
|
for my $key ( keys %{$self} ) { |
|
0
|
|
|
|
|
|
|
103
|
0
|
0
|
|
|
|
|
unless ( $key =~ /(?:_client|json_args|endpoint)$/ ) { |
104
|
0
|
|
|
|
|
|
$args->{$key} = $self->{$key}; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
} |
107
|
0
|
|
|
|
|
|
return to_json($args); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 init |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub init { |
115
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
116
|
0
|
|
|
|
|
|
my $init = $self->json_args; |
117
|
0
|
0
|
|
|
|
|
$init or return; |
118
|
0
|
|
|
|
|
|
return $self; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |