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

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

81 statements  

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

2# Copyright 2025 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] 

57 [google.devtools.clouderrorreporting.v1beta1.ListGroupStatsRequest.alignment_time] 

58 provided in the request. 

59 

60 The [alignment_time] 

61 [google.devtools.clouderrorreporting.v1beta1.ListGroupStatsRequest.alignment_time] 

62 does not have to be inside the query period but even if it 

63 is outside, only time periods are returned which overlap 

64 with the query period. 

65 

66 A rounded alignment will typically result in a different 

67 size of the first or the last time period. 

68 ALIGNMENT_EQUAL_AT_END (2): 

69 The time periods shall be consecutive, have 

70 width equal to the requested duration, and be 

71 aligned at the end of the requested time period. 

72 This can result in a different size of the first 

73 time period. 

74 """ 

75 ERROR_COUNT_ALIGNMENT_UNSPECIFIED = 0 

76 ALIGNMENT_EQUAL_ROUNDED = 1 

77 ALIGNMENT_EQUAL_AT_END = 2 

78 

79 

80class ErrorGroupOrder(proto.Enum): 

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

82 

83 Values: 

84 GROUP_ORDER_UNSPECIFIED (0): 

85 No group order specified. 

86 COUNT_DESC (1): 

87 Total count of errors in the given time 

88 window in descending order. 

89 LAST_SEEN_DESC (2): 

90 Timestamp when the group was last seen in the 

91 given time window in descending order. 

92 CREATED_DESC (3): 

93 Timestamp when the group was created in 

94 descending order. 

95 AFFECTED_USERS_DESC (4): 

96 Number of affected users in the given time 

97 window in descending order. 

98 """ 

99 GROUP_ORDER_UNSPECIFIED = 0 

100 COUNT_DESC = 1 

101 LAST_SEEN_DESC = 2 

102 CREATED_DESC = 3 

103 AFFECTED_USERS_DESC = 4 

104 

105 

106class ListGroupStatsRequest(proto.Message): 

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

108 

109 Attributes: 

110 project_name (str): 

111 Required. The resource name of the Google Cloud Platform 

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

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

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

115 console <https://support.google.com/cloud/answer/6158840>`__. 

116 It may also include a location, such as 

117 ``projects/{projectID}/locations/{location}`` where 

118 ``{location}`` is a cloud region. 

119 

120 Examples: ``projects/my-project-123``, ``projects/5551234``, 

121 ``projects/my-project-123/locations/us-central1``, 

122 ``projects/5551234/locations/us-central1``. 

123 

124 For a list of supported locations, see `Supported 

125 Regions <https://cloud.google.com/logging/docs/region-support>`__. 

126 ``global`` is the default when unspecified. Use ``-`` as a 

127 wildcard to request group stats from all regions. 

128 group_id (MutableSequence[str]): 

129 Optional. List all [ErrorGroupStats] 

130 [google.devtools.clouderrorreporting.v1beta1.ErrorGroupStats] 

131 with these IDs. The ``group_id`` is a unique identifier for 

132 a particular error group. The identifier is derived from key 

133 parts of the error-log content and is treated as Service 

134 Data. For information about how Service Data is handled, see 

135 [Google Cloud Privacy Notice] 

