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