Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/google/cloud/errorreporting_v1beta1/types/error_stats_service.py: 98%

80 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-12-08 06:45 +0000

1# -*- coding: utf-8 -*- 

2# Copyright 2023 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 

20import proto # type: ignore 

21 

22from google.cloud.errorreporting_v1beta1.types import common 

23from google.protobuf import duration_pb2 # type: ignore 

24from google.protobuf import timestamp_pb2 # type: ignore 

25 

26 

27__protobuf__ = proto.module( 

28 package="google.devtools.clouderrorreporting.v1beta1", 

29 manifest={ 

30 "TimedCountAlignment", 

31 "ErrorGroupOrder", 

32 "ListGroupStatsRequest", 

33 "ListGroupStatsResponse", 

34 "ErrorGroupStats", 

35 "TimedCount", 

36 "ListEventsRequest", 

37 "ListEventsResponse", 

38 "QueryTimeRange", 

39 "ServiceContextFilter", 

40 "DeleteEventsRequest", 

41 "DeleteEventsResponse", 

42 }, 

43) 

44 

45 

46class TimedCountAlignment(proto.Enum): 

47 r"""Specifies how the time periods of error group counts are 

48 aligned. 

49 

50 Values: 

51 ERROR_COUNT_ALIGNMENT_UNSPECIFIED (0): 

52 No alignment specified. 

53 ALIGNMENT_EQUAL_ROUNDED (1): 

54 The time periods shall be consecutive, have width equal to 

55 the requested duration, and be aligned at the 

56 ``alignment_time`` provided in the request. The 

57 ``alignment_time`` does not have to be inside the query 

58 period but even if it is outside, only time periods are 

59 returned which overlap with the query period. A rounded 

60 alignment will typically result in a different size of the 

61 first or the last time period. 

62 ALIGNMENT_EQUAL_AT_END (2): 

63 The time periods shall be consecutive, have 

64 width equal to the requested duration, and be 

65 aligned at the end of the requested time period. 

66 This can result in a different size of the first 

67 time period. 

68 """ 

69 ERROR_COUNT_ALIGNMENT_UNSPECIFIED = 0 

70 ALIGNMENT_EQUAL_ROUNDED = 1 

71 ALIGNMENT_EQUAL_AT_END = 2 

72 

73 

74class ErrorGroupOrder(proto.Enum): 

75 r"""A sorting order of error groups. 

76 

77 Values: 

78 GROUP_ORDER_UNSPECIFIED (0): 

79 No group order specified. 

80 COUNT_DESC (1): 

81 Total count of errors in the given time 

82 window in descending order. 

83 LAST_SEEN_DESC (2): 

84 Timestamp when the group was last seen in the 

85 given time window in descending order. 

86 CREATED_DESC (3): 

87 Timestamp when the group was created in 

88 descending order. 

89 AFFECTED_USERS_DESC (4): 

90 Number of affected users in the given time 

91 window in descending order. 

92 """ 

93 GROUP_ORDER_UNSPECIFIED = 0 

94 COUNT_DESC = 1 

95 LAST_SEEN_DESC = 2 

96 CREATED_DESC = 3 

97 AFFECTED_USERS_DESC = 4 

98 

99 

100class ListGroupStatsRequest(proto.Message): 

