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