| 1 | package Google::RestApi::DriveApi3; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | our $VERSION = '2.2.5'; | |||||||||
| 4 | |||||||||||
| 5 | 2 | ▶ | use Google::RestApi::Setup; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 2 | ▶ | use Readonly; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use URI; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 2 | ▶ | use aliased 'Google::RestApi::DriveApi3::File'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 2 | ▶ | use aliased 'Google::RestApi::DriveApi3::About'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 2 | ▶ | use aliased 'Google::RestApi::DriveApi3::Changes'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 2 | ▶ | use aliased 'Google::RestApi::DriveApi3::Drive'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 2 | Readonly our $Drive_Endpoint => 'https://www.googleapis.com/drive/v3'; | |||||||||
| 16 | 2 | Readonly our $Drive_File_Id => '[a-zA-Z0-9-_]+'; | |||||||||
| 17 | 2 | Readonly our $Drive_Id => '[a-zA-Z0-9-_]+'; | |||||||||
| 18 | |||||||||||
| 19 | 79 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 20 | 79 | my $class = shift; | |||||||||
| 21 | 79 | state $check = signature( | |||||||||
| 22 | bless => !!0, | ||||||||||
| 23 | named => [ | ||||||||||
| 24 | api => HasApi, | ||||||||||
| 25 | endpoint => Str, { default => $Drive_Endpoint }, | ||||||||||
| 26 | ], | ||||||||||
| 27 | ); | ||||||||||
| 28 | 79 | return bless $check->(@_), $class; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 114 | ▶ | sub api { | ||||||||
|
Subroutine
api: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 32 | 114 | my $self = shift; | |||||||||
| 33 | 114 | state $check = signature( | |||||||||
| 34 | bless => !!0, | ||||||||||
| 35 | named => [ | ||||||||||
| 36 | uri => Str, { optional => 1 }, | ||||||||||
| 37 | _extra_ => slurpy HashRef, | ||||||||||
| 38 | ], | ||||||||||
| 39 | ); | ||||||||||
| 40 | 114 | my $p = named_extra($check->(@_)); | |||||||||
| 41 | 114 | my $uri = "$self->{endpoint}/"; | |||||||||
| 42 | 114 | ▶ | $uri .= delete $p->{uri} if defined $p->{uri}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 114 | return $self->{api}->api(%$p, uri => $uri); | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 38 | ▶ | sub list { | ||||||||
|
Subroutine
list: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 47 | 38 | my $self = shift; | |||||||||
| 48 | 38 | state $check = signature( | |||||||||
| 49 | bless => !!0, | ||||||||||
| 50 | named => [ | ||||||||||
| 51 | filter => Str, | ||||||||||
| 52 | max_pages => Int, { default => 0 }, | ||||||||||
| 53 | page_callback => CodeRef, { optional => 1 }, | ||||||||||
| 54 | params => HashRef, { default => {} }, | ||||||||||
| 55 | ], | ||||||||||
| 56 | ); | ||||||||||
| 57 | 38 | my $p = $check->(@_); | |||||||||
| 58 | |||||||||||
| 59 | 38 | $p->{params}->{q} = $p->{filter}; | |||||||||
| 60 | |||||||||||
| 61 | return paginated_list( | ||||||||||
| 62 | api => $self, | ||||||||||
| 63 | uri => 'files', | ||||||||||
| 64 | result_key => 'files', | ||||||||||
| 65 | default_fields => 'files(id, name)', | ||||||||||
| 66 | max_pages => $p->{max_pages}, | ||||||||||
| 67 | params => $p->{params}, | ||||||||||
| 68 | 38 | ▶ | ($p->{page_callback} ? (page_callback => $p->{page_callback}) : ()), | ||||||||
|
Branch: 1 branch
| |||||||||||
| 69 | ); | ||||||||||
| 70 | } | ||||||||||
| 71 | # backward compatibility. | ||||||||||
| 72 | 2 | *filter_files = *list{CODE}; | |||||||||
| 73 | |||||||||||
| 74 | 0 | ▶ | sub upload_endpoint { | ||||||||
|
Subroutine
upload_endpoint: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 75 | 0 | my $self = shift; | |||||||||
| 76 | 0 | my $upload = $self->{endpoint}; | |||||||||
| 77 | 0 | $upload =~ s|googleapis.com/|googleapis.com/upload/|; | |||||||||
| 78 | 0 | return $upload; | |||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | 61 | ▶ | sub file { File->new(drive => shift, @_); } | ||||||||
|
Subroutine
file: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 82 | |||||||||||
| 83 | 5 | ▶ | sub about { About->new(drive_api => shift); } | ||||||||
|
Subroutine
about: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 84 | |||||||||||
| 85 | 3 | ▶ | sub changes { Changes->new(drive_api => shift); } | ||||||||
|
Subroutine
changes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 86 | |||||||||||
| 87 | 1 | ▶ | sub shared_drive { | ||||||||
|
Subroutine
shared_drive: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 88 | 1 | my $self = shift; | |||||||||
| 89 | 1 | state $check = signature( | |||||||||
| 90 | bless => !!0, | ||||||||||
| 91 | named => [ | ||||||||||
| 92 | id => Str, { optional => 1 }, | ||||||||||
| 93 | ], | ||||||||||
| 94 | ); | ||||||||||
| 95 | 1 | my $p = $check->(@_); | |||||||||
| 96 | 1 | return Drive->new(drive_api => $self, %$p); | |||||||||
| 97 | } | ||||||||||
| 98 | |||||||||||
| 99 | 2 | ▶ | sub list_drives { | ||||||||
|
Subroutine
list_drives: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 100 | 2 | my $self = shift; | |||||||||
| 101 | 2 | state $check = signature( | |||||||||
| 102 | bless => !!0, | ||||||||||
| 103 | named => [ | ||||||||||
| 104 | max_pages => Int, { default => 0 }, | ||||||||||
| 105 | page_callback => CodeRef, { optional => 1 }, | ||||||||||
| 106 | params => HashRef, { default => {} }, | ||||||||||
| 107 | ], | ||||||||||
| 108 | ); | ||||||||||
| 109 | 2 | my $p = $check->(@_); | |||||||||
| 110 | |||||||||||
| 111 | return paginated_list( | ||||||||||
| 112 | api => $self, | ||||||||||
| 113 | uri => 'drives', | ||||||||||
| 114 | result_key => 'drives', | ||||||||||
| 115 | default_fields => 'drives(id, name)', | ||||||||||
| 116 | max_pages => $p->{max_pages}, | ||||||||||
| 117 | params => $p->{params}, | ||||||||||
| 118 | 2 | ▶ | ($p->{page_callback} ? (page_callback => $p->{page_callback}) : ()), | ||||||||
|
Branch: 1 branch
| |||||||||||
| 119 | ); | ||||||||||
| 120 | } | ||||||||||
| 121 | |||||||||||
| 122 | 0 | ▶ | sub create_drive { | ||||||||
|
Subroutine
create_drive: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 123 | 0 | my $self = shift; | |||||||||
| 124 | 0 | state $check = signature( | |||||||||
| 125 | bless => !!0, | ||||||||||
| 126 | named => [ | ||||||||||
| 127 | name => Str, | ||||||||||
| 128 | request_id => Str, | ||||||||||
| 129 | _extra_ => slurpy HashRef, | ||||||||||
| 130 | ], | ||||||||||
| 131 | ); | ||||||||||
| 132 | 0 | my $p = named_extra($check->(@_)); | |||||||||
| 133 | |||||||||||
| 134 | 0 | my $request_id = delete $p->{request_id}; | |||||||||
| 135 | 0 | my $result = $self->api( | |||||||||
| 136 | uri => 'drives', | ||||||||||
| 137 | method => 'post', | ||||||||||
| 138 | params => { requestId => $request_id }, | ||||||||||
| 139 | content => $p, | ||||||||||
| 140 | ); | ||||||||||
| 141 | 0 | return Drive->new(drive_api => $self, id => $result->{id}); | |||||||||
| 142 | } | ||||||||||
| 143 | |||||||||||
| 144 | 0 | ▶ | sub generate_ids { | ||||||||
|
Subroutine
generate_ids: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 145 | 0 | my $self = shift; | |||||||||
| 146 | 0 | state $check = signature( | |||||||||
| 147 | bless => !!0, | ||||||||||
| 148 | named => [ | ||||||||||
| 149 | count => PositiveInt, { default => 10 }, | ||||||||||
| 150 | space => Str, { default => 'drive' }, | ||||||||||
| 151 | ], | ||||||||||
| 152 | ); | ||||||||||
| 153 | 0 | my $p = $check->(@_); | |||||||||
| 154 | |||||||||||
| 155 | my $result = $self->api( | ||||||||||
| 156 | uri => 'files/generateIds', | ||||||||||
| 157 | params => { count => $p->{count}, space => $p->{space} }, | ||||||||||
| 158 | 0 | ); | |||||||||
| 159 | 0 | ▶ | return $result->{ids} ? $result->{ids}->@* : (); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 160 | } | ||||||||||
| 161 | |||||||||||
| 162 | 0 | ▶ | sub empty_trash { | ||||||||
|
Subroutine
empty_trash: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 163 | 0 | my $self = shift; | |||||||||
| 164 | 0 | return $self->api( | |||||||||
| 165 | uri => 'files/trash', | ||||||||||
| 166 | method => 'delete', | ||||||||||
| 167 | ); | ||||||||||
| 168 | } | ||||||||||
| 169 | |||||||||||
| 170 | 0 | ▶ | sub rest_api { shift->{api}; } | ||||||||
|
Subroutine
rest_api: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 171 | 0 | ▶ | sub transaction { shift->rest_api()->transaction(); } | ||||||||
|
Subroutine
transaction: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 172 | 0 | ▶ | sub stats { shift->rest_api()->stats(); } | ||||||||
|
Subroutine
stats: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 173 | 0 | ▶ | sub reset_stats { shift->rest_api->reset_stats(); } | ||||||||
|
Subroutine
reset_stats: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 174 | |||||||||||
| 175 | 2 | 1; | |||||||||
| 176 | |||||||||||
| 177 | __END__ | ||||||||||