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\Eventarc\Resource;
19
20use Google\Service\Eventarc\GoogleLongrunningOperation;
21use Google\Service\Eventarc\ListTriggersResponse;
22use Google\Service\Eventarc\Policy;
23use Google\Service\Eventarc\SetIamPolicyRequest;
24use Google\Service\Eventarc\TestIamPermissionsRequest;
25use Google\Service\Eventarc\TestIamPermissionsResponse;
26use Google\Service\Eventarc\Trigger;
27
28/**
29 * The "triggers" collection of methods.
30 * Typical usage is:
31 *  <code>
32 *   $eventarcService = new Google\Service\Eventarc(...);
33 *   $triggers = $eventarcService->triggers;
34 *  </code>
35 */
36class ProjectsLocationsTriggers extends \Google\Service\Resource
37{
38  /**
39   * Create a new trigger in a particular project and location. (triggers.create)
40   *
41   * @param string $parent Required. The parent collection in which to add this
42   * trigger.
43   * @param Trigger $postBody
44   * @param array $optParams Optional parameters.
45   *
46   * @opt_param string triggerId Required. The user-provided ID to be assigned to
47   * the trigger.
48   * @opt_param bool validateOnly Required. If set, validate the request and
49   * preview the review, but do not post it.
50   * @return GoogleLongrunningOperation
51   */
52  public function create($parent, Trigger $postBody, $optParams = [])
53  {
54    $params = ['parent' => $parent, 'postBody' => $postBody];
55    $params = array_merge($params, $optParams);
56    return $this->call('create', [$params], GoogleLongrunningOperation::class);
57  }
58  /**
59   * Delete a single trigger. (triggers.delete)
60   *
61   * @param string $name Required. The name of the trigger to be deleted.
62   * @param array $optParams Optional parameters.
63   *
64   * @opt_param bool allowMissing If set to true, and the trigger is not found,
65   * the request will succeed but no action will be taken on the server.
66   * @opt_param string etag If provided, the trigger will only be deleted if the
67   * etag matches the current etag on the resource.
68   * @opt_param bool validateOnly Required. If set, validate the request and
69   * preview the review, but do not post it.
70   * @return GoogleLongrunningOperation
71   */
72  public function delete($name, $optParams = [])
73  {
74    $params = ['name' => $name];
75    $params = array_merge($params, $optParams);
76    return $this->call('delete', [$params], GoogleLongrunningOperation::class);
77  }
78  /**
79   * Get a single trigger. (triggers.get)
80   *
81   * @param string $name Required. The name of the trigger to get.
82   * @param array $optParams Optional parameters.
83   * @return Trigger
84   */
85  public function get($name, $optParams = [])
86  {
87    $params = ['name' => $name];
88    $params = array_merge($params, $optParams);
89    return $this->call('get', [$params], Trigger::class);
90  }
91  /**
92   * Gets the access control policy for a resource. Returns an empty policy if the
93   * resource exists and does not have a policy set. (triggers.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 Policy
113   */
114  public function getIamPolicy($resource, $optParams = [])
115  {
116    $params = ['resource' => $resource];
117    $params = array_merge($params, $optParams);
118    return $this->call('getIamPolicy', [$params], Policy::class);
119  }
120  /**
121   * List triggers. (triggers.listProjectsLocationsTriggers)
122   *
123   * @param string $parent Required. The parent collection to list triggers on.
124   * @param array $optParams Optional parameters.
125   *
126   * @opt_param string filter Filter field. Used to filter the Triggers to be
127   * listed. Possible filters are described in https://google.aip.dev/160. For
128   * example, using "?filter=destination:gke" would list only Triggers with a gke
129   * destination.
130   * @opt_param string orderBy The sorting order of the resources returned. Value
131   * should be a comma-separated list of fields. The default sorting order is
132   * ascending. To specify descending order for a field, append a `desc` suffix;
133   * for example: `name desc, trigger_id`.
134   * @opt_param int pageSize The maximum number of triggers to return on each
135   * page. Note: The service may send fewer.
136   * @opt_param string pageToken The page token; provide the value from the
137   * `next_page_token` field in a previous `ListTriggers` call to retrieve the
138   * subsequent page. When paginating, all other parameters provided to
139   * `ListTriggers` must match the call that provided the page token.
140   * @return ListTriggersResponse
141   */
142  public function listProjectsLocationsTriggers($parent, $optParams = [])
143  {
144    $params = ['parent' => $parent];
145    $params = array_merge($params, $optParams);
146    return $this->call('list', [$params], ListTriggersResponse::class);
147  }
148  /**
149   * Update a single trigger. (triggers.patch)
150   *
151   * @param string $name Required. The resource name of the trigger. Must be
152   * unique within the location of the project and must be in
153   * `projects/{project}/locations/{location}/triggers/{trigger}` format.
154   * @param Trigger $postBody
155   * @param array $optParams Optional parameters.
156   *
157   * @opt_param bool allowMissing If set to true, and the trigger is not found, a
158   * new trigger will be created. In this situation, `update_mask` is ignored.
159   * @opt_param string updateMask The fields to be updated; only fields explicitly
160   * provided are updated. If no field mask is provided, all provided fields in
161   * the request are updated. To update all fields, provide a field mask of "*".
162   * @opt_param bool validateOnly Required. If set, validate the request and
163   * preview the review, but do not post it.
164   * @return GoogleLongrunningOperation
165   */
166  public function patch($name, Trigger $postBody, $optParams = [])
167  {
168    $params = ['name' => $name, 'postBody' => $postBody];
169    $params = array_merge($params, $optParams);
170    return $this->call('patch', [$params], GoogleLongrunningOperation::class);
171  }
172  /**
173   * Sets the access control policy on the specified resource. Replaces any
174   * existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and
175   * `PERMISSION_DENIED` errors. (triggers.setIamPolicy)
176   *
177   * @param string $resource REQUIRED: The resource for which the policy is being
178   * specified. See the operation documentation for the appropriate value for this
179   * field.
180   * @param SetIamPolicyRequest $postBody
181   * @param array $optParams Optional parameters.
182   * @return Policy
183   */
184  public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
185  {
186    $params = ['resource' => $resource, 'postBody' => $postBody];
187    $params = array_merge($params, $optParams);
188    return $this->call('setIamPolicy', [$params], Policy::class);
189  }
190  /**
191   * Returns permissions that a caller has on the specified resource. If the
192   * resource does not exist, this will return an empty set of permissions, not a
193   * `NOT_FOUND` error. Note: This operation is designed to be used for building
194   * permission-aware UIs and command-line tools, not for authorization checking.
195   * This operation may "fail open" without warning. (triggers.testIamPermissions)
196   *
197   * @param string $resource REQUIRED: The resource for which the policy detail is
198   * being requested. See the operation documentation for the appropriate value
199   * for this field.
200   * @param TestIamPermissionsRequest $postBody
201   * @param array $optParams Optional parameters.
202   * @return TestIamPermissionsResponse
203   */
204  public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = [])
205  {
206    $params = ['resource' => $resource, 'postBody' => $postBody];
207    $params = array_merge($params, $optParams);
208    return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
209  }
210}
211
212// Adding a class alias for backwards compatibility with the previous class name.
213class_alias(ProjectsLocationsTriggers::class, 'Google_Service_Eventarc_Resource_ProjectsLocationsTriggers');
214