source: vendor/google/apiclient-services/src/Drive/Resource/Files.php@ e3d4e0a

Last change on this file since e3d4e0a was e3d4e0a, checked in by Vlado 222039 <vlado.popovski@…>, 9 days ago

Upload project files

  • Property mode set to 100644
File size: 21.3 KB
Line 
1<?php
2/*
3 * Copyright 2014 Google Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 * use this file except in compliance with the License. You may obtain a copy of
7 * the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17
18namespace Google\Service\Drive\Resource;
19
20use Google\Service\Drive\Channel;
21use Google\Service\Drive\DriveFile;
22use Google\Service\Drive\FileList;
23use Google\Service\Drive\GeneratedIds;
24use Google\Service\Drive\LabelList;
25use Google\Service\Drive\ModifyLabelsRequest;
26use Google\Service\Drive\ModifyLabelsResponse;
27use Google\Service\Drive\Operation as OperationModel;
28
29/**
30 * The "files" collection of methods.
31 * Typical usage is:
32 * <code>
33 * $driveService = new Google\Service\Drive(...);
34 * $files = $driveService->files;
35 * </code>
36 */
37class Files extends \Google\Service\Resource
38{
39 /**
40 * Creates a copy of a file and applies any requested updates with patch
41 * semantics. (files.copy)
42 *
43 * @param string $fileId The ID of the file.
44 * @param DriveFile $postBody
45 * @param array $optParams Optional parameters.
46 *
47 * @opt_param bool enforceSingleParent Deprecated. Copying files into multiple
48 * folders is no longer supported. Use shortcuts instead.
49 * @opt_param bool ignoreDefaultVisibility Whether to ignore the domain's
50 * default visibility settings for the created file. Domain administrators can
51 * choose to make all uploaded files visible to the domain by default; this
52 * parameter bypasses that behavior for the request. Permissions are still
53 * inherited from parent folders.
54 * @opt_param string includeLabels A comma-separated list of IDs of labels to
55 * include in the `labelInfo` part of the response.
56 * @opt_param string includePermissionsForView Specifies which additional view's
57 * permissions to include in the response. Only 'published' is supported.
58 * @opt_param bool keepRevisionForever Whether to set the 'keepForever' field in
59 * the new head revision. This is only applicable to files with binary content
60 * in Google Drive. Only 200 revisions for the file can be kept forever. If the
61 * limit is reached, try deleting pinned revisions.
62 * @opt_param string ocrLanguage A language hint for OCR processing during image
63 * import (ISO 639-1 code).
64 * @opt_param bool supportsAllDrives Whether the requesting application supports
65 * both My Drives and shared drives.
66 * @opt_param bool supportsTeamDrives Deprecated: Use `supportsAllDrives`
67 * instead.
68 * @return DriveFile
69 * @throws \Google\Service\Exception
70 */
71 public function copy($fileId, DriveFile $postBody, $optParams = [])
72 {
73 $params = ['fileId' => $fileId, 'postBody' => $postBody];
74 $params = array_merge($params, $optParams);
75 return $this->call('copy', [$params], DriveFile::class);
76 }
77 /**
78 * Creates a new file. This method supports an upload* URI and accepts uploaded
79 * media with the following characteristics: - *Maximum file size:* 5,120 GB -
80 * *Accepted Media MIME types:*`*` Note: Specify a valid MIME type, rather than
81 * the literal `*` value. The literal `*` is only used to indicate that any
82 * valid MIME type can be uploaded. For more information on uploading files, see
83 * [Upload file data](/drive/api/guides/manage-uploads). Apps creating shortcuts
84 * with `files.create` must specify the MIME type `application/vnd.google-
85 * apps.shortcut`. Apps should specify a file extension in the `name` property
86 * when inserting files with the API. For example, an operation to insert a JPEG
87 * file should specify something like `"name": "cat.jpg"` in the metadata.
88 * Subsequent `GET` requests include the read-only `fileExtension` property
89 * populated with the extension originally specified in the `title` property.
90 * When a Google Drive user requests to download a file, or when the file is
91 * downloaded through the sync client, Drive builds a full filename (with
92 * extension) based on the title. In cases where the extension is missing, Drive
93 * attempts to determine the extension based on the file's MIME type.
94 * (files.create)
95 *
96 * @param DriveFile $postBody
97 * @param array $optParams Optional parameters.
98 *
99 * @opt_param bool enforceSingleParent Deprecated. Creating files in multiple
100 * folders is no longer supported.
101 * @opt_param bool ignoreDefaultVisibility Whether to ignore the domain's
102 * default visibility settings for the created file. Domain administrators can
103 * choose to make all uploaded files visible to the domain by default; this
104 * parameter bypasses that behavior for the request. Permissions are still
105 * inherited from parent folders.
106 * @opt_param string includeLabels A comma-separated list of IDs of labels to
107 * include in the `labelInfo` part of the response.
108 * @opt_param string includePermissionsForView Specifies which additional view's
109 * permissions to include in the response. Only 'published' is supported.
110 * @opt_param bool keepRevisionForever Whether to set the 'keepForever' field in
111 * the new head revision. This is only applicable to files with binary content
112 * in Google Drive. Only 200 revisions for the file can be kept forever. If the
113 * limit is reached, try deleting pinned revisions.
114 * @opt_param string ocrLanguage A language hint for OCR processing during image
115 * import (ISO 639-1 code).
116 * @opt_param bool supportsAllDrives Whether the requesting application supports
117 * both My Drives and shared drives.
118 * @opt_param bool supportsTeamDrives Deprecated: Use `supportsAllDrives`
119 * instead.
120 * @opt_param bool useContentAsIndexableText Whether to use the uploaded content
121 * as indexable text.
122 * @return DriveFile
123 * @throws \Google\Service\Exception
124 */
125 public function create(DriveFile $postBody, $optParams = [])
126 {
127 $params = ['postBody' => $postBody];
128 $params = array_merge($params, $optParams);
129 return $this->call('create', [$params], DriveFile::class);
130 }
131 /**
132 * Permanently deletes a file owned by the user without moving it to the trash.
133 * If the file belongs to a shared drive, the user must be an `organizer` on the
134 * parent folder. If the target is a folder, all descendants owned by the user
135 * are also deleted. (files.delete)
136 *
137 * @param string $fileId The ID of the file.
138 * @param array $optParams Optional parameters.
139 *
140 * @opt_param bool enforceSingleParent Deprecated: If an item is not in a shared
141 * drive and its last parent is deleted but the item itself is not, the item
142 * will be placed under its owner's root.
143 * @opt_param bool supportsAllDrives Whether the requesting application supports
144 * both My Drives and shared drives.
145 * @opt_param bool supportsTeamDrives Deprecated: Use `supportsAllDrives`
146 * instead.
147 * @throws \Google\Service\Exception
148 */
149 public function delete($fileId, $optParams = [])
150 {
151 $params = ['fileId' => $fileId];
152 $params = array_merge($params, $optParams);
153 return $this->call('delete', [$params]);
154 }
155 /**
156 * Downloads content of a file. Operations are valid for 24 hours from the time
157 * of creation. (files.download)
158 *
159 * @param string $fileId Required. The ID of the file to download.
160 * @param array $optParams Optional parameters.
161 *
162 * @opt_param string mimeType Optional. The MIME type the file should be
163 * downloaded as. This field can only be set when downloading Google Workspace
164 * documents. See [Export MIME types for Google Workspace
165 * documents](/drive/api/guides/ref-export-formats) for the list of supported
166 * MIME types. If not set, a Google Workspace document is downloaded with a
167 * default MIME type. The default MIME type might change in the future.
168 * @opt_param string revisionId Optional. The revision ID of the file to
169 * download. This field can only be set when downloading blob files, Google
170 * Docs, and Google Sheets. Returns `INVALID_ARGUMENT` if downloading a specific
171 * revision on the file is unsupported.
172 * @return OperationModel
173 * @throws \Google\Service\Exception
174 */
175 public function download($fileId, $optParams = [])
176 {
177 $params = ['fileId' => $fileId];
178 $params = array_merge($params, $optParams);
179 return $this->call('download', [$params], OperationModel::class);
180 }
181 /**
182 * Permanently deletes all of the user's trashed files. (files.emptyTrash)
183 *
184 * @param array $optParams Optional parameters.
185 *
186 * @opt_param string driveId If set, empties the trash of the provided shared
187 * drive.
188 * @opt_param bool enforceSingleParent Deprecated: If an item is not in a shared
189 * drive and its last parent is deleted but the item itself is not, the item
190 * will be placed under its owner's root.
191 * @throws \Google\Service\Exception
192 */
193 public function emptyTrash($optParams = [])
194 {
195 $params = [];
196 $params = array_merge($params, $optParams);
197 return $this->call('emptyTrash', [$params]);
198 }
199 /**
200 * Exports a Google Workspace document to the requested MIME type and returns
201 * exported byte content. Note that the exported content is limited to 10MB.
202 * (files.export)
203 *
204 * @param string $fileId The ID of the file.
205 * @param string $mimeType Required. The MIME type of the format requested for
206 * this export.
207 * @param array $optParams Optional parameters.
208 * @throws \Google\Service\Exception
209 */
210 public function export($fileId, $mimeType, $optParams = [])
211 {
212 $params = ['fileId' => $fileId, 'mimeType' => $mimeType];
213 $params = array_merge($params, $optParams);
214 return $this->call('export', [$params]);
215 }
216 /**
217 * Generates a set of file IDs which can be provided in create or copy requests.
218 * (files.generateIds)
219 *
220 * @param array $optParams Optional parameters.
221 *
222 * @opt_param int count The number of IDs to return.
223 * @opt_param string space The space in which the IDs can be used to create new
224 * files. Supported values are 'drive' and 'appDataFolder'. (Default: 'drive')
225 * @opt_param string type The type of items which the IDs can be used for.
226 * Supported values are 'files' and 'shortcuts'. Note that 'shortcuts' are only
227 * supported in the `drive` 'space'. (Default: 'files')
228 * @return GeneratedIds
229 * @throws \Google\Service\Exception
230 */
231 public function generateIds($optParams = [])
232 {
233 $params = [];
234 $params = array_merge($params, $optParams);
235 return $this->call('generateIds', [$params], GeneratedIds::class);
236 }
237 /**
238 * Gets a file's metadata or content by ID. If you provide the URL parameter
239 * `alt=media`, then the response includes the file contents in the response
240 * body. Downloading content with `alt=media` only works if the file is stored
241 * in Drive. To download Google Docs, Sheets, and Slides use
242 * [`files.export`](/drive/api/reference/rest/v3/files/export) instead. For more
243 * information, see [Download & export files](/drive/api/guides/manage-
244 * downloads). (files.get)
245 *
246 * @param string $fileId The ID of the file.
247 * @param array $optParams Optional parameters.
248 *
249 * @opt_param bool acknowledgeAbuse Whether the user is acknowledging the risk
250 * of downloading known malware or other abusive files. This is only applicable
251 * when the `alt` parameter is set to `media` and the user is the owner of the
252 * file or an organizer of the shared drive in which the file resides.
253 * @opt_param string includeLabels A comma-separated list of IDs of labels to
254 * include in the `labelInfo` part of the response.
255 * @opt_param string includePermissionsForView Specifies which additional view's
256 * permissions to include in the response. Only 'published' is supported.
257 * @opt_param bool supportsAllDrives Whether the requesting application supports
258 * both My Drives and shared drives.
259 * @opt_param bool supportsTeamDrives Deprecated: Use `supportsAllDrives`
260 * instead.
261 * @return DriveFile
262 * @throws \Google\Service\Exception
263 */
264 public function get($fileId, $optParams = [])
265 {
266 $params = ['fileId' => $fileId];
267 $params = array_merge($params, $optParams);
268 return $this->call('get', [$params], DriveFile::class);
269 }
270 /**
271 * Lists the user's files. This method accepts the `q` parameter, which is a
272 * search query combining one or more search terms. For more information, see
273 * the [Search for files & folders](/drive/api/guides/search-files) guide.
274 * *Note:* This method returns *all* files by default, including trashed files.
275 * If you don't want trashed files to appear in the list, use the
276 * `trashed=false` query parameter to remove trashed files from the results.
277 * (files.listFiles)
278 *
279 * @param array $optParams Optional parameters.
280 *
281 * @opt_param string corpora Bodies of items (files/documents) to which the
282 * query applies. Supported bodies are 'user', 'domain', 'drive', and
283 * 'allDrives'. Prefer 'user' or 'drive' to 'allDrives' for efficiency. By
284 * default, corpora is set to 'user'. However, this can change depending on the
285 * filter set through the 'q' parameter.
286 * @opt_param string corpus Deprecated: The source of files to list. Use
287 * 'corpora' instead.
288 * @opt_param string driveId ID of the shared drive to search.
289 * @opt_param bool includeItemsFromAllDrives Whether both My Drive and shared
290 * drive items should be included in results.
291 * @opt_param string includeLabels A comma-separated list of IDs of labels to
292 * include in the `labelInfo` part of the response.
293 * @opt_param string includePermissionsForView Specifies which additional view's
294 * permissions to include in the response. Only 'published' is supported.
295 * @opt_param bool includeTeamDriveItems Deprecated: Use
296 * `includeItemsFromAllDrives` instead.
297 * @opt_param string orderBy A comma-separated list of sort keys. Valid keys
298 * are: * `createdTime`: When the file was created. * `folder`: The folder ID.
299 * This field is sorted using alphabetical ordering. * `modifiedByMeTime`: The
300 * last time the file was modified by the user. * `modifiedTime`: The last time
301 * the file was modified by anyone. * `name`: The name of the file. This field
302 * is sorted using alphabetical ordering, so 1, 12, 2, 22. * `name_natural`: The
303 * name of the file. This field is sorted using natural sort ordering, so 1, 2,
304 * 12, 22. * `quotaBytesUsed`: The number of storage quota bytes used by the
305 * file. * `recency`: The most recent timestamp from the file's date-time
306 * fields. * `sharedWithMeTime`: When the file was shared with the user, if
307 * applicable. * `starred`: Whether the user has starred the file. *
308 * `viewedByMeTime`: The last time the file was viewed by the user. Each key
309 * sorts ascending by default, but can be reversed with the 'desc' modifier.
310 * Example usage: `?orderBy=folder,modifiedTime desc,name`.
311 * @opt_param int pageSize The maximum number of files to return per page.
312 * Partial or empty result pages are possible even before the end of the files
313 * list has been reached.
314 * @opt_param string pageToken The token for continuing a previous list request
315 * on the next page. This should be set to the value of 'nextPageToken' from the
316 * previous response.
317 * @opt_param string q A query for filtering the file results. See the "Search
318 * for files & folders" guide for supported syntax.
319 * @opt_param string spaces A comma-separated list of spaces to query within the
320 * corpora. Supported values are 'drive' and 'appDataFolder'.
321 * @opt_param bool supportsAllDrives Whether the requesting application supports
322 * both My Drives and shared drives.
323 * @opt_param bool supportsTeamDrives Deprecated: Use `supportsAllDrives`
324 * instead.
325 * @opt_param string teamDriveId Deprecated: Use `driveId` instead.
326 * @return FileList
327 * @throws \Google\Service\Exception
328 */
329 public function listFiles($optParams = [])
330 {
331 $params = [];
332 $params = array_merge($params, $optParams);
333 return $this->call('list', [$params], FileList::class);
334 }
335 /**
336 * Lists the labels on a file. (files.listLabels)
337 *
338 * @param string $fileId The ID for the file.
339 * @param array $optParams Optional parameters.
340 *
341 * @opt_param int maxResults The maximum number of labels to return per page.
342 * When not set, defaults to 100.
343 * @opt_param string pageToken The token for continuing a previous list request
344 * on the next page. This should be set to the value of 'nextPageToken' from the
345 * previous response.
346 * @return LabelList
347 * @throws \Google\Service\Exception
348 */
349 public function listLabels($fileId, $optParams = [])
350 {
351 $params = ['fileId' => $fileId];
352 $params = array_merge($params, $optParams);
353 return $this->call('listLabels', [$params], LabelList::class);
354 }
355 /**
356 * Modifies the set of labels applied to a file. Returns a list of the labels
357 * that were added or modified. (files.modifyLabels)
358 *
359 * @param string $fileId The ID of the file to which the labels belong.
360 * @param ModifyLabelsRequest $postBody
361 * @param array $optParams Optional parameters.
362 * @return ModifyLabelsResponse
363 * @throws \Google\Service\Exception
364 */
365 public function modifyLabels($fileId, ModifyLabelsRequest $postBody, $optParams = [])
366 {
367 $params = ['fileId' => $fileId, 'postBody' => $postBody];
368 $params = array_merge($params, $optParams);
369 return $this->call('modifyLabels', [$params], ModifyLabelsResponse::class);
370 }
371 /**
372 * Updates a file's metadata and/or content. When calling this method, only
373 * populate fields in the request that you want to modify. When updating fields,
374 * some fields might be changed automatically, such as `modifiedDate`. This
375 * method supports patch semantics. This method supports an upload* URI and
376 * accepts uploaded media with the following characteristics: - *Maximum file
377 * size:* 5,120 GB - *Accepted Media MIME types:*`*` Note: Specify a valid MIME
378 * type, rather than the literal `*` value. The literal `*` is only used to
379 * indicate that any valid MIME type can be uploaded. For more information on
380 * uploading files, see [Upload file data](/drive/api/guides/manage-uploads).
381 * (files.update)
382 *
383 * @param string $fileId The ID of the file.
384 * @param DriveFile $postBody
385 * @param array $optParams Optional parameters.
386 *
387 * @opt_param string addParents A comma-separated list of parent IDs to add.
388 * @opt_param bool enforceSingleParent Deprecated: Adding files to multiple
389 * folders is no longer supported. Use shortcuts instead.
390 * @opt_param string includeLabels A comma-separated list of IDs of labels to
391 * include in the `labelInfo` part of the response.
392 * @opt_param string includePermissionsForView Specifies which additional view's
393 * permissions to include in the response. Only 'published' is supported.
394 * @opt_param bool keepRevisionForever Whether to set the 'keepForever' field in
395 * the new head revision. This is only applicable to files with binary content
396 * in Google Drive. Only 200 revisions for the file can be kept forever. If the
397 * limit is reached, try deleting pinned revisions.
398 * @opt_param string ocrLanguage A language hint for OCR processing during image
399 * import (ISO 639-1 code).
400 * @opt_param string removeParents A comma-separated list of parent IDs to
401 * remove.
402 * @opt_param bool supportsAllDrives Whether the requesting application supports
403 * both My Drives and shared drives.
404 * @opt_param bool supportsTeamDrives Deprecated: Use `supportsAllDrives`
405 * instead.
406 * @opt_param bool useContentAsIndexableText Whether to use the uploaded content
407 * as indexable text.
408 * @return DriveFile
409 * @throws \Google\Service\Exception
410 */
411 public function update($fileId, DriveFile $postBody, $optParams = [])
412 {
413 $params = ['fileId' => $fileId, 'postBody' => $postBody];
414 $params = array_merge($params, $optParams);
415 return $this->call('update', [$params], DriveFile::class);
416 }
417 /**
418 * Subscribes to changes to a file. (files.watch)
419 *
420 * @param string $fileId The ID of the file.
421 * @param Channel $postBody
422 * @param array $optParams Optional parameters.
423 *
424 * @opt_param bool acknowledgeAbuse Whether the user is acknowledging the risk
425 * of downloading known malware or other abusive files. This is only applicable
426 * when the `alt` parameter is set to `media` and the user is the owner of the
427 * file or an organizer of the shared drive in which the file resides.
428 * @opt_param string includeLabels A comma-separated list of IDs of labels to
429 * include in the `labelInfo` part of the response.
430 * @opt_param string includePermissionsForView Specifies which additional view's
431 * permissions to include in the response. Only 'published' is supported.
432 * @opt_param bool supportsAllDrives Whether the requesting application supports
433 * both My Drives and shared drives.
434 * @opt_param bool supportsTeamDrives Deprecated: Use `supportsAllDrives`
435 * instead.
436 * @return Channel
437 * @throws \Google\Service\Exception
438 */
439 public function watch($fileId, Channel $postBody, $optParams = [])
440 {
441 $params = ['fileId' => $fileId, 'postBody' => $postBody];
442 $params = array_merge($params, $optParams);
443 return $this->call('watch', [$params], Channel::class);
444 }
445}
446
447// Adding a class alias for backwards compatibility with the previous class name.
448class_alias(Files::class, 'Google_Service_Drive_Resource_Files');
Note: See TracBrowser for help on using the repository browser.