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\CreateTaskRequest; 22use Google\Service\CloudTasks\ListTasksResponse; 23use Google\Service\CloudTasks\RunTaskRequest; 24use Google\Service\CloudTasks\Task; 25 26/** 27 * The "tasks" collection of methods. 28 * Typical usage is: 29 * <code> 30 * $cloudtasksService = new Google\Service\CloudTasks(...); 31 * $tasks = $cloudtasksService->tasks; 32 * </code> 33 */ 34class ProjectsLocationsQueuesTasks extends \Google\Service\Resource 35{ 36 /** 37 * Creates a task and adds it to a queue. Tasks cannot be updated after 38 * creation; there is no UpdateTask command. * The maximum task size is 100KB. 39 * (tasks.create) 40 * 41 * @param string $parent Required. The queue name. For example: 42 * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` The queue must 43 * already exist. 44 * @param CreateTaskRequest $postBody 45 * @param array $optParams Optional parameters. 46 * @return Task 47 */ 48 public function create($parent, CreateTaskRequest $postBody, $optParams = []) 49 { 50 $params = ['parent' => $parent, 'postBody' => $postBody]; 51 $params = array_merge($params, $optParams); 52 return $this->call('create', [$params], Task::class); 53 } 54 /** 55 * Deletes a task. A task can be deleted if it is scheduled or dispatched. A 56 * task cannot be deleted if it has executed successfully or permanently failed. 57 * (tasks.delete) 58 * 59 * @param string $name Required. The task name. For example: 60 * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` 61 * @param array $optParams Optional parameters. 62 * @return CloudtasksEmpty 63 */ 64 public function delete($name, $optParams = []) 65 { 66 $params = ['name' => $name]; 67 $params = array_merge($params, $optParams); 68 return $this->call('delete', [$params], CloudtasksEmpty::class); 69 } 70 /** 71 * Gets a task. (tasks.get) 72 * 73 * @param string $name Required. The task name. For example: 74 * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` 75 * @param array $optParams Optional parameters. 76 * 77 * @opt_param string responseView The response_view specifies which subset of 78 * the Task will be returned. By default response_view is BASIC; not all 79 * information is retrieved by default because some data, such as payloads, 80 * might be desirable to return only when needed because of its large size or 81 * because of the sensitivity of data that it contains. Authorization for FULL 82 * requires `cloudtasks.tasks.fullView` [Google 83 * IAM](https://cloud.google.com/iam/) permission on the Task resource. 84 * @return Task 85 */ 86 public function get($name, $optParams = []) 87 { 88 $params = ['name' => $name]; 89 $params = array_merge($params, $optParams); 90 return $this->call('get', [$params], Task::class); 91 } 92 /** 93 * Lists the tasks in a queue. By default, only the BASIC view is retrieved due 94 * to performance considerations; response_view controls the subset of 95 * information which is returned. The tasks may be returned in any order. The 96 * ordering may change at any time. (tasks.listProjectsLocationsQueuesTasks) 97 * 98 * @param string $parent Required. The queue name. For example: 99 * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` 100 * @param array $optParams Optional parameters. 101 * 102 * @opt_param int pageSize Maximum page size. Fewer tasks than requested might 103 * be returned, even if more tasks exist; use next_page_token in the response to 104 * determine if more tasks exist. The maximum page size is 1000. If unspecified, 105 * the page size will be the maximum. 106 * @opt_param string pageToken A token identifying the page of results to 107 * return. To request the first page results, page_token must be empty. To 108 * request the next page of results, page_token must be the value of 109 * next_page_token returned from the previous call to ListTasks method. The page 110 * token is valid for only 2 hours. 111 * @opt_param string responseView The response_view specifies which subset of 112 * the Task will be returned. By default response_view is BASIC; not all 113 * information is retrieved by default because some data, such as payloads, 114 * might be desirable to return only when needed because of its large size or 115 * because of the sensitivity of data that it contains. Authorization for FULL 116 * requires `cloudtasks.tasks.fullView` [Google 117 * IAM](https://cloud.google.com/iam/) permission on the Task resource. 118 * @return ListTasksResponse 119 */ 120 public function listProjectsLocationsQueuesTasks($parent, $optParams = []) 121 { 122 $params = ['parent' => $parent]; 123 $params = array_merge($params, $optParams); 124 return $this->call('list', [$params], ListTasksResponse::class); 125 } 126 /** 127 * Forces a task to run now. When this method is called, Cloud Tasks will 128 * dispatch the task, even if the task is already running, the queue has reached 129 * its RateLimits or is PAUSED. This command is meant to be used for manual 130 * debugging. For example, RunTask can be used to retry a failed task after a 131 * fix has been made or to manually force a task to be dispatched now. The 132 * dispatched task is returned. That is, the task that is returned contains the 133 * status after the task is dispatched but before the task is received by its 134 * target. If Cloud Tasks receives a successful response from the task's target, 135 * then the task will be deleted; otherwise the task's schedule_time will be 136 * reset to the time that RunTask was called plus the retry delay specified in 137 * the queue's RetryConfig. RunTask returns NOT_FOUND when it is called on a 138 * task that has already succeeded or permanently failed. (tasks.run) 139 * 140 * @param string $name Required. The task name. For example: 141 * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` 142 * @param RunTaskRequest $postBody 143 * @param array $optParams Optional parameters. 144 * @return Task 145 */ 146 public function run($name, RunTaskRequest $postBody, $optParams = []) 147 { 148 $params = ['name' => $name, 'postBody' => $postBody]; 149 $params = array_merge($params, $optParams); 150 return $this->call('run', [$params], Task::class); 151 } 152} 153 154// Adding a class alias for backwards compatibility with the previous class name. 155class_alias(ProjectsLocationsQueuesTasks::class, 'Google_Service_CloudTasks_Resource_ProjectsLocationsQueuesTasks'); 156