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\CloudTasks\Resource;
19
20use Google\Service\CloudTasks\CloudtasksEmpty;
21use Google\Service\CloudTasks\GetIamPolicyRequest;
22use Google\Service\CloudTasks\ListQueuesResponse;
23use Google\Service\CloudTasks\PauseQueueRequest;
24use Google\Service\CloudTasks\Policy;
25use Google\Service\CloudTasks\PurgeQueueRequest;
26use Google\Service\CloudTasks\Queue;
27use Google\Service\CloudTasks\ResumeQueueRequest;
28use Google\Service\CloudTasks\SetIamPolicyRequest;
29use Google\Service\CloudTasks\TestIamPermissionsRequest;
30use Google\Service\CloudTasks\TestIamPermissionsResponse;
31
32/**
33 * The "queues" collection of methods.
34 * Typical usage is:
35 *  <code>
36 *   $cloudtasksService = new Google\Service\CloudTasks(...);
37 *   $queues = $cloudtasksService->queues;
38 *  </code>
39 */
40class ProjectsLocationsQueues extends \Google\Service\Resource
41{
42  /**
43   * Creates a queue. Queues created with this method allow tasks to live for a
44   * maximum of 31 days. After a task is 31 days old, the task will be deleted
45   * regardless of whether it was dispatched or not. WARNING: Using this method
46   * may have unintended side effects if you are using an App Engine `queue.yaml`
47   * or `queue.xml` file to manage your queues. Read [Overview of Queue Management
48   * and queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
49   * this method. (queues.create)
50   *
51   * @param string $parent Required. The location name in which the queue will be
52   * created. For example: `projects/PROJECT_ID/locations/LOCATION_ID` The list of
53   * allowed locations can be obtained by calling Cloud Tasks' implementation of
54   * ListLocations.
55   * @param Queue $postBody
56   * @param array $optParams Optional parameters.
57   * @return Queue
58   */
59  public function create($parent, Queue $postBody, $optParams = [])
60  {
61    $params = ['parent' => $parent, 'postBody' => $postBody];
62    $params = array_merge($params, $optParams);
63    return $this->call('create', [$params], Queue::class);
64  }
65  /**
66   * Deletes a queue. This command will delete the queue even if it has tasks in
67   * it. Note: If you delete a queue, a queue with the same name can't be created
68   * for 7 days. WARNING: Using this method may have unintended side effects if
69   * you are using an App Engine `queue.yaml` or `queue.xml` file to manage your
70   * queues. Read [Overview of Queue Management and
71   * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this
72   * method. (queues.delete)
73   *
74   * @param string $name Required. The queue name. For example:
75   * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
76   * @param array $optParams Optional parameters.
77   * @return CloudtasksEmpty
78   */
79  public function delete($name, $optParams = [])
80  {
81    $params = ['name' => $name];
82    $params = array_merge($params, $optParams);
83    return $this->call('delete', [$params], CloudtasksEmpty::class);
84  }
85  /**
86   * Gets a queue. (queues.get)
87   *
88   * @param string $name Required. The resource name of the queue. For example:
89   * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
90   * @param array $optParams Optional parameters.
91   * @return Queue
92   */
93  public function get($name, $optParams = [])
94  {
95    $params = ['name' => $name];
96    $params = array_merge($params, $optParams);
97    return $this->call('get', [$params], Queue::class);
98  }
99  /**
100   * Gets the access control policy for a Queue. Returns an empty policy if the
101   * resource exists and does not have a policy set. Authorization requires the
102   * following [Google IAM](https://cloud.google.com/iam) permission on the
103   * specified resource parent: * `cloudtasks.queues.getIamPolicy`
104   * (queues.getIamPolicy)
105   *
106   * @param string $resource REQUIRED: The resource for which the policy is being
107   * requested. See the operation documentation for the appropriate value for this
108   * field.
109   * @param GetIamPolicyRequest $postBody
110   * @param array $optParams Optional parameters.
111   * @return Policy
112   */
113  public function getIamPolicy($resource, GetIamPolicyRequest $postBody, $optParams = [])
114  {
115    $params = ['resource' => $resource, 'postBody' => $postBody];
116    $params = array_merge($params, $optParams);
117    return $this->call('getIamPolicy', [$params], Policy::class);
118  }
119  /**
120   * Lists queues. Queues are returned in lexicographical order.
121   * (queues.listProjectsLocationsQueues)
122   *
123   * @param string $parent Required. The location name. For example:
124   * `projects/PROJECT_ID/locations/LOCATION_ID`
125   * @param array $optParams Optional parameters.
126   *
127   * @opt_param string filter `filter` can be used to specify a subset of queues.
128   * Any Queue field can be used as a filter and several operators as supported.
129   * For example: `<=, <, >=, >, !=, =, :`. The filter syntax is the same as
130   * described in [Stackdriver's Advanced Logs
131   * Filters](https://cloud.google.com/logging/docs/view/advanced_filters). Sample
132   * filter "state: PAUSED". Note that using filters might cause fewer queues than
133   * the requested page_size to be returned.
134   * @opt_param int pageSize Requested page size. The maximum page size is 9800.
135   * If unspecified, the page size will be the maximum. Fewer queues than
136   * requested might be returned, even if more queues exist; use the
137   * next_page_token in the response to determine if more queues exist.
138   * @opt_param string pageToken A token identifying the page of results to
139   * return. To request the first page results, page_token must be empty. To
140   * request the next page of results, page_token must be the value of
141   * next_page_token returned from the previous call to ListQueues method. It is
142   * an error to switch the value of the filter while iterating through pages.
143   * @return ListQueuesResponse
144   */
145  public function listProjectsLocationsQueues($parent, $optParams = [])
146  {
147    $params = ['parent' => $parent];
148    $params = array_merge($params, $optParams);
149    return $this->call('list', [$params], ListQueuesResponse::class);
150  }
151  /**
152   * Updates a queue. This method creates the queue if it does not exist and
153   * updates the queue if it does exist. Queues created with this method allow
154   * tasks to live for a maximum of 31 days. After a task is 31 days old, the task
155   * will be deleted regardless of whether it was dispatched or not. WARNING:
156   * Using this method may have unintended side effects if you are using an App
157   * Engine `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview
158   * of Queue Management and queue.yaml](https://cloud.google.com/tasks/docs
159   * /queue-yaml) before using this method. (queues.patch)
160   *
161   * @param string $name Caller-specified and required in CreateQueue, after which
162   * it becomes output only. The queue name. The queue name must have the
163   * following format: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
164   * * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]), hyphens (-),
165   * colons (:), or periods (.). For more information, see [Identifying
166   * projects](https://cloud.google.com/resource-manager/docs/creating-managing-
167   * projects#identifying_projects) * `LOCATION_ID` is the canonical ID for the
168   * queue's location. The list of available locations can be obtained by calling
169   * ListLocations. For more information, see
170   * https://cloud.google.com/about/locations/. * `QUEUE_ID` can contain letters
171   * ([A-Za-z]), numbers ([0-9]), or hyphens (-). The maximum length is 100
172   * characters.
173   * @param Queue $postBody
174   * @param array $optParams Optional parameters.
175   *
176   * @opt_param string updateMask A mask used to specify which fields of the queue
177   * are being updated. If empty, then all fields will be updated.
178   * @return Queue
179   */
180  public function patch($name, Queue $postBody, $optParams = [])
181  {
182    $params = ['name' => $name, 'postBody' => $postBody];
183    $params = array_merge($params, $optParams);
184    return $this->call('patch', [$params], Queue::class);
185  }
186  /**
187   * Pauses the queue. If a queue is paused then the system will stop dispatching
188   * tasks until the queue is resumed via ResumeQueue. Tasks can still be added
189   * when the queue is paused. A queue is paused if its state is PAUSED.
190   * (queues.pause)
191   *
192   * @param string $name Required. The queue name. For example:
193   * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
194   * @param PauseQueueRequest $postBody
195   * @param array $optParams Optional parameters.
196   * @return Queue
197   */
198  public function pause($name, PauseQueueRequest $postBody, $optParams = [])
199  {
200    $params = ['name' => $name, 'postBody' => $postBody];
201    $params = array_merge($params, $optParams);
202    return $this->call('pause', [$params], Queue::class);
203  }
204  /**
205   * Purges a queue by deleting all of its tasks. All tasks created before this
206   * method is called are permanently deleted. Purge operations can take up to one
207   * minute to take effect. Tasks might be dispatched before the purge takes
208   * effect. A purge is irreversible. (queues.purge)
209   *
210   * @param string $name Required. The queue name. For example:
211   * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
212   * @param PurgeQueueRequest $postBody
213   * @param array $optParams Optional parameters.
214   * @return Queue
215   */
216  public function purge($name, PurgeQueueRequest $postBody, $optParams = [])
217  {
218    $params = ['name' => $name, 'postBody' => $postBody];
219    $params = array_merge($params, $optParams);
220    return $this->call('purge', [$params], Queue::class);
221  }
222  /**
223   * Resume a queue. This method resumes a queue after it has been PAUSED or
224   * DISABLED. The state of a queue is stored in the queue's state; after calling
225   * this method it will be set to RUNNING. WARNING: Resuming many high-QPS queues
226   * at the same time can lead to target overloading. If you are resuming high-QPS
227   * queues, follow the 500/50/5 pattern described in [Managing Cloud Tasks
228   * Scaling Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-
229   * scaling). (queues.resume)
230   *
231   * @param string $name Required. The queue name. For example:
232   * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
233   * @param ResumeQueueRequest $postBody
234   * @param array $optParams Optional parameters.
235   * @return Queue
236   */
237  public function resume($name, ResumeQueueRequest $postBody, $optParams = [])
238  {
239    $params = ['name' => $name, 'postBody' => $postBody];
240    $params = array_merge($params, $optParams);
241    return $this->call('resume', [$params], Queue::class);
242  }
243  /**
244   * Sets the access control policy for a Queue. Replaces any existing policy.
245   * Note: The Cloud Console does not check queue-level IAM permissions yet.
246   * Project-level permissions are required to use the Cloud Console.
247   * Authorization requires the following [Google
248   * IAM](https://cloud.google.com/iam) permission on the specified resource
249   * parent: * `cloudtasks.queues.setIamPolicy` (queues.setIamPolicy)
250   *
251   * @param string $resource REQUIRED: The resource for which the policy is being
252   * specified. See the operation documentation for the appropriate value for this
253   * field.
254   * @param SetIamPolicyRequest $postBody
255   * @param array $optParams Optional parameters.
256   * @return Policy
257   */
258  public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
259  {
260    $params = ['resource' => $resource, 'postBody' => $postBody];
261    $params = array_merge($params, $optParams);
262    return $this->call('setIamPolicy', [$params], Policy::class);
263  }
264  /**
265   * Returns permissions that a caller has on a Queue. If the resource does not
266   * exist, this will return an empty set of permissions, not a NOT_FOUND error.
267   * Note: This operation is designed to be used for building permission-aware UIs
268   * and command-line tools, not for authorization checking. This operation may
269   * "fail open" without warning. (queues.testIamPermissions)
270   *
271   * @param string $resource REQUIRED: The resource for which the policy detail is
272   * being requested. See the operation documentation for the appropriate value
273   * for this field.
274   * @param TestIamPermissionsRequest $postBody
275   * @param array $optParams Optional parameters.
276   * @return TestIamPermissionsResponse
277   */
278  public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = [])
279  {
280    $params = ['resource' => $resource, 'postBody' => $postBody];
281    $params = array_merge($params, $optParams);
282    return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
283  }
284}
285
286// Adding a class alias for backwards compatibility with the previous class name.
287class_alias(ProjectsLocationsQueues::class, 'Google_Service_CloudTasks_Resource_ProjectsLocationsQueues');
288