| 1 | 9 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | package Net::Etcd::KV::Put; | ||||||||||
| 3 | |||||||||||
| 4 | 9 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 9 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 9 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 9 | ▶ | use Types::Standard qw(Str Int Bool HashRef ArrayRef); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 9 | ▶ | use MIME::Base64; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 9 | ▶ | use JSON; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 9 | with 'Net::Etcd::Role::Actions'; | |||||||||
| 13 | |||||||||||
| 14 | 9 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | =head1 NAME | ||||||||||
| 17 | |||||||||||
| 18 | Net::Etcd::Put | ||||||||||
| 19 | |||||||||||
| 20 | =cut | ||||||||||
| 21 | |||||||||||
| 22 | 9 | our $VERSION = '0.022'; | |||||||||
| 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 | 9 | 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 | 0 | ▶ | coerce => sub { return encode_base64( $_[0], '' ) }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 53 | 9 | ); | |||||||||
| 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 | 0 | ▶ | coerce => sub { return encode_base64( $_[0], '' ) }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 66 | 9 | ); | |||||||||
| 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 | 9 | 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 | 0 | ▶ | coerce => sub { no strict 'refs'; return $_[0] ? JSON::true : JSON::false } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
Subroutine
__ANON__: not called CC=2 SCAR=9.2
Branch: 1 branch
| |||||||||||
| 91 | 9 | ); | |||||||||
| 92 | |||||||||||
| 93 | 9 | 1; | |||||||||