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