Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/google/cloud/logging_v2/types/logging.py: 96%
67 statements
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 07:30 +0000
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 07:30 +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
18from typing import MutableMapping, MutableSequence
20import proto # type: ignore
22from google.api import monitored_resource_pb2 # type: ignore
23from google.cloud.logging_v2.types import log_entry
24from google.protobuf import duration_pb2 # type: ignore
25from google.rpc import status_pb2 # type: ignore
28__protobuf__ = proto.module(
29 package="google.logging.v2",
30 manifest={
31 "DeleteLogRequest",
32 "WriteLogEntriesRequest",
33 "WriteLogEntriesResponse",
34 "WriteLogEntriesPartialErrors",
35 "ListLogEntriesRequest",
36 "ListLogEntriesResponse",
37 "ListMonitoredResourceDescriptorsRequest",
38 "ListMonitoredResourceDescriptorsResponse",
39 "ListLogsRequest",
40 "ListLogsResponse",
41 "TailLogEntriesRequest",
42 "TailLogEntriesResponse",
43 },
44)
47class DeleteLogRequest(proto.Message):
48 r"""The parameters to DeleteLog.
50 Attributes:
51 log_name (str):
52 Required. The resource name of the log to delete:
54 - ``projects/[PROJECT_ID]/logs/[LOG_ID]``
55 - ``organizations/[ORGANIZATION_ID]/logs/[LOG_ID]``
56 - ``billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]``
57 - ``folders/[FOLDER_ID]/logs/[LOG_ID]``
59 ``[LOG_ID]`` must be URL-encoded. For example,
60 ``"projects/my-project-id/logs/syslog"``,
61 ``"organizations/123/logs/cloudaudit.googleapis.com%2Factivity"``.
63 For more information about log names, see
64 [LogEntry][google.logging.v2.LogEntry].
65 """
67 log_name: str = proto.Field(
68 proto.STRING,
69 number=1,
70 )
73class WriteLogEntriesRequest(proto.Message):
74 r"""The parameters to WriteLogEntries.
76 Attributes:
77 log_name (str):
78 Optional. A default log resource name that is assigned to
79 all log entries in ``entries`` that do not specify a value
80 for ``log_name``:
82 - ``projects/[PROJECT_ID]/logs/[LOG_ID]``
83 - ``organizations/[ORGANIZATION_ID]/logs/[LOG_ID]``
84 - ``billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]``
85 - ``folders/[FOLDER_ID]/logs/[LOG_ID]``
87 ``[LOG_ID]`` must be URL-encoded. For example:
89 ::
91 "projects/my-project-id/logs/syslog"
92 "organizations/123/logs/cloudaudit.googleapis.com%2Factivity"
94 The permission ``logging.logEntries.create`` is needed on
95 each project, organization, billing account, or folder that
96 is receiving new log entries, whether the resource is
97 specified in ``logName`` or in an individual log entry.
98 resource (google.api.monitored_resource_pb2.MonitoredResource):
99 Optional. A default monitored resource object that is
100 assigned to all log entries in ``entries`` that do not
101 specify a value for ``resource``. Example:
103 ::
105 { "type": "gce_instance",
106 "labels": {
107 "zone": "us-central1-a", "instance_id": "00000000000000000000" }}
109 See [LogEntry][google.logging.v2.LogEntry].
110 labels (MutableMapping[str, str]):
111 Optional. Default labels that are added to the ``labels``
112 field of all log entries in ``entries``. If a log entry
113 already has a label with the same key as a label in this
114 parameter, then the log entry's label is not changed. See
115 [LogEntry][google.logging.v2.LogEntry].
116 entries (MutableSequence[google.cloud.logging_v2.types.LogEntry]):
117 Required. The log entries to send to Logging. The order of
118 log entries in this list does not matter. Values supplied in
119 this method's ``log_name``, ``resource``, and ``labels``
120 fields are copied into those log entries in this list that
121 do not include values for their corresponding fields. For
122 more information, see the
123 [LogEntry][google.logging.v2.LogEntry] type.
125 If the ``timestamp`` or ``insert_id`` fields are missing in
126 log entries, then this method supplies the current time or a
127 unique identifier, respectively. The supplied values are
128 chosen so that, among the log entries that did not supply
129 their own values, the entries earlier in the list will sort
130 before the entries later in the list. See the
131 ``entries.list`` method.
133 Log entries with timestamps that are more than the `logs
134 retention
135 period <https://cloud.google.com/logging/quotas>`__ in the
136 past or more than 24 hours in the future will not be
137 available when calling ``entries.list``. However, those log
138 entries can still be `exported with
139 LogSinks <https://cloud.google.com/logging/docs/api/tasks/exporting-logs>`__.
141 To improve throughput and to avoid exceeding the `quota
142 limit <https://cloud.google.com/logging/quotas>`__ for calls
143 to ``entries.write``, you should try to include several log
144 entries in this list, rather than calling this method for
145 each individual log entry.
146 partial_success (bool):
147 Optional. Whether valid entries should be written even if
148 some other entries fail due to INVALID_ARGUMENT or
149 PERMISSION_DENIED errors. If any entry is not written, then
150 the response status is the error associated with one of the
151 failed entries and the response includes error details keyed
152 by the entries' zero-based index in the ``entries.write``
153 method.
154 dry_run (bool):
155 Optional. If true, the request should expect
156 normal response, but the entries won't be
157 persisted nor exported. Useful for checking
158 whether the logging API endpoints are working
159 properly before sending valuable data.
160 """
162 log_name: str = proto.Field(
163 proto.STRING,
164 number=1,
165 )
166 resource: monitored_resource_pb2.MonitoredResource = proto.Field(
167 proto.MESSAGE,
168 number=2,
169 message=monitored_resource_pb2.MonitoredResource,
170 )
171 labels: MutableMapping[str, str] = proto.MapField(
172 proto.STRING,
173 proto.STRING,
174 number=3,
175 )
176 entries: MutableSequence[log_entry.LogEntry] = proto.RepeatedField(
177 proto.MESSAGE,
178 number=4,
179 message=log_entry.LogEntry,
180 )
181 partial_success: bool = proto.Field(
182 proto.BOOL,
183 number=5,
184 )
185 dry_run: bool = proto.Field(
186 proto.BOOL,
187 number=6,
188 )
191class WriteLogEntriesResponse(proto.Message):
192 r"""Result returned from WriteLogEntries."""
195class WriteLogEntriesPartialErrors(proto.Message):
196 r"""Error details for WriteLogEntries with partial success.
198 Attributes:
199 log_entry_errors (MutableMapping[int, google.rpc.status_pb2.Status]):
200 When ``WriteLogEntriesRequest.partial_success`` is true,
201 records the error status for entries that were not written
202 due to a permanent error, keyed by the entry's zero-based
203 index in ``WriteLogEntriesRequest.entries``.
205 Failed requests for which no entries are written will not
206 include per-entry errors.
207 """
209 log_entry_errors: MutableMapping[int, status_pb2.Status] = proto.MapField(
210 proto.INT32,
211 proto.MESSAGE,
212 number=1,
213 message=status_pb2.Status,
214 )
217class ListLogEntriesRequest(proto.Message):
218 r"""The parameters to ``ListLogEntries``.
220 Attributes:
221 resource_names (MutableSequence[str]):
222 Required. Names of one or more parent resources from which
223 to retrieve log entries:
225 - ``projects/[PROJECT_ID]``
226 - ``organizations/[ORGANIZATION_ID]``
227 - ``billingAccounts/[BILLING_ACCOUNT_ID]``
228 - ``folders/[FOLDER_ID]``
230 May alternatively be one or more views:
232 - ``projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]``
233 - ``organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]``
234 - ``billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]``
235 - ``folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]``
237 Projects listed in the ``project_ids`` field are added to
238 this list.
239 filter (str):
240 Optional. A filter that chooses which log entries to return.
241 See `Advanced Logs
242 Queries <https://cloud.google.com/logging/docs/view/advanced-queries>`__.
243 Only log entries that match the filter are returned. An
244 empty filter matches all log entries in the resources listed
245 in ``resource_names``. Referencing a parent resource that is
246 not listed in ``resource_names`` will cause the filter to
247 return no results. The maximum length of the filter is 20000
248 characters.
249 order_by (str):
250 Optional. How the results should be sorted. Presently, the
251 only permitted values are ``"timestamp asc"`` (default) and
252 ``"timestamp desc"``. The first option returns entries in
253 order of increasing values of ``LogEntry.timestamp`` (oldest
254 first), and the second option returns entries in order of
255 decreasing timestamps (newest first). Entries with equal
256 timestamps are returned in order of their ``insert_id``
257 values.
258 page_size (int):
259 Optional. The maximum number of results to return from this
260 request. Default is 50. If the value is negative or exceeds
261 1000, the request is rejected. The presence of
262 ``next_page_token`` in the response indicates that more
263 results might be available.
264 page_token (str):
265 Optional. If present, then retrieve the next batch of
266 results from the preceding call to this method.
267 ``page_token`` must be the value of ``next_page_token`` from
268 the previous response. The values of other method parameters
269 should be identical to those in the previous call.
270 """
272 resource_names: MutableSequence[str] = proto.RepeatedField(
273 proto.STRING,
274 number=8,
275 )
276 filter: str = proto.Field(
277 proto.STRING,
278 number=2,
279 )
280 order_by: str = proto.Field(
281 proto.STRING,
282 number=3,
283 )
284 page_size: int = proto.Field(
285 proto.INT32,
286 number=4,
287 )
288 page_token: str = proto.Field(
289 proto.STRING,
290 number=5,
291 )
294class ListLogEntriesResponse(proto.Message):
295 r"""Result returned from ``ListLogEntries``.
297 Attributes:
298 entries (MutableSequence[google.cloud.logging_v2.types.LogEntry]):
299 A list of log entries. If ``entries`` is empty,
300 ``nextPageToken`` may still be returned, indicating that
301 more entries may exist. See ``nextPageToken`` for more
302 information.
303 next_page_token (str):
304 If there might be more results than those appearing in this
305 response, then ``nextPageToken`` is included. To get the
306 next set of results, call this method again using the value
307 of ``nextPageToken`` as ``pageToken``.
309 If a value for ``next_page_token`` appears and the
310 ``entries`` field is empty, it means that the search found
311 no log entries so far but it did not have time to search all
312 the possible log entries. Retry the method with this value
313 for ``page_token`` to continue the search. Alternatively,
314 consider speeding up the search by changing your filter to
315 specify a single log name or resource type, or to narrow the
316 time range of the search.
317 """
319 @property
320 def raw_page(self):
321 return self
323 entries: MutableSequence[log_entry.LogEntry] = proto.RepeatedField(
324 proto.MESSAGE,
325 number=1,
326 message=log_entry.LogEntry,
327 )
328 next_page_token: str = proto.Field(
329 proto.STRING,
330 number=2,
331 )
334class ListMonitoredResourceDescriptorsRequest(proto.Message):
335 r"""The parameters to ListMonitoredResourceDescriptors
337 Attributes:
338 page_size (int):
339 Optional. The maximum number of results to return from this
340 request. Non-positive values are ignored. The presence of
341 ``nextPageToken`` in the response indicates that more
342 results might be available.
343 page_token (str):
344 Optional. If present, then retrieve the next batch of
345 results from the preceding call to this method.
346 ``pageToken`` must be the value of ``nextPageToken`` from
347 the previous response. The values of other method parameters
348 should be identical to those in the previous call.
349 """
351 page_size: int = proto.Field(
352 proto.INT32,
353 number=1,
354 )
355 page_token: str = proto.Field(
356 proto.STRING,
357 number=2,
358 )
361class ListMonitoredResourceDescriptorsResponse(proto.Message):
362 r"""Result returned from ListMonitoredResourceDescriptors.
364 Attributes:
365 resource_descriptors (MutableSequence[google.api.monitored_resource_pb2.MonitoredResourceDescriptor]):
366 A list of resource descriptors.
367 next_page_token (str):
368 If there might be more results than those appearing in this
369 response, then ``nextPageToken`` is included. To get the
370 next set of results, call this method again using the value
371 of ``nextPageToken`` as ``pageToken``.
372 """
374 @property
375 def raw_page(self):
376 return self
378 resource_descriptors: MutableSequence[
379 monitored_resource_pb2.MonitoredResourceDescriptor
380 ] = proto.RepeatedField(
381 proto.MESSAGE,
382 number=1,
383 message=monitored_resource_pb2.MonitoredResourceDescriptor,
384 )
385 next_page_token: str = proto.Field(
386 proto.STRING,
387 number=2,
388 )
391class ListLogsRequest(proto.Message):
392 r"""The parameters to ListLogs.
394 Attributes:
395 parent (str):
396 Required. The resource name that owns the logs:
398 - ``projects/[PROJECT_ID]``
399 - ``organizations/[ORGANIZATION_ID]``
400 - ``billingAccounts/[BILLING_ACCOUNT_ID]``
401 - ``folders/[FOLDER_ID]``
402 page_size (int):
403 Optional. The maximum number of results to return from this
404 request. Non-positive values are ignored. The presence of
405 ``nextPageToken`` in the response indicates that more
406 results might be available.
407 page_token (str):
408 Optional. If present, then retrieve the next batch of
409 results from the preceding call to this method.
410 ``pageToken`` must be the value of ``nextPageToken`` from
411 the previous response. The values of other method parameters
412 should be identical to those in the previous call.
413 resource_names (MutableSequence[str]):
414 Optional. The resource name that owns the logs:
416 - ``projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]``
417 - ``organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]``
418 - ``billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]``
419 - ``folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]``
421 To support legacy queries, it could also be:
423 - ``projects/[PROJECT_ID]``
424 - ``organizations/[ORGANIZATION_ID]``
425 - ``billingAccounts/[BILLING_ACCOUNT_ID]``
426 - ``folders/[FOLDER_ID]``
427 """
429 parent: str = proto.Field(
430 proto.STRING,
431 number=1,
432 )
433 page_size: int = proto.Field(
434 proto.INT32,
435 number=2,
436 )
437 page_token: str = proto.Field(
438 proto.STRING,
439 number=3,
440 )
441 resource_names: MutableSequence[str] = proto.RepeatedField(
442 proto.STRING,
443 number=8,
444 )
447class ListLogsResponse(proto.Message):
448 r"""Result returned from ListLogs.
450 Attributes:
451 log_names (MutableSequence[str]):
452 A list of log names. For example,
453 ``"projects/my-project/logs/syslog"`` or
454 ``"organizations/123/logs/cloudresourcemanager.googleapis.com%2Factivity"``.
455 next_page_token (str):
456 If there might be more results than those appearing in this
457 response, then ``nextPageToken`` is included. To get the
458 next set of results, call this method again using the value
459 of ``nextPageToken`` as ``pageToken``.
460 """
462 @property
463 def raw_page(self):
464 return self
466 log_names: MutableSequence[str] = proto.RepeatedField(
467 proto.STRING,
468 number=3,
469 )
470 next_page_token: str = proto.Field(
471 proto.STRING,
472 number=2,
473 )
476class TailLogEntriesRequest(proto.Message):
477 r"""The parameters to ``TailLogEntries``.
479 Attributes:
480 resource_names (MutableSequence[str]):
481 Required. Name of a parent resource from which to retrieve
482 log entries:
484 - ``projects/[PROJECT_ID]``
485 - ``organizations/[ORGANIZATION_ID]``
486 - ``billingAccounts/[BILLING_ACCOUNT_ID]``
487 - ``folders/[FOLDER_ID]``
489 May alternatively be one or more views:
491 - ``projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]``
492 - ``organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]``
493 - ``billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]``
494 - ``folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]``
495 filter (str):
496 Optional. A filter that chooses which log entries to return.
497 See `Advanced Logs
498 Filters <https://cloud.google.com/logging/docs/view/advanced_filters>`__.
499 Only log entries that match the filter are returned. An
500 empty filter matches all log entries in the resources listed
501 in ``resource_names``. Referencing a parent resource that is
502 not in ``resource_names`` will cause the filter to return no
503 results. The maximum length of the filter is 20000
504 characters.
505 buffer_window (google.protobuf.duration_pb2.Duration):
506 Optional. The amount of time to buffer log
507 entries at the server before being returned to
508 prevent out of order results due to late
509 arriving log entries. Valid values are between
510 0-60000 milliseconds. Defaults to 2000
511 milliseconds.
512 """
514 resource_names: MutableSequence[str] = proto.RepeatedField(
515 proto.STRING,
516 number=1,
517 )
518 filter: str = proto.Field(
519 proto.STRING,
520 number=2,
521 )
522 buffer_window: duration_pb2.Duration = proto.Field(
523 proto.MESSAGE,
524 number=3,
525 message=duration_pb2.Duration,
526 )
529class TailLogEntriesResponse(proto.Message):
530 r"""Result returned from ``TailLogEntries``.
532 Attributes:
533 entries (MutableSequence[google.cloud.logging_v2.types.LogEntry]):
534 A list of log entries. Each response in the stream will
535 order entries with increasing values of
536 ``LogEntry.timestamp``. Ordering is not guaranteed between
537 separate responses.
538 suppression_info (MutableSequence[google.cloud.logging_v2.types.TailLogEntriesResponse.SuppressionInfo]):
539 If entries that otherwise would have been
540 included in the session were not sent back to
541 the client, counts of relevant entries omitted
542 from the session with the reason that they were
543 not included. There will be at most one of each
544 reason per response. The counts represent the
545 number of suppressed entries since the last
546 streamed response.
547 """
549 class SuppressionInfo(proto.Message):
550 r"""Information about entries that were omitted from the session.
552 Attributes:
553 reason (google.cloud.logging_v2.types.TailLogEntriesResponse.SuppressionInfo.Reason):
554 The reason that entries were omitted from the
555 session.
556 suppressed_count (int):
557 A lower bound on the count of entries omitted due to
558 ``reason``.
559 """
561 class Reason(proto.Enum):
562 r"""An indicator of why entries were omitted.
564 Values:
565 REASON_UNSPECIFIED (0):
566 Unexpected default.
567 RATE_LIMIT (1):
568 Indicates suppression occurred due to relevant entries being
569 received in excess of rate limits. For quotas and limits,
570 see `Logging API quotas and
571 limits <https://cloud.google.com/logging/quotas#api-limits>`__.
572 NOT_CONSUMED (2):
573 Indicates suppression occurred due to the
574 client not consuming responses quickly enough.
575 """
576 REASON_UNSPECIFIED = 0
577 RATE_LIMIT = 1
578 NOT_CONSUMED = 2
580 reason: "TailLogEntriesResponse.SuppressionInfo.Reason" = proto.Field(
581 proto.ENUM,
582 number=1,
583 enum="TailLogEntriesResponse.SuppressionInfo.Reason",
584 )
585 suppressed_count: int = proto.Field(
586 proto.INT32,
587 number=2,
588 )
590 entries: MutableSequence[log_entry.LogEntry] = proto.RepeatedField(
591 proto.MESSAGE,
592 number=1,
593 message=log_entry.LogEntry,
594 )
595 suppression_info: MutableSequence[SuppressionInfo] = proto.RepeatedField(
596 proto.MESSAGE,
597 number=2,
598 message=SuppressionInfo,
599 )
602__all__ = tuple(sorted(__protobuf__.manifest))