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\NetworkSecurity\Resource;
19
20use Google\Service\NetworkSecurity\AuthorizationPolicy;
21use Google\Service\NetworkSecurity\GoogleIamV1Policy;
22use Google\Service\NetworkSecurity\GoogleIamV1SetIamPolicyRequest;
23use Google\Service\NetworkSecurity\GoogleIamV1TestIamPermissionsRequest;
24use Google\Service\NetworkSecurity\GoogleIamV1TestIamPermissionsResponse;
25use Google\Service\NetworkSecurity\ListAuthorizationPoliciesResponse;
26use Google\Service\NetworkSecurity\Operation;
27
28/**
29 * The "authorizationPolicies" collection of methods.
30 * Typical usage is:
31 *  <code>
32 *   $networksecurityService = new Google\Service\NetworkSecurity(...);
33 *   $authorizationPolicies = $networksecurityService->authorizationPolicies;
34 *  </code>
35 */
36class ProjectsLocationsAuthorizationPolicies extends \Google\Service\Resource
37{
38  /**
39   * Creates a new AuthorizationPolicy in a given project and location.
40   * (authorizationPolicies.create)
41   *
42   * @param string $parent Required. The parent resource of the
43   * AuthorizationPolicy. Must be in the format
44   * `projects/{project}/locations/{location}`.
45   * @param AuthorizationPolicy $postBody
46   * @param array $optParams Optional parameters.
47   *
48   * @opt_param string authorizationPolicyId Required. Short name of the
49   * AuthorizationPolicy resource to be created. This value should be 1-63
50   * characters long, containing only letters, numbers, hyphens, and underscores,
51   * and should not start with a number. E.g. "authz_policy".
52   * @return Operation
53   */
54  public function create($parent, AuthorizationPolicy $postBody, $optParams = [])
55  {
56    $params = ['parent' => $parent, 'postBody' => $postBody];
57    $params = array_merge($params, $optParams);
58    return $this->call('create', [$params], Operation::class);
59  }
60  /**
61   * Deletes a single AuthorizationPolicy. (authorizationPolicies.delete)
62   *
63   * @param string $name Required. A name of the AuthorizationPolicy to delete.
64   * Must be in the format
65   * `projects/{project}/locations/{location}/authorizationPolicies`.
66   * @param array $optParams Optional parameters.
67   * @return Operation
68   */
69  public function delete($name, $optParams = [])
70  {
71    $params = ['name' => $name];
72    $params = array_merge($params, $optParams);
73    return $this->call('delete', [$params], Operation::class);
74  }
75  /**
76   * Gets details of a single AuthorizationPolicy. (authorizationPolicies.get)
77   *
78   * @param string $name Required. A name of the AuthorizationPolicy to get. Must
79   * be in the format
80   * `projects/{project}/locations/{location}/authorizationPolicies`.
81   * @param array $optParams Optional parameters.
82   * @return AuthorizationPolicy
83   */
84  public function get($name, $optParams = [])
85  {
86    $params = ['name' => $name];
87    $params = array_merge($params, $optParams);
88    return $this->call('get', [$params], AuthorizationPolicy::class);
89  }
90  /**
91   * Gets the access control policy for a resource. Returns an empty policy if the
92   * resource exists and does not have a policy set.
93   * (authorizationPolicies.getIamPolicy)
94   *
95   * @param string $resource REQUIRED: The resource for which the policy is being
96   * requested. See the operation documentation for the appropriate value for this
97   * field.
98   * @param array $optParams Optional parameters.
99   *
100   * @opt_param int options.requestedPolicyVersion Optional. The maximum policy
101   * version that will be used to format the policy. Valid values are 0, 1, and 3.
102   * Requests specifying an invalid value will be rejected. Requests for policies
103   * with any conditional role bindings must specify version 3. Policies with no
104   * conditional role bindings may specify any valid value or leave the field
105   * unset. The policy in the response might use the policy version that you
106   * specified, or it might use a lower policy version. For example, if you
107   * specify version 3, but the policy has no conditional role bindings, the
108   * response uses version 1. To learn which resources support conditions in their
109   * IAM policies, see the [IAM
110   * documentation](https://cloud.google.com/iam/help/conditions/resource-
111   * policies).
112   * @return GoogleIamV1Policy
113   */
114  public function getIamPolicy($resource, $optParams = [])
115  {
116    $params = ['resource' => $resource];
117    $params = array_merge($params, $optParams);
118    return $this->call('getIamPolicy', [$params], GoogleIamV1Policy::class);
119  }
120  /**
121   * Lists AuthorizationPolicies in a given project and location.
122   * (authorizationPolicies.listProjectsLocationsAuthorizationPolicies)
123   *
124   * @param string $parent Required. The project and location from which the
125   * AuthorizationPolicies should be listed, specified in the format
126   * `projects/{project}/locations/{location}`.
127   * @param array $optParams Optional parameters.
128   *
129   * @opt_param int pageSize Maximum number of AuthorizationPolicies to return per
130   * call.
131   * @opt_param string pageToken The value returned by the last
132   * `ListAuthorizationPoliciesResponse` Indicates that this is a continuation of
133   * a prior `ListAuthorizationPolicies` call, and that the system should return
134   * the next page of data.
135   * @return ListAuthorizationPoliciesResponse
136   */
137  public function listProjectsLocationsAuthorizationPolicies($parent, $optParams = [])
138  {
139    $params = ['parent' => $parent];
140    $params = array_merge($params, $optParams);
141    return $this->call('list', [$params], ListAuthorizationPoliciesResponse::class);
142  }
143  /**
144   * Updates the parameters of a single AuthorizationPolicy.
145   * (authorizationPolicies.patch)
146   *
147   * @param string $name Required. Name of the AuthorizationPolicy resource. It
148   * matches pattern
149   * `projects/{project}/locations/{location}/authorizationPolicies/`.
150   * @param AuthorizationPolicy $postBody
151   * @param array $optParams Optional parameters.
152   *
153   * @opt_param string updateMask Optional. Field mask is used to specify the
154   * fields to be overwritten in the AuthorizationPolicy resource by the update.
155   * The fields specified in the update_mask are relative to the resource, not the
156   * full request. A field will be overwritten if it is in the mask. If the user
157   * does not provide a mask then all fields will be overwritten.
158   * @return Operation
159   */
160  public function patch($name, AuthorizationPolicy $postBody, $optParams = [])
161  {
162    $params = ['name' => $name, 'postBody' => $postBody];
163    $params = array_merge($params, $optParams);
164    return $this->call('patch', [$params], Operation::class);
165  }
166  /**
167   * Sets the access control policy on the specified resource. Replaces any
168   * existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and
169   * `PERMISSION_DENIED` errors. (authorizationPolicies.setIamPolicy)
170   *
171   * @param string $resource REQUIRED: The resource for which the policy is being
172   * specified. See the operation documentation for the appropriate value for this
173   * field.
174   * @param GoogleIamV1SetIamPolicyRequest $postBody
175   * @param array $optParams Optional parameters.
176   * @return GoogleIamV1Policy
177   */
178  public function setIamPolicy($resource, GoogleIamV1SetIamPolicyRequest $postBody, $optParams = [])
179  {
180    $params = ['resource' => $resource, 'postBody' => $postBody];
181    $params = array_merge($params, $optParams);
182    return $this->call('setIamPolicy', [$params], GoogleIamV1Policy::class);
183  }
184  /**
185   * Returns permissions that a caller has on the specified resource. If the
186   * resource does not exist, this will return an empty set of permissions, not a
187   * `NOT_FOUND` error. Note: This operation is designed to be used for building
188   * permission-aware UIs and command-line tools, not for authorization checking.
189   * This operation may "fail open" without warning.
190   * (authorizationPolicies.testIamPermissions)
191   *
192   * @param string $resource REQUIRED: The resource for which the policy detail is
193   * being requested. See the operation documentation for the appropriate value
194   * for this field.
195   * @param GoogleIamV1TestIamPermissionsRequest $postBody
196   * @param array $optParams Optional parameters.
197   * @return GoogleIamV1TestIamPermissionsResponse
198   */
199  public function testIamPermissions($resource, GoogleIamV1TestIamPermissionsRequest $postBody, $optParams = [])
200  {
201    $params = ['resource' => $resource, 'postBody' => $postBody];
202    $params = array_merge($params, $optParams);
203    return $this->call('testIamPermissions', [$params], GoogleIamV1TestIamPermissionsResponse::class);
204  }
205}
206
207// Adding a class alias for backwards compatibility with the previous class name.
208class_alias(ProjectsLocationsAuthorizationPolicies::class, 'Google_Service_NetworkSecurity_Resource_ProjectsLocationsAuthorizationPolicies');
209