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