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\CloudResourceManager\Resource;
|
---|
19 |
|
---|
20 | use Google\Service\CloudResourceManager\Folder;
|
---|
21 | use Google\Service\CloudResourceManager\GetIamPolicyRequest;
|
---|
22 | use Google\Service\CloudResourceManager\ListFoldersResponse;
|
---|
23 | use Google\Service\CloudResourceManager\MoveFolderRequest;
|
---|
24 | use Google\Service\CloudResourceManager\Operation;
|
---|
25 | use Google\Service\CloudResourceManager\Policy;
|
---|
26 | use Google\Service\CloudResourceManager\SearchFoldersResponse;
|
---|
27 | use Google\Service\CloudResourceManager\SetIamPolicyRequest;
|
---|
28 | use Google\Service\CloudResourceManager\TestIamPermissionsRequest;
|
---|
29 | use Google\Service\CloudResourceManager\TestIamPermissionsResponse;
|
---|
30 | use Google\Service\CloudResourceManager\UndeleteFolderRequest;
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * The "folders" collection of methods.
|
---|
34 | * Typical usage is:
|
---|
35 | * <code>
|
---|
36 | * $cloudresourcemanagerService = new Google\Service\CloudResourceManager(...);
|
---|
37 | * $folders = $cloudresourcemanagerService->folders;
|
---|
38 | * </code>
|
---|
39 | */
|
---|
40 | class Folders extends \Google\Service\Resource
|
---|
41 | {
|
---|
42 | /**
|
---|
43 | * Creates a folder in the resource hierarchy. Returns an `Operation` which can
|
---|
44 | * be used to track the progress of the folder creation workflow. Upon success,
|
---|
45 | * the `Operation.response` field will be populated with the created Folder. In
|
---|
46 | * order to succeed, the addition of this new folder must not violate the folder
|
---|
47 | * naming, height, or fanout constraints. + The folder's `display_name` must be
|
---|
48 | * distinct from all other folders that share its parent. + The addition of the
|
---|
49 | * folder must not cause the active folder hierarchy to exceed a height of 10.
|
---|
50 | * Note, the full active + deleted folder hierarchy is allowed to reach a height
|
---|
51 | * of 20; this provides additional headroom when moving folders that contain
|
---|
52 | * deleted folders. + The addition of the folder must not cause the total number
|
---|
53 | * of folders under its parent to exceed 300. If the operation fails due to a
|
---|
54 | * folder constraint violation, some errors may be returned by the
|
---|
55 | * `CreateFolder` request, with status code `FAILED_PRECONDITION` and an error
|
---|
56 | * description. Other folder constraint violations will be communicated in the
|
---|
57 | * `Operation`, with the specific `PreconditionFailure` returned in the details
|
---|
58 | * list in the `Operation.error` field. The caller must have
|
---|
59 | * `resourcemanager.folders.create` permission on the identified parent.
|
---|
60 | * (folders.create)
|
---|
61 | *
|
---|
62 | * @param Folder $postBody
|
---|
63 | * @param array $optParams Optional parameters.
|
---|
64 | * @return Operation
|
---|
65 | * @throws \Google\Service\Exception
|
---|
66 | */
|
---|
67 | public function create(Folder $postBody, $optParams = [])
|
---|
68 | {
|
---|
69 | $params = ['postBody' => $postBody];
|
---|
70 | $params = array_merge($params, $optParams);
|
---|
71 | return $this->call('create', [$params], Operation::class);
|
---|
72 | }
|
---|
73 | /**
|
---|
74 | * Requests deletion of a folder. The folder is moved into the DELETE_REQUESTED
|
---|
75 | * state immediately, and is deleted approximately 30 days later. This method
|
---|
76 | * may only be called on an empty folder, where a folder is empty if it doesn't
|
---|
77 | * contain any folders or projects in the ACTIVE state. If called on a folder in
|
---|
78 | * DELETE_REQUESTED state the operation will result in a no-op success. The
|
---|
79 | * caller must have `resourcemanager.folders.delete` permission on the
|
---|
80 | * identified folder. (folders.delete)
|
---|
81 | *
|
---|
82 | * @param string $name Required. The resource name of the folder to be deleted.
|
---|
83 | * Must be of the form `folders/{folder_id}`.
|
---|
84 | * @param array $optParams Optional parameters.
|
---|
85 | * @return Operation
|
---|
86 | * @throws \Google\Service\Exception
|
---|
87 | */
|
---|
88 | public function delete($name, $optParams = [])
|
---|
89 | {
|
---|
90 | $params = ['name' => $name];
|
---|
91 | $params = array_merge($params, $optParams);
|
---|
92 | return $this->call('delete', [$params], Operation::class);
|
---|
93 | }
|
---|
94 | /**
|
---|
95 | * Retrieves a folder identified by the supplied resource name. Valid folder
|
---|
96 | * resource names have the format `folders/{folder_id}` (for example,
|
---|
97 | * `folders/1234`). The caller must have `resourcemanager.folders.get`
|
---|
98 | * permission on the identified folder. (folders.get)
|
---|
99 | *
|
---|
100 | * @param string $name Required. The resource name of the folder to retrieve.
|
---|
101 | * Must be of the form `folders/{folder_id}`.
|
---|
102 | * @param array $optParams Optional parameters.
|
---|
103 | * @return Folder
|
---|
104 | * @throws \Google\Service\Exception
|
---|
105 | */
|
---|
106 | public function get($name, $optParams = [])
|
---|
107 | {
|
---|
108 | $params = ['name' => $name];
|
---|
109 | $params = array_merge($params, $optParams);
|
---|
110 | return $this->call('get', [$params], Folder::class);
|
---|
111 | }
|
---|
112 | /**
|
---|
113 | * Gets the access control policy for a folder. The returned policy may be empty
|
---|
114 | * if no such policy or resource exists. The `resource` field should be the
|
---|
115 | * folder's resource name, for example: "folders/1234". The caller must have
|
---|
116 | * `resourcemanager.folders.getIamPolicy` permission on the identified folder.
|
---|
117 | * (folders.getIamPolicy)
|
---|
118 | *
|
---|
119 | * @param string $resource REQUIRED: The resource for which the policy is being
|
---|
120 | * requested. See [Resource
|
---|
121 | * names](https://cloud.google.com/apis/design/resource_names) for the
|
---|
122 | * appropriate value for this field.
|
---|
123 | * @param GetIamPolicyRequest $postBody
|
---|
124 | * @param array $optParams Optional parameters.
|
---|
125 | * @return Policy
|
---|
126 | * @throws \Google\Service\Exception
|
---|
127 | */
|
---|
128 | public function getIamPolicy($resource, GetIamPolicyRequest $postBody, $optParams = [])
|
---|
129 | {
|
---|
130 | $params = ['resource' => $resource, 'postBody' => $postBody];
|
---|
131 | $params = array_merge($params, $optParams);
|
---|
132 | return $this->call('getIamPolicy', [$params], Policy::class);
|
---|
133 | }
|
---|
134 | /**
|
---|
135 | * Lists the folders that are direct descendants of supplied parent resource.
|
---|
136 | * `list()` provides a strongly consistent view of the folders underneath the
|
---|
137 | * specified parent resource. `list()` returns folders sorted based upon the
|
---|
138 | * (ascending) lexical ordering of their display_name. The caller must have
|
---|
139 | * `resourcemanager.folders.list` permission on the identified parent.
|
---|
140 | * (folders.listFolders)
|
---|
141 | *
|
---|
142 | * @param array $optParams Optional parameters.
|
---|
143 | *
|
---|
144 | * @opt_param int pageSize Optional. The maximum number of folders to return in
|
---|
145 | * the response. The server can return fewer folders than requested. If
|
---|
146 | * unspecified, server picks an appropriate default.
|
---|
147 | * @opt_param string pageToken Optional. A pagination token returned from a
|
---|
148 | * previous call to `ListFolders` that indicates where this listing should
|
---|
149 | * continue from.
|
---|
150 | * @opt_param string parent Required. The name of the parent resource whose
|
---|
151 | * folders are being listed. Only children of this parent resource are listed;
|
---|
152 | * descendants are not listed. If the parent is a folder, use the value
|
---|
153 | * `folders/{folder_id}`. If the parent is an organization, use the value
|
---|
154 | * `organizations/{org_id}`. Access to this method is controlled by checking the
|
---|
155 | * `resourcemanager.folders.list` permission on the `parent`.
|
---|
156 | * @opt_param bool showDeleted Optional. Controls whether folders in the
|
---|
157 | * DELETE_REQUESTED state should be returned. Defaults to false.
|
---|
158 | * @return ListFoldersResponse
|
---|
159 | * @throws \Google\Service\Exception
|
---|
160 | */
|
---|
161 | public function listFolders($optParams = [])
|
---|
162 | {
|
---|
163 | $params = [];
|
---|
164 | $params = array_merge($params, $optParams);
|
---|
165 | return $this->call('list', [$params], ListFoldersResponse::class);
|
---|
166 | }
|
---|
167 | /**
|
---|
168 | * Moves a folder under a new resource parent. Returns an `Operation` which can
|
---|
169 | * be used to track the progress of the folder move workflow. Upon success, the
|
---|
170 | * `Operation.response` field will be populated with the moved folder. Upon
|
---|
171 | * failure, a `FolderOperationError` categorizing the failure cause will be
|
---|
172 | * returned - if the failure occurs synchronously then the
|
---|
173 | * `FolderOperationError` will be returned in the `Status.details` field. If it
|
---|
174 | * occurs asynchronously, then the FolderOperation will be returned in the
|
---|
175 | * `Operation.error` field. In addition, the `Operation.metadata` field will be
|
---|
176 | * populated with a `FolderOperation` message as an aid to stateless clients.
|
---|
177 | * Folder moves will be rejected if they violate either the naming, height, or
|
---|
178 | * fanout constraints described in the CreateFolder documentation. The caller
|
---|
179 | * must have `resourcemanager.folders.move` permission on the folder's current
|
---|
180 | * and proposed new parent. (folders.move)
|
---|
181 | *
|
---|
182 | * @param string $name Required. The resource name of the Folder to move. Must
|
---|
183 | * be of the form folders/{folder_id}
|
---|
184 | * @param MoveFolderRequest $postBody
|
---|
185 | * @param array $optParams Optional parameters.
|
---|
186 | * @return Operation
|
---|
187 | * @throws \Google\Service\Exception
|
---|
188 | */
|
---|
189 | public function move($name, MoveFolderRequest $postBody, $optParams = [])
|
---|
190 | {
|
---|
191 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
192 | $params = array_merge($params, $optParams);
|
---|
193 | return $this->call('move', [$params], Operation::class);
|
---|
194 | }
|
---|
195 | /**
|
---|
196 | * Updates a folder, changing its `display_name`. Changes to the folder
|
---|
197 | * `display_name` will be rejected if they violate either the `display_name`
|
---|
198 | * formatting rules or the naming constraints described in the CreateFolder
|
---|
199 | * documentation. The folder's `display_name` must start and end with a letter
|
---|
200 | * or digit, may contain letters, digits, spaces, hyphens and underscores and
|
---|
201 | * can be between 3 and 30 characters. This is captured by the regular
|
---|
202 | * expression: `\p{L}\p{N}{1,28}[\p{L}\p{N}]`. The caller must have
|
---|
203 | * `resourcemanager.folders.update` permission on the identified folder. If the
|
---|
204 | * update fails due to the unique name constraint then a `PreconditionFailure`
|
---|
205 | * explaining this violation will be returned in the Status.details field.
|
---|
206 | * (folders.patch)
|
---|
207 | *
|
---|
208 | * @param string $name Output only. The resource name of the folder. Its format
|
---|
209 | * is `folders/{folder_id}`, for example: "folders/1234".
|
---|
210 | * @param Folder $postBody
|
---|
211 | * @param array $optParams Optional parameters.
|
---|
212 | *
|
---|
213 | * @opt_param string updateMask Required. Fields to be updated. Only the
|
---|
214 | * `display_name` can be updated.
|
---|
215 | * @return Operation
|
---|
216 | * @throws \Google\Service\Exception
|
---|
217 | */
|
---|
218 | public function patch($name, Folder $postBody, $optParams = [])
|
---|
219 | {
|
---|
220 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
221 | $params = array_merge($params, $optParams);
|
---|
222 | return $this->call('patch', [$params], Operation::class);
|
---|
223 | }
|
---|
224 | /**
|
---|
225 | * Search for folders that match specific filter criteria. `search()` provides
|
---|
226 | * an eventually consistent view of the folders a user has access to which meet
|
---|
227 | * the specified filter criteria. This will only return folders on which the
|
---|
228 | * caller has the permission `resourcemanager.folders.get`. (folders.search)
|
---|
229 | *
|
---|
230 | * @param array $optParams Optional parameters.
|
---|
231 | *
|
---|
232 | * @opt_param int pageSize Optional. The maximum number of folders to return in
|
---|
233 | * the response. The server can return fewer folders than requested. If
|
---|
234 | * unspecified, server picks an appropriate default.
|
---|
235 | * @opt_param string pageToken Optional. A pagination token returned from a
|
---|
236 | * previous call to `SearchFolders` that indicates from where search should
|
---|
237 | * continue.
|
---|
238 | * @opt_param string query Optional. Search criteria used to select the folders
|
---|
239 | * to return. If no search criteria is specified then all accessible folders
|
---|
240 | * will be returned. Query expressions can be used to restrict results based
|
---|
241 | * upon displayName, state and parent, where the operators `=` (`:`) `NOT`,
|
---|
242 | * `AND` and `OR` can be used along with the suffix wildcard symbol `*`. The
|
---|
243 | * `displayName` field in a query expression should use escaped quotes for
|
---|
244 | * values that include whitespace to prevent unexpected behavior. ``` | Field |
|
---|
245 | * Description |
|
---|
246 | * |-------------------------|----------------------------------------| |
|
---|
247 | * displayName | Filters by displayName. | | parent | Filters by parent (for
|
---|
248 | * example: folders/123). | | state, lifecycleState | Filters by state. | ```
|
---|
249 | * Some example queries are: * Query `displayName=Test*` returns Folder
|
---|
250 | * resources whose display name starts with "Test". * Query `state=ACTIVE`
|
---|
251 | * returns Folder resources with `state` set to `ACTIVE`. * Query
|
---|
252 | * `parent=folders/123` returns Folder resources that have `folders/123` as a
|
---|
253 | * parent resource. * Query `parent=folders/123 AND state=ACTIVE` returns active
|
---|
254 | * Folder resources that have `folders/123` as a parent resource. * Query
|
---|
255 | * `displayName=\\"Test String\\"` returns Folder resources with display names
|
---|
256 | * that include both "Test" and "String".
|
---|
257 | * @return SearchFoldersResponse
|
---|
258 | * @throws \Google\Service\Exception
|
---|
259 | */
|
---|
260 | public function search($optParams = [])
|
---|
261 | {
|
---|
262 | $params = [];
|
---|
263 | $params = array_merge($params, $optParams);
|
---|
264 | return $this->call('search', [$params], SearchFoldersResponse::class);
|
---|
265 | }
|
---|
266 | /**
|
---|
267 | * Sets the access control policy on a folder, replacing any existing policy.
|
---|
268 | * The `resource` field should be the folder's resource name, for example:
|
---|
269 | * "folders/1234". The caller must have `resourcemanager.folders.setIamPolicy`
|
---|
270 | * permission on the identified folder. (folders.setIamPolicy)
|
---|
271 | *
|
---|
272 | * @param string $resource REQUIRED: The resource for which the policy is being
|
---|
273 | * specified. See [Resource
|
---|
274 | * names](https://cloud.google.com/apis/design/resource_names) for the
|
---|
275 | * appropriate value for this field.
|
---|
276 | * @param SetIamPolicyRequest $postBody
|
---|
277 | * @param array $optParams Optional parameters.
|
---|
278 | * @return Policy
|
---|
279 | * @throws \Google\Service\Exception
|
---|
280 | */
|
---|
281 | public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
|
---|
282 | {
|
---|
283 | $params = ['resource' => $resource, 'postBody' => $postBody];
|
---|
284 | $params = array_merge($params, $optParams);
|
---|
285 | return $this->call('setIamPolicy', [$params], Policy::class);
|
---|
286 | }
|
---|
287 | /**
|
---|
288 | * Returns permissions that a caller has on the specified folder. The `resource`
|
---|
289 | * field should be the folder's resource name, for example: "folders/1234".
|
---|
290 | * There are no permissions required for making this API call.
|
---|
291 | * (folders.testIamPermissions)
|
---|
292 | *
|
---|
293 | * @param string $resource REQUIRED: The resource for which the policy detail is
|
---|
294 | * being requested. See [Resource
|
---|
295 | * names](https://cloud.google.com/apis/design/resource_names) for the
|
---|
296 | * appropriate value for this field.
|
---|
297 | * @param TestIamPermissionsRequest $postBody
|
---|
298 | * @param array $optParams Optional parameters.
|
---|
299 | * @return TestIamPermissionsResponse
|
---|
300 | * @throws \Google\Service\Exception
|
---|
301 | */
|
---|
302 | public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = [])
|
---|
303 | {
|
---|
304 | $params = ['resource' => $resource, 'postBody' => $postBody];
|
---|
305 | $params = array_merge($params, $optParams);
|
---|
306 | return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
|
---|
307 | }
|
---|
308 | /**
|
---|
309 | * Cancels the deletion request for a folder. This method may be called on a
|
---|
310 | * folder in any state. If the folder is in the ACTIVE state the result will be
|
---|
311 | * a no-op success. In order to succeed, the folder's parent must be in the
|
---|
312 | * ACTIVE state. In addition, reintroducing the folder into the tree must not
|
---|
313 | * violate folder naming, height, and fanout constraints described in the
|
---|
314 | * CreateFolder documentation. The caller must have
|
---|
315 | * `resourcemanager.folders.undelete` permission on the identified folder.
|
---|
316 | * (folders.undelete)
|
---|
317 | *
|
---|
318 | * @param string $name Required. The resource name of the folder to undelete.
|
---|
319 | * Must be of the form `folders/{folder_id}`.
|
---|
320 | * @param UndeleteFolderRequest $postBody
|
---|
321 | * @param array $optParams Optional parameters.
|
---|
322 | * @return Operation
|
---|
323 | * @throws \Google\Service\Exception
|
---|
324 | */
|
---|
325 | public function undelete($name, UndeleteFolderRequest $postBody, $optParams = [])
|
---|
326 | {
|
---|
327 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
328 | $params = array_merge($params, $optParams);
|
---|
329 | return $this->call('undelete', [$params], Operation::class);
|
---|
330 | }
|
---|
331 | }
|
---|
332 |
|
---|
333 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
334 | class_alias(Folders::class, 'Google_Service_CloudResourceManager_Resource_Folders');
|
---|