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\BinaryAuthorization\Resource;
19
20use Google\Service\BinaryAuthorization\IamPolicy;
21use Google\Service\BinaryAuthorization\SetIamPolicyRequest;
22use Google\Service\BinaryAuthorization\TestIamPermissionsRequest;
23use Google\Service\BinaryAuthorization\TestIamPermissionsResponse;
24
25/**
26 * The "policy" collection of methods.
27 * Typical usage is:
28 *  <code>
29 *   $binaryauthorizationService = new Google\Service\BinaryAuthorization(...);
30 *   $policy = $binaryauthorizationService->policy;
31 *  </code>
32 */
33class ProjectsPolicy extends \Google\Service\Resource
34{
35  /**
36   * Gets the access control policy for a resource. Returns an empty policy if the
37   * resource exists and does not have a policy set. (policy.getIamPolicy)
38   *
39   * @param string $resource REQUIRED: The resource for which the policy is being
40   * requested. See the operation documentation for the appropriate value for this
41   * field.
42   * @param array $optParams Optional parameters.
43   *
44   * @opt_param int options.requestedPolicyVersion Optional. The maximum policy
45   * version that will be used to format the policy. Valid values are 0, 1, and 3.
46   * Requests specifying an invalid value will be rejected. Requests for policies
47   * with any conditional role bindings must specify version 3. Policies with no
48   * conditional role bindings may specify any valid value or leave the field
49   * unset. The policy in the response might use the policy version that you
50   * specified, or it might use a lower policy version. For example, if you
51   * specify version 3, but the policy has no conditional role bindings, the
52   * response uses version 1. To learn which resources support conditions in their
53   * IAM policies, see the [IAM
54   * documentation](https://cloud.google.com/iam/help/conditions/resource-
55   * policies).
56   * @return IamPolicy
57   */
58  public function getIamPolicy($resource, $optParams = [])
59  {
60    $params = ['resource' => $resource];
61    $params = array_merge($params, $optParams);
62    return $this->call('getIamPolicy', [$params], IamPolicy::class);
63  }
64  /**
65   * Sets the access control policy on the specified resource. Replaces any
66   * existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and
67   * `PERMISSION_DENIED` errors. (policy.setIamPolicy)
68   *
69   * @param string $resource REQUIRED: The resource for which the policy is being
70   * specified. See the operation documentation for the appropriate value for this
71   * field.
72   * @param SetIamPolicyRequest $postBody
73   * @param array $optParams Optional parameters.
74   * @return IamPolicy
75   */
76  public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
77  {
78    $params = ['resource' => $resource, 'postBody' => $postBody];
79    $params = array_merge($params, $optParams);
80    return $this->call('setIamPolicy', [$params], IamPolicy::class);
81  }
82  /**
83   * Returns permissions that a caller has on the specified resource. If the
84   * resource does not exist, this will return an empty set of permissions, not a
85   * `NOT_FOUND` error. Note: This operation is designed to be used for building
86   * permission-aware UIs and command-line tools, not for authorization checking.
87   * This operation may "fail open" without warning. (policy.testIamPermissions)
88   *
89   * @param string $resource REQUIRED: The resource for which the policy detail is
90   * being requested. See the operation documentation for the appropriate value
91   * for this field.
92   * @param TestIamPermissionsRequest $postBody
93   * @param array $optParams Optional parameters.
94   * @return TestIamPermissionsResponse
95   */
96  public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = [])
97  {
98    $params = ['resource' => $resource, 'postBody' => $postBody];
99    $params = array_merge($params, $optParams);
100    return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
101  }
102}
103
104// Adding a class alias for backwards compatibility with the previous class name.
105class_alias(ProjectsPolicy::class, 'Google_Service_BinaryAuthorization_Resource_ProjectsPolicy');
106