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#
16import inspect
17import json
18import pickle
19import logging as std_logging
20import warnings
21from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union
22
23from google.api_core import gapic_v1
24from google.api_core import grpc_helpers_async
25from google.api_core import exceptions as core_exceptions
26from google.api_core import retry_async as retries
27from google.api_core import operations_v1
28from google.auth import credentials as ga_credentials # type: ignore
29from google.auth.transport.grpc import SslCredentials # type: ignore
30from google.protobuf.json_format import MessageToJson
31import google.protobuf.message
32
33import grpc # type: ignore
34import proto # type: ignore
35from grpc.experimental import aio # type: ignore
36
37from google.cloud.logging_v2.types import logging_config
38from google.longrunning import operations_pb2 # type: ignore
39from google.protobuf import empty_pb2 # type: ignore
40from .base import ConfigServiceV2Transport, DEFAULT_CLIENT_INFO
41from .grpc import ConfigServiceV2GrpcTransport
42
43try:
44 from google.api_core import client_logging # type: ignore
45
46 CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
47except ImportError: # pragma: NO COVER
48 CLIENT_LOGGING_SUPPORTED = False
49
50_LOGGER = std_logging.getLogger(__name__)
51
52
53class _LoggingClientAIOInterceptor(
54 grpc.aio.UnaryUnaryClientInterceptor
55): # pragma: NO COVER
56 async def intercept_unary_unary(self, continuation, client_call_details, request):
57 logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
58 std_logging.DEBUG
59 )
60 if logging_enabled: # pragma: NO COVER
61 request_metadata = client_call_details.metadata
62 if isinstance(request, proto.Message):
63 request_payload = type(request).to_json(request)
64 elif isinstance(request, google.protobuf.message.Message):
65 request_payload = MessageToJson(request)
66 else:
67 request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
68
69 request_metadata = {
70 key: value.decode("utf-8") if isinstance(value, bytes) else value
71 for key, value in request_metadata
72 }
73 grpc_request = {
74 "payload": request_payload,
75 "requestMethod": "grpc",
76 "metadata": dict(request_metadata),
77 }
78 _LOGGER.debug(
79 f"Sending request for {client_call_details.method}",
80 extra={
81 "serviceName": "google.logging.v2.ConfigServiceV2",
82 "rpcName": str(client_call_details.method),
83 "request": grpc_request,
84 "metadata": grpc_request["metadata"],
85 },
86 )
87 response = await continuation(client_call_details, request)
88 if logging_enabled: # pragma: NO COVER
89 response_metadata = await response.trailing_metadata()
90 # Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples
91 metadata = (
92 dict([(k, str(v)) for k, v in response_metadata])
93 if response_metadata
94 else None
95 )
96 result = await response
97 if isinstance(result, proto.Message):
98 response_payload = type(result).to_json(result)
99 elif isinstance(result, google.protobuf.message.Message):
100 response_payload = MessageToJson(result)
101 else:
102 response_payload = f"{type(result).__name__}: {pickle.dumps(result)}"
103 grpc_response = {
104 "payload": response_payload,
105 "metadata": metadata,
106 "status": "OK",
107 }
108 _LOGGER.debug(
109 f"Received response to rpc {client_call_details.method}.",
110 extra={
111 "serviceName": "google.logging.v2.ConfigServiceV2",
112 "rpcName": str(client_call_details.method),
113 "response": grpc_response,
114 "metadata": grpc_response["metadata"],
115 },
116 )
117 return response
118
119
120class ConfigServiceV2GrpcAsyncIOTransport(ConfigServiceV2Transport):
121 """gRPC AsyncIO backend transport for ConfigServiceV2.
122
123 Service for configuring sinks used to route log entries.
124
125 This class defines the same methods as the primary client, so the
126 primary client can load the underlying transport implementation
127 and call it.
128
129 It sends protocol buffers over the wire using gRPC (which is built on
130 top of HTTP/2); the ``grpcio`` package must be installed.
131 """
132
133 _grpc_channel: aio.Channel
134 _stubs: Dict[str, Callable] = {}
135
136 @classmethod
137 def create_channel(
138 cls,
139 host: str = "logging.googleapis.com",
140 credentials: Optional[ga_credentials.Credentials] = None,
141 credentials_file: Optional[str] = None,
142 scopes: Optional[Sequence[str]] = None,
143 quota_project_id: Optional[str] = None,
144 **kwargs,
145 ) -> aio.Channel:
146 """Create and return a gRPC AsyncIO channel object.
147 Args:
148 host (Optional[str]): The host for the channel to use.
149 credentials (Optional[~.Credentials]): The
150 authorization credentials to attach to requests. These
151 credentials identify this application to the service. If
152 none are specified, the client will attempt to ascertain
153 the credentials from the environment.
154 credentials_file (Optional[str]): A file with credentials that can
155 be loaded with :func:`google.auth.load_credentials_from_file`.
156 scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
157 service. These are only used when credentials are not specified and
158 are passed to :func:`google.auth.default`.
159 quota_project_id (Optional[str]): An optional project to use for billing
160 and quota.
161 kwargs (Optional[dict]): Keyword arguments, which are passed to the
162 channel creation.
163 Returns:
164 aio.Channel: A gRPC AsyncIO channel object.
165 """
166
167 return grpc_helpers_async.create_channel(
168 host,
169 credentials=credentials,
170 credentials_file=credentials_file,
171 quota_project_id=quota_project_id,
172 default_scopes=cls.AUTH_SCOPES,
173 scopes=scopes,
174 default_host=cls.DEFAULT_HOST,
175 **kwargs,
176 )
177
178 def __init__(
179 self,
180 *,
181 host: str = "logging.googleapis.com",
182 credentials: Optional[ga_credentials.Credentials] = None,
183 credentials_file: Optional[str] = None,
184 scopes: Optional[Sequence[str]] = None,
185 channel: Optional[Union[aio.Channel, Callable[..., aio.Channel]]] = None,
186 api_mtls_endpoint: Optional[str] = None,
187 client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
188 ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
189 client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
190 quota_project_id: Optional[str] = None,
191 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
192 always_use_jwt_access: Optional[bool] = False,
193 api_audience: Optional[str] = None,
194 ) -> None:
195 """Instantiate the transport.
196
197 Args:
198 host (Optional[str]):
199 The hostname to connect to (default: 'logging.googleapis.com').
200 credentials (Optional[google.auth.credentials.Credentials]): The
201 authorization credentials to attach to requests. These
202 credentials identify the application to the service; if none
203 are specified, the client will attempt to ascertain the
204 credentials from the environment.
205 This argument is ignored if a ``channel`` instance is provided.
206 credentials_file (Optional[str]): A file with credentials that can
207 be loaded with :func:`google.auth.load_credentials_from_file`.
208 This argument is ignored if a ``channel`` instance is provided.
209 scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
210 service. These are only used when credentials are not specified and
211 are passed to :func:`google.auth.default`.
212 channel (Optional[Union[aio.Channel, Callable[..., aio.Channel]]]):
213 A ``Channel`` instance through which to make calls, or a Callable
214 that constructs and returns one. If set to None, ``self.create_channel``
215 is used to create the channel. If a Callable is given, it will be called
216 with the same arguments as used in ``self.create_channel``.
217 api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
218 If provided, it overrides the ``host`` argument and tries to create
219 a mutual TLS channel with client SSL credentials from
220 ``client_cert_source`` or application default SSL credentials.
221 client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
222 Deprecated. A callback to provide client SSL certificate bytes and
223 private key bytes, both in PEM format. It is ignored if
224 ``api_mtls_endpoint`` is None.
225 ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
226 for the grpc channel. It is ignored if a ``channel`` instance is provided.
227 client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
228 A callback to provide client certificate bytes and private key bytes,
229 both in PEM format. It is used to configure a mutual TLS channel. It is
230 ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
231 quota_project_id (Optional[str]): An optional project to use for billing
232 and quota.
233 client_info (google.api_core.gapic_v1.client_info.ClientInfo):
234 The client info used to send a user-agent string along with
235 API requests. If ``None``, then default info will be used.
236 Generally, you only need to set this if you're developing
237 your own client library.
238 always_use_jwt_access (Optional[bool]): Whether self signed JWT should
239 be used for service account credentials.
240
241 Raises:
242 google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
243 creation failed for any reason.
244 google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
245 and ``credentials_file`` are passed.
246 """
247 self._grpc_channel = None
248 self._ssl_channel_credentials = ssl_channel_credentials
249 self._stubs: Dict[str, Callable] = {}
250 self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None
251
252 if api_mtls_endpoint:
253 warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
254 if client_cert_source:
255 warnings.warn("client_cert_source is deprecated", DeprecationWarning)
256
257 if isinstance(channel, aio.Channel):
258 # Ignore credentials if a channel was passed.
259 credentials = None
260 self._ignore_credentials = True
261 # If a channel was explicitly provided, set it.
262 self._grpc_channel = channel
263 self._ssl_channel_credentials = None
264 else:
265 if api_mtls_endpoint:
266 host = api_mtls_endpoint
267
268 # Create SSL credentials with client_cert_source or application
269 # default SSL credentials.
270 if client_cert_source:
271 cert, key = client_cert_source()
272 self._ssl_channel_credentials = grpc.ssl_channel_credentials(
273 certificate_chain=cert, private_key=key
274 )
275 else:
276 self._ssl_channel_credentials = SslCredentials().ssl_credentials
277
278 else:
279 if client_cert_source_for_mtls and not ssl_channel_credentials:
280 cert, key = client_cert_source_for_mtls()
281 self._ssl_channel_credentials = grpc.ssl_channel_credentials(
282 certificate_chain=cert, private_key=key
283 )
284
285 # The base transport sets the host, credentials and scopes
286 super().__init__(
287 host=host,
288 credentials=credentials,
289 credentials_file=credentials_file,
290 scopes=scopes,
291 quota_project_id=quota_project_id,
292 client_info=client_info,
293 always_use_jwt_access=always_use_jwt_access,
294 api_audience=api_audience,
295 )
296
297 if not self._grpc_channel:
298 # initialize with the provided callable or the default channel
299 channel_init = channel or type(self).create_channel
300 self._grpc_channel = channel_init(
301 self._host,
302 # use the credentials which are saved
303 credentials=self._credentials,
304 # Set ``credentials_file`` to ``None`` here as
305 # the credentials that we saved earlier should be used.
306 credentials_file=None,
307 scopes=self._scopes,
308 ssl_credentials=self._ssl_channel_credentials,
309 quota_project_id=quota_project_id,
310 options=[
311 ("grpc.max_send_message_length", -1),
312 ("grpc.max_receive_message_length", -1),
313 ],
314 )
315
316 self._interceptor = _LoggingClientAIOInterceptor()
317 self._grpc_channel._unary_unary_interceptors.append(self._interceptor)
318 self._logged_channel = self._grpc_channel
319 self._wrap_with_kind = (
320 "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters
321 )
322 # Wrap messages. This must be done after self._logged_channel exists
323 self._prep_wrapped_messages(client_info)
324
325 @property
326 def grpc_channel(self) -> aio.Channel:
327 """Create the channel designed to connect to this service.
328
329 This property caches on the instance; repeated calls return
330 the same channel.
331 """
332 # Return the channel from cache.
333 return self._grpc_channel
334
335 @property
336 def operations_client(self) -> operations_v1.OperationsAsyncClient:
337 """Create the client designed to process long-running operations.
338
339 This property caches on the instance; repeated calls return the same
340 client.
341 """
342 # Quick check: Only create a new client if we do not already have one.
343 if self._operations_client is None:
344 self._operations_client = operations_v1.OperationsAsyncClient(
345 self._logged_channel
346 )
347
348 # Return the client from cache.
349 return self._operations_client
350
351 @property
352 def list_buckets(
353 self,
354 ) -> Callable[
355 [logging_config.ListBucketsRequest],
356 Awaitable[logging_config.ListBucketsResponse],
357 ]:
358 r"""Return a callable for the list buckets method over gRPC.
359
360 Lists log buckets.
361
362 Returns:
363 Callable[[~.ListBucketsRequest],
364 Awaitable[~.ListBucketsResponse]]:
365 A function that, when called, will call the underlying RPC
366 on the server.
367 """
368 # Generate a "stub function" on-the-fly which will actually make
369 # the request.
370 # gRPC handles serialization and deserialization, so we just need
371 # to pass in the functions for each.
372 if "list_buckets" not in self._stubs:
373 self._stubs["list_buckets"] = self._logged_channel.unary_unary(
374 "/google.logging.v2.ConfigServiceV2/ListBuckets",
375 request_serializer=logging_config.ListBucketsRequest.serialize,
376 response_deserializer=logging_config.ListBucketsResponse.deserialize,
377 )
378 return self._stubs["list_buckets"]
379
380 @property
381 def get_bucket(
382 self,
383 ) -> Callable[
384 [logging_config.GetBucketRequest], Awaitable[logging_config.LogBucket]
385 ]:
386 r"""Return a callable for the get bucket method over gRPC.
387
388 Gets a log bucket.
389
390 Returns:
391 Callable[[~.GetBucketRequest],
392 Awaitable[~.LogBucket]]:
393 A function that, when called, will call the underlying RPC
394 on the server.
395 """
396 # Generate a "stub function" on-the-fly which will actually make
397 # the request.
398 # gRPC handles serialization and deserialization, so we just need
399 # to pass in the functions for each.
400 if "get_bucket" not in self._stubs:
401 self._stubs["get_bucket"] = self._logged_channel.unary_unary(
402 "/google.logging.v2.ConfigServiceV2/GetBucket",
403 request_serializer=logging_config.GetBucketRequest.serialize,
404 response_deserializer=logging_config.LogBucket.deserialize,
405 )
406 return self._stubs["get_bucket"]
407
408 @property
409 def create_bucket_async(
410 self,
411 ) -> Callable[
412 [logging_config.CreateBucketRequest], Awaitable[operations_pb2.Operation]
413 ]:
414 r"""Return a callable for the create bucket async method over gRPC.
415
416 Creates a log bucket asynchronously that can be used
417 to store log entries.
418 After a bucket has been created, the bucket's location
419 cannot be changed.
420
421 Returns:
422 Callable[[~.CreateBucketRequest],
423 Awaitable[~.Operation]]:
424 A function that, when called, will call the underlying RPC
425 on the server.
426 """
427 # Generate a "stub function" on-the-fly which will actually make
428 # the request.
429 # gRPC handles serialization and deserialization, so we just need
430 # to pass in the functions for each.
431 if "create_bucket_async" not in self._stubs:
432 self._stubs["create_bucket_async"] = self._logged_channel.unary_unary(
433 "/google.logging.v2.ConfigServiceV2/CreateBucketAsync",
434 request_serializer=logging_config.CreateBucketRequest.serialize,
435 response_deserializer=operations_pb2.Operation.FromString,
436 )
437 return self._stubs["create_bucket_async"]
438
439 @property
440 def update_bucket_async(
441 self,
442 ) -> Callable[
443 [logging_config.UpdateBucketRequest], Awaitable[operations_pb2.Operation]
444 ]:
445 r"""Return a callable for the update bucket async method over gRPC.
446
447 Updates a log bucket asynchronously.
448
449 If the bucket has a ``lifecycle_state`` of ``DELETE_REQUESTED``,
450 then ``FAILED_PRECONDITION`` will be returned.
451
452 After a bucket has been created, the bucket's location cannot be
453 changed.
454
455 Returns:
456 Callable[[~.UpdateBucketRequest],
457 Awaitable[~.Operation]]:
458 A function that, when called, will call the underlying RPC
459 on the server.
460 """
461 # Generate a "stub function" on-the-fly which will actually make
462 # the request.
463 # gRPC handles serialization and deserialization, so we just need
464 # to pass in the functions for each.
465 if "update_bucket_async" not in self._stubs:
466 self._stubs["update_bucket_async"] = self._logged_channel.unary_unary(
467 "/google.logging.v2.ConfigServiceV2/UpdateBucketAsync",
468 request_serializer=logging_config.UpdateBucketRequest.serialize,
469 response_deserializer=operations_pb2.Operation.FromString,
470 )
471 return self._stubs["update_bucket_async"]
472
473 @property
474 def create_bucket(
475 self,
476 ) -> Callable[
477 [logging_config.CreateBucketRequest], Awaitable[logging_config.LogBucket]
478 ]:
479 r"""Return a callable for the create bucket method over gRPC.
480
481 Creates a log bucket that can be used to store log
482 entries. After a bucket has been created, the bucket's
483 location cannot be changed.
484
485 Returns:
486 Callable[[~.CreateBucketRequest],
487 Awaitable[~.LogBucket]]:
488 A function that, when called, will call the underlying RPC
489 on the server.
490 """
491 # Generate a "stub function" on-the-fly which will actually make
492 # the request.
493 # gRPC handles serialization and deserialization, so we just need
494 # to pass in the functions for each.
495 if "create_bucket" not in self._stubs:
496 self._stubs["create_bucket"] = self._logged_channel.unary_unary(
497 "/google.logging.v2.ConfigServiceV2/CreateBucket",
498 request_serializer=logging_config.CreateBucketRequest.serialize,
499 response_deserializer=logging_config.LogBucket.deserialize,
500 )
501 return self._stubs["create_bucket"]
502
503 @property
504 def update_bucket(
505 self,
506 ) -> Callable[
507 [logging_config.UpdateBucketRequest], Awaitable[logging_config.LogBucket]
508 ]:
509 r"""Return a callable for the update bucket method over gRPC.
510
511 Updates a log bucket.
512
513 If the bucket has a ``lifecycle_state`` of ``DELETE_REQUESTED``,
514 then ``FAILED_PRECONDITION`` will be returned.
515
516 After a bucket has been created, the bucket's location cannot be
517 changed.
518
519 Returns:
520 Callable[[~.UpdateBucketRequest],
521 Awaitable[~.LogBucket]]:
522 A function that, when called, will call the underlying RPC
523 on the server.
524 """
525 # Generate a "stub function" on-the-fly which will actually make
526 # the request.
527 # gRPC handles serialization and deserialization, so we just need
528 # to pass in the functions for each.
529 if "update_bucket" not in self._stubs:
530 self._stubs["update_bucket"] = self._logged_channel.unary_unary(
531 "/google.logging.v2.ConfigServiceV2/UpdateBucket",
532 request_serializer=logging_config.UpdateBucketRequest.serialize,
533 response_deserializer=logging_config.LogBucket.deserialize,
534 )
535 return self._stubs["update_bucket"]
536
537 @property
538 def delete_bucket(
539 self,
540 ) -> Callable[[logging_config.DeleteBucketRequest], Awaitable[empty_pb2.Empty]]:
541 r"""Return a callable for the delete bucket method over gRPC.
542
543 Deletes a log bucket.
544
545 Changes the bucket's ``lifecycle_state`` to the
546 ``DELETE_REQUESTED`` state. After 7 days, the bucket will be
547 purged and all log entries in the bucket will be permanently
548 deleted.
549
550 Returns:
551 Callable[[~.DeleteBucketRequest],
552 Awaitable[~.Empty]]:
553 A function that, when called, will call the underlying RPC
554 on the server.
555 """
556 # Generate a "stub function" on-the-fly which will actually make
557 # the request.
558 # gRPC handles serialization and deserialization, so we just need
559 # to pass in the functions for each.
560 if "delete_bucket" not in self._stubs:
561 self._stubs["delete_bucket"] = self._logged_channel.unary_unary(
562 "/google.logging.v2.ConfigServiceV2/DeleteBucket",
563 request_serializer=logging_config.DeleteBucketRequest.serialize,
564 response_deserializer=empty_pb2.Empty.FromString,
565 )
566 return self._stubs["delete_bucket"]
567
568 @property
569 def undelete_bucket(
570 self,
571 ) -> Callable[[logging_config.UndeleteBucketRequest], Awaitable[empty_pb2.Empty]]:
572 r"""Return a callable for the undelete bucket method over gRPC.
573
574 Undeletes a log bucket. A bucket that has been
575 deleted can be undeleted within the grace period of 7
576 days.
577
578 Returns:
579 Callable[[~.UndeleteBucketRequest],
580 Awaitable[~.Empty]]:
581 A function that, when called, will call the underlying RPC
582 on the server.
583 """
584 # Generate a "stub function" on-the-fly which will actually make
585 # the request.
586 # gRPC handles serialization and deserialization, so we just need
587 # to pass in the functions for each.
588 if "undelete_bucket" not in self._stubs:
589 self._stubs["undelete_bucket"] = self._logged_channel.unary_unary(
590 "/google.logging.v2.ConfigServiceV2/UndeleteBucket",
591 request_serializer=logging_config.UndeleteBucketRequest.serialize,
592 response_deserializer=empty_pb2.Empty.FromString,
593 )
594 return self._stubs["undelete_bucket"]
595
596 @property
597 def list_views(
598 self,
599 ) -> Callable[
600 [logging_config.ListViewsRequest], Awaitable[logging_config.ListViewsResponse]
601 ]:
602 r"""Return a callable for the list views method over gRPC.
603
604 Lists views on a log bucket.
605
606 Returns:
607 Callable[[~.ListViewsRequest],
608 Awaitable[~.ListViewsResponse]]:
609 A function that, when called, will call the underlying RPC
610 on the server.
611 """
612 # Generate a "stub function" on-the-fly which will actually make
613 # the request.
614 # gRPC handles serialization and deserialization, so we just need
615 # to pass in the functions for each.
616 if "list_views" not in self._stubs:
617 self._stubs["list_views"] = self._logged_channel.unary_unary(
618 "/google.logging.v2.ConfigServiceV2/ListViews",
619 request_serializer=logging_config.ListViewsRequest.serialize,
620 response_deserializer=logging_config.ListViewsResponse.deserialize,
621 )
622 return self._stubs["list_views"]
623
624 @property
625 def get_view(
626 self,
627 ) -> Callable[[logging_config.GetViewRequest], Awaitable[logging_config.LogView]]:
628 r"""Return a callable for the get view method over gRPC.
629
630 Gets a view on a log bucket..
631
632 Returns:
633 Callable[[~.GetViewRequest],
634 Awaitable[~.LogView]]:
635 A function that, when called, will call the underlying RPC
636 on the server.
637 """
638 # Generate a "stub function" on-the-fly which will actually make
639 # the request.
640 # gRPC handles serialization and deserialization, so we just need
641 # to pass in the functions for each.
642 if "get_view" not in self._stubs:
643 self._stubs["get_view"] = self._logged_channel.unary_unary(
644 "/google.logging.v2.ConfigServiceV2/GetView",
645 request_serializer=logging_config.GetViewRequest.serialize,
646 response_deserializer=logging_config.LogView.deserialize,
647 )
648 return self._stubs["get_view"]
649
650 @property
651 def create_view(
652 self,
653 ) -> Callable[
654 [logging_config.CreateViewRequest], Awaitable[logging_config.LogView]
655 ]:
656 r"""Return a callable for the create view method over gRPC.
657
658 Creates a view over log entries in a log bucket. A
659 bucket may contain a maximum of 30 views.
660
661 Returns:
662 Callable[[~.CreateViewRequest],
663 Awaitable[~.LogView]]:
664 A function that, when called, will call the underlying RPC
665 on the server.
666 """
667 # Generate a "stub function" on-the-fly which will actually make
668 # the request.
669 # gRPC handles serialization and deserialization, so we just need
670 # to pass in the functions for each.
671 if "create_view" not in self._stubs:
672 self._stubs["create_view"] = self._logged_channel.unary_unary(
673 "/google.logging.v2.ConfigServiceV2/CreateView",
674 request_serializer=logging_config.CreateViewRequest.serialize,
675 response_deserializer=logging_config.LogView.deserialize,
676 )
677 return self._stubs["create_view"]
678
679 @property
680 def update_view(
681 self,
682 ) -> Callable[
683 [logging_config.UpdateViewRequest], Awaitable[logging_config.LogView]
684 ]:
685 r"""Return a callable for the update view method over gRPC.
686
687 Updates a view on a log bucket. This method replaces the
688 following fields in the existing view with values from the new
689 view: ``filter``. If an ``UNAVAILABLE`` error is returned, this
690 indicates that system is not in a state where it can update the
691 view. If this occurs, please try again in a few minutes.
692
693 Returns:
694 Callable[[~.UpdateViewRequest],
695 Awaitable[~.LogView]]:
696 A function that, when called, will call the underlying RPC
697 on the server.
698 """
699 # Generate a "stub function" on-the-fly which will actually make
700 # the request.
701 # gRPC handles serialization and deserialization, so we just need
702 # to pass in the functions for each.
703 if "update_view" not in self._stubs:
704 self._stubs["update_view"] = self._logged_channel.unary_unary(
705 "/google.logging.v2.ConfigServiceV2/UpdateView",
706 request_serializer=logging_config.UpdateViewRequest.serialize,
707 response_deserializer=logging_config.LogView.deserialize,
708 )
709 return self._stubs["update_view"]
710
711 @property
712 def delete_view(
713 self,
714 ) -> Callable[[logging_config.DeleteViewRequest], Awaitable[empty_pb2.Empty]]:
715 r"""Return a callable for the delete view method over gRPC.
716
717 Deletes a view on a log bucket. If an ``UNAVAILABLE`` error is
718 returned, this indicates that system is not in a state where it
719 can delete the view. If this occurs, please try again in a few
720 minutes.
721
722 Returns:
723 Callable[[~.DeleteViewRequest],
724 Awaitable[~.Empty]]:
725 A function that, when called, will call the underlying RPC
726 on the server.
727 """
728 # Generate a "stub function" on-the-fly which will actually make
729 # the request.
730 # gRPC handles serialization and deserialization, so we just need
731 # to pass in the functions for each.
732 if "delete_view" not in self._stubs:
733 self._stubs["delete_view"] = self._logged_channel.unary_unary(
734 "/google.logging.v2.ConfigServiceV2/DeleteView",
735 request_serializer=logging_config.DeleteViewRequest.serialize,
736 response_deserializer=empty_pb2.Empty.FromString,
737 )
738 return self._stubs["delete_view"]
739
740 @property
741 def list_sinks(
742 self,
743 ) -> Callable[
744 [logging_config.ListSinksRequest], Awaitable[logging_config.ListSinksResponse]
745 ]:
746 r"""Return a callable for the list sinks method over gRPC.
747
748 Lists sinks.
749
750 Returns:
751 Callable[[~.ListSinksRequest],
752 Awaitable[~.ListSinksResponse]]:
753 A function that, when called, will call the underlying RPC
754 on the server.
755 """
756 # Generate a "stub function" on-the-fly which will actually make
757 # the request.
758 # gRPC handles serialization and deserialization, so we just need
759 # to pass in the functions for each.
760 if "list_sinks" not in self._stubs:
761 self._stubs["list_sinks"] = self._logged_channel.unary_unary(
762 "/google.logging.v2.ConfigServiceV2/ListSinks",
763 request_serializer=logging_config.ListSinksRequest.serialize,
764 response_deserializer=logging_config.ListSinksResponse.deserialize,
765 )
766 return self._stubs["list_sinks"]
767
768 @property
769 def get_sink(
770 self,
771 ) -> Callable[[logging_config.GetSinkRequest], Awaitable[logging_config.LogSink]]:
772 r"""Return a callable for the get sink method over gRPC.
773
774 Gets a sink.
775
776 Returns:
777 Callable[[~.GetSinkRequest],
778 Awaitable[~.LogSink]]:
779 A function that, when called, will call the underlying RPC
780 on the server.
781 """
782 # Generate a "stub function" on-the-fly which will actually make
783 # the request.
784 # gRPC handles serialization and deserialization, so we just need
785 # to pass in the functions for each.
786 if "get_sink" not in self._stubs:
787 self._stubs["get_sink"] = self._logged_channel.unary_unary(
788 "/google.logging.v2.ConfigServiceV2/GetSink",
789 request_serializer=logging_config.GetSinkRequest.serialize,
790 response_deserializer=logging_config.LogSink.deserialize,
791 )
792 return self._stubs["get_sink"]
793
794 @property
795 def create_sink(
796 self,
797 ) -> Callable[
798 [logging_config.CreateSinkRequest], Awaitable[logging_config.LogSink]
799 ]:
800 r"""Return a callable for the create sink method over gRPC.
801
802 Creates a sink that exports specified log entries to a
803 destination. The export of newly-ingested log entries begins
804 immediately, unless the sink's ``writer_identity`` is not
805 permitted to write to the destination. A sink can export log
806 entries only from the resource owning the sink.
807
808 Returns:
809 Callable[[~.CreateSinkRequest],
810 Awaitable[~.LogSink]]:
811 A function that, when called, will call the underlying RPC
812 on the server.
813 """
814 # Generate a "stub function" on-the-fly which will actually make
815 # the request.
816 # gRPC handles serialization and deserialization, so we just need
817 # to pass in the functions for each.
818 if "create_sink" not in self._stubs:
819 self._stubs["create_sink"] = self._logged_channel.unary_unary(
820 "/google.logging.v2.ConfigServiceV2/CreateSink",
821 request_serializer=logging_config.CreateSinkRequest.serialize,
822 response_deserializer=logging_config.LogSink.deserialize,
823 )
824 return self._stubs["create_sink"]
825
826 @property
827 def update_sink(
828 self,
829 ) -> Callable[
830 [logging_config.UpdateSinkRequest], Awaitable[logging_config.LogSink]
831 ]:
832 r"""Return a callable for the update sink method over gRPC.
833
834 Updates a sink. This method replaces the following fields in the
835 existing sink with values from the new sink: ``destination``,
836 and ``filter``.
837
838 The updated sink might also have a new ``writer_identity``; see
839 the ``unique_writer_identity`` field.
840
841 Returns:
842 Callable[[~.UpdateSinkRequest],
843 Awaitable[~.LogSink]]:
844 A function that, when called, will call the underlying RPC
845 on the server.
846 """
847 # Generate a "stub function" on-the-fly which will actually make
848 # the request.
849 # gRPC handles serialization and deserialization, so we just need
850 # to pass in the functions for each.
851 if "update_sink" not in self._stubs:
852 self._stubs["update_sink"] = self._logged_channel.unary_unary(
853 "/google.logging.v2.ConfigServiceV2/UpdateSink",
854 request_serializer=logging_config.UpdateSinkRequest.serialize,
855 response_deserializer=logging_config.LogSink.deserialize,
856 )
857 return self._stubs["update_sink"]
858
859 @property
860 def delete_sink(
861 self,
862 ) -> Callable[[logging_config.DeleteSinkRequest], Awaitable[empty_pb2.Empty]]:
863 r"""Return a callable for the delete sink method over gRPC.
864
865 Deletes a sink. If the sink has a unique ``writer_identity``,
866 then that service account is also deleted.
867
868 Returns:
869 Callable[[~.DeleteSinkRequest],
870 Awaitable[~.Empty]]:
871 A function that, when called, will call the underlying RPC
872 on the server.
873 """
874 # Generate a "stub function" on-the-fly which will actually make
875 # the request.
876 # gRPC handles serialization and deserialization, so we just need
877 # to pass in the functions for each.
878 if "delete_sink" not in self._stubs:
879 self._stubs["delete_sink"] = self._logged_channel.unary_unary(
880 "/google.logging.v2.ConfigServiceV2/DeleteSink",
881 request_serializer=logging_config.DeleteSinkRequest.serialize,
882 response_deserializer=empty_pb2.Empty.FromString,
883 )
884 return self._stubs["delete_sink"]
885
886 @property
887 def create_link(
888 self,
889 ) -> Callable[
890 [logging_config.CreateLinkRequest], Awaitable[operations_pb2.Operation]
891 ]:
892 r"""Return a callable for the create link method over gRPC.
893
894 Asynchronously creates a linked dataset in BigQuery
895 which makes it possible to use BigQuery to read the logs
896 stored in the log bucket. A log bucket may currently
897 only contain one link.
898
899 Returns:
900 Callable[[~.CreateLinkRequest],
901 Awaitable[~.Operation]]:
902 A function that, when called, will call the underlying RPC
903 on the server.
904 """
905 # Generate a "stub function" on-the-fly which will actually make
906 # the request.
907 # gRPC handles serialization and deserialization, so we just need
908 # to pass in the functions for each.
909 if "create_link" not in self._stubs:
910 self._stubs["create_link"] = self._logged_channel.unary_unary(
911 "/google.logging.v2.ConfigServiceV2/CreateLink",
912 request_serializer=logging_config.CreateLinkRequest.serialize,
913 response_deserializer=operations_pb2.Operation.FromString,
914 )
915 return self._stubs["create_link"]
916
917 @property
918 def delete_link(
919 self,
920 ) -> Callable[
921 [logging_config.DeleteLinkRequest], Awaitable[operations_pb2.Operation]
922 ]:
923 r"""Return a callable for the delete link method over gRPC.
924
925 Deletes a link. This will also delete the
926 corresponding BigQuery linked dataset.
927
928 Returns:
929 Callable[[~.DeleteLinkRequest],
930 Awaitable[~.Operation]]:
931 A function that, when called, will call the underlying RPC
932 on the server.
933 """
934 # Generate a "stub function" on-the-fly which will actually make
935 # the request.
936 # gRPC handles serialization and deserialization, so we just need
937 # to pass in the functions for each.
938 if "delete_link" not in self._stubs:
939 self._stubs["delete_link"] = self._logged_channel.unary_unary(
940 "/google.logging.v2.ConfigServiceV2/DeleteLink",
941 request_serializer=logging_config.DeleteLinkRequest.serialize,
942 response_deserializer=operations_pb2.Operation.FromString,
943 )
944 return self._stubs["delete_link"]
945
946 @property
947 def list_links(
948 self,
949 ) -> Callable[
950 [logging_config.ListLinksRequest], Awaitable[logging_config.ListLinksResponse]
951 ]:
952 r"""Return a callable for the list links method over gRPC.
953
954 Lists links.
955
956 Returns:
957 Callable[[~.ListLinksRequest],
958 Awaitable[~.ListLinksResponse]]:
959 A function that, when called, will call the underlying RPC
960 on the server.
961 """
962 # Generate a "stub function" on-the-fly which will actually make
963 # the request.
964 # gRPC handles serialization and deserialization, so we just need
965 # to pass in the functions for each.
966 if "list_links" not in self._stubs:
967 self._stubs["list_links"] = self._logged_channel.unary_unary(
968 "/google.logging.v2.ConfigServiceV2/ListLinks",
969 request_serializer=logging_config.ListLinksRequest.serialize,
970 response_deserializer=logging_config.ListLinksResponse.deserialize,
971 )
972 return self._stubs["list_links"]
973
974 @property
975 def get_link(
976 self,
977 ) -> Callable[[logging_config.GetLinkRequest], Awaitable[logging_config.Link]]:
978 r"""Return a callable for the get link method over gRPC.
979
980 Gets a link.
981
982 Returns:
983 Callable[[~.GetLinkRequest],
984 Awaitable[~.Link]]:
985 A function that, when called, will call the underlying RPC
986 on the server.
987 """
988 # Generate a "stub function" on-the-fly which will actually make
989 # the request.
990 # gRPC handles serialization and deserialization, so we just need
991 # to pass in the functions for each.
992 if "get_link" not in self._stubs:
993 self._stubs["get_link"] = self._logged_channel.unary_unary(
994 "/google.logging.v2.ConfigServiceV2/GetLink",
995 request_serializer=logging_config.GetLinkRequest.serialize,
996 response_deserializer=logging_config.Link.deserialize,
997 )
998 return self._stubs["get_link"]
999
1000 @property
1001 def list_exclusions(
1002 self,
1003 ) -> Callable[
1004 [logging_config.ListExclusionsRequest],
1005 Awaitable[logging_config.ListExclusionsResponse],
1006 ]:
1007 r"""Return a callable for the list exclusions method over gRPC.
1008
1009 Lists all the exclusions on the \_Default sink in a parent
1010 resource.
1011
1012 Returns:
1013 Callable[[~.ListExclusionsRequest],
1014 Awaitable[~.ListExclusionsResponse]]:
1015 A function that, when called, will call the underlying RPC
1016 on the server.
1017 """
1018 # Generate a "stub function" on-the-fly which will actually make
1019 # the request.
1020 # gRPC handles serialization and deserialization, so we just need
1021 # to pass in the functions for each.
1022 if "list_exclusions" not in self._stubs:
1023 self._stubs["list_exclusions"] = self._logged_channel.unary_unary(
1024 "/google.logging.v2.ConfigServiceV2/ListExclusions",
1025 request_serializer=logging_config.ListExclusionsRequest.serialize,
1026 response_deserializer=logging_config.ListExclusionsResponse.deserialize,
1027 )
1028 return self._stubs["list_exclusions"]
1029
1030 @property
1031 def get_exclusion(
1032 self,
1033 ) -> Callable[
1034 [logging_config.GetExclusionRequest], Awaitable[logging_config.LogExclusion]
1035 ]:
1036 r"""Return a callable for the get exclusion method over gRPC.
1037
1038 Gets the description of an exclusion in the \_Default sink.
1039
1040 Returns:
1041 Callable[[~.GetExclusionRequest],
1042 Awaitable[~.LogExclusion]]:
1043 A function that, when called, will call the underlying RPC
1044 on the server.
1045 """
1046 # Generate a "stub function" on-the-fly which will actually make
1047 # the request.
1048 # gRPC handles serialization and deserialization, so we just need
1049 # to pass in the functions for each.
1050 if "get_exclusion" not in self._stubs:
1051 self._stubs["get_exclusion"] = self._logged_channel.unary_unary(
1052 "/google.logging.v2.ConfigServiceV2/GetExclusion",
1053 request_serializer=logging_config.GetExclusionRequest.serialize,
1054 response_deserializer=logging_config.LogExclusion.deserialize,
1055 )
1056 return self._stubs["get_exclusion"]
1057
1058 @property
1059 def create_exclusion(
1060 self,
1061 ) -> Callable[
1062 [logging_config.CreateExclusionRequest], Awaitable[logging_config.LogExclusion]
1063 ]:
1064 r"""Return a callable for the create exclusion method over gRPC.
1065
1066 Creates a new exclusion in the \_Default sink in a specified
1067 parent resource. Only log entries belonging to that resource can
1068 be excluded. You can have up to 10 exclusions in a resource.
1069
1070 Returns:
1071 Callable[[~.CreateExclusionRequest],
1072 Awaitable[~.LogExclusion]]:
1073 A function that, when called, will call the underlying RPC
1074 on the server.
1075 """
1076 # Generate a "stub function" on-the-fly which will actually make
1077 # the request.
1078 # gRPC handles serialization and deserialization, so we just need
1079 # to pass in the functions for each.
1080 if "create_exclusion" not in self._stubs:
1081 self._stubs["create_exclusion"] = self._logged_channel.unary_unary(
1082 "/google.logging.v2.ConfigServiceV2/CreateExclusion",
1083 request_serializer=logging_config.CreateExclusionRequest.serialize,
1084 response_deserializer=logging_config.LogExclusion.deserialize,
1085 )
1086 return self._stubs["create_exclusion"]
1087
1088 @property
1089 def update_exclusion(
1090 self,
1091 ) -> Callable[
1092 [logging_config.UpdateExclusionRequest], Awaitable[logging_config.LogExclusion]
1093 ]:
1094 r"""Return a callable for the update exclusion method over gRPC.
1095
1096 Changes one or more properties of an existing exclusion in the
1097 \_Default sink.
1098
1099 Returns:
1100 Callable[[~.UpdateExclusionRequest],
1101 Awaitable[~.LogExclusion]]:
1102 A function that, when called, will call the underlying RPC
1103 on the server.
1104 """
1105 # Generate a "stub function" on-the-fly which will actually make
1106 # the request.
1107 # gRPC handles serialization and deserialization, so we just need
1108 # to pass in the functions for each.
1109 if "update_exclusion" not in self._stubs:
1110 self._stubs["update_exclusion"] = self._logged_channel.unary_unary(
1111 "/google.logging.v2.ConfigServiceV2/UpdateExclusion",
1112 request_serializer=logging_config.UpdateExclusionRequest.serialize,
1113 response_deserializer=logging_config.LogExclusion.deserialize,
1114 )
1115 return self._stubs["update_exclusion"]
1116
1117 @property
1118 def delete_exclusion(
1119 self,
1120 ) -> Callable[[logging_config.DeleteExclusionRequest], Awaitable[empty_pb2.Empty]]:
1121 r"""Return a callable for the delete exclusion method over gRPC.
1122
1123 Deletes an exclusion in the \_Default sink.
1124
1125 Returns:
1126 Callable[[~.DeleteExclusionRequest],
1127 Awaitable[~.Empty]]:
1128 A function that, when called, will call the underlying RPC
1129 on the server.
1130 """
1131 # Generate a "stub function" on-the-fly which will actually make
1132 # the request.
1133 # gRPC handles serialization and deserialization, so we just need
1134 # to pass in the functions for each.
1135 if "delete_exclusion" not in self._stubs:
1136 self._stubs["delete_exclusion"] = self._logged_channel.unary_unary(
1137 "/google.logging.v2.ConfigServiceV2/DeleteExclusion",
1138 request_serializer=logging_config.DeleteExclusionRequest.serialize,
1139 response_deserializer=empty_pb2.Empty.FromString,
1140 )
1141 return self._stubs["delete_exclusion"]
1142
1143 @property
1144 def get_cmek_settings(
1145 self,
1146 ) -> Callable[
1147 [logging_config.GetCmekSettingsRequest], Awaitable[logging_config.CmekSettings]
1148 ]:
1149 r"""Return a callable for the get cmek settings method over gRPC.
1150
1151 Gets the Logging CMEK settings for the given resource.
1152
1153 Note: CMEK for the Log Router can be configured for Google Cloud
1154 projects, folders, organizations and billing accounts. Once
1155 configured for an organization, it applies to all projects and
1156 folders in the Google Cloud organization.
1157
1158 See `Enabling CMEK for Log
1159 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
1160 for more information.
1161
1162 Returns:
1163 Callable[[~.GetCmekSettingsRequest],
1164 Awaitable[~.CmekSettings]]:
1165 A function that, when called, will call the underlying RPC
1166 on the server.
1167 """
1168 # Generate a "stub function" on-the-fly which will actually make
1169 # the request.
1170 # gRPC handles serialization and deserialization, so we just need
1171 # to pass in the functions for each.
1172 if "get_cmek_settings" not in self._stubs:
1173 self._stubs["get_cmek_settings"] = self._logged_channel.unary_unary(
1174 "/google.logging.v2.ConfigServiceV2/GetCmekSettings",
1175 request_serializer=logging_config.GetCmekSettingsRequest.serialize,
1176 response_deserializer=logging_config.CmekSettings.deserialize,
1177 )
1178 return self._stubs["get_cmek_settings"]
1179
1180 @property
1181 def update_cmek_settings(
1182 self,
1183 ) -> Callable[
1184 [logging_config.UpdateCmekSettingsRequest],
1185 Awaitable[logging_config.CmekSettings],
1186 ]:
1187 r"""Return a callable for the update cmek settings method over gRPC.
1188
1189 Updates the Log Router CMEK settings for the given resource.
1190
1191 Note: CMEK for the Log Router can currently only be configured
1192 for Google Cloud organizations. Once configured, it applies to
1193 all projects and folders in the Google Cloud organization.
1194
1195 [UpdateCmekSettings][google.logging.v2.ConfigServiceV2.UpdateCmekSettings]
1196 will fail if 1) ``kms_key_name`` is invalid, or 2) the
1197 associated service account does not have the required
1198 ``roles/cloudkms.cryptoKeyEncrypterDecrypter`` role assigned for
1199 the key, or 3) access to the key is disabled.
1200
1201 See `Enabling CMEK for Log
1202 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
1203 for more information.
1204
1205 Returns:
1206 Callable[[~.UpdateCmekSettingsRequest],
1207 Awaitable[~.CmekSettings]]:
1208 A function that, when called, will call the underlying RPC
1209 on the server.
1210 """
1211 # Generate a "stub function" on-the-fly which will actually make
1212 # the request.
1213 # gRPC handles serialization and deserialization, so we just need
1214 # to pass in the functions for each.
1215 if "update_cmek_settings" not in self._stubs:
1216 self._stubs["update_cmek_settings"] = self._logged_channel.unary_unary(
1217 "/google.logging.v2.ConfigServiceV2/UpdateCmekSettings",
1218 request_serializer=logging_config.UpdateCmekSettingsRequest.serialize,
1219 response_deserializer=logging_config.CmekSettings.deserialize,
1220 )
1221 return self._stubs["update_cmek_settings"]
1222
1223 @property
1224 def get_settings(
1225 self,
1226 ) -> Callable[
1227 [logging_config.GetSettingsRequest], Awaitable[logging_config.Settings]
1228 ]:
1229 r"""Return a callable for the get settings method over gRPC.
1230
1231 Gets the Log Router settings for the given resource.
1232
1233 Note: Settings for the Log Router can be get for Google Cloud
1234 projects, folders, organizations and billing accounts. Currently
1235 it can only be configured for organizations. Once configured for
1236 an organization, it applies to all projects and folders in the
1237 Google Cloud organization.
1238
1239 See `Enabling CMEK for Log
1240 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
1241 for more information.
1242
1243 Returns:
1244 Callable[[~.GetSettingsRequest],
1245 Awaitable[~.Settings]]:
1246 A function that, when called, will call the underlying RPC
1247 on the server.
1248 """
1249 # Generate a "stub function" on-the-fly which will actually make
1250 # the request.
1251 # gRPC handles serialization and deserialization, so we just need
1252 # to pass in the functions for each.
1253 if "get_settings" not in self._stubs:
1254 self._stubs["get_settings"] = self._logged_channel.unary_unary(
1255 "/google.logging.v2.ConfigServiceV2/GetSettings",
1256 request_serializer=logging_config.GetSettingsRequest.serialize,
1257 response_deserializer=logging_config.Settings.deserialize,
1258 )
1259 return self._stubs["get_settings"]
1260
1261 @property
1262 def update_settings(
1263 self,
1264 ) -> Callable[
1265 [logging_config.UpdateSettingsRequest], Awaitable[logging_config.Settings]
1266 ]:
1267 r"""Return a callable for the update settings method over gRPC.
1268
1269 Updates the Log Router settings for the given resource.
1270
1271 Note: Settings for the Log Router can currently only be
1272 configured for Google Cloud organizations. Once configured, it
1273 applies to all projects and folders in the Google Cloud
1274 organization.
1275
1276 [UpdateSettings][google.logging.v2.ConfigServiceV2.UpdateSettings]
1277 will fail if 1) ``kms_key_name`` is invalid, or 2) the
1278 associated service account does not have the required
1279 ``roles/cloudkms.cryptoKeyEncrypterDecrypter`` role assigned for
1280 the key, or 3) access to the key is disabled. 4) ``location_id``
1281 is not supported by Logging. 5) ``location_id`` violate
1282 OrgPolicy.
1283
1284 See `Enabling CMEK for Log
1285 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
1286 for more information.
1287
1288 Returns:
1289 Callable[[~.UpdateSettingsRequest],
1290 Awaitable[~.Settings]]:
1291 A function that, when called, will call the underlying RPC
1292 on the server.
1293 """
1294 # Generate a "stub function" on-the-fly which will actually make
1295 # the request.
1296 # gRPC handles serialization and deserialization, so we just need
1297 # to pass in the functions for each.
1298 if "update_settings" not in self._stubs:
1299 self._stubs["update_settings"] = self._logged_channel.unary_unary(
1300 "/google.logging.v2.ConfigServiceV2/UpdateSettings",
1301 request_serializer=logging_config.UpdateSettingsRequest.serialize,
1302 response_deserializer=logging_config.Settings.deserialize,
1303 )
1304 return self._stubs["update_settings"]
1305
1306 @property
1307 def copy_log_entries(
1308 self,
1309 ) -> Callable[
1310 [logging_config.CopyLogEntriesRequest], Awaitable[operations_pb2.Operation]
1311 ]:
1312 r"""Return a callable for the copy log entries method over gRPC.
1313
1314 Copies a set of log entries from a log bucket to a
1315 Cloud Storage bucket.
1316
1317 Returns:
1318 Callable[[~.CopyLogEntriesRequest],
1319 Awaitable[~.Operation]]:
1320 A function that, when called, will call the underlying RPC
1321 on the server.
1322 """
1323 # Generate a "stub function" on-the-fly which will actually make
1324 # the request.
1325 # gRPC handles serialization and deserialization, so we just need
1326 # to pass in the functions for each.
1327 if "copy_log_entries" not in self._stubs:
1328 self._stubs["copy_log_entries"] = self._logged_channel.unary_unary(
1329 "/google.logging.v2.ConfigServiceV2/CopyLogEntries",
1330 request_serializer=logging_config.CopyLogEntriesRequest.serialize,
1331 response_deserializer=operations_pb2.Operation.FromString,
1332 )
1333 return self._stubs["copy_log_entries"]
1334
1335 def _prep_wrapped_messages(self, client_info):
1336 """Precompute the wrapped methods, overriding the base class method to use async wrappers."""
1337 self._wrapped_methods = {
1338 self.list_buckets: self._wrap_method(
1339 self.list_buckets,
1340 default_timeout=None,
1341 client_info=client_info,
1342 ),
1343 self.get_bucket: self._wrap_method(
1344 self.get_bucket,
1345 default_timeout=None,
1346 client_info=client_info,
1347 ),
1348 self.create_bucket_async: self._wrap_method(
1349 self.create_bucket_async,
1350 default_timeout=None,
1351 client_info=client_info,
1352 ),
1353 self.update_bucket_async: self._wrap_method(
1354 self.update_bucket_async,
1355 default_timeout=None,
1356 client_info=client_info,
1357 ),
1358 self.create_bucket: self._wrap_method(
1359 self.create_bucket,
1360 default_timeout=None,
1361 client_info=client_info,
1362 ),
1363 self.update_bucket: self._wrap_method(
1364 self.update_bucket,
1365 default_timeout=None,
1366 client_info=client_info,
1367 ),
1368 self.delete_bucket: self._wrap_method(
1369 self.delete_bucket,
1370 default_timeout=None,
1371 client_info=client_info,
1372 ),
1373 self.undelete_bucket: self._wrap_method(
1374 self.undelete_bucket,
1375 default_timeout=None,
1376 client_info=client_info,
1377 ),
1378 self.list_views: self._wrap_method(
1379 self.list_views,
1380 default_timeout=None,
1381 client_info=client_info,
1382 ),
1383 self.get_view: self._wrap_method(
1384 self.get_view,
1385 default_timeout=None,
1386 client_info=client_info,
1387 ),
1388 self.create_view: self._wrap_method(
1389 self.create_view,
1390 default_timeout=None,
1391 client_info=client_info,
1392 ),
1393 self.update_view: self._wrap_method(
1394 self.update_view,
1395 default_timeout=None,
1396 client_info=client_info,
1397 ),
1398 self.delete_view: self._wrap_method(
1399 self.delete_view,
1400 default_timeout=None,
1401 client_info=client_info,
1402 ),
1403 self.list_sinks: self._wrap_method(
1404 self.list_sinks,
1405 default_retry=retries.AsyncRetry(
1406 initial=0.1,
1407 maximum=60.0,
1408 multiplier=1.3,
1409 predicate=retries.if_exception_type(
1410 core_exceptions.DeadlineExceeded,
1411 core_exceptions.InternalServerError,
1412 core_exceptions.ServiceUnavailable,
1413 ),
1414 deadline=60.0,
1415 ),
1416 default_timeout=60.0,
1417 client_info=client_info,
1418 ),
1419 self.get_sink: self._wrap_method(
1420 self.get_sink,
1421 default_retry=retries.AsyncRetry(
1422 initial=0.1,
1423 maximum=60.0,
1424 multiplier=1.3,
1425 predicate=retries.if_exception_type(
1426 core_exceptions.DeadlineExceeded,
1427 core_exceptions.InternalServerError,
1428 core_exceptions.ServiceUnavailable,
1429 ),
1430 deadline=60.0,
1431 ),
1432 default_timeout=60.0,
1433 client_info=client_info,
1434 ),
1435 self.create_sink: self._wrap_method(
1436 self.create_sink,
1437 default_timeout=120.0,
1438 client_info=client_info,
1439 ),
1440 self.update_sink: self._wrap_method(
1441 self.update_sink,
1442 default_retry=retries.AsyncRetry(
1443 initial=0.1,
1444 maximum=60.0,
1445 multiplier=1.3,
1446 predicate=retries.if_exception_type(
1447 core_exceptions.DeadlineExceeded,
1448 core_exceptions.InternalServerError,
1449 core_exceptions.ServiceUnavailable,
1450 ),
1451 deadline=60.0,
1452 ),
1453 default_timeout=60.0,
1454 client_info=client_info,
1455 ),
1456 self.delete_sink: self._wrap_method(
1457 self.delete_sink,
1458 default_retry=retries.AsyncRetry(
1459 initial=0.1,
1460 maximum=60.0,
1461 multiplier=1.3,
1462 predicate=retries.if_exception_type(
1463 core_exceptions.DeadlineExceeded,
1464 core_exceptions.InternalServerError,
1465 core_exceptions.ServiceUnavailable,
1466 ),
1467 deadline=60.0,
1468 ),
1469 default_timeout=60.0,
1470 client_info=client_info,
1471 ),
1472 self.create_link: self._wrap_method(
1473 self.create_link,
1474 default_timeout=None,
1475 client_info=client_info,
1476 ),
1477 self.delete_link: self._wrap_method(
1478 self.delete_link,
1479 default_timeout=None,
1480 client_info=client_info,
1481 ),
1482 self.list_links: self._wrap_method(
1483 self.list_links,
1484 default_timeout=None,
1485 client_info=client_info,
1486 ),
1487 self.get_link: self._wrap_method(
1488 self.get_link,
1489 default_timeout=None,
1490 client_info=client_info,
1491 ),
1492 self.list_exclusions: self._wrap_method(
1493 self.list_exclusions,
1494 default_retry=retries.AsyncRetry(
1495 initial=0.1,
1496 maximum=60.0,
1497 multiplier=1.3,
1498 predicate=retries.if_exception_type(
1499 core_exceptions.DeadlineExceeded,
1500 core_exceptions.InternalServerError,
1501 core_exceptions.ServiceUnavailable,
1502 ),
1503 deadline=60.0,
1504 ),
1505 default_timeout=60.0,
1506 client_info=client_info,
1507 ),
1508 self.get_exclusion: self._wrap_method(
1509 self.get_exclusion,
1510 default_retry=retries.AsyncRetry(
1511 initial=0.1,
1512 maximum=60.0,
1513 multiplier=1.3,
1514 predicate=retries.if_exception_type(
1515 core_exceptions.DeadlineExceeded,
1516 core_exceptions.InternalServerError,
1517 core_exceptions.ServiceUnavailable,
1518 ),
1519 deadline=60.0,
1520 ),
1521 default_timeout=60.0,
1522 client_info=client_info,
1523 ),
1524 self.create_exclusion: self._wrap_method(
1525 self.create_exclusion,
1526 default_timeout=120.0,
1527 client_info=client_info,
1528 ),
1529 self.update_exclusion: self._wrap_method(
1530 self.update_exclusion,
1531 default_timeout=120.0,
1532 client_info=client_info,
1533 ),
1534 self.delete_exclusion: self._wrap_method(
1535 self.delete_exclusion,
1536 default_retry=retries.AsyncRetry(
1537 initial=0.1,
1538 maximum=60.0,
1539 multiplier=1.3,
1540 predicate=retries.if_exception_type(
1541 core_exceptions.DeadlineExceeded,
1542 core_exceptions.InternalServerError,
1543 core_exceptions.ServiceUnavailable,
1544 ),
1545 deadline=60.0,
1546 ),
1547 default_timeout=60.0,
1548 client_info=client_info,
1549 ),
1550 self.get_cmek_settings: self._wrap_method(
1551 self.get_cmek_settings,
1552 default_timeout=None,
1553 client_info=client_info,
1554 ),
1555 self.update_cmek_settings: self._wrap_method(
1556 self.update_cmek_settings,
1557 default_timeout=None,
1558 client_info=client_info,
1559 ),
1560 self.get_settings: self._wrap_method(
1561 self.get_settings,
1562 default_timeout=None,
1563 client_info=client_info,
1564 ),
1565 self.update_settings: self._wrap_method(
1566 self.update_settings,
1567 default_timeout=None,
1568 client_info=client_info,
1569 ),
1570 self.copy_log_entries: self._wrap_method(
1571 self.copy_log_entries,
1572 default_timeout=None,
1573 client_info=client_info,
1574 ),
1575 self.cancel_operation: self._wrap_method(
1576 self.cancel_operation,
1577 default_timeout=None,
1578 client_info=client_info,
1579 ),
1580 self.get_operation: self._wrap_method(
1581 self.get_operation,
1582 default_timeout=None,
1583 client_info=client_info,
1584 ),
1585 self.list_operations: self._wrap_method(
1586 self.list_operations,
1587 default_timeout=None,
1588 client_info=client_info,
1589 ),
1590 }
1591
1592 def _wrap_method(self, func, *args, **kwargs):
1593 if self._wrap_with_kind: # pragma: NO COVER
1594 kwargs["kind"] = self.kind
1595 return gapic_v1.method_async.wrap_method(func, *args, **kwargs)
1596
1597 def close(self):
1598 return self._logged_channel.close()
1599
1600 @property
1601 def kind(self) -> str:
1602 return "grpc_asyncio"
1603
1604 @property
1605 def cancel_operation(
1606 self,
1607 ) -> Callable[[operations_pb2.CancelOperationRequest], None]:
1608 r"""Return a callable for the cancel_operation method over gRPC."""
1609 # Generate a "stub function" on-the-fly which will actually make
1610 # the request.
1611 # gRPC handles serialization and deserialization, so we just need
1612 # to pass in the functions for each.
1613 if "cancel_operation" not in self._stubs:
1614 self._stubs["cancel_operation"] = self._logged_channel.unary_unary(
1615 "/google.longrunning.Operations/CancelOperation",
1616 request_serializer=operations_pb2.CancelOperationRequest.SerializeToString,
1617 response_deserializer=None,
1618 )
1619 return self._stubs["cancel_operation"]
1620
1621 @property
1622 def get_operation(
1623 self,
1624 ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]:
1625 r"""Return a callable for the get_operation method over gRPC."""
1626 # Generate a "stub function" on-the-fly which will actually make
1627 # the request.
1628 # gRPC handles serialization and deserialization, so we just need
1629 # to pass in the functions for each.
1630 if "get_operation" not in self._stubs:
1631 self._stubs["get_operation"] = self._logged_channel.unary_unary(
1632 "/google.longrunning.Operations/GetOperation",
1633 request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
1634 response_deserializer=operations_pb2.Operation.FromString,
1635 )
1636 return self._stubs["get_operation"]
1637
1638 @property
1639 def list_operations(
1640 self,
1641 ) -> Callable[
1642 [operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse
1643 ]:
1644 r"""Return a callable for the list_operations method over gRPC."""
1645 # Generate a "stub function" on-the-fly which will actually make
1646 # the request.
1647 # gRPC handles serialization and deserialization, so we just need
1648 # to pass in the functions for each.
1649 if "list_operations" not in self._stubs:
1650 self._stubs["list_operations"] = self._logged_channel.unary_unary(
1651 "/google.longrunning.Operations/ListOperations",
1652 request_serializer=operations_pb2.ListOperationsRequest.SerializeToString,
1653 response_deserializer=operations_pb2.ListOperationsResponse.FromString,
1654 )
1655 return self._stubs["list_operations"]
1656
1657
1658__all__ = ("ConfigServiceV2GrpcAsyncIOTransport",)