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; 24 25/** 26 * The "files" collection of methods. 27 * Typical usage is: 28 * <code> 29 * $driveService = new Google\Service\Drive(...); 30 * $files = $driveService->files; 31 * </code> 32 */ 33class Files extends \Google\Service\Resource 34{ 35 /** 36 * Creates a copy of a file and applies any requested updates with patch 37 * semantics. Folders cannot be copied. (files.copy) 38 * 39 * @param string $fileId The ID of the file. 40 * @param DriveFile $postBody 41 * @param array $optParams Optional parameters. 42 * 43 * @opt_param bool enforceSingleParent Deprecated. Copying files into multiple 44 * folders is no longer supported. Use shortcuts instead. 45 * @opt_param bool ignoreDefaultVisibility Whether to ignore the domain's 46 * default visibility settings for the created file. Domain administrators can 47 * choose to make all uploaded files visible to the domain by default; this 48 * parameter bypasses that behavior for the request. Permissions are still 49 * inherited from parent folders. 50 * @opt_param string includePermissionsForView Specifies which additional view's 51 * permissions to include in the response. Only 'published' is supported. 52 * @opt_param bool keepRevisionForever Whether to set the 'keepForever' field in 53 * the new head revision. This is only applicable to files with binary content 54 * in Google Drive. Only 200 revisions for the file can be kept forever. If the 55 * limit is reached, try deleting pinned revisions. 56 * @opt_param string ocrLanguage A language hint for OCR processing during image 57 * import (ISO 639-1 code). 58 * @opt_param bool supportsAllDrives Whether the requesting application supports 59 * both My Drives and shared drives. 60 * @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead. 61 * @return DriveFile 62 */ 63 public function copy($fileId, DriveFile $postBody, $optParams = []) 64 { 65 $params = ['fileId' => $fileId, 'postBody' => $postBody]; 66 $params = array_merge($params, $optParams); 67 return $this->call('copy', [$params], DriveFile::class); 68 } 69 /** 70 * Creates a new file. (files.create) 71 * 72 * @param DriveFile $postBody 73 * @param array $optParams Optional parameters. 74 * 75 * @opt_param bool enforceSingleParent Deprecated. Creating files in multiple 76 * folders is no longer supported. 77 * @opt_param bool ignoreDefaultVisibility Whether to ignore the domain's 78 * default visibility settings for the created file. Domain administrators can 79 * choose to make all uploaded files visible to the domain by default; this 80 * parameter bypasses that behavior for the request. Permissions are still 81 * inherited from parent folders. 82 * @opt_param string includePermissionsForView Specifies which additional view's 83 * permissions to include in the response. Only 'published' is supported. 84 * @opt_param bool keepRevisionForever Whether to set the 'keepForever' field in 85 * the new head revision. This is only applicable to files with binary content 86 * in Google Drive. Only 200 revisions for the file can be kept forever. If the 87 * limit is reached, try deleting pinned revisions. 88 * @opt_param string ocrLanguage A language hint for OCR processing during image 89 * import (ISO 639-1 code). 90 * @opt_param bool supportsAllDrives Whether the requesting application supports 91 * both My Drives and shared drives. 92 * @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead. 93 * @opt_param bool useContentAsIndexableText Whether to use the uploaded content 94 * as indexable text. 95 * @return DriveFile 96 */ 97 public function create(DriveFile $postBody, $optParams = []) 98 { 99 $params = ['postBody' => $postBody]; 100 $params = array_merge($params, $optParams); 101 return $this->call('create', [$params], DriveFile::class); 102 } 103 /** 104 * Permanently deletes a file owned by the user without moving it to the trash. 105 * If the file belongs to a shared drive the user must be an organizer on the 106 * parent. If the target is a folder, all descendants owned by the user are also 107 * deleted. (files.delete) 108 * 109 * @param string $fileId The ID of the file. 110 * @param array $optParams Optional parameters. 111 * 112 * @opt_param bool enforceSingleParent Deprecated. If an item is not in a shared 113 * drive and its last parent is deleted but the item itself is not, the item 114 * will be placed under its owner's root. 115 * @opt_param bool supportsAllDrives Whether the requesting application supports 116 * both My Drives and shared drives. 117 * @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead. 118 */ 119 public function delete($fileId, $optParams = []) 120 { 121 $params = ['fileId' => $fileId]; 122 $params = array_merge($params, $optParams); 123 return $this->call('delete', [$params]); 124 } 125 /** 126 * Permanently deletes all of the user's trashed files. (files.emptyTrash) 127 * 128 * @param array $optParams Optional parameters. 129 * 130 * @opt_param bool enforceSingleParent Deprecated. If an item is not in a shared 131 * drive and its last parent is deleted but the item itself is not, the item 132 * will be placed under its owner's root. 133 */ 134 public function emptyTrash($optParams = []) 135 { 136 $params = []; 137 $params = array_merge($params, $optParams); 138 return $this->call('emptyTrash', [$params]); 139 } 140 /** 141 * Exports a Google Workspace document to the requested MIME type and returns 142 * exported byte content. Note that the exported content is limited to 10MB. 143 * (files.export) 144 * 145 * @param string $fileId The ID of the file. 146 * @param string $mimeType The MIME type of the format requested for this 147 * export. 148 * @param array $optParams Optional parameters. 149 */ 150 public function export($fileId, $mimeType, $optParams = []) 151 { 152 $params = ['fileId' => $fileId, 'mimeType' => $mimeType]; 153 $params = array_merge($params, $optParams); 154 return $this->call('export', [$params]); 155 } 156 /** 157 * Generates a set of file IDs which can be provided in create or copy requests. 158 * (files.generateIds) 159 * 160 * @param array $optParams Optional parameters. 161 * 162 * @opt_param int count The number of IDs to return. 163 * @opt_param string space The space in which the IDs can be used to create new 164 * files. Supported values are 'drive' and 'appDataFolder'. (Default: 'drive') 165 * @opt_param string type The type of items which the IDs can be used for. 166 * Supported values are 'files' and 'shortcuts'. Note that 'shortcuts' are only 167 * supported in the drive 'space'. (Default: 'files') 168 * @return GeneratedIds 169 */ 170 public function generateIds($optParams = []) 171 { 172 $params = []; 173 $params = array_merge($params, $optParams); 174 return $this->call('generateIds', [$params], GeneratedIds::class); 175 } 176 /** 177 * Gets a file's metadata or content by ID. (files.get) 178 * 179 * @param string $fileId The ID of the file. 180 * @param array $optParams Optional parameters. 181 * 182 * @opt_param bool acknowledgeAbuse Whether the user is acknowledging the risk 183 * of downloading known malware or other abusive files. This is only applicable 184 * when alt=media. 185 * @opt_param string includePermissionsForView Specifies which additional view's 186 * permissions to include in the response. Only 'published' is supported. 187 * @opt_param bool supportsAllDrives Whether the requesting application supports 188 * both My Drives and shared drives. 189 * @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead. 190 * @return DriveFile 191 */ 192 public function get($fileId, $optParams = []) 193 { 194 $params = ['fileId' => $fileId]; 195 $params = array_merge($params, $optParams); 196 return $this->call('get', [$params], DriveFile::class); 197 } 198 /** 199 * Lists or searches files. (files.listFiles) 200 * 201 * @param array $optParams Optional parameters. 202 * 203 * @opt_param string corpora Groupings of files to which the query applies. 204 * Supported groupings are: 'user' (files created by, opened by, or shared 205 * directly with the user), 'drive' (files in the specified shared drive as 206 * indicated by the 'driveId'), 'domain' (files shared to the user's domain), 207 * and 'allDrives' (A combination of 'user' and 'drive' for all drives where the 208 * user is a member). When able, use 'user' or 'drive', instead of 'allDrives', 209 * for efficiency. 210 * @opt_param string corpus The source of files to list. Deprecated: use 211 * 'corpora' instead. 212 * @opt_param string driveId ID of the shared drive to search. 213 * @opt_param bool includeItemsFromAllDrives Whether both My Drive and shared 214 * drive items should be included in results. 215 * @opt_param string includePermissionsForView Specifies which additional view's 216 * permissions to include in the response. Only 'published' is supported. 217 * @opt_param bool includeTeamDriveItems Deprecated use 218 * includeItemsFromAllDrives instead. 219 * @opt_param string orderBy A comma-separated list of sort keys. Valid keys are 220 * 'createdTime', 'folder', 'modifiedByMeTime', 'modifiedTime', 'name', 221 * 'name_natural', 'quotaBytesUsed', 'recency', 'sharedWithMeTime', 'starred', 222 * and 'viewedByMeTime'. Each key sorts ascending by default, but may be 223 * reversed with the 'desc' modifier. Example usage: 224 * ?orderBy=folder,modifiedTime desc,name. Please note that there is a current 225 * limitation for users with approximately one million files in which the 226 * requested sort order is ignored. 227 * @opt_param int pageSize The maximum number of files to return per page. 228 * Partial or empty result pages are possible even before the end of the files 229 * list has been reached. 230 * @opt_param string pageToken The token for continuing a previous list request 231 * on the next page. This should be set to the value of 'nextPageToken' from the 232 * previous response. 233 * @opt_param string q A query for filtering the file results. See the "Search 234 * for Files" guide for supported syntax. 235 * @opt_param string spaces A comma-separated list of spaces to query within the 236 * corpus. Supported values are 'drive' and 'appDataFolder'. 237 * @opt_param bool supportsAllDrives Whether the requesting application supports 238 * both My Drives and shared drives. 239 * @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead. 240 * @opt_param string teamDriveId Deprecated use driveId instead. 241 * @return FileList 242 */ 243 public function listFiles($optParams = []) 244 { 245 $params = []; 246 $params = array_merge($params, $optParams); 247 return $this->call('list', [$params], FileList::class); 248 } 249 /** 250 * Updates a file's metadata and/or content. When calling this method, only 251 * populate fields in the request that you want to modify. When updating fields, 252 * some fields might change automatically, such as modifiedDate. This method 253 * supports patch semantics. (files.update) 254 * 255 * @param string $fileId The ID of the file. 256 * @param DriveFile $postBody 257 * @param array $optParams Optional parameters. 258 * 259 * @opt_param string addParents A comma-separated list of parent IDs to add. 260 * @opt_param bool enforceSingleParent Deprecated. Adding files to multiple 261 * folders is no longer supported. Use shortcuts instead. 262 * @opt_param string includePermissionsForView Specifies which additional view's 263 * permissions to include in the response. Only 'published' is supported. 264 * @opt_param bool keepRevisionForever Whether to set the 'keepForever' field in 265 * the new head revision. This is only applicable to files with binary content 266 * in Google Drive. Only 200 revisions for the file can be kept forever. If the 267 * limit is reached, try deleting pinned revisions. 268 * @opt_param string ocrLanguage A language hint for OCR processing during image 269 * import (ISO 639-1 code). 270 * @opt_param string removeParents A comma-separated list of parent IDs to 271 * remove. 272 * @opt_param bool supportsAllDrives Whether the requesting application supports 273 * both My Drives and shared drives. 274 * @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead. 275 * @opt_param bool useContentAsIndexableText Whether to use the uploaded content 276 * as indexable text. 277 * @return DriveFile 278 */ 279 public function update($fileId, DriveFile $postBody, $optParams = []) 280 { 281 $params = ['fileId' => $fileId, 'postBody' => $postBody]; 282 $params = array_merge($params, $optParams); 283 return $this->call('update', [$params], DriveFile::class); 284 } 285 /** 286 * Subscribes to changes to a file. While you can establish a channel for 287 * changes to a file on a shared drive, a change to a shared drive file won't 288 * create a notification. (files.watch) 289 * 290 * @param string $fileId The ID of the file. 291 * @param Channel $postBody 292 * @param array $optParams Optional parameters. 293 * 294 * @opt_param bool acknowledgeAbuse Whether the user is acknowledging the risk 295 * of downloading known malware or other abusive files. This is only applicable 296 * when alt=media. 297 * @opt_param string includePermissionsForView Specifies which additional view's 298 * permissions to include in the response. Only 'published' is supported. 299 * @opt_param bool supportsAllDrives Whether the requesting application supports 300 * both My Drives and shared drives. 301 * @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead. 302 * @return Channel 303 */ 304 public function watch($fileId, Channel $postBody, $optParams = []) 305 { 306 $params = ['fileId' => $fileId, 'postBody' => $postBody]; 307 $params = array_merge($params, $optParams); 308 return $this->call('watch', [$params], Channel::class); 309 } 310} 311 312// Adding a class alias for backwards compatibility with the previous class name. 313class_alias(Files::class, 'Google_Service_Drive_Resource_Files'); 314