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\AccessContextManager\Resource;
19
20use Google\Service\AccessContextManager\AccessPolicy;
21use Google\Service\AccessContextManager\GetIamPolicyRequest;
22use Google\Service\AccessContextManager\ListAccessPoliciesResponse;
23use Google\Service\AccessContextManager\Operation;
24use Google\Service\AccessContextManager\Policy;
25use Google\Service\AccessContextManager\SetIamPolicyRequest;
26use Google\Service\AccessContextManager\TestIamPermissionsRequest;
27use Google\Service\AccessContextManager\TestIamPermissionsResponse;
28
29/**
30 * The "accessPolicies" collection of methods.
31 * Typical usage is:
32 *  <code>
33 *   $accesscontextmanagerService = new Google\Service\AccessContextManager(...);
34 *   $accessPolicies = $accesscontextmanagerService->accessPolicies;
35 *  </code>
36 */
37class AccessPolicies extends \Google\Service\Resource
38{
39  /**
40   * Creates an access policy. This method fails if the organization already has
41   * an access policy. The long-running operation has a successful status after
42   * the access policy propagates to long-lasting storage. Syntactic and basic
43   * semantic errors are returned in `metadata` as a BadRequest proto.
44   * (accessPolicies.create)
45   *
46   * @param AccessPolicy $postBody
47   * @param array $optParams Optional parameters.
48   * @return Operation
49   */
50  public function create(AccessPolicy $postBody, $optParams = [])
51  {
52    $params = ['postBody' => $postBody];
53    $params = array_merge($params, $optParams);
54    return $this->call('create', [$params], Operation::class);
55  }
56  /**
57   * Deletes an access policy based on the resource name. The long-running
58   * operation has a successful status after the access policy is removed from
59   * long-lasting storage. (accessPolicies.delete)
60   *
61   * @param string $name Required. Resource name for the access policy to delete.
62   * Format `accessPolicies/{policy_id}`
63   * @param array $optParams Optional parameters.
64   * @return Operation
65   */
66  public function delete($name, $optParams = [])
67  {
68    $params = ['name' => $name];
69    $params = array_merge($params, $optParams);
70    return $this->call('delete', [$params], Operation::class);
71  }
72  /**
73   * Returns an access policy based on the name. (accessPolicies.get)
74   *
75   * @param string $name Required. Resource name for the access policy to get.
76   * Format `accessPolicies/{policy_id}`
77   * @param array $optParams Optional parameters.
78   * @return AccessPolicy
79   */
80  public function get($name, $optParams = [])
81  {
82    $params = ['name' => $name];
83    $params = array_merge($params, $optParams);
84    return $this->call('get', [$params], AccessPolicy::class);
85  }
86  /**
87   * Gets the IAM policy for the specified Access Context Manager access policy.
88   * (accessPolicies.getIamPolicy)
89   *
90   * @param string $resource REQUIRED: The resource for which the policy is being
91   * requested. See the operation documentation for the appropriate value for this
92   * field.
93   * @param GetIamPolicyRequest $postBody
94   * @param array $optParams Optional parameters.
95   * @return Policy
96   */
97  public function getIamPolicy($resource, GetIamPolicyRequest $postBody, $optParams = [])
98  {
99    $params = ['resource' => $resource, 'postBody' => $postBody];
100    $params = array_merge($params, $optParams);
101    return $this->call('getIamPolicy', [$params], Policy::class);
102  }
103  /**
104   * Lists all access policies in an organization.
105   * (accessPolicies.listAccessPolicies)
106   *
107   * @param array $optParams Optional parameters.
108   *
109   * @opt_param int pageSize Number of AccessPolicy instances to include in the
110   * list. Default 100.
111   * @opt_param string pageToken Next page token for the next batch of
112   * AccessPolicy instances. Defaults to the first page of results.
113   * @opt_param string parent Required. Resource name for the container to list
114   * AccessPolicy instances from. Format: `organizations/{org_id}`
115   * @return ListAccessPoliciesResponse
116   */
117  public function listAccessPolicies($optParams = [])
118  {
119    $params = [];
120    $params = array_merge($params, $optParams);
121    return $this->call('list', [$params], ListAccessPoliciesResponse::class);
122  }
123  /**
124   * Updates an access policy. The long-running operation from this RPC has a
125   * successful status after the changes to the access policy propagate to long-
126   * lasting storage. (accessPolicies.patch)
127   *
128   * @param string $name Output only. Resource name of the `AccessPolicy`. Format:
129   * `accessPolicies/{access_policy}`
130   * @param AccessPolicy $postBody
131   * @param array $optParams Optional parameters.
132   *
133   * @opt_param string updateMask Required. Mask to control which fields get
134   * updated. Must be non-empty.
135   * @return Operation
136   */
137  public function patch($name, AccessPolicy $postBody, $optParams = [])
138  {
139    $params = ['name' => $name, 'postBody' => $postBody];
140    $params = array_merge($params, $optParams);
141    return $this->call('patch', [$params], Operation::class);
142  }
143  /**
144   * Sets the IAM policy for the specified Access Context Manager access policy.
145   * This method replaces the existing IAM policy on the access policy. The IAM
146   * policy controls the set of users who can perform specific operations on the
147   * Access Context Manager access policy. (accessPolicies.setIamPolicy)
148   *
149   * @param string $resource REQUIRED: The resource for which the policy is being
150   * specified. See the operation documentation for the appropriate value for this
151   * field.
152   * @param SetIamPolicyRequest $postBody
153   * @param array $optParams Optional parameters.
154   * @return Policy
155   */
156  public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
157  {
158    $params = ['resource' => $resource, 'postBody' => $postBody];
159    $params = array_merge($params, $optParams);
160    return $this->call('setIamPolicy', [$params], Policy::class);
161  }
162  /**
163   * Returns the IAM permissions that the caller has on the specified Access
164   * Context Manager resource. The resource can be an AccessPolicy, AccessLevel,
165   * or ServicePerimeter. This method does not support other resources.
166   * (accessPolicies.testIamPermissions)
167   *
168   * @param string $resource REQUIRED: The resource for which the policy detail is
169   * being requested. See the operation documentation for the appropriate value
170   * for this field.
171   * @param TestIamPermissionsRequest $postBody
172   * @param array $optParams Optional parameters.
173   * @return TestIamPermissionsResponse
174   */
175  public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = [])
176  {
177    $params = ['resource' => $resource, 'postBody' => $postBody];
178    $params = array_merge($params, $optParams);
179    return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
180  }
181}
182
183// Adding a class alias for backwards compatibility with the previous class name.
184class_alias(AccessPolicies::class, 'Google_Service_AccessContextManager_Resource_AccessPolicies');
185