136 (https://cloud.google.com/terms/cloud-privacy-notice). 

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

138 Optional. List only [ErrorGroupStats] 

139 [google.devtools.clouderrorreporting.v1beta1.ErrorGroupStats] 

140 which belong to a service context that matches the filter. 

141 Data for all service contexts is returned if this field is 

142 not specified. 

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

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

145 default time range is used. The field [time_range_begin] 

146 [google.devtools.clouderrorreporting.v1beta1.ListGroupStatsResponse.time_range_begin] 

147 in the response will specify the beginning of this time 

148 range. Only [ErrorGroupStats] 

149 [google.devtools.clouderrorreporting.v1beta1.ErrorGroupStats] 

150 with a non-zero count in the given time range are returned, 

151 unless the request contains an explicit [group_id] 

152 [google.devtools.clouderrorreporting.v1beta1.ListGroupStatsRequest.group_id] 

153 list. If a [group_id] 

154 [google.devtools.clouderrorreporting.v1beta1.ListGroupStatsRequest.group_id] 

155 list is given, also [ErrorGroupStats] 

156 [google.devtools.clouderrorreporting.v1beta1.ErrorGroupStats] 

157 with zero occurrences are returned. 

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

159 Optional. The preferred duration for a single returned 

160 [TimedCount] 

161 [google.devtools.clouderrorreporting.v1beta1.TimedCount]. If 

162 not set, no timed counts are returned. 

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

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

165 Default is ``ALIGNMENT_EQUAL_AT_END``. 

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

167 Optional. Time where the timed counts shall 

168 be aligned if rounded alignment is chosen. 

169 Default is 00:00 UTC. 

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

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

172 Default is ``COUNT_DESC``. 

173 page_size (int): 

174 Optional. The maximum number of results to 

175 return per response. Default is 20. 

176 page_token (str): 

177 Optional. A [next_page_token] 

178 [google.devtools.clouderrorreporting.v1beta1.ListGroupStatsResponse.next_page_token] 

179 provided by a previous response. To view additional results, 

180 pass this token along with the identical query parameters as 

181 the first request. 

182 """ 

183 

184 project_name: str = proto.Field( 

185 proto.STRING, 

186 number=1, 

187 ) 

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

189 proto.STRING, 

190 number=2, 

191 ) 

192 service_filter: "ServiceContextFilter" = proto.Field( 

193 proto.MESSAGE, 

194 number=3, 

195 message="ServiceContextFilter", 

196 ) 

197 time_range: "QueryTimeRange" = proto.Field( 

198 proto.MESSAGE, 

199 number=5, 

200 message="QueryTimeRange", 

201 ) 

202 timed_count_duration: duration_pb2.Duration = proto.Field( 

203 proto.MESSAGE, 

204 number=6, 

205 message=duration_pb2.Duration, 

206 ) 

207 alignment: "TimedCountAlignment" = proto.Field( 

208 proto.ENUM, 

209 number=7, 

210 enum="TimedCountAlignment", 

211 ) 

212 alignment_time: timestamp_pb2.Timestamp = proto.Field( 

213 proto.MESSAGE, 

214 number=8, 

215 message=timestamp_pb2.Timestamp, 

216 ) 

217 order: "ErrorGroupOrder" = proto.Field( 

218 proto.ENUM, 

219 number=9, 

220 enum="ErrorGroupOrder", 

221 ) 

222 page_size: int = proto.Field( 

223 proto.INT32, 

224 number=11, 

225 ) 

226 page_token: str = proto.Field( 

227 proto.STRING, 

228 number=12, 

229 ) 

230 

231 

232class ListGroupStatsResponse(proto.Message): 

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

234 

235 Attributes: 

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

237 The error group stats which match the given 

238 request. 

239 next_page_token (str): 

240 If non-empty, more results are available. 

241 Pass this token, along with the same query 

242 parameters as the first request, to view the 

243 next page of results. 

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

245 The timestamp specifies the start time to 

246 which the request was restricted. The start time 

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

248 be adjusted to a later time if a project has 

249 exceeded the storage quota and older data has 

250 been deleted. 

251 """ 

252 

253 @property 

254 def raw_page(self): 

255 return self 

256 

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

258 proto.MESSAGE, 

259 number=1, 

260 message="ErrorGroupStats", 

261 ) 

262 next_page_token: str = proto.Field( 

263 proto.STRING, 

264 number=2, 

265 ) 

266 time_range_begin: timestamp_pb2.Timestamp = proto.Field( 

267 proto.MESSAGE, 

268 number=4, 

269 message=timestamp_pb2.Timestamp, 

270 ) 

271 

272 

273class ErrorGroupStats(proto.Message): 

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

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

276 

277 Attributes: 

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

279 Group data that is independent of the filter 

280 criteria. 

281 count (int): 

282 Approximate total number of events in the 

283 given group that match the filter criteria. 

284 affected_users_count (int): 

285 Approximate number of affected users in the given group that 

286 match the filter criteria. Users are distinguished by data 

287 in the [ErrorContext] 

288 [google.devtools.clouderrorreporting.v1beta1.ErrorContext] 

289 of the individual error events, such as their login name or 

290 their remote IP address in case of HTTP requests. The number 

291 of affected users can be zero even if the number of errors 

292 is non-zero if no data was provided from which the affected 

293 user could be deduced. Users are counted based on data in 

294 the request context that was provided in the error report. 

295 If more users are implicitly affected, such as due to a 

296 crash of the whole service, this is not reflected here. 

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

298 Approximate number of occurrences over time. 

299 Timed counts returned by ListGroups are 

300 guaranteed to be: 

301 

302 - Inside the requested time interval 

303 - Non-overlapping, and 

304 - Ordered by ascending time. 

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

306 Approximate first occurrence that was ever seen for this 

307 group and which matches the given filter criteria, ignoring 

308 the time_range that was specified in the request. 

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

310 Approximate last occurrence that was ever seen for this 