101 r"""Specifies a set of ``ErrorGroupStats`` to return. 

102 

103 Attributes: 

104 project_name (str): 

105 Required. The resource name of the Google Cloud Platform 

106 project. Written as ``projects/{projectID}`` or 

107 ``projects/{projectNumber}``, where ``{projectID}`` and 

108 ``{projectNumber}`` can be found in the `Google Cloud 

109 Console <https://support.google.com/cloud/answer/6158840>`__. 

110 

111 Examples: ``projects/my-project-123``, ``projects/5551234``. 

112 group_id (MutableSequence[str]): 

113 Optional. List all 

114 <code>ErrorGroupStats</code> with these IDs. 

115 service_filter (google.cloud.errorreporting_v1beta1.types.ServiceContextFilter): 

116 Optional. List only 

117 <code>ErrorGroupStats</code> which belong to a 

118 service context that matches the filter. Data 

119 for all service contexts is returned if this 

120 field is not specified. 

121 time_range (google.cloud.errorreporting_v1beta1.types.QueryTimeRange): 

122 Optional. List data for the given time range. If not set, a 

123 default time range is used. The field time_range_begin in 

124 the response will specify the beginning of this time range. 

125 Only ErrorGroupStats with a non-zero count in the given time 

126 range are returned, unless the request contains an explicit 

127 group_id list. If a group_id list is given, also 

128 ErrorGroupStats with zero occurrences are returned. 

129 timed_count_duration (google.protobuf.duration_pb2.Duration): 

130 Optional. The preferred duration for a single returned 

131 ``TimedCount``. If not set, no timed counts are returned. 

132 alignment (google.cloud.errorreporting_v1beta1.types.TimedCountAlignment): 

133 Optional. The alignment of the timed counts to be returned. 

134 Default is ``ALIGNMENT_EQUAL_AT_END``. 

135 alignment_time (google.protobuf.timestamp_pb2.Timestamp): 

136 Optional. Time where the timed counts shall 

137 be aligned if rounded alignment is chosen. 

138 Default is 00:00 UTC. 

139 order (google.cloud.errorreporting_v1beta1.types.ErrorGroupOrder): 

140 Optional. The sort order in which the results are returned. 

141 Default is ``COUNT_DESC``. 

142 page_size (int): 

143 Optional. The maximum number of results to 

144 return per response. Default is 20. 

145 page_token (str): 

146 Optional. A ``next_page_token`` provided by a previous 

147 response. To view additional results, pass this token along 

148 with the identical query parameters as the first request. 

149 """ 

150 

151 project_name: str = proto.Field( 

152 proto.STRING, 

153 number=1, 

154 ) 

155 group_id: MutableSequence[str] = proto.RepeatedField( 

156 proto.STRING, 

157 number=2, 

158 ) 

159 service_filter: "ServiceContextFilter" = proto.Field( 

160 proto.MESSAGE, 

161 number=3, 

162 message="ServiceContextFilter", 

163 ) 

164 time_range: "QueryTimeRange" = proto.Field( 

165 proto.MESSAGE, 

166 number=5, 

167 message="QueryTimeRange", 

168 ) 

169 timed_count_duration: duration_pb2.Duration = proto.Field( 

170 proto.MESSAGE, 

171 number=6, 

172 message=duration_pb2.Duration, 

173 ) 

174 alignment: "TimedCountAlignment" = proto.Field( 

175 proto.ENUM, 

176 number=7, 

177 enum="TimedCountAlignment", 

178 ) 

179 alignment_time: timestamp_pb2.Timestamp = proto.Field( 

180 proto.MESSAGE, 

181 number=8, 

182 message=timestamp_pb2.Timestamp, 

183 ) 

184 order: "ErrorGroupOrder" = proto.Field( 

185 proto.ENUM, 

186 number=9, 

187 enum="ErrorGroupOrder", 

188 ) 

189 page_size: int = proto.Field( 

190 proto.INT32, 

191 number=11, 

192 ) 

193 page_token: str = proto.Field( 

194 proto.STRING, 

195 number=12, 

196 ) 

197 

198 

199class ListGroupStatsResponse(proto.Message): 

200 r"""Contains a set of requested error group stats. 

201 

202 Attributes: 

203 error_group_stats (MutableSequence[google.cloud.errorreporting_v1beta1.types.ErrorGroupStats]): 

204 The error group stats which match the given 

205 request. 

206 next_page_token (str): 

207 If non-empty, more results are available. 

208 Pass this token, along with the same query 

209 parameters as the first request, to view the 

210 next page of results. 

211 time_range_begin (google.protobuf.timestamp_pb2.Timestamp): 

212 The timestamp specifies the start time to 

213 which the request was restricted. The start time 

214 is set based on the requested time range. It may 

215 be adjusted to a later time if a project has 

216 exceeded the storage quota and older data has 

217 been deleted. 

218 """ 

219 

220 @property 

221 def raw_page(self): 

222 return self 

223 

224 error_group_stats: MutableSequence["ErrorGroupStats"] = proto.RepeatedField( 

225 proto.MESSAGE, 

226 number=1, 

227 message="ErrorGroupStats", 

228 ) 

