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
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 - Inside the requested time interval
268 - Non-overlapping, and
269 - Ordered by ascending time.
270 first_seen_time (google.protobuf.timestamp_pb2.Timestamp):
271 Approximate first occurrence that was ever seen for this
272 group and which matches the given filter criteria, ignoring
273 the time_range that was specified in the request.
274 last_seen_time (google.protobuf.timestamp_pb2.Timestamp):
275 Approximate last occurrence that was ever seen for this
276 group and which matches the given filter criteria, ignoring
277 the time_range that was specified in the request.
278 affected_services (MutableSequence[google.cloud.errorreporting_v1beta1.types.ServiceContext]):
279 Service contexts with a non-zero error count for the given
280 filter criteria. This list can be truncated if multiple
281 services are affected. Refer to ``num_affected_services``
282 for the total count.
283 num_affected_services (int):
284 The total number of services with a non-zero
285 error count for the given filter criteria.
286 representative (google.cloud.errorreporting_v1beta1.types.ErrorEvent):
287 An arbitrary event that is chosen as
288 representative for the whole group. The
289 representative event is intended to be used as a
290 quick preview for the whole group. Events in the
291 group are usually sufficiently similar to each
292 other such that showing an arbitrary
293 representative provides insight into the
294 characteristics of the group as a whole.
295 """
296
297 group: common.ErrorGroup = proto.Field(
298 proto.MESSAGE,
299 number=1,
300 message=common.ErrorGroup,
301 )
302 count: int = proto.Field(
303 proto.INT64,
304 number=2,
305 )
306 affected_users_count: int = proto.Field(
307 proto.INT64,
308 number=3,
309 )
310 timed_counts: MutableSequence["TimedCount"] = proto.RepeatedField(
311 proto.MESSAGE,
312 number=4,
313 message="TimedCount",
314 )
315 first_seen_time: timestamp_pb2.Timestamp = proto.Field(
316 proto.MESSAGE,
317 number=5,
318 message=timestamp_pb2.Timestamp,
319 )
320 last_seen_time: timestamp_pb2.Timestamp = proto.Field(
321 proto.MESSAGE,
322 number=6,
323 message=timestamp_pb2.Timestamp,
324 )
325 affected_services: MutableSequence[common.ServiceContext] = proto.RepeatedField(
326 proto.MESSAGE,
327 number=7,
328 message=common.ServiceContext,
329 )
330 num_affected_services: int = proto.Field(
331 proto.INT32,
332 number=8,
333 )
334 representative: common.ErrorEvent = proto.Field(
335 proto.MESSAGE,
336 number=9,
337 message=common.ErrorEvent,
338 )
339
340
341class TimedCount(proto.Message):
342 r"""The number of errors in a given time period.
343 All numbers are approximate since the error events are sampled
344 before counting them.
345
346 Attributes:
347 count (int):
348 Approximate number of occurrences in the
349 given time period.
350 start_time (google.protobuf.timestamp_pb2.Timestamp):
351 Start of the time period to which ``count`` refers
352 (included).
353 end_time (google.protobuf.timestamp_pb2.Timestamp):
354 End of the time period to which ``count`` refers (excluded).
355 """
356
357 count: int = proto.Field(
358 proto.INT64,
359 number=1,
360 )
361 start_time: timestamp_pb2.Timestamp = proto.Field(
362 proto.MESSAGE,
363 number=2,
364 message=timestamp_pb2.Timestamp,
365 )
366 end_time: timestamp_pb2.Timestamp = proto.Field(
367 proto.MESSAGE,
368 number=3,
369 message=timestamp_pb2.Timestamp,
370 )
371
372
373class ListEventsRequest(proto.Message):
374 r"""Specifies a set of error events to return.
375
376 Attributes:
377 project_name (str):
378 Required. The resource name of the Google Cloud Platform
379 project. Written as ``projects/{projectID}``, where
380 ``{projectID}`` is the `Google Cloud Platform project
381 ID <https://support.google.com/cloud/answer/6158840>`__.
382
383 Example: ``projects/my-project-123``.
384 group_id (str):
385 Required. The group for which events shall be
386 returned.
387 service_filter (google.cloud.errorreporting_v1beta1.types.ServiceContextFilter):
388 Optional. List only ErrorGroups which belong
389 to a service context that matches the filter.
390 Data for all service contexts is returned if
391 this field is not specified.
392 time_range (google.cloud.errorreporting_v1beta1.types.QueryTimeRange):
393 Optional. List only data for the given time range. If not
394 set a default time range is used. The field time_range_begin
395 in the response will specify the beginning of this time
396 range.
397 page_size (int):
398 Optional. The maximum number of results to
399 return per response.
400 page_token (str):
401 Optional. A ``next_page_token`` provided by a previous
402 response.
403 """
404
405 project_name: str = proto.Field(
406 proto.STRING,
407 number=1,
408 )
409 group_id: str = proto.Field(
410 proto.STRING,
411 number=2,
412 )
413 service_filter: "ServiceContextFilter" = proto.Field(
414 proto.MESSAGE,
415 number=3,
416 message="ServiceContextFilter",
417 )
418 time_range: "QueryTimeRange" = proto.Field(
419 proto.MESSAGE,
420 number=4,
421 message="QueryTimeRange",
422 )
423 page_size: int = proto.Field(
424 proto.INT32,
425 number=6,
426 )
427 page_token: str = proto.Field(
428 proto.STRING,
429 number=7,
430 )
431
432
433class ListEventsResponse(proto.Message):
434 r"""Contains a set of requested error events.
435
436 Attributes:
437 error_events (MutableSequence[google.cloud.errorreporting_v1beta1.types.ErrorEvent]):
438 The error events which match the given
439 request.
440 next_page_token (str):
441 If non-empty, more results are available.
442 Pass this token, along with the same query
443 parameters as the first request, to view the
444 next page of results.
445 time_range_begin (google.protobuf.timestamp_pb2.Timestamp):
446 The timestamp specifies the start time to
447 which the request was restricted.
448 """
449
450 @property
451 def raw_page(self):
452 return self
453
454 error_events: MutableSequence[common.ErrorEvent] = proto.RepeatedField(
455 proto.MESSAGE,
456 number=1,
457 message=common.ErrorEvent,
458 )
459 next_page_token: str = proto.Field(
460 proto.STRING,
461 number=2,
462 )
463 time_range_begin: timestamp_pb2.Timestamp = proto.Field(
464 proto.MESSAGE,
465 number=4,
466 message=timestamp_pb2.Timestamp,
467 )
468
469
470class QueryTimeRange(proto.Message):
471 r"""Requests might be rejected or the resulting timed count
472 durations might be adjusted for lower durations.
473
474 Attributes:
475 period (google.cloud.errorreporting_v1beta1.types.QueryTimeRange.Period):
476 Restricts the query to the specified time
477 range.
478 """
479
480 class Period(proto.Enum):
481 r"""The supported time ranges.
482
483 Values:
484 PERIOD_UNSPECIFIED (0):
485 Do not use.
486 PERIOD_1_HOUR (1):
487 Retrieve data for the last hour.
488 Recommended minimum timed count duration: 1 min.
489 PERIOD_6_HOURS (2):
490 Retrieve data for the last 6 hours.
491 Recommended minimum timed count duration: 10
492 min.
493 PERIOD_1_DAY (3):
494 Retrieve data for the last day.
495 Recommended minimum timed count duration: 1
496 hour.
497 PERIOD_1_WEEK (4):
498 Retrieve data for the last week.
499 Recommended minimum timed count duration: 6
500 hours.
501 PERIOD_30_DAYS (5):
502 Retrieve data for the last 30 days.
503 Recommended minimum timed count duration: 1 day.
504 """
505 PERIOD_UNSPECIFIED = 0
506 PERIOD_1_HOUR = 1
507 PERIOD_6_HOURS = 2
508 PERIOD_1_DAY = 3
509 PERIOD_1_WEEK = 4
510 PERIOD_30_DAYS = 5
511
512 period: Period = proto.Field(
513 proto.ENUM,
514 number=1,
515 enum=Period,
516 )
517
518
519class ServiceContextFilter(proto.Message):
520 r"""Specifies criteria for filtering a subset of service contexts. The
521 fields in the filter correspond to the fields in ``ServiceContext``.
522 Only exact, case-sensitive matches are supported. If a field is
523 unset or empty, it matches arbitrary values.
524
525 Attributes:
526 service (str):
527 Optional. The exact value to match against
528 ```ServiceContext.service`` </error-reporting/reference/rest/v1beta1/ServiceContext#FIELDS.service>`__.
529 version (str):
530 Optional. The exact value to match against
531 ```ServiceContext.version`` </error-reporting/reference/rest/v1beta1/ServiceContext#FIELDS.version>`__.
532 resource_type (str):
533 Optional. The exact value to match against
534 ```ServiceContext.resource_type`` </error-reporting/reference/rest/v1beta1/ServiceContext#FIELDS.resource_type>`__.
535 """
536
537 service: str = proto.Field(
538 proto.STRING,
539 number=2,
540 )
541 version: str = proto.Field(
542 proto.STRING,
543 number=3,
544 )
545 resource_type: str = proto.Field(
546 proto.STRING,
547 number=4,
548 )
549
550
551class DeleteEventsRequest(proto.Message):
552 r"""Deletes all events in the project.
553
554 Attributes:
555 project_name (str):
556 Required. The resource name of the Google Cloud Platform
557 project. Written as ``projects/{projectID}``, where
558 ``{projectID}`` is the `Google Cloud Platform project
559 ID <https://support.google.com/cloud/answer/6158840>`__.
560
561 Example: ``projects/my-project-123``.
562 """
563
564 project_name: str = proto.Field(
565 proto.STRING,
566 number=1,
567 )
568
569
570class DeleteEventsResponse(proto.Message):
571 r"""Response message for deleting error events."""
572
573
574__all__ = tuple(sorted(__protobuf__.manifest))