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\RegionSetPolicyRequest;
23use Google\Service\Compute\Subnetwork;
24use Google\Service\Compute\SubnetworkAggregatedList;
25use Google\Service\Compute\SubnetworkList;
26use Google\Service\Compute\SubnetworksExpandIpCidrRangeRequest;
27use Google\Service\Compute\SubnetworksSetPrivateIpGoogleAccessRequest;
28use Google\Service\Compute\TestPermissionsRequest;
29use Google\Service\Compute\TestPermissionsResponse;
30use Google\Service\Compute\UsableSubnetworksAggregatedList;
31
32/**
33 * The "subnetworks" collection of methods.
34 * Typical usage is:
35 *  <code>
36 *   $computeService = new Google\Service\Compute(...);
37 *   $subnetworks = $computeService->subnetworks;
38 *  </code>
39 */
40class Subnetworks extends \Google\Service\Resource
41{
42  /**
43   * Retrieves an aggregated list of subnetworks. (subnetworks.aggregatedList)
44   *
45   * @param string $project Project ID for this request.
46   * @param array $optParams Optional parameters.
47   *
48   * @opt_param string filter A filter expression that filters resources listed in
49   * the response. The expression must specify the field name, an operator, and
50   * the value that you want to use for filtering. The value must be a string, a
51   * number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`,
52   * `>=` or `:`. For example, if you are filtering Compute Engine instances, you
53   * can exclude instances named `example-instance` by specifying `name !=
54   * example-instance`. The `:` operator can be used with string fields to match
55   * substrings. For non-string fields it is equivalent to the `=` operator. The
56   * `:*` comparison can be used to test whether a key has been defined. For
57   * example, to find all objects with `owner` label use: ``` labels.owner:* ```
58   * You can also filter nested fields. For example, you could specify
59   * `scheduling.automaticRestart = false` to include instances only if they are
60   * not scheduled for automatic restarts. You can use filtering on nested fields
61   * to filter based on resource labels. To filter on multiple expressions,
62   * provide each separate expression within parentheses. For example: ```
63   * (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By
64   * default, each expression is an `AND` expression. However, you can include
65   * `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel
66   * Skylake") OR (cpuPlatform = "Intel Broadwell") AND
67   * (scheduling.automaticRestart = true) ```
68   * @opt_param bool includeAllScopes Indicates whether every visible scope for
69   * each scope type (zone, region, global) should be included in the response.
70   * For new resource types added after this field, the flag has no effect as new
71   * resource types will always include every visible scope for each scope type in
72   * response. For resource types which predate this field, if this flag is
73   * omitted or false, only scopes of the scope types where the resource type is
74   * expected to be found will be included.
75   * @opt_param string maxResults The maximum number of results per page that
76   * should be returned. If the number of available results is larger than
77   * `maxResults`, Compute Engine returns a `nextPageToken` that can be used to
78   * get the next page of results in subsequent list requests. Acceptable values
79   * are `0` to `500`, inclusive. (Default: `500`)
80   * @opt_param string orderBy Sorts list results by a certain order. By default,
81   * results are returned in alphanumerical order based on the resource name. You
82   * can also sort results in descending order based on the creation timestamp
83   * using `orderBy="creationTimestamp desc"`. This sorts results based on the
84   * `creationTimestamp` field in reverse chronological order (newest result
85   * first). Use this to sort resources like operations so that the newest
86   * operation is returned first. Currently, only sorting by `name` or
87   * `creationTimestamp desc` is supported.
88   * @opt_param string pageToken Specifies a page token to use. Set `pageToken` to
89   * the `nextPageToken` returned by a previous list request to get the next page
90   * of results.
91   * @opt_param bool returnPartialSuccess Opt-in for partial success behavior
92   * which provides partial results in case of failure. The default value is
93   * false.
94   * @return SubnetworkAggregatedList
95   */
96  public function aggregatedList($project, $optParams = [])
97  {
98    $params = ['project' => $project];
99    $params = array_merge($params, $optParams);
100    return $this->call('aggregatedList', [$params], SubnetworkAggregatedList::class);
101  }
102  /**
103   * Deletes the specified subnetwork. (subnetworks.delete)
104   *
105   * @param string $project Project ID for this request.
106   * @param string $region Name of the region scoping this request.
107   * @param string $subnetwork Name of the Subnetwork resource to delete.
108   * @param array $optParams Optional parameters.
109   *
110   * @opt_param string requestId An optional request ID to identify requests.
111   * Specify a unique request ID so that if you must retry your request, the
112   * server will know to ignore the request if it has already been completed. For
113   * example, consider a situation where you make an initial request and the
114   * request times out. If you make the request again with the same request ID,
115   * the server can check if original operation with the same request ID was
116   * received, and if so, will ignore the second request. This prevents clients
117   * from accidentally creating duplicate commitments. The request ID must be a
118   * valid UUID with the exception that zero UUID is not supported (
119   * 00000000-0000-0000-0000-000000000000).
120   * @return Operation
121   */
122  public function delete($project, $region, $subnetwork, $optParams = [])
123  {
124    $params = ['project' => $project, 'region' => $region, 'subnetwork' => $subnetwork];
125    $params = array_merge($params, $optParams);
126    return $this->call('delete', [$params], Operation::class);
127  }
128  /**
129   * Expands the IP CIDR range of the subnetwork to a specified value.
130   * (subnetworks.expandIpCidrRange)
131   *
132   * @param string $project Project ID for this request.
133   * @param string $region Name of the region scoping this request.
134   * @param string $subnetwork Name of the Subnetwork resource to update.
135   * @param SubnetworksExpandIpCidrRangeRequest $postBody
136   * @param array $optParams Optional parameters.
137   *
138   * @opt_param string requestId An optional request ID to identify requests.
139   * Specify a unique request ID so that if you must retry your request, the
140   * server will know to ignore the request if it has already been completed. For
141   * example, consider a situation where you make an initial request and the
142   * request times out. If you make the request again with the same request ID,
143   * the server can check if original operation with the same request ID was
144   * received, and if so, will ignore the second request. This prevents clients
145   * from accidentally creating duplicate commitments. The request ID must be a
146   * valid UUID with the exception that zero UUID is not supported (
147   * 00000000-0000-0000-0000-000000000000).
148   * @return Operation
149   */
150  public function expandIpCidrRange($project, $region, $subnetwork, SubnetworksExpandIpCidrRangeRequest $postBody, $optParams = [])
151  {
152    $params = ['project' => $project, 'region' => $region, 'subnetwork' => $subnetwork, 'postBody' => $postBody];
153    $params = array_merge($params, $optParams);
154    return $this->call('expandIpCidrRange', [$params], Operation::class);
155  }
156  /**
157   * Returns the specified subnetwork. Gets a list of available subnetworks list()
158   * request. (subnetworks.get)
159   *
160   * @param string $project Project ID for this request.
161   * @param string $region Name of the region scoping this request.
162   * @param string $subnetwork Name of the Subnetwork resource to return.
163   * @param array $optParams Optional parameters.
164   * @return Subnetwork
165   */
166  public function get($project, $region, $subnetwork, $optParams = [])
167  {
168    $params = ['project' => $project, 'region' => $region, 'subnetwork' => $subnetwork];
169    $params = array_merge($params, $optParams);
170    return $this->call('get', [$params], Subnetwork::class);
171  }
172  /**
173   * Gets the access control policy for a resource. May be empty if no such policy
174   * or resource exists. (subnetworks.getIamPolicy)
175   *
176   * @param string $project Project ID for this request.
177   * @param string $region The name of the region for this request.
178   * @param string $resource Name or id of the resource for this request.
179   * @param array $optParams Optional parameters.
180   *
181   * @opt_param int optionsRequestedPolicyVersion Requested IAM Policy version.
182   * @return Policy
183   */
184  public function getIamPolicy($project, $region, $resource, $optParams = [])
185  {
186    $params = ['project' => $project, 'region' => $region, 'resource' => $resource];
187    $params = array_merge($params, $optParams);
188    return $this->call('getIamPolicy', [$params], Policy::class);
189  }
190  /**
191   * Creates a subnetwork in the specified project using the data included in the
192   * request. (subnetworks.insert)
193   *
194   * @param string $project Project ID for this request.
195   * @param string $region Name of the region scoping this request.
196   * @param Subnetwork $postBody
197   * @param array $optParams Optional parameters.
198   *
199   * @opt_param string requestId An optional request ID to identify requests.
200   * Specify a unique request ID so that if you must retry your request, the
201   * server will know to ignore the request if it has already been completed. For
202   * example, consider a situation where you make an initial request and the
203   * request times out. If you make the request again with the same request ID,
204   * the server can check if original operation with the same request ID was
205   * received, and if so, will ignore the second request. This prevents clients
206   * from accidentally creating duplicate commitments. The request ID must be a
207   * valid UUID with the exception that zero UUID is not supported (
208   * 00000000-0000-0000-0000-000000000000).
209   * @return Operation
210   */
211  public function insert($project, $region, Subnetwork $postBody, $optParams = [])
212  {
213    $params = ['project' => $project, 'region' => $region, 'postBody' => $postBody];
214    $params = array_merge($params, $optParams);
215    return $this->call('insert', [$params], Operation::class);
216  }
217  /**
218   * Retrieves a list of subnetworks available to the specified project.
219   * (subnetworks.listSubnetworks)
220   *
221   * @param string $project Project ID for this request.
222   * @param string $region Name of the region scoping this request.
223   * @param array $optParams Optional parameters.
224   *
225   * @opt_param string filter A filter expression that filters resources listed in
226   * the response. The expression must specify the field name, an operator, and
227   * the value that you want to use for filtering. The value must be a string, a
228   * number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`,
229   * `>=` or `:`. For example, if you are filtering Compute Engine instances, you
230   * can exclude instances named `example-instance` by specifying `name !=
231   * example-instance`. The `:` operator can be used with string fields to match
232   * substrings. For non-string fields it is equivalent to the `=` operator. The
233   * `:*` comparison can be used to test whether a key has been defined. For
234   * example, to find all objects with `owner` label use: ``` labels.owner:* ```
235   * You can also filter nested fields. For example, you could specify
236   * `scheduling.automaticRestart = false` to include instances only if they are
237   * not scheduled for automatic restarts. You can use filtering on nested fields
238   * to filter based on resource labels. To filter on multiple expressions,
239   * provide each separate expression within parentheses. For example: ```
240   * (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By
241   * default, each expression is an `AND` expression. However, you can include
242   * `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel
243   * Skylake") OR (cpuPlatform = "Intel Broadwell") AND
244   * (scheduling.automaticRestart = true) ```
245   * @opt_param string maxResults The maximum number of results per page that
246   * should be returned. If the number of available results is larger than
247   * `maxResults`, Compute Engine returns a `nextPageToken` that can be used to
248   * get the next page of results in subsequent list requests. Acceptable values
249   * are `0` to `500`, inclusive. (Default: `500`)
250   * @opt_param string orderBy Sorts list results by a certain order. By default,
251   * results are returned in alphanumerical order based on the resource name. You
252   * can also sort results in descending order based on the creation timestamp
253   * using `orderBy="creationTimestamp desc"`. This sorts results based on the
254   * `creationTimestamp` field in reverse chronological order (newest result
255   * first). Use this to sort resources like operations so that the newest
256   * operation is returned first. Currently, only sorting by `name` or
257   * `creationTimestamp desc` is supported.
258   * @opt_param string pageToken Specifies a page token to use. Set `pageToken` to
259   * the `nextPageToken` returned by a previous list request to get the next page
260   * of results.
261   * @opt_param bool returnPartialSuccess Opt-in for partial success behavior
262   * which provides partial results in case of failure. The default value is
263   * false.
264   * @return SubnetworkList
265   */
266  public function listSubnetworks($project, $region, $optParams = [])
267  {
268    $params = ['project' => $project, 'region' => $region];
269    $params = array_merge($params, $optParams);
270    return $this->call('list', [$params], SubnetworkList::class);
271  }
272  /**
273   * Retrieves an aggregated list of all usable subnetworks in the project.
274   * (subnetworks.listUsable)
275   *
276   * @param string $project Project ID for this request.
277   * @param array $optParams Optional parameters.
278   *
279   * @opt_param string filter A filter expression that filters resources listed in
280   * the response. The expression must specify the field name, an operator, and
281   * the value that you want to use for filtering. The value must be a string, a
282   * number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`,
283   * `>=` or `:`. For example, if you are filtering Compute Engine instances, you
284   * can exclude instances named `example-instance` by specifying `name !=
285   * example-instance`. The `:` operator can be used with string fields to match
286   * substrings. For non-string fields it is equivalent to the `=` operator. The
287   * `:*` comparison can be used to test whether a key has been defined. For
288   * example, to find all objects with `owner` label use: ``` labels.owner:* ```
289   * You can also filter nested fields. For example, you could specify
290   * `scheduling.automaticRestart = false` to include instances only if they are
291   * not scheduled for automatic restarts. You can use filtering on nested fields
292   * to filter based on resource labels. To filter on multiple expressions,
293   * provide each separate expression within parentheses. For example: ```
294   * (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By
295   * default, each expression is an `AND` expression. However, you can include
296   * `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel
297   * Skylake") OR (cpuPlatform = "Intel Broadwell") AND
298   * (scheduling.automaticRestart = true) ```
299   * @opt_param string maxResults The maximum number of results per page that
300   * should be returned. If the number of available results is larger than
301   * `maxResults`, Compute Engine returns a `nextPageToken` that can be used to
302   * get the next page of results in subsequent list requests. Acceptable values
303   * are `0` to `500`, inclusive. (Default: `500`)
304   * @opt_param string orderBy Sorts list results by a certain order. By default,
305   * results are returned in alphanumerical order based on the resource name. You
306   * can also sort results in descending order based on the creation timestamp
307   * using `orderBy="creationTimestamp desc"`. This sorts results based on the
308   * `creationTimestamp` field in reverse chronological order (newest result
309   * first). Use this to sort resources like operations so that the newest
310   * operation is returned first. Currently, only sorting by `name` or
311   * `creationTimestamp desc` is supported.
312   * @opt_param string pageToken Specifies a page token to use. Set `pageToken` to
313   * the `nextPageToken` returned by a previous list request to get the next page
314   * of results.
315   * @opt_param bool returnPartialSuccess Opt-in for partial success behavior
316   * which provides partial results in case of failure. The default value is
317   * false.
318   * @return UsableSubnetworksAggregatedList
319   */
320  public function listUsable($project, $optParams = [])
321  {
322    $params = ['project' => $project];
323    $params = array_merge($params, $optParams);
324    return $this->call('listUsable', [$params], UsableSubnetworksAggregatedList::class);
325  }
326  /**
327   * Patches the specified subnetwork with the data included in the request. Only
328   * certain fields can be updated with a patch request as indicated in the field
329   * descriptions. You must specify the current fingerprint of the subnetwork
330   * resource being patched. (subnetworks.patch)
331   *
332   * @param string $project Project ID for this request.
333   * @param string $region Name of the region scoping this request.
334   * @param string $subnetwork Name of the Subnetwork resource to patch.
335   * @param Subnetwork $postBody
336   * @param array $optParams Optional parameters.
337   *
338   * @opt_param int drainTimeoutSeconds The drain timeout specifies the upper
339   * bound in seconds on the amount of time allowed to drain connections from the
340   * current ACTIVE subnetwork to the current BACKUP subnetwork. The drain timeout
341   * is only applicable when the following conditions are true: - the subnetwork
342   * being patched has purpose = INTERNAL_HTTPS_LOAD_BALANCER - the subnetwork
343   * being patched has role = BACKUP - the patch request is setting the role to
344   * ACTIVE. Note that after this patch operation the roles of the ACTIVE and
345   * BACKUP subnetworks will be swapped.
346   * @opt_param string requestId An optional request ID to identify requests.
347   * Specify a unique request ID so that if you must retry your request, the
348   * server will know to ignore the request if it has already been completed. For
349   * example, consider a situation where you make an initial request and the
350   * request times out. If you make the request again with the same request ID,
351   * the server can check if original operation with the same request ID was
352   * received, and if so, will ignore the second request. This prevents clients
353   * from accidentally creating duplicate commitments. The request ID must be a
354   * valid UUID with the exception that zero UUID is not supported (
355   * 00000000-0000-0000-0000-000000000000).
356   * @return Operation
357   */
358  public function patch($project, $region, $subnetwork, Subnetwork $postBody, $optParams = [])
359  {
360    $params = ['project' => $project, 'region' => $region, 'subnetwork' => $subnetwork, 'postBody' => $postBody];
361    $params = array_merge($params, $optParams);
362    return $this->call('patch', [$params], Operation::class);
363  }
364  /**
365   * Sets the access control policy on the specified resource. Replaces any
366   * existing policy. (subnetworks.setIamPolicy)
367   *
368   * @param string $project Project ID for this request.
369   * @param string $region The name of the region for this request.
370   * @param string $resource Name or id of the resource for this request.
371   * @param RegionSetPolicyRequest $postBody
372   * @param array $optParams Optional parameters.
373   * @return Policy
374   */
375  public function setIamPolicy($project, $region, $resource, RegionSetPolicyRequest $postBody, $optParams = [])
376  {
377    $params = ['project' => $project, 'region' => $region, 'resource' => $resource, 'postBody' => $postBody];
378    $params = array_merge($params, $optParams);
379    return $this->call('setIamPolicy', [$params], Policy::class);
380  }
381  /**
382   * Set whether VMs in this subnet can access Google services without assigning
383   * external IP addresses through Private Google Access.
384   * (subnetworks.setPrivateIpGoogleAccess)
385   *
386   * @param string $project Project ID for this request.
387   * @param string $region Name of the region scoping this request.
388   * @param string $subnetwork Name of the Subnetwork resource.
389   * @param SubnetworksSetPrivateIpGoogleAccessRequest $postBody
390   * @param array $optParams Optional parameters.
391   *
392   * @opt_param string requestId An optional request ID to identify requests.
393   * Specify a unique request ID so that if you must retry your request, the
394   * server will know to ignore the request if it has already been completed. For
395   * example, consider a situation where you make an initial request and the
396   * request times out. If you make the request again with the same request ID,
397   * the server can check if original operation with the same request ID was
398   * received, and if so, will ignore the second request. This prevents clients
399   * from accidentally creating duplicate commitments. The request ID must be a
400   * valid UUID with the exception that zero UUID is not supported (
401   * 00000000-0000-0000-0000-000000000000).
402   * @return Operation
403   */
404  public function setPrivateIpGoogleAccess($project, $region, $subnetwork, SubnetworksSetPrivateIpGoogleAccessRequest $postBody, $optParams = [])
405  {
406    $params = ['project' => $project, 'region' => $region, 'subnetwork' => $subnetwork, 'postBody' => $postBody];
407    $params = array_merge($params, $optParams);
408    return $this->call('setPrivateIpGoogleAccess', [$params], Operation::class);
409  }
410  /**
411   * Returns permissions that a caller has on the specified resource.
412   * (subnetworks.testIamPermissions)
413   *
414   * @param string $project Project ID for this request.
415   * @param string $region The name of the region for this request.
416   * @param string $resource Name or id of the resource for this request.
417   * @param TestPermissionsRequest $postBody
418   * @param array $optParams Optional parameters.
419   * @return TestPermissionsResponse
420   */
421  public function testIamPermissions($project, $region, $resource, TestPermissionsRequest $postBody, $optParams = [])
422  {
423    $params = ['project' => $project, 'region' => $region, 'resource' => $resource, 'postBody' => $postBody];
424    $params = array_merge($params, $optParams);
425    return $this->call('testIamPermissions', [$params], TestPermissionsResponse::class);
426  }
427}
428
429// Adding a class alias for backwards compatibility with the previous class name.
430class_alias(Subnetworks::class, 'Google_Service_Compute_Resource_Subnetworks');
431