PageRenderTime 35ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/google/apiclient-services/src/Drive/Resource/Files.php

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