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