line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
10
|
use utf8; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
13
|
|
2
|
|
|
|
|
|
|
package Etcd3::Put; |
3
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
92
|
use strict; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
48
|
|
5
|
3
|
|
|
3
|
|
8
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
59
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
9
|
use Moo; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
10
|
|
8
|
3
|
|
|
3
|
|
554
|
use Types::Standard qw(Str Int Bool HashRef ArrayRef); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
20
|
|
9
|
3
|
|
|
3
|
|
1612
|
use MIME::Base64; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
126
|
|
10
|
3
|
|
|
3
|
|
17
|
use JSON; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
12
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Etcd3::Role::Actions'; |
13
|
|
|
|
|
|
|
|
14
|
3
|
|
|
3
|
|
269
|
use namespace::clean; |
|
3
|
|
|
|
|
139
|
|
|
3
|
|
|
|
|
20
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Etcd3::Put |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
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
|
3
|
|
|
3
|
|
966
|
coerce => sub { no strict 'refs'; return $_[0] ? JSON::true : JSON::false } |
|
3
|
|
|
|
|
2
|
|
|
3
|
|
|
|
|
602
|
|
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; |