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