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\InstanceReference;
21use Google\Service\Compute\Operation;
22use Google\Service\Compute\TargetPool;
23use Google\Service\Compute\TargetPoolAggregatedList;
24use Google\Service\Compute\TargetPoolInstanceHealth;
25use Google\Service\Compute\TargetPoolList;
26use Google\Service\Compute\TargetPoolsAddHealthCheckRequest;
27use Google\Service\Compute\TargetPoolsAddInstanceRequest;
28use Google\Service\Compute\TargetPoolsRemoveHealthCheckRequest;
29use Google\Service\Compute\TargetPoolsRemoveInstanceRequest;
30use Google\Service\Compute\TargetReference;
31
32/**
33 * The "targetPools" collection of methods.
34 * Typical usage is:
35 *  <code>
36 *   $computeService = new Google\Service\Compute(...);
37 *   $targetPools = $computeService->targetPools;
38 *  </code>
39 */
40class TargetPools extends \Google\Service\Resource
41{
42  /**
43   * Adds health check URLs to a target pool. (targetPools.addHealthCheck)
44   *
45   * @param string $project Project ID for this request.
46   * @param string $region Name of the region scoping this request.
47   * @param string $targetPool Name of the target pool to add a health check to.
48   * @param TargetPoolsAddHealthCheckRequest $postBody
49   * @param array $optParams Optional parameters.
50   *
51   * @opt_param string requestId An optional request ID to identify requests.
52   * Specify a unique request ID so that if you must retry your request, the
53   * server will know to ignore the request if it has already been completed. For
54   * example, consider a situation where you make an initial request and the
55   * request times out. If you make the request again with the same request ID,
56   * the server can check if original operation with the same request ID was
57   * received, and if so, will ignore the second request. This prevents clients
58   * from accidentally creating duplicate commitments. The request ID must be a
59   * valid UUID with the exception that zero UUID is not supported (
60   * 00000000-0000-0000-0000-000000000000).
61   * @return Operation
62   */
63  public function addHealthCheck($project, $region, $targetPool, TargetPoolsAddHealthCheckRequest $postBody, $optParams = [])
64  {
65    $params = ['project' => $project, 'region' => $region, 'targetPool' => $targetPool, 'postBody' => $postBody];
66    $params = array_merge($params, $optParams);
67    return $this->call('addHealthCheck', [$params], Operation::class);
68  }
69  /**
70   * Adds an instance to a target pool. (targetPools.addInstance)
71   *
72   * @param string $project Project ID for this request.
73   * @param string $region Name of the region scoping this request.
74   * @param string $targetPool Name of the TargetPool resource to add instances
75   * to.
76   * @param TargetPoolsAddInstanceRequest $postBody
77   * @param array $optParams Optional parameters.
78   *
79   * @opt_param string requestId An optional request ID to identify requests.
80   * Specify a unique request ID so that if you must retry your request, the
81   * server will know to ignore the request if it has already been completed. For
82   * example, consider a situation where you make an initial request and the
83   * request times out. If you make the request again with the same request ID,
84   * the server can check if original operation with the same request ID was
85   * received, and if so, will ignore the second request. This prevents clients
86   * from accidentally creating duplicate commitments. The request ID must be a
87   * valid UUID with the exception that zero UUID is not supported (
88   * 00000000-0000-0000-0000-000000000000).
89   * @return Operation
90   */
91  public function addInstance($project, $region, $targetPool, TargetPoolsAddInstanceRequest $postBody, $optParams = [])
92  {
93    $params = ['project' => $project, 'region' => $region, 'targetPool' => $targetPool, 'postBody' => $postBody];
94    $params = array_merge($params, $optParams);
95    return $this->call('addInstance', [$params], Operation::class);
96  }
97  /**
98   * Retrieves an aggregated list of target pools. (targetPools.aggregatedList)
99   *
100   * @param string $project Project ID for this request.
101   * @param array $optParams Optional parameters.
102   *
103   * @opt_param string filter A filter expression that filters resources listed in
104   * the response. The expression must specify the field name, an operator, and
105   * the value that you want to use for filtering. The value must be a string, a
106   * number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`,
107   * `>=` or `:`. For example, if you are filtering Compute Engine instances, you
108   * can exclude instances named `example-instance` by specifying `name !=
109   * example-instance`. The `:` operator can be used with string fields to match
110   * substrings. For non-string fields it is equivalent to the `=` operator. The
111   * `:*` comparison can be used to test whether a key has been defined. For
112   * example, to find all objects with `owner` label use: ``` labels.owner:* ```
113   * You can also filter nested fields. For example, you could specify
114   * `scheduling.automaticRestart = false` to include instances only if they are
115   * not scheduled for automatic restarts. You can use filtering on nested fields
116   * to filter based on resource labels. To filter on multiple expressions,
117   * provide each separate expression within parentheses. For example: ```
118   * (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By
119   * default, each expression is an `AND` expression. However, you can include
120   * `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel
121   * Skylake") OR (cpuPlatform = "Intel Broadwell") AND
122   * (scheduling.automaticRestart = true) ```
123   * @opt_param bool includeAllScopes Indicates whether every visible scope for
124   * each scope type (zone, region, global) should be included in the response.
125   * For new resource types added after this field, the flag has no effect as new
126   * resource types will always include every visible scope for each scope type in
127   * response. For resource types which predate this field, if this flag is
128   * omitted or false, only scopes of the scope types where the resource type is
129   * expected to be found will be included.
130   * @opt_param string maxResults The maximum number of results per page that
131   * should be returned. If the number of available results is larger than
132   * `maxResults`, Compute Engine returns a `nextPageToken` that can be used to
133   * get the next page of results in subsequent list requests. Acceptable values
134   * are `0` to `500`, inclusive. (Default: `500`)
135   * @opt_param string orderBy Sorts list results by a certain order. By default,
136   * results are returned in alphanumerical order based on the resource name. You
137   * can also sort results in descending order based on the creation timestamp
138   * using `orderBy="creationTimestamp desc"`. This sorts results based on the
139   * `creationTimestamp` field in reverse chronological order (newest result
140   * first). Use this to sort resources like operations so that the newest
141   * operation is returned first. Currently, only sorting by `name` or
142   * `creationTimestamp desc` is supported.
143   * @opt_param string pageToken Specifies a page token to use. Set `pageToken` to
144   * the `nextPageToken` returned by a previous list request to get the next page
145   * of results.
146   * @opt_param bool returnPartialSuccess Opt-in for partial success behavior
147   * which provides partial results in case of failure. The default value is
148   * false.
149   * @return TargetPoolAggregatedList
150   */
151  public function aggregatedList($project, $optParams = [])
152  {
153    $params = ['project' => $project];
154    $params = array_merge($params, $optParams);
155    return $this->call('aggregatedList', [$params], TargetPoolAggregatedList::class);
156  }
157  /**
158   * Deletes the specified target pool. (targetPools.delete)
159   *
160   * @param string $project Project ID for this request.
161   * @param string $region Name of the region scoping this request.
162   * @param string $targetPool Name of the TargetPool resource to delete.
163   * @param array $optParams Optional parameters.
164   *
165   * @opt_param string requestId An optional request ID to identify requests.
166   * Specify a unique request ID so that if you must retry your request, the
167   * server will know to ignore the request if it has already been completed. For
168   * example, consider a situation where you make an initial request and the
169   * request times out. If you make the request again with the same request ID,
170   * the server can check if original operation with the same request ID was
171   * received, and if so, will ignore the second request. This prevents clients
172   * from accidentally creating duplicate commitments. The request ID must be a
173   * valid UUID with the exception that zero UUID is not supported (
174   * 00000000-0000-0000-0000-000000000000).
175   * @return Operation
176   */
177  public function delete($project, $region, $targetPool, $optParams = [])
178  {
179    $params = ['project' => $project, 'region' => $region, 'targetPool' => $targetPool];
180    $params = array_merge($params, $optParams);
181    return $this->call('delete', [$params], Operation::class);
182  }
183  /**
184   * Returns the specified target pool. Gets a list of available target pools by
185   * making a list() request. (targetPools.get)
186   *
187   * @param string $project Project ID for this request.
188   * @param string $region Name of the region scoping this request.
189   * @param string $targetPool Name of the TargetPool resource to return.
190   * @param array $optParams Optional parameters.
191   * @return TargetPool
192   */
193  public function get($project, $region, $targetPool, $optParams = [])
194  {
195    $params = ['project' => $project, 'region' => $region, 'targetPool' => $targetPool];
196    $params = array_merge($params, $optParams);
197    return $this->call('get', [$params], TargetPool::class);
198  }
199  /**
200   * Gets the most recent health check results for each IP for the instance that
201   * is referenced by the given target pool. (targetPools.getHealth)
202   *
203   * @param string $project Project ID for this request.
204   * @param string $region Name of the region scoping this request.
205   * @param string $targetPool Name of the TargetPool resource to which the
206   * queried instance belongs.
207   * @param InstanceReference $postBody
208   * @param array $optParams Optional parameters.
209   * @return TargetPoolInstanceHealth
210   */
211  public function getHealth($project, $region, $targetPool, InstanceReference $postBody, $optParams = [])
212  {
213    $params = ['project' => $project, 'region' => $region, 'targetPool' => $targetPool, 'postBody' => $postBody];
214    $params = array_merge($params, $optParams);
215    return $this->call('getHealth', [$params], TargetPoolInstanceHealth::class);
216  }
217  /**
218   * Creates a target pool in the specified project and region using the data
219   * included in the request. (targetPools.insert)
220   *
221   * @param string $project Project ID for this request.
222   * @param string $region Name of the region scoping this request.
223   * @param TargetPool $postBody
224   * @param array $optParams Optional parameters.
225   *
226   * @opt_param string requestId An optional request ID to identify requests.
227   * Specify a unique request ID so that if you must retry your request, the
228   * server will know to ignore the request if it has already been completed. For
229   * example, consider a situation where you make an initial request and the
230   * request times out. If you make the request again with the same request ID,
231   * the server can check if original operation with the same request ID was
232   * received, and if so, will ignore the second request. This prevents clients
233   * from accidentally creating duplicate commitments. The request ID must be a
234   * valid UUID with the exception that zero UUID is not supported (
235   * 00000000-0000-0000-0000-000000000000).
236   * @return Operation
237   */
238  public function insert($project, $region, TargetPool $postBody, $optParams = [])
239  {
240    $params = ['project' => $project, 'region' => $region, 'postBody' => $postBody];
241    $params = array_merge($params, $optParams);
242    return $this->call('insert', [$params], Operation::class);
243  }
244  /**
245   * Retrieves a list of target pools available to the specified project and
246   * region. (targetPools.listTargetPools)
247   *
248   * @param string $project Project ID for this request.
249   * @param string $region Name of the region scoping this request.
250   * @param array $optParams Optional parameters.
251   *
252   * @opt_param string filter A filter expression that filters resources listed in
253   * the response. The expression must specify the field name, an operator, and
254   * the value that you want to use for filtering. The value must be a string, a
255   * number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`,
256   * `>=` or `:`. For example, if you are filtering Compute Engine instances, you
257   * can exclude instances named `example-instance` by specifying `name !=
258   * example-instance`. The `:` operator can be used with string fields to match
259   * substrings. For non-string fields it is equivalent to the `=` operator. The
260   * `:*` comparison can be used to test whether a key has been defined. For
261   * example, to find all objects with `owner` label use: ``` labels.owner:* ```
262   * You can also filter nested fields. For example, you could specify
263   * `scheduling.automaticRestart = false` to include instances only if they are
264   * not scheduled for automatic restarts. You can use filtering on nested fields
265   * to filter based on resource labels. To filter on multiple expressions,
266   * provide each separate expression within parentheses. For example: ```
267   * (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By
268   * default, each expression is an `AND` expression. However, you can include
269   * `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel
270   * Skylake") OR (cpuPlatform = "Intel Broadwell") AND
271   * (scheduling.automaticRestart = true) ```
272   * @opt_param string maxResults The maximum number of results per page that
273   * should be returned. If the number of available results is larger than
274   * `maxResults`, Compute Engine returns a `nextPageToken` that can be used to
275   * get the next page of results in subsequent list requests. Acceptable values
276   * are `0` to `500`, inclusive. (Default: `500`)
277   * @opt_param string orderBy Sorts list results by a certain order. By default,
278   * results are returned in alphanumerical order based on the resource name. You
279   * can also sort results in descending order based on the creation timestamp
280   * using `orderBy="creationTimestamp desc"`. This sorts results based on the
281   * `creationTimestamp` field in reverse chronological order (newest result
282   * first). Use this to sort resources like operations so that the newest
283   * operation is returned first. Currently, only sorting by `name` or
284   * `creationTimestamp desc` is supported.
285   * @opt_param string pageToken Specifies a page token to use. Set `pageToken` to
286   * the `nextPageToken` returned by a previous list request to get the next page
287   * of results.
288   * @opt_param bool returnPartialSuccess Opt-in for partial success behavior
289   * which provides partial results in case of failure. The default value is
290   * false.
291   * @return TargetPoolList
292   */
293  public function listTargetPools($project, $region, $optParams = [])
294  {
295    $params = ['project' => $project, 'region' => $region];
296    $params = array_merge($params, $optParams);
297    return $this->call('list', [$params], TargetPoolList::class);
298  }
299  /**
300   * Removes health check URL from a target pool. (targetPools.removeHealthCheck)
301   *
302   * @param string $project Project ID for this request.
303   * @param string $region Name of the region for this request.
304   * @param string $targetPool Name of the target pool to remove health checks
305   * from.
306   * @param TargetPoolsRemoveHealthCheckRequest $postBody
307   * @param array $optParams Optional parameters.
308   *
309   * @opt_param string requestId An optional request ID to identify requests.
310   * Specify a unique request ID so that if you must retry your request, the
311   * server will know to ignore the request if it has already been completed. For
312   * example, consider a situation where you make an initial request and the
313   * request times out. If you make the request again with the same request ID,
314   * the server can check if original operation with the same request ID was
315   * received, and if so, will ignore the second request. This prevents clients
316   * from accidentally creating duplicate commitments. The request ID must be a
317   * valid UUID with the exception that zero UUID is not supported (
318   * 00000000-0000-0000-0000-000000000000).
319   * @return Operation
320   */
321  public function removeHealthCheck($project, $region, $targetPool, TargetPoolsRemoveHealthCheckRequest $postBody, $optParams = [])
322  {
323    $params = ['project' => $project, 'region' => $region, 'targetPool' => $targetPool, 'postBody' => $postBody];
324    $params = array_merge($params, $optParams);
325    return $this->call('removeHealthCheck', [$params], Operation::class);
326  }
327  /**
328   * Removes instance URL from a target pool. (targetPools.removeInstance)
329   *
330   * @param string $project Project ID for this request.
331   * @param string $region Name of the region scoping this request.
332   * @param string $targetPool Name of the TargetPool resource to remove instances
333   * from.
334   * @param TargetPoolsRemoveInstanceRequest $postBody
335   * @param array $optParams Optional parameters.
336   *
337   * @opt_param string requestId An optional request ID to identify requests.
338   * Specify a unique request ID so that if you must retry your request, the
339   * server will know to ignore the request if it has already been completed. For
340   * example, consider a situation where you make an initial request and the
341   * request times out. If you make the request again with the same request ID,
342   * the server can check if original operation with the same request ID was
343   * received, and if so, will ignore the second request. This prevents clients
344   * from accidentally creating duplicate commitments. The request ID must be a
345   * valid UUID with the exception that zero UUID is not supported (
346   * 00000000-0000-0000-0000-000000000000).
347   * @return Operation
348   */
349  public function removeInstance($project, $region, $targetPool, TargetPoolsRemoveInstanceRequest $postBody, $optParams = [])
350  {
351    $params = ['project' => $project, 'region' => $region, 'targetPool' => $targetPool, 'postBody' => $postBody];
352    $params = array_merge($params, $optParams);
353    return $this->call('removeInstance', [$params], Operation::class);
354  }
355  /**
356   * Changes a backup target pool's configurations. (targetPools.setBackup)
357   *
358   * @param string $project Project ID for this request.
359   * @param string $region Name of the region scoping this request.
360   * @param string $targetPool Name of the TargetPool resource to set a backup
361   * pool for.
362   * @param TargetReference $postBody
363   * @param array $optParams Optional parameters.
364   *
365   * @opt_param float failoverRatio New failoverRatio value for the target pool.
366   * @opt_param string requestId An optional request ID to identify requests.
367   * Specify a unique request ID so that if you must retry your request, the
368   * server will know to ignore the request if it has already been completed. For
369   * example, consider a situation where you make an initial request and the
370   * request times out. If you make the request again with the same request ID,
371   * the server can check if original operation with the same request ID was
372   * received, and if so, will ignore the second request. This prevents clients
373   * from accidentally creating duplicate commitments. The request ID must be a
374   * valid UUID with the exception that zero UUID is not supported (
375   * 00000000-0000-0000-0000-000000000000).
376   * @return Operation
377   */
378  public function setBackup($project, $region, $targetPool, TargetReference $postBody, $optParams = [])
379  {
380    $params = ['project' => $project, 'region' => $region, 'targetPool' => $targetPool, 'postBody' => $postBody];
381    $params = array_merge($params, $optParams);
382    return $this->call('setBackup', [$params], Operation::class);
383  }
384}
385
386// Adding a class alias for backwards compatibility with the previous class name.
387class_alias(TargetPools::class, 'Google_Service_Compute_Resource_TargetPools');
388