311 group and which matches the given filter criteria, ignoring 

312 the time_range that was specified in the request. 

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

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

315 filter criteria. This list can be truncated if multiple 

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

317 for the total count. 

318 num_affected_services (int): 

319 The total number of services with a non-zero 

320 error count for the given filter criteria. 

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

322 An arbitrary event that is chosen as 

323 representative for the whole group. The 

324 representative event is intended to be used as a 

325 quick preview for the whole group. Events in the 

326 group are usually sufficiently similar to each 

327 other such that showing an arbitrary 

328 representative provides insight into the 

329 characteristics of the group as a whole. 

330 """ 

331 

332 group: common.ErrorGroup = proto.Field( 

333 proto.MESSAGE, 

334 number=1, 

335 message=common.ErrorGroup, 

336 ) 

337 count: int = proto.Field( 

338 proto.INT64, 

339 number=2, 

340 ) 

341 affected_users_count: int = proto.Field( 

342 proto.INT64, 

343 number=3, 

344 ) 

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

346 proto.MESSAGE, 

347 number=4, 

348 message="TimedCount", 

349 ) 

350 first_seen_time: timestamp_pb2.Timestamp = proto.Field( 

351 proto.MESSAGE, 

352 number=5, 

353 message=timestamp_pb2.Timestamp, 

354 ) 

355 last_seen_time: timestamp_pb2.Timestamp = proto.Field( 

356 proto.MESSAGE, 

357 number=6, 

358 message=timestamp_pb2.Timestamp, 

359 ) 

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

361 proto.MESSAGE, 

362 number=7, 

363 message=common.ServiceContext, 

364 ) 

365 num_affected_services: int = proto.Field( 

366 proto.INT32, 

367 number=8, 

368 ) 

369 representative: common.ErrorEvent = proto.Field( 

370 proto.MESSAGE, 

371 number=9, 

372 message=common.ErrorEvent, 

373 ) 

374 

375 

376class TimedCount(proto.Message): 

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

378 All numbers are approximate since the error events are sampled 

379 before counting them. 

380 

381 Attributes: 

382 count (int): 

383 Approximate number of occurrences in the 

384 given time period. 

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

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

387 (included). 

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

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

390 """ 

391 

392 count: int = proto.Field( 

393 proto.INT64, 

394 number=1, 

395 ) 

396 start_time: timestamp_pb2.Timestamp = proto.Field( 

397 proto.MESSAGE, 

398 number=2, 

399 message=timestamp_pb2.Timestamp, 

400 ) 

401 end_time: timestamp_pb2.Timestamp = proto.Field( 

402 proto.MESSAGE, 

403 number=3, 

404 message=timestamp_pb2.Timestamp, 

405 ) 

406 

407 

408class ListEventsRequest(proto.Message): 

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

410 

411 Attributes: 

412 project_name (str): 

413 Required. The resource name of the Google Cloud Platform 

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

415 ``projects/{projectID}/locations/{location}``, where 

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

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

418 ``{location}`` is a Cloud region. 

419 

420 Examples: ``projects/my-project-123``, 

421 ``projects/my-project-123/locations/global``. 

422 

423 For a list of supported locations, see `Supported 

424 Regions <https://cloud.google.com/logging/docs/region-support>`__. 

425 ``global`` is the default when unspecified. 

426 group_id (str): 

427 Required. The group for which events shall be returned. The 

428 ``group_id`` is a unique identifier for a particular error 

429 group. The identifier is derived from key parts of the 

430 error-log content and is treated as Service Data. For 

431 information about how Service Data is handled, see `Google 

432 Cloud Privacy 

433 Notice <https://cloud.google.com/terms/cloud-privacy-notice>`__. 

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

435 Optional. List only ErrorGroups which belong 

436 to a service context that matches the filter. 

437 Data for all service contexts is returned if 

438 this field is not specified. 

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

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

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

442 in the response will specify the beginning of this time 

443 range. 

444 page_size (int): 

445 Optional. The maximum number of results to 

446 return per response. 

447 page_token (str): 

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

449 response. 

