line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Google::RestApi::DriveApi3::File; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '1.0.3'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
580
|
use Google::RestApi::Setup; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
13478
|
use aliased 'Google::RestApi::DriveApi3'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
17
|
|
|
17
|
0
|
35
|
my $class = shift; |
11
|
17
|
|
|
|
|
58
|
my $qr_id = DriveApi3->Drive_File_Id; |
12
|
17
|
|
|
|
|
37
|
state $check = compile_named( |
13
|
|
|
|
|
|
|
drive => HasApi, |
14
|
|
|
|
|
|
|
id => StrMatch[qr/$qr_id/], |
15
|
|
|
|
|
|
|
); |
16
|
17
|
|
|
|
|
4179
|
return bless $check->(@_), $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub api { |
20
|
11
|
|
|
11
|
0
|
22
|
my $self = shift; |
21
|
11
|
|
|
|
|
40
|
my %p = @_; |
22
|
11
|
|
|
|
|
29
|
my $uri = "files"; |
23
|
11
|
50
|
|
|
|
47
|
$uri .= "/$p{uri}" if $p{uri}; |
24
|
11
|
|
|
|
|
32
|
return $self->drive()->api(%p, uri => $uri); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub copy { |
28
|
6
|
|
|
6
|
0
|
17
|
my $self = shift; |
29
|
|
|
|
|
|
|
|
30
|
6
|
|
|
|
|
13
|
state $check = compile_named( |
31
|
|
|
|
|
|
|
name => Str, { optional => 1 }, |
32
|
|
|
|
|
|
|
title => Str, { optional => 1 }, |
33
|
|
|
|
|
|
|
_extra_ => slurpy Any, |
34
|
|
|
|
|
|
|
); |
35
|
6
|
|
|
|
|
4733
|
my $p = named_extra($check->(@_)); |
36
|
6
|
|
100
|
|
|
39
|
$p->{name} //= $p->{title}; |
37
|
6
|
100
|
|
|
|
29
|
$p->{content}->{name} = $p->{name} if defined $p->{name}; |
38
|
6
|
|
|
|
|
22
|
delete @$p{qw(name title)}; |
39
|
|
|
|
|
|
|
|
40
|
6
|
|
|
|
|
19
|
my $file_id = $self->file_id(); |
41
|
6
|
|
|
|
|
21
|
$p->{uri} = "$file_id/copy"; |
42
|
6
|
|
|
|
|
16
|
$p->{method} = 'post'; |
43
|
|
|
|
|
|
|
|
44
|
6
|
|
|
|
|
25
|
my $copy = $self->api(%$p); |
45
|
6
|
|
|
|
|
29
|
DEBUG(sprintf("Copied file '%s' to '$copy->{id}'", $self->file_id())); |
46
|
|
|
|
|
|
|
return ref($self)->new( |
47
|
|
|
|
|
|
|
drive => $self->drive(), |
48
|
|
|
|
|
|
|
id => $copy->{id}, |
49
|
6
|
|
|
|
|
56
|
); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub delete { |
53
|
5
|
|
|
5
|
0
|
256
|
my $self = shift; |
54
|
5
|
|
|
|
|
20
|
DEBUG(sprintf("Deleting file '%s'", $self->file_id())); |
55
|
5
|
|
|
|
|
61
|
return $self->api( |
56
|
|
|
|
|
|
|
method => 'delete', |
57
|
|
|
|
|
|
|
uri => $self->file_id(), |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
28
|
|
|
28
|
0
|
201
|
sub file_id { shift->{id}; } |
62
|
17
|
|
|
17
|
0
|
74
|
sub drive { shift->{drive}; } |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 NAME |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Google::RestApi::DriveApi3::File - File object for Google Drive. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 DESCRIPTION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Represents a Drive file. You may currently copy and delete the file. |
75
|
|
|
|
|
|
|
This needs further filling out. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHORS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=over |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Robin Murray mvsjes@cpan.org |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=back |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 COPYRIGHT |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Copyright (c) 2021, Robin Murray. All rights reserved. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. |