line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Google::RestApi::DriveApi3::File; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '1.0.4'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
612
|
use Google::RestApi::Setup; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
13293
|
use aliased 'Google::RestApi::DriveApi3'; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
8
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
17
|
|
|
17
|
0
|
33
|
my $class = shift; |
11
|
17
|
|
|
|
|
65
|
my $qr_id = DriveApi3->Drive_File_Id; |
12
|
17
|
|
|
|
|
33
|
state $check = compile_named( |
13
|
|
|
|
|
|
|
drive => HasApi, |
14
|
|
|
|
|
|
|
id => StrMatch[qr/$qr_id/], |
15
|
|
|
|
|
|
|
); |
16
|
17
|
|
|
|
|
4313
|
return bless $check->(@_), $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub api { |
20
|
11
|
|
|
11
|
0
|
22
|
my $self = shift; |
21
|
11
|
|
|
|
|
41
|
my %p = @_; |
22
|
11
|
|
|
|
|
25
|
my $uri = "files"; |
23
|
11
|
50
|
|
|
|
43
|
$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
|
15
|
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
|
|
|
|
|
4777
|
my $p = named_extra($check->(@_)); |
36
|
6
|
|
100
|
|
|
59
|
$p->{name} //= $p->{title}; |
37
|
6
|
100
|
|
|
|
31
|
$p->{content}->{name} = $p->{name} if defined $p->{name}; |
38
|
6
|
|
|
|
|
24
|
delete @$p{qw(name title)}; |
39
|
|
|
|
|
|
|
|
40
|
6
|
|
|
|
|
20
|
my $file_id = $self->file_id(); |
41
|
6
|
|
|
|
|
23
|
$p->{uri} = "$file_id/copy"; |
42
|
6
|
|
|
|
|
12
|
$p->{method} = 'post'; |
43
|
|
|
|
|
|
|
|
44
|
6
|
|
|
|
|
33
|
my $copy = $self->api(%$p); |
45
|
6
|
|
|
|
|
33
|
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
|
|
|
|
|
54
|
); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub delete { |
53
|
5
|
|
|
5
|
0
|
216
|
my $self = shift; |
54
|
5
|
|
|
|
|
17
|
DEBUG(sprintf("Deleting file '%s'", $self->file_id())); |
55
|
5
|
|
|
|
|
47
|
return $self->api( |
56
|
|
|
|
|
|
|
method => 'delete', |
57
|
|
|
|
|
|
|
uri => $self->file_id(), |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
28
|
|
|
28
|
0
|
133
|
sub file_id { shift->{id}; } |
62
|
17
|
|
|
17
|
0
|
75
|
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. |