Skip to content

Commit 3a25c8c

Browse files
chore: Re-generated to pick up changes from googleapis. (#126)
* changes without context autosynth cannot find the source of changes triggered by earlier changes in this repository, or by version upgrades to tools such as linters. * feat: add the Tailing API to get a live stream of the tail end of filtered logs PiperOrigin-RevId: 344435830 Source-Author: Google APIs <[email protected]> Source-Date: Thu Nov 26 09:56:05 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: e8857c4c36948e7e0500377cd7fcecbf2459afc8 Source-Link: googleapis/googleapis@e8857c4
1 parent ca3d751 commit 3a25c8c

File tree

10 files changed

+503
-4
lines changed

10 files changed

+503
-4
lines changed

google/cloud/logging_v2/proto/logging.proto

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ service LoggingServiceV2 {
125125
};
126126
option (google.api.method_signature) = "parent";
127127
}
128+
129+
// Streaming read of log entries as they are ingested. Until the stream is
130+
// terminated, it will continue reading logs.
131+
rpc TailLogEntries(stream TailLogEntriesRequest) returns (stream TailLogEntriesResponse) {
132+
option (google.api.http) = {
133+
post: "/v2/entries:tail"
134+
body: "*"
135+
};
136+
}
128137
}
129138

130139
// The parameters to DeleteLog.
@@ -254,6 +263,11 @@ message ListLogEntriesRequest {
254263
// "billingAccounts/[BILLING_ACCOUNT_ID]"
255264
// "folders/[FOLDER_ID]"
256265
//
266+
// May alternatively be one or more views
267+
// projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
268+
// organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
269+
// billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
270+
// folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
257271
//
258272
// Projects listed in the `project_ids` field are added to this list.
259273
repeated string resource_names = 8 [
@@ -363,6 +377,19 @@ message ListLogsRequest {
363377
// `nextPageToken` from the previous response. The values of other method
364378
// parameters should be identical to those in the previous call.
365379
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
380+
381+
// Optional. The resource name that owns the logs:
382+
// projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
383+
// organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
384+
// billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
385+
// folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
386+
//
387+
// To support legacy queries, it could also be:
388+
// "projects/[PROJECT_ID]"
389+
// "organizations/[ORGANIZATION_ID]"
390+
// "billingAccounts/[BILLING_ACCOUNT_ID]"
391+
// "folders/[FOLDER_ID]"
392+
repeated string resource_names = 8 [(google.api.field_behavior) = OPTIONAL];
366393
}
367394

368395
// Result returned from ListLogs.
@@ -377,3 +404,75 @@ message ListLogsResponse {
377404
// method again using the value of `nextPageToken` as `pageToken`.
378405
string next_page_token = 2;
379406
}
407+
408+
// The parameters to `TailLogEntries`.
409+
message TailLogEntriesRequest {
410+
// Required. Name of a parent resource from which to retrieve log entries:
411+
//
412+
// "projects/[PROJECT_ID]"
413+
// "organizations/[ORGANIZATION_ID]"
414+
// "billingAccounts/[BILLING_ACCOUNT_ID]"
415+
// "folders/[FOLDER_ID]"
416+
//
417+
// May alternatively be one or more views:
418+
// "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]"
419+
// "organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]"
420+
// "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]"
421+
// "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]"
422+
repeated string resource_names = 1 [(google.api.field_behavior) = REQUIRED];
423+
424+
// Optional. A filter that chooses which log entries to return. See [Advanced
425+
// Logs Filters](https://cloud.google.com/logging/docs/view/advanced_filters).
426+
// Only log entries that match the filter are returned. An empty filter
427+
// matches all log entries in the resources listed in `resource_names`.
428+
// Referencing a parent resource that is not in `resource_names` will cause
429+
// the filter to return no results. The maximum length of the filter is 20000
430+
// characters.
431+
string filter = 2 [(google.api.field_behavior) = OPTIONAL];
432+
433+
// Optional. The amount of time to buffer log entries at the server before
434+
// being returned to prevent out of order results due to late arriving log
435+
// entries. Valid values are between 0-60000 milliseconds. Defaults to 2000
436+
// milliseconds.
437+
google.protobuf.Duration buffer_window = 3 [(google.api.field_behavior) = OPTIONAL];
438+
}
439+
440+
// Result returned from `TailLogEntries`.
441+
message TailLogEntriesResponse {
442+
// Information about entries that were omitted from the session.
443+
message SuppressionInfo {
444+
// An indicator of why entries were omitted.
445+
enum Reason {
446+
// Unexpected default.
447+
REASON_UNSPECIFIED = 0;
448+
449+
// Indicates suppression occurred due to relevant entries being
450+
// received in excess of rate limits. For quotas and limits, see
451+
// [Logging API quotas and
452+
// limits](https://cloud.google.com/logging/quotas#api-limits).
453+
RATE_LIMIT = 1;
454+
455+
// Indicates suppression occurred due to the client not consuming
456+
// responses quickly enough.
457+
NOT_CONSUMED = 2;
458+
}
459+
460+
// The reason that entries were omitted from the session.
461+
Reason reason = 1;
462+
463+
// A lower bound on the count of entries omitted due to `reason`.
464+
int32 suppressed_count = 2;
465+
}
466+
467+
// A list of log entries. Each response in the stream will order entries with
468+
// increasing values of `LogEntry.timestamp`. Ordering is not guaranteed
469+
// between separate responses.
470+
repeated LogEntry entries = 1;
471+
472+
// If entries that otherwise would have been included in the session were not
473+
// sent back to the client, counts of relevant entries omitted from the
474+
// session with the reason that they were not included. There will be at most
475+
// one of each reason per response. The counts represent the number of
476+
// suppressed entries since the last streamed response.
477+
repeated SuppressionInfo suppression_info = 2;
478+
}

google/cloud/logging_v2/services/logging_service_v2/async_client.py

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,16 @@
1818
from collections import OrderedDict
1919
import functools
2020
import re
21-
from typing import Dict, Sequence, Tuple, Type, Union
21+
from typing import (
22+
Dict,
23+
AsyncIterable,
24+
Awaitable,
25+
AsyncIterator,
26+
Sequence,
27+
Tuple,
28+
Type,
29+
Union,
30+
)
2231
import pkg_resources
2332

2433
import google.api_core.client_options as ClientOptions # type: ignore
@@ -430,6 +439,12 @@ async def list_log_entries(
430439
"billingAccounts/[BILLING_ACCOUNT_ID]"
431440
"folders/[FOLDER_ID]"
432441
442+
May alternatively be one or more views
443+
projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
444+
organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
445+
billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
446+
folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
447+
433448
Projects listed in the ``project_ids`` field are added
434449
to this list.
435450
This corresponds to the ``resource_names`` field
@@ -690,6 +705,56 @@ async def list_logs(
690705
# Done; return the response.
691706
return response
692707

708+
def tail_log_entries(
709+
self,
710+
requests: AsyncIterator[logging.TailLogEntriesRequest] = None,
711+
*,
712+
retry: retries.Retry = gapic_v1.method.DEFAULT,
713+
timeout: float = None,
714+
metadata: Sequence[Tuple[str, str]] = (),
715+
) -> Awaitable[AsyncIterable[logging.TailLogEntriesResponse]]:
716+
r"""Streaming read of log entries as they are ingested.
717+
Until the stream is terminated, it will continue reading
718+
logs.
719+
720+
Args:
721+
requests (AsyncIterator[`~.logging.TailLogEntriesRequest`]):
722+
The request object AsyncIterator. The parameters to `TailLogEntries`.
723+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
724+
should be retried.
725+
timeout (float): The timeout for this request.
726+
metadata (Sequence[Tuple[str, str]]): Strings which should be
727+
sent along with the request as metadata.
728+
729+
Returns:
730+
AsyncIterable[~.logging.TailLogEntriesResponse]:
731+
Result returned from ``TailLogEntries``.
732+
"""
733+
734+
# Wrap the RPC method; this adds retry and timeout information,
735+
# and friendly error handling.
736+
rpc = gapic_v1.method_async.wrap_method(
737+
self._client._transport.tail_log_entries,
738+
default_retry=retries.Retry(
739+
initial=0.1,
740+
maximum=60.0,
741+
multiplier=1.3,
742+
predicate=retries.if_exception_type(
743+
exceptions.DeadlineExceeded,
744+
exceptions.InternalServerError,
745+
exceptions.ServiceUnavailable,
746+
),
747+
),
748+
default_timeout=3600.0,
749+
client_info=DEFAULT_CLIENT_INFO,
750+
)
751+
752+
# Send the request.
753+
response = rpc(requests, retry=retry, timeout=timeout, metadata=metadata,)
754+
755+
# Done; return the response.
756+
return response
757+
693758

694759
try:
695760
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(

google/cloud/logging_v2/services/logging_service_v2/client.py

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,17 @@
1919
from distutils import util
2020
import os
2121
import re
22-
from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union
22+
from typing import (
23+
Callable,
24+
Dict,
25+
Optional,
26+
Iterable,
27+
Iterator,
28+
Sequence,
29+
Tuple,
30+
Type,
31+
Union,
32+
)
2333
import pkg_resources
2434

2535
from google.api_core import client_options as client_options_lib # type: ignore
@@ -598,6 +608,12 @@ def list_log_entries(
598608
"billingAccounts/[BILLING_ACCOUNT_ID]"
599609
"folders/[FOLDER_ID]"
600610
611+
May alternatively be one or more views
612+
projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
613+
organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
614+
billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
615+
folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
616+
601617
Projects listed in the ``project_ids`` field are added
602618
to this list.
603619
This corresponds to the ``resource_names`` field
@@ -833,6 +849,42 @@ def list_logs(
833849
# Done; return the response.
834850
return response
835851

852+
def tail_log_entries(
853+
self,
854+
requests: Iterator[logging.TailLogEntriesRequest] = None,
855+
*,
856+
retry: retries.Retry = gapic_v1.method.DEFAULT,
857+
timeout: float = None,
858+
metadata: Sequence[Tuple[str, str]] = (),
859+
) -> Iterable[logging.TailLogEntriesResponse]:
860+
r"""Streaming read of log entries as they are ingested.
861+
Until the stream is terminated, it will continue reading
862+
logs.
863+
864+
Args:
865+
requests (Iterator[`~.logging.TailLogEntriesRequest`]):
866+
The request object iterator. The parameters to `TailLogEntries`.
867+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
868+
should be retried.
869+
timeout (float): The timeout for this request.
870+
metadata (Sequence[Tuple[str, str]]): Strings which should be
871+
sent along with the request as metadata.
872+
873+
Returns:
874+
Iterable[~.logging.TailLogEntriesResponse]:
875+
Result returned from ``TailLogEntries``.
876+
"""
877+
878+
# Wrap the RPC method; this adds retry and timeout information,
879+
# and friendly error handling.
880+
rpc = self._transport._wrapped_methods[self._transport.tail_log_entries]
881+
882+
# Send the request.
883+
response = rpc(requests, retry=retry, timeout=timeout, metadata=metadata,)
884+
885+
# Done; return the response.
886+
return response
887+
836888

837889
try:
838890
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(

google/cloud/logging_v2/services/logging_service_v2/transports/base.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,21 @@ def _prep_wrapped_messages(self, client_info):
186186
default_timeout=60.0,
187187
client_info=client_info,
188188
),
189+
self.tail_log_entries: gapic_v1.method.wrap_method(
190+
self.tail_log_entries,
191+
default_retry=retries.Retry(
192+
initial=0.1,
193+
maximum=60.0,
194+
multiplier=1.3,
195+
predicate=retries.if_exception_type(
196+
exceptions.DeadlineExceeded,
197+
exceptions.InternalServerError,
198+
exceptions.ServiceUnavailable,
199+
),
200+
),
201+
default_timeout=3600.0,
202+
client_info=client_info,
203+
),
189204
}
190205

191206
@property
@@ -244,5 +259,17 @@ def list_logs(
244259
]:
245260
raise NotImplementedError()
246261

262+
@property
263+
def tail_log_entries(
264+
self,
265+
) -> typing.Callable[
266+
[logging.TailLogEntriesRequest],
267+
typing.Union[
268+
logging.TailLogEntriesResponse,
269+
typing.Awaitable[logging.TailLogEntriesResponse],
270+
],
271+
]:
272+
raise NotImplementedError()
273+
247274

248275
__all__ = ("LoggingServiceV2Transport",)

google/cloud/logging_v2/services/logging_service_v2/transports/grpc.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,5 +380,33 @@ def list_logs(
380380
)
381381
return self._stubs["list_logs"]
382382

383+
@property
384+
def tail_log_entries(
385+
self,
386+
) -> Callable[[logging.TailLogEntriesRequest], logging.TailLogEntriesResponse]:
387+
r"""Return a callable for the tail log entries method over gRPC.
388+
389+
Streaming read of log entries as they are ingested.
390+
Until the stream is terminated, it will continue reading
391+
logs.
392+
393+
Returns:
394+
Callable[[~.TailLogEntriesRequest],
395+
~.TailLogEntriesResponse]:
396+
A function that, when called, will call the underlying RPC
397+
on the server.
398+
"""
399+
# Generate a "stub function" on-the-fly which will actually make
400+
# the request.
401+
# gRPC handles serialization and deserialization, so we just need
402+
# to pass in the functions for each.
403+
if "tail_log_entries" not in self._stubs:
404+
self._stubs["tail_log_entries"] = self.grpc_channel.stream_stream(
405+
"/google.logging.v2.LoggingServiceV2/TailLogEntries",
406+
request_serializer=logging.TailLogEntriesRequest.serialize,
407+
response_deserializer=logging.TailLogEntriesResponse.deserialize,
408+
)
409+
return self._stubs["tail_log_entries"]
410+
383411

384412
__all__ = ("LoggingServiceV2GrpcTransport",)

google/cloud/logging_v2/services/logging_service_v2/transports/grpc_asyncio.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,5 +390,35 @@ def list_logs(
390390
)
391391
return self._stubs["list_logs"]
392392

393+
@property
394+
def tail_log_entries(
395+
self,
396+
) -> Callable[
397+
[logging.TailLogEntriesRequest], Awaitable[logging.TailLogEntriesResponse]
398+
]:
399+
r"""Return a callable for the tail log entries method over gRPC.
400+
401+
Streaming read of log entries as they are ingested.
402+
Until the stream is terminated, it will continue reading
403+
logs.
404+
405+
Returns:
406+
Callable[[~.TailLogEntriesRequest],
407+
Awaitable[~.TailLogEntriesResponse]]:
408+
A function that, when called, will call the underlying RPC
409+
on the server.
410+
"""
411+
# Generate a "stub function" on-the-fly which will actually make
412+
# the request.
413+
# gRPC handles serialization and deserialization, so we just need
414+
# to pass in the functions for each.
415+
if "tail_log_entries" not in self._stubs:
416+
self._stubs["tail_log_entries"] = self.grpc_channel.stream_stream(
417+
"/google.logging.v2.LoggingServiceV2/TailLogEntries",
418+
request_serializer=logging.TailLogEntriesRequest.serialize,
419+
response_deserializer=logging.TailLogEntriesResponse.deserialize,
420+
)
421+
return self._stubs["tail_log_entries"]
422+
393423

394424
__all__ = ("LoggingServiceV2GrpcAsyncIOTransport",)

0 commit comments

Comments
 (0)