| 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::R2; | ||||||||||
| 14 | |||||||||||
| 15 | |||||||||||
| 16 | # Compiler Pragma | ||||||||||
| 17 | # | ||||||||||
| 18 | 2 | ▶ | use strict qw(vars); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 2 | ▶ | use vars qw(@ISA $VERSION); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | |||||||||||
| 22 | |||||||||||
| 23 | # Cloudflare::API modules and inheritance | ||||||||||
| 24 | # | ||||||||||
| 25 | 2 | ▶ | use Cloudflare::API::Resource; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | 2 | @ISA=qw(Cloudflare::API::Resource); | |||||||||
| 27 | |||||||||||
| 28 | |||||||||||
| 29 | # Version information | ||||||||||
| 30 | # | ||||||||||
| 31 | 2 | $VERSION='1.011'; | |||||||||
| 32 | |||||||||||
| 33 | |||||||||||
| 34 | # All done. Positive return | ||||||||||
| 35 | # | ||||||||||
| 36 | 2 | 1; | |||||||||
| 37 | |||||||||||
| 38 | |||||||||||
| 39 | #============================================================================ | ||||||||||
| 40 | |||||||||||
| 41 | |||||||||||
| 42 | 1 | ▶ | sub list_buckets { | ||||||||
|
Subroutine
list_buckets: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 43 | |||||||||||
| 44 | 1 | my ($self, %query)=@_; | |||||||||
| 45 | 1 | return $self->collect_list($self->list_buckets_page(%query)); | |||||||||
| 46 | |||||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | |||||||||||
| 50 | 1 | ▶ | sub list_buckets_page { | ||||||||
|
Subroutine
list_buckets_page: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 51 | |||||||||||
| 52 | 1 | my ($self, %query)=@_; | |||||||||
| 53 | 1 | return $self->list_pagination($self->api()->account_path('r2', 'buckets'), { | |||||||||
| 54 | mode => 'cursor', items => 'result.buckets' | ||||||||||
| 55 | }, \%query); | ||||||||||
| 56 | |||||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | |||||||||||
| 60 | 0 | ▶ | sub list_buckets_page_response { | ||||||||
|
Subroutine
list_buckets_page_response: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 61 | |||||||||||
| 62 | 0 | my ($self, %query)=@_; | |||||||||
| 63 | 0 | return $self->list_response($self->api()->account_path('r2', 'buckets'), \%query); | |||||||||
| 64 | |||||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | |||||||||||
| 68 | 0 | ▶ | sub get_bucket { | ||||||||
|
Subroutine
get_bucket: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 69 | |||||||||||
| 70 | 0 | my ($self, $name, %opt)=@_; | |||||||||
| 71 | 0 | return $self->api()->request('GET', $self->api()->account_path('r2', 'buckets', $name), | |||||||||
| 72 | %opt); | ||||||||||
| 73 | |||||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | |||||||||||
| 77 | 1 | ▶ | sub create_bucket { | ||||||||
|
Subroutine
create_bucket: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||
| 78 | |||||||||||
| 79 | |||||||||||
| 80 | # Forward Cloudflare's bucket settings without changing their shape | ||||||||||
| 81 | # | ||||||||||
| 82 | 1 | my ($self, $body_hr, %opt)=@_; | |||||||||
| 83 | 1 | ▶ | die "bucket body must be a hash reference\n" unless ref($body_hr) eq 'HASH'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | 1 | return $self->api()->request('POST', $self->api()->account_path('r2', 'buckets'), | |||||||||
| 85 | json => $body_hr, %opt); | ||||||||||
| 86 | |||||||||||
| 87 | } | ||||||||||
| 88 | |||||||||||
| 89 | |||||||||||
| 90 | 1 | ▶ | sub delete_bucket { | ||||||||
|
Subroutine
delete_bucket: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 91 | |||||||||||
| 92 | 1 | my ($self, $name, %opt)=@_; | |||||||||
| 93 | 1 | return $self->api()->request('DELETE', $self->api()->account_path('r2', 'buckets', $name), | |||||||||
| 94 | %opt); | ||||||||||
| 95 | |||||||||||
| 96 | } | ||||||||||
| 97 | |||||||||||
| 98 | |||||||||||
| 99 | 1 | ▶ | sub update_bucket { | ||||||||
|
Subroutine
update_bucket: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||
| 100 | |||||||||||
| 101 | 1 | my ($self, $name, $body_hr, %opt)=@_; | |||||||||
| 102 | 1 | ▶ | die "bucket body must be a hash reference\n" unless ref($body_hr) eq 'HASH'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 103 | 1 | return $self->api()->request('PATCH', $self->api()->account_path('r2', 'buckets', $name), | |||||||||
| 104 | json => $body_hr, %opt); | ||||||||||
| 105 | |||||||||||
| 106 | } | ||||||||||
| 107 | __END__ | ||||||||||