Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/google/cloud/tasks_v2/types/task.py: 100%

30 statements  

« 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 

17 

18from typing import MutableMapping, MutableSequence 

19 

20from google.protobuf import duration_pb2 # type: ignore 

21from google.protobuf import timestamp_pb2 # type: ignore 

22from google.rpc import status_pb2 # type: ignore 

23import proto # type: ignore 

24 

25from google.cloud.tasks_v2.types import target 

26 

27__protobuf__ = proto.module( 

28 package="google.cloud.tasks.v2", 

29 manifest={ 

30 "Task", 

31 "Attempt", 

32 }, 

33) 

34 

35 

36class Task(proto.Message): 

37 r"""A unit of scheduled work. 

38 

39 This message has `oneof`_ fields (mutually exclusive fields). 

40 For each oneof, at most one member field can be set at the same time. 

41 Setting any member of the oneof automatically clears all other 

42 members. 

43 

44 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields 

45 

46 Attributes: 

47 name (str): 

48 Optionally caller-specified in 

49 [CreateTask][google.cloud.tasks.v2.CloudTasks.CreateTask]. 

50 

51 The task name. 

52 

53 The task name must have the following format: 

54 ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`` 

55 

56 - ``PROJECT_ID`` can contain letters ([A-Za-z]), numbers 

57 ([0-9]), hyphens (-), colons (:), or periods (.). For 

58 more information, see `Identifying 

59 projects <https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects>`__ 

60 - ``LOCATION_ID`` is the canonical ID for the task's 

61 location. The list of available locations can be obtained 

62 by calling 

63 [ListLocations][google.cloud.location.Locations.ListLocations]. 

64 For more information, see 

65 https://cloud.google.com/about/locations/. 

66 - ``QUEUE_ID`` can contain letters ([A-Za-z]), numbers 

67 ([0-9]), or hyphens (-). The maximum length is 100 

68 characters. 

69 - ``TASK_ID`` can contain only letters ([A-Za-z]), numbers 

70 ([0-9]), hyphens (-), or underscores (_). The maximum 

71 length is 500 characters. 

72 app_engine_http_request (google.cloud.tasks_v2.types.AppEngineHttpRequest): 

73 HTTP request that is sent to the App Engine app handler. 

74 

75 An App Engine task is a task that has 

76 [AppEngineHttpRequest][google.cloud.tasks.v2.AppEngineHttpRequest] 

77 set. 

78 

79 This field is a member of `oneof`_ ``message_type``. 

80 http_request (google.cloud.tasks_v2.types.HttpRequest): 

81 HTTP request that is sent to the worker. 

82 

83 An HTTP task is a task that has 

84 [HttpRequest][google.cloud.tasks.v2.HttpRequest] set. 

85 

86 This field is a member of `oneof`_ ``message_type``. 

87 schedule_time (google.protobuf.timestamp_pb2.Timestamp): 

88 The time when the task is scheduled to be attempted or 

89 retried. 

90 

91 ``schedule_time`` will be truncated to the nearest 

92 microsecond. 

93 create_time (google.protobuf.timestamp_pb2.Timestamp): 

94 Output only. The time that the task was created. 

95 

96 ``create_time`` will be truncated to the nearest second. 

97 dispatch_deadline (google.protobuf.duration_pb2.Duration): 

98 The deadline for requests sent to the worker. If the worker 

99 does not respond by this deadline then the request is 

100 cancelled and the attempt is marked as a 

101 ``DEADLINE_EXCEEDED`` failure. Cloud Tasks will retry the 

102 task according to the 

103 [RetryConfig][google.cloud.tasks.v2.RetryConfig]. 

104 

105 Note that when the request is cancelled, Cloud Tasks will 

106 stop listing for the response, but whether the worker stops 

107 processing depends on the worker. For example, if the worker 

108 is stuck, it may not react to cancelled requests. 

109 

110 The default and maximum values depend on the type of 

111 request: 

112 

113 - For [HTTP tasks][google.cloud.tasks.v2.HttpRequest], the 

114 default is 10 minutes. The deadline must be in the 

115 interval [15 seconds, 30 minutes]. 

116 

117 - For [App Engine 

118 tasks][google.cloud.tasks.v2.AppEngineHttpRequest], 0 

119 indicates that the request has the default deadline. The 

120 default deadline depends on the `scaling 

121 type <https://cloud.google.com/appengine/docs/standard/go/how-instances-are-managed#instance_scaling>`__ 

122 of the service: 10 minutes for standard apps with 

123 automatic scaling, 24 hours for standard apps with manual 

124 and basic scaling, and 60 minutes for flex apps. If the 

125 request deadline is set, it must be in the interval [15 

126 seconds, 24 hours 15 seconds]. Regardless of the task's 

127 ``dispatch_deadline``, the app handler will not run for 

128 longer than than the service's timeout. We recommend 

129 setting the ``dispatch_deadline`` to at most a few 

130 seconds more than the app handler's timeout. For more 

131 information see 

132 `Timeouts <https://cloud.google.com/tasks/docs/creating-appengine-handlers#timeouts>`__. 

133 

134 ``dispatch_deadline`` will be truncated to the nearest 

135 millisecond. The deadline is an approximate deadline. 

136 dispatch_count (int): 

137 Output only. The number of attempts 

138 dispatched. 

139 This count includes attempts which have been 

140 dispatched but haven't received a response. 

141 response_count (int): 

142 Output only. The number of attempts which 

143 have received a response. 

144 first_attempt (google.cloud.tasks_v2.types.Attempt): 

145 Output only. The status of the task's first attempt. 

146 

147 Only 

148 [dispatch_time][google.cloud.tasks.v2.Attempt.dispatch_time] 

149 will be set. The other 

150 [Attempt][google.cloud.tasks.v2.Attempt] information is not 

151 retained by Cloud Tasks. 

152 last_attempt (google.cloud.tasks_v2.types.Attempt): 

153 Output only. The status of the task's last 

154 attempt. 

155 view (google.cloud.tasks_v2.types.Task.View): 

156 Output only. The view specifies which subset of the 

157 [Task][google.cloud.tasks.v2.Task] has been returned. 

158 """ 

