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\Compute\Resource;
19
20use Google\Service\Compute\Disk;
21use Google\Service\Compute\DiskList;
22use Google\Service\Compute\Operation;
23use Google\Service\Compute\Policy;
24use Google\Service\Compute\RegionDisksAddResourcePoliciesRequest;
25use Google\Service\Compute\RegionDisksRemoveResourcePoliciesRequest;
26use Google\Service\Compute\RegionDisksResizeRequest;
27use Google\Service\Compute\RegionSetLabelsRequest;
28use Google\Service\Compute\RegionSetPolicyRequest;
29use Google\Service\Compute\Snapshot;
30use Google\Service\Compute\TestPermissionsRequest;
31use Google\Service\Compute\TestPermissionsResponse;
32
33/**
34 * The "regionDisks" collection of methods.
35 * Typical usage is:
36 *  <code>
37 *   $computeService = new Google\Service\Compute(...);
38 *   $regionDisks = $computeService->regionDisks;
39 *  </code>
40 */
41class RegionDisks extends \Google\Service\Resource
42{
43  /**
44   * Adds existing resource policies to a regional disk. You can only add one
45   * policy which will be applied to this disk for scheduling snapshot creation.
46   * (regionDisks.addResourcePolicies)
47   *
48   * @param string $project Project ID for this request.
49   * @param string $region The name of the region for this request.
50   * @param string $disk The disk name for this request.
51   * @param RegionDisksAddResourcePoliciesRequest $postBody
52   * @param array $optParams Optional parameters.
53   *
54   * @opt_param string requestId An optional request ID to identify requests.
55   * Specify a unique request ID so that if you must retry your request, the
56   * server will know to ignore the request if it has already been completed. For
57   * example, consider a situation where you make an initial request and the
58   * request times out. If you make the request again with the same request ID,
59   * the server can check if original operation with the same request ID was
60   * received, and if so, will ignore the second request. This prevents clients
61   * from accidentally creating duplicate commitments. The request ID must be a
62   * valid UUID with the exception that zero UUID is not supported (
63   * 00000000-0000-0000-0000-000000000000).
64   * @return Operation
65   */
66  public function addResourcePolicies($project, $region, $disk, RegionDisksAddResourcePoliciesRequest $postBody, $optParams = [])
67  {
68    $params = ['project' => $project, 'region' => $region, 'disk' => $disk, 'postBody' => $postBody];
69    $params = array_merge($params, $optParams);
70    return $this->call('addResourcePolicies', [$params], Operation::class);
71  }
72  /**
73   * Creates a snapshot of a specified persistent disk. For regular snapshot
74   * creation, consider using snapshots.insert instead, as that method supports
75   * more features, such as creating snapshots in a project different from the
76   * source disk project. (regionDisks.createSnapshot)
77   *
78   * @param string $project Project ID for this request.
79   * @param string $region Name of the region for this request.
80   * @param string $disk Name of the regional persistent disk to snapshot.
81   * @param Snapshot $postBody
82   * @param array $optParams Optional parameters.
83   *
84   * @opt_param string requestId An optional request ID to identify requests.
85   * Specify a unique request ID so that if you must retry your request, the
86   * server will know to ignore the request if it has already been completed. For
87   * example, consider a situation where you make an initial request and the
88   * request times out. If you make the request again with the same request ID,
89   * the server can check if original operation with the same request ID was
90   * received, and if so, will ignore the second request. This prevents clients
91   * from accidentally creating duplicate commitments. The request ID must be a
92   * valid UUID with the exception that zero UUID is not supported (
93   * 00000000-0000-0000-0000-000000000000).
94   * @return Operation
95   */
96  public function createSnapshot($project, $region, $disk, Snapshot $postBody, $optParams = [])
97  {
98    $params = ['project' => $project, 'region' => $region, 'disk' => $disk, 'postBody' => $postBody];
99    $params = array_merge($params, $optParams);
100    return $this->call('createSnapshot', [$params], Operation::class);
101  }
102  /**
103   * Deletes the specified regional persistent disk. Deleting a regional disk
104   * removes all the replicas of its data permanently and is irreversible.
105   * However, deleting a disk does not delete any snapshots previously made from
106   * the disk. You must separately delete snapshots. (regionDisks.delete)
107   *
108   * @param string $project Project ID for this request.
109   * @param string $region Name of the region for this request.
110   * @param string $disk Name of the regional persistent disk to delete.
111   * @param array $optParams Optional parameters.
112   *
113   * @opt_param string requestId An optional request ID to identify requests.
114   * Specify a unique request ID so that if you must retry your request, the
115   * server will know to ignore the request if it has already been completed. For
116   * example, consider a situation where you make an initial request and the
117   * request times out. If you make the request again with the same request ID,
118   * the server can check if original operation with the same request ID was
119   * received, and if so, will ignore the second request. This prevents clients
120   * from accidentally creating duplicate commitments. The request ID must be a
121   * valid UUID with the exception that zero UUID is not supported (
122   * 00000000-0000-0000-0000-000000000000).
123   * @return Operation
124   */
125  public function delete($project, $region, $disk, $optParams = [])
126  {
127    $params = ['project' => $project, 'region' => $region, 'disk' => $disk];
128    $params = array_merge($params, $optParams);
129    return $this->call('delete', [$params], Operation::class);
130  }
131  /**
132   * Returns a specified regional persistent disk. (regionDisks.get)
133   *
134   * @param string $project Project ID for this request.
135   * @param string $region Name of the region for this request.
136   * @param string $disk Name of the regional persistent disk to return.
137   * @param array $optParams Optional parameters.
138   * @return Disk
139   */
140  public function get($project, $region, $disk, $optParams = [])
141  {
142    $params = ['project' => $project, 'region' => $region, 'disk' => $disk];
143    $params = array_merge($params, $optParams);
144    return $this->call('get', [$params], Disk::class);
145  }
146  /**
147   * Gets the access control policy for a resource. May be empty if no such policy
148   * or resource exists. (regionDisks.getIamPolicy)
149   *
150   * @param string $project Project ID for this request.
151   * @param string $region The name of the region for this request.
152   * @param string $resource Name or id of the resource for this request.
153   * @param array $optParams Optional parameters.
154   *
155   * @opt_param int optionsRequestedPolicyVersion Requested IAM Policy version.
156   * @return Policy
157   */
158  public function getIamPolicy($project, $region, $resource, $optParams = [])
159  {
160    $params = ['project' => $project, 'region' => $region, 'resource' => $resource];
161    $params = array_merge($params, $optParams);
162    return $this->call('getIamPolicy', [$params], Policy::class);
163  }
164  /**
165   * Creates a persistent regional disk in the specified project using the data
166   * included in the request. (regionDisks.insert)
167   *
168   * @param string $project Project ID for this request.
169   * @param string $region Name of the region for this request.
170   * @param Disk $postBody
171   * @param array $optParams Optional parameters.
172   *
173   * @opt_param string requestId An optional request ID to identify requests.
174   * Specify a unique request ID so that if you must retry your request, the
175   * server will know to ignore the request if it has already been completed. For
176   * example, consider a situation where you make an initial request and the
177   * request times out. If you make the request again with the same request ID,
178   * the server can check if original operation with the same request ID was
179   * received, and if so, will ignore the second request. This prevents clients
180   * from accidentally creating duplicate commitments. The request ID must be a
181   * valid UUID with the exception that zero UUID is not supported (
182   * 00000000-0000-0000-0000-000000000000).
183   * @opt_param string sourceImage Source image to restore onto a disk. This field
184   * is optional.
185   * @return Operation
186   */
187  public function insert($project, $region, Disk $postBody, $optParams = [])
188  {
189    $params = ['project' => $project, 'region' => $region, 'postBody' => $postBody];
190    $params = array_merge($params, $optParams);
191    return $this->call('insert', [$params], Operation::class);
192  }
193  /**
194   * Retrieves the list of persistent disks contained within the specified region.
195   * (regionDisks.listRegionDisks)
196   *
197   * @param string $project Project ID for this request.
198   * @param string $region Name of the region for this request.
199   * @param array $optParams Optional parameters.
200   *
201   * @opt_param string filter A filter expression that filters resources listed in
202   * the response. The expression must specify the field name, an operator, and
203   * the value that you want to use for filtering. The value must be a string, a
204   * number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`,
205   * `>=` or `:`. For example, if you are filtering Compute Engine instances, you
206   * can exclude instances named `example-instance` by specifying `name !=
207   * example-instance`. The `:` operator can be used with string fields to match
208   * substrings. For non-string fields it is equivalent to the `=` operator. The
209   * `:*` comparison can be used to test whether a key has been defined. For
210   * example, to find all objects with `owner` label use: ``` labels.owner:* ```
211   * You can also filter nested fields. For example, you could specify
212   * `scheduling.automaticRestart = false` to include instances only if they are
213   * not scheduled for automatic restarts. You can use filtering on nested fields
214   * to filter based on resource labels. To filter on multiple expressions,
215   * provide each separate expression within parentheses. For example: ```
216   * (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By
217   * default, each expression is an `AND` expression. However, you can include
218   * `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel
219   * Skylake") OR (cpuPlatform = "Intel Broadwell") AND
220   * (scheduling.automaticRestart = true) ```
221   * @opt_param string maxResults The maximum number of results per page that
222   * should be returned. If the number of available results is larger than
223   * `maxResults`, Compute Engine returns a `nextPageToken` that can be used to
224   * get the next page of results in subsequent list requests. Acceptable values
225   * are `0` to `500`, inclusive. (Default: `500`)
226   * @opt_param string orderBy Sorts list results by a certain order. By default,
227   * results are returned in alphanumerical order based on the resource name. You
228   * can also sort results in descending order based on the creation timestamp
229   * using `orderBy="creationTimestamp desc"`. This sorts results based on the
230   * `creationTimestamp` field in reverse chronological order (newest result
231   * first). Use this to sort resources like operations so that the newest
232   * operation is returned first. Currently, only sorting by `name` or
233   * `creationTimestamp desc` is supported.
234   * @opt_param string pageToken Specifies a page token to use. Set `pageToken` to
235   * the `nextPageToken` returned by a previous list request to get the next page
236   * of results.
237   * @opt_param bool returnPartialSuccess Opt-in for partial success behavior
238   * which provides partial results in case of failure. The default value is
239   * false.
240   * @return DiskList
241   */
242  public function listRegionDisks($project, $region, $optParams = [])
243  {
244    $params = ['project' => $project, 'region' => $region];
245    $params = array_merge($params, $optParams);
246    return $this->call('list', [$params], DiskList::class);
247  }
248  /**
249   * Removes resource policies from a regional disk.
250   * (regionDisks.removeResourcePolicies)
251   *
252   * @param string $project Project ID for this request.
253   * @param string $region The name of the region for this request.
254   * @param string $disk The disk name for this request.
255   * @param RegionDisksRemoveResourcePoliciesRequest $postBody
256   * @param array $optParams Optional parameters.
257   *
258   * @opt_param string requestId An optional request ID to identify requests.
259   * Specify a unique request ID so that if you must retry your request, the
260   * server will know to ignore the request if it has already been completed. For
261   * example, consider a situation where you make an initial request and the
262   * request times out. If you make the request again with the same request ID,
263   * the server can check if original operation with the same request ID was
264   * received, and if so, will ignore the second request. This prevents clients
265   * from accidentally creating duplicate commitments. The request ID must be a
266   * valid UUID with the exception that zero UUID is not supported (
267   * 00000000-0000-0000-0000-000000000000).
268   * @return Operation
269   */
270  public function removeResourcePolicies($project, $region, $disk, RegionDisksRemoveResourcePoliciesRequest $postBody, $optParams = [])
271  {
272    $params = ['project' => $project, 'region' => $region, 'disk' => $disk, 'postBody' => $postBody];
273    $params = array_merge($params, $optParams);
274    return $this->call('removeResourcePolicies', [$params], Operation::class);
275  }
276  /**
277   * Resizes the specified regional persistent disk. (regionDisks.resize)
278   *
279   * @param string $project The project ID for this request.
280   * @param string $region Name of the region for this request.
281   * @param string $disk Name of the regional persistent disk.
282   * @param RegionDisksResizeRequest $postBody
283   * @param array $optParams Optional parameters.
284   *
285   * @opt_param string requestId An optional request ID to identify requests.
286   * Specify a unique request ID so that if you must retry your request, the
287   * server will know to ignore the request if it has already been completed. For
288   * example, consider a situation where you make an initial request and the
289   * request times out. If you make the request again with the same request ID,
290   * the server can check if original operation with the same request ID was
291   * received, and if so, will ignore the second request. This prevents clients
292   * from accidentally creating duplicate commitments. The request ID must be a
293   * valid UUID with the exception that zero UUID is not supported (
294   * 00000000-0000-0000-0000-000000000000).
295   * @return Operation
296   */
297  public function resize($project, $region, $disk, RegionDisksResizeRequest $postBody, $optParams = [])
298  {
299    $params = ['project' => $project, 'region' => $region, 'disk' => $disk, 'postBody' => $postBody];
300    $params = array_merge($params, $optParams);
301    return $this->call('resize', [$params], Operation::class);
302  }
303  /**
304   * Sets the access control policy on the specified resource. Replaces any
305   * existing policy. (regionDisks.setIamPolicy)
306   *
307   * @param string $project Project ID for this request.
308   * @param string $region The name of the region for this request.
309   * @param string $resource Name or id of the resource for this request.
310   * @param RegionSetPolicyRequest $postBody
311   * @param array $optParams Optional parameters.
312   * @return Policy
313   */
314  public function setIamPolicy($project, $region, $resource, RegionSetPolicyRequest $postBody, $optParams = [])
315  {
316    $params = ['project' => $project, 'region' => $region, 'resource' => $resource, 'postBody' => $postBody];
317    $params = array_merge($params, $optParams);
318    return $this->call('setIamPolicy', [$params], Policy::class);
319  }
320  /**
321   * Sets the labels on the target regional disk. (regionDisks.setLabels)
322   *
323   * @param string $project Project ID for this request.
324   * @param string $region The region for this request.
325   * @param string $resource Name or id of the resource for this request.
326   * @param RegionSetLabelsRequest $postBody
327   * @param array $optParams Optional parameters.
328   *
329   * @opt_param string requestId An optional request ID to identify requests.
330   * Specify a unique request ID so that if you must retry your request, the
331   * server will know to ignore the request if it has already been completed. For
332   * example, consider a situation where you make an initial request and the
333   * request times out. If you make the request again with the same request ID,
334   * the server can check if original operation with the same request ID was
335   * received, and if so, will ignore the second request. This prevents clients
336   * from accidentally creating duplicate commitments. The request ID must be a
337   * valid UUID with the exception that zero UUID is not supported (
338   * 00000000-0000-0000-0000-000000000000).
339   * @return Operation
340   */
341  public function setLabels($project, $region, $resource, RegionSetLabelsRequest $postBody, $optParams = [])
342  {
343    $params = ['project' => $project, 'region' => $region, 'resource' => $resource, 'postBody' => $postBody];
344    $params = array_merge($params, $optParams);
345    return $this->call('setLabels', [$params], Operation::class);
346  }
347  /**
348   * Returns permissions that a caller has on the specified resource.
349   * (regionDisks.testIamPermissions)
350   *
351   * @param string $project Project ID for this request.
352   * @param string $region The name of the region for this request.
353   * @param string $resource Name or id of the resource for this request.
354   * @param TestPermissionsRequest $postBody
355   * @param array $optParams Optional parameters.
356   * @return TestPermissionsResponse
357   */
358  public function testIamPermissions($project, $region, $resource, TestPermissionsRequest $postBody, $optParams = [])
359  {
360    $params = ['project' => $project, 'region' => $region, 'resource' => $resource, 'postBody' => $postBody];
361    $params = array_merge($params, $optParams);
362    return $this->call('testIamPermissions', [$params], TestPermissionsResponse::class);
363  }
364}
365
366// Adding a class alias for backwards compatibility with the previous class name.
367class_alias(RegionDisks::class, 'Google_Service_Compute_Resource_RegionDisks');
368