xref: /aosp_15_r20/external/googleapis/google/cloud/tasks/v2beta2/task.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2023 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package google.cloud.tasks.v2beta2;
18
19import "google/api/resource.proto";
20import "google/cloud/tasks/v2beta2/target.proto";
21import "google/protobuf/timestamp.proto";
22import "google/rpc/status.proto";
23
24option go_package = "cloud.google.com/go/cloudtasks/apiv2beta2/cloudtaskspb;cloudtaskspb";
25option java_multiple_files = true;
26option java_outer_classname = "TaskProto";
27option java_package = "com.google.cloud.tasks.v2beta2";
28
29// A unit of scheduled work.
30message Task {
31  option (google.api.resource) = {
32    type: "cloudtasks.googleapis.com/Task"
33    pattern: "projects/{project}/locations/{location}/queues/{queue}/tasks/{task}"
34  };
35
36  // The view specifies a subset of [Task][google.cloud.tasks.v2beta2.Task]
37  // data.
38  //
39  // When a task is returned in a response, not all
40  // information is retrieved by default because some data, such as
41  // payloads, might be desirable to return only when needed because
42  // of its large size or because of the sensitivity of data that it
43  // contains.
44  enum View {
45    // Unspecified. Defaults to BASIC.
46    VIEW_UNSPECIFIED = 0;
47
48    // The basic view omits fields which can be large or can contain
49    // sensitive data.
50    //
51    // This view does not include the
52    // ([payload in
53    // AppEngineHttpRequest][google.cloud.tasks.v2beta2.AppEngineHttpRequest]
54    // and [payload in
55    // PullMessage][google.cloud.tasks.v2beta2.PullMessage.payload]). These
56    // payloads are desirable to return only when needed, because they can be
57    // large and because of the sensitivity of the data that you choose to store
58    // in it.
59    BASIC = 1;
60
61    // All information is returned.
62    //
63    // Authorization for [FULL][google.cloud.tasks.v2beta2.Task.View.FULL]
64    // requires `cloudtasks.tasks.fullView` [Google
65    // IAM](https://cloud.google.com/iam/) permission on the
66    // [Queue][google.cloud.tasks.v2beta2.Queue] resource.
67    FULL = 2;
68  }
69
70  // Optionally caller-specified in
71  // [CreateTask][google.cloud.tasks.v2beta2.CloudTasks.CreateTask].
72  //
73  // The task name.
74  //
75  // The task name must have the following format:
76  // `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
77  //
78  // * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]),
79  //    hyphens (-), colons (:), or periods (.).
80  //    For more information, see
81  //    [Identifying
82  //    projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects)
83  // * `LOCATION_ID` is the canonical ID for the task's location.
84  //    The list of available locations can be obtained by calling
85  //    [ListLocations][google.cloud.location.Locations.ListLocations].
86  //    For more information, see https://cloud.google.com/about/locations/.
87  // * `QUEUE_ID` can contain letters ([A-Za-z]), numbers ([0-9]), or
88  //   hyphens (-). The maximum length is 100 characters.
89  // * `TASK_ID` can contain only letters ([A-Za-z]), numbers ([0-9]),
90  //   hyphens (-), or underscores (_). The maximum length is 500 characters.
91  string name = 1;
92
93  // Required.
94  //
95  // The task's payload is used by the task's target to process the task.
96  // A payload is valid only if it is compatible with the queue's target.
97  oneof payload_type {
98    // App Engine HTTP request that is sent to the task's target. Can
99    // be set only if
100    // [app_engine_http_target][google.cloud.tasks.v2beta2.Queue.app_engine_http_target]
101    // is set on the queue.
102    //
103    // An App Engine task is a task that has
104    // [AppEngineHttpRequest][google.cloud.tasks.v2beta2.AppEngineHttpRequest]
105    // set.
106    AppEngineHttpRequest app_engine_http_request = 3;
107
108    // [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] to process
109    // the task. Can be set only if
110    // [pull_target][google.cloud.tasks.v2beta2.Queue.pull_target] is set on the
111    // queue.
112    //
113    // A pull task is a task that has
114    // [PullMessage][google.cloud.tasks.v2beta2.PullMessage] set.
115    PullMessage pull_message = 4;
116
117    // HTTP request that is sent to the task's target.
118    //
119    // An HTTP task is a task that has
120    // [HttpRequest][google.cloud.tasks.v2beta2.HttpRequest] set.
121    HttpRequest http_request = 13;
122  }
123
124  // The time when the task is scheduled to be attempted.
125  //
126  // For App Engine queues, this is when the task will be attempted or retried.
127  //
128  // For pull queues, this is the time when the task is available to
129  // be leased; if a task is currently leased, this is the time when
130  // the current lease expires, that is, the time that the task was
131  // leased plus the
132  // [lease_duration][google.cloud.tasks.v2beta2.LeaseTasksRequest.lease_duration].
133  //
134  // `schedule_time` will be truncated to the nearest microsecond.
135  google.protobuf.Timestamp schedule_time = 5;
136
137  // Output only. The time that the task was created.
138  //
139  // `create_time` will be truncated to the nearest second.
140  google.protobuf.Timestamp create_time = 6;
141
142  // Output only. The task status.
143  TaskStatus status = 7;
144
145  // Output only. The view specifies which subset of the
146  // [Task][google.cloud.tasks.v2beta2.Task] has been returned.
147  View view = 8;
148}
149
150// Status of the task.
151message TaskStatus {
152  // Output only. The number of attempts dispatched.
153  //
154  // This count includes attempts which have been dispatched but haven't
155  // received a response.
156  int32 attempt_dispatch_count = 1;
157
158  // Output only. The number of attempts which have received a response.
159  //
160  // This field is not calculated for [pull
161  // tasks][google.cloud.tasks.v2beta2.PullMessage].
162  int32 attempt_response_count = 2;
163
164  // Output only. The status of the task's first attempt.
165  //
166  // Only
167  // [dispatch_time][google.cloud.tasks.v2beta2.AttemptStatus.dispatch_time]
168  // will be set. The other
169  // [AttemptStatus][google.cloud.tasks.v2beta2.AttemptStatus] information is
170  // not retained by Cloud Tasks.
171  //
172  // This field is not calculated for [pull
173  // tasks][google.cloud.tasks.v2beta2.PullMessage].
174  AttemptStatus first_attempt_status = 3;
175
176  // Output only. The status of the task's last attempt.
177  //
178  // This field is not calculated for [pull
179  // tasks][google.cloud.tasks.v2beta2.PullMessage].
180  AttemptStatus last_attempt_status = 4;
181}
182
183// The status of a task attempt.
184message AttemptStatus {
185  // Output only. The time that this attempt was scheduled.
186  //
187  // `schedule_time` will be truncated to the nearest microsecond.
188  google.protobuf.Timestamp schedule_time = 1;
189
190  // Output only. The time that this attempt was dispatched.
191  //
192  // `dispatch_time` will be truncated to the nearest microsecond.
193  google.protobuf.Timestamp dispatch_time = 2;
194
195  // Output only. The time that this attempt response was received.
196  //
197  // `response_time` will be truncated to the nearest microsecond.
198  google.protobuf.Timestamp response_time = 3;
199
200  // Output only. The response from the target for this attempt.
201  //
202  // If the task has not been attempted or the task is currently running
203  // then the response status is unset.
204  google.rpc.Status response_status = 4;
205}
206