159 

160 class View(proto.Enum): 

161 r"""The view specifies a subset of [Task][google.cloud.tasks.v2.Task] 

162 data. 

163 

164 When a task is returned in a response, not all information is 

165 retrieved by default because some data, such as payloads, might be 

166 desirable to return only when needed because of its large size or 

167 because of the sensitivity of data that it contains. 

168 

169 Values: 

170 VIEW_UNSPECIFIED (0): 

171 Unspecified. Defaults to BASIC. 

172 BASIC (1): 

173 The basic view omits fields which can be large or can 

174 contain sensitive data. 

175 

176 This view does not include the [body in 

177 AppEngineHttpRequest][google.cloud.tasks.v2.AppEngineHttpRequest.body]. 

178 Bodies are desirable to return only when needed, because 

179 they can be large and because of the sensitivity of the data 

180 that you choose to store in it. 

181 FULL (2): 

182 All information is returned. 

183 

184 Authorization for 

185 [FULL][google.cloud.tasks.v2.Task.View.FULL] requires 

186 ``cloudtasks.tasks.fullView`` `Google 

187 IAM <https://cloud.google.com/iam/>`__ permission on the 

188 [Queue][google.cloud.tasks.v2.Queue] resource. 

189 """ 

190 VIEW_UNSPECIFIED = 0 

191 BASIC = 1 

192 FULL = 2 

193 

194 name: str = proto.Field( 

195 proto.STRING, 

196 number=1, 

197 ) 

198 app_engine_http_request: target.AppEngineHttpRequest = proto.Field( 

199 proto.MESSAGE, 

200 number=2, 

201 oneof="message_type", 

202 message=target.AppEngineHttpRequest, 

203 ) 

204 http_request: target.HttpRequest = proto.Field( 

205 proto.MESSAGE, 

206 number=3, 

207 oneof="message_type", 

208 message=target.HttpRequest, 

209 ) 

210 schedule_time: timestamp_pb2.Timestamp = proto.Field( 

211 proto.MESSAGE, 

212 number=4, 

213 message=timestamp_pb2.Timestamp, 

214 ) 

215 create_time: timestamp_pb2.Timestamp = proto.Field( 

216 proto.MESSAGE, 

217 number=5, 

218 message=timestamp_pb2.Timestamp, 

219 ) 

220 dispatch_deadline: duration_pb2.Duration = proto.Field( 

221 proto.MESSAGE, 

222 number=6, 

223 message=duration_pb2.Duration, 

224 ) 

225 dispatch_count: int = proto.Field( 

226 proto.INT32, 

227 number=7, 

228 ) 

229 response_count: int = proto.Field( 

230 proto.INT32, 

231 number=8, 

232 ) 

233 first_attempt: "Attempt" = proto.Field( 

234 proto.MESSAGE, 

235 number=9, 

236 message="Attempt", 

237 ) 

238 last_attempt: "Attempt" = proto.Field( 

239 proto.MESSAGE, 

240 number=10, 

241 message="Attempt", 

242 ) 

243 view: View = proto.Field( 

244 proto.ENUM, 

245 number=11, 

246 enum=View, 

247 ) 

248 

249 

250class Attempt(proto.Message): 

251 r"""The status of a task attempt. 

252 

253 Attributes: 

254 schedule_time (google.protobuf.timestamp_pb2.Timestamp): 

255 Output only. The time that this attempt was scheduled. 

256 

257 ``schedule_time`` will be truncated to the nearest 

258 microsecond. 

259 dispatch_time (google.protobuf.timestamp_pb2.Timestamp): 

260 Output only. The time that this attempt was dispatched. 

261 

262 ``dispatch_time`` will be truncated to the nearest 

263 microsecond. 

264 response_time (google.protobuf.timestamp_pb2.Timestamp): 

265 Output only. The time that this attempt response was 

266 received. 

267 

268 ``response_time`` will be truncated to the nearest 

269 microsecond. 

270 response_status (google.rpc.status_pb2.Status): 

271 Output only. The response from the worker for this attempt. 

272 

273 If ``response_time`` is unset, then the task has not been 

274 attempted or is currently running and the 

275 ``response_status`` field is meaningless. 

276 """ 

277 

278 schedule_time: timestamp_pb2.Timestamp = proto.Field( 

279 proto.MESSAGE, 

280 number=1, 

281 message=timestamp_pb2.Timestamp, 

282 ) 

283 dispatch_time: timestamp_pb2.Timestamp = proto.Field( 

284 proto.MESSAGE, 

285 number=2, 

286 message=timestamp_pb2.Timestamp, 

287 ) 

288 response_time: timestamp_pb2.Timestamp = proto.Field( 

289 proto.MESSAGE, 

290 number=3, 

291 message=timestamp_pb2.Timestamp, 

292 ) 

293 response_status: status_pb2.Status = proto.Field( 

294 proto.MESSAGE, 

295 number=4, 

296 message=status_pb2.Status, 

297 ) 

298 

299 

300__all__ = tuple(sorted(__protobuf__.manifest))