| 1 | # | ||||||||||||||||||||||||||||
| 2 | # This file is part of Cloudflare::API. | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | # This software is copyright (c) 2026 by Andrew Speer <andrew.speer@isolutions.com.au>. | ||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||
| 9 | # Full license text is available at: | ||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||
| 11 | # <http://dev.perl.org/licenses/> | ||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||
| 13 | package Cloudflare::API::Resource; | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | # Compiler Pragma | ||||||||||||||||||||||||||||
| 17 | # | ||||||||||||||||||||||||||||
| 18 | 3 | ▶ | use strict qw(vars); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 3 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | # Version information | ||||||||||||||||||||||||||||
| 24 | # | ||||||||||||||||||||||||||||
| 25 | 3 | $VERSION='1.011'; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | # All done. Positive return | ||||||||||||||||||||||||||||
| 29 | # | ||||||||||||||||||||||||||||
| 30 | 3 | 1; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | #============================================================================ | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 65 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # Keep the parent client so every resource uses the same transport | ||||||||||||||||||||||||||||
| 40 | # | ||||||||||||||||||||||||||||
| 41 | 65 | my ($class, $api_or)=@_; | |||||||||||||||||||||||||||
| 42 | 65 | ▶ | die "Cloudflare::API object is required\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $api_or and $api_or->isa("Cloudflare::API")
MC/DC0%0/2
ref $api_or and $api_or->isa("Cloudflare::API")
ref $api_or
$api_or->isa("Cloudflare::API")
Truth table33%1/3
A and B
A= ref $api_orB= $api_or->isa("Cloudflare::API")
| |||||||||||||||||||||||||||||
| 43 | unless ref($api_or)&&$api_or->isa('Cloudflare::API'); | ||||||||||||||||||||||||||||
| 44 | 65 | my $self=bless({ api_or => $api_or }, $class); | |||||||||||||||||||||||||||
| 45 | 65 | return $self; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 142 | ▶ | sub api { return $_[0]->{'api_or'} } | ||||||||||||||||||||||||||
|
Subroutine
api: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 15 | ▶ | sub collect_list { | ||||||||||||||||||||||||||
|
Subroutine
collect_list: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 15 | my ($self, $page_or)=@_; | |||||||||||||||||||||||||||
| 56 | 15 | return scalar($page_or->all()); | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 17 | ▶ | sub list_pagination { | ||||||||||||||||||||||||||
|
Subroutine
list_pagination: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 17 | my ($self, $path, $config_hr, $query_hr)=@_; | |||||||||||||||||||||||||||
| 64 | 17 | ▶ | die "pagination config must be a hash reference\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | unless ref($config_hr) eq 'HASH'; | ||||||||||||||||||||||||||||
| 66 | 17 | $self->check_list_query($query_hr); | |||||||||||||||||||||||||||
| 67 | 16 | return $self->api()->pagination($path, %$config_hr, query => $query_hr); | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 3 | ▶ | sub list_response { | ||||||||||||||||||||||||||
|
Subroutine
list_response: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 3 | my ($self, $path, $query_hr)=@_; | |||||||||||||||||||||||||||
| 75 | 3 | $self->check_list_query($query_hr); | |||||||||||||||||||||||||||
| 76 | 3 | return $self->api()->request_full('GET', $path, query => $query_hr); | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 20 | ▶ | sub check_list_query { | ||||||||||||||||||||||||||
|
Subroutine
check_list_query: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 20 | my ($self, $query_hr)=@_; | |||||||||||||||||||||||||||
| 84 | 20 | ▶ | die "list query must be a hash reference\n" unless ref($query_hr) eq 'HASH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | die "full_response is unavailable for list methods; use the page response method\n" | ||||||||||||||||||||||||||||
| 86 | 20 | ▶ | if exists($query_hr->{'full_response'}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 19 | return 1; | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | __END__ | ||||||||||||||||||||||||||||