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