229 next_page_token: str = proto.Field( 

230 proto.STRING, 

231 number=2, 

232 ) 

233 time_range_begin: timestamp_pb2.Timestamp = proto.Field( 

234 proto.MESSAGE, 

235 number=4, 

236 message=timestamp_pb2.Timestamp, 

237 ) 

238 

239 

240class ErrorGroupStats(proto.Message): 

241 r"""Data extracted for a specific group based on certain filter 

242 criteria, such as a given time period and/or service filter. 

243 

244 Attributes: 

245 group (google.cloud.errorreporting_v1beta1.types.ErrorGroup): 

246 Group data that is independent of the filter 

247 criteria. 

248 count (int): 

249 Approximate total number of events in the 

250 given group that match the filter criteria. 

251 affected_users_count (int): 

252 Approximate number of affected users in the given group that 

253 match the filter criteria. Users are distinguished by data 

254 in the ``ErrorContext`` of the individual error events, such 

255 as their login name or their remote IP address in case of 

256 HTTP requests. The number of affected users can be zero even 

257 if the number of errors is non-zero if no data was provided 

258 from which the affected user could be deduced. Users are 

259 counted based on data in the request context that was 

260 provided in the error report. If more users are implicitly 

261 affected, such as due to a crash of the whole service, this 

262 is not reflected here. 

263 timed_counts (MutableSequence[google.cloud.errorreporting_v1beta1.types.TimedCount]): 

264 Approximate number of occurrences over time. 

265 Timed counts returned by ListGroups are 

266 guaranteed to be: 

267 

268 - Inside the requested time interval 

269 - Non-overlapping, and 

270 - Ordered by ascending time. 

271 first_seen_time (google.protobuf.timestamp_pb2.Timestamp): 

272 Approximate first occurrence that was ever seen for this 

273 group and which matches the given filter criteria, ignoring 

274 the time_range that was specified in the request. 

275 last_seen_time (google.protobuf.timestamp_pb2.Timestamp): 

276 Approximate last occurrence that was ever seen for this 

277 group and which matches the given filter criteria, ignoring 

278 the time_range that was specified in the request. 

279 affected_services (MutableSequence[google.cloud.errorreporting_v1beta1.types.ServiceContext]): 

280 Service contexts with a non-zero error count for the given 

281 filter criteria. This list can be truncated if multiple 

282 services are affected. Refer to ``num_affected_services`` 

283 for the total count. 

284 num_affected_services (int): 

285 The total number of services with a non-zero 

286 error count for the given filter criteria. 

287 representative (google.cloud.errorreporting_v1beta1.types.ErrorEvent): 

288 An arbitrary event that is chosen as 

289 representative for the whole group. The 

290 representative event is intended to be used as a 

291 quick preview for the whole group. Events in the 

292 group are usually sufficiently similar to each 

293 other such that showing an arbitrary 

294 representative provides insight into the 

295 characteristics of the group as a whole. 

296 """ 

297 

298 group: common.ErrorGroup = proto.Field( 

299 proto.MESSAGE, 

300 number=1, 

301 message=common.ErrorGroup, 

302 ) 

303 count: int = proto.Field( 

304 proto.INT64, 

305 number=2, 

306 ) 

307 affected_users_count: int = proto.Field( 

308 proto.INT64, 

309 number=3, 

310 ) 

311 timed_counts: MutableSequence["TimedCount"] = proto.RepeatedField( 

312 proto.MESSAGE, 

313 number=4, 

314 message="TimedCount", 

315 ) 

316 first_seen_time: timestamp_pb2.Timestamp = proto.Field( 

317 proto.MESSAGE, 

318 number=5, 

319 message=timestamp_pb2.Timestamp, 

320 ) 

321 last_seen_time: timestamp_pb2.Timestamp = proto.Field( 

322 proto.MESSAGE, 

323 number=6, 

324 message=timestamp_pb2.Timestamp, 

325 ) 

326 affected_services: MutableSequence[common.ServiceContext] = proto.RepeatedField( 

327 proto.MESSAGE, 

328 number=7, 

329 message=common.ServiceContext, 

330 ) 

