File Coverage

blib/lib/Net/Etcd/KV/Put.pm
Criterion Covered Total %
statement 27 27 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod n/a
total 36 36 100.0


line stmt bran cond sub pod time code
1 9     9   58 use utf8;
  9         20  
  9         49  
2             package Net::Etcd::KV::Put;
3              
4 9     9   353 use strict;
  9         24  
  9         203  
5 9     9   49 use warnings;
  9         22  
  9         227  
6              
7 9     9   51 use Moo;
  9         29  
  9         60  
8 9     9   3407 use Types::Standard qw(Str Int Bool HashRef ArrayRef);
  9         23  
  9         55  
9 9     9   9451 use MIME::Base64;
  9         23  
  9         569  
10 9     9   90 use JSON;
  9         24  
  9         74  
11              
12             with 'Net::Etcd::Role::Actions';
13              
14 9     9   1493 use namespace::clean;
  9         26  
  9         65  
15              
16             =head1 NAME
17              
18             Net::Etcd::Put
19              
20             =cut
21              
22             our $VERSION = '0.021';
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             =head1 ACCESSORS
31              
32             =head2 endpoint
33              
34             =cut
35              
36             has endpoint => (
37             is => 'ro',
38             isa => Str,
39             default => '/kv/put'
40             );
41              
42             =head2 key
43              
44             key is the key, in bytes, to put into the key-value store.
45              
46             =cut
47              
48             has key => (
49             is => 'ro',
50             isa => Str,
51             required => 1,
52             coerce => sub { return encode_base64( $_[0], '' ) },
53             );
54              
55             =head2 value
56              
57             value is the value, in bytes, to associate with the key in the key-value store.
58              
59             =cut
60              
61             has value => (
62             is => 'ro',
63             isa => Str,
64             required => 1,
65             coerce => sub { return encode_base64( $_[0], '' ) },
66             );
67              
68             =head2 lease
69              
70             lease is the lease ID to associate with the key in the key-value store. A lease
71             value of 0 indicates no lease.
72              
73             =cut
74              
75             has lease => (
76             is => 'ro',
77             isa => Int,
78             );
79              
80             =head2 prev_kv
81              
82             If prev_kv is set, etcd gets the previous key-value pair before changing it.
83             The previous key-value pair will be returned in the put response.
84              
85             =cut
86              
87             has prev_kv => (
88             is => 'ro',
89             isa => Bool,
90 9     9   6032 coerce => sub { no strict 'refs'; return $_[0] ? JSON::true : JSON::false }
  9         20  
  9         1140  
91             );
92              
93             1;