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\Permission; 21use Google\Service\Drive\PermissionList; 22 23/** 24 * The "permissions" collection of methods. 25 * Typical usage is: 26 * <code> 27 * $driveService = new Google\Service\Drive(...); 28 * $permissions = $driveService->permissions; 29 * </code> 30 */ 31class Permissions extends \Google\Service\Resource 32{ 33 /** 34 * Creates a permission for a file or shared drive. (permissions.create) 35 * 36 * @param string $fileId The ID of the file or shared drive. 37 * @param Permission $postBody 38 * @param array $optParams Optional parameters. 39 * 40 * @opt_param string emailMessage A plain text custom message to include in the 41 * notification email. 42 * @opt_param bool enforceSingleParent Deprecated. See moveToNewOwnersRoot for 43 * details. 44 * @opt_param bool moveToNewOwnersRoot This parameter will only take effect if 45 * the item is not in a shared drive and the request is attempting to transfer 46 * the ownership of the item. If set to true, the item will be moved to the new 47 * owner's My Drive root folder and all prior parents removed. If set to false, 48 * parents are not changed. 49 * @opt_param bool sendNotificationEmail Whether to send a notification email 50 * when sharing to users or groups. This defaults to true for users and groups, 51 * and is not allowed for other requests. It must not be disabled for ownership 52 * transfers. 53 * @opt_param bool supportsAllDrives Whether the requesting application supports 54 * both My Drives and shared drives. 55 * @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead. 56 * @opt_param bool transferOwnership Whether to transfer ownership to the 57 * specified user and downgrade the current owner to a writer. This parameter is 58 * required as an acknowledgement of the side effect. File owners can only 59 * transfer ownership of files existing on My Drive. Files existing in a shared 60 * drive are owned by the organization that owns that shared drive. Ownership 61 * transfers are not supported for files and folders in shared drives. 62 * Organizers of a shared drive can move items from that shared drive into their 63 * My Drive which transfers the ownership to them. 64 * @opt_param bool useDomainAdminAccess Issue the request as a domain 65 * administrator; if set to true, then the requester will be granted access if 66 * the file ID parameter refers to a shared drive and the requester is an 67 * administrator of the domain to which the shared drive belongs. 68 * @return Permission 69 */ 70 public function create($fileId, Permission $postBody, $optParams = []) 71 { 72 $params = ['fileId' => $fileId, 'postBody' => $postBody]; 73 $params = array_merge($params, $optParams); 74 return $this->call('create', [$params], Permission::class); 75 } 76 /** 77 * Deletes a permission. (permissions.delete) 78 * 79 * @param string $fileId The ID of the file or shared drive. 80 * @param string $permissionId The ID of the permission. 81 * @param array $optParams Optional parameters. 82 * 83 * @opt_param bool supportsAllDrives Whether the requesting application supports 84 * both My Drives and shared drives. 85 * @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead. 86 * @opt_param bool useDomainAdminAccess Issue the request as a domain 87 * administrator; if set to true, then the requester will be granted access if 88 * the file ID parameter refers to a shared drive and the requester is an 89 * administrator of the domain to which the shared drive belongs. 90 */ 91 public function delete($fileId, $permissionId, $optParams = []) 92 { 93 $params = ['fileId' => $fileId, 'permissionId' => $permissionId]; 94 $params = array_merge($params, $optParams); 95 return $this->call('delete', [$params]); 96 } 97 /** 98 * Gets a permission by ID. (permissions.get) 99 * 100 * @param string $fileId The ID of the file. 101 * @param string $permissionId The ID of the permission. 102 * @param array $optParams Optional parameters. 103 * 104 * @opt_param bool supportsAllDrives Whether the requesting application supports 105 * both My Drives and shared drives. 106 * @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead. 107 * @opt_param bool useDomainAdminAccess Issue the request as a domain 108 * administrator; if set to true, then the requester will be granted access if 109 * the file ID parameter refers to a shared drive and the requester is an 110 * administrator of the domain to which the shared drive belongs. 111 * @return Permission 112 */ 113 public function get($fileId, $permissionId, $optParams = []) 114 { 115 $params = ['fileId' => $fileId, 'permissionId' => $permissionId]; 116 $params = array_merge($params, $optParams); 117 return $this->call('get', [$params], Permission::class); 118 } 119 /** 120 * Lists a file's or shared drive's permissions. (permissions.listPermissions) 121 * 122 * @param string $fileId The ID of the file or shared drive. 123 * @param array $optParams Optional parameters. 124 * 125 * @opt_param string includePermissionsForView Specifies which additional view's 126 * permissions to include in the response. Only 'published' is supported. 127 * @opt_param int pageSize The maximum number of permissions to return per page. 128 * When not set for files in a shared drive, at most 100 results will be 129 * returned. When not set for files that are not in a shared drive, the entire 130 * list will be returned. 131 * @opt_param string pageToken The token for continuing a previous list request 132 * on the next page. This should be set to the value of 'nextPageToken' from the 133 * previous response. 134 * @opt_param bool supportsAllDrives Whether the requesting application supports 135 * both My Drives and shared drives. 136 * @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead. 137 * @opt_param bool useDomainAdminAccess Issue the request as a domain 138 * administrator; if set to true, then the requester will be granted access if 139 * the file ID parameter refers to a shared drive and the requester is an 140 * administrator of the domain to which the shared drive belongs. 141 * @return PermissionList 142 */ 143 public function listPermissions($fileId, $optParams = []) 144 { 145 $params = ['fileId' => $fileId]; 146 $params = array_merge($params, $optParams); 147 return $this->call('list', [$params], PermissionList::class); 148 } 149 /** 150 * Updates a permission with patch semantics. (permissions.update) 151 * 152 * @param string $fileId The ID of the file or shared drive. 153 * @param string $permissionId The ID of the permission. 154 * @param Permission $postBody 155 * @param array $optParams Optional parameters. 156 * 157 * @opt_param bool removeExpiration Whether to remove the expiration date. 158 * @opt_param bool supportsAllDrives Whether the requesting application supports 159 * both My Drives and shared drives. 160 * @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead. 161 * @opt_param bool transferOwnership Whether to transfer ownership to the 162 * specified user and downgrade the current owner to a writer. This parameter is 163 * required as an acknowledgement of the side effect. File owners can only 164 * transfer ownership of files existing on My Drive. Files existing in a shared 165 * drive are owned by the organization that owns that shared drive. Ownership 166 * transfers are not supported for files and folders in shared drives. 167 * Organizers of a shared drive can move items from that shared drive into their 168 * My Drive which transfers the ownership to them. 169 * @opt_param bool useDomainAdminAccess Issue the request as a domain 170 * administrator; if set to true, then the requester will be granted access if 171 * the file ID parameter refers to a shared drive and the requester is an 172 * administrator of the domain to which the shared drive belongs. 173 * @return Permission 174 */ 175 public function update($fileId, $permissionId, Permission $postBody, $optParams = []) 176 { 177 $params = ['fileId' => $fileId, 'permissionId' => $permissionId, 'postBody' => $postBody]; 178 $params = array_merge($params, $optParams); 179 return $this->call('update', [$params], Permission::class); 180 } 181} 182 183// Adding a class alias for backwards compatibility with the previous class name. 184class_alias(Permissions::class, 'Google_Service_Drive_Resource_Permissions'); 185