| 1 | package Net::Kubernetes::Resource; | ||||||||||
| 2 | # ABSTRACT: Base class for all Net::Kubernetes::Resource objects. | ||||||||||
| 3 | 4 | $Net::Kubernetes::Resource::VERSION = '1.03'; | |||||||||
| 4 | 4 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 4 | ▶ | use Clone qw(clone); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 4 | with 'Net::Kubernetes::Role::APIAccess'; | |||||||||
| 8 | |||||||||||
| 9 | |||||||||||
| 10 | 4 | has kind => ( | |||||||||
| 11 | is => 'ro', | ||||||||||
| 12 | isa => 'Str', | ||||||||||
| 13 | required => 0, | ||||||||||
| 14 | ); | ||||||||||
| 15 | |||||||||||
| 16 | 4 | has api_version => ( | |||||||||
| 17 | is => 'ro', | ||||||||||
| 18 | isa => 'Str', | ||||||||||
| 19 | required => 0, | ||||||||||
| 20 | ); | ||||||||||
| 21 | |||||||||||
| 22 | 4 | has metadata => ( | |||||||||
| 23 | is => 'rw', | ||||||||||
| 24 | isa => 'HashRef', | ||||||||||
| 25 | required => 1 | ||||||||||
| 26 | ); | ||||||||||
| 27 | |||||||||||
| 28 | |||||||||||
| 29 | 6 | ▶ | sub delete { | ||||||||
|
Subroutine
delete: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||
| 30 | 6 | my($self) = @_; | |||||||||
| 31 | 6 | my($res) = $self->ua->request($self->create_request(DELETE => $self->path)); | |||||||||
| 32 | 6 | ▶ | if ($res->is_success) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 6 | return 1; | |||||||||
| 34 | } | ||||||||||
| 35 | 0 | return 0; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 6 | ▶ | sub update { | ||||||||
|
Subroutine
update: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||
| 39 | 6 | my($self) = @_; | |||||||||
| 40 | 6 | my($res) = $self->ua->request($self->create_request(PUT => $self->path, undef, $self->json->encode($self->as_hashref))); | |||||||||
| 41 | 6 | ▶ | if ($res->is_success) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 6 | return 1; | |||||||||
| 43 | } | ||||||||||
| 44 | 0 | return 0; | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | sub as_hashref | ||||||||||
| 48 | 12 | ▶ | { | ||||||||
|
Subroutine
as_hashref: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 49 | 12 | my($self) = @_; | |||||||||
| 50 | |||||||||||
| 51 | # It is possible for kuberentes to churn the resource version higher even if | ||||||||||
| 52 | # you just refresh it and then attempt an update operation. Let's ignore it for now. | ||||||||||
| 53 | 12 | my $metadata = $self->metadata; | |||||||||
| 54 | 12 | delete $metadata->{resourceVersion}; | |||||||||
| 55 | |||||||||||
| 56 | 12 | return clone({ | |||||||||
| 57 | inner(), | ||||||||||
| 58 | apiVersion=>$self->api_version, | ||||||||||
| 59 | kind=>$self->kind, | ||||||||||
| 60 | metadata=>$self->metadata | ||||||||||
| 61 | }); | ||||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | 4 | return 42; | |||||||||
| 65 | |||||||||||
| 66 | __END__ | ||||||||||