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\GlobalSetPolicyRequest;
21use Google\Service\Compute\MachineImage;
22use Google\Service\Compute\MachineImageList;
23use Google\Service\Compute\Operation;
24use Google\Service\Compute\Policy;
25use Google\Service\Compute\TestPermissionsRequest;
26use Google\Service\Compute\TestPermissionsResponse;
27
28/**
29 * The "machineImages" collection of methods.
30 * Typical usage is:
31 *  <code>
32 *   $computeService = new Google\Service\Compute(...);
33 *   $machineImages = $computeService->machineImages;
34 *  </code>
35 */
36class MachineImages extends \Google\Service\Resource
37{
38  /**
39   * Deletes the specified machine image. Deleting a machine image is permanent
40   * and cannot be undone. (machineImages.delete)
41   *
42   * @param string $project Project ID for this request.
43   * @param string $machineImage The name of the machine image to delete.
44   * @param array $optParams Optional parameters.
45   *
46   * @opt_param string requestId An optional request ID to identify requests.
47   * Specify a unique request ID so that if you must retry your request, the
48   * server will know to ignore the request if it has already been completed. For
49   * example, consider a situation where you make an initial request and the
50   * request times out. If you make the request again with the same request ID,
51   * the server can check if original operation with the same request ID was
52   * received, and if so, will ignore the second request. This prevents clients
53   * from accidentally creating duplicate commitments. The request ID must be a
54   * valid UUID with the exception that zero UUID is not supported (
55   * 00000000-0000-0000-0000-000000000000).
56   * @return Operation
57   */
58  public function delete($project, $machineImage, $optParams = [])
59  {
60    $params = ['project' => $project, 'machineImage' => $machineImage];
61    $params = array_merge($params, $optParams);
62    return $this->call('delete', [$params], Operation::class);
63  }
64  /**
65   * Returns the specified machine image. Gets a list of available machine images
66   * by making a list() request. (machineImages.get)
67   *
68   * @param string $project Project ID for this request.
69   * @param string $machineImage The name of the machine image.
70   * @param array $optParams Optional parameters.
71   * @return MachineImage
72   */
73  public function get($project, $machineImage, $optParams = [])
74  {
75    $params = ['project' => $project, 'machineImage' => $machineImage];
76    $params = array_merge($params, $optParams);
77    return $this->call('get', [$params], MachineImage::class);
78  }
79  /**
80   * Gets the access control policy for a resource. May be empty if no such policy
81   * or resource exists. (machineImages.getIamPolicy)
82   *
83   * @param string $project Project ID for this request.
84   * @param string $resource Name or id of the resource for this request.
85   * @param array $optParams Optional parameters.
86   *
87   * @opt_param int optionsRequestedPolicyVersion Requested IAM Policy version.
88   * @return Policy
89   */
90  public function getIamPolicy($project, $resource, $optParams = [])
91  {
92    $params = ['project' => $project, 'resource' => $resource];
93    $params = array_merge($params, $optParams);
94    return $this->call('getIamPolicy', [$params], Policy::class);
95  }
96  /**
97   * Creates a machine image in the specified project using the data that is
98   * included in the request. If you are creating a new machine image to update an
99   * existing instance, your new machine image should use the same network or, if
100   * applicable, the same subnetwork as the original instance.
101   * (machineImages.insert)
102   *
103   * @param string $project Project ID for this request.
104   * @param MachineImage $postBody
105   * @param array $optParams Optional parameters.
106   *
107   * @opt_param string requestId An optional request ID to identify requests.
108   * Specify a unique request ID so that if you must retry your request, the
109   * server will know to ignore the request if it has already been completed. For
110   * example, consider a situation where you make an initial request and the
111   * request times out. If you make the request again with the same request ID,
112   * the server can check if original operation with the same request ID was
113   * received, and if so, will ignore the second request. This prevents clients
114   * from accidentally creating duplicate commitments. The request ID must be a
115   * valid UUID with the exception that zero UUID is not supported (
116   * 00000000-0000-0000-0000-000000000000).
117   * @opt_param string sourceInstance Required. Source instance that is used to
118   * create the machine image from.
119   * @return Operation
120   */
121  public function insert($project, MachineImage $postBody, $optParams = [])
122  {
123    $params = ['project' => $project, 'postBody' => $postBody];
124    $params = array_merge($params, $optParams);
125    return $this->call('insert', [$params], Operation::class);
126  }
127  /**
128   * Retrieves a list of machine images that are contained within the specified
129   * project. (machineImages.listMachineImages)
130   *
131   * @param string $project Project ID for this request.
132   * @param array $optParams Optional parameters.
133   *
134   * @opt_param string filter A filter expression that filters resources listed in
135   * the response. The expression must specify the field name, an operator, and
136   * the value that you want to use for filtering. The value must be a string, a
137   * number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`,
138   * `>=` or `:`. For example, if you are filtering Compute Engine instances, you
139   * can exclude instances named `example-instance` by specifying `name !=
140   * example-instance`. The `:` operator can be used with string fields to match
141   * substrings. For non-string fields it is equivalent to the `=` operator. The
142   * `:*` comparison can be used to test whether a key has been defined. For
143   * example, to find all objects with `owner` label use: ``` labels.owner:* ```
144   * You can also filter nested fields. For example, you could specify
145   * `scheduling.automaticRestart = false` to include instances only if they are
146   * not scheduled for automatic restarts. You can use filtering on nested fields
147   * to filter based on resource labels. To filter on multiple expressions,
148   * provide each separate expression within parentheses. For example: ```
149   * (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By
150   * default, each expression is an `AND` expression. However, you can include
151   * `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel
152   * Skylake") OR (cpuPlatform = "Intel Broadwell") AND
153   * (scheduling.automaticRestart = true) ```
154   * @opt_param string maxResults The maximum number of results per page that
155   * should be returned. If the number of available results is larger than
156   * `maxResults`, Compute Engine returns a `nextPageToken` that can be used to
157   * get the next page of results in subsequent list requests. Acceptable values
158   * are `0` to `500`, inclusive. (Default: `500`)
159   * @opt_param string orderBy Sorts list results by a certain order. By default,
160   * results are returned in alphanumerical order based on the resource name. You
161   * can also sort results in descending order based on the creation timestamp
162   * using `orderBy="creationTimestamp desc"`. This sorts results based on the
163   * `creationTimestamp` field in reverse chronological order (newest result
164   * first). Use this to sort resources like operations so that the newest
165   * operation is returned first. Currently, only sorting by `name` or
166   * `creationTimestamp desc` is supported.
167   * @opt_param string pageToken Specifies a page token to use. Set `pageToken` to
168   * the `nextPageToken` returned by a previous list request to get the next page
169   * of results.
170   * @opt_param bool returnPartialSuccess Opt-in for partial success behavior
171   * which provides partial results in case of failure. The default value is
172   * false.
173   * @return MachineImageList
174   */
175  public function listMachineImages($project, $optParams = [])
176  {
177    $params = ['project' => $project];
178    $params = array_merge($params, $optParams);
179    return $this->call('list', [$params], MachineImageList::class);
180  }
181  /**
182   * Sets the access control policy on the specified resource. Replaces any
183   * existing policy. (machineImages.setIamPolicy)
184   *
185   * @param string $project Project ID for this request.
186   * @param string $resource Name or id of the resource for this request.
187   * @param GlobalSetPolicyRequest $postBody
188   * @param array $optParams Optional parameters.
189   * @return Policy
190   */
191  public function setIamPolicy($project, $resource, GlobalSetPolicyRequest $postBody, $optParams = [])
192  {
193    $params = ['project' => $project, 'resource' => $resource, 'postBody' => $postBody];
194    $params = array_merge($params, $optParams);
195    return $this->call('setIamPolicy', [$params], Policy::class);
196  }
197  /**
198   * Returns permissions that a caller has on the specified resource.
199   * (machineImages.testIamPermissions)
200   *
201   * @param string $project Project ID for this request.
202   * @param string $resource Name or id of the resource for this request.
203   * @param TestPermissionsRequest $postBody
204   * @param array $optParams Optional parameters.
205   * @return TestPermissionsResponse
206   */
207  public function testIamPermissions($project, $resource, TestPermissionsRequest $postBody, $optParams = [])
208  {
209    $params = ['project' => $project, 'resource' => $resource, 'postBody' => $postBody];
210    $params = array_merge($params, $optParams);
211    return $this->call('testIamPermissions', [$params], TestPermissionsResponse::class);
212  }
213}
214
215// Adding a class alias for backwards compatibility with the previous class name.
216class_alias(MachineImages::class, 'Google_Service_Compute_Resource_MachineImages');
217