xref: /aosp_15_r20/external/googleapis/google/cloud/tasks/v2/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.v2;
18
19import "google/api/resource.proto";
20import "google/cloud/tasks/v2/target.proto";
21import "google/protobuf/duration.proto";
22import "google/protobuf/timestamp.proto";
23import "google/rpc/status.proto";
24
25option go_package = "cloud.google.com/go/cloudtasks/apiv2/cloudtaskspb;cloudtaskspb";
26option java_multiple_files = true;
27option java_outer_classname = "TaskProto";
28option java_package = "com.google.cloud.tasks.v2";
29
30// A unit of scheduled work.
31message Task {
32  option (google.api.resource) = {
33    type: "cloudtasks.googleapis.com/Task"
34    pattern: "projects/{project}/locations/{location}/queues/{queue}/tasks/{task}"
35  };
36
37  // The view specifies a subset of [Task][google.cloud.tasks.v2.Task] 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    // [body in
53    // AppEngineHttpRequest][google.cloud.tasks.v2.AppEngineHttpRequest.body].
54    // Bodies are desirable to return only when needed, because they
55    // can be large and because of the sensitivity of the data that you
56    // choose to store in it.
57    BASIC = 1;
58
59    // All information is returned.
60    //
61    // Authorization for [FULL][google.cloud.tasks.v2.Task.View.FULL] requires
62    // `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
63    // permission on the [Queue][google.cloud.tasks.v2.Queue] resource.
64    FULL = 2;
65  }
66
67  // Optionally caller-specified in
68  // [CreateTask][google.cloud.tasks.v2.CloudTasks.CreateTask].
69  //
70  // The task name.
71  //
72  // The task name must have the following format:
73  // `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
74  //
75  // * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]),
76  //    hyphens (-), colons (:), or periods (.).
77  //    For more information, see
78  //    [Identifying
79  //    projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects)
80  // * `LOCATION_ID` is the canonical ID for the task's location.
81  //    The list of available locations can be obtained by calling
82  //    [ListLocations][google.cloud.location.Locations.ListLocations].
83  //    For more information, see https://cloud.google.com/about/locations/.
84  // * `QUEUE_ID` can contain letters ([A-Za-z]), numbers ([0-9]), or
85  //   hyphens (-). The maximum length is 100 characters.
86  // * `TASK_ID` can contain only letters ([A-Za-z]), numbers ([0-9]),
87  //   hyphens (-), or underscores (_). The maximum length is 500 characters.
88  string name = 1;
89
90  // Required. The message to send to the worker.
91  oneof message_type {
92    // HTTP request that is sent to the App Engine app handler.
93    //
94    // An App Engine task is a task that has
95    // [AppEngineHttpRequest][google.cloud.tasks.v2.AppEngineHttpRequest] set.
96    AppEngineHttpRequest app_engine_http_request = 2;
97
98    // HTTP request that is sent to the worker.
99    //
100    // An HTTP task is a task that has
101    // [HttpRequest][google.cloud.tasks.v2.HttpRequest] set.
102    HttpRequest http_request = 3;
103  }
104
105  // The time when the task is scheduled to be attempted or retried.
106  //
107  // `schedule_time` will be truncated to the nearest microsecond.
108  google.protobuf.Timestamp schedule_time = 4;
109
110  // Output only. The time that the task was created.
111  //
112  // `create_time` will be truncated to the nearest second.
113  google.protobuf.Timestamp create_time = 5;
114
115  // The deadline for requests sent to the worker. If the worker does not
116  // respond by this deadline then the request is cancelled and the attempt
117  // is marked as a `DEADLINE_EXCEEDED` failure. Cloud Tasks will retry the
118  // task according to the [RetryConfig][google.cloud.tasks.v2.RetryConfig].
119  //
120  // Note that when the request is cancelled, Cloud Tasks will stop listening
121  // for the response, but whether the worker stops processing depends on the
122  // worker. For example, if the worker is stuck, it may not react to cancelled
123  // requests.
124  //
125  // The default and maximum values depend on the type of request:
126  //
127  // * For [HTTP tasks][google.cloud.tasks.v2.HttpRequest], the default is 10
128  // minutes. The deadline
129  //   must be in the interval [15 seconds, 30 minutes].
130  //
131  // * For [App Engine tasks][google.cloud.tasks.v2.AppEngineHttpRequest], 0
132  // indicates that the
133  //   request has the default deadline. The default deadline depends on the
134  //   [scaling
135  //   type](https://cloud.google.com/appengine/docs/standard/go/how-instances-are-managed#instance_scaling)
136  //   of the service: 10 minutes for standard apps with automatic scaling, 24
137  //   hours for standard apps with manual and basic scaling, and 60 minutes for
138  //   flex apps. If the request deadline is set, it must be in the interval [15
139  //   seconds, 24 hours 15 seconds]. Regardless of the task's
140  //   `dispatch_deadline`, the app handler will not run for longer than than
141  //   the service's timeout. We recommend setting the `dispatch_deadline` to
142  //   at most a few seconds more than the app handler's timeout. For more
143  //   information see
144  //   [Timeouts](https://cloud.google.com/tasks/docs/creating-appengine-handlers#timeouts).
145  //
146  // `dispatch_deadline` will be truncated to the nearest millisecond. The
147  // deadline is an approximate deadline.
148  google.protobuf.Duration dispatch_deadline = 6;
149
150  // Output only. The number of attempts dispatched.
151  //
152  // This count includes attempts which have been dispatched but haven't
153  // received a response.
154  int32 dispatch_count = 7;
155
156  // Output only. The number of attempts which have received a response.
157  int32 response_count = 8;
158
159  // Output only. The status of the task's first attempt.
160  //
161  // Only [dispatch_time][google.cloud.tasks.v2.Attempt.dispatch_time] will be
162  // set. The other [Attempt][google.cloud.tasks.v2.Attempt] information is not
163  // retained by Cloud Tasks.
164  Attempt first_attempt = 9;
165
166  // Output only. The status of the task's last attempt.
167  Attempt last_attempt = 10;
168
169  // Output only. The view specifies which subset of the
170  // [Task][google.cloud.tasks.v2.Task] has been returned.
171  View view = 11;
172}
173
174// The status of a task attempt.
175message Attempt {
176  // Output only. The time that this attempt was scheduled.
177  //
178  // `schedule_time` will be truncated to the nearest microsecond.
179  google.protobuf.Timestamp schedule_time = 1;
180
181  // Output only. The time that this attempt was dispatched.
182  //
183  // `dispatch_time` will be truncated to the nearest microsecond.
184  google.protobuf.Timestamp dispatch_time = 2;
185
186  // Output only. The time that this attempt response was received.
187  //
188  // `response_time` will be truncated to the nearest microsecond.
189  google.protobuf.Timestamp response_time = 3;
190
191  // Output only. The response from the worker for this attempt.
192  //
193  // If `response_time` is unset, then the task has not been attempted or is
194  // currently running and the `response_status` field is meaningless.
195  google.rpc.Status response_status = 4;
196}
197