| 1 | ########################################### | ||||||||||||||||||||||||||||
| 2 | package Net::Google::Drive::Simple::V3; | ||||||||||||||||||||||||||||
| 3 | ########################################### | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 10 | ▶ | use parent qw< Net::Google::Drive::Simple::Core >; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 10 | ▶ | use URI (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 10 | ▶ | use URI::QueryParam (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 10 | ▶ | use File::Basename (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 10 | ▶ | use JSON qw< from_json >; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 10 | ▶ | use Log::Log4perl qw(:easy); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | use constant { | ||||||||||||||||||||||||||||
| 16 | 10 | 'HTTP_METHOD_GET' => 'GET', | |||||||||||||||||||||||||||
| 17 | 'HTTP_METHOD_POST' => 'POST', | ||||||||||||||||||||||||||||
| 18 | 'HTTP_METHOD_PUT' => 'PUT', | ||||||||||||||||||||||||||||
| 19 | 'HTTP_METHOD_PATCH' => 'PATCH', | ||||||||||||||||||||||||||||
| 20 | 'HTTP_METHOD_DELETE' => 'DELETE', | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 'TYPE_STRING' => 'string', | ||||||||||||||||||||||||||||
| 23 | 'TYPE_INTEGER' => 'integer', | ||||||||||||||||||||||||||||
| 24 | 'TYPE_LONG' => 'long', | ||||||||||||||||||||||||||||
| 25 | 'TYPE_BOOLEAN' => 'boolean', | ||||||||||||||||||||||||||||
| 26 | 'TYPE_OBJECT' => 'object', | ||||||||||||||||||||||||||||
| 27 | 'TYPE_BYTES' => 'bytes', | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 'SIZE_256K' => 262_144, # default chunk size | ||||||||||||||||||||||||||||
| 30 | 'SIZE_5MB' => 5_242_880, # low limit | ||||||||||||||||||||||||||||
| 31 | 'SIZE_5120GB' => 5_497_558_138_880 # high limit | ||||||||||||||||||||||||||||
| 32 | 10 | ▶ | }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 10 | ▶ | use constant { 'DEF_CHUNK_SIZE' => SIZE_5MB() * 2 }; # 10 MB | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 10 | our $VERSION = '3.01'; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | # TODO: | ||||||||||||||||||||||||||||
| 39 | # * requestId are random UUIDs that we should probably generate (drive_create) | ||||||||||||||||||||||||||||
| 40 | # * Support for Request Body values | ||||||||||||||||||||||||||||
| 41 | # * Support fields format: https://developers.google.com/drive/api/guides/fields-parameter | ||||||||||||||||||||||||||||
| 42 | # * Add validation for path parameters | ||||||||||||||||||||||||||||
| 43 | # * Specific types (like ISO 639-1) | ||||||||||||||||||||||||||||
| 44 | # * Extended upload support: https://developers.google.com/drive/api/guides/manage-uploads | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | # These are only the defaults | ||||||||||||||||||||||||||||
| 47 | 10 | my %default_deprecated_param_names = ( | |||||||||||||||||||||||||||
| 48 | 'corpus' => 'corpora', | ||||||||||||||||||||||||||||
| 49 | 'includeTeamDriveItems' => 'includeItemsFromAllDrives', | ||||||||||||||||||||||||||||
| 50 | 'supportsTeamDrives' => 'supportsAllDrives', | ||||||||||||||||||||||||||||
| 51 | 'teamDriveId' => 'driveId', | ||||||||||||||||||||||||||||
| 52 | ); | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | ########################################### | ||||||||||||||||||||||||||||
| 55 | sub new { | ||||||||||||||||||||||||||||
| 56 | ########################################### | ||||||||||||||||||||||||||||
| 57 | 8 | ▶ | my ( $class, %options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 58 | 8 | return $class->SUPER::new( | |||||||||||||||||||||||||||
| 59 | %options, | ||||||||||||||||||||||||||||
| 60 | 'api_base_url' => 'https://www.googleapis.com/drive/v3/', | ||||||||||||||||||||||||||||
| 61 | 'api_upload_url' => 'https://www.googleapis.com/upload/drive/v3/files', | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | # to make sure api_test() works: | ||||||||||||||||||||||||||||
| 64 | 'api_file_url' => 'https://www.googleapis.com/drive/v3/files', | ||||||||||||||||||||||||||||
| 65 | ); | ||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | ########################################### | ||||||||||||||||||||||||||||
| 69 | sub _validate_param_type { | ||||||||||||||||||||||||||||
| 70 | ########################################### | ||||||||||||||||||||||||||||
| 71 | 37 | ▶ | my ( $self, $method, $param_data, $param_values ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_validate_param_type: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | my %validation_types = ( | ||||||||||||||||||||||||||||
| 74 | 5 | ▶ | TYPE_STRING() => sub { defined and length }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | 8 | ▶ | TYPE_INTEGER() => sub { defined and m{^[0-9]+$}xms }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | 4 | ▶ | TYPE_LONG() => sub { defined and m{^[0-9]+$}xms }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 6 | ▶ | TYPE_BOOLEAN() => sub { defined and m{^[01]$}xms }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 7 | ▶ | TYPE_OBJECT() => sub { ref eq 'HASH' }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 79 | 3 | ▶ | TYPE_BYTES() => sub { defined and length }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 37 | ); | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 37 | foreach my $param_name ( sort keys %{$param_values} ) { | |||||||||||||||||||||||||||
| 83 | 35 | ▶ | if ( !exists $param_data->{$param_name} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | 1 | LOGDIE("[$method] Parameter name '$param_name' does not exist"); | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 36 | foreach my $param_name ( sort keys %{$param_data} ) { | |||||||||||||||||||||||||||
| 89 | 36 | my ( $param_type, $is_required ) = @{ $param_data->{$param_name} }; | |||||||||||||||||||||||||||
| 90 | 36 | my $param_value = $param_values->{$param_name}; | |||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | # You did not provide a parameter that is needed | ||||||||||||||||||||||||||||
| 93 | 36 | ▶ | if ( !exists $param_values->{$param_name} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | 2 | ▶ | $is_required | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | and LOGDIE("[$method] Parameter '$param_name' is required"); | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 1 | next; | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 34 | my $validation_cb = $validation_types{$param_type}; | |||||||||||||||||||||||||||
| 101 | 34 | ▶ | if ( !$validation_cb ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | 1 | LOGDIE("[$method] Parameter type '$param_type' does not exist"); | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 33 | local $_ = $param_value; | |||||||||||||||||||||||||||
| 106 | 33 | ▶ | my $success = $validation_cb->() | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | or LOGDIE("[$method] Parameter type '$param_name' does not validate as '$param_type'"); | ||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 14 | return 1; | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | ########################################### | ||||||||||||||||||||||||||||
| 114 | sub _handle_complex_types { | ||||||||||||||||||||||||||||
| 115 | ########################################### | ||||||||||||||||||||||||||||
| 116 | 21 | ▶ | my ( $self, $method, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_handle_complex_types: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 21 | ▶ | if ( my $perm_for_view = $options->{'includePermissionsForView'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | 2 | ▶ | $perm_for_view eq 'published' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | or LOGDIE("[$method] Parameter 'includePermissionsForView' must be: published"); | ||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 20 | my $page_size = $options->{'pageSize'}; | |||||||||||||||||||||||||||
| 124 | 20 | ▶ | if ( defined $page_size ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 125 | 8 | ▶ | $page_size >= 1 && $page_size <= 1_000 | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$page_size >= 1 and $page_size <= 1000
MC/DC100%2/2
$page_size >= 1 and $page_size <= 1000
$page_size >= 1
$page_size <= 1000
Truth table100%3/3
A and B
A= $page_size >= 1B= $page_size <= 1000
| |||||||||||||||||||||||||||||
| 126 | or LOGDIE("[$method] Parameter 'pageSize' must be: 1 to 1000"); | ||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 16 | ▶ | if ( my $upload_type = $options->{'uploadType'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | 6 | ▶ | $upload_type =~ /^( media | multipart | resumable )$/xms | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | or LOGDIE("[$method] Parameter 'uploadType' must be: media|multipart|resumable"); | ||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 13 | return 1; | |||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | ########################################### | ||||||||||||||||||||||||||||
| 138 | sub _generate_uri { | ||||||||||||||||||||||||||||
| 139 | ########################################### | ||||||||||||||||||||||||||||
| 140 | 7 | ▶ | my ( $self, $path, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_generate_uri: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 141 | 7 | ▶ | my $uri = URI->new( $path =~ /^http/xms ? $path : $self->{'api_base_url'} . $path ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 7 | ▶ | $options && %{$options} | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$options and %{$options;}
MC/DC100%2/2
$options and %{$options;}
$options
%{$options;}
Truth table100%3/3
A and B
A= $optionsB= %{$options;}
| |||||||||||||||||||||||||||||
| 144 | and $uri->query_form($options); | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 7 | return $uri; | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | ########################################### | ||||||||||||||||||||||||||||
| 150 | sub _handle_deprecated_params { | ||||||||||||||||||||||||||||
| 151 | ########################################### | ||||||||||||||||||||||||||||
| 152 | 27 | ▶ | my ( $self, $method, $info, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_handle_deprecated_params: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 27 | foreach my $dep_name ( sort keys %{$options} ) { | |||||||||||||||||||||||||||
| 155 | my $alt = $info->{'deprecated_param_names'}{$dep_name} | ||||||||||||||||||||||||||||
| 156 | 26 | ▶ | || $default_deprecated_param_names{$dep_name}; | ||||||||||||||||||||||||||
|
Condition100%3/3
$info->{'deprecated_param_names'}{$dep_name} || $default_deprecated_param_names{$dep_name}
MC/DC100%2/2
$info->{'deprecated_param_names'}{$dep_name} || $default_deprecated_param_names{$dep_name}
$info->{'deprecated_param_names'}{$dep_name}
$default_deprecated_param_names{$dep_name}
Truth table100%3/3
A || B
A= $info->{'deprecated_param_names'}{$dep_name}B= $default_deprecated_param_names{$dep_name}
| |||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 26 | ▶ | if ($alt) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | 13 | WARN("[$method] Parameter name '$dep_name' is deprecated, use '$alt' instead"); | |||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 27 | return; | |||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | ########################################### | ||||||||||||||||||||||||||||
| 167 | sub _prepare_body_options { | ||||||||||||||||||||||||||||
| 168 | ########################################### | ||||||||||||||||||||||||||||
| 169 | 6 | ▶ | my ( $self, $options, $body_param_names ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_prepare_body_options: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | my $body_options = { | ||||||||||||||||||||||||||||
| 172 | map +( exists $options->{$_} ? ( $_ => delete $options->{$_} ) : () ), | ||||||||||||||||||||||||||||
| 173 | 6 | ▶ | @{$body_param_names}, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 174 | }; | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 6 | ▶ | keys %{$body_options} == 0 | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 177 | and return; | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 3 | return $body_options; | |||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | ########################################### | ||||||||||||||||||||||||||||
| 183 | sub _handle_api_method { | ||||||||||||||||||||||||||||
| 184 | ########################################### | ||||||||||||||||||||||||||||
| 185 | 5 | ▶ | my ( $self, $info, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_handle_api_method: called CC=8 SCAR=20.9
| |||||||||||||||||||||||||||||
| 186 | 5 | my $method = $info->{'method_name'}; | |||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | # We yank out all the body parameters so we don't validate them | ||||||||||||||||||||||||||||
| 189 | # We reuse the same key to store the key + value this time (instead of which keys to use in options) | ||||||||||||||||||||||||||||
| 190 | # TODO: Support body parameter validation | ||||||||||||||||||||||||||||
| 191 | 5 | my $body_parameters = delete $info->{'body_parameters'}; | |||||||||||||||||||||||||||
| 192 | 5 | ▶ | $info->{'body_parameters'} //= $self->_prepare_body_options( $options, $body_parameters ); | ||||||||||||||||||||||||||
|
Condition66%2/3
$info->{"body_parameters"} //= $self->_prepare_body_options($options, $body_parameters)
MC/DC50%1/2
$info->{"body_parameters"} //= $self->_prepare_body_options($options, $body_parameters)
$info->{"body_parameters"}
$self->_prepare_body_options($options, $body_parameters)
Truth table66%2/3
A //= B
A= $info->{"body_parameters"}B= $self->_prepare_body_options($options, $body_parameters)
| |||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | # We validate the options left | ||||||||||||||||||||||||||||
| 195 | 5 | $self->_validate_param_type( $method, $info->{'query_parameters'}, $options ); | |||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | # We might have a more complicated type checking specified | ||||||||||||||||||||||||||||
| 198 | 5 | ▶ | if ( my $param_check = $info->{'parameter_checks'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 199 | 1 | foreach my $name ( sort keys %{$param_check} ) { | |||||||||||||||||||||||||||
| 200 | 3 | ▶ | defined $options->{$name} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 201 | or next; | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 2 | my $cb = $param_check->{$name}; | |||||||||||||||||||||||||||
| 204 | 2 | ▶ | ref $cb eq 'CODE' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | or LOGDIE("[$method] Parameter '$name' missing validation callback"); | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 2 | local $_ = $options->{$name}; | |||||||||||||||||||||||||||
| 208 | 2 | my $error_str = $cb->(); | |||||||||||||||||||||||||||
| 209 | 2 | ▶ | $error_str | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | and LOGDIE("[$method] Parameter '$name' failed validation: $error_str"); | ||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | # We check for deprecated parameters (from a list of known deprecated parameters) | ||||||||||||||||||||||||||||
| 215 | 4 | $self->_handle_deprecated_params( $method, $info, $options ); | |||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | # We handle some more specific validation rules (from a list of known parameters) | ||||||||||||||||||||||||||||
| 218 | 4 | $self->_handle_complex_types( $method, $options ); | |||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 4 | $self->init(); | |||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | # We generate the URI path | ||||||||||||||||||||||||||||
| 223 | 4 | my $uri = $self->_generate_uri( $info->{'path'}, $options ); | |||||||||||||||||||||||||||
| 224 | 4 | my $req = $self->_generate_request( $uri, $info ); | |||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 4 | ▶ | if ( $info->{'return_http_request'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | 0 | return $req; | |||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 4 | return $self->_make_request( $req, $info->{'return_http_response'} ); | |||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | # --- about | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | ########################################### | ||||||||||||||||||||||||||||
| 236 | sub about { | ||||||||||||||||||||||||||||
| 237 | ########################################### | ||||||||||||||||||||||||||||
| 238 | 0 | ▶ | my ( $self, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
about: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 0 | ▶ | ref $options eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 241 | or LOGDIE('about() missing parameters'); | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 0 | my $info = { | |||||||||||||||||||||||||||
| 244 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 245 | 'fields' => [ TYPE_STRING(), 1 ], | ||||||||||||||||||||||||||||
| 246 | }, | ||||||||||||||||||||||||||||
| 247 | 'path' => 'about', | ||||||||||||||||||||||||||||
| 248 | 'method_name' => 'about', | ||||||||||||||||||||||||||||
| 249 | 'http_method' => HTTP_METHOD_GET(), | ||||||||||||||||||||||||||||
| 250 | }; | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | # --- changes | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | ########################################### | ||||||||||||||||||||||||||||
| 258 | sub getStartPageToken { | ||||||||||||||||||||||||||||
| 259 | ########################################### | ||||||||||||||||||||||||||||
| 260 | 0 | ▶ | my ( $self, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
getStartPageToken: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 0 | ▶ | $options //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$options //= {}
MC/DC0%0/1
$options //= {}
$options
Truth table0%0/2
A
A= $options
| |||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | 0 | my $info = { | |||||||||||||||||||||||||||
| 265 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 266 | 'driveId' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 267 | 'fields' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 268 | 'supportsAllDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 269 | 'supportsTeamDrives' => [ TYPE_BOOLEAN(), 0 ], # Deprecated | ||||||||||||||||||||||||||||
| 270 | 'teamDriveId' => [ TYPE_STRING(), 0 ], # Deprecated | ||||||||||||||||||||||||||||
| 271 | }, | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 'path' => 'changes/startPageToken', | ||||||||||||||||||||||||||||
| 274 | 'http_method' => HTTP_METHOD_GET(), | ||||||||||||||||||||||||||||
| 275 | 'method_name' => 'getStartPageToken', | ||||||||||||||||||||||||||||
| 276 | }; | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | ########################################### | ||||||||||||||||||||||||||||
| 282 | sub changes { | ||||||||||||||||||||||||||||
| 283 | ########################################### | ||||||||||||||||||||||||||||
| 284 | 0 | ▶ | my ( $self, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
changes: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | 0 | ▶ | ref $options eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 287 | or LOGDIE('changes() missing parameters'); | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | my $info = { | ||||||||||||||||||||||||||||
| 290 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 291 | 'pageToken' => [ TYPE_STRING(), 1 ], | ||||||||||||||||||||||||||||
| 292 | 'driveId' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 293 | 'fields' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 294 | 'includeCorpusRemovals' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 295 | 'includeItemsFromAllDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 296 | 'includePermissionsForView' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 297 | 'includeRemoved' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 298 | 'includeTeamDriveItems' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 299 | 'pageSize' => [ TYPE_INTEGER(), 0 ], | ||||||||||||||||||||||||||||
| 300 | 'restrictToMyDrive' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 301 | 'spaces' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 302 | 'supportsAllDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 303 | 'supportsTeamDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 304 | 'teamDriveId' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 305 | }, | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | 'parameter_checks' => { | ||||||||||||||||||||||||||||
| 308 | 'spaces' => sub { | ||||||||||||||||||||||||||||
| 309 | 0 | ▶ | /^( drive | appDataFolder | photos )$/xms | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 310 | or return 'must be: drive|appDataFolder|photos'; | ||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | 0 | return 0; | |||||||||||||||||||||||||||
| 313 | }, | ||||||||||||||||||||||||||||
| 314 | }, | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | 0 | 'path' => 'changes', | |||||||||||||||||||||||||||
| 317 | 'http_method' => HTTP_METHOD_GET(), | ||||||||||||||||||||||||||||
| 318 | 'method_name' => 'changes', | ||||||||||||||||||||||||||||
| 319 | }; | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | ########################################### | ||||||||||||||||||||||||||||
| 325 | sub watch_changes { | ||||||||||||||||||||||||||||
| 326 | ########################################### | ||||||||||||||||||||||||||||
| 327 | 0 | ▶ | my ( $self, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
watch_changes: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | 0 | ▶ | $options //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$options //= {}
MC/DC0%0/1
$options //= {}
$options
Truth table0%0/2
A
A= $options
| |||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | 0 | my $info = { | |||||||||||||||||||||||||||
| 332 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 333 | 'fields' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 334 | }, | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 'body_parameters' => [ | ||||||||||||||||||||||||||||
| 337 | qw< | ||||||||||||||||||||||||||||
| 338 | kind | ||||||||||||||||||||||||||||
| 339 | id | ||||||||||||||||||||||||||||
| 340 | resourceId | ||||||||||||||||||||||||||||
| 341 | resourceUri | ||||||||||||||||||||||||||||
| 342 | token | ||||||||||||||||||||||||||||
| 343 | expiration | ||||||||||||||||||||||||||||
| 344 | type | ||||||||||||||||||||||||||||
| 345 | address | ||||||||||||||||||||||||||||
| 346 | payload | ||||||||||||||||||||||||||||
| 347 | params | ||||||||||||||||||||||||||||
| 348 | > | ||||||||||||||||||||||||||||
| 349 | ], | ||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | 'path' => 'changes/watch', | ||||||||||||||||||||||||||||
| 352 | 'http_method' => HTTP_METHOD_POST(), | ||||||||||||||||||||||||||||
| 353 | 'method_name' => 'watch_changes', | ||||||||||||||||||||||||||||
| 354 | }; | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | 0 | $options->{'kind'} = 'api#channel'; | |||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | # --- channels | ||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | ########################################### | ||||||||||||||||||||||||||||
| 364 | sub stop_channels { | ||||||||||||||||||||||||||||
| 365 | ########################################### | ||||||||||||||||||||||||||||
| 366 | 0 | ▶ | my ( $self, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
stop_channels: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | 0 | ▶ | ref $options eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 369 | or LOGDIE('stop_channels() missing parameters'); | ||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | my $info = { | ||||||||||||||||||||||||||||
| 372 | 'body_parameters' => [ | ||||||||||||||||||||||||||||
| 373 | qw< | ||||||||||||||||||||||||||||
| 374 | kind | ||||||||||||||||||||||||||||
| 375 | id | ||||||||||||||||||||||||||||
| 376 | resourceId | ||||||||||||||||||||||||||||
| 377 | resourceUri | ||||||||||||||||||||||||||||
| 378 | token | ||||||||||||||||||||||||||||
| 379 | expiration | ||||||||||||||||||||||||||||
| 380 | type | ||||||||||||||||||||||||||||
| 381 | address | ||||||||||||||||||||||||||||
| 382 | payload | ||||||||||||||||||||||||||||
| 383 | params | ||||||||||||||||||||||||||||
| 384 | > | ||||||||||||||||||||||||||||
| 385 | ], | ||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | 'parameter_checks' => { | ||||||||||||||||||||||||||||
| 388 | 'type' => sub { | ||||||||||||||||||||||||||||
| 389 | 0 | ▶ | m{^web_?hook$}xms | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 390 | or return 'must be: webhook|web_hook'; | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | 0 | return 0; | |||||||||||||||||||||||||||
| 393 | }, | ||||||||||||||||||||||||||||
| 394 | }, | ||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | 0 | 'path' => 'channels/stop', | |||||||||||||||||||||||||||
| 397 | 'http_method' => HTTP_METHOD_POST(), | ||||||||||||||||||||||||||||
| 398 | 'method_name' => 'stop_channels', | ||||||||||||||||||||||||||||
| 399 | }; | ||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | 0 | $options->{'kind'} = 'api#channel'; | |||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | # --- comments | ||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | ########################################### | ||||||||||||||||||||||||||||
| 409 | sub create_comment { | ||||||||||||||||||||||||||||
| 410 | ########################################### | ||||||||||||||||||||||||||||
| 411 | 0 | ▶ | my ( $self, $fileId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
create_comment: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 414 | or LOGDIE('create_comment() missing file ID'); | ||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | 0 | ▶ | ref $options eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 417 | or LOGDIE('create_comment() missing parameters'); | ||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | 0 | my $info = { | |||||||||||||||||||||||||||
| 420 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 421 | 'fields' => [ TYPE_STRING(), 1 ], | ||||||||||||||||||||||||||||
| 422 | }, | ||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | 'body_parameters' => [ | ||||||||||||||||||||||||||||
| 425 | qw< | ||||||||||||||||||||||||||||
| 426 | content | ||||||||||||||||||||||||||||
| 427 | anchor | ||||||||||||||||||||||||||||
| 428 | quotedFileContent | ||||||||||||||||||||||||||||
| 429 | > | ||||||||||||||||||||||||||||
| 430 | ], | ||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||
| 432 | 'path' => "files/$fileId/comments", | ||||||||||||||||||||||||||||
| 433 | 'method_name' => 'create_comment', | ||||||||||||||||||||||||||||
| 434 | 'http_method' => HTTP_METHOD_POST(), | ||||||||||||||||||||||||||||
| 435 | }; | ||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | ########################################### | ||||||||||||||||||||||||||||
| 441 | sub delete_comment { | ||||||||||||||||||||||||||||
| 442 | ########################################### | ||||||||||||||||||||||||||||
| 443 | 0 | ▶ | my ( $self, $fileId, $commentId ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
delete_comment: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||
| 445 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 446 | or LOGDIE('create_comment() missing file ID'); | ||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | 0 | ▶ | defined $commentId && length $commentId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $commentId and length $commentId
MC/DC0%0/2
defined $commentId and length $commentId
defined $commentId
length $commentId
Truth table0%0/3
A and B
A= defined $commentIdB= length $commentId
| |||||||||||||||||||||||||||||
| 449 | or LOGDIE('create_comment() missing comment ID'); | ||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||
| 451 | 0 | my $info = { | |||||||||||||||||||||||||||
| 452 | 'path' => "files/$fileId/comments/$commentId", | ||||||||||||||||||||||||||||
| 453 | 'method_name' => 'delete_comment', | ||||||||||||||||||||||||||||
| 454 | 'http_method' => HTTP_METHOD_DELETE(), | ||||||||||||||||||||||||||||
| 455 | }; | ||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | 0 | return $self->_handle_api_method( $info, {} ); | |||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||
| 460 | ########################################### | ||||||||||||||||||||||||||||
| 461 | sub get_comment { | ||||||||||||||||||||||||||||
| 462 | ########################################### | ||||||||||||||||||||||||||||
| 463 | 0 | ▶ | my ( $self, $fileId, $commentId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_comment: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 466 | or LOGDIE('get_comment() missing file ID'); | ||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||
| 468 | 0 | ▶ | defined $commentId && length $commentId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $commentId and length $commentId
MC/DC0%0/2
defined $commentId and length $commentId
defined $commentId
length $commentId
Truth table0%0/3
A and B
A= defined $commentIdB= length $commentId
| |||||||||||||||||||||||||||||
| 469 | or LOGDIE('get_comment() missing comment ID'); | ||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | 0 | ▶ | ref $options eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 472 | or LOGDIE('get_comment() missing parameters'); | ||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||
| 474 | 0 | my $info = { | |||||||||||||||||||||||||||
| 475 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 476 | 'fields' => [ TYPE_STRING(), 1 ], | ||||||||||||||||||||||||||||
| 477 | 'includeDeleted' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 478 | }, | ||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||
| 480 | 'path' => "files/$fileId/comments/$commentId", | ||||||||||||||||||||||||||||
| 481 | 'method_name' => 'get_comment', | ||||||||||||||||||||||||||||
| 482 | 'http_method' => HTTP_METHOD_GET(), | ||||||||||||||||||||||||||||
| 483 | }; | ||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||
| 488 | ########################################### | ||||||||||||||||||||||||||||
| 489 | sub comments { | ||||||||||||||||||||||||||||
| 490 | ########################################### | ||||||||||||||||||||||||||||
| 491 | 0 | ▶ | my ( $self, $fileId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
comments: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||
| 493 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 494 | or LOGDIE('comments() missing file ID'); | ||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||
| 496 | 0 | ▶ | ref $options eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 497 | or LOGDIE('comments() missing parameters'); | ||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | 0 | my $info = { | |||||||||||||||||||||||||||
| 500 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 501 | 'fields' => [ TYPE_STRING(), 1 ], | ||||||||||||||||||||||||||||
| 502 | 'includeDeleted' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 503 | 'pageSize' => [ TYPE_INTEGER(), 0 ], | ||||||||||||||||||||||||||||
| 504 | 'pageToken' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 505 | 'startModifiedTime' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 506 | }, | ||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||
| 508 | 'path' => "files/$fileId/comments", | ||||||||||||||||||||||||||||
| 509 | 'method_name' => 'comments', | ||||||||||||||||||||||||||||
| 510 | 'http_method' => HTTP_METHOD_GET(), | ||||||||||||||||||||||||||||
| 511 | }; | ||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||
| 513 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||
| 516 | ########################################### | ||||||||||||||||||||||||||||
| 517 | sub update_comment { | ||||||||||||||||||||||||||||
| 518 | ########################################### | ||||||||||||||||||||||||||||
| 519 | 0 | ▶ | my ( $self, $fileId, $commentId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
update_comment: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||
| 521 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 522 | or LOGDIE('update_comment() missing file ID'); | ||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||
| 524 | 0 | ▶ | defined $commentId && length $commentId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $commentId and length $commentId
MC/DC0%0/2
defined $commentId and length $commentId
defined $commentId
length $commentId
Truth table0%0/3
A and B
A= defined $commentIdB= length $commentId
| |||||||||||||||||||||||||||||
| 525 | or LOGDIE('update_comment() missing comment ID'); | ||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | 0 | ▶ | ref $options eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 528 | or LOGDIE('update_comment() missing parameters'); | ||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||
| 530 | 0 | my $info = { | |||||||||||||||||||||||||||
| 531 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 532 | 'fields' => [ TYPE_STRING(), 1 ], | ||||||||||||||||||||||||||||
| 533 | }, | ||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||
| 535 | 'body_parameters' => [ | ||||||||||||||||||||||||||||
| 536 | qw< | ||||||||||||||||||||||||||||
| 537 | content | ||||||||||||||||||||||||||||
| 538 | > | ||||||||||||||||||||||||||||
| 539 | ], | ||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||
| 541 | 'path' => "files/$fileId/comments/$commentId", | ||||||||||||||||||||||||||||
| 542 | 'method_name' => 'update_comment', | ||||||||||||||||||||||||||||
| 543 | 'http_method' => HTTP_METHOD_PATCH(), | ||||||||||||||||||||||||||||
| 544 | }; | ||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||
| 546 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||
| 549 | # --- files | ||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||
| 551 | ########################################### | ||||||||||||||||||||||||||||
| 552 | sub copy_file { | ||||||||||||||||||||||||||||
| 553 | ########################################### | ||||||||||||||||||||||||||||
| 554 | 0 | ▶ | my ( $self, $fileId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
copy_file: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 557 | or LOGDIE('copy_file() missing file ID'); | ||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||
| 559 | 0 | ▶ | ref $options eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 560 | or LOGDIE('copy_file() missing parameters'); | ||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | # TODO: ocrLanguage is ISO 639-1 code | ||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | 0 | my $info = { | |||||||||||||||||||||||||||
| 565 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 566 | 'fields' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 567 | 'ignoreDefaultVisibility' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 568 | 'includePermissionsForView' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 569 | 'keepRevisionForever' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 570 | 'ocrLanguage' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 571 | 'supportsAllDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 572 | 'supportsTeamDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 573 | }, | ||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | 'body_parameters' => [ | ||||||||||||||||||||||||||||
| 576 | qw< | ||||||||||||||||||||||||||||
| 577 | appProperties | ||||||||||||||||||||||||||||
| 578 | contentHints | ||||||||||||||||||||||||||||
| 579 | contentRestrictions | ||||||||||||||||||||||||||||
| 580 | copyRequiresWriterPermission | ||||||||||||||||||||||||||||
| 581 | description | ||||||||||||||||||||||||||||
| 582 | id | ||||||||||||||||||||||||||||
| 583 | mimeType | ||||||||||||||||||||||||||||
| 584 | modifiedTime | ||||||||||||||||||||||||||||
| 585 | name | ||||||||||||||||||||||||||||
| 586 | parents | ||||||||||||||||||||||||||||
| 587 | properties | ||||||||||||||||||||||||||||
| 588 | starred | ||||||||||||||||||||||||||||
| 589 | viewedByMeTime | ||||||||||||||||||||||||||||
| 590 | writersCanShare | ||||||||||||||||||||||||||||
| 591 | > | ||||||||||||||||||||||||||||
| 592 | ], | ||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||
| 594 | 'path' => "files/$fileId/copy", | ||||||||||||||||||||||||||||
| 595 | 'method_name' => 'copy_file', | ||||||||||||||||||||||||||||
| 596 | 'http_method' => HTTP_METHOD_POST(), | ||||||||||||||||||||||||||||
| 597 | }; | ||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||
| 599 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||
| 602 | # Metadata only | ||||||||||||||||||||||||||||
| 603 | ########################################### | ||||||||||||||||||||||||||||
| 604 | sub create_file { | ||||||||||||||||||||||||||||
| 605 | ########################################### | ||||||||||||||||||||||||||||
| 606 | 0 | ▶ | my ( $self, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
create_file: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||
| 608 | 0 | ▶ | ref $options eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 609 | or LOGDIE('create_file() missing parameters'); | ||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||
| 611 | 0 | my $info = { | |||||||||||||||||||||||||||
| 612 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 613 | 'enforceSingleParent' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 614 | 'ignoreDefaultVisibility' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 615 | 'includePermissionsForView' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 616 | 'keepRevisionForever' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 617 | 'ocrLanguage' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 618 | 'supportsAllDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 619 | 'supportsTeamDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 620 | 'useContentAsIndexableText' => [ TYPE_BOOLEAN(), 0 ] | ||||||||||||||||||||||||||||
| 621 | }, | ||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||
| 623 | 'body_parameters' => [ | ||||||||||||||||||||||||||||
| 624 | qw< | ||||||||||||||||||||||||||||
| 625 | appProperties | ||||||||||||||||||||||||||||
| 626 | contentHints | ||||||||||||||||||||||||||||
| 627 | contentRestrictions | ||||||||||||||||||||||||||||
| 628 | copyRequiresWriterPermission | ||||||||||||||||||||||||||||
| 629 | createdTime | ||||||||||||||||||||||||||||
| 630 | description | ||||||||||||||||||||||||||||
| 631 | folderColorRgb | ||||||||||||||||||||||||||||
| 632 | id | ||||||||||||||||||||||||||||
| 633 | mimeType | ||||||||||||||||||||||||||||
| 634 | modifiedTime | ||||||||||||||||||||||||||||
| 635 | name | ||||||||||||||||||||||||||||
| 636 | originalFilename | ||||||||||||||||||||||||||||
| 637 | parents | ||||||||||||||||||||||||||||
| 638 | properties | ||||||||||||||||||||||||||||
| 639 | shortcutDetails.targetId | ||||||||||||||||||||||||||||
| 640 | starred | ||||||||||||||||||||||||||||
| 641 | viewedByMeTime | ||||||||||||||||||||||||||||
| 642 | writersCanShare | ||||||||||||||||||||||||||||
| 643 | > | ||||||||||||||||||||||||||||
| 644 | ], | ||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||
| 646 | 'path' => 'files', | ||||||||||||||||||||||||||||
| 647 | 'method_name' => 'create_file', | ||||||||||||||||||||||||||||
| 648 | 'http_method' => HTTP_METHOD_POST(), | ||||||||||||||||||||||||||||
| 649 | }; | ||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||
| 651 | 0 | ▶ | if ( defined $options->{'enforceSingleParent'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 652 | 0 | LOGDIE("[$info->{'method_name'}] Creating files in multiple folders is no longer supported"); | |||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||
| 655 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||
| 658 | # Uploading file (uploadType=media) | ||||||||||||||||||||||||||||
| 659 | ########################################### | ||||||||||||||||||||||||||||
| 660 | sub upload_media_file { | ||||||||||||||||||||||||||||
| 661 | ########################################### | ||||||||||||||||||||||||||||
| 662 | 0 | ▶ | my ( $self, $file, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
upload_media_file: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||
| 664 | 0 | ▶ | defined $file && length $file | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $file and length $file
MC/DC0%0/2
defined $file and length $file
defined $file
length $file
Truth table0%0/3
A and B
A= defined $fileB= length $file
| |||||||||||||||||||||||||||||
| 665 | or LOGDIE('upload_media_file() missing file'); | ||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||
| 667 | 0 | ▶ | -r $file | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 668 | or LOGDIE("upload_media_file() received non-existent/unreadable file: $file"); | ||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||
| 670 | 0 | my $size = -s $file; | |||||||||||||||||||||||||||
| 671 | 0 | ▶ | $size <= SIZE_5MB() | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 672 | or LOGDIE("upload_media_file() has a limit of 5M, '$file' is bigger"); | ||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||
| 674 | 0 | ▶ | $options //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$options //= {}
MC/DC0%0/1
$options //= {}
$options
Truth table0%0/2
A
A= $options
| |||||||||||||||||||||||||||||
| 675 | 0 | $options->{'uploadType'} = 'media'; | |||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||
| 677 | 0 | ▶ | my $mimeType = delete $options->{'mimeType'} // $self->file_mime_type($file); | ||||||||||||||||||||||||||
|
Condition0%0/3
delete $options->{"mimeType"} // $self->file_mime_type($file)
MC/DC0%0/2
delete $options->{"mimeType"} // $self->file_mime_type($file)
delete $options->{"mimeType"}
$self->file_mime_type($file)
Truth table0%0/3
A // B
A= delete $options->{"mimeType"}B= $self->file_mime_type($file)
| |||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||
| 679 | my $info = { | ||||||||||||||||||||||||||||
| 680 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 681 | 'uploadType' => [ TYPE_STRING(), 1 ], | ||||||||||||||||||||||||||||
| 682 | 'enforceSingleParent' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 683 | 'ignoreDefaultVisibility' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 684 | 'includePermissionsForView' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 685 | 'keepRevisionForever' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 686 | 'ocrLanguage' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 687 | 'supportsAllDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 688 | 'supportsTeamDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 689 | 'useContentAsIndexableText' => [ TYPE_BOOLEAN(), 0 ] | ||||||||||||||||||||||||||||
| 690 | }, | ||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||
| 692 | 0 | 'path' => $self->{'api_upload_url'}, | |||||||||||||||||||||||||||
| 693 | 'method_name' => 'upload_media_file', | ||||||||||||||||||||||||||||
| 694 | 'http_method' => HTTP_METHOD_POST(), | ||||||||||||||||||||||||||||
| 695 | 'body_content' => $self->_content_sub($file), | ||||||||||||||||||||||||||||
| 696 | 'extra_headers' => [ | ||||||||||||||||||||||||||||
| 697 | 'Content-Type' => $mimeType, | ||||||||||||||||||||||||||||
| 698 | 'Content-Length' => $size, | ||||||||||||||||||||||||||||
| 699 | ], | ||||||||||||||||||||||||||||
| 700 | }; | ||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||
| 702 | 0 | ▶ | if ( defined $options->{'enforceSingleParent'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 703 | 0 | LOGDIE("[$info->{'method_name'}] Creating files in multiple folders is no longer supported"); | |||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||
| 706 | # Since a file upload can take a long time, refresh the token | ||||||||||||||||||||||||||||
| 707 | # just in case. | ||||||||||||||||||||||||||||
| 708 | 0 | $self->{'oauth'}->token_expire(); | |||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||
| 710 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||
| 713 | ########################################### | ||||||||||||||||||||||||||||
| 714 | sub upload_multipart_file { | ||||||||||||||||||||||||||||
| 715 | ########################################### | ||||||||||||||||||||||||||||
| 716 | 0 | ▶ | my ( $self, $file, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
upload_multipart_file: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||
| 718 | 0 | ▶ | defined $file && length $file | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $file and length $file
MC/DC0%0/2
defined $file and length $file
defined $file
length $file
Truth table0%0/3
A and B
A= defined $fileB= length $file
| |||||||||||||||||||||||||||||
| 719 | or LOGDIE('upload_multipart_file() missing file'); | ||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||
| 721 | 0 | ▶ | -r $file | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 722 | or LOGDIE("upload_multipart_file() received non-existent/unreadable file: $file"); | ||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||
| 724 | 0 | my $size = -s $file; | |||||||||||||||||||||||||||
| 725 | 0 | ▶ | $size <= SIZE_5MB() | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 726 | or LOGDIE("upload_multipart_file() has a limit of 5M, '$file' is bigger"); | ||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||
| 728 | 0 | ▶ | $options //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$options //= {}
MC/DC0%0/1
$options //= {}
$options
Truth table0%0/2
A
A= $options
| |||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||
| 730 | 0 | ▶ | $options->{'name'} //= File::Basename::basename($file); | ||||||||||||||||||||||||||
|
Condition0%0/3
$options->{"name"} //= File::Basename::basename($file)
MC/DC0%0/2
$options->{"name"} //= File::Basename::basename($file)
$options->{"name"}
File::Basename::basename($file)
Truth table0%0/3
A //= B
A= $options->{"name"}B= File::Basename::basename($file)
| |||||||||||||||||||||||||||||
| 731 | 0 | ▶ | $options->{'mimeType'} //= $self->file_mime_type($file); | ||||||||||||||||||||||||||
|
Condition0%0/3
$options->{"mimeType"} //= $self->file_mime_type($file)
MC/DC0%0/2
$options->{"mimeType"} //= $self->file_mime_type($file)
$options->{"mimeType"}
$self->file_mime_type($file)
Truth table0%0/3
A //= B
A= $options->{"mimeType"}B= $self->file_mime_type($file)
| |||||||||||||||||||||||||||||
| 732 | 0 | $options->{'uploadType'} = 'multipart'; | |||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||
| 734 | # TODO: Wouldn't it be great to support Chunking with a callback? | ||||||||||||||||||||||||||||
| 735 | 0 | my $file_content; | |||||||||||||||||||||||||||
| 736 | { | ||||||||||||||||||||||||||||
| 737 | 0 | ▶ | open my $fh, '<', $file | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 738 | or LOGDIE("File '$file' cannot be open for reading"); | ||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||
| 740 | 0 | undef $/; | |||||||||||||||||||||||||||
| 741 | 0 | $file_content = <$fh>; | |||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||
| 743 | 0 | ▶ | close $fh | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 744 | or LOGDIE("File '$file' cannot be closed after reading"); | ||||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||
| 747 | my $info = { | ||||||||||||||||||||||||||||
| 748 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 749 | 'uploadType' => [ TYPE_STRING(), 1 ], | ||||||||||||||||||||||||||||
| 750 | 'enforceSingleParent' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 751 | 'ignoreDefaultVisibility' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 752 | 'includePermissionsForView' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 753 | 'keepRevisionForever' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 754 | 'ocrLanguage' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 755 | 'supportsAllDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 756 | 'supportsTeamDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 757 | 'useContentAsIndexableText' => [ TYPE_BOOLEAN(), 0 ] | ||||||||||||||||||||||||||||
| 758 | }, | ||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||
| 760 | 'body_parameters' => [ | ||||||||||||||||||||||||||||
| 761 | qw< | ||||||||||||||||||||||||||||
| 762 | appProperties | ||||||||||||||||||||||||||||
| 763 | contentHints | ||||||||||||||||||||||||||||
| 764 | contentRestrictions | ||||||||||||||||||||||||||||
| 765 | copyRequiresWriterPermission | ||||||||||||||||||||||||||||
| 766 | createdTime | ||||||||||||||||||||||||||||
| 767 | description | ||||||||||||||||||||||||||||
| 768 | folderColorRgb | ||||||||||||||||||||||||||||
| 769 | id | ||||||||||||||||||||||||||||
| 770 | mimeType | ||||||||||||||||||||||||||||
| 771 | modifiedTime | ||||||||||||||||||||||||||||
| 772 | name | ||||||||||||||||||||||||||||
| 773 | originalFilename | ||||||||||||||||||||||||||||
| 774 | parents | ||||||||||||||||||||||||||||
| 775 | properties | ||||||||||||||||||||||||||||
| 776 | shortcutDetails.targetId | ||||||||||||||||||||||||||||
| 777 | starred | ||||||||||||||||||||||||||||
| 778 | viewedByMeTime | ||||||||||||||||||||||||||||
| 779 | writersCanShare | ||||||||||||||||||||||||||||
| 780 | > | ||||||||||||||||||||||||||||
| 781 | ], | ||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||
| 783 | 0 | 'path' => $self->{'api_upload_url'}, | |||||||||||||||||||||||||||
| 784 | 'method_name' => 'upload_multipart_file', | ||||||||||||||||||||||||||||
| 785 | 'http_method' => HTTP_METHOD_POST(), | ||||||||||||||||||||||||||||
| 786 | 'multipart' => 1, | ||||||||||||||||||||||||||||
| 787 | 'body_content' => $file_content, | ||||||||||||||||||||||||||||
| 788 | }; | ||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||
| 790 | 0 | ▶ | if ( defined $options->{'enforceSingleParent'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 791 | 0 | LOGDIE("[$info->{'method_name'}] Creating files in multiple folders is no longer supported"); | |||||||||||||||||||||||||||
| 792 | } | ||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||
| 794 | # Since a file upload can take a long time, refresh the token | ||||||||||||||||||||||||||||
| 795 | # just in case. | ||||||||||||||||||||||||||||
| 796 | 0 | $self->{'oauth'}->token_expire(); | |||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||
| 798 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||
| 801 | ########################################### | ||||||||||||||||||||||||||||
| 802 | sub create_resumable_upload_for { | ||||||||||||||||||||||||||||
| 803 | ########################################### | ||||||||||||||||||||||||||||
| 804 | 0 | ▶ | my ( $self, $file, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
create_resumable_upload_for: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||
| 806 | 0 | ▶ | defined $file && length $file | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $file and length $file
MC/DC0%0/2
defined $file and length $file
defined $file
length $file
Truth table0%0/3
A and B
A= defined $fileB= length $file
| |||||||||||||||||||||||||||||
| 807 | or LOGDIE('create_resumable_upload_for() missing file'); | ||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||
| 809 | 0 | ▶ | -r $file | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 810 | or LOGDIE("create_resumable_upload_for() received non-existent/unreadable file: $file"); | ||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||
| 812 | 0 | my $size = -s $file; | |||||||||||||||||||||||||||
| 813 | 0 | ▶ | $size <= SIZE_5120GB() | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 814 | or LOGDIE("create_resumavble_upload_for() has a limit of 5120G, '$file' is bigger"); | ||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||
| 816 | 0 | ▶ | $options //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$options //= {}
MC/DC0%0/1
$options //= {}
$options
Truth table0%0/2
A
A= $options
| |||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||
| 818 | 0 | ▶ | $options->{'name'} //= File::Basename::basename($file); | ||||||||||||||||||||||||||
|
Condition0%0/3
$options->{"name"} //= File::Basename::basename($file)
MC/DC0%0/2
$options->{"name"} //= File::Basename::basename($file)
$options->{"name"}
File::Basename::basename($file)
Truth table0%0/3
A //= B
A= $options->{"name"}B= File::Basename::basename($file)
| |||||||||||||||||||||||||||||
| 819 | 0 | ▶ | $options->{'mimeType'} //= $self->file_mime_type($file); | ||||||||||||||||||||||||||
|
Condition0%0/3
$options->{"mimeType"} //= $self->file_mime_type($file)
MC/DC0%0/2
$options->{"mimeType"} //= $self->file_mime_type($file)
$options->{"mimeType"}
$self->file_mime_type($file)
Truth table0%0/3
A //= B
A= $options->{"mimeType"}B= $self->file_mime_type($file)
| |||||||||||||||||||||||||||||
| 820 | 0 | $options->{'uploadType'} = 'resumable'; | |||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||
| 822 | my @extra_headers = ( | ||||||||||||||||||||||||||||
| 823 | 0 | 'X-Upload-Content-Type' => $options->{'mimeType'}, | |||||||||||||||||||||||||||
| 824 | 'X-Upload-Content-Length' => $size, | ||||||||||||||||||||||||||||
| 825 | ); | ||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||
| 827 | # Do we have metadata other than uploadType? | ||||||||||||||||||||||||||||
| 828 | 0 | ▶ | if ( keys %{$options} > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 829 | 0 | push @extra_headers, 'Content-Type' => 'application/json; charset=UTF-8'; | |||||||||||||||||||||||||||
| 830 | } | ||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||
| 832 | my $info = { | ||||||||||||||||||||||||||||
| 833 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 834 | 'uploadType' => [ TYPE_STRING(), 1 ], | ||||||||||||||||||||||||||||
| 835 | 'enforceSingleParent' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 836 | 'ignoreDefaultVisibility' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 837 | 'includePermissionsForView' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 838 | 'keepRevisionForever' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 839 | 'ocrLanguage' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 840 | 'supportsAllDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 841 | 'supportsTeamDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 842 | 'useContentAsIndexableText' => [ TYPE_BOOLEAN(), 0 ] | ||||||||||||||||||||||||||||
| 843 | }, | ||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||
| 845 | 'body_parameters' => [ | ||||||||||||||||||||||||||||
| 846 | qw< | ||||||||||||||||||||||||||||
| 847 | appProperties | ||||||||||||||||||||||||||||
| 848 | contentHints | ||||||||||||||||||||||||||||
| 849 | contentRestrictions | ||||||||||||||||||||||||||||
| 850 | copyRequiresWriterPermission | ||||||||||||||||||||||||||||
| 851 | createdTime | ||||||||||||||||||||||||||||
| 852 | description | ||||||||||||||||||||||||||||
| 853 | folderColorRgb | ||||||||||||||||||||||||||||
| 854 | id | ||||||||||||||||||||||||||||
| 855 | mimeType | ||||||||||||||||||||||||||||
| 856 | modifiedTime | ||||||||||||||||||||||||||||
| 857 | name | ||||||||||||||||||||||||||||
| 858 | originalFilename | ||||||||||||||||||||||||||||
| 859 | parents | ||||||||||||||||||||||||||||
| 860 | properties | ||||||||||||||||||||||||||||
| 861 | shortcutDetails.targetId | ||||||||||||||||||||||||||||
| 862 | starred | ||||||||||||||||||||||||||||
| 863 | viewedByMeTime | ||||||||||||||||||||||||||||
| 864 | writersCanShare | ||||||||||||||||||||||||||||
| 865 | > | ||||||||||||||||||||||||||||
| 866 | ], | ||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||
| 868 | 0 | 'path' => $self->{'api_upload_url'}, | |||||||||||||||||||||||||||
| 869 | 'method_name' => 'create_resumable_upload', | ||||||||||||||||||||||||||||
| 870 | 'http_method' => HTTP_METHOD_POST(), | ||||||||||||||||||||||||||||
| 871 | 'extra_headers' => \@extra_headers, | ||||||||||||||||||||||||||||
| 872 | 'resumable' => 1, | ||||||||||||||||||||||||||||
| 873 | 'return_http_response' => 1, | ||||||||||||||||||||||||||||
| 874 | }; | ||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||
| 876 | 0 | ▶ | if ( defined $options->{'enforceSingleParent'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 877 | 0 | LOGDIE("[$info->{'method_name'}] Creating files in multiple folders is no longer supported"); | |||||||||||||||||||||||||||
| 878 | } | ||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||
| 880 | # Since a file upload can take a long time, refresh the token | ||||||||||||||||||||||||||||
| 881 | # just in case. | ||||||||||||||||||||||||||||
| 882 | 0 | $self->{'oauth'}->token_expire(); | |||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||
| 884 | 0 | my $response = $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 885 | 0 | ▶ | $response->is_success() | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 886 | or return; | ||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||
| 888 | 0 | my $location = $response->header('Location'); | |||||||||||||||||||||||||||
| 889 | 0 | ▶ | return $location || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$location || ''
MC/DC0%0/1
$location || ''
$location
Truth table0%0/2
A
A= $location
| |||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||
| 892 | ########################################### | ||||||||||||||||||||||||||||
| 893 | sub create_resumable_upload { | ||||||||||||||||||||||||||||
| 894 | ########################################### | ||||||||||||||||||||||||||||
| 895 | 0 | ▶ | my ( $self, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
create_resumable_upload: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||
| 897 | 0 | ▶ | $options //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$options //= {}
MC/DC0%0/1
$options //= {}
$options
Truth table0%0/2
A
A= $options
| |||||||||||||||||||||||||||||
| 898 | 0 | $options->{'uploadType'} = 'resumable'; | |||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||
| 900 | 0 | my @extra_headers; | |||||||||||||||||||||||||||
| 901 | 0 | ▶ | if ( my $mimeType = delete $options->{'mediaType'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 902 | 0 | push @extra_headers, 'X-Upload-Content-Type' => $mimeType; | |||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||
| 905 | # Do we have metadata other than uploadType? | ||||||||||||||||||||||||||||
| 906 | 0 | ▶ | if ( keys %{$options} > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 907 | 0 | push @extra_headers, 'Content-Type' => 'application/json; charset=UTF-8'; | |||||||||||||||||||||||||||
| 908 | } | ||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||
| 910 | my $info = { | ||||||||||||||||||||||||||||
| 911 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 912 | 'uploadType' => [ TYPE_STRING(), 1 ], | ||||||||||||||||||||||||||||
| 913 | 'enforceSingleParent' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 914 | 'ignoreDefaultVisibility' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 915 | 'includePermissionsForView' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 916 | 'keepRevisionForever' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 917 | 'ocrLanguage' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 918 | 'supportsAllDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 919 | 'supportsTeamDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 920 | 'useContentAsIndexableText' => [ TYPE_BOOLEAN(), 0 ] | ||||||||||||||||||||||||||||
| 921 | }, | ||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||
| 923 | 'body_parameters' => [ | ||||||||||||||||||||||||||||
| 924 | qw< | ||||||||||||||||||||||||||||
| 925 | appProperties | ||||||||||||||||||||||||||||
| 926 | contentHints | ||||||||||||||||||||||||||||
| 927 | contentRestrictions | ||||||||||||||||||||||||||||
| 928 | copyRequiresWriterPermission | ||||||||||||||||||||||||||||
| 929 | createdTime | ||||||||||||||||||||||||||||
| 930 | description | ||||||||||||||||||||||||||||
| 931 | folderColorRgb | ||||||||||||||||||||||||||||
| 932 | id | ||||||||||||||||||||||||||||
| 933 | mimeType | ||||||||||||||||||||||||||||
| 934 | modifiedTime | ||||||||||||||||||||||||||||
| 935 | name | ||||||||||||||||||||||||||||
| 936 | originalFilename | ||||||||||||||||||||||||||||
| 937 | parents | ||||||||||||||||||||||||||||
| 938 | properties | ||||||||||||||||||||||||||||
| 939 | shortcutDetails.targetId | ||||||||||||||||||||||||||||
| 940 | starred | ||||||||||||||||||||||||||||
| 941 | viewedByMeTime | ||||||||||||||||||||||||||||
| 942 | writersCanShare | ||||||||||||||||||||||||||||
| 943 | > | ||||||||||||||||||||||||||||
| 944 | ], | ||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||
| 946 | 0 | 'path' => $self->{'api_upload_url'}, | |||||||||||||||||||||||||||
| 947 | 'method_name' => 'create_resumable_upload', | ||||||||||||||||||||||||||||
| 948 | 'http_method' => HTTP_METHOD_POST(), | ||||||||||||||||||||||||||||
| 949 | 'extra_headers' => \@extra_headers, | ||||||||||||||||||||||||||||
| 950 | 'resumable' => 1, | ||||||||||||||||||||||||||||
| 951 | 'return_http_response' => 1, | ||||||||||||||||||||||||||||
| 952 | }; | ||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||
| 954 | 0 | ▶ | if ( defined $options->{'enforceSingleParent'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 955 | 0 | LOGDIE("[$info->{'method_name'}] Creating files in multiple folders is no longer supported"); | |||||||||||||||||||||||||||
| 956 | } | ||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||
| 958 | # Since a file upload can take a long time, refresh the token | ||||||||||||||||||||||||||||
| 959 | # just in case. | ||||||||||||||||||||||||||||
| 960 | 0 | $self->{'oauth'}->token_expire(); | |||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||
| 962 | 0 | my $response = $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 963 | 0 | ▶ | $response->is_success() | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 964 | or return; | ||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||
| 966 | 0 | my $location = $response->header('Location'); | |||||||||||||||||||||||||||
| 967 | 0 | ▶ | return $location || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$location || ''
MC/DC0%0/1
$location || ''
$location
Truth table0%0/2
A
A= $location
| |||||||||||||||||||||||||||||
| 968 | } | ||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||
| 970 | ########################################### | ||||||||||||||||||||||||||||
| 971 | sub upload_file_content_single { | ||||||||||||||||||||||||||||
| 972 | ########################################### | ||||||||||||||||||||||||||||
| 973 | 0 | ▶ | my ( $self, $upload_uri, $file ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
upload_file_content_single: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||
| 975 | 0 | ▶ | defined $upload_uri && length $upload_uri | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $upload_uri and length $upload_uri
MC/DC0%0/2
defined $upload_uri and length $upload_uri
defined $upload_uri
length $upload_uri
Truth table0%0/3
A and B
A= defined $upload_uriB= length $upload_uri
| |||||||||||||||||||||||||||||
| 976 | or LOGDIE('upload_file_content_single() missing upload_uri'); | ||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||
| 978 | 0 | ▶ | $upload_uri =~ m{^https://.*\bupload_id=.+}xmsi | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 979 | or LOGDIE('upload_file_content_single() upload_uri seems malformed'); | ||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||
| 981 | 0 | ▶ | defined $file && length $file | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $file and length $file
MC/DC0%0/2
defined $file and length $file
defined $file
length $file
Truth table0%0/3
A and B
A= defined $fileB= length $file
| |||||||||||||||||||||||||||||
| 982 | or LOGDIE('upload_file_content_single() missing file'); | ||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||
| 984 | 0 | ▶ | -r $file | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 985 | or LOGDIE("upload_file_content_single() received non-existent/unreadable file: $file"); | ||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||
| 987 | 0 | my $size = -s $file; | |||||||||||||||||||||||||||
| 988 | 0 | ▶ | $size <= SIZE_5120GB() | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 989 | or LOGDIE("upload_file_content_single() has a limit of 5120G, '$file' is bigger"); | ||||||||||||||||||||||||||||
| 990 | |||||||||||||||||||||||||||||
| 991 | 0 | my $info = { | |||||||||||||||||||||||||||
| 992 | 'path' => $upload_uri, | ||||||||||||||||||||||||||||
| 993 | 'method_name' => 'upload_file_content_single', | ||||||||||||||||||||||||||||
| 994 | 'http_method' => HTTP_METHOD_PUT(), | ||||||||||||||||||||||||||||
| 995 | 'body_content' => $self->_content_sub($file), | ||||||||||||||||||||||||||||
| 996 | }; | ||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||
| 998 | # Since a file upload can take a long time, refresh the token | ||||||||||||||||||||||||||||
| 999 | # just in case. | ||||||||||||||||||||||||||||
| 1000 | 0 | $self->{'oauth'}->token_expire(); | |||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||
| 1002 | 0 | return $self->_handle_api_method( $info, {} ); | |||||||||||||||||||||||||||
| 1003 | } | ||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||
| 1005 | ########################################### | ||||||||||||||||||||||||||||
| 1006 | sub upload_file_content_multiple { | ||||||||||||||||||||||||||||
| 1007 | ########################################### | ||||||||||||||||||||||||||||
| 1008 | 0 | ▶ | my ( $self, $upload_uri, $file, $chunk_size ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
upload_file_content_multiple: not called CC=14 SCAR=53.5
Pod
documented
| |||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||
| 1010 | 0 | ▶ | defined $upload_uri && length $upload_uri | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $upload_uri and length $upload_uri
MC/DC0%0/2
defined $upload_uri and length $upload_uri
defined $upload_uri
length $upload_uri
Truth table0%0/3
A and B
A= defined $upload_uriB= length $upload_uri
| |||||||||||||||||||||||||||||
| 1011 | or LOGDIE('upload_file_content_multiple() missing upload_uri'); | ||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||
| 1013 | 0 | ▶ | $upload_uri =~ m{^https://.*upload_id=.+}xms | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1014 | or LOGDIE('upload_file_content_multiple() upload_uri seems malformed'); | ||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||
| 1016 | 0 | ▶ | defined $file && length $file | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $file and length $file
MC/DC0%0/2
defined $file and length $file
defined $file
length $file
Truth table0%0/3
A and B
A= defined $fileB= length $file
| |||||||||||||||||||||||||||||
| 1017 | or LOGDIE('upload_file_content_multiple() missing file'); | ||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||
| 1019 | 0 | ▶ | -r $file | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1020 | or LOGDIE("upload_file_content_multiple() received non-existent/unreadable file: $file"); | ||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||
| 1022 | 0 | my $size = -s $file; | |||||||||||||||||||||||||||
| 1023 | 0 | ▶ | $size <= SIZE_5120GB() | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1024 | or LOGDIE("upload_file_content_multiple() has a limit of 5120G, '$file' is bigger"); | ||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||
| 1026 | # By upload in 10 MB chunks | ||||||||||||||||||||||||||||
| 1027 | # But you can provide the amount of bytes instead | ||||||||||||||||||||||||||||
| 1028 | 0 | ▶ | $chunk_size //= DEF_CHUNK_SIZE(); | ||||||||||||||||||||||||||
|
Condition0%0/2
$chunk_size //= 10485760
MC/DC0%0/1
$chunk_size //= 10485760
$chunk_size
Truth table0%0/2
A
A= $chunk_size
| |||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||
| 1030 | 0 | ▶ | $chunk_size > 0 | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1031 | or LOGDIE('upload_file_content_multiple() must have a chunk size above 0'); | ||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||
| 1033 | 0 | ▶ | $chunk_size % SIZE_256K() == 0 | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1034 | or LOGDIE('upload_file_content_multiple() chunk size must divide by 256K'); | ||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||
| 1036 | 0 | my $iter = $self->upload_file_content_iterator( $upload_uri, $file, $chunk_size ); | |||||||||||||||||||||||||||
| 1037 | 0 | ▶ | while ( my $request = $iter->() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1038 | 0 | my $response = $self->_make_request( $request, 1 ); | |||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||
| 1040 | # 200 - means we're done | ||||||||||||||||||||||||||||
| 1041 | # 308 - means continue | ||||||||||||||||||||||||||||
| 1042 | # anything else - we're confused, so it's an error no matter what | ||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||
| 1044 | 0 | ▶ | if ( $response->code() == Net::Google::Drive::Simple::Core::HTTP_CODE_OK() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1045 | 0 | return from_json( $response->decoded_content() ); | |||||||||||||||||||||||||||
| 1046 | } | ||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||
| 1048 | 0 | ▶ | if ( $response->code() != Net::Google::Drive::Simple::Core::HTTP_CODE_RESUME() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1049 | 0 | LOGDIE( "Triggered error: " . $response->code() ); | |||||||||||||||||||||||||||
| 1050 | } | ||||||||||||||||||||||||||||
| 1051 | } | ||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||
| 1053 | 0 | return; | |||||||||||||||||||||||||||
| 1054 | } | ||||||||||||||||||||||||||||
| 1055 | |||||||||||||||||||||||||||||
| 1056 | ########################################### | ||||||||||||||||||||||||||||
| 1057 | sub upload_file_content_iterator { | ||||||||||||||||||||||||||||
| 1058 | ########################################### | ||||||||||||||||||||||||||||
| 1059 | 0 | ▶ | my ( $self, $upload_uri, $file, $chunk_size ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
upload_file_content_iterator: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||
| 1061 | 0 | ▶ | defined $upload_uri && length $upload_uri | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $upload_uri and length $upload_uri
MC/DC0%0/2
defined $upload_uri and length $upload_uri
defined $upload_uri
length $upload_uri
Truth table0%0/3
A and B
A= defined $upload_uriB= length $upload_uri
| |||||||||||||||||||||||||||||
| 1062 | or LOGDIE('upload_file_content_multiple() missing upload_uri'); | ||||||||||||||||||||||||||||
| 1063 | |||||||||||||||||||||||||||||
| 1064 | 0 | ▶ | $upload_uri =~ m{^https://.*upload_id=.+}xms | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1065 | or LOGDIE('upload_file_content_multiple() upload_uri seems malformed'); | ||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||
| 1067 | 0 | ▶ | defined $file && length $file | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $file and length $file
MC/DC0%0/2
defined $file and length $file
defined $file
length $file
Truth table0%0/3
A and B
A= defined $fileB= length $file
| |||||||||||||||||||||||||||||
| 1068 | or LOGDIE('upload_file_content_multiple() missing file'); | ||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||
| 1070 | 0 | ▶ | -r $file | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1071 | or LOGDIE("upload_file_content_multiple() received non-existent/unreadable file: $file"); | ||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||
| 1073 | 0 | my $size = -s $file; | |||||||||||||||||||||||||||
| 1074 | 0 | ▶ | $size <= SIZE_5120GB() | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1075 | or LOGDIE("upload_file_content_multiple() has a limit of 5120G, '$file' is bigger"); | ||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||
| 1077 | # By upload in 10 MB chunks | ||||||||||||||||||||||||||||
| 1078 | # But you can provide the amount of bytes instead | ||||||||||||||||||||||||||||
| 1079 | 0 | ▶ | $chunk_size //= DEF_CHUNK_SIZE(); | ||||||||||||||||||||||||||
|
Condition0%0/2
$chunk_size //= 10485760
MC/DC0%0/1
$chunk_size //= 10485760
$chunk_size
Truth table0%0/2
A
A= $chunk_size
| |||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||
| 1081 | 0 | ▶ | $chunk_size > 0 | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1082 | or LOGDIE('upload_file_content_multiple() must have a chunk size above 0'); | ||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||
| 1084 | 0 | ▶ | $chunk_size % SIZE_256K() == 0 | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1085 | or LOGDIE('upload_file_content_multiple() chunk size must divide by 256K'); | ||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||
| 1087 | # How many chunks are we going to iterate over | ||||||||||||||||||||||||||||
| 1088 | # size in bytes divided by 256K (chunk size) | ||||||||||||||||||||||||||||
| 1089 | 0 | my $chunks = ( $size / $chunk_size ); | |||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||
| 1091 | # One more if there's a tail | ||||||||||||||||||||||||||||
| 1092 | 0 | ▶ | $size % $chunk_size | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1093 | and $chunks++; | ||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||
| 1095 | 0 | my $position = 0; | |||||||||||||||||||||||||||
| 1096 | my $iter = sub { | ||||||||||||||||||||||||||||
| 1097 | 0 | ▶ | $chunks-- == 0 | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1098 | and return; | ||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||
| 1100 | 0 | my $start_position = $position; | |||||||||||||||||||||||||||
| 1101 | |||||||||||||||||||||||||||||
| 1102 | # TODO: Should we take the approach of _content_sub with opening usnig IO::File? | ||||||||||||||||||||||||||||
| 1103 | 0 | ▶ | open my $fh, '<', $file | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1104 | or LOGDIE("File '$file' cannot be open for reading"); | ||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||
| 1106 | 0 | my $content; | |||||||||||||||||||||||||||
| 1107 | 0 | sysseek $fh, $start_position, 0; | |||||||||||||||||||||||||||
| 1108 | 0 | my $bytes_read = sysread $fh, $content, $chunk_size; | |||||||||||||||||||||||||||
| 1109 | 0 | $position += $bytes_read; | |||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||
| 1111 | 0 | ▶ | close $fh | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1112 | or LOGDIE("File '$file' cannot be closed after reading"); | ||||||||||||||||||||||||||||
| 1113 | |||||||||||||||||||||||||||||
| 1114 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1115 | 'path' => $upload_uri, | ||||||||||||||||||||||||||||
| 1116 | 'method_name' => 'upload_file_content_multiple', | ||||||||||||||||||||||||||||
| 1117 | 'http_method' => HTTP_METHOD_PUT(), | ||||||||||||||||||||||||||||
| 1118 | 'return_http_request' => 1, | ||||||||||||||||||||||||||||
| 1119 | 'body_content' => $content, | ||||||||||||||||||||||||||||
| 1120 | 'extra_headers' => [ | ||||||||||||||||||||||||||||
| 1121 | 'Content-Length' => $bytes_read, | ||||||||||||||||||||||||||||
| 1122 | 'Content-Range' => "bytes $start_position-" . ( $position - 1 ) . "/$size" #. ( $position + $bytes_read ), | ||||||||||||||||||||||||||||
| 1123 | ], | ||||||||||||||||||||||||||||
| 1124 | }; | ||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||
| 1126 | # Since a file upload can take a long time, refresh the token | ||||||||||||||||||||||||||||
| 1127 | # just in case. | ||||||||||||||||||||||||||||
| 1128 | 0 | $self->{'oauth'}->token_expire(); | |||||||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||||||||
| 1130 | 0 | my $request = $self->_handle_api_method( $info, {} ); | |||||||||||||||||||||||||||
| 1131 | 0 | return $request; | |||||||||||||||||||||||||||
| 1132 | 0 | }; | |||||||||||||||||||||||||||
| 1133 | |||||||||||||||||||||||||||||
| 1134 | 0 | return $iter; | |||||||||||||||||||||||||||
| 1135 | } | ||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||
| 1137 | ########################################### | ||||||||||||||||||||||||||||
| 1138 | sub upload_file { | ||||||||||||||||||||||||||||
| 1139 | ########################################### | ||||||||||||||||||||||||||||
| 1140 | 0 | ▶ | my ( $self, $file, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
upload_file: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 1141 | 0 | my $upload_uri = $self->create_resumable_upload_for( $file, $options ); | |||||||||||||||||||||||||||
| 1142 | 0 | return $self->upload_file_content_single( $upload_uri, $file ); | |||||||||||||||||||||||||||
| 1143 | } | ||||||||||||||||||||||||||||
| 1144 | |||||||||||||||||||||||||||||
| 1145 | ########################################### | ||||||||||||||||||||||||||||
| 1146 | sub delete_file { | ||||||||||||||||||||||||||||
| 1147 | ########################################### | ||||||||||||||||||||||||||||
| 1148 | 0 | ▶ | my ( $self, $fileId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
delete_file: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||
| 1150 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 1151 | or LOGDIE('delete_file() missing file ID'); | ||||||||||||||||||||||||||||
| 1152 | |||||||||||||||||||||||||||||
| 1153 | 0 | ▶ | $options //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$options //= {}
MC/DC0%0/1
$options //= {}
$options
Truth table0%0/2
A
A= $options
| |||||||||||||||||||||||||||||
| 1154 | |||||||||||||||||||||||||||||
| 1155 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1156 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1157 | 'enforceSingleParent' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1158 | 'supportsTeamDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1159 | 'supportsAllDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1160 | }, | ||||||||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||||||||
| 1162 | 'path' => "files/$fileId", | ||||||||||||||||||||||||||||
| 1163 | 'method_name' => 'delete_file', | ||||||||||||||||||||||||||||
| 1164 | 'http_method' => HTTP_METHOD_DELETE(), | ||||||||||||||||||||||||||||
| 1165 | }; | ||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||
| 1167 | 0 | ▶ | if ( defined $options->{'enforceSingleParent'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1168 | 0 | LOGDIE("[$info->{'method_name'}] If an item is not in a shared drive and its last parent is deleted but the item itself is not, the item will be placed under its owner's root"); | |||||||||||||||||||||||||||
| 1169 | } | ||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||
| 1171 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 1172 | } | ||||||||||||||||||||||||||||
| 1173 | |||||||||||||||||||||||||||||
| 1174 | ########################################### | ||||||||||||||||||||||||||||
| 1175 | sub export_file { | ||||||||||||||||||||||||||||
| 1176 | ########################################### | ||||||||||||||||||||||||||||
| 1177 | 0 | ▶ | my ( $self, $fileId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
export_file: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 1178 | |||||||||||||||||||||||||||||
| 1179 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 1180 | or LOGDIE('export_file() missing file ID'); | ||||||||||||||||||||||||||||
| 1181 | |||||||||||||||||||||||||||||
| 1182 | 0 | ▶ | ref $options eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1183 | or LOGDIE('export_file() missing parameters'); | ||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||
| 1185 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1186 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1187 | 'mimeType' => [ TYPE_STRING(), 1 ], | ||||||||||||||||||||||||||||
| 1188 | 'fields' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1189 | }, | ||||||||||||||||||||||||||||
| 1190 | |||||||||||||||||||||||||||||
| 1191 | 'path' => "files/$fileId/export", | ||||||||||||||||||||||||||||
| 1192 | 'method_name' => 'export_file', | ||||||||||||||||||||||||||||
| 1193 | 'http_method' => HTTP_METHOD_GET(), | ||||||||||||||||||||||||||||
| 1194 | }; | ||||||||||||||||||||||||||||
| 1195 | |||||||||||||||||||||||||||||
| 1196 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 1197 | } | ||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||
| 1199 | ########################################### | ||||||||||||||||||||||||||||
| 1200 | sub generateIds { | ||||||||||||||||||||||||||||
| 1201 | ########################################### | ||||||||||||||||||||||||||||
| 1202 | 0 | ▶ | my ( $self, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
generateIds: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||
| 1204 | 0 | ▶ | $options //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$options //= {}
MC/DC0%0/1
$options //= {}
$options
Truth table0%0/2
A
A= $options
| |||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||
| 1206 | my $info = { | ||||||||||||||||||||||||||||
| 1207 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1208 | 'count' => [ TYPE_INTEGER(), 0 ], | ||||||||||||||||||||||||||||
| 1209 | 'fields' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1210 | 'space' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1211 | 'type' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1212 | }, | ||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||
| 1214 | 'parameter_checks' => { | ||||||||||||||||||||||||||||
| 1215 | 'spaces' => sub { | ||||||||||||||||||||||||||||
| 1216 | 0 | ▶ | /^( files | shortcuts )$/xms | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1217 | or return 'must be: files|shortcuts'; | ||||||||||||||||||||||||||||
| 1218 | |||||||||||||||||||||||||||||
| 1219 | 0 | return 0; | |||||||||||||||||||||||||||
| 1220 | } | ||||||||||||||||||||||||||||
| 1221 | }, | ||||||||||||||||||||||||||||
| 1222 | |||||||||||||||||||||||||||||
| 1223 | 0 | 'path' => 'files/generateIds', | |||||||||||||||||||||||||||
| 1224 | 'method_name' => 'generateIds', | ||||||||||||||||||||||||||||
| 1225 | 'http_method' => HTTP_METHOD_GET(), | ||||||||||||||||||||||||||||
| 1226 | }; | ||||||||||||||||||||||||||||
| 1227 | |||||||||||||||||||||||||||||
| 1228 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 1229 | } | ||||||||||||||||||||||||||||
| 1230 | |||||||||||||||||||||||||||||
| 1231 | ########################################### | ||||||||||||||||||||||||||||
| 1232 | sub get_file { | ||||||||||||||||||||||||||||
| 1233 | ########################################### | ||||||||||||||||||||||||||||
| 1234 | 0 | ▶ | my ( $self, $fileId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_file: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||
| 1236 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 1237 | or LOGDIE('get_file() missing file ID'); | ||||||||||||||||||||||||||||
| 1238 | |||||||||||||||||||||||||||||
| 1239 | 0 | ▶ | $options //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$options //= {}
MC/DC0%0/1
$options //= {}
$options
Truth table0%0/2
A
A= $options
| |||||||||||||||||||||||||||||
| 1240 | |||||||||||||||||||||||||||||
| 1241 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1242 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1243 | 'acknowledgeAbuse' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1244 | 'fields' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1245 | 'includePermissionsForView' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1246 | 'supportsAllDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1247 | 'supportsTeamDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1248 | }, | ||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||
| 1250 | 'path' => "files/$fileId", | ||||||||||||||||||||||||||||
| 1251 | 'method_name' => 'get_file', | ||||||||||||||||||||||||||||
| 1252 | 'http_method' => HTTP_METHOD_GET(), | ||||||||||||||||||||||||||||
| 1253 | }; | ||||||||||||||||||||||||||||
| 1254 | |||||||||||||||||||||||||||||
| 1255 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 1256 | } | ||||||||||||||||||||||||||||
| 1257 | |||||||||||||||||||||||||||||
| 1258 | ########################################### | ||||||||||||||||||||||||||||
| 1259 | sub files { | ||||||||||||||||||||||||||||
| 1260 | ########################################### | ||||||||||||||||||||||||||||
| 1261 | 0 | ▶ | my ( $self, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
files: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 1262 | |||||||||||||||||||||||||||||
| 1263 | 0 | ▶ | $options //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$options //= {}
MC/DC0%0/1
$options //= {}
$options
Truth table0%0/2
A
A= $options
| |||||||||||||||||||||||||||||
| 1264 | |||||||||||||||||||||||||||||
| 1265 | # TODO: orderBy | ||||||||||||||||||||||||||||
| 1266 | # 'createdTime', 'folder', 'modifiedByMeTime', 'modifiedTime', 'name', 'name_natural', 'quotaBytesUsed', 'recency', 'sharedWithMeTime', 'starred', and 'viewedByMeTime'. | ||||||||||||||||||||||||||||
| 1267 | # ?orderBy=folder,modifiedTime desc,name | ||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||
| 1269 | # TODO: Steal the struct to query syntax from MetaCPAN::Client | ||||||||||||||||||||||||||||
| 1270 | # https://developers.google.com/drive/api/guides/search-files | ||||||||||||||||||||||||||||
| 1271 | #if ( my $query_str = $options->{'q'} ) {...} | ||||||||||||||||||||||||||||
| 1272 | |||||||||||||||||||||||||||||
| 1273 | my $info = { | ||||||||||||||||||||||||||||
| 1274 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1275 | 'corpora' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1276 | 'corpus' => [ TYPE_STRING(), 0 ], # deprecated | ||||||||||||||||||||||||||||
| 1277 | 'driveId' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1278 | 'fields' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1279 | 'includeItemsFromAllDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1280 | 'includePermissionsForView' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1281 | 'includeTeamDriveItems' => [ TYPE_BOOLEAN(), 0 ], # deprecated | ||||||||||||||||||||||||||||
| 1282 | 'orderBy' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1283 | 'pageSize' => [ TYPE_INTEGER(), 0 ], | ||||||||||||||||||||||||||||
| 1284 | 'pageToken' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1285 | 'q' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1286 | 'spaces' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1287 | 'supportsAllDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1288 | 'supportsTeamDrives' => [ TYPE_BOOLEAN(), 0 ], # deprecated | ||||||||||||||||||||||||||||
| 1289 | 'teamDriveId' => [ TYPE_STRING(), 0 ], # deprecated | ||||||||||||||||||||||||||||
| 1290 | 'trashed' => [ TYPE_BOOLEAN(), 0 ], # not documented | ||||||||||||||||||||||||||||
| 1291 | }, | ||||||||||||||||||||||||||||
| 1292 | |||||||||||||||||||||||||||||
| 1293 | 'parameter_checks' => { | ||||||||||||||||||||||||||||
| 1294 | 'corpora' => sub { | ||||||||||||||||||||||||||||
| 1295 | 0 | ▶ | /^( user | drive | domain | allDrives )$/xms | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1296 | or return 'must be: user|drive|domain|allDrives'; | ||||||||||||||||||||||||||||
| 1297 | |||||||||||||||||||||||||||||
| 1298 | 0 | ▶ | if ( $_ eq 'drive' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1299 | 0 | ▶ | defined $options->{'driveId'} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1300 | or return 'if corpora is drive, parameter driveId must be set'; | ||||||||||||||||||||||||||||
| 1301 | } | ||||||||||||||||||||||||||||
| 1302 | |||||||||||||||||||||||||||||
| 1303 | 0 | return 0; | |||||||||||||||||||||||||||
| 1304 | }, | ||||||||||||||||||||||||||||
| 1305 | |||||||||||||||||||||||||||||
| 1306 | 'corpus' => sub { | ||||||||||||||||||||||||||||
| 1307 | 0 | ▶ | /^( domain | user )$/xms | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1308 | or return 'must be: domain|user'; | ||||||||||||||||||||||||||||
| 1309 | |||||||||||||||||||||||||||||
| 1310 | 0 | return 0; | |||||||||||||||||||||||||||
| 1311 | }, | ||||||||||||||||||||||||||||
| 1312 | |||||||||||||||||||||||||||||
| 1313 | 'spaces' => sub { | ||||||||||||||||||||||||||||
| 1314 | 0 | ▶ | /^( drive | appDataFolder )$/xms | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1315 | or return 'must be: drive|appDataFolder'; | ||||||||||||||||||||||||||||
| 1316 | |||||||||||||||||||||||||||||
| 1317 | 0 | return 0; | |||||||||||||||||||||||||||
| 1318 | }, | ||||||||||||||||||||||||||||
| 1319 | }, | ||||||||||||||||||||||||||||
| 1320 | |||||||||||||||||||||||||||||
| 1321 | 0 | 'path' => 'files', | |||||||||||||||||||||||||||
| 1322 | 'method_name' => 'files', | ||||||||||||||||||||||||||||
| 1323 | 'http_method' => HTTP_METHOD_GET(), | ||||||||||||||||||||||||||||
| 1324 | }; | ||||||||||||||||||||||||||||
| 1325 | |||||||||||||||||||||||||||||
| 1326 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 1327 | } | ||||||||||||||||||||||||||||
| 1328 | |||||||||||||||||||||||||||||
| 1329 | # Update with upload | ||||||||||||||||||||||||||||
| 1330 | ########################################### | ||||||||||||||||||||||||||||
| 1331 | sub update_file { | ||||||||||||||||||||||||||||
| 1332 | ########################################### | ||||||||||||||||||||||||||||
| 1333 | 0 | ▶ | my ( $self, $fileId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
update_file: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 1334 | |||||||||||||||||||||||||||||
| 1335 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 1336 | or LOGDIE('update_file() missing file ID'); | ||||||||||||||||||||||||||||
| 1337 | |||||||||||||||||||||||||||||
| 1338 | 0 | ▶ | ref $options eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1339 | or LOGDIE('update_file() missing parameters'); | ||||||||||||||||||||||||||||
| 1340 | |||||||||||||||||||||||||||||
| 1341 | my $info = { | ||||||||||||||||||||||||||||
| 1342 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1343 | 'uploadType' => [ TYPE_STRING(), 1 ], | ||||||||||||||||||||||||||||
| 1344 | 'addParents' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1345 | 'enforceSingleParent' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1346 | 'includePermissionsForView' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1347 | 'keepRevisionForever' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1348 | 'ocrLanguage' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1349 | 'removeParents' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1350 | 'supportsAllDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1351 | 'supportsTeamDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1352 | 'useContentAsIndexableText' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1353 | }, | ||||||||||||||||||||||||||||
| 1354 | |||||||||||||||||||||||||||||
| 1355 | 'body_parameters' => [ | ||||||||||||||||||||||||||||
| 1356 | qw< | ||||||||||||||||||||||||||||
| 1357 | appProperties | ||||||||||||||||||||||||||||
| 1358 | contentHints | ||||||||||||||||||||||||||||
| 1359 | contentRestrictions | ||||||||||||||||||||||||||||
| 1360 | copyRequiresWriterPermission | ||||||||||||||||||||||||||||
| 1361 | description | ||||||||||||||||||||||||||||
| 1362 | folderColorRgb | ||||||||||||||||||||||||||||
| 1363 | mimeType | ||||||||||||||||||||||||||||
| 1364 | modifiedTime | ||||||||||||||||||||||||||||
| 1365 | name | ||||||||||||||||||||||||||||
| 1366 | originalFilename | ||||||||||||||||||||||||||||
| 1367 | properties | ||||||||||||||||||||||||||||
| 1368 | starred | ||||||||||||||||||||||||||||
| 1369 | trashed | ||||||||||||||||||||||||||||
| 1370 | viewedByMeTime | ||||||||||||||||||||||||||||
| 1371 | writersCanShare | ||||||||||||||||||||||||||||
| 1372 | > | ||||||||||||||||||||||||||||
| 1373 | ], | ||||||||||||||||||||||||||||
| 1374 | |||||||||||||||||||||||||||||
| 1375 | 0 | 'path' => $self->{'api_upload_file'} . "/$fileId", | |||||||||||||||||||||||||||
| 1376 | 'method_name' => 'update_file', | ||||||||||||||||||||||||||||
| 1377 | 'http_method' => HTTP_METHOD_PATCH(), | ||||||||||||||||||||||||||||
| 1378 | }; | ||||||||||||||||||||||||||||
| 1379 | |||||||||||||||||||||||||||||
| 1380 | 0 | ▶ | if ( defined $options->{'enforceSingleParent'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1381 | 0 | LOGDIE("[$info->{'method_name'}] Adding files to multiple folders is no longer supported. Use shortcuts instead"); | |||||||||||||||||||||||||||
| 1382 | } | ||||||||||||||||||||||||||||
| 1383 | |||||||||||||||||||||||||||||
| 1384 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 1385 | } | ||||||||||||||||||||||||||||
| 1386 | |||||||||||||||||||||||||||||
| 1387 | # Metadata | ||||||||||||||||||||||||||||
| 1388 | ########################################### | ||||||||||||||||||||||||||||
| 1389 | sub update_file_metadata { | ||||||||||||||||||||||||||||
| 1390 | ########################################### | ||||||||||||||||||||||||||||
| 1391 | 0 | ▶ | my ( $self, $fileId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
update_file_metadata: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 1392 | |||||||||||||||||||||||||||||
| 1393 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 1394 | or LOGDIE('update_file_metadata() missing file ID'); | ||||||||||||||||||||||||||||
| 1395 | |||||||||||||||||||||||||||||
| 1396 | 0 | ▶ | ref $options eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1397 | or LOGDIE('update_file_metadata() missing parameters'); | ||||||||||||||||||||||||||||
| 1398 | |||||||||||||||||||||||||||||
| 1399 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1400 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1401 | 'addParents' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1402 | 'enforceSingleParent' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1403 | 'includePermissionsForView' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1404 | 'keepRevisionForever' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1405 | 'ocrLanguage' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1406 | 'removeParents' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1407 | 'supportsAllDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1408 | 'supportsTeamDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1409 | 'useContentAsIndexableText' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1410 | }, | ||||||||||||||||||||||||||||
| 1411 | |||||||||||||||||||||||||||||
| 1412 | 'body_parameters' => [ | ||||||||||||||||||||||||||||
| 1413 | qw< | ||||||||||||||||||||||||||||
| 1414 | appProperties | ||||||||||||||||||||||||||||
| 1415 | contentHints | ||||||||||||||||||||||||||||
| 1416 | contentRestrictions | ||||||||||||||||||||||||||||
| 1417 | copyRequiresWriterPermission | ||||||||||||||||||||||||||||
| 1418 | description | ||||||||||||||||||||||||||||
| 1419 | folderColorRgb | ||||||||||||||||||||||||||||
| 1420 | mimeType | ||||||||||||||||||||||||||||
| 1421 | modifiedTime | ||||||||||||||||||||||||||||
| 1422 | name | ||||||||||||||||||||||||||||
| 1423 | originalFilename | ||||||||||||||||||||||||||||
| 1424 | properties | ||||||||||||||||||||||||||||
| 1425 | starred | ||||||||||||||||||||||||||||
| 1426 | trashed | ||||||||||||||||||||||||||||
| 1427 | viewedByMeTime | ||||||||||||||||||||||||||||
| 1428 | writersCanShare | ||||||||||||||||||||||||||||
| 1429 | > | ||||||||||||||||||||||||||||
| 1430 | ], | ||||||||||||||||||||||||||||
| 1431 | |||||||||||||||||||||||||||||
| 1432 | 'path' => "files/$fileId", | ||||||||||||||||||||||||||||
| 1433 | 'method_name' => 'update_file_metadata', | ||||||||||||||||||||||||||||
| 1434 | 'http_method' => HTTP_METHOD_PATCH(), | ||||||||||||||||||||||||||||
| 1435 | }; | ||||||||||||||||||||||||||||
| 1436 | |||||||||||||||||||||||||||||
| 1437 | 0 | ▶ | if ( defined $options->{'enforceSingleParent'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1438 | 0 | LOGDIE("[$info->{'method_name'}] Adding files to multiple folders is no longer supported. Use shortcuts instead"); | |||||||||||||||||||||||||||
| 1439 | } | ||||||||||||||||||||||||||||
| 1440 | |||||||||||||||||||||||||||||
| 1441 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 1442 | } | ||||||||||||||||||||||||||||
| 1443 | |||||||||||||||||||||||||||||
| 1444 | ########################################### | ||||||||||||||||||||||||||||
| 1445 | sub watch_file { | ||||||||||||||||||||||||||||
| 1446 | ########################################### | ||||||||||||||||||||||||||||
| 1447 | 0 | ▶ | my ( $self, $fileId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
watch_file: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 1448 | |||||||||||||||||||||||||||||
| 1449 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 1450 | or LOGDIE('watch_file() missing file ID'); | ||||||||||||||||||||||||||||
| 1451 | |||||||||||||||||||||||||||||
| 1452 | 0 | ▶ | ref $options eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1453 | or LOGDIE('watch_file() missing parameters'); | ||||||||||||||||||||||||||||
| 1454 | |||||||||||||||||||||||||||||
| 1455 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1456 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1457 | 'acknowledgeAbuse' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1458 | 'fields' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1459 | 'supportsAllDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1460 | 'supportsTeamDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1461 | }, | ||||||||||||||||||||||||||||
| 1462 | |||||||||||||||||||||||||||||
| 1463 | 'body_parameters' => [ | ||||||||||||||||||||||||||||
| 1464 | qw< | ||||||||||||||||||||||||||||
| 1465 | kind | ||||||||||||||||||||||||||||
| 1466 | id | ||||||||||||||||||||||||||||
| 1467 | resourceId | ||||||||||||||||||||||||||||
| 1468 | resourceUri | ||||||||||||||||||||||||||||
| 1469 | token | ||||||||||||||||||||||||||||
| 1470 | expiration | ||||||||||||||||||||||||||||
| 1471 | type | ||||||||||||||||||||||||||||
| 1472 | address | ||||||||||||||||||||||||||||
| 1473 | payload | ||||||||||||||||||||||||||||
| 1474 | params | ||||||||||||||||||||||||||||
| 1475 | > | ||||||||||||||||||||||||||||
| 1476 | ], | ||||||||||||||||||||||||||||
| 1477 | |||||||||||||||||||||||||||||
| 1478 | 'path' => "files/$fileId/watch", | ||||||||||||||||||||||||||||
| 1479 | 'method_name' => 'watch_file', | ||||||||||||||||||||||||||||
| 1480 | 'http_method' => HTTP_METHOD_POST(), | ||||||||||||||||||||||||||||
| 1481 | }; | ||||||||||||||||||||||||||||
| 1482 | |||||||||||||||||||||||||||||
| 1483 | 0 | $options->{'kind'} = 'api#channel'; | |||||||||||||||||||||||||||
| 1484 | |||||||||||||||||||||||||||||
| 1485 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 1486 | } | ||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||
| 1488 | ########################################### | ||||||||||||||||||||||||||||
| 1489 | sub empty_trash { | ||||||||||||||||||||||||||||
| 1490 | ########################################### | ||||||||||||||||||||||||||||
| 1491 | 0 | ▶ | my ( $self, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
empty_trash: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 1492 | |||||||||||||||||||||||||||||
| 1493 | 0 | ▶ | $options //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$options //= {}
MC/DC0%0/1
$options //= {}
$options
Truth table0%0/2
A
A= $options
| |||||||||||||||||||||||||||||
| 1494 | |||||||||||||||||||||||||||||
| 1495 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1496 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1497 | 'enforceSingleParent' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1498 | }, | ||||||||||||||||||||||||||||
| 1499 | |||||||||||||||||||||||||||||
| 1500 | 'path' => 'files/trash', | ||||||||||||||||||||||||||||
| 1501 | 'method' => 'empty_trash', | ||||||||||||||||||||||||||||
| 1502 | 'http_method' => HTTP_METHOD_DELETE(), | ||||||||||||||||||||||||||||
| 1503 | }; | ||||||||||||||||||||||||||||
| 1504 | |||||||||||||||||||||||||||||
| 1505 | 0 | ▶ | if ( defined $options->{'enforceSingleParent'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1506 | 0 | LOGDIE("[$info->{'method_name'}] If an item is not in a shared drive and its last parent is deleted but the item itself is not, the item will be placed under its owner's root"); | |||||||||||||||||||||||||||
| 1507 | } | ||||||||||||||||||||||||||||
| 1508 | |||||||||||||||||||||||||||||
| 1509 | 0 | return $self->_handle_api_method( $info, {} ); | |||||||||||||||||||||||||||
| 1510 | } | ||||||||||||||||||||||||||||
| 1511 | |||||||||||||||||||||||||||||
| 1512 | # --- permissions | ||||||||||||||||||||||||||||
| 1513 | |||||||||||||||||||||||||||||
| 1514 | ########################################### | ||||||||||||||||||||||||||||
| 1515 | sub create_permission { | ||||||||||||||||||||||||||||
| 1516 | ########################################### | ||||||||||||||||||||||||||||
| 1517 | 0 | ▶ | my ( $self, $fileId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
create_permission: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 1518 | |||||||||||||||||||||||||||||
| 1519 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 1520 | or LOGDIE('create_permission() missing file ID'); | ||||||||||||||||||||||||||||
| 1521 | |||||||||||||||||||||||||||||
| 1522 | 0 | ▶ | ref $options eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1523 | or LOGDIE('create_permission() missing parameters'); | ||||||||||||||||||||||||||||
| 1524 | |||||||||||||||||||||||||||||
| 1525 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1526 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1527 | 'emailMessage' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1528 | 'enforceSingleParent' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1529 | 'fields' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1530 | 'moveToNewOwnersRoot' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1531 | 'sendNotificationEmail' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1532 | 'supportsAllDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1533 | 'supportsTeamDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1534 | 'transferOwnership' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1535 | 'useDomainAdminAccess' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1536 | }, | ||||||||||||||||||||||||||||
| 1537 | |||||||||||||||||||||||||||||
| 1538 | 'body_parameters' => [ | ||||||||||||||||||||||||||||
| 1539 | qw< | ||||||||||||||||||||||||||||
| 1540 | role | ||||||||||||||||||||||||||||
| 1541 | type | ||||||||||||||||||||||||||||
| 1542 | allowFileDiscovery | ||||||||||||||||||||||||||||
| 1543 | domain | ||||||||||||||||||||||||||||
| 1544 | emailAddress | ||||||||||||||||||||||||||||
| 1545 | pendingOwner | ||||||||||||||||||||||||||||
| 1546 | view | ||||||||||||||||||||||||||||
| 1547 | > | ||||||||||||||||||||||||||||
| 1548 | ], | ||||||||||||||||||||||||||||
| 1549 | |||||||||||||||||||||||||||||
| 1550 | 'deprecated_param_names' => { | ||||||||||||||||||||||||||||
| 1551 | 'enforceSingleParent' => 'moveToNewOwnersRoot', | ||||||||||||||||||||||||||||
| 1552 | }, | ||||||||||||||||||||||||||||
| 1553 | |||||||||||||||||||||||||||||
| 1554 | 'path' => "files/$fileId/permissions", | ||||||||||||||||||||||||||||
| 1555 | 'method_name' => 'create_permission', | ||||||||||||||||||||||||||||
| 1556 | 'http_method' => HTTP_METHOD_POST(), | ||||||||||||||||||||||||||||
| 1557 | }; | ||||||||||||||||||||||||||||
| 1558 | |||||||||||||||||||||||||||||
| 1559 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 1560 | } | ||||||||||||||||||||||||||||
| 1561 | |||||||||||||||||||||||||||||
| 1562 | ########################################### | ||||||||||||||||||||||||||||
| 1563 | sub delete_permission { | ||||||||||||||||||||||||||||
| 1564 | ########################################### | ||||||||||||||||||||||||||||
| 1565 | 0 | ▶ | my ( $self, $fileId, $permissionId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
delete_permission: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 1566 | |||||||||||||||||||||||||||||
| 1567 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 1568 | or LOGDIE('delete_permission() missing file ID'); | ||||||||||||||||||||||||||||
| 1569 | |||||||||||||||||||||||||||||
| 1570 | 0 | ▶ | defined $permissionId && length $permissionId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $permissionId and length $permissionId
MC/DC0%0/2
defined $permissionId and length $permissionId
defined $permissionId
length $permissionId
Truth table0%0/3
A and B
A= defined $permissionIdB= length $permissionId
| |||||||||||||||||||||||||||||
| 1571 | or LOGDIE('delete_permission() missing permission ID'); | ||||||||||||||||||||||||||||
| 1572 | |||||||||||||||||||||||||||||
| 1573 | 0 | ▶ | $options //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$options //= {}
MC/DC0%0/1
$options //= {}
$options
Truth table0%0/2
A
A= $options
| |||||||||||||||||||||||||||||
| 1574 | |||||||||||||||||||||||||||||
| 1575 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1576 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1577 | 'supportsAllDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1578 | 'supportsTeamDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1579 | 'useDomainAdminAccess' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1580 | }, | ||||||||||||||||||||||||||||
| 1581 | |||||||||||||||||||||||||||||
| 1582 | 'path' => "files/$fileId/permissions/$permissionId", | ||||||||||||||||||||||||||||
| 1583 | 'method_name' => 'delete_permission', | ||||||||||||||||||||||||||||
| 1584 | 'http_method' => HTTP_METHOD_DELETE(), | ||||||||||||||||||||||||||||
| 1585 | }; | ||||||||||||||||||||||||||||
| 1586 | |||||||||||||||||||||||||||||
| 1587 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 1588 | } | ||||||||||||||||||||||||||||
| 1589 | |||||||||||||||||||||||||||||
| 1590 | ########################################### | ||||||||||||||||||||||||||||
| 1591 | sub get_permission { | ||||||||||||||||||||||||||||
| 1592 | ########################################### | ||||||||||||||||||||||||||||
| 1593 | 0 | ▶ | my ( $self, $fileId, $permissionId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_permission: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 1594 | |||||||||||||||||||||||||||||
| 1595 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 1596 | or LOGDIE('get_permission() missing file ID'); | ||||||||||||||||||||||||||||
| 1597 | |||||||||||||||||||||||||||||
| 1598 | 0 | ▶ | defined $permissionId && length $permissionId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $permissionId and length $permissionId
MC/DC0%0/2
defined $permissionId and length $permissionId
defined $permissionId
length $permissionId
Truth table0%0/3
A and B
A= defined $permissionIdB= length $permissionId
| |||||||||||||||||||||||||||||
| 1599 | or LOGDIE('get_permission() missing permission ID'); | ||||||||||||||||||||||||||||
| 1600 | |||||||||||||||||||||||||||||
| 1601 | 0 | ▶ | $options //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$options //= {}
MC/DC0%0/1
$options //= {}
$options
Truth table0%0/2
A
A= $options
| |||||||||||||||||||||||||||||
| 1602 | |||||||||||||||||||||||||||||
| 1603 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1604 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1605 | 'fields' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1606 | 'supportsAllDrivee' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1607 | 'supportsTeamDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1608 | 'useDomainAdminAccess' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1609 | }, | ||||||||||||||||||||||||||||
| 1610 | |||||||||||||||||||||||||||||
| 1611 | 'path' => "files/$fileId/permissions/$permissionId", | ||||||||||||||||||||||||||||
| 1612 | 'method_name' => 'get_permission', | ||||||||||||||||||||||||||||
| 1613 | 'http_method' => HTTP_METHOD_GET(), | ||||||||||||||||||||||||||||
| 1614 | }; | ||||||||||||||||||||||||||||
| 1615 | |||||||||||||||||||||||||||||
| 1616 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 1617 | } | ||||||||||||||||||||||||||||
| 1618 | |||||||||||||||||||||||||||||
| 1619 | ########################################### | ||||||||||||||||||||||||||||
| 1620 | sub permissions { | ||||||||||||||||||||||||||||
| 1621 | ########################################### | ||||||||||||||||||||||||||||
| 1622 | 0 | ▶ | my ( $self, $fileId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
permissions: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 1623 | |||||||||||||||||||||||||||||
| 1624 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 1625 | or LOGDIE('permissions() missing file ID'); | ||||||||||||||||||||||||||||
| 1626 | |||||||||||||||||||||||||||||
| 1627 | 0 | ▶ | $options //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$options //= {}
MC/DC0%0/1
$options //= {}
$options
Truth table0%0/2
A
A= $options
| |||||||||||||||||||||||||||||
| 1628 | |||||||||||||||||||||||||||||
| 1629 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1630 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1631 | 'fields' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1632 | 'includePermissionsForView' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1633 | 'pageSize' => [ TYPE_INTEGER(), 0 ], | ||||||||||||||||||||||||||||
| 1634 | 'pageToken' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1635 | 'supportsAllDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1636 | 'supportsTeamDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1637 | 'useDomainAdminAccess' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1638 | }, | ||||||||||||||||||||||||||||
| 1639 | |||||||||||||||||||||||||||||
| 1640 | 'path' => "files/$fileId/permissions", | ||||||||||||||||||||||||||||
| 1641 | 'method_name' => 'permissions', | ||||||||||||||||||||||||||||
| 1642 | 'http_method' => HTTP_METHOD_GET(), | ||||||||||||||||||||||||||||
| 1643 | }; | ||||||||||||||||||||||||||||
| 1644 | |||||||||||||||||||||||||||||
| 1645 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 1646 | } | ||||||||||||||||||||||||||||
| 1647 | |||||||||||||||||||||||||||||
| 1648 | ########################################### | ||||||||||||||||||||||||||||
| 1649 | sub update_permission { | ||||||||||||||||||||||||||||
| 1650 | ########################################### | ||||||||||||||||||||||||||||
| 1651 | 0 | ▶ | my ( $self, $fileId, $permissionId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
update_permission: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 1652 | |||||||||||||||||||||||||||||
| 1653 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 1654 | or LOGDIE('update_permission() missing file ID'); | ||||||||||||||||||||||||||||
| 1655 | |||||||||||||||||||||||||||||
| 1656 | 0 | ▶ | defined $permissionId && length $permissionId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $permissionId and length $permissionId
MC/DC0%0/2
defined $permissionId and length $permissionId
defined $permissionId
length $permissionId
Truth table0%0/3
A and B
A= defined $permissionIdB= length $permissionId
| |||||||||||||||||||||||||||||
| 1657 | or LOGDIE('update_permission() missing permission ID'); | ||||||||||||||||||||||||||||
| 1658 | |||||||||||||||||||||||||||||
| 1659 | 0 | ▶ | $options //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$options //= {}
MC/DC0%0/1
$options //= {}
$options
Truth table0%0/2
A
A= $options
| |||||||||||||||||||||||||||||
| 1660 | |||||||||||||||||||||||||||||
| 1661 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1662 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1663 | 'fields' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1664 | 'removeExpiration' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1665 | 'supportsAllDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1666 | 'supportsTeamDrives' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1667 | 'transferOwnership' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1668 | 'useDomainAdminAccess' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1669 | }, | ||||||||||||||||||||||||||||
| 1670 | |||||||||||||||||||||||||||||
| 1671 | 'path' => "files/$fileId/permissions/$permissionId", | ||||||||||||||||||||||||||||
| 1672 | 'method_name' => 'update_permission', | ||||||||||||||||||||||||||||
| 1673 | 'http_method' => HTTP_METHOD_PATCH(), | ||||||||||||||||||||||||||||
| 1674 | }; | ||||||||||||||||||||||||||||
| 1675 | |||||||||||||||||||||||||||||
| 1676 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 1677 | } | ||||||||||||||||||||||||||||
| 1678 | |||||||||||||||||||||||||||||
| 1679 | # --- replies | ||||||||||||||||||||||||||||
| 1680 | |||||||||||||||||||||||||||||
| 1681 | ########################################### | ||||||||||||||||||||||||||||
| 1682 | sub create_reply { | ||||||||||||||||||||||||||||
| 1683 | ########################################### | ||||||||||||||||||||||||||||
| 1684 | 0 | ▶ | my ( $self, $fileId, $commentId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
create_reply: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 1685 | |||||||||||||||||||||||||||||
| 1686 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 1687 | or LOGDIE('create_reply() missing file ID'); | ||||||||||||||||||||||||||||
| 1688 | |||||||||||||||||||||||||||||
| 1689 | 0 | ▶ | defined $commentId && length $commentId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $commentId and length $commentId
MC/DC0%0/2
defined $commentId and length $commentId
defined $commentId
length $commentId
Truth table0%0/3
A and B
A= defined $commentIdB= length $commentId
| |||||||||||||||||||||||||||||
| 1690 | or LOGDIE('create_reply() missing comment ID'); | ||||||||||||||||||||||||||||
| 1691 | |||||||||||||||||||||||||||||
| 1692 | 0 | ▶ | ref $options eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1693 | or LOGDIE('create_reply() missing parameters'); | ||||||||||||||||||||||||||||
| 1694 | |||||||||||||||||||||||||||||
| 1695 | my $info = { | ||||||||||||||||||||||||||||
| 1696 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1697 | 'fields' => [ TYPE_STRING(), 1 ], | ||||||||||||||||||||||||||||
| 1698 | }, | ||||||||||||||||||||||||||||
| 1699 | |||||||||||||||||||||||||||||
| 1700 | 'body_parameters' => [ | ||||||||||||||||||||||||||||
| 1701 | qw< | ||||||||||||||||||||||||||||
| 1702 | action | ||||||||||||||||||||||||||||
| 1703 | content | ||||||||||||||||||||||||||||
| 1704 | > | ||||||||||||||||||||||||||||
| 1705 | ], | ||||||||||||||||||||||||||||
| 1706 | |||||||||||||||||||||||||||||
| 1707 | 'parameter_checks' => { | ||||||||||||||||||||||||||||
| 1708 | 'action' => sub { | ||||||||||||||||||||||||||||
| 1709 | 0 | ▶ | m{^( resolve | reopen )$}xms | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1710 | or return 'must be: resolve|reopen'; | ||||||||||||||||||||||||||||
| 1711 | |||||||||||||||||||||||||||||
| 1712 | 0 | return 0; | |||||||||||||||||||||||||||
| 1713 | }, | ||||||||||||||||||||||||||||
| 1714 | }, | ||||||||||||||||||||||||||||
| 1715 | |||||||||||||||||||||||||||||
| 1716 | 0 | 'path' => "files/$fileId/comments/$commentId/replies", | |||||||||||||||||||||||||||
| 1717 | 'method_name' => 'create_reply', | ||||||||||||||||||||||||||||
| 1718 | 'http_method' => HTTP_METHOD_POST(), | ||||||||||||||||||||||||||||
| 1719 | }; | ||||||||||||||||||||||||||||
| 1720 | |||||||||||||||||||||||||||||
| 1721 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 1722 | } | ||||||||||||||||||||||||||||
| 1723 | |||||||||||||||||||||||||||||
| 1724 | ########################################### | ||||||||||||||||||||||||||||
| 1725 | sub delete_reply { | ||||||||||||||||||||||||||||
| 1726 | ########################################### | ||||||||||||||||||||||||||||
| 1727 | 0 | ▶ | my ( $self, $fileId, $commentId, $replyId ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
delete_reply: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 1728 | |||||||||||||||||||||||||||||
| 1729 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 1730 | or LOGDIE('delete_reply() missing file ID'); | ||||||||||||||||||||||||||||
| 1731 | |||||||||||||||||||||||||||||
| 1732 | 0 | ▶ | defined $commentId && length $commentId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $commentId and length $commentId
MC/DC0%0/2
defined $commentId and length $commentId
defined $commentId
length $commentId
Truth table0%0/3
A and B
A= defined $commentIdB= length $commentId
| |||||||||||||||||||||||||||||
| 1733 | or LOGDIE('delete_reply() missing comment ID'); | ||||||||||||||||||||||||||||
| 1734 | |||||||||||||||||||||||||||||
| 1735 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1736 | 'path' => "files/$fileId/comments/$commentId/replies/$replyId", | ||||||||||||||||||||||||||||
| 1737 | 'method_name' => 'delete_reply', | ||||||||||||||||||||||||||||
| 1738 | 'http_method' => HTTP_METHOD_DELETE(), | ||||||||||||||||||||||||||||
| 1739 | }; | ||||||||||||||||||||||||||||
| 1740 | |||||||||||||||||||||||||||||
| 1741 | 0 | return $self->_handle_api_method( $info, {} ); | |||||||||||||||||||||||||||
| 1742 | } | ||||||||||||||||||||||||||||
| 1743 | |||||||||||||||||||||||||||||
| 1744 | ########################################### | ||||||||||||||||||||||||||||
| 1745 | sub get_reply { | ||||||||||||||||||||||||||||
| 1746 | ########################################### | ||||||||||||||||||||||||||||
| 1747 | 0 | ▶ | my ( $self, $fileId, $commentId, $replyId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_reply: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||
| 1748 | |||||||||||||||||||||||||||||
| 1749 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 1750 | or LOGDIE('get_reply() missing file ID'); | ||||||||||||||||||||||||||||
| 1751 | |||||||||||||||||||||||||||||
| 1752 | 0 | ▶ | defined $commentId && length $commentId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $commentId and length $commentId
MC/DC0%0/2
defined $commentId and length $commentId
defined $commentId
length $commentId
Truth table0%0/3
A and B
A= defined $commentIdB= length $commentId
| |||||||||||||||||||||||||||||
| 1753 | or LOGDIE('get_reply() missing comment ID'); | ||||||||||||||||||||||||||||
| 1754 | |||||||||||||||||||||||||||||
| 1755 | 0 | ▶ | defined $replyId && length $replyId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $replyId and length $replyId
MC/DC0%0/2
defined $replyId and length $replyId
defined $replyId
length $replyId
Truth table0%0/3
A and B
A= defined $replyIdB= length $replyId
| |||||||||||||||||||||||||||||
| 1756 | or LOGDIE('get_reply() missing reply ID'); | ||||||||||||||||||||||||||||
| 1757 | |||||||||||||||||||||||||||||
| 1758 | 0 | ▶ | ref $options eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1759 | or LOGDIE('get_reply() missing parameters'); | ||||||||||||||||||||||||||||
| 1760 | |||||||||||||||||||||||||||||
| 1761 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1762 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1763 | 'fields' => [ TYPE_STRING(), 1 ], | ||||||||||||||||||||||||||||
| 1764 | 'includeDeleted' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1765 | }, | ||||||||||||||||||||||||||||
| 1766 | |||||||||||||||||||||||||||||
| 1767 | 'path' => "files/$fileId/comments/$commentId/replies/$replyId", | ||||||||||||||||||||||||||||
| 1768 | 'method_name' => 'get_reply', | ||||||||||||||||||||||||||||
| 1769 | 'http_method' => HTTP_METHOD_GET(), | ||||||||||||||||||||||||||||
| 1770 | }; | ||||||||||||||||||||||||||||
| 1771 | |||||||||||||||||||||||||||||
| 1772 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 1773 | } | ||||||||||||||||||||||||||||
| 1774 | |||||||||||||||||||||||||||||
| 1775 | ########################################### | ||||||||||||||||||||||||||||
| 1776 | sub replies { | ||||||||||||||||||||||||||||
| 1777 | ########################################### | ||||||||||||||||||||||||||||
| 1778 | 0 | ▶ | my ( $self, $fileId, $commentId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
replies: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 1779 | |||||||||||||||||||||||||||||
| 1780 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 1781 | or LOGDIE('replies() missing file ID'); | ||||||||||||||||||||||||||||
| 1782 | |||||||||||||||||||||||||||||
| 1783 | 0 | ▶ | defined $commentId && length $commentId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $commentId and length $commentId
MC/DC0%0/2
defined $commentId and length $commentId
defined $commentId
length $commentId
Truth table0%0/3
A and B
A= defined $commentIdB= length $commentId
| |||||||||||||||||||||||||||||
| 1784 | or LOGDIE('replies() missing comment ID'); | ||||||||||||||||||||||||||||
| 1785 | |||||||||||||||||||||||||||||
| 1786 | 0 | ▶ | ref $options eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1787 | or LOGDIE('replies() missing parameters'); | ||||||||||||||||||||||||||||
| 1788 | |||||||||||||||||||||||||||||
| 1789 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1790 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1791 | 'fields' => [ TYPE_STRING(), 1 ], | ||||||||||||||||||||||||||||
| 1792 | 'includeDeleted' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1793 | 'pageSize' => [ TYPE_INTEGER(), 0 ], | ||||||||||||||||||||||||||||
| 1794 | 'pageToken' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1795 | }, | ||||||||||||||||||||||||||||
| 1796 | |||||||||||||||||||||||||||||
| 1797 | 'path' => "files/$fileId/comments/$commentId/replies", | ||||||||||||||||||||||||||||
| 1798 | 'method_name' => 'replies', | ||||||||||||||||||||||||||||
| 1799 | 'http_method' => HTTP_METHOD_GET(), | ||||||||||||||||||||||||||||
| 1800 | }; | ||||||||||||||||||||||||||||
| 1801 | |||||||||||||||||||||||||||||
| 1802 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 1803 | } | ||||||||||||||||||||||||||||
| 1804 | |||||||||||||||||||||||||||||
| 1805 | ########################################### | ||||||||||||||||||||||||||||
| 1806 | sub update_reply { | ||||||||||||||||||||||||||||
| 1807 | ########################################### | ||||||||||||||||||||||||||||
| 1808 | 0 | ▶ | my ( $self, $fileId, $commentId, $replyId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
update_reply: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||
| 1809 | |||||||||||||||||||||||||||||
| 1810 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 1811 | or LOGDIE('update_reply() missing file ID'); | ||||||||||||||||||||||||||||
| 1812 | |||||||||||||||||||||||||||||
| 1813 | 0 | ▶ | defined $commentId && length $commentId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $commentId and length $commentId
MC/DC0%0/2
defined $commentId and length $commentId
defined $commentId
length $commentId
Truth table0%0/3
A and B
A= defined $commentIdB= length $commentId
| |||||||||||||||||||||||||||||
| 1814 | or LOGDIE('update_reply() missing comment ID'); | ||||||||||||||||||||||||||||
| 1815 | |||||||||||||||||||||||||||||
| 1816 | 0 | ▶ | defined $replyId && length $replyId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $replyId and length $replyId
MC/DC0%0/2
defined $replyId and length $replyId
defined $replyId
length $replyId
Truth table0%0/3
A and B
A= defined $replyIdB= length $replyId
| |||||||||||||||||||||||||||||
| 1817 | or LOGDIE('update_reply() missing reply ID'); | ||||||||||||||||||||||||||||
| 1818 | |||||||||||||||||||||||||||||
| 1819 | 0 | ▶ | ref $options eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1820 | or LOGDIE('update_reply() missing parameters'); | ||||||||||||||||||||||||||||
| 1821 | |||||||||||||||||||||||||||||
| 1822 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1823 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1824 | 'fields' => [ TYPE_STRING(), 1 ], | ||||||||||||||||||||||||||||
| 1825 | }, | ||||||||||||||||||||||||||||
| 1826 | |||||||||||||||||||||||||||||
| 1827 | 'body_parameters' => { | ||||||||||||||||||||||||||||
| 1828 | 'content' => [ TYPE_STRING(), 1 ], | ||||||||||||||||||||||||||||
| 1829 | }, | ||||||||||||||||||||||||||||
| 1830 | |||||||||||||||||||||||||||||
| 1831 | 'path' => "files/$fileId/comments/$commentId/replies/$replyId", | ||||||||||||||||||||||||||||
| 1832 | 'method_name' => 'update_reply', | ||||||||||||||||||||||||||||
| 1833 | 'http_method' => HTTP_METHOD_PATCH(), | ||||||||||||||||||||||||||||
| 1834 | }; | ||||||||||||||||||||||||||||
| 1835 | |||||||||||||||||||||||||||||
| 1836 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 1837 | } | ||||||||||||||||||||||||||||
| 1838 | |||||||||||||||||||||||||||||
| 1839 | # --- revisions | ||||||||||||||||||||||||||||
| 1840 | |||||||||||||||||||||||||||||
| 1841 | ########################################### | ||||||||||||||||||||||||||||
| 1842 | sub delete_revision { | ||||||||||||||||||||||||||||
| 1843 | ########################################### | ||||||||||||||||||||||||||||
| 1844 | 0 | ▶ | my ( $self, $fileId, $revisionId ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
delete_revision: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 1845 | |||||||||||||||||||||||||||||
| 1846 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 1847 | or LOGDIE('delete_revision() missing file ID'); | ||||||||||||||||||||||||||||
| 1848 | |||||||||||||||||||||||||||||
| 1849 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1850 | 'path' => "files/$fileId/revisions/$revisionId", | ||||||||||||||||||||||||||||
| 1851 | 'method_name' => 'delete_revision', | ||||||||||||||||||||||||||||
| 1852 | 'http_method' => HTTP_METHOD_DELETE(), | ||||||||||||||||||||||||||||
| 1853 | }; | ||||||||||||||||||||||||||||
| 1854 | |||||||||||||||||||||||||||||
| 1855 | 0 | return $self->_handle_api_method( $info, {} ); | |||||||||||||||||||||||||||
| 1856 | } | ||||||||||||||||||||||||||||
| 1857 | |||||||||||||||||||||||||||||
| 1858 | ########################################### | ||||||||||||||||||||||||||||
| 1859 | sub get_revision { | ||||||||||||||||||||||||||||
| 1860 | ########################################### | ||||||||||||||||||||||||||||
| 1861 | 0 | ▶ | my ( $self, $fileId, $revisionId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_revision: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 1862 | |||||||||||||||||||||||||||||
| 1863 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 1864 | or LOGDIE('get_revision() missing file ID'); | ||||||||||||||||||||||||||||
| 1865 | |||||||||||||||||||||||||||||
| 1866 | 0 | ▶ | defined $revisionId && length $revisionId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $revisionId and length $revisionId
MC/DC0%0/2
defined $revisionId and length $revisionId
defined $revisionId
length $revisionId
Truth table0%0/3
A and B
A= defined $revisionIdB= length $revisionId
| |||||||||||||||||||||||||||||
| 1867 | or LOGDIE('get_revision() missing revision ID'); | ||||||||||||||||||||||||||||
| 1868 | |||||||||||||||||||||||||||||
| 1869 | 0 | ▶ | $options //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$options //= {}
MC/DC0%0/1
$options //= {}
$options
Truth table0%0/2
A
A= $options
| |||||||||||||||||||||||||||||
| 1870 | |||||||||||||||||||||||||||||
| 1871 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1872 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1873 | 'acknowledgeAbuse' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 1874 | 'fields' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1875 | }, | ||||||||||||||||||||||||||||
| 1876 | |||||||||||||||||||||||||||||
| 1877 | 'path' => "files/$fileId/revisions/$revisionId", | ||||||||||||||||||||||||||||
| 1878 | 'method_name' => 'get_revision', | ||||||||||||||||||||||||||||
| 1879 | 'http_method' => HTTP_METHOD_GET(), | ||||||||||||||||||||||||||||
| 1880 | }; | ||||||||||||||||||||||||||||
| 1881 | |||||||||||||||||||||||||||||
| 1882 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 1883 | } | ||||||||||||||||||||||||||||
| 1884 | |||||||||||||||||||||||||||||
| 1885 | ########################################### | ||||||||||||||||||||||||||||
| 1886 | sub revisions { | ||||||||||||||||||||||||||||
| 1887 | ########################################### | ||||||||||||||||||||||||||||
| 1888 | 0 | ▶ | my ( $self, $fileId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
revisions: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 1889 | |||||||||||||||||||||||||||||
| 1890 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 1891 | or LOGDIE('revisions() missing file ID'); | ||||||||||||||||||||||||||||
| 1892 | |||||||||||||||||||||||||||||
| 1893 | 0 | ▶ | $options //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$options //= {}
MC/DC0%0/1
$options //= {}
$options
Truth table0%0/2
A
A= $options
| |||||||||||||||||||||||||||||
| 1894 | |||||||||||||||||||||||||||||
| 1895 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1896 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1897 | 'fields' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1898 | 'pageSize' => [ TYPE_INTEGER(), 0 ], | ||||||||||||||||||||||||||||
| 1899 | 'pageToken' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1900 | }, | ||||||||||||||||||||||||||||
| 1901 | |||||||||||||||||||||||||||||
| 1902 | 'path' => "files/$fileId/revisions", | ||||||||||||||||||||||||||||
| 1903 | 'method_name' => 'revisions', | ||||||||||||||||||||||||||||
| 1904 | 'http_method' => HTTP_METHOD_GET(), | ||||||||||||||||||||||||||||
| 1905 | }; | ||||||||||||||||||||||||||||
| 1906 | |||||||||||||||||||||||||||||
| 1907 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 1908 | } | ||||||||||||||||||||||||||||
| 1909 | |||||||||||||||||||||||||||||
| 1910 | ########################################### | ||||||||||||||||||||||||||||
| 1911 | sub update_revision { | ||||||||||||||||||||||||||||
| 1912 | ########################################### | ||||||||||||||||||||||||||||
| 1913 | 0 | ▶ | my ( $self, $fileId, $revisionId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
update_revision: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 1914 | |||||||||||||||||||||||||||||
| 1915 | 0 | ▶ | defined $fileId && length $fileId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fileId and length $fileId
MC/DC0%0/2
defined $fileId and length $fileId
defined $fileId
length $fileId
Truth table0%0/3
A and B
A= defined $fileIdB= length $fileId
| |||||||||||||||||||||||||||||
| 1916 | or LOGDIE('update_revision() missing file ID'); | ||||||||||||||||||||||||||||
| 1917 | |||||||||||||||||||||||||||||
| 1918 | 0 | ▶ | defined $revisionId && length $revisionId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $revisionId and length $revisionId
MC/DC0%0/2
defined $revisionId and length $revisionId
defined $revisionId
length $revisionId
Truth table0%0/3
A and B
A= defined $revisionIdB= length $revisionId
| |||||||||||||||||||||||||||||
| 1919 | or LOGDIE('update_revision() missing revision ID'); | ||||||||||||||||||||||||||||
| 1920 | |||||||||||||||||||||||||||||
| 1921 | 0 | ▶ | ref $options eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1922 | or LOGDIE('update_revision() missing parameters'); | ||||||||||||||||||||||||||||
| 1923 | |||||||||||||||||||||||||||||
| 1924 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1925 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1926 | 'fields' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1927 | }, | ||||||||||||||||||||||||||||
| 1928 | |||||||||||||||||||||||||||||
| 1929 | 'body_parameter' => [ | ||||||||||||||||||||||||||||
| 1930 | qw< | ||||||||||||||||||||||||||||
| 1931 | keepForever | ||||||||||||||||||||||||||||
| 1932 | publishAuto | ||||||||||||||||||||||||||||
| 1933 | published | ||||||||||||||||||||||||||||
| 1934 | publishedOutsideDomain | ||||||||||||||||||||||||||||
| 1935 | > | ||||||||||||||||||||||||||||
| 1936 | ], | ||||||||||||||||||||||||||||
| 1937 | |||||||||||||||||||||||||||||
| 1938 | 'path' => "files/$fileId/revisions/$revisionId", | ||||||||||||||||||||||||||||
| 1939 | 'method_name' => 'update_revision', | ||||||||||||||||||||||||||||
| 1940 | 'http_method' => HTTP_METHOD_PATCH(), | ||||||||||||||||||||||||||||
| 1941 | }; | ||||||||||||||||||||||||||||
| 1942 | |||||||||||||||||||||||||||||
| 1943 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 1944 | } | ||||||||||||||||||||||||||||
| 1945 | |||||||||||||||||||||||||||||
| 1946 | # --- drives | ||||||||||||||||||||||||||||
| 1947 | |||||||||||||||||||||||||||||
| 1948 | ########################################### | ||||||||||||||||||||||||||||
| 1949 | sub create_drive { | ||||||||||||||||||||||||||||
| 1950 | ########################################### | ||||||||||||||||||||||||||||
| 1951 | 0 | ▶ | my ( $self, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
create_drive: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 1952 | |||||||||||||||||||||||||||||
| 1953 | 0 | ▶ | ref $options eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1954 | or LOGDIE('create_drive() missing parameters'); | ||||||||||||||||||||||||||||
| 1955 | |||||||||||||||||||||||||||||
| 1956 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1957 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 1958 | 'requestId' => [ TYPE_STRING(), 1 ], | ||||||||||||||||||||||||||||
| 1959 | }, | ||||||||||||||||||||||||||||
| 1960 | |||||||||||||||||||||||||||||
| 1961 | 'body_parameters' => { | ||||||||||||||||||||||||||||
| 1962 | 'name' => [ TYPE_STRING(), 1 ], | ||||||||||||||||||||||||||||
| 1963 | 'themeId' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 1964 | }, | ||||||||||||||||||||||||||||
| 1965 | |||||||||||||||||||||||||||||
| 1966 | 'path' => 'drives', | ||||||||||||||||||||||||||||
| 1967 | 'method_name' => 'create_drive', | ||||||||||||||||||||||||||||
| 1968 | 'http_method' => HTTP_METHOD_POST(), | ||||||||||||||||||||||||||||
| 1969 | }; | ||||||||||||||||||||||||||||
| 1970 | |||||||||||||||||||||||||||||
| 1971 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 1972 | } | ||||||||||||||||||||||||||||
| 1973 | |||||||||||||||||||||||||||||
| 1974 | ########################################### | ||||||||||||||||||||||||||||
| 1975 | sub delete_drive { | ||||||||||||||||||||||||||||
| 1976 | ########################################### | ||||||||||||||||||||||||||||
| 1977 | 0 | ▶ | my ( $self, $driveId ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
delete_drive: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 1978 | |||||||||||||||||||||||||||||
| 1979 | 0 | ▶ | defined $driveId && length $driveId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $driveId and length $driveId
MC/DC0%0/2
defined $driveId and length $driveId
defined $driveId
length $driveId
Truth table0%0/3
A and B
A= defined $driveIdB= length $driveId
| |||||||||||||||||||||||||||||
| 1980 | or LOGDIE('delete_drive() missing drive ID'); | ||||||||||||||||||||||||||||
| 1981 | |||||||||||||||||||||||||||||
| 1982 | 0 | my $info = { | |||||||||||||||||||||||||||
| 1983 | 'path' => "drives/$driveId", | ||||||||||||||||||||||||||||
| 1984 | 'method_name' => 'delete_drive', | ||||||||||||||||||||||||||||
| 1985 | 'http_method' => HTTP_METHOD_DELETE(), | ||||||||||||||||||||||||||||
| 1986 | }; | ||||||||||||||||||||||||||||
| 1987 | |||||||||||||||||||||||||||||
| 1988 | 0 | return $self->_handle_api_method( $info, {} ); | |||||||||||||||||||||||||||
| 1989 | } | ||||||||||||||||||||||||||||
| 1990 | |||||||||||||||||||||||||||||
| 1991 | ########################################### | ||||||||||||||||||||||||||||
| 1992 | sub get_drive { | ||||||||||||||||||||||||||||
| 1993 | ########################################### | ||||||||||||||||||||||||||||
| 1994 | 0 | ▶ | my ( $self, $driveId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_drive: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 1995 | |||||||||||||||||||||||||||||
| 1996 | 0 | ▶ | defined $driveId && length $driveId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $driveId and length $driveId
MC/DC0%0/2
defined $driveId and length $driveId
defined $driveId
length $driveId
Truth table0%0/3
A and B
A= defined $driveIdB= length $driveId
| |||||||||||||||||||||||||||||
| 1997 | or LOGDIE('get_drive() missing drive ID'); | ||||||||||||||||||||||||||||
| 1998 | |||||||||||||||||||||||||||||
| 1999 | 0 | ▶ | $options //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$options //= {}
MC/DC0%0/1
$options //= {}
$options
Truth table0%0/2
A
A= $options
| |||||||||||||||||||||||||||||
| 2000 | |||||||||||||||||||||||||||||
| 2001 | 0 | my $info = { | |||||||||||||||||||||||||||
| 2002 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 2003 | 'useDomainAdminAccess' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 2004 | }, | ||||||||||||||||||||||||||||
| 2005 | |||||||||||||||||||||||||||||
| 2006 | 'path' => "drives/$driveId", | ||||||||||||||||||||||||||||
| 2007 | 'method_name' => 'get_drive', | ||||||||||||||||||||||||||||
| 2008 | 'http_method' => HTTP_METHOD_GET(), | ||||||||||||||||||||||||||||
| 2009 | }; | ||||||||||||||||||||||||||||
| 2010 | |||||||||||||||||||||||||||||
| 2011 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 2012 | } | ||||||||||||||||||||||||||||
| 2013 | |||||||||||||||||||||||||||||
| 2014 | ########################################### | ||||||||||||||||||||||||||||
| 2015 | sub hide_drive { | ||||||||||||||||||||||||||||
| 2016 | ########################################### | ||||||||||||||||||||||||||||
| 2017 | 0 | ▶ | my ( $self, $driveId ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
hide_drive: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 2018 | |||||||||||||||||||||||||||||
| 2019 | 0 | ▶ | defined $driveId && length $driveId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $driveId and length $driveId
MC/DC0%0/2
defined $driveId and length $driveId
defined $driveId
length $driveId
Truth table0%0/3
A and B
A= defined $driveIdB= length $driveId
| |||||||||||||||||||||||||||||
| 2020 | or LOGDIE('hide_drive() missing drive ID'); | ||||||||||||||||||||||||||||
| 2021 | |||||||||||||||||||||||||||||
| 2022 | 0 | my $info = { | |||||||||||||||||||||||||||
| 2023 | 'path' => "drives/$driveId/hide", | ||||||||||||||||||||||||||||
| 2024 | 'method_name' => 'hide_drive', | ||||||||||||||||||||||||||||
| 2025 | 'http_method' => HTTP_METHOD_POST(), | ||||||||||||||||||||||||||||
| 2026 | }; | ||||||||||||||||||||||||||||
| 2027 | |||||||||||||||||||||||||||||
| 2028 | 0 | return $self->_handle_api_method( $info, {} ); | |||||||||||||||||||||||||||
| 2029 | } | ||||||||||||||||||||||||||||
| 2030 | |||||||||||||||||||||||||||||
| 2031 | ########################################### | ||||||||||||||||||||||||||||
| 2032 | sub drives { | ||||||||||||||||||||||||||||
| 2033 | ########################################### | ||||||||||||||||||||||||||||
| 2034 | 0 | ▶ | my ( $self, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
drives: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 2035 | |||||||||||||||||||||||||||||
| 2036 | 0 | ▶ | $options //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$options //= {}
MC/DC0%0/1
$options //= {}
$options
Truth table0%0/2
A
A= $options
| |||||||||||||||||||||||||||||
| 2037 | |||||||||||||||||||||||||||||
| 2038 | 0 | my $info = { | |||||||||||||||||||||||||||
| 2039 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 2040 | 'pageSize' => [ TYPE_INTEGER(), 0 ], | ||||||||||||||||||||||||||||
| 2041 | 'pageToken' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 2042 | 'q' => [ TYPE_STRING(), 0 ], | ||||||||||||||||||||||||||||
| 2043 | 'useDomainAdminAccess' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 2044 | }, | ||||||||||||||||||||||||||||
| 2045 | |||||||||||||||||||||||||||||
| 2046 | 'path' => 'drives', | ||||||||||||||||||||||||||||
| 2047 | 'method_name' => 'drives', | ||||||||||||||||||||||||||||
| 2048 | 'http_method' => HTTP_METHOD_GET(), | ||||||||||||||||||||||||||||
| 2049 | }; | ||||||||||||||||||||||||||||
| 2050 | |||||||||||||||||||||||||||||
| 2051 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 2052 | } | ||||||||||||||||||||||||||||
| 2053 | |||||||||||||||||||||||||||||
| 2054 | ########################################### | ||||||||||||||||||||||||||||
| 2055 | sub unhide_drive { | ||||||||||||||||||||||||||||
| 2056 | ########################################### | ||||||||||||||||||||||||||||
| 2057 | 0 | ▶ | my ( $self, $driveId ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
unhide_drive: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 2058 | |||||||||||||||||||||||||||||
| 2059 | 0 | ▶ | defined $driveId && length $driveId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $driveId and length $driveId
MC/DC0%0/2
defined $driveId and length $driveId
defined $driveId
length $driveId
Truth table0%0/3
A and B
A= defined $driveIdB= length $driveId
| |||||||||||||||||||||||||||||
| 2060 | or LOGDIE('unhide_drive() missing drive ID'); | ||||||||||||||||||||||||||||
| 2061 | |||||||||||||||||||||||||||||
| 2062 | 0 | my $info = { | |||||||||||||||||||||||||||
| 2063 | 'path' => "drives/$driveId/unhide", | ||||||||||||||||||||||||||||
| 2064 | 'method_name' => 'unhide_drive', | ||||||||||||||||||||||||||||
| 2065 | 'http_method' => HTTP_METHOD_POST(), | ||||||||||||||||||||||||||||
| 2066 | }; | ||||||||||||||||||||||||||||
| 2067 | |||||||||||||||||||||||||||||
| 2068 | 0 | return $self->_handle_api_method( $info, {} ); | |||||||||||||||||||||||||||
| 2069 | } | ||||||||||||||||||||||||||||
| 2070 | |||||||||||||||||||||||||||||
| 2071 | ########################################### | ||||||||||||||||||||||||||||
| 2072 | sub update_drive { | ||||||||||||||||||||||||||||
| 2073 | ########################################### | ||||||||||||||||||||||||||||
| 2074 | 0 | ▶ | my ( $self, $driveId, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
update_drive: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 2075 | |||||||||||||||||||||||||||||
| 2076 | 0 | ▶ | defined $driveId && length $driveId | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $driveId and length $driveId
MC/DC0%0/2
defined $driveId and length $driveId
defined $driveId
length $driveId
Truth table0%0/3
A and B
A= defined $driveIdB= length $driveId
| |||||||||||||||||||||||||||||
| 2077 | or LOGDIE('update_drive() missing drive ID'); | ||||||||||||||||||||||||||||
| 2078 | |||||||||||||||||||||||||||||
| 2079 | 0 | ▶ | ref $options eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2080 | or LOGDIE('update_drive() missing parameters'); | ||||||||||||||||||||||||||||
| 2081 | |||||||||||||||||||||||||||||
| 2082 | 0 | my $info = { | |||||||||||||||||||||||||||
| 2083 | 'query_parameters' => { | ||||||||||||||||||||||||||||
| 2084 | 'useDomainAdminAccess' => [ TYPE_BOOLEAN(), 0 ], | ||||||||||||||||||||||||||||
| 2085 | }, | ||||||||||||||||||||||||||||
| 2086 | |||||||||||||||||||||||||||||
| 2087 | 'body_parameters' => [ | ||||||||||||||||||||||||||||
| 2088 | qw< | ||||||||||||||||||||||||||||
| 2089 | backgroundImageFile | ||||||||||||||||||||||||||||
| 2090 | colorRgb | ||||||||||||||||||||||||||||
| 2091 | name | ||||||||||||||||||||||||||||
| 2092 | restrictions | ||||||||||||||||||||||||||||
| 2093 | themeId | ||||||||||||||||||||||||||||
| 2094 | > | ||||||||||||||||||||||||||||
| 2095 | ], | ||||||||||||||||||||||||||||
| 2096 | |||||||||||||||||||||||||||||
| 2097 | 'path' => "drives/$driveId", | ||||||||||||||||||||||||||||
| 2098 | 'method_name' => 'update_drive', | ||||||||||||||||||||||||||||
| 2099 | 'http_method' => HTTP_METHOD_PATCH(), | ||||||||||||||||||||||||||||
| 2100 | }; | ||||||||||||||||||||||||||||
| 2101 | |||||||||||||||||||||||||||||
| 2102 | 0 | return $self->_handle_api_method( $info, $options ); | |||||||||||||||||||||||||||
| 2103 | } | ||||||||||||||||||||||||||||
| 2104 | |||||||||||||||||||||||||||||
| 2105 | # Helper methods | ||||||||||||||||||||||||||||
| 2106 | |||||||||||||||||||||||||||||
| 2107 | ########################################### | ||||||||||||||||||||||||||||
| 2108 | sub children { | ||||||||||||||||||||||||||||
| 2109 | ########################################### | ||||||||||||||||||||||||||||
| 2110 | 0 | ▶ | my ( $self, $path, $opts, $search_opts ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
children: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 2111 | |||||||||||||||||||||||||||||
| 2112 | 0 | DEBUG("Determine children of $path"); | |||||||||||||||||||||||||||
| 2113 | 0 | ▶ | LOGDIE("No $path given") unless defined $path; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2114 | |||||||||||||||||||||||||||||
| 2115 | 0 | ▶ | $opts //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$opts //= {}
MC/DC0%0/1
$opts //= {}
$opts
Truth table0%0/2
A
A= $opts
| |||||||||||||||||||||||||||||
| 2116 | 0 | ▶ | $search_opts //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$search_opts //= {}
MC/DC0%0/1
$search_opts //= {}
$search_opts
Truth table0%0/2
A
A= $search_opts
| |||||||||||||||||||||||||||||
| 2117 | |||||||||||||||||||||||||||||
| 2118 | 0 | ▶ | $opts->{'maxResults'} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2119 | and LOGDIE("'maxResults' not supported, use 'pagesize' instead"); | ||||||||||||||||||||||||||||
| 2120 | |||||||||||||||||||||||||||||
| 2121 | 0 | my ( $folder_id, $parent ) = $self->_path_resolve( $path, $search_opts ); | |||||||||||||||||||||||||||
| 2122 | |||||||||||||||||||||||||||||
| 2123 | 0 | ▶ | return unless defined $folder_id; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2124 | |||||||||||||||||||||||||||||
| 2125 | 0 | DEBUG("Getting content of folder $folder_id"); | |||||||||||||||||||||||||||
| 2126 | 0 | ▶ | my $children = $self->children_by_folder_id( $folder_id, $opts, $search_opts ) or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2127 | |||||||||||||||||||||||||||||
| 2128 | 0 | return $children; | |||||||||||||||||||||||||||
| 2129 | } | ||||||||||||||||||||||||||||
| 2130 | |||||||||||||||||||||||||||||
| 2131 | ########################################### | ||||||||||||||||||||||||||||
| 2132 | sub children_by_folder_id { | ||||||||||||||||||||||||||||
| 2133 | ########################################### | ||||||||||||||||||||||||||||
| 2134 | 0 | ▶ | my ( $self, $folder_id, $opts, $search_opts ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
children_by_folder_id: not called CC=18 SCAR=58.3
Pod
documented
| |||||||||||||||||||||||||||||
| 2135 | |||||||||||||||||||||||||||||
| 2136 | 0 | ▶ | $folder_id | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2137 | or LOGDIE('Must provide a folder id'); | ||||||||||||||||||||||||||||
| 2138 | |||||||||||||||||||||||||||||
| 2139 | 0 | $self->init(); | |||||||||||||||||||||||||||
| 2140 | |||||||||||||||||||||||||||||
| 2141 | 0 | ▶ | $opts = {} unless defined $opts; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2142 | 0 | ▶ | $search_opts = {} unless defined $search_opts; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2143 | |||||||||||||||||||||||||||||
| 2144 | 0 | ▶ | exists $search_opts->{'page'} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2145 | and LOGDIE("Search option 'page' is deprecated, use 'auto_paging'"); | ||||||||||||||||||||||||||||
| 2146 | |||||||||||||||||||||||||||||
| 2147 | 0 | ▶ | exists $search_opts->{'title'} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2148 | and LOGDIE("Search option 'title' is deprecated, set 'q' parameter with 'name' accordingly"); | ||||||||||||||||||||||||||||
| 2149 | |||||||||||||||||||||||||||||
| 2150 | 0 | ▶ | $search_opts->{'auto_paging'} //= 1; | ||||||||||||||||||||||||||
|
Condition0%0/2
$search_opts->{"auto_paging"} //= 1
MC/DC0%0/1
$search_opts->{"auto_paging"} //= 1
$search_opts->{"auto_paging"}
Truth table0%0/2
A
A= $search_opts->{"auto_paging"}
| |||||||||||||||||||||||||||||
| 2151 | |||||||||||||||||||||||||||||
| 2152 | # Append or create a search in folder | ||||||||||||||||||||||||||||
| 2153 | 0 | ▶ | if ( defined $opts->{'q'} && length $opts->{'q'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $opts->{"q"} and length $opts->{"q"}
MC/DC0%0/2
defined $opts->{"q"} and length $opts->{"q"}
defined $opts->{"q"}
length $opts->{"q"}
Truth table0%0/3
A and B
A= defined $opts->{"q"}B= length $opts->{"q"}
| |||||||||||||||||||||||||||||
| 2154 | 0 | $opts->{'q'} .= ' AND '; | |||||||||||||||||||||||||||
| 2155 | } | ||||||||||||||||||||||||||||
| 2156 | else { | ||||||||||||||||||||||||||||
| 2157 | 0 | $opts->{'q'} = ''; | |||||||||||||||||||||||||||
| 2158 | } | ||||||||||||||||||||||||||||
| 2159 | |||||||||||||||||||||||||||||
| 2160 | 0 | $opts->{'q'} .= "'$folder_id' in parents"; | |||||||||||||||||||||||||||
| 2161 | |||||||||||||||||||||||||||||
| 2162 | 0 | ▶ | if ( my $name = $search_opts->{'name'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2163 | 0 | $name =~ s{\'}{\\\'}xmsg; | |||||||||||||||||||||||||||
| 2164 | 0 | $opts->{'q'} .= " AND name = '$name'"; | |||||||||||||||||||||||||||
| 2165 | } | ||||||||||||||||||||||||||||
| 2166 | |||||||||||||||||||||||||||||
| 2167 | 0 | ▶ | $opts->{'fields'} //= ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$opts->{"fields"} //= ""
MC/DC0%0/1
$opts->{"fields"} //= ""
$opts->{"fields"}
Truth table0%0/2
A
A= $opts->{"fields"}
| |||||||||||||||||||||||||||||
| 2168 | 0 | ▶ | if ( $opts->{'fields'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2169 | 0 | $opts->{'fields'} .= ','; | |||||||||||||||||||||||||||
| 2170 | } | ||||||||||||||||||||||||||||
| 2171 | 0 | $opts->{'fields'} .= 'files(id,kind,name,mimeType,originalFilename,trashed)'; | |||||||||||||||||||||||||||
| 2172 | |||||||||||||||||||||||||||||
| 2173 | # Find only those not in the trash | ||||||||||||||||||||||||||||
| 2174 | # possibly go through all paged results | ||||||||||||||||||||||||||||
| 2175 | 0 | my @children; | |||||||||||||||||||||||||||
| 2176 | 0 | while (1) { | |||||||||||||||||||||||||||
| 2177 | 0 | ▶ | my $data = $self->files($opts) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2178 | or return; | ||||||||||||||||||||||||||||
| 2179 | |||||||||||||||||||||||||||||
| 2180 | 0 | ▶ | my @items = @{ $data->{'files'} || [] }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2181 | |||||||||||||||||||||||||||||
| 2182 | 0 | ▶ | while ( my $item = shift @items ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2183 | 0 | ▶ | if ( $item->{'trashed'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2184 | 0 | DEBUG("Skipping $item->{'name'} (item in trash)"); | |||||||||||||||||||||||||||
| 2185 | 0 | next; | |||||||||||||||||||||||||||
| 2186 | } | ||||||||||||||||||||||||||||
| 2187 | |||||||||||||||||||||||||||||
| 2188 | # use the Item.pm object with AUTOLOAD, is_folder, and is_file | ||||||||||||||||||||||||||||
| 2189 | # TODO: I dislke the AUTOLOAD format... | ||||||||||||||||||||||||||||
| 2190 | 0 | push @children, $self->data_factory($item); | |||||||||||||||||||||||||||
| 2191 | } | ||||||||||||||||||||||||||||
| 2192 | |||||||||||||||||||||||||||||
| 2193 | 0 | ▶ | if ( $search_opts->{'auto_paging'} && $data->{'nextPageToken'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$search_opts->{"auto_paging"} and $data->{"nextPageToken"}
MC/DC0%0/2
$search_opts->{"auto_paging"} and $data->{"nextPageToken"}
$search_opts->{"auto_paging"}
$data->{"nextPageToken"}
Truth table0%0/3
A and B
A= $search_opts->{"auto_paging"}B= $data->{"nextPageToken"}
| |||||||||||||||||||||||||||||
| 2194 | 0 | $opts->{'pageToken'} = $data->{'nextPageToken'}; | |||||||||||||||||||||||||||
| 2195 | } | ||||||||||||||||||||||||||||
| 2196 | else { | ||||||||||||||||||||||||||||
| 2197 | 0 | last; | |||||||||||||||||||||||||||
| 2198 | } | ||||||||||||||||||||||||||||
| 2199 | } | ||||||||||||||||||||||||||||
| 2200 | |||||||||||||||||||||||||||||
| 2201 | 0 | return \@children; | |||||||||||||||||||||||||||
| 2202 | } | ||||||||||||||||||||||||||||
| 2203 | |||||||||||||||||||||||||||||
| 2204 | ########################################### | ||||||||||||||||||||||||||||
| 2205 | sub _path_resolve { | ||||||||||||||||||||||||||||
| 2206 | ########################################### | ||||||||||||||||||||||||||||
| 2207 | 0 | ▶ | my ( $self, $path, $search_opts ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_path_resolve: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||
| 2208 | |||||||||||||||||||||||||||||
| 2209 | 0 | ▶ | $search_opts = {} if !defined $search_opts; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2210 | |||||||||||||||||||||||||||||
| 2211 | 0 | my @parts = grep length, split '/', $path; | |||||||||||||||||||||||||||
| 2212 | |||||||||||||||||||||||||||||
| 2213 | 0 | my @ids = qw(root); | |||||||||||||||||||||||||||
| 2214 | 0 | my $folder_id = my $parent = 'root'; | |||||||||||||||||||||||||||
| 2215 | 0 | DEBUG("Parent: $parent"); | |||||||||||||||||||||||||||
| 2216 | |||||||||||||||||||||||||||||
| 2217 | PART: | ||||||||||||||||||||||||||||
| 2218 | 0 | foreach my $part (@parts) { | |||||||||||||||||||||||||||
| 2219 | 0 | DEBUG("Looking up part $part (folder_id=$folder_id)"); | |||||||||||||||||||||||||||
| 2220 | |||||||||||||||||||||||||||||
| 2221 | # We append to 'q' parameter in case the user provided it | ||||||||||||||||||||||||||||
| 2222 | 0 | my $name = $part =~ s{\'}{\\\'}xmsgr; | |||||||||||||||||||||||||||
| 2223 | 0 | ▶ | if ( defined $search_opts->{'q'} && length $search_opts->{'q'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $search_opts->{"q"} and length $search_opts->{"q"}
MC/DC0%0/2
defined $search_opts->{"q"} and length $search_opts->{"q"}
defined $search_opts->{"q"}
length $search_opts->{"q"}
Truth table0%0/3
A and B
A= defined $search_opts->{"q"}B= length $search_opts->{"q"}
| |||||||||||||||||||||||||||||
| 2224 | 0 | $search_opts->{'q'} .= ' AND '; | |||||||||||||||||||||||||||
| 2225 | } | ||||||||||||||||||||||||||||
| 2226 | else { | ||||||||||||||||||||||||||||
| 2227 | 0 | $search_opts->{'q'} = ''; | |||||||||||||||||||||||||||
| 2228 | } | ||||||||||||||||||||||||||||
| 2229 | 0 | $search_opts->{'q'} .= "name = '$name'"; | |||||||||||||||||||||||||||
| 2230 | |||||||||||||||||||||||||||||
| 2231 | 0 | ▶ | my $children = $self->children_by_folder_id( $folder_id, {}, $search_opts ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2232 | or return; | ||||||||||||||||||||||||||||
| 2233 | |||||||||||||||||||||||||||||
| 2234 | 0 | for my $child (@$children) { | |||||||||||||||||||||||||||
| 2235 | 0 | DEBUG( "Found child: " . $child->name() ); | |||||||||||||||||||||||||||
| 2236 | |||||||||||||||||||||||||||||
| 2237 | 0 | ▶ | if ( $child->name() eq $part ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2238 | 0 | $folder_id = $child->{'id'}; | |||||||||||||||||||||||||||
| 2239 | 0 | unshift @ids, $folder_id; | |||||||||||||||||||||||||||
| 2240 | 0 | $parent = $folder_id; | |||||||||||||||||||||||||||
| 2241 | 0 | DEBUG("Parent: $parent"); | |||||||||||||||||||||||||||
| 2242 | 0 | next PART; | |||||||||||||||||||||||||||
| 2243 | } | ||||||||||||||||||||||||||||
| 2244 | } | ||||||||||||||||||||||||||||
| 2245 | |||||||||||||||||||||||||||||
| 2246 | 0 | my $msg = "Child $part not found"; | |||||||||||||||||||||||||||
| 2247 | 0 | $self->error($msg); | |||||||||||||||||||||||||||
| 2248 | 0 | ERROR($msg); | |||||||||||||||||||||||||||
| 2249 | 0 | return; | |||||||||||||||||||||||||||
| 2250 | } | ||||||||||||||||||||||||||||
| 2251 | |||||||||||||||||||||||||||||
| 2252 | # parent of root is root | ||||||||||||||||||||||||||||
| 2253 | 0 | ▶ | if ( @ids == 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2254 | 0 | push @ids, $ids[0]; | |||||||||||||||||||||||||||
| 2255 | } | ||||||||||||||||||||||||||||
| 2256 | |||||||||||||||||||||||||||||
| 2257 | 0 | return @ids; | |||||||||||||||||||||||||||
| 2258 | } | ||||||||||||||||||||||||||||
| 2259 | |||||||||||||||||||||||||||||
| 2260 | # TODO: Placed here until I have a use for it | ||||||||||||||||||||||||||||
| 2261 | #my %IMPORT_FORMATS = ( | ||||||||||||||||||||||||||||
| 2262 | # 'application/x-vnd.oasis.opendocument.presentation' => 'application/vnd.google-apps.presentation', | ||||||||||||||||||||||||||||
| 2263 | # 'text/tab-separated-values' => 'application/vnd.google-apps.spreadsheet', | ||||||||||||||||||||||||||||
| 2264 | # 'image/jpeg' => 'application/vnd.google-apps.document', | ||||||||||||||||||||||||||||
| 2265 | # 'image/bmp' => 'application/vnd.google-apps.document', | ||||||||||||||||||||||||||||
| 2266 | # 'image/gif' => 'application/vnd.google-apps.document', | ||||||||||||||||||||||||||||
| 2267 | # 'application/vnd.ms-excel.sheet.macroenabled.12' => 'application/vnd.google-apps.spreadsheet', | ||||||||||||||||||||||||||||
| 2268 | # 'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => 'application/vnd.google-apps.document', | ||||||||||||||||||||||||||||
| 2269 | # 'application/vnd.ms-powerpoint.presentation.macroenabled.12' => 'application/vnd.google-apps.presentation', | ||||||||||||||||||||||||||||
| 2270 | # 'application/vnd.ms-word.template.macroenabled.12' => 'application/vnd.google-apps.document', | ||||||||||||||||||||||||||||
| 2271 | # 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'application/vnd.google-apps.document', | ||||||||||||||||||||||||||||
| 2272 | # 'image/pjpeg' => 'application/vnd.google-apps.document', | ||||||||||||||||||||||||||||
| 2273 | # 'application/vnd.google-apps.script+text/plain' => 'application/vnd.google-apps.script', | ||||||||||||||||||||||||||||
| 2274 | # 'application/vnd.ms-excel' => 'application/vnd.google-apps.spreadsheet', | ||||||||||||||||||||||||||||
| 2275 | # 'application/vnd.sun.xml.writer' => 'application/vnd.google-apps.document', | ||||||||||||||||||||||||||||
| 2276 | # 'application/vnd.ms-word.document.macroenabled.12' => 'application/vnd.google-apps.document', | ||||||||||||||||||||||||||||
| 2277 | # 'application/vnd.ms-powerpoint.slideshow.macroenabled.12' => 'application/vnd.google-apps.presentation', | ||||||||||||||||||||||||||||
| 2278 | # 'text/rtf' => 'application/vnd.google-apps.document', | ||||||||||||||||||||||||||||
| 2279 | # 'application/vnd.oasis.opendocument.spreadsheet' => 'application/vnd.google-apps.spreadsheet', | ||||||||||||||||||||||||||||
| 2280 | # 'text/plain' => 'application/vnd.google-apps.document', | ||||||||||||||||||||||||||||
| 2281 | # 'application/x-vnd.oasis.opendocument.spreadsheet' => 'application/vnd.google-apps.spreadsheet', | ||||||||||||||||||||||||||||
| 2282 | # 'application/x-vnd.oasis.opendocument.text' => 'application/vnd.google-apps.document', | ||||||||||||||||||||||||||||
| 2283 | # 'image/png' => 'application/vnd.google-apps.document', | ||||||||||||||||||||||||||||
| 2284 | # 'application/msword' => 'application/vnd.google-apps.document', | ||||||||||||||||||||||||||||
| 2285 | # 'application/pdf' => 'application/vnd.google-apps.document', | ||||||||||||||||||||||||||||
| 2286 | # 'application/x-msmetafile' => 'application/vnd.google-apps.drawing', | ||||||||||||||||||||||||||||
| 2287 | # 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => 'application/vnd.google-apps.spreadsheet', | ||||||||||||||||||||||||||||
| 2288 | # 'application/vnd.ms-powerpoint' => 'application/vnd.google-apps.presentation', | ||||||||||||||||||||||||||||
| 2289 | # 'application/vnd.ms-excel.template.macroenabled.12' => 'application/vnd.google-apps.spreadsheet', | ||||||||||||||||||||||||||||
| 2290 | # 'image/x-bmp' => 'application/vnd.google-apps.document', | ||||||||||||||||||||||||||||
| 2291 | # 'application/rtf' => 'application/vnd.google-apps.document', | ||||||||||||||||||||||||||||
| 2292 | # 'application/vnd.openxmlformats-officedocument.presentationml.template' => 'application/vnd.google-apps.presentation', | ||||||||||||||||||||||||||||
| 2293 | # 'image/x-png' => 'application/vnd.google-apps.document', | ||||||||||||||||||||||||||||
| 2294 | # 'text/html' => 'application/vnd.google-apps.document', | ||||||||||||||||||||||||||||
| 2295 | # 'application/vnd.oasis.opendocument.text' => 'application/vnd.google-apps.document', | ||||||||||||||||||||||||||||
| 2296 | # 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'application/vnd.google-apps.presentation', | ||||||||||||||||||||||||||||
| 2297 | # 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'application/vnd.google-apps.spreadsheet', | ||||||||||||||||||||||||||||
| 2298 | # 'application/vnd.google-apps.script+json' => 'application/vnd.google-apps.script', | ||||||||||||||||||||||||||||
| 2299 | # 'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 'application/vnd.google-apps.presentation', | ||||||||||||||||||||||||||||
| 2300 | # 'application/vnd.ms-powerpoint.template.macroenabled.12' => 'application/vnd.google-apps.presentation', | ||||||||||||||||||||||||||||
| 2301 | # 'text/csv' => 'application/vnd.google-apps.spreadsheet', | ||||||||||||||||||||||||||||
| 2302 | # 'application/vnd.oasis.opendocument.presentation' => 'application/vnd.google-apps.presentation', | ||||||||||||||||||||||||||||
| 2303 | # 'image/jpg' => 'application/vnd.google-apps.document', | ||||||||||||||||||||||||||||
| 2304 | # 'text/richtext' => 'application/vnd.google-apps.document'] | ||||||||||||||||||||||||||||
| 2305 | #); | ||||||||||||||||||||||||||||
| 2306 | |||||||||||||||||||||||||||||
| 2307 | 10 | 1; | |||||||||||||||||||||||||||
| 2308 | |||||||||||||||||||||||||||||
| 2309 | __END__ | ||||||||||||||||||||||||||||
| 2310 | |||||||||||||||||||||||||||||
| 2311 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 2312 | |||||||||||||||||||||||||||||
| 2313 | my $gd_v3 = Net::Google::Drive::Simple->new( 'version' => 3 ); | ||||||||||||||||||||||||||||
| 2314 | # same as: | ||||||||||||||||||||||||||||
| 2315 | my $gd_v3 = Net::Google::Drive::Simple::V3->new(); | ||||||||||||||||||||||||||||
| 2316 | |||||||||||||||||||||||||||||
| 2317 | $gd->changes(...); | ||||||||||||||||||||||||||||
| 2318 | $gd->create_comment(...); | ||||||||||||||||||||||||||||
| 2319 | $gd->delete_file(...); | ||||||||||||||||||||||||||||
| 2320 | |||||||||||||||||||||||||||||
| 2321 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 2322 | |||||||||||||||||||||||||||||
| 2323 | This is a complete implementation of the Google Drive API V3. You can | ||||||||||||||||||||||||||||
| 2324 | use all the documented methods below. | ||||||||||||||||||||||||||||
| 2325 | |||||||||||||||||||||||||||||
| 2326 | Uploading files over 5 MB require reading the B<UPLOADING> section below. | ||||||||||||||||||||||||||||
| 2327 | |||||||||||||||||||||||||||||
| 2328 | =head1 METHODS | ||||||||||||||||||||||||||||
| 2329 | |||||||||||||||||||||||||||||
| 2330 | =head2 C<new> | ||||||||||||||||||||||||||||
| 2331 | |||||||||||||||||||||||||||||
| 2332 | my $gd = Net::Google::Drive::Simple::V3->new(); | ||||||||||||||||||||||||||||
| 2333 | |||||||||||||||||||||||||||||
| 2334 | Create a new instance. | ||||||||||||||||||||||||||||
| 2335 | |||||||||||||||||||||||||||||
| 2336 | You can also create an instance using L<Net::Google::Drive::Simple>: | ||||||||||||||||||||||||||||
| 2337 | |||||||||||||||||||||||||||||
| 2338 | my $gd = Net::Google::Drive::Simple->new( 'version' => 3 ); | ||||||||||||||||||||||||||||
| 2339 | |||||||||||||||||||||||||||||
| 2340 | =head2 C<about> | ||||||||||||||||||||||||||||
| 2341 | |||||||||||||||||||||||||||||
| 2342 | my $about = $gd->about({%params}); | ||||||||||||||||||||||||||||
| 2343 | |||||||||||||||||||||||||||||
| 2344 | This serves the path to C</about>. | ||||||||||||||||||||||||||||
| 2345 | |||||||||||||||||||||||||||||
| 2346 | It's also referred to as C<about.get>. | ||||||||||||||||||||||||||||
| 2347 | |||||||||||||||||||||||||||||
| 2348 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2349 | L<API page|https://developers.google.com/drive/api/v3/reference/about/get>. | ||||||||||||||||||||||||||||
| 2350 | |||||||||||||||||||||||||||||
| 2351 | =head2 C<getStartPageToken> | ||||||||||||||||||||||||||||
| 2352 | |||||||||||||||||||||||||||||
| 2353 | my $data = $gd->getStartPageToken({%params}); | ||||||||||||||||||||||||||||
| 2354 | |||||||||||||||||||||||||||||
| 2355 | Parameters are optional. | ||||||||||||||||||||||||||||
| 2356 | |||||||||||||||||||||||||||||
| 2357 | This serves the path to C</changes/startPageToken>. | ||||||||||||||||||||||||||||
| 2358 | |||||||||||||||||||||||||||||
| 2359 | This is also known as C<changes_getStartPageToken>. | ||||||||||||||||||||||||||||
| 2360 | |||||||||||||||||||||||||||||
| 2361 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2362 | L<API page|https://developers.google.com/drive/api/v3/reference/changes/getStartPageToken>. | ||||||||||||||||||||||||||||
| 2363 | |||||||||||||||||||||||||||||
| 2364 | =head2 C<changes> | ||||||||||||||||||||||||||||
| 2365 | |||||||||||||||||||||||||||||
| 2366 | my $changes_list = $gd->changes({%params}); | ||||||||||||||||||||||||||||
| 2367 | |||||||||||||||||||||||||||||
| 2368 | This serves the path to C</changes>. | ||||||||||||||||||||||||||||
| 2369 | |||||||||||||||||||||||||||||
| 2370 | This is also known as C<changes.list>. | ||||||||||||||||||||||||||||
| 2371 | |||||||||||||||||||||||||||||
| 2372 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2373 | L<API page|https://developers.google.com/drive/api/v3/reference/changes/list>. | ||||||||||||||||||||||||||||
| 2374 | |||||||||||||||||||||||||||||
| 2375 | =head2 C<watch_changes> | ||||||||||||||||||||||||||||
| 2376 | |||||||||||||||||||||||||||||
| 2377 | my $data = $gd->watch_changes({%params}); | ||||||||||||||||||||||||||||
| 2378 | |||||||||||||||||||||||||||||
| 2379 | Parameters are optional. | ||||||||||||||||||||||||||||
| 2380 | |||||||||||||||||||||||||||||
| 2381 | This serves the path to C</changes/watch>. | ||||||||||||||||||||||||||||
| 2382 | |||||||||||||||||||||||||||||
| 2383 | This is also known as C<changes.watch>. | ||||||||||||||||||||||||||||
| 2384 | |||||||||||||||||||||||||||||
| 2385 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2386 | L<API page|https://developers.google.com/drive/api/v3/reference/changes/watch>. | ||||||||||||||||||||||||||||
| 2387 | |||||||||||||||||||||||||||||
| 2388 | =head2 C<stop_channels> | ||||||||||||||||||||||||||||
| 2389 | |||||||||||||||||||||||||||||
| 2390 | $gd->stop_channels({%params}); | ||||||||||||||||||||||||||||
| 2391 | |||||||||||||||||||||||||||||
| 2392 | This serves the path to C</channels/stop>. | ||||||||||||||||||||||||||||
| 2393 | |||||||||||||||||||||||||||||
| 2394 | This is also known as C<channels.stop>. | ||||||||||||||||||||||||||||
| 2395 | |||||||||||||||||||||||||||||
| 2396 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2397 | L<API page|https://developers.google.com/drive/api/v3/reference/channels/stop>. | ||||||||||||||||||||||||||||
| 2398 | |||||||||||||||||||||||||||||
| 2399 | =head2 C<create_comment> | ||||||||||||||||||||||||||||
| 2400 | |||||||||||||||||||||||||||||
| 2401 | my $comment = $gd->create_comment( $fileId, {%params} ); | ||||||||||||||||||||||||||||
| 2402 | |||||||||||||||||||||||||||||
| 2403 | This serves the path to C</files/$fileId/comments>. | ||||||||||||||||||||||||||||
| 2404 | |||||||||||||||||||||||||||||
| 2405 | This is also known as C<comments.create>. | ||||||||||||||||||||||||||||
| 2406 | |||||||||||||||||||||||||||||
| 2407 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2408 | L<API page|https://developers.google.com/drive/api/v3/reference/comments/create>. | ||||||||||||||||||||||||||||
| 2409 | |||||||||||||||||||||||||||||
| 2410 | =head2 C<delete_comment( $fileId, $commentId )> | ||||||||||||||||||||||||||||
| 2411 | |||||||||||||||||||||||||||||
| 2412 | $gd->delete_comment( $fileId, $commentId ); | ||||||||||||||||||||||||||||
| 2413 | |||||||||||||||||||||||||||||
| 2414 | This serves the path to C</files/$fileId/comments/$commentId>. | ||||||||||||||||||||||||||||
| 2415 | |||||||||||||||||||||||||||||
| 2416 | This is also known as C<comments.delete>. | ||||||||||||||||||||||||||||
| 2417 | |||||||||||||||||||||||||||||
| 2418 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2419 | L<API page|https://developers.google.com/drive/api/v3/reference/comments/delete>. | ||||||||||||||||||||||||||||
| 2420 | |||||||||||||||||||||||||||||
| 2421 | =head2 C<get_comment( $fileId, $commentId, $params )> | ||||||||||||||||||||||||||||
| 2422 | |||||||||||||||||||||||||||||
| 2423 | my $comment = $gd->get_comment( $fileId, $commentId, {%params} ); | ||||||||||||||||||||||||||||
| 2424 | |||||||||||||||||||||||||||||
| 2425 | This serves the path to C</files/$fileId/comments/$commentId>. | ||||||||||||||||||||||||||||
| 2426 | |||||||||||||||||||||||||||||
| 2427 | This is also known as C<comments.get>. | ||||||||||||||||||||||||||||
| 2428 | |||||||||||||||||||||||||||||
| 2429 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2430 | L<API page|https://developers.google.com/drive/api/v3/reference/comments/get>. | ||||||||||||||||||||||||||||
| 2431 | |||||||||||||||||||||||||||||
| 2432 | =head2 C<comments> | ||||||||||||||||||||||||||||
| 2433 | |||||||||||||||||||||||||||||
| 2434 | my $comments = $gd->comments( $fileId, {%params} ); | ||||||||||||||||||||||||||||
| 2435 | |||||||||||||||||||||||||||||
| 2436 | This serves the path to C</files/$fileId/comments>. | ||||||||||||||||||||||||||||
| 2437 | |||||||||||||||||||||||||||||
| 2438 | This is also known as C<comments.list>. | ||||||||||||||||||||||||||||
| 2439 | |||||||||||||||||||||||||||||
| 2440 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2441 | L<API page|https://developers.google.com/drive/api/v3/reference/comments/list>. | ||||||||||||||||||||||||||||
| 2442 | |||||||||||||||||||||||||||||
| 2443 | =head2 C<update_comment> | ||||||||||||||||||||||||||||
| 2444 | |||||||||||||||||||||||||||||
| 2445 | my $comment = $gd->update_comment( $fileId, $commentId, {%params} ); | ||||||||||||||||||||||||||||
| 2446 | |||||||||||||||||||||||||||||
| 2447 | This serves the path to C</files/$fileId/comments/$commentId>. | ||||||||||||||||||||||||||||
| 2448 | |||||||||||||||||||||||||||||
| 2449 | This is also known as C<comments.update>. | ||||||||||||||||||||||||||||
| 2450 | |||||||||||||||||||||||||||||
| 2451 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2452 | L<API page|https://developers.google.com/drive/api/v3/reference/comments/update>. | ||||||||||||||||||||||||||||
| 2453 | |||||||||||||||||||||||||||||
| 2454 | =head2 C<copy_file> | ||||||||||||||||||||||||||||
| 2455 | |||||||||||||||||||||||||||||
| 2456 | my $file = $gd->copy_file( $fileId, {%params} ); | ||||||||||||||||||||||||||||
| 2457 | |||||||||||||||||||||||||||||
| 2458 | This serves the path to C</files/$fileId/copy>. | ||||||||||||||||||||||||||||
| 2459 | |||||||||||||||||||||||||||||
| 2460 | This is also known as C<files.copy>. | ||||||||||||||||||||||||||||
| 2461 | |||||||||||||||||||||||||||||
| 2462 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2463 | L<API page|https://developers.google.com/drive/api/v3/reference/files/copy>. | ||||||||||||||||||||||||||||
| 2464 | |||||||||||||||||||||||||||||
| 2465 | =head2 C<create_file> | ||||||||||||||||||||||||||||
| 2466 | |||||||||||||||||||||||||||||
| 2467 | my $file = $gd->create_file({%params}); | ||||||||||||||||||||||||||||
| 2468 | |||||||||||||||||||||||||||||
| 2469 | This serves the path to C</files>. | ||||||||||||||||||||||||||||
| 2470 | |||||||||||||||||||||||||||||
| 2471 | This is also known as C<files.create>. | ||||||||||||||||||||||||||||
| 2472 | |||||||||||||||||||||||||||||
| 2473 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2474 | L<API page|https://developers.google.com/drive/api/v3/reference/files/create>. | ||||||||||||||||||||||||||||
| 2475 | |||||||||||||||||||||||||||||
| 2476 | This one is B<ONLY for creating metadata for a file>. It will not upload | ||||||||||||||||||||||||||||
| 2477 | any content. If you want to set content, use the following methods below: | ||||||||||||||||||||||||||||
| 2478 | C<upload_media_file()>, C<upload_multipart_file>, | ||||||||||||||||||||||||||||
| 2479 | C<create_resumable_upload()>, C<upload_file_content_single()>, | ||||||||||||||||||||||||||||
| 2480 | C<upload_file_content_multiple()>, and C<upload_file_content_iterator>. | ||||||||||||||||||||||||||||
| 2481 | |||||||||||||||||||||||||||||
| 2482 | Read more about uploading under B<UPLOADING> below. If you want a simple way | ||||||||||||||||||||||||||||
| 2483 | to upload files, check C<upload_file()>. | ||||||||||||||||||||||||||||
| 2484 | |||||||||||||||||||||||||||||
| 2485 | =head2 C<upload_file> | ||||||||||||||||||||||||||||
| 2486 | |||||||||||||||||||||||||||||
| 2487 | my $result = $gd->upload_file( $filename, {%params} ); | ||||||||||||||||||||||||||||
| 2488 | |||||||||||||||||||||||||||||
| 2489 | Parameters are optional. | ||||||||||||||||||||||||||||
| 2490 | |||||||||||||||||||||||||||||
| 2491 | This method combines the different mechanisms for uploading a file and makes | ||||||||||||||||||||||||||||
| 2492 | it easy to upload large files. There are disadvantages, but for most cases, | ||||||||||||||||||||||||||||
| 2493 | this method should serve you well. | ||||||||||||||||||||||||||||
| 2494 | |||||||||||||||||||||||||||||
| 2495 | Read more about uploading under B<UPLOADING> below. | ||||||||||||||||||||||||||||
| 2496 | |||||||||||||||||||||||||||||
| 2497 | =head2 C<upload_media_file> | ||||||||||||||||||||||||||||
| 2498 | |||||||||||||||||||||||||||||
| 2499 | my $file = $gd->upload_media_file( $filename, {%params} ); | ||||||||||||||||||||||||||||
| 2500 | |||||||||||||||||||||||||||||
| 2501 | Parameters are optional. | ||||||||||||||||||||||||||||
| 2502 | |||||||||||||||||||||||||||||
| 2503 | This serves the path to C</files>. | ||||||||||||||||||||||||||||
| 2504 | |||||||||||||||||||||||||||||
| 2505 | This is also known as C<files.create>. | ||||||||||||||||||||||||||||
| 2506 | |||||||||||||||||||||||||||||
| 2507 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2508 | L<API page|https://developers.google.com/drive/api/v3/reference/files/create>. | ||||||||||||||||||||||||||||
| 2509 | |||||||||||||||||||||||||||||
| 2510 | This one is for uploading a file B<without metadata>. File size limitation | ||||||||||||||||||||||||||||
| 2511 | is 5 MB and we read it 4K at a time. | ||||||||||||||||||||||||||||
| 2512 | |||||||||||||||||||||||||||||
| 2513 | Read more about uploading under B<UPLOADING> below. | ||||||||||||||||||||||||||||
| 2514 | |||||||||||||||||||||||||||||
| 2515 | =head2 C<upload_multipart_file> | ||||||||||||||||||||||||||||
| 2516 | |||||||||||||||||||||||||||||
| 2517 | my $file = $gd->upload_multipart_file( $filename, {%params} ); | ||||||||||||||||||||||||||||
| 2518 | |||||||||||||||||||||||||||||
| 2519 | Parameters are optional. | ||||||||||||||||||||||||||||
| 2520 | |||||||||||||||||||||||||||||
| 2521 | This serves the path to C</files>. | ||||||||||||||||||||||||||||
| 2522 | |||||||||||||||||||||||||||||
| 2523 | This is also known as C<files.create>. | ||||||||||||||||||||||||||||
| 2524 | |||||||||||||||||||||||||||||
| 2525 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2526 | L<API page|https://developers.google.com/drive/api/v3/reference/files/create>. | ||||||||||||||||||||||||||||
| 2527 | |||||||||||||||||||||||||||||
| 2528 | This one is for uploading B<both a file and its metadata>. File size limitation | ||||||||||||||||||||||||||||
| 2529 | is 5 MB and we read the entire file into memory at once before uploading. | ||||||||||||||||||||||||||||
| 2530 | |||||||||||||||||||||||||||||
| 2531 | Read more about uploading under B<UPLOADING> below. | ||||||||||||||||||||||||||||
| 2532 | |||||||||||||||||||||||||||||
| 2533 | =head2 C<create_resumable_upload_for> | ||||||||||||||||||||||||||||
| 2534 | |||||||||||||||||||||||||||||
| 2535 | my $upload_id = $gd->upload_multimedia_file( $filename, {%params} ); | ||||||||||||||||||||||||||||
| 2536 | |||||||||||||||||||||||||||||
| 2537 | Parameters are optional. | ||||||||||||||||||||||||||||
| 2538 | |||||||||||||||||||||||||||||
| 2539 | This serves the path to C</files>. | ||||||||||||||||||||||||||||
| 2540 | |||||||||||||||||||||||||||||
| 2541 | This is also known as C<files.create>. | ||||||||||||||||||||||||||||
| 2542 | |||||||||||||||||||||||||||||
| 2543 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2544 | L<API page|https://developers.google.com/drive/api/v3/reference/files/create>. | ||||||||||||||||||||||||||||
| 2545 | |||||||||||||||||||||||||||||
| 2546 | This method starts a resumable upload for a specific file on disk. It provides | ||||||||||||||||||||||||||||
| 2547 | you with an ID that you can then feed to the following methods: | ||||||||||||||||||||||||||||
| 2548 | C<upload_file_content_single()>, C<upload_file_content_multiple()>, and | ||||||||||||||||||||||||||||
| 2549 | C<upload_file_content_iterator()>. | ||||||||||||||||||||||||||||
| 2550 | |||||||||||||||||||||||||||||
| 2551 | File size limitation for any resumable upload is 5120 GB and | ||||||||||||||||||||||||||||
| 2552 | C<create_resumable_upload_for()> checks for this limit. | ||||||||||||||||||||||||||||
| 2553 | |||||||||||||||||||||||||||||
| 2554 | Read more about uploading under B<UPLOADING> below. | ||||||||||||||||||||||||||||
| 2555 | |||||||||||||||||||||||||||||
| 2556 | =head2 C<create_resumable_upload> | ||||||||||||||||||||||||||||
| 2557 | |||||||||||||||||||||||||||||
| 2558 | my $upload_id = $gd->create_resumable_upload( {%params} ); | ||||||||||||||||||||||||||||
| 2559 | |||||||||||||||||||||||||||||
| 2560 | Parameters are optional. | ||||||||||||||||||||||||||||
| 2561 | |||||||||||||||||||||||||||||
| 2562 | This serves the path to C</files>. | ||||||||||||||||||||||||||||
| 2563 | |||||||||||||||||||||||||||||
| 2564 | This is also known as C<files.create>. | ||||||||||||||||||||||||||||
| 2565 | |||||||||||||||||||||||||||||
| 2566 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2567 | L<API page|https://developers.google.com/drive/api/v3/reference/files/create>. | ||||||||||||||||||||||||||||
| 2568 | |||||||||||||||||||||||||||||
| 2569 | This method starts a resumable upload. It provides you with an ID that you can | ||||||||||||||||||||||||||||
| 2570 | then feed to the following methods: C<upload_file_content_single()>, | ||||||||||||||||||||||||||||
| 2571 | C<upload_file_content_multiple()>, and C<upload_file_content_iterator()>. | ||||||||||||||||||||||||||||
| 2572 | |||||||||||||||||||||||||||||
| 2573 | File size limitation for any resumable upload is 5120 GB and | ||||||||||||||||||||||||||||
| 2574 | C<create_resumable_upload_for()> checks for this limit. | ||||||||||||||||||||||||||||
| 2575 | |||||||||||||||||||||||||||||
| 2576 | Read more about uploading under B<UPLOADING> below. | ||||||||||||||||||||||||||||
| 2577 | |||||||||||||||||||||||||||||
| 2578 | =head2 C<upload_file_content_single> | ||||||||||||||||||||||||||||
| 2579 | |||||||||||||||||||||||||||||
| 2580 | my $result = $gd->upload_file_content_single( $upload_uri, $filename ); | ||||||||||||||||||||||||||||
| 2581 | |||||||||||||||||||||||||||||
| 2582 | This serves the path to the upload URI you provide it. | ||||||||||||||||||||||||||||
| 2583 | |||||||||||||||||||||||||||||
| 2584 | There is a limitation of 5120 GB for the file. With this method, we feed the | ||||||||||||||||||||||||||||
| 2585 | file 4K at a time. | ||||||||||||||||||||||||||||
| 2586 | |||||||||||||||||||||||||||||
| 2587 | Read more about uploading under B<UPLOADING>. | ||||||||||||||||||||||||||||
| 2588 | |||||||||||||||||||||||||||||
| 2589 | =head2 C<upload_file_content_multiple> | ||||||||||||||||||||||||||||
| 2590 | |||||||||||||||||||||||||||||
| 2591 | my $result = $gd->upload_file_content_multiple( $upload_uri, $file, $chunk_size ); | ||||||||||||||||||||||||||||
| 2592 | |||||||||||||||||||||||||||||
| 2593 | Chunk size is optional, defaults to 10 MB. | ||||||||||||||||||||||||||||
| 2594 | |||||||||||||||||||||||||||||
| 2595 | This serves the path to the upload URI you provide it. | ||||||||||||||||||||||||||||
| 2596 | |||||||||||||||||||||||||||||
| 2597 | There is a limitation of 5120 GB for the file. With this method, we feed the | ||||||||||||||||||||||||||||
| 2598 | file in chunks defined by the chunk size you provide or the default 10 MB. | ||||||||||||||||||||||||||||
| 2599 | |||||||||||||||||||||||||||||
| 2600 | Read more about uploading under B<UPLOADING>. | ||||||||||||||||||||||||||||
| 2601 | |||||||||||||||||||||||||||||
| 2602 | The difference between C<upload_file_content_single()> and | ||||||||||||||||||||||||||||
| 2603 | C<upload_file_content_multiple()> is that this variation will work better | ||||||||||||||||||||||||||||
| 2604 | for long files, in theory. More importantly, it uses | ||||||||||||||||||||||||||||
| 2605 | C<upload_file_content_iterator()> which really allows you to control matters. | ||||||||||||||||||||||||||||
| 2606 | |||||||||||||||||||||||||||||
| 2607 | =head2 C<upload_file_content_iterator> | ||||||||||||||||||||||||||||
| 2608 | |||||||||||||||||||||||||||||
| 2609 | use JSON qw< from_json >; | ||||||||||||||||||||||||||||
| 2610 | |||||||||||||||||||||||||||||
| 2611 | my $iter_cb = $gd->upload_file_content_iterator( $filename, $file, $chunk_size ); | ||||||||||||||||||||||||||||
| 2612 | |||||||||||||||||||||||||||||
| 2613 | while ( my $request = $iter->() ) { | ||||||||||||||||||||||||||||
| 2614 | my $response = handle_http_request($request); | ||||||||||||||||||||||||||||
| 2615 | # anything else - we're confused, so it's an error no matter what | ||||||||||||||||||||||||||||
| 2616 | |||||||||||||||||||||||||||||
| 2617 | # 200 - Done! | ||||||||||||||||||||||||||||
| 2618 | if ( $response->code() == 200 ) { | ||||||||||||||||||||||||||||
| 2619 | return from_json( $response->decoded_content() ); | ||||||||||||||||||||||||||||
| 2620 | } | ||||||||||||||||||||||||||||
| 2621 | |||||||||||||||||||||||||||||
| 2622 | # 308 - Continue uploading! | ||||||||||||||||||||||||||||
| 2623 | # anything else - not what we're expecting | ||||||||||||||||||||||||||||
| 2624 | if ( $response->code() != 308 ) { | ||||||||||||||||||||||||||||
| 2625 | die "Error: " . $response->code(); | ||||||||||||||||||||||||||||
| 2626 | } | ||||||||||||||||||||||||||||
| 2627 | } | ||||||||||||||||||||||||||||
| 2628 | |||||||||||||||||||||||||||||
| 2629 | Chunk size is optional, defaults to 10 MB. | ||||||||||||||||||||||||||||
| 2630 | |||||||||||||||||||||||||||||
| 2631 | This returns a callback that allows you to control how to handle the | ||||||||||||||||||||||||||||
| 2632 | uploading. It's especially valuable when you want to connect the uploading | ||||||||||||||||||||||||||||
| 2633 | to an event loop like L<IO::Async>, L<POE>, L<AnyEvent>, or others. | ||||||||||||||||||||||||||||
| 2634 | |||||||||||||||||||||||||||||
| 2635 | The callback returns an object of L<HTTP::Request> which represent the | ||||||||||||||||||||||||||||
| 2636 | request that needs to be done. Once requested, if you receive a 308, it | ||||||||||||||||||||||||||||
| 2637 | means you can continue, and if you receive a 200, it means you are done | ||||||||||||||||||||||||||||
| 2638 | uploading. | ||||||||||||||||||||||||||||
| 2639 | |||||||||||||||||||||||||||||
| 2640 | There is a limitation of 5120 GB for the file. With this method, we feed the | ||||||||||||||||||||||||||||
| 2641 | file in chunks defined by the chunk size you provide or the default 10 MB. | ||||||||||||||||||||||||||||
| 2642 | |||||||||||||||||||||||||||||
| 2643 | Read more about uploading under B<UPLOADING>. | ||||||||||||||||||||||||||||
| 2644 | |||||||||||||||||||||||||||||
| 2645 | =head2 C<delete_file> | ||||||||||||||||||||||||||||
| 2646 | |||||||||||||||||||||||||||||
| 2647 | $gd->delete_file( $fileId, {%params} ); | ||||||||||||||||||||||||||||
| 2648 | |||||||||||||||||||||||||||||
| 2649 | Parameters are optional. | ||||||||||||||||||||||||||||
| 2650 | |||||||||||||||||||||||||||||
| 2651 | This serves the path to C</files/$fileId>. | ||||||||||||||||||||||||||||
| 2652 | |||||||||||||||||||||||||||||
| 2653 | This is also known as C<files.delete>. | ||||||||||||||||||||||||||||
| 2654 | |||||||||||||||||||||||||||||
| 2655 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2656 | L<API page|https://developers.google.com/drive/api/v3/reference/files/delete>. | ||||||||||||||||||||||||||||
| 2657 | |||||||||||||||||||||||||||||
| 2658 | =head2 C<export_file> | ||||||||||||||||||||||||||||
| 2659 | |||||||||||||||||||||||||||||
| 2660 | my $file_content_in_bytes = $gd->export_file( $fileId, {%params} ); | ||||||||||||||||||||||||||||
| 2661 | |||||||||||||||||||||||||||||
| 2662 | This serves the path to C</files/$fileId/export>. | ||||||||||||||||||||||||||||
| 2663 | |||||||||||||||||||||||||||||
| 2664 | This is also known as C<files.export>. | ||||||||||||||||||||||||||||
| 2665 | |||||||||||||||||||||||||||||
| 2666 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2667 | L<API page|https://developers.google.com/drive/api/v3/reference/files/export>. | ||||||||||||||||||||||||||||
| 2668 | |||||||||||||||||||||||||||||
| 2669 | =head2 C<generateIds> | ||||||||||||||||||||||||||||
| 2670 | |||||||||||||||||||||||||||||
| 2671 | my $data = $gd->generateIds({%params}); | ||||||||||||||||||||||||||||
| 2672 | |||||||||||||||||||||||||||||
| 2673 | Parameters are optional. | ||||||||||||||||||||||||||||
| 2674 | |||||||||||||||||||||||||||||
| 2675 | This serves the path to C</files/generateIds>. | ||||||||||||||||||||||||||||
| 2676 | |||||||||||||||||||||||||||||
| 2677 | This is also known as C<files.generateIds>. | ||||||||||||||||||||||||||||
| 2678 | |||||||||||||||||||||||||||||
| 2679 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2680 | L<API page|https://developers.google.com/drive/api/v3/reference/files/generateIds>. | ||||||||||||||||||||||||||||
| 2681 | |||||||||||||||||||||||||||||
| 2682 | =head2 C<get_file> | ||||||||||||||||||||||||||||
| 2683 | |||||||||||||||||||||||||||||
| 2684 | my $file = $gd->get_file( $fileId, {%params} ); | ||||||||||||||||||||||||||||
| 2685 | |||||||||||||||||||||||||||||
| 2686 | Parameters are optional. | ||||||||||||||||||||||||||||
| 2687 | |||||||||||||||||||||||||||||
| 2688 | This serves the path to C</files/$fileId>. | ||||||||||||||||||||||||||||
| 2689 | |||||||||||||||||||||||||||||
| 2690 | This is also known as C<files.get>. | ||||||||||||||||||||||||||||
| 2691 | |||||||||||||||||||||||||||||
| 2692 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2693 | L<API page|https://developers.google.com/drive/api/v3/reference/files/get>. | ||||||||||||||||||||||||||||
| 2694 | |||||||||||||||||||||||||||||
| 2695 | =head2 C<files> | ||||||||||||||||||||||||||||
| 2696 | |||||||||||||||||||||||||||||
| 2697 | my $files = $gd->files({%params}); | ||||||||||||||||||||||||||||
| 2698 | |||||||||||||||||||||||||||||
| 2699 | Parameters are optional. | ||||||||||||||||||||||||||||
| 2700 | |||||||||||||||||||||||||||||
| 2701 | This serves the path to C</files>. | ||||||||||||||||||||||||||||
| 2702 | |||||||||||||||||||||||||||||
| 2703 | This is also known as C<files.list>. | ||||||||||||||||||||||||||||
| 2704 | |||||||||||||||||||||||||||||
| 2705 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2706 | L<API page|https://developers.google.com/drive/api/v3/reference/files/list>. | ||||||||||||||||||||||||||||
| 2707 | |||||||||||||||||||||||||||||
| 2708 | =head2 C<update_file> | ||||||||||||||||||||||||||||
| 2709 | |||||||||||||||||||||||||||||
| 2710 | my $file = $gd->update_file( $fileId, {%params} ); | ||||||||||||||||||||||||||||
| 2711 | |||||||||||||||||||||||||||||
| 2712 | This serves the path to C</files/$fileId>. | ||||||||||||||||||||||||||||
| 2713 | |||||||||||||||||||||||||||||
| 2714 | This is also known as C<files.update>. | ||||||||||||||||||||||||||||
| 2715 | |||||||||||||||||||||||||||||
| 2716 | This is for updating a file's metadata and content. | ||||||||||||||||||||||||||||
| 2717 | |||||||||||||||||||||||||||||
| 2718 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2719 | L<API page|https://developers.google.com/drive/api/v3/reference/files/update>. | ||||||||||||||||||||||||||||
| 2720 | |||||||||||||||||||||||||||||
| 2721 | =head2 C<update_file_metadata> | ||||||||||||||||||||||||||||
| 2722 | |||||||||||||||||||||||||||||
| 2723 | my $file = $gd->update_file_metadata( $fileId, {%params} ); | ||||||||||||||||||||||||||||
| 2724 | |||||||||||||||||||||||||||||
| 2725 | This serves the path to C</files/$fileId>. | ||||||||||||||||||||||||||||
| 2726 | |||||||||||||||||||||||||||||
| 2727 | This is also known as C<files.update>. | ||||||||||||||||||||||||||||
| 2728 | |||||||||||||||||||||||||||||
| 2729 | This one is only for updating a file's metadata, even though it shares | ||||||||||||||||||||||||||||
| 2730 | a moniker with the C<update_file()> method in the Google Drive API. | ||||||||||||||||||||||||||||
| 2731 | |||||||||||||||||||||||||||||
| 2732 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2733 | L<API page|https://developers.google.com/drive/api/v3/reference/files/update>. | ||||||||||||||||||||||||||||
| 2734 | |||||||||||||||||||||||||||||
| 2735 | =head2 C<watch_file> | ||||||||||||||||||||||||||||
| 2736 | |||||||||||||||||||||||||||||
| 2737 | my $data = $gd->watch_file( $fileId, {%params} ); | ||||||||||||||||||||||||||||
| 2738 | |||||||||||||||||||||||||||||
| 2739 | This serves the path to C</files/$fileId/watch>. | ||||||||||||||||||||||||||||
| 2740 | |||||||||||||||||||||||||||||
| 2741 | This is also known as C<files.watch>. | ||||||||||||||||||||||||||||
| 2742 | |||||||||||||||||||||||||||||
| 2743 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2744 | L<API page|https://developers.google.com/drive/api/v3/reference/files/watch>. | ||||||||||||||||||||||||||||
| 2745 | |||||||||||||||||||||||||||||
| 2746 | =head2 C<empty_trash> | ||||||||||||||||||||||||||||
| 2747 | |||||||||||||||||||||||||||||
| 2748 | $gd->empty_trash({%params}) | ||||||||||||||||||||||||||||
| 2749 | |||||||||||||||||||||||||||||
| 2750 | Parameters are optional. | ||||||||||||||||||||||||||||
| 2751 | |||||||||||||||||||||||||||||
| 2752 | This serves the path to C</files/trash>. | ||||||||||||||||||||||||||||
| 2753 | |||||||||||||||||||||||||||||
| 2754 | This is also known as C<files.emptyTrash>. | ||||||||||||||||||||||||||||
| 2755 | |||||||||||||||||||||||||||||
| 2756 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2757 | L<API page|https://developers.google.com/drive/api/v3/reference/files/emptyTrash>. | ||||||||||||||||||||||||||||
| 2758 | |||||||||||||||||||||||||||||
| 2759 | =head2 C<create_permission> | ||||||||||||||||||||||||||||
| 2760 | |||||||||||||||||||||||||||||
| 2761 | my $permission = $gd-><create_permission( $fileId, {%params} ); | ||||||||||||||||||||||||||||
| 2762 | |||||||||||||||||||||||||||||
| 2763 | This serves the path to C</files/$fileId/permissions>. | ||||||||||||||||||||||||||||
| 2764 | |||||||||||||||||||||||||||||
| 2765 | This is also known as C<permissions.create>. | ||||||||||||||||||||||||||||
| 2766 | |||||||||||||||||||||||||||||
| 2767 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2768 | L<API page|https://developers.google.com/drive/api/v3/reference/permissions/create>. | ||||||||||||||||||||||||||||
| 2769 | |||||||||||||||||||||||||||||
| 2770 | =head2 C<delete_permission> | ||||||||||||||||||||||||||||
| 2771 | |||||||||||||||||||||||||||||
| 2772 | $gd->delete_permission( $fileId, $permissionId, {%params} ); | ||||||||||||||||||||||||||||
| 2773 | |||||||||||||||||||||||||||||
| 2774 | Parameters are optional. | ||||||||||||||||||||||||||||
| 2775 | |||||||||||||||||||||||||||||
| 2776 | This serves the path to C</files/$fileId/permissions/$permissionId>. | ||||||||||||||||||||||||||||
| 2777 | |||||||||||||||||||||||||||||
| 2778 | This is also known as C<permissions.delete>. | ||||||||||||||||||||||||||||
| 2779 | |||||||||||||||||||||||||||||
| 2780 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2781 | L<API page|https://developers.google.com/drive/api/v3/reference/permissions/delete>. | ||||||||||||||||||||||||||||
| 2782 | |||||||||||||||||||||||||||||
| 2783 | =head2 C<get_permission> | ||||||||||||||||||||||||||||
| 2784 | |||||||||||||||||||||||||||||
| 2785 | my $permission = $gd->get_permission( $fileId, $permissionId, {%params} ); | ||||||||||||||||||||||||||||
| 2786 | |||||||||||||||||||||||||||||
| 2787 | Parameters are optional. | ||||||||||||||||||||||||||||
| 2788 | |||||||||||||||||||||||||||||
| 2789 | This serves the path to C</files/$fileId/permissions/$permissionId>. | ||||||||||||||||||||||||||||
| 2790 | |||||||||||||||||||||||||||||
| 2791 | This is also known as C<permissions.get>. | ||||||||||||||||||||||||||||
| 2792 | |||||||||||||||||||||||||||||
| 2793 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2794 | L<API page|https://developers.google.com/drive/api/v3/reference/permissions/get>. | ||||||||||||||||||||||||||||
| 2795 | |||||||||||||||||||||||||||||
| 2796 | =head2 C<permissions> | ||||||||||||||||||||||||||||
| 2797 | |||||||||||||||||||||||||||||
| 2798 | my $permissions = $gd->permissions( $fileId, {%params} ); | ||||||||||||||||||||||||||||
| 2799 | |||||||||||||||||||||||||||||
| 2800 | Parameters are optional. | ||||||||||||||||||||||||||||
| 2801 | |||||||||||||||||||||||||||||
| 2802 | This serves the path to C</files/$fileId/permissions>. | ||||||||||||||||||||||||||||
| 2803 | |||||||||||||||||||||||||||||
| 2804 | This is also known as C<permissions.list>. | ||||||||||||||||||||||||||||
| 2805 | |||||||||||||||||||||||||||||
| 2806 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2807 | L<API page|https://developers.google.com/drive/api/v3/reference/permissions/list>. | ||||||||||||||||||||||||||||
| 2808 | |||||||||||||||||||||||||||||
| 2809 | =head2 C<update_permission> | ||||||||||||||||||||||||||||
| 2810 | |||||||||||||||||||||||||||||
| 2811 | my $permission = $gd->update_permission( $fileId, $permissionId, {%params} ); | ||||||||||||||||||||||||||||
| 2812 | |||||||||||||||||||||||||||||
| 2813 | Parameters are optional. | ||||||||||||||||||||||||||||
| 2814 | |||||||||||||||||||||||||||||
| 2815 | This serves the path to C</files/$fileId/permissions/$permissionId>. | ||||||||||||||||||||||||||||
| 2816 | |||||||||||||||||||||||||||||
| 2817 | This is also known as C<permissions.update>. | ||||||||||||||||||||||||||||
| 2818 | |||||||||||||||||||||||||||||
| 2819 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2820 | L<API page|https://developers.google.com/drive/api/v3/reference/permissions/update>. | ||||||||||||||||||||||||||||
| 2821 | |||||||||||||||||||||||||||||
| 2822 | =head2 C<create_reply> | ||||||||||||||||||||||||||||
| 2823 | |||||||||||||||||||||||||||||
| 2824 | my $reply = $gd->create_reply( $fileId, $commentId, {%params} ); | ||||||||||||||||||||||||||||
| 2825 | |||||||||||||||||||||||||||||
| 2826 | This serves the path to C</files/$fileId/comments/$commentId/replies>. | ||||||||||||||||||||||||||||
| 2827 | |||||||||||||||||||||||||||||
| 2828 | This is also known as C<replies.create>. | ||||||||||||||||||||||||||||
| 2829 | |||||||||||||||||||||||||||||
| 2830 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2831 | L<API page|https://developers.google.com/drive/api/v3/reference/replies/create>. | ||||||||||||||||||||||||||||
| 2832 | |||||||||||||||||||||||||||||
| 2833 | =head2 C<delete_reply( $fileId, $commentId, $replyId )> | ||||||||||||||||||||||||||||
| 2834 | |||||||||||||||||||||||||||||
| 2835 | $gd->delete_reply( $fileId, $commentId, $replyId ); | ||||||||||||||||||||||||||||
| 2836 | |||||||||||||||||||||||||||||
| 2837 | This serves the path to C</files/$fileId/comments/$commentId/replies/$replyId>. | ||||||||||||||||||||||||||||
| 2838 | |||||||||||||||||||||||||||||
| 2839 | This is also known as C<replies.delete>. | ||||||||||||||||||||||||||||
| 2840 | |||||||||||||||||||||||||||||
| 2841 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2842 | L<API page|https://developers.google.com/drive/api/v3/reference/replies/delete>. | ||||||||||||||||||||||||||||
| 2843 | |||||||||||||||||||||||||||||
| 2844 | =head2 C<get_reply> | ||||||||||||||||||||||||||||
| 2845 | |||||||||||||||||||||||||||||
| 2846 | my $reply = %gd->get_reply( $fileId, $commentId, $replyId, {%params} ); | ||||||||||||||||||||||||||||
| 2847 | |||||||||||||||||||||||||||||
| 2848 | This serves the path to C</files/$fileId/comments/$commentId/replies/$replyId>. | ||||||||||||||||||||||||||||
| 2849 | |||||||||||||||||||||||||||||
| 2850 | This is also known as C<replies.get>. | ||||||||||||||||||||||||||||
| 2851 | |||||||||||||||||||||||||||||
| 2852 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2853 | L<API page|https://developers.google.com/drive/api/v3/reference/replies/get>. | ||||||||||||||||||||||||||||
| 2854 | |||||||||||||||||||||||||||||
| 2855 | =head2 C<replies> | ||||||||||||||||||||||||||||
| 2856 | |||||||||||||||||||||||||||||
| 2857 | my $replies = $gd->replies( $fileId, $commentId, {%params} ); | ||||||||||||||||||||||||||||
| 2858 | |||||||||||||||||||||||||||||
| 2859 | This serves the path to C</files/$fileId/comments/$commentId/replies>. | ||||||||||||||||||||||||||||
| 2860 | |||||||||||||||||||||||||||||
| 2861 | This is also known as C<replies.list>. | ||||||||||||||||||||||||||||
| 2862 | |||||||||||||||||||||||||||||
| 2863 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2864 | L<API page|https://developers.google.com/drive/api/v3/reference/replies/list>. | ||||||||||||||||||||||||||||
| 2865 | |||||||||||||||||||||||||||||
| 2866 | =head2 C<update_reply> | ||||||||||||||||||||||||||||
| 2867 | |||||||||||||||||||||||||||||
| 2868 | my $reply = $gd->update_reply( $fileId, $commentId, $replyId, {%params} ); | ||||||||||||||||||||||||||||
| 2869 | |||||||||||||||||||||||||||||
| 2870 | This serves the path to C</files/$fileId/comments/$commentId/replies/$replyId>. | ||||||||||||||||||||||||||||
| 2871 | |||||||||||||||||||||||||||||
| 2872 | This is also known as C<replies.update>. | ||||||||||||||||||||||||||||
| 2873 | |||||||||||||||||||||||||||||
| 2874 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2875 | L<API page|https://developers.google.com/drive/api/v3/reference/replies/update>. | ||||||||||||||||||||||||||||
| 2876 | |||||||||||||||||||||||||||||
| 2877 | =head2 C<delete_revision> | ||||||||||||||||||||||||||||
| 2878 | |||||||||||||||||||||||||||||
| 2879 | $gd->delete_revision( $fileId, {%params} ); | ||||||||||||||||||||||||||||
| 2880 | |||||||||||||||||||||||||||||
| 2881 | This serves the path to C</files/$fileId/revisions/$revisionId>. | ||||||||||||||||||||||||||||
| 2882 | |||||||||||||||||||||||||||||
| 2883 | This is also known as C<revisions.delete>. | ||||||||||||||||||||||||||||
| 2884 | |||||||||||||||||||||||||||||
| 2885 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2886 | L<API page|https://developers.google.com/drive/api/v3/reference/revisions/delete>. | ||||||||||||||||||||||||||||
| 2887 | |||||||||||||||||||||||||||||
| 2888 | =head2 C<get_revision( $fileId, $revisionId, $params )> | ||||||||||||||||||||||||||||
| 2889 | |||||||||||||||||||||||||||||
| 2890 | my $revision = $gd->get_revision( $fileId, $revisionId, {%params} ); | ||||||||||||||||||||||||||||
| 2891 | |||||||||||||||||||||||||||||
| 2892 | Parameters are optional. | ||||||||||||||||||||||||||||
| 2893 | |||||||||||||||||||||||||||||
| 2894 | This serves the path to C</files/$fileId/revisions/$revisionId>. | ||||||||||||||||||||||||||||
| 2895 | |||||||||||||||||||||||||||||
| 2896 | This is also known as C<revisions.get>. | ||||||||||||||||||||||||||||
| 2897 | |||||||||||||||||||||||||||||
| 2898 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2899 | L<API page|https://developers.google.com/drive/api/v3/reference/revisions/get>. | ||||||||||||||||||||||||||||
| 2900 | |||||||||||||||||||||||||||||
| 2901 | =head2 C<revisions> | ||||||||||||||||||||||||||||
| 2902 | |||||||||||||||||||||||||||||
| 2903 | my $revisions = $gd->revisions( $fileId, {%params} ); | ||||||||||||||||||||||||||||
| 2904 | |||||||||||||||||||||||||||||
| 2905 | Parameters are optional. | ||||||||||||||||||||||||||||
| 2906 | |||||||||||||||||||||||||||||
| 2907 | This serves the path to C</files/$fileId/revisions>. | ||||||||||||||||||||||||||||
| 2908 | |||||||||||||||||||||||||||||
| 2909 | This is also known as C<revisions.list>. | ||||||||||||||||||||||||||||
| 2910 | |||||||||||||||||||||||||||||
| 2911 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2912 | L<API page|https://developers.google.com/drive/api/v3/reference/revisions/list>. | ||||||||||||||||||||||||||||
| 2913 | |||||||||||||||||||||||||||||
| 2914 | =head2 C<update_revision> | ||||||||||||||||||||||||||||
| 2915 | |||||||||||||||||||||||||||||
| 2916 | my $revision = $gd->update_revision( $fileId, $revisionId, {%params} ); | ||||||||||||||||||||||||||||
| 2917 | |||||||||||||||||||||||||||||
| 2918 | This serves the path to C</files/$fileId/revisions/$revisionId>. | ||||||||||||||||||||||||||||
| 2919 | |||||||||||||||||||||||||||||
| 2920 | This is also known as C<revisions.update>. | ||||||||||||||||||||||||||||
| 2921 | |||||||||||||||||||||||||||||
| 2922 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2923 | L<API page|https://developers.google.com/drive/api/v3/reference/revisions/update>. | ||||||||||||||||||||||||||||
| 2924 | |||||||||||||||||||||||||||||
| 2925 | =head2 C<create_drive> | ||||||||||||||||||||||||||||
| 2926 | |||||||||||||||||||||||||||||
| 2927 | my $drive = $gd->create_drive({%params}); | ||||||||||||||||||||||||||||
| 2928 | |||||||||||||||||||||||||||||
| 2929 | This serves the path to C</drives>. | ||||||||||||||||||||||||||||
| 2930 | |||||||||||||||||||||||||||||
| 2931 | This is also known as C<drives.create>. | ||||||||||||||||||||||||||||
| 2932 | |||||||||||||||||||||||||||||
| 2933 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2934 | L<API page|https://developers.google.com/drive/api/v3/reference/drives/create>. | ||||||||||||||||||||||||||||
| 2935 | |||||||||||||||||||||||||||||
| 2936 | =head2 C<delete_drive> | ||||||||||||||||||||||||||||
| 2937 | |||||||||||||||||||||||||||||
| 2938 | $gd->delete_drive($driveId); | ||||||||||||||||||||||||||||
| 2939 | |||||||||||||||||||||||||||||
| 2940 | This serves the path to C</drives/$driveId>. | ||||||||||||||||||||||||||||
| 2941 | |||||||||||||||||||||||||||||
| 2942 | This is also known as C<drives.delete>. | ||||||||||||||||||||||||||||
| 2943 | |||||||||||||||||||||||||||||
| 2944 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2945 | L<API page|https://developers.google.com/drive/api/v3/reference/drives/delete>. | ||||||||||||||||||||||||||||
| 2946 | |||||||||||||||||||||||||||||
| 2947 | =head2 C<get_drive> | ||||||||||||||||||||||||||||
| 2948 | |||||||||||||||||||||||||||||
| 2949 | my $drive = $gd->get_drive( $driveId, {%params} ); | ||||||||||||||||||||||||||||
| 2950 | |||||||||||||||||||||||||||||
| 2951 | Parameters are optional. | ||||||||||||||||||||||||||||
| 2952 | |||||||||||||||||||||||||||||
| 2953 | This serves the path to C</drives/$driveId>. | ||||||||||||||||||||||||||||
| 2954 | |||||||||||||||||||||||||||||
| 2955 | This is also known as C<drives.get>. | ||||||||||||||||||||||||||||
| 2956 | |||||||||||||||||||||||||||||
| 2957 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2958 | L<API page|https://developers.google.com/drive/api/v3/reference/drives/get>. | ||||||||||||||||||||||||||||
| 2959 | |||||||||||||||||||||||||||||
| 2960 | =head2 C<hide_drive> | ||||||||||||||||||||||||||||
| 2961 | |||||||||||||||||||||||||||||
| 2962 | my $drive = $gd->hide_drive($driveId); | ||||||||||||||||||||||||||||
| 2963 | |||||||||||||||||||||||||||||
| 2964 | This serves the path to C</drives/$driveId/hide>. | ||||||||||||||||||||||||||||
| 2965 | |||||||||||||||||||||||||||||
| 2966 | This is also known as C<drives.hide>. | ||||||||||||||||||||||||||||
| 2967 | |||||||||||||||||||||||||||||
| 2968 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2969 | L<API page|https://developers.google.com/drive/api/v3/reference/drives/hide>. | ||||||||||||||||||||||||||||
| 2970 | |||||||||||||||||||||||||||||
| 2971 | =head2 C<drives> | ||||||||||||||||||||||||||||
| 2972 | |||||||||||||||||||||||||||||
| 2973 | my $drives = $gd->drives({%params}); | ||||||||||||||||||||||||||||
| 2974 | |||||||||||||||||||||||||||||
| 2975 | Parameters are optional. | ||||||||||||||||||||||||||||
| 2976 | |||||||||||||||||||||||||||||
| 2977 | This serves the path to C</drives>. | ||||||||||||||||||||||||||||
| 2978 | |||||||||||||||||||||||||||||
| 2979 | This is also known as C<drives.list>. | ||||||||||||||||||||||||||||
| 2980 | |||||||||||||||||||||||||||||
| 2981 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2982 | L<API page|https://developers.google.com/drive/api/v3/reference/drives/list>. | ||||||||||||||||||||||||||||
| 2983 | |||||||||||||||||||||||||||||
| 2984 | =head2 C<unhide_drive> | ||||||||||||||||||||||||||||
| 2985 | |||||||||||||||||||||||||||||
| 2986 | my $drive = $gd->unhide_drive($driveId); | ||||||||||||||||||||||||||||
| 2987 | |||||||||||||||||||||||||||||
| 2988 | This serves the path to C</drives/$driveId/unhide>. | ||||||||||||||||||||||||||||
| 2989 | |||||||||||||||||||||||||||||
| 2990 | This is also known as C<drives.unhide>. | ||||||||||||||||||||||||||||
| 2991 | |||||||||||||||||||||||||||||
| 2992 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 2993 | L<API page|https://developers.google.com/drive/api/v3/reference/drives/unhide>. | ||||||||||||||||||||||||||||
| 2994 | |||||||||||||||||||||||||||||
| 2995 | =head2 C<update_drive> | ||||||||||||||||||||||||||||
| 2996 | |||||||||||||||||||||||||||||
| 2997 | my $drive = $gd->update_drive( $driveId, {%params} ); | ||||||||||||||||||||||||||||
| 2998 | |||||||||||||||||||||||||||||
| 2999 | This serves the path to C</drives/$driveId>. | ||||||||||||||||||||||||||||
| 3000 | |||||||||||||||||||||||||||||
| 3001 | This is also known as C<drives.update>. | ||||||||||||||||||||||||||||
| 3002 | |||||||||||||||||||||||||||||
| 3003 | You can read about the parameters on the Google Drive | ||||||||||||||||||||||||||||
| 3004 | L<API page|https://developers.google.com/drive/api/v3/reference/drives/update>. | ||||||||||||||||||||||||||||
| 3005 | |||||||||||||||||||||||||||||
| 3006 | =head2 C<children> | ||||||||||||||||||||||||||||
| 3007 | |||||||||||||||||||||||||||||
| 3008 | my $children = $gd->children( '/path/to', {%params}, {%extra_params} )> | ||||||||||||||||||||||||||||
| 3009 | |||||||||||||||||||||||||||||
| 3010 | The parameters and extra parameters are both optional. | ||||||||||||||||||||||||||||
| 3011 | |||||||||||||||||||||||||||||
| 3012 | Return the entries under a given path on the Google Drive as a reference | ||||||||||||||||||||||||||||
| 3013 | to an array. Each entry | ||||||||||||||||||||||||||||
| 3014 | is an object composed of the JSON data returned by the Google Drive API. | ||||||||||||||||||||||||||||
| 3015 | Each object offers methods named like the fields in the JSON data, e.g. | ||||||||||||||||||||||||||||
| 3016 | C<originalFilename()>, C<downloadUrl>, etc. | ||||||||||||||||||||||||||||
| 3017 | |||||||||||||||||||||||||||||
| 3018 | Will return all entries found unless C<pageSize> is set: | ||||||||||||||||||||||||||||
| 3019 | |||||||||||||||||||||||||||||
| 3020 | my $children = $gd->children( "/path/to", { pageSize => 3 } ) | ||||||||||||||||||||||||||||
| 3021 | |||||||||||||||||||||||||||||
| 3022 | Due to the somewhat capricious ways Google Drive handles its directory | ||||||||||||||||||||||||||||
| 3023 | structures, the method needs to traverse the path component by component | ||||||||||||||||||||||||||||
| 3024 | and determine the ID of each directory to get to the next level. To speed | ||||||||||||||||||||||||||||
| 3025 | up subsequent lookups, it also returns the ID of the last component to the | ||||||||||||||||||||||||||||
| 3026 | caller: | ||||||||||||||||||||||||||||
| 3027 | |||||||||||||||||||||||||||||
| 3028 | my( $children, $parent ) = $gd->children( "/path/to" ); | ||||||||||||||||||||||||||||
| 3029 | |||||||||||||||||||||||||||||
| 3030 | If the caller now wants to e.g. insert a file into the directory, its | ||||||||||||||||||||||||||||
| 3031 | ID is available in $parent. | ||||||||||||||||||||||||||||
| 3032 | |||||||||||||||||||||||||||||
| 3033 | Each child comes back as a files#resource type and gets mapped into | ||||||||||||||||||||||||||||
| 3034 | an object that offers access to the various fields via methods: | ||||||||||||||||||||||||||||
| 3035 | |||||||||||||||||||||||||||||
| 3036 | for my $child ( @$children ) { | ||||||||||||||||||||||||||||
| 3037 | print $child->kind(), " ", $child->name(), "\n"; | ||||||||||||||||||||||||||||
| 3038 | } | ||||||||||||||||||||||||||||
| 3039 | |||||||||||||||||||||||||||||
| 3040 | Please refer to | ||||||||||||||||||||||||||||
| 3041 | |||||||||||||||||||||||||||||
| 3042 | https://developers.google.com/drive/v3/reference/files#resource | ||||||||||||||||||||||||||||
| 3043 | |||||||||||||||||||||||||||||
| 3044 | for details on which fields are available. | ||||||||||||||||||||||||||||
| 3045 | |||||||||||||||||||||||||||||
| 3046 | =head2 C<children_by_folder_id> | ||||||||||||||||||||||||||||
| 3047 | |||||||||||||||||||||||||||||
| 3048 | my $children = $gd->children_by_folder_id($folderId); | ||||||||||||||||||||||||||||
| 3049 | |||||||||||||||||||||||||||||
| 3050 | # Search with a particular query and stop at the first page | ||||||||||||||||||||||||||||
| 3051 | my $children = $gd->children_by_folder_id( | ||||||||||||||||||||||||||||
| 3052 | $folderId, | ||||||||||||||||||||||||||||
| 3053 | { 'q' => q{name contains 'hello'} }, | ||||||||||||||||||||||||||||
| 3054 | { 'auto_paging' => 0 }, | ||||||||||||||||||||||||||||
| 3055 | ); | ||||||||||||||||||||||||||||
| 3056 | |||||||||||||||||||||||||||||
| 3057 | Similar to C<children()> but uses a folder ID. | ||||||||||||||||||||||||||||
| 3058 | |||||||||||||||||||||||||||||
| 3059 | The second parameter is the parameters the C<files()> method receives. | ||||||||||||||||||||||||||||
| 3060 | |||||||||||||||||||||||||||||
| 3061 | The third parameter is for additional options on how to conduct this | ||||||||||||||||||||||||||||
| 3062 | search. Only one option is supported: C<auto_paging>. | ||||||||||||||||||||||||||||
| 3063 | |||||||||||||||||||||||||||||
| 3064 | When C<auto_paging> is turned on (which is the default), the search | ||||||||||||||||||||||||||||
| 3065 | will be done on every page of the results instead of stopping at the | ||||||||||||||||||||||||||||
| 3066 | first page. | ||||||||||||||||||||||||||||
| 3067 | |||||||||||||||||||||||||||||
| 3068 | =head1 UPLOADING | ||||||||||||||||||||||||||||
| 3069 | |||||||||||||||||||||||||||||
| 3070 | Uploading of a 5 MB file or lower is simple, but uploading a larger | ||||||||||||||||||||||||||||
| 3071 | file is more difficult. This module supports every possible option, | ||||||||||||||||||||||||||||
| 3072 | including connecting uploads to a different systems. | ||||||||||||||||||||||||||||
| 3073 | |||||||||||||||||||||||||||||
| 3074 | =head2 SIMPLE AND EASY UPLOADING | ||||||||||||||||||||||||||||
| 3075 | |||||||||||||||||||||||||||||
| 3076 | If you are not interested in all the details and finer controls of | ||||||||||||||||||||||||||||
| 3077 | uploading files, you can just use C<upload_file>. | ||||||||||||||||||||||||||||
| 3078 | |||||||||||||||||||||||||||||
| 3079 | my $data = $gd->upload_file( $filename, {%params} ); | ||||||||||||||||||||||||||||
| 3080 | |||||||||||||||||||||||||||||
| 3081 | The parameters are optional and you can read more about them in | ||||||||||||||||||||||||||||
| 3082 | the appropriate | ||||||||||||||||||||||||||||
| 3083 | L<API page|https://developers.google.com/drive/api/v3/reference/files/create>. | ||||||||||||||||||||||||||||
| 3084 | |||||||||||||||||||||||||||||
| 3085 | The disadvantages are that you cannot control how much is uploaded | ||||||||||||||||||||||||||||
| 3086 | at a time, it's not resumable, nor coudl you connect it with an | ||||||||||||||||||||||||||||
| 3087 | event loop. | ||||||||||||||||||||||||||||
| 3088 | |||||||||||||||||||||||||||||
| 3089 | However, this has no size limitations other than 5120 GB. | ||||||||||||||||||||||||||||
| 3090 | |||||||||||||||||||||||||||||
| 3091 | =head2 UPLOADING FILES 5 MB OR SMALLER | ||||||||||||||||||||||||||||
| 3092 | |||||||||||||||||||||||||||||
| 3093 | When uploading 5 MB and under, you can either use C<create_file()> | ||||||||||||||||||||||||||||
| 3094 | for metadata or C<upload_media_file()> for both metadata and content. | ||||||||||||||||||||||||||||
| 3095 | |||||||||||||||||||||||||||||
| 3096 | Despite the name, you may upload any form of file, not just media | ||||||||||||||||||||||||||||
| 3097 | files. (This is the name Google provides this form of upload.) | ||||||||||||||||||||||||||||
| 3098 | |||||||||||||||||||||||||||||
| 3099 | # Create only the metadata | ||||||||||||||||||||||||||||
| 3100 | my $data = $gd->create_file({ | ||||||||||||||||||||||||||||
| 3101 | 'name' => 'foo.txt', | ||||||||||||||||||||||||||||
| 3102 | 'mediaType' => 'text/plain', | ||||||||||||||||||||||||||||
| 3103 | }) | ||||||||||||||||||||||||||||
| 3104 | |||||||||||||||||||||||||||||
| 3105 | Once you call C<create_file()>, you can use the ID of the response | ||||||||||||||||||||||||||||
| 3106 | in subsequent calls to C<upload_media_file()> or | ||||||||||||||||||||||||||||
| 3107 | C<upload_multipart_file()>. (This might work for resumable uploads | ||||||||||||||||||||||||||||
| 3108 | too, but it's not tested.) | ||||||||||||||||||||||||||||
| 3109 | |||||||||||||||||||||||||||||
| 3110 | # Upload just the file | ||||||||||||||||||||||||||||
| 3111 | $data = $gd->upload_media_file('foo.txt'); | ||||||||||||||||||||||||||||
| 3112 | $data = $gd->upload_media_file( 'foo.txt', { 'name' => 'bar.txt' } ); | ||||||||||||||||||||||||||||
| 3113 | |||||||||||||||||||||||||||||
| 3114 | The only supported parameters are the query parameters. | ||||||||||||||||||||||||||||
| 3115 | |||||||||||||||||||||||||||||
| 3116 | # Upload the file and all the metadata | ||||||||||||||||||||||||||||
| 3117 | $data = $gd->upload_multipart_file( 'foo.txt', {...} ); | ||||||||||||||||||||||||||||
| 3118 | |||||||||||||||||||||||||||||
| 3119 | The difference between C<upload_media_file()> and | ||||||||||||||||||||||||||||
| 3120 | C<upload_multipart_file()> is that the former method allows the query | ||||||||||||||||||||||||||||
| 3121 | parameters, but the latter method allows all options. | ||||||||||||||||||||||||||||
| 3122 | |||||||||||||||||||||||||||||
| 3123 | You can read more about the available options for either of these | ||||||||||||||||||||||||||||
| 3124 | file uploads | ||||||||||||||||||||||||||||
| 3125 | L<here|https://developers.google.com/drive/api/v3/reference/files/create>. | ||||||||||||||||||||||||||||
| 3126 | |||||||||||||||||||||||||||||
| 3127 | =head2 UPLOADING FILES ABOVE 5 MB | ||||||||||||||||||||||||||||
| 3128 | |||||||||||||||||||||||||||||
| 3129 | When uploading files above 5 MB, you must first create a URI for the | ||||||||||||||||||||||||||||
| 3130 | file upload and then upload to that URI with another method. | ||||||||||||||||||||||||||||
| 3131 | |||||||||||||||||||||||||||||
| 3132 | There are two ways to create it, depending on whether you have a file | ||||||||||||||||||||||||||||
| 3133 | available on disk or not. | ||||||||||||||||||||||||||||
| 3134 | |||||||||||||||||||||||||||||
| 3135 | # Creating the URI using a file | ||||||||||||||||||||||||||||
| 3136 | my $upload_uri = $gd->create_resumable_upload_for( $file, {...} ); | ||||||||||||||||||||||||||||
| 3137 | |||||||||||||||||||||||||||||
| 3138 | # Creating the URI without a file | ||||||||||||||||||||||||||||
| 3139 | my $upload_uri = $gd->create_resumable_upload({ | ||||||||||||||||||||||||||||
| 3140 | 'name' => 'foo.txt', | ||||||||||||||||||||||||||||
| 3141 | 'mimeType' => 'text/plain', | ||||||||||||||||||||||||||||
| 3142 | }); | ||||||||||||||||||||||||||||
| 3143 | |||||||||||||||||||||||||||||
| 3144 | The benefit of using C<create_resumable_upload_for()> is that it allows | ||||||||||||||||||||||||||||
| 3145 | you to use an existing file's mime type and filename. Otherwise, if you | ||||||||||||||||||||||||||||
| 3146 | use the low-level C<create_resumable_upload()>, you will need to provide | ||||||||||||||||||||||||||||
| 3147 | the C<name> and C<mediaType> parameters yourself. | ||||||||||||||||||||||||||||
| 3148 | |||||||||||||||||||||||||||||
| 3149 | There are three different methods for uploading - choose the one that | ||||||||||||||||||||||||||||
| 3150 | suits you best. | ||||||||||||||||||||||||||||
| 3151 | |||||||||||||||||||||||||||||
| 3152 | # Just upload the entire file | ||||||||||||||||||||||||||||
| 3153 | my $data = upload_file_content_single( $upload_uri, $file ); | ||||||||||||||||||||||||||||
| 3154 | |||||||||||||||||||||||||||||
| 3155 | This upload will still try to chunk it by 4K so it doesn't load the | ||||||||||||||||||||||||||||
| 3156 | entire file into memory. The biggest downside of this method is that | ||||||||||||||||||||||||||||
| 3157 | if the file fails, it fully fails and you have to start from scratch. | ||||||||||||||||||||||||||||
| 3158 | |||||||||||||||||||||||||||||
| 3159 | # Upload the file in resumable chunks | ||||||||||||||||||||||||||||
| 3160 | my $data = upload_file_content_multiple( | ||||||||||||||||||||||||||||
| 3161 | $upload_uri, $file, $optional_chunk_size, | ||||||||||||||||||||||||||||
| 3162 | ); | ||||||||||||||||||||||||||||
| 3163 | |||||||||||||||||||||||||||||
| 3164 | This method will attempt to upload the file in chunks of 10 MB (or a | ||||||||||||||||||||||||||||
| 3165 | whatever chunk size you ask for - in bytes) until it successfully | ||||||||||||||||||||||||||||
| 3166 | finishes. If it fails, you might be able to resume. However, resuming | ||||||||||||||||||||||||||||
| 3167 | is not yet supported within the API, sorry. | ||||||||||||||||||||||||||||
| 3168 | |||||||||||||||||||||||||||||
| 3169 | =head2 UPLOADING FILES WITH EVENT LOOPS | ||||||||||||||||||||||||||||
| 3170 | |||||||||||||||||||||||||||||
| 3171 | If you want to connect file uploading to an event loop, you can use | ||||||||||||||||||||||||||||
| 3172 | C<upload_file_content_iterator()> to receive an iterator which will | ||||||||||||||||||||||||||||
| 3173 | generate a proper L<HTTP::Request> object you can then use in the | ||||||||||||||||||||||||||||
| 3174 | event loop request. | ||||||||||||||||||||||||||||
| 3175 | |||||||||||||||||||||||||||||
| 3176 | my $iterator = upload_file_content_iterator( | ||||||||||||||||||||||||||||
| 3177 | $upload_uir, $file, $optional_chunk_size, | ||||||||||||||||||||||||||||
| 3178 | ); | ||||||||||||||||||||||||||||
| 3179 | |||||||||||||||||||||||||||||
| 3180 | while ( my $request = $iter->() ) { | ||||||||||||||||||||||||||||
| 3181 | my $response = do_something_with_request($request); | ||||||||||||||||||||||||||||
| 3182 | |||||||||||||||||||||||||||||
| 3183 | # $response->code() == 200 - Done | ||||||||||||||||||||||||||||
| 3184 | # $response->code() == 308 - Keep going | ||||||||||||||||||||||||||||
| 3185 | # anything else - Probably some form of error | ||||||||||||||||||||||||||||
| 3186 | } | ||||||||||||||||||||||||||||
| 3187 | |||||||||||||||||||||||||||||
| 3188 | There is currently no sample code for any particular event loop. | ||||||||||||||||||||||||||||
| 3189 | |||||||||||||||||||||||||||||
| 3190 | =head1 LEGALESE | ||||||||||||||||||||||||||||
| 3191 | |||||||||||||||||||||||||||||
| 3192 | Copyright 2012-2019 by Mike Schilli, all rights reserved. | ||||||||||||||||||||||||||||
| 3193 | This program is free software, you can redistribute it and/or | ||||||||||||||||||||||||||||
| 3194 | modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 3195 | |||||||||||||||||||||||||||||
| 3196 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 3197 | |||||||||||||||||||||||||||||
| 3198 | Sawyer X <xsawyerx@cpan.org> | ||||||||||||||||||||||||||||