331 num_affected_services: int = proto.Field( 

332 proto.INT32, 

333 number=8, 

334 ) 

335 representative: common.ErrorEvent = proto.Field( 

336 proto.MESSAGE, 

337 number=9, 

338 message=common.ErrorEvent, 

339 ) 

340 

341 

342class TimedCount(proto.Message): 

343 r"""The number of errors in a given time period. 

344 All numbers are approximate since the error events are sampled 

345 before counting them. 

346 

347 Attributes: 

348 count (int): 

349 Approximate number of occurrences in the 

350 given time period. 

351 start_time (google.protobuf.timestamp_pb2.Timestamp): 

352 Start of the time period to which ``count`` refers 

353 (included). 

354 end_time (google.protobuf.timestamp_pb2.Timestamp): 

355 End of the time period to which ``count`` refers (excluded). 

356 """ 

357 

358 count: int = proto.Field( 

359 proto.INT64, 

360 number=1, 

361 ) 

362 start_time: timestamp_pb2.Timestamp = proto.Field( 

363 proto.MESSAGE, 

364 number=2, 

365 message=timestamp_pb2.Timestamp, 

366 ) 

367 end_time: timestamp_pb2.Timestamp = proto.Field( 

368 proto.MESSAGE, 

369 number=3, 

370 message=timestamp_pb2.Timestamp, 

371 ) 

372 

373 

374class ListEventsRequest(proto.Message): 

375 r"""Specifies a set of error events to return. 

376 

377 Attributes: 

378 project_name (str): 

379 Required. The resource name of the Google Cloud Platform 

380 project. Written as ``projects/{projectID}``, where 

381 ``{projectID}`` is the `Google Cloud Platform project 

382 ID <https://support.google.com/cloud/answer/6158840>`__. 

383 

384 Example: ``projects/my-project-123``. 

385 group_id (str): 

386 Required. The group for which events shall be 

387 returned. 

388 service_filter (google.cloud.errorreporting_v1beta1.types.ServiceContextFilter): 

389 Optional. List only ErrorGroups which belong 

390 to a service context that matches the filter. 

391 Data for all service contexts is returned if 

392 this field is not specified. 

393 time_range (google.cloud.errorreporting_v1beta1.types.QueryTimeRange): 

394 Optional. List only data for the given time range. If not 

395 set a default time range is used. The field time_range_begin 

396 in the response will specify the beginning of this time 

397 range. 

398 page_size (int): 

399 Optional. The maximum number of results to 

400 return per response. 

401 page_token (str): 

402 Optional. A ``next_page_token`` provided by a previous 

403 response. 

404 """ 

405 

406 project_name: str = proto.Field( 

407 proto.STRING, 

408 number=1, 

409 ) 

410 group_id: str = proto.Field( 

411 proto.STRING, 

412 number=2, 

413 ) 

414 service_filter: "ServiceContextFilter" = proto.Field( 

415 proto.MESSAGE, 

416 number=3, 

417 message="ServiceContextFilter", 

418 ) 

419 time_range: "QueryTimeRange" = proto.Field( 

420 proto.MESSAGE, 

421 number=4, 

422 message="QueryTimeRange", 

423 ) 

424 page_size: int = proto.Field( 

425 proto.INT32, 

426 number=6, 

427 ) 

428 page_token: str = proto.Field( 

429 proto.STRING, 

430 number=7, 

431 ) 

432 

433 

434class ListEventsResponse(proto.Message): 

435 r"""Contains a set of requested error events. 

436 

437 Attributes: 

438 error_events (MutableSequence[google.cloud.errorreporting_v1beta1.types.ErrorEvent]): 

439 The error events which match the given 

440 request. 

441 next_page_token (str): 

442 If non-empty, more results are available. 

443 Pass this token, along with the same query 

444 parameters as the first request, to view the 

445 next page of results. 

446 time_range_begin (google.protobuf.timestamp_pb2.Timestamp): 

447 The timestamp specifies the start time to 

448 which the request was restricted. 

449 """ 

450 

451 @property 

452 def raw_page(self): 

453 return self 

454 

