File Coverage

blib/lib/Net/Etcd/KV/DeleteRange.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   59 use utf8;
  9         18  
  9         49  
2             package Net::Etcd::KV::DeleteRange;
3              
4 9     9   358 use strict;
  9         17  
  9         166  
5 9     9   37 use warnings;
  9         15  
  9         201  
6              
7 9     9   41 use Moo;
  9         13  
  9         40  
8 9     9   2789 use Types::Standard qw(Str Int Bool HashRef ArrayRef);
  9         16  
  9         59  
9 9     9   8251 use MIME::Base64;
  9         19  
  9         650  
10 9     9   59 use JSON;
  9         18  
  9         53  
11              
12             with 'Net::Etcd::Role::Actions';
13              
14 9     9   980 use namespace::clean;
  9         17  
  9         61  
15              
16             =head1 NAME
17              
18             Net::Etcd::DeleteRange
19              
20             =cut
21              
22             our $VERSION = '0.020';
23              
24             =head1 DESCRIPTION
25              
26             DeleteRange deletes the given range from the key-value store. A
27             delete request increments the revision of the key-value store and
28             generates a delete event in the event history for every deleted key.
29              
30             =head1 ACCESSORS
31              
32             =head2 endpoint
33              
34             =cut
35              
36             has endpoint => (
37             is => 'ro',
38             isa => Str,
39             default => '/kv/deleterange'
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 prev_kv
56              
57             If prev_kv is set, etcd gets the previous key-value pair before changing it.
58             The previous key-value pair will be returned in the put response.
59              
60             =cut
61              
62             has prev_kv => (
63             is => 'ro',
64             isa => Bool,
65 9     9   4369 coerce => sub { no strict 'refs'; return $_[0] ? JSON::true : JSON::false }
  9         17  
  9         993  
66             );
67              
68             =head2 range_end
69              
70             range_end is the upper bound on the requested range [key, range_end). If range_end is '\0',
71             the range is all keys >= key. If the range_end is one bit larger than the given key, then
72             the range requests get the all keys with the prefix (the given key). If both key and
73             range_end are '\0', then range requests returns all keys. the key is encoded with base64.
74             type bytes. NOTE: If range_end is not given, the request only looks up key.
75              
76             =cut
77              
78             has range_end => (
79             is => 'ro',
80             isa => Str,
81             coerce => sub { return encode_base64( $_[0], '' ) }
82             );
83              
84             1;