File Coverage

blib/lib/Etcd3/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 5     5   29 use utf8;
  5         12  
  5         26  
2             package Etcd3::KV::Put;
3              
4 5     5   179 use strict;
  5         11  
  5         88  
5 5     5   23 use warnings;
  5         9  
  5         118  
6              
7 5     5   25 use Moo;
  5         13  
  5         32  
8 5     5   1404 use Types::Standard qw(Str Int Bool HashRef ArrayRef);
  5         11  
  5         25  
9 5     5   4698 use MIME::Base64;
  5         13  
  5         264  
10 5     5   27 use JSON;
  5         10  
  5         35  
11              
12             with 'Etcd3::Role::Actions';
13              
14 5     5   665 use namespace::clean;
  5         12  
  5         33  
15              
16             =head1 NAME
17              
18             Etcd3::Put
19              
20             =cut
21              
22             our $VERSION = '0.007';
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 5     5   2402 coerce => sub { no strict 'refs'; return $_[0] ? JSON::true : JSON::false }
  5         10  
  5         289  
91             );
92              
93             1;