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