450 """ 

451 

452 project_name: str = proto.Field( 

453 proto.STRING, 

454 number=1, 

455 ) 

456 group_id: str = proto.Field( 

457 proto.STRING, 

458 number=2, 

459 ) 

460 service_filter: "ServiceContextFilter" = proto.Field( 

461 proto.MESSAGE, 

462 number=3, 

463 message="ServiceContextFilter", 

464 ) 

465 time_range: "QueryTimeRange" = proto.Field( 

466 proto.MESSAGE, 

467 number=4, 

468 message="QueryTimeRange", 

469 ) 

470 page_size: int = proto.Field( 

471 proto.INT32, 

472 number=6, 

473 ) 

474 page_token: str = proto.Field( 

475 proto.STRING, 

476 number=7, 

477 ) 

478 

479 

480class ListEventsResponse(proto.Message): 

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

482 

483 Attributes: 

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

485 The error events which match the given 

486 request. 

487 next_page_token (str): 

488 If non-empty, more results are available. 

489 Pass this token, along with the same query 

490 parameters as the first request, to view the 

491 next page of results. 

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

493 The timestamp specifies the start time to 

494 which the request was restricted. 

495 """ 

496 

497 @property 

498 def raw_page(self): 

499 return self 

500 

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

502 proto.MESSAGE, 

503 number=1, 

504 message=common.ErrorEvent, 

505 ) 

506 next_page_token: str = proto.Field( 

507 proto.STRING, 

508 number=2, 

509 ) 

510 time_range_begin: timestamp_pb2.Timestamp = proto.Field( 

511 proto.MESSAGE, 

512 number=4, 

513 message=timestamp_pb2.Timestamp, 

514 ) 

515 

516 

517class QueryTimeRange(proto.Message): 

518 r"""A time range for which error group data shall be displayed. 

519 Query time ranges end at 'now'. 

520 When longer time ranges are selected, the resolution of the data 

521 decreases. The description of each time range below indicates 

522 the suggested minimum timed count duration for that range. 

523 

524 Requests might be rejected or the resulting timed count 

525 durations might be adjusted for lower durations. 

526 

527 Attributes: 

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

529 Restricts the query to the specified time 

530 range. 

531 """ 

532 

533 class Period(proto.Enum): 

534 r"""The supported time ranges. 

535 

536 Values: 

537 PERIOD_UNSPECIFIED (0): 

538 Do not use. 

539 PERIOD_1_HOUR (1): 

540 Retrieve data for the last hour. 

541 Recommended minimum timed count duration: 1 min. 

542 PERIOD_6_HOURS (2): 

543 Retrieve data for the last 6 hours. 

544 Recommended minimum timed count duration: 10 

545 min. 

546 PERIOD_1_DAY (3): 

547 Retrieve data for the last day. 

548 Recommended minimum timed count duration: 1 

549 hour. 

550 PERIOD_1_WEEK (4): 

551 Retrieve data for the last week. 

552 Recommended minimum timed count duration: 6 

553 hours. 

554 PERIOD_30_DAYS (5): 

555 Retrieve data for the last 30 days. 

556 Recommended minimum timed count duration: 1 day. 

557 """ 

558 PERIOD_UNSPECIFIED = 0 

559 PERIOD_1_HOUR = 1 

560 PERIOD_6_HOURS = 2 

561 PERIOD_1_DAY = 3 

562 PERIOD_1_WEEK = 4 

563 PERIOD_30_DAYS = 5 

564 

565 period: Period = proto.Field( 

566 proto.ENUM, 

567 number=1, 

568 enum=Period, 

569 ) 

570 

571 

572class ServiceContextFilter(proto.Message): 

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

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

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

576 unset or empty, it matches arbitrary values. 

577 

578 Attributes: 

579 service (str): 

580 Optional. The exact value to match against 

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

582 version (str): 

583 Optional. The exact value to match against 

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

585 resource_type (str): 

586 Optional. The exact value to match against 

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

588 """ 

589 

590 service: str = proto.Field( 

591 proto.STRING, 

592 number=2, 

593 ) 

594 version: str = proto.Field( 

595 proto.STRING, 

596 number=3, 

597 ) 

598 resource_type: str = proto.Field( 

599 proto.STRING, 

600 number=4, 

601 ) 

602 

603 

604class DeleteEventsRequest(proto.Message): 

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

606 

607 Attributes: 

608 project_name (str): 

609 Required. The resource name of the Google Cloud Platform 

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

611 ``projects/{projectID}/locations/{location}``, where 

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

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

614 ``{location}`` is a Cloud region. 

615 

616 Examples: ``projects/my-project-123``, 

617 ``projects/my-project-123/locations/global``. 

618 

619 For a list of supported locations, see `Supported 

620 Regions <https://cloud.google.com/logging/docs/region-support>`__. 

621 ``global`` is the default when unspecified. 

622 """ 

623 

624 project_name: str = proto.Field( 

625 proto.STRING, 

626 number=1, 

627 ) 

628 

629 

630class DeleteEventsResponse(proto.Message): 

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

632 

633 

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