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