455 error_events: MutableSequence[common.ErrorEvent] = proto.RepeatedField( 

456 proto.MESSAGE, 

457 number=1, 

458 message=common.ErrorEvent, 

459 ) 

460 next_page_token: str = proto.Field( 

461 proto.STRING, 

462 number=2, 

463 ) 

464 time_range_begin: timestamp_pb2.Timestamp = proto.Field( 

465 proto.MESSAGE, 

466 number=4, 

467 message=timestamp_pb2.Timestamp, 

468 ) 

469 

470 

471class QueryTimeRange(proto.Message): 

472 r"""Requests might be rejected or the resulting timed count 

473 durations might be adjusted for lower durations. 

474 

475 Attributes: 

476 period (google.cloud.errorreporting_v1beta1.types.QueryTimeRange.Period): 

477 Restricts the query to the specified time 

478 range. 

479 """ 

480 

481 class Period(proto.Enum): 

482 r"""The supported time ranges. 

483 

484 Values: 

485 PERIOD_UNSPECIFIED (0): 

486 Do not use. 

487 PERIOD_1_HOUR (1): 

488 Retrieve data for the last hour. 

489 Recommended minimum timed count duration: 1 min. 

490 PERIOD_6_HOURS (2): 

491 Retrieve data for the last 6 hours. 

492 Recommended minimum timed count duration: 10 

493 min. 

494 PERIOD_1_DAY (3): 

495 Retrieve data for the last day. 

496 Recommended minimum timed count duration: 1 

497 hour. 

498 PERIOD_1_WEEK (4): 

499 Retrieve data for the last week. 

500 Recommended minimum timed count duration: 6 

501 hours. 

502 PERIOD_30_DAYS (5): 

503 Retrieve data for the last 30 days. 

504 Recommended minimum timed count duration: 1 day. 

505 """ 

506 PERIOD_UNSPECIFIED = 0 

507 PERIOD_1_HOUR = 1 

508 PERIOD_6_HOURS = 2 

509 PERIOD_1_DAY = 3 

510 PERIOD_1_WEEK = 4 

511 PERIOD_30_DAYS = 5 

512 

513 period: Period = proto.Field( 

514 proto.ENUM, 

515 number=1, 

516 enum=Period, 

517 ) 

518 

519 

520class ServiceContextFilter(proto.Message): 

521 r"""Specifies criteria for filtering a subset of service contexts. The 

522 fields in the filter correspond to the fields in ``ServiceContext``. 

523 Only exact, case-sensitive matches are supported. If a field is 

524 unset or empty, it matches arbitrary values. 

525 

526 Attributes: 

527 service (str): 

528 Optional. The exact value to match against 

529 ```ServiceContext.service`` </error-reporting/reference/rest/v1beta1/ServiceContext#FIELDS.service>`__. 

530 version (str): 

531 Optional. The exact value to match against 

532 ```ServiceContext.version`` </error-reporting/reference/rest/v1beta1/ServiceContext#FIELDS.version>`__. 

533 resource_type (str): 

534 Optional. The exact value to match against 

535 ```ServiceContext.resource_type`` </error-reporting/reference/rest/v1beta1/ServiceContext#FIELDS.resource_type>`__. 

536 """ 

537 

538 service: str = proto.Field( 

539 proto.STRING, 

540 number=2, 

541 ) 

542 version: str = proto.Field( 

543 proto.STRING, 

544 number=3, 

545 ) 

546 resource_type: str = proto.Field( 

547 proto.STRING, 

548 number=4, 

549 ) 

550 

551 

552class DeleteEventsRequest(proto.Message): 

553 r"""Deletes all events in the project. 

554 

555 Attributes: 

556 project_name (str): 

557 Required. The resource name of the Google Cloud Platform 

558 project. Written as ``projects/{projectID}``, where 

559 ``{projectID}`` is the `Google Cloud Platform project 

560 ID <https://support.google.com/cloud/answer/6158840>`__. 

561 

562 Example: ``projects/my-project-123``. 

563 """ 

564 

565 project_name: str = proto.Field( 

566 proto.STRING, 

567 number=1, 

568 ) 

569 

570 

571class DeleteEventsResponse(proto.Message): 

572 r"""Response message for deleting error events.""" 

573 

574 

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