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\Attestor;
21use Google\Service\BinaryAuthorization\BinaryauthorizationEmpty;
22use Google\Service\BinaryAuthorization\IamPolicy;
23use Google\Service\BinaryAuthorization\ListAttestorsResponse;
24use Google\Service\BinaryAuthorization\SetIamPolicyRequest;
25use Google\Service\BinaryAuthorization\TestIamPermissionsRequest;
26use Google\Service\BinaryAuthorization\TestIamPermissionsResponse;
27use Google\Service\BinaryAuthorization\ValidateAttestationOccurrenceRequest;
28use Google\Service\BinaryAuthorization\ValidateAttestationOccurrenceResponse;
29
30/**
31 * The "attestors" collection of methods.
32 * Typical usage is:
33 *  <code>
34 *   $binaryauthorizationService = new Google\Service\BinaryAuthorization(...);
35 *   $attestors = $binaryauthorizationService->attestors;
36 *  </code>
37 */
38class ProjectsAttestors extends \Google\Service\Resource
39{
40  /**
41   * Creates an attestor, and returns a copy of the new attestor. Returns
42   * NOT_FOUND if the project does not exist, INVALID_ARGUMENT if the request is
43   * malformed, ALREADY_EXISTS if the attestor already exists. (attestors.create)
44   *
45   * @param string $parent Required. The parent of this attestor.
46   * @param Attestor $postBody
47   * @param array $optParams Optional parameters.
48   *
49   * @opt_param string attestorId Required. The attestors ID.
50   * @return Attestor
51   */
52  public function create($parent, Attestor $postBody, $optParams = [])
53  {
54    $params = ['parent' => $parent, 'postBody' => $postBody];
55    $params = array_merge($params, $optParams);
56    return $this->call('create', [$params], Attestor::class);
57  }
58  /**
59   * Deletes an attestor. Returns NOT_FOUND if the attestor does not exist.
60   * (attestors.delete)
61   *
62   * @param string $name Required. The name of the attestors to delete, in the
63   * format `projects/attestors`.
64   * @param array $optParams Optional parameters.
65   * @return BinaryauthorizationEmpty
66   */
67  public function delete($name, $optParams = [])
68  {
69    $params = ['name' => $name];
70    $params = array_merge($params, $optParams);
71    return $this->call('delete', [$params], BinaryauthorizationEmpty::class);
72  }
73  /**
74   * Gets an attestor. Returns NOT_FOUND if the attestor does not exist.
75   * (attestors.get)
76   *
77   * @param string $name Required. The name of the attestor to retrieve, in the
78   * format `projects/attestors`.
79   * @param array $optParams Optional parameters.
80   * @return Attestor
81   */
82  public function get($name, $optParams = [])
83  {
84    $params = ['name' => $name];
85    $params = array_merge($params, $optParams);
86    return $this->call('get', [$params], Attestor::class);
87  }
88  /**
89   * Gets the access control policy for a resource. Returns an empty policy if the
90   * resource exists and does not have a policy set. (attestors.getIamPolicy)
91   *
92   * @param string $resource REQUIRED: The resource for which the policy is being
93   * requested. See the operation documentation for the appropriate value for this
94   * field.
95   * @param array $optParams Optional parameters.
96   *
97   * @opt_param int options.requestedPolicyVersion Optional. The maximum policy
98   * version that will be used to format the policy. Valid values are 0, 1, and 3.
99   * Requests specifying an invalid value will be rejected. Requests for policies
100   * with any conditional role bindings must specify version 3. Policies with no
101   * conditional role bindings may specify any valid value or leave the field
102   * unset. The policy in the response might use the policy version that you
103   * specified, or it might use a lower policy version. For example, if you
104   * specify version 3, but the policy has no conditional role bindings, the
105   * response uses version 1. To learn which resources support conditions in their
106   * IAM policies, see the [IAM
107   * documentation](https://cloud.google.com/iam/help/conditions/resource-
108   * policies).
109   * @return IamPolicy
110   */
111  public function getIamPolicy($resource, $optParams = [])
112  {
113    $params = ['resource' => $resource];
114    $params = array_merge($params, $optParams);
115    return $this->call('getIamPolicy', [$params], IamPolicy::class);
116  }
117  /**
118   * Lists attestors. Returns INVALID_ARGUMENT if the project does not exist.
119   * (attestors.listProjectsAttestors)
120   *
121   * @param string $parent Required. The resource name of the project associated
122   * with the attestors, in the format `projects`.
123   * @param array $optParams Optional parameters.
124   *
125   * @opt_param int pageSize Requested page size. The server may return fewer
126   * results than requested. If unspecified, the server will pick an appropriate
127   * default.
128   * @opt_param string pageToken A token identifying a page of results the server
129   * should return. Typically, this is the value of
130   * ListAttestorsResponse.next_page_token returned from the previous call to the
131   * `ListAttestors` method.
132   * @return ListAttestorsResponse
133   */
134  public function listProjectsAttestors($parent, $optParams = [])
135  {
136    $params = ['parent' => $parent];
137    $params = array_merge($params, $optParams);
138    return $this->call('list', [$params], ListAttestorsResponse::class);
139  }
140  /**
141   * Sets the access control policy on the specified resource. Replaces any
142   * existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and
143   * `PERMISSION_DENIED` errors. (attestors.setIamPolicy)
144   *
145   * @param string $resource REQUIRED: The resource for which the policy is being
146   * specified. See the operation documentation for the appropriate value for this
147   * field.
148   * @param SetIamPolicyRequest $postBody
149   * @param array $optParams Optional parameters.
150   * @return IamPolicy
151   */
152  public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
153  {
154    $params = ['resource' => $resource, 'postBody' => $postBody];
155    $params = array_merge($params, $optParams);
156    return $this->call('setIamPolicy', [$params], IamPolicy::class);
157  }
158  /**
159   * Returns permissions that a caller has on the specified resource. If the
160   * resource does not exist, this will return an empty set of permissions, not a
161   * `NOT_FOUND` error. Note: This operation is designed to be used for building
162   * permission-aware UIs and command-line tools, not for authorization checking.
163   * This operation may "fail open" without warning.
164   * (attestors.testIamPermissions)
165   *
166   * @param string $resource REQUIRED: The resource for which the policy detail is
167   * being requested. See the operation documentation for the appropriate value
168   * for this field.
169   * @param TestIamPermissionsRequest $postBody
170   * @param array $optParams Optional parameters.
171   * @return TestIamPermissionsResponse
172   */
173  public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = [])
174  {
175    $params = ['resource' => $resource, 'postBody' => $postBody];
176    $params = array_merge($params, $optParams);
177    return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
178  }
179  /**
180   * Updates an attestor. Returns NOT_FOUND if the attestor does not exist.
181   * (attestors.update)
182   *
183   * @param string $name Required. The resource name, in the format:
184   * `projects/attestors`. This field may not be updated.
185   * @param Attestor $postBody
186   * @param array $optParams Optional parameters.
187   * @return Attestor
188   */
189  public function update($name, Attestor $postBody, $optParams = [])
190  {
191    $params = ['name' => $name, 'postBody' => $postBody];
192    $params = array_merge($params, $optParams);
193    return $this->call('update', [$params], Attestor::class);
194  }
195  /**
196   * Returns whether the given Attestation for the given image URI was signed by
197   * the given Attestor (attestors.validateAttestationOccurrence)
198   *
199   * @param string $attestor Required. The resource name of the Attestor of the
200   * occurrence, in the format `projects/attestors`.
201   * @param ValidateAttestationOccurrenceRequest $postBody
202   * @param array $optParams Optional parameters.
203   * @return ValidateAttestationOccurrenceResponse
204   */
205  public function validateAttestationOccurrence($attestor, ValidateAttestationOccurrenceRequest $postBody, $optParams = [])
206  {
207    $params = ['attestor' => $attestor, 'postBody' => $postBody];
208    $params = array_merge($params, $optParams);
209    return $this->call('validateAttestationOccurrence', [$params], ValidateAttestationOccurrenceResponse::class);
210  }
211}
212
213// Adding a class alias for backwards compatibility with the previous class name.
214class_alias(ProjectsAttestors::class, 'Google_Service_BinaryAuthorization_Resource_ProjectsAttestors');
215