blib/lib/Cloudflare/API/D1.pm

filter: Statementstmt 76.1% 32 / 42 Branchbran 64.2% 9 / 14 Conditioncond 44.4% 4 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 61.5% 8 / 13 Podpod 0.0% 0 / 9 totaltotal 57.6% 53 / 92 CC 11 SCAR 14.8
CC
11
Cov
69%
query_sql
9.4
create_database
2.0
update_database
2.0
CRAP 4.4
« blib/lib/Cloudflare/API/Error.pm ↑ Summary blib/lib/Cloudflare/API/KV.pm »
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::D1;
14  
15  
16 # Compiler Pragma
17 #
18 1 ▶use strict qw(vars);
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use vars qw(@ISA $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22  
23 # Cloudflare::API modules and inheritance
24 #
25 1 ▶use Cloudflare::API::Resource;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 @ISA=qw(Cloudflare::API::Resource);
27  
28  
29 # Version information
30 #
31 1 $VERSION='1.011';
32  
33  
34 # All done. Positive return
35 #
36 1 1;
37  
38  
39 #============================================================================
40  
41  
42 0 ▶sub list_databases {
Subroutine list_databases: not called CC=1 SCAR=6.9
Pod undocumented
43  
44 0 my ($self, %query)=@_;
45 0 return $self->collect_list($self->list_databases_page(%query));
46  
47 }
48  
49  
50 0 ▶sub list_databases_page {
Subroutine list_databases_page: not called CC=1 SCAR=6.9
Pod undocumented
51  
52 0 my ($self, %query)=@_;
53 0 return $self->list_pagination($self->api()->account_path('d1', 'database'),
54 { mode => 'page' }, \%query);
55  
56 }
57  
58  
59 0 ▶sub list_databases_page_response {
Subroutine list_databases_page_response: not called CC=1 SCAR=6.9
Pod undocumented
60  
61 0 my ($self, %query)=@_;
62 0 return $self->list_response($self->api()->account_path('d1', 'database'), \%query);
63  
64 }
65  
66  
67 0 ▶sub get_database {
Subroutine get_database: not called CC=1 SCAR=6.9
Pod undocumented
68  
69 0 my ($self, $id, %opt)=@_;
70 0 return $self->api()->request('GET', $self->api()->account_path('d1', 'database', $id),
71 %opt);
72  
73 }
74  
75  
76 1 ▶sub create_database {
Subroutine create_database: called CC=2 SCAR=7.1
Pod undocumented
77  
78 1 my ($self, $body_hr, %opt)=@_;
79 1 ▶ die "database body must be a hash reference\n" unless ref($body_hr) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $body_hr eq "HASH" 0 1 1
80 1 return $self->api()->request('POST', $self->api()->account_path('d1', 'database'),
81 json => $body_hr, %opt);
82  
83 }
84  
85  
86 0 ▶sub delete_database {
Subroutine delete_database: not called CC=1 SCAR=6.9
Pod undocumented
87  
88 0 my ($self, $id, %opt)=@_;
89 0 return $self->api()->request('DELETE', $self->api()->account_path('d1', 'database', $id),
90 %opt);
91  
92 }
93  
94  
95 1 ▶sub update_database {
Subroutine update_database: called CC=2 SCAR=7.1
Pod undocumented
96  
97 1 my ($self, $id, $body_hr, %opt)=@_;
98 1 ▶ die "database body must be a hash reference\n" unless ref($body_hr) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $body_hr eq "HASH" 0 1 1
99 1 return $self->api()->request('PATCH', $self->api()->account_path('d1', 'database', $id),
100 json => $body_hr, %opt);
101  
102 }
103  
104  
105 3 ▶sub query_database {
Subroutine query_database: called CC=2 SCAR=7.1
Pod undocumented
106  
107  
108 # Pass SQL and its parameters in the caller's supplied request body
109 #
110 3 my ($self, $id, $body_hr, %opt)=@_;
111 3 ▶ die "query body must be a hash reference\n" unless ref($body_hr) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $body_hr eq "HASH" 0 3 3
112 3 return $self->api()->request('POST', $self->api()->account_path('d1', 'database', $id, 'query'),
113 json => $body_hr, %opt);
114  
115 }
116  
117  
118 2 ▶sub query_sql {
Subroutine query_sql: called CC=8 SCAR=22.4
Pod undocumented
119  
120  
121 # Keep bound values separate from SQL text
122 #
123 2 my ($self, $id, $sql, @arg)=@_;
124 2 ▶ my $params_ar=@arg % 2 ? shift(@arg) : undef;
Branch: 1 branch
BranchTrueFalseTotal
@arg % 2 ? : 1 1 2
125 2 my %opt=@arg;
126 2 ▶ die "sql must be a non-empty scalar\n" unless defined($sql)&&!ref($sql)&&length($sql);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sql and not ref $sql and length $sql 0 2 2
Condition33%2/6
defined $sql and not ref $sql and length $sql
!ll&&!rl&&r
002
defined $sql and not ref $sql
!ll&&!rl&&r
002
MC/DC0%0/3
defined $sql and not ref $sql and length $sql
defined $sql not ref $sql length $sql
Truth table25%1/4
A and not(B) and C
A= defined $sqlB= not ref $sqlC= length $sql
ABCresult
0XX0
10X0
1100
1111
127 2 ▶ die "params must be an array reference\n"
Branch: 1 branch
BranchTrueFalseTotal
if defined $params_ar and ref $params_ar ne "ARRAY" 0 2 2
Condition66%2/3
defined $params_ar and ref $params_ar ne "ARRAY"
!ll&&!rl&&r
110
MC/DC0%0/2
defined $params_ar and ref $params_ar ne "ARRAY"
defined $params_ar ref $params_ar ne "ARRAY"
Truth table66%2/3
A and B
A= defined $params_arB= ref $params_ar ne "ARRAY"
ABresult
0X0
100
111
128 if defined($params_ar)&&ref($params_ar) ne 'ARRAY';
129 2 my %body=(sql => $sql);
130 2 ▶ $body{'params'}=$params_ar if defined($params_ar);
Branch: 1 branch
BranchTrueFalseTotal
if defined $params_ar 1 1 2
131 2 return $self->query_database($id, \%body, %opt);
132  
133 }
134 __END__
« blib/lib/Cloudflare/API/Error.pm ↑ Summary blib/lib/Cloudflare/API/KV.pm »