Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/google/cloud/tasks_v2/types/cloudtasks.py: 97%
58 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 07:07 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 07:07 +0000
1# -*- coding: utf-8 -*-
2# Copyright 2022 Google LLC
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16from __future__ import annotations
18from typing import MutableMapping, MutableSequence
20from google.protobuf import field_mask_pb2 # type: ignore
21import proto # type: ignore
23from google.cloud.tasks_v2.types import queue as gct_queue
24from google.cloud.tasks_v2.types import task as gct_task
26__protobuf__ = proto.module(
27 package="google.cloud.tasks.v2",
28 manifest={
29 "ListQueuesRequest",
30 "ListQueuesResponse",
31 "GetQueueRequest",
32 "CreateQueueRequest",
33 "UpdateQueueRequest",
34 "DeleteQueueRequest",
35 "PurgeQueueRequest",
36 "PauseQueueRequest",
37 "ResumeQueueRequest",
38 "ListTasksRequest",
39 "ListTasksResponse",
40 "GetTaskRequest",
41 "CreateTaskRequest",
42 "DeleteTaskRequest",
43 "RunTaskRequest",
44 },
45)
48class ListQueuesRequest(proto.Message):
49 r"""Request message for
50 [ListQueues][google.cloud.tasks.v2.CloudTasks.ListQueues].
52 Attributes:
53 parent (str):
54 Required. The location name. For example:
55 ``projects/PROJECT_ID/locations/LOCATION_ID``
56 filter (str):
57 ``filter`` can be used to specify a subset of queues. Any
58 [Queue][google.cloud.tasks.v2.Queue] field can be used as a
59 filter and several operators as supported. For example:
60 ``<=, <, >=, >, !=, =, :``. The filter syntax is the same as
61 described in `Stackdriver's Advanced Logs
62 Filters <https://cloud.google.com/logging/docs/view/advanced_filters>`__.
64 Sample filter "state: PAUSED".
66 Note that using filters might cause fewer queues than the
67 requested page_size to be returned.
68 page_size (int):
69 Requested page size.
71 The maximum page size is 9800. If unspecified, the page size
72 will be the maximum. Fewer queues than requested might be
73 returned, even if more queues exist; use the
74 [next_page_token][google.cloud.tasks.v2.ListQueuesResponse.next_page_token]
75 in the response to determine if more queues exist.
76 page_token (str):
77 A token identifying the page of results to return.
79 To request the first page results, page_token must be empty.
80 To request the next page of results, page_token must be the
81 value of
82 [next_page_token][google.cloud.tasks.v2.ListQueuesResponse.next_page_token]
83 returned from the previous call to
84 [ListQueues][google.cloud.tasks.v2.CloudTasks.ListQueues]
85 method. It is an error to switch the value of the
86 [filter][google.cloud.tasks.v2.ListQueuesRequest.filter]
87 while iterating through pages.
88 """
90 parent: str = proto.Field(
91 proto.STRING,
92 number=1,
93 )
94 filter: str = proto.Field(
95 proto.STRING,
96 number=2,
97 )
98 page_size: int = proto.Field(
99 proto.INT32,
100 number=3,
101 )
102 page_token: str = proto.Field(
103 proto.STRING,
104 number=4,
105 )
108class ListQueuesResponse(proto.Message):
109 r"""Response message for
110 [ListQueues][google.cloud.tasks.v2.CloudTasks.ListQueues].
112 Attributes:
113 queues (MutableSequence[google.cloud.tasks_v2.types.Queue]):
114 The list of queues.
115 next_page_token (str):
116 A token to retrieve next page of results.
118 To return the next page of results, call
119 [ListQueues][google.cloud.tasks.v2.CloudTasks.ListQueues]
120 with this value as the
121 [page_token][google.cloud.tasks.v2.ListQueuesRequest.page_token].
123 If the next_page_token is empty, there are no more results.
125 The page token is valid for only 2 hours.
126 """
128 @property
129 def raw_page(self):
130 return self
132 queues: MutableSequence[gct_queue.Queue] = proto.RepeatedField(
133 proto.MESSAGE,
134 number=1,
135 message=gct_queue.Queue,
136 )
137 next_page_token: str = proto.Field(
138 proto.STRING,
139 number=2,
140 )
143class GetQueueRequest(proto.Message):
144 r"""Request message for
145 [GetQueue][google.cloud.tasks.v2.CloudTasks.GetQueue].
147 Attributes:
148 name (str):
149 Required. The resource name of the queue. For example:
150 ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID``
151 """
153 name: str = proto.Field(
154 proto.STRING,
155 number=1,
156 )
159class CreateQueueRequest(proto.Message):
160 r"""Request message for
161 [CreateQueue][google.cloud.tasks.v2.CloudTasks.CreateQueue].
163 Attributes:
164 parent (str):
165 Required. The location name in which the queue will be
166 created. For example:
167 ``projects/PROJECT_ID/locations/LOCATION_ID``
169 The list of allowed locations can be obtained by calling
170 Cloud Tasks' implementation of
171 [ListLocations][google.cloud.location.Locations.ListLocations].
172 queue (google.cloud.tasks_v2.types.Queue):
173 Required. The queue to create.
175 [Queue's name][google.cloud.tasks.v2.Queue.name] cannot be
176 the same as an existing queue.
177 """
179 parent: str = proto.Field(
180 proto.STRING,
181 number=1,
182 )
183 queue: gct_queue.Queue = proto.Field(
184 proto.MESSAGE,
185 number=2,
186 message=gct_queue.Queue,
187 )
190class UpdateQueueRequest(proto.Message):
191 r"""Request message for
192 [UpdateQueue][google.cloud.tasks.v2.CloudTasks.UpdateQueue].
194 Attributes:
195 queue (google.cloud.tasks_v2.types.Queue):
196 Required. The queue to create or update.
198 The queue's [name][google.cloud.tasks.v2.Queue.name] must be
199 specified.
201 Output only fields cannot be modified using UpdateQueue. Any
202 value specified for an output only field will be ignored.
203 The queue's [name][google.cloud.tasks.v2.Queue.name] cannot
204 be changed.
205 update_mask (google.protobuf.field_mask_pb2.FieldMask):
206 A mask used to specify which fields of the
207 queue are being updated.
208 If empty, then all fields will be updated.
209 """
211 queue: gct_queue.Queue = proto.Field(
212 proto.MESSAGE,
213 number=1,
214 message=gct_queue.Queue,
215 )
216 update_mask: field_mask_pb2.FieldMask = proto.Field(
217 proto.MESSAGE,
218 number=2,
219 message=field_mask_pb2.FieldMask,
220 )
223class DeleteQueueRequest(proto.Message):
224 r"""Request message for
225 [DeleteQueue][google.cloud.tasks.v2.CloudTasks.DeleteQueue].
227 Attributes:
228 name (str):
229 Required. The queue name. For example:
230 ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID``
231 """
233 name: str = proto.Field(
234 proto.STRING,
235 number=1,
236 )
239class PurgeQueueRequest(proto.Message):
240 r"""Request message for
241 [PurgeQueue][google.cloud.tasks.v2.CloudTasks.PurgeQueue].
243 Attributes:
244 name (str):
245 Required. The queue name. For example:
246 ``projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID``
247 """
249 name: str = proto.Field(
250 proto.STRING,
251 number=1,
252 )
255class PauseQueueRequest(proto.Message):
256 r"""Request message for
257 [PauseQueue][google.cloud.tasks.v2.CloudTasks.PauseQueue].
259 Attributes:
260 name (str):
261 Required. The queue name. For example:
262 ``projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID``
263 """
265 name: str = proto.Field(
266 proto.STRING,
267 number=1,
268 )
271class ResumeQueueRequest(proto.Message):
272 r"""Request message for
273 [ResumeQueue][google.cloud.tasks.v2.CloudTasks.ResumeQueue].
275 Attributes:
276 name (str):
277 Required. The queue name. For example:
278 ``projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID``
279 """
281 name: str = proto.Field(
282 proto.STRING,
283 number=1,
284 )
287class ListTasksRequest(proto.Message):
288 r"""Request message for listing tasks using
289 [ListTasks][google.cloud.tasks.v2.CloudTasks.ListTasks].
291 Attributes:
292 parent (str):
293 Required. The queue name. For example:
294 ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID``
295 response_view (google.cloud.tasks_v2.types.Task.View):
296 The response_view specifies which subset of the
297 [Task][google.cloud.tasks.v2.Task] will be returned.
299 By default response_view is
300 [BASIC][google.cloud.tasks.v2.Task.View.BASIC]; not all
301 information is retrieved by default because some data, such
302 as payloads, might be desirable to return only when needed
303 because of its large size or because of the sensitivity of
304 data that it contains.
306 Authorization for
307 [FULL][google.cloud.tasks.v2.Task.View.FULL] requires
308 ``cloudtasks.tasks.fullView`` `Google
309 IAM <https://cloud.google.com/iam/>`__ permission on the
310 [Task][google.cloud.tasks.v2.Task] resource.
311 page_size (int):
312 Maximum page size.
314 Fewer tasks than requested might be returned, even if more
315 tasks exist; use
316 [next_page_token][google.cloud.tasks.v2.ListTasksResponse.next_page_token]
317 in the response to determine if more tasks exist.
319 The maximum page size is 1000. If unspecified, the page size
320 will be the maximum.
321 page_token (str):
322 A token identifying the page of results to return.
324 To request the first page results, page_token must be empty.
325 To request the next page of results, page_token must be the
326 value of
327 [next_page_token][google.cloud.tasks.v2.ListTasksResponse.next_page_token]
328 returned from the previous call to
329 [ListTasks][google.cloud.tasks.v2.CloudTasks.ListTasks]
330 method.
332 The page token is valid for only 2 hours.
333 """
335 parent: str = proto.Field(
336 proto.STRING,
337 number=1,
338 )
339 response_view: gct_task.Task.View = proto.Field(
340 proto.ENUM,
341 number=2,
342 enum=gct_task.Task.View,
343 )
344 page_size: int = proto.Field(
345 proto.INT32,
346 number=3,
347 )
348 page_token: str = proto.Field(
349 proto.STRING,
350 number=4,
351 )
354class ListTasksResponse(proto.Message):
355 r"""Response message for listing tasks using
356 [ListTasks][google.cloud.tasks.v2.CloudTasks.ListTasks].
358 Attributes:
359 tasks (MutableSequence[google.cloud.tasks_v2.types.Task]):
360 The list of tasks.
361 next_page_token (str):
362 A token to retrieve next page of results.
364 To return the next page of results, call
365 [ListTasks][google.cloud.tasks.v2.CloudTasks.ListTasks] with
366 this value as the
367 [page_token][google.cloud.tasks.v2.ListTasksRequest.page_token].
369 If the next_page_token is empty, there are no more results.
370 """
372 @property
373 def raw_page(self):
374 return self
376 tasks: MutableSequence[gct_task.Task] = proto.RepeatedField(
377 proto.MESSAGE,
378 number=1,
379 message=gct_task.Task,
380 )
381 next_page_token: str = proto.Field(
382 proto.STRING,
383 number=2,
384 )
387class GetTaskRequest(proto.Message):
388 r"""Request message for getting a task using
389 [GetTask][google.cloud.tasks.v2.CloudTasks.GetTask].
391 Attributes:
392 name (str):
393 Required. The task name. For example:
394 ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID``
395 response_view (google.cloud.tasks_v2.types.Task.View):
396 The response_view specifies which subset of the
397 [Task][google.cloud.tasks.v2.Task] will be returned.
399 By default response_view is
400 [BASIC][google.cloud.tasks.v2.Task.View.BASIC]; not all
401 information is retrieved by default because some data, such
402 as payloads, might be desirable to return only when needed
403 because of its large size or because of the sensitivity of
404 data that it contains.
406 Authorization for
407 [FULL][google.cloud.tasks.v2.Task.View.FULL] requires
408 ``cloudtasks.tasks.fullView`` `Google
409 IAM <https://cloud.google.com/iam/>`__ permission on the
410 [Task][google.cloud.tasks.v2.Task] resource.
411 """
413 name: str = proto.Field(
414 proto.STRING,
415 number=1,
416 )
417 response_view: gct_task.Task.View = proto.Field(
418 proto.ENUM,
419 number=2,
420 enum=gct_task.Task.View,
421 )
424class CreateTaskRequest(proto.Message):
425 r"""Request message for
426 [CreateTask][google.cloud.tasks.v2.CloudTasks.CreateTask].
428 Attributes:
429 parent (str):
430 Required. The queue name. For example:
431 ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID``
433 The queue must already exist.
434 task (google.cloud.tasks_v2.types.Task):
435 Required. The task to add.
437 Task names have the following format:
438 ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID``.
439 The user can optionally specify a task
440 [name][google.cloud.tasks.v2.Task.name]. If a name is not
441 specified then the system will generate a random unique task
442 id, which will be set in the task returned in the
443 [response][google.cloud.tasks.v2.Task.name].
445 If [schedule_time][google.cloud.tasks.v2.Task.schedule_time]
446 is not set or is in the past then Cloud Tasks will set it to
447 the current time.
449 Task De-duplication:
451 Explicitly specifying a task ID enables task de-duplication.
452 If a task's ID is identical to that of an existing task or a
453 task that was deleted or executed recently then the call
454 will fail with
455 [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS]. If the
456 task's queue was created using Cloud Tasks, then another
457 task with the same name can't be created for ~1hour after
458 the original task was deleted or executed. If the task's
459 queue was created using queue.yaml or queue.xml, then
460 another task with the same name can't be created for ~9days
461 after the original task was deleted or executed.
463 Because there is an extra lookup cost to identify duplicate
464 task names, these
465 [CreateTask][google.cloud.tasks.v2.CloudTasks.CreateTask]
466 calls have significantly increased latency. Using hashed
467 strings for the task id or for the prefix of the task id is
468 recommended. Choosing task ids that are sequential or have
469 sequential prefixes, for example using a timestamp, causes
470 an increase in latency and error rates in all task commands.
471 The infrastructure relies on an approximately uniform
472 distribution of task ids to store and serve tasks
473 efficiently.
474 response_view (google.cloud.tasks_v2.types.Task.View):
475 The response_view specifies which subset of the
476 [Task][google.cloud.tasks.v2.Task] will be returned.
478 By default response_view is
479 [BASIC][google.cloud.tasks.v2.Task.View.BASIC]; not all
480 information is retrieved by default because some data, such
481 as payloads, might be desirable to return only when needed
482 because of its large size or because of the sensitivity of
483 data that it contains.
485 Authorization for
486 [FULL][google.cloud.tasks.v2.Task.View.FULL] requires
487 ``cloudtasks.tasks.fullView`` `Google
488 IAM <https://cloud.google.com/iam/>`__ permission on the
489 [Task][google.cloud.tasks.v2.Task] resource.
490 """
492 parent: str = proto.Field(
493 proto.STRING,
494 number=1,
495 )
496 task: gct_task.Task = proto.Field(
497 proto.MESSAGE,
498 number=2,
499 message=gct_task.Task,
500 )
501 response_view: gct_task.Task.View = proto.Field(
502 proto.ENUM,
503 number=3,
504 enum=gct_task.Task.View,
505 )
508class DeleteTaskRequest(proto.Message):
509 r"""Request message for deleting a task using
510 [DeleteTask][google.cloud.tasks.v2.CloudTasks.DeleteTask].
512 Attributes:
513 name (str):
514 Required. The task name. For example:
515 ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID``
516 """
518 name: str = proto.Field(
519 proto.STRING,
520 number=1,
521 )
524class RunTaskRequest(proto.Message):
525 r"""Request message for forcing a task to run now using
526 [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask].
528 Attributes:
529 name (str):
530 Required. The task name. For example:
531 ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID``
532 response_view (google.cloud.tasks_v2.types.Task.View):
533 The response_view specifies which subset of the
534 [Task][google.cloud.tasks.v2.Task] will be returned.
536 By default response_view is
537 [BASIC][google.cloud.tasks.v2.Task.View.BASIC]; not all
538 information is retrieved by default because some data, such
539 as payloads, might be desirable to return only when needed
540 because of its large size or because of the sensitivity of
541 data that it contains.
543 Authorization for
544 [FULL][google.cloud.tasks.v2.Task.View.FULL] requires
545 ``cloudtasks.tasks.fullView`` `Google
546 IAM <https://cloud.google.com/iam/>`__ permission on the
547 [Task][google.cloud.tasks.v2.Task] resource.
548 """
550 name: str = proto.Field(
551 proto.STRING,
552 number=1,
553 )
554 response_view: gct_task.Task.View = proto.Field(
555 proto.ENUM,
556 number=2,
557 enum=gct_task.Task.View,
558 )
561__all__ = tuple(sorted(__protobuf__.manifest))