| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Google::Client::Files; |
|
2
|
|
|
|
|
|
|
$Google::Client::Files::VERSION = '0.004'; |
|
3
|
17
|
|
|
17
|
|
61800
|
use Moo; |
|
|
17
|
|
|
|
|
17
|
|
|
|
17
|
|
|
|
|
76
|
|
|
4
|
|
|
|
|
|
|
with qw/ |
|
5
|
|
|
|
|
|
|
Google::Client::Role::Token |
|
6
|
|
|
|
|
|
|
Google::Client::Role::FurlAgent |
|
7
|
|
|
|
|
|
|
/; |
|
8
|
|
|
|
|
|
|
|
|
9
|
17
|
|
|
17
|
|
3333
|
use Carp; |
|
|
17
|
|
|
|
|
27
|
|
|
|
17
|
|
|
|
|
754
|
|
|
10
|
17
|
|
|
17
|
|
1399
|
use Cpanel::JSON::XS; |
|
|
17
|
|
|
|
|
4507
|
|
|
|
17
|
|
|
|
|
11269
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has base_url => ( |
|
13
|
|
|
|
|
|
|
is => 'ro', |
|
14
|
|
|
|
|
|
|
default => 'https://www.googleapis.com/drive/v3/files' |
|
15
|
|
|
|
|
|
|
); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub copy { |
|
18
|
1
|
|
|
1
|
1
|
20
|
my ($self, $id, $params, $content) = @_; |
|
19
|
1
|
50
|
|
|
|
3
|
confess("No fileId provided") unless ($id); |
|
20
|
|
|
|
|
|
|
|
|
21
|
1
|
50
|
|
|
|
14
|
$content = $content ? encode_json($content) : undef; |
|
22
|
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
5
|
my $url = $self->_url("/$id/copy", $params); |
|
24
|
1
|
|
|
|
|
30
|
my $json = $self->_request( |
|
25
|
|
|
|
|
|
|
method => 'POST', |
|
26
|
|
|
|
|
|
|
url => $url, |
|
27
|
|
|
|
|
|
|
content => $content |
|
28
|
|
|
|
|
|
|
); |
|
29
|
1
|
|
|
|
|
6
|
return $json; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub create { |
|
33
|
1
|
|
|
1
|
1
|
23
|
my ($self, $params, $content) = @_; |
|
34
|
1
|
50
|
33
|
|
|
9
|
unless ( $content && %$content ) { |
|
35
|
0
|
|
|
|
|
0
|
confess("No content provided to create a media upload"); |
|
36
|
|
|
|
|
|
|
} |
|
37
|
1
|
|
|
|
|
4
|
my $url = $self->_url('/drive/v3/files', $params); |
|
38
|
1
|
|
|
|
|
47
|
my $json = $self->_request( |
|
39
|
|
|
|
|
|
|
method => 'POST', |
|
40
|
|
|
|
|
|
|
url => $url, |
|
41
|
|
|
|
|
|
|
content => encode_json($content) |
|
42
|
|
|
|
|
|
|
); |
|
43
|
1
|
|
|
|
|
4
|
return $json; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub create_media { |
|
47
|
1
|
|
|
1
|
1
|
20
|
my ($self, $params, $content) = @_; |
|
48
|
1
|
50
|
33
|
|
|
10
|
unless ( $content && %$content ) { |
|
49
|
0
|
|
|
|
|
0
|
confess("No content provided to create a media upload"); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
1
|
|
|
|
|
4
|
my $url = $self->_url('/upload/drive/v3/files', $params); |
|
52
|
1
|
|
|
|
|
46
|
my $json = $self->_request( |
|
53
|
|
|
|
|
|
|
method => 'POST', |
|
54
|
|
|
|
|
|
|
url => $url, |
|
55
|
|
|
|
|
|
|
content => encode_json($content) |
|
56
|
|
|
|
|
|
|
); |
|
57
|
1
|
|
|
|
|
7
|
return $json; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub delete { |
|
61
|
1
|
|
|
1
|
1
|
21
|
my ($self, $id) = @_; |
|
62
|
1
|
50
|
|
|
|
4
|
confess("No ID provided") unless ($id); |
|
63
|
1
|
|
|
|
|
4
|
my $url = $self->_url("/$id"); |
|
64
|
1
|
|
|
|
|
76
|
$self->_request( |
|
65
|
|
|
|
|
|
|
method => 'DELETE', |
|
66
|
|
|
|
|
|
|
url => $url |
|
67
|
|
|
|
|
|
|
); |
|
68
|
1
|
|
|
|
|
34
|
return 1; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub empty_trash { |
|
72
|
1
|
|
|
1
|
1
|
20
|
my ($self) = @_; |
|
73
|
1
|
|
|
|
|
5
|
$self->_request( |
|
74
|
|
|
|
|
|
|
method => 'DELETE', |
|
75
|
|
|
|
|
|
|
url => $self->_url('/trash') |
|
76
|
|
|
|
|
|
|
); |
|
77
|
1
|
|
|
|
|
33
|
return 1; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub export { |
|
81
|
1
|
|
|
1
|
1
|
21
|
my ($self, $id, $params) = @_; |
|
82
|
1
|
50
|
|
|
|
4
|
confess("No ID provided") unless ($id); |
|
83
|
1
|
50
|
|
|
|
3
|
confess("mimeType is a required param to export files") unless ($params->{mimeType}); |
|
84
|
1
|
|
|
|
|
5
|
my $url = $self->_url("/$id/export", $params); |
|
85
|
1
|
|
|
|
|
30
|
my $json = $self->_request( |
|
86
|
|
|
|
|
|
|
method => 'GET', |
|
87
|
|
|
|
|
|
|
url => $url |
|
88
|
|
|
|
|
|
|
); |
|
89
|
1
|
|
|
|
|
3
|
return $json; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub generate_ids { |
|
93
|
1
|
|
|
1
|
1
|
20
|
my ($self, $params) = @_; |
|
94
|
1
|
|
|
|
|
4
|
my $url = $self->_url('/generateIds', $params); |
|
95
|
1
|
|
|
|
|
29
|
my $json = $self->_request( |
|
96
|
|
|
|
|
|
|
method => 'GET', |
|
97
|
|
|
|
|
|
|
url => $url |
|
98
|
|
|
|
|
|
|
); |
|
99
|
1
|
|
|
|
|
3
|
return $json; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub get { |
|
103
|
1
|
|
|
1
|
1
|
20
|
my ($self, $id, $params) = @_; |
|
104
|
1
|
50
|
|
|
|
4
|
confess("No ID provided") unless ($id); |
|
105
|
1
|
|
|
|
|
5
|
my $url = $self->_url("/$id", $params); |
|
106
|
1
|
|
|
|
|
99
|
my $json = $self->_request( |
|
107
|
|
|
|
|
|
|
method => 'GET', |
|
108
|
|
|
|
|
|
|
url => $url |
|
109
|
|
|
|
|
|
|
); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub list { |
|
113
|
1
|
|
|
1
|
1
|
21
|
my ($self, $params) = @_; |
|
114
|
1
|
|
|
|
|
4
|
my $url = $self->_url(undef, $params); |
|
115
|
1
|
|
|
|
|
30
|
my $json = $self->_request( |
|
116
|
|
|
|
|
|
|
method => 'GET', |
|
117
|
|
|
|
|
|
|
url => $url |
|
118
|
|
|
|
|
|
|
); |
|
119
|
1
|
|
|
|
|
4
|
return $json; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub update_media { |
|
123
|
1
|
|
|
1
|
1
|
21
|
my ($self, $id, $params, $content) = @_; |
|
124
|
1
|
50
|
|
|
|
4
|
confess("No ID provided") unless ($id); |
|
125
|
1
|
50
|
33
|
|
|
10
|
unless ( $content && %$content ) { |
|
126
|
0
|
|
|
|
|
0
|
confess("No content provided to update"); |
|
127
|
|
|
|
|
|
|
} |
|
128
|
1
|
|
|
|
|
6
|
my $url = $self->_url("/upload/drive/v3/files/$id", $params); |
|
129
|
1
|
|
|
|
|
43
|
my $json = $self->_request( |
|
130
|
|
|
|
|
|
|
method => 'PATCH', |
|
131
|
|
|
|
|
|
|
url => $url, |
|
132
|
|
|
|
|
|
|
content => encode_json($content) |
|
133
|
|
|
|
|
|
|
); |
|
134
|
1
|
|
|
|
|
3
|
return $json; |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub update { |
|
138
|
1
|
|
|
1
|
1
|
21
|
my ($self, $id, $params, $content) = @_; |
|
139
|
1
|
50
|
|
|
|
4
|
confess("No ID provided") unless ($id); |
|
140
|
1
|
50
|
33
|
|
|
10
|
unless ( $content && %$content ) { |
|
141
|
0
|
|
|
|
|
0
|
confess("No content provided to update"); |
|
142
|
|
|
|
|
|
|
} |
|
143
|
1
|
|
|
|
|
5
|
my $url = $self->_url("/$id", $params); |
|
144
|
1
|
|
|
|
|
42
|
my $json = $self->_request( |
|
145
|
|
|
|
|
|
|
method => 'PATCH', |
|
146
|
|
|
|
|
|
|
url => $url, |
|
147
|
|
|
|
|
|
|
content => encode_json($content) |
|
148
|
|
|
|
|
|
|
); |
|
149
|
1
|
|
|
|
|
4
|
return $json; |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub watch { |
|
153
|
1
|
|
|
1
|
1
|
30
|
my ($self, $id, $params, $content) = @_; |
|
154
|
1
|
50
|
|
|
|
4
|
confess("No ID provided") unless ($id); |
|
155
|
1
|
|
|
|
|
5
|
my $url = $self->_url("/$id/watch", $params); |
|
156
|
1
|
50
|
|
|
|
23
|
$content = $content ? encode_json($content) : undef; |
|
157
|
1
|
|
|
|
|
24
|
my $json = $self->_request( |
|
158
|
|
|
|
|
|
|
method => 'POST', |
|
159
|
|
|
|
|
|
|
url => $url, |
|
160
|
|
|
|
|
|
|
content => $content |
|
161
|
|
|
|
|
|
|
); |
|
162
|
1
|
|
|
|
|
3
|
return $json; |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 NAME |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Google::Client::Files |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
A file resource client used in L to integrate with |
|
172
|
|
|
|
|
|
|
Googles Files REST API. |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
See L for documentation. |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 copy(Str $id, HashRef $query_params, HashRef $post_content) |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head2 create(HashRef $query_params, HashRef $post_content) |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head2 create_media(HashRef $query_params, HashRef $post_content) |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head2 delete(Str $id) |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head2 empty_trash() |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head2 export(Str $id, HashRef $query_params) |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head2 generate_ids(HashRef $query_params) |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head2 get(Str $id, HashRef $query_params) |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head2 list(HashRef $query_params) |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head2 update(Str $id, HashRef $query_params, HashRef $post_content) |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head2 update_media(Str $id, HashRef $query_params, HashRef $post_content) |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head2 watch(Str $id, HashRef $query_params, HashRef $post_content) |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 AUTHOR |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Ali Zia, C<< >> |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head1 REPOSITORY |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
L |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
This is free software. You may use it and distribute it under the same terms as Perl itself. |
|
211
|
|
|
|
|
|
|
Copyright (C) 2016 - Ali Zia |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=cut |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
1; |