1# -*- coding: utf-8 -*-
2# Copyright 2023 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 warnings
17from typing import Callable, Dict, Optional, Sequence, Tuple, Union
18
19from google.api_core import grpc_helpers
20from google.api_core import operations_v1
21from google.api_core import gapic_v1
22import google.auth # type: ignore
23from google.auth import credentials as ga_credentials # type: ignore
24from google.auth.transport.grpc import SslCredentials # type: ignore
25
26import grpc # type: ignore
27
28from google.cloud.logging_v2.types import logging_config
29from google.longrunning import operations_pb2 # type: ignore
30from google.protobuf import empty_pb2 # type: ignore
31from .base import ConfigServiceV2Transport, DEFAULT_CLIENT_INFO
32
33
34class ConfigServiceV2GrpcTransport(ConfigServiceV2Transport):
35 """gRPC backend transport for ConfigServiceV2.
36
37 Service for configuring sinks used to route log entries.
38
39 This class defines the same methods as the primary client, so the
40 primary client can load the underlying transport implementation
41 and call it.
42
43 It sends protocol buffers over the wire using gRPC (which is built on
44 top of HTTP/2); the ``grpcio`` package must be installed.
45 """
46
47 _stubs: Dict[str, Callable]
48
49 def __init__(
50 self,
51 *,
52 host: str = "logging.googleapis.com",
53 credentials: Optional[ga_credentials.Credentials] = None,
54 credentials_file: Optional[str] = None,
55 scopes: Optional[Sequence[str]] = None,
56 channel: Optional[grpc.Channel] = None,
57 api_mtls_endpoint: Optional[str] = None,
58 client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
59 ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
60 client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
61 quota_project_id: Optional[str] = None,
62 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
63 always_use_jwt_access: Optional[bool] = False,
64 api_audience: Optional[str] = None,
65 ) -> None:
66 """Instantiate the transport.
67
68 Args:
69 host (Optional[str]):
70 The hostname to connect to.
71 credentials (Optional[google.auth.credentials.Credentials]): The
72 authorization credentials to attach to requests. These
73 credentials identify the application to the service; if none
74 are specified, the client will attempt to ascertain the
75 credentials from the environment.
76 This argument is ignored if ``channel`` is provided.
77 credentials_file (Optional[str]): A file with credentials that can
78 be loaded with :func:`google.auth.load_credentials_from_file`.
79 This argument is ignored if ``channel`` is provided.
80 scopes (Optional(Sequence[str])): A list of scopes. This argument is
81 ignored if ``channel`` is provided.
82 channel (Optional[grpc.Channel]): A ``Channel`` instance through
83 which to make calls.
84 api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
85 If provided, it overrides the ``host`` argument and tries to create
86 a mutual TLS channel with client SSL credentials from
87 ``client_cert_source`` or application default SSL credentials.
88 client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
89 Deprecated. A callback to provide client SSL certificate bytes and
90 private key bytes, both in PEM format. It is ignored if
91 ``api_mtls_endpoint`` is None.
92 ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
93 for the grpc channel. It is ignored if ``channel`` is provided.
94 client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
95 A callback to provide client certificate bytes and private key bytes,
96 both in PEM format. It is used to configure a mutual TLS channel. It is
97 ignored if ``channel`` or ``ssl_channel_credentials`` is provided.
98 quota_project_id (Optional[str]): An optional project to use for billing
99 and quota.
100 client_info (google.api_core.gapic_v1.client_info.ClientInfo):
101 The client info used to send a user-agent string along with
102 API requests. If ``None``, then default info will be used.
103 Generally, you only need to set this if you're developing
104 your own client library.
105 always_use_jwt_access (Optional[bool]): Whether self signed JWT should
106 be used for service account credentials.
107
108 Raises:
109 google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
110 creation failed for any reason.
111 google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
112 and ``credentials_file`` are passed.
113 """
114 self._grpc_channel = None
115 self._ssl_channel_credentials = ssl_channel_credentials
116 self._stubs: Dict[str, Callable] = {}
117 self._operations_client: Optional[operations_v1.OperationsClient] = None
118
119 if api_mtls_endpoint:
120 warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
121 if client_cert_source:
122 warnings.warn("client_cert_source is deprecated", DeprecationWarning)
123
124 if channel:
125 # Ignore credentials if a channel was passed.
126 credentials = False
127 # If a channel was explicitly provided, set it.
128 self._grpc_channel = channel
129 self._ssl_channel_credentials = None
130
131 else:
132 if api_mtls_endpoint:
133 host = api_mtls_endpoint
134
135 # Create SSL credentials with client_cert_source or application
136 # default SSL credentials.
137 if client_cert_source:
138 cert, key = client_cert_source()
139 self._ssl_channel_credentials = grpc.ssl_channel_credentials(
140 certificate_chain=cert, private_key=key
141 )
142 else:
143 self._ssl_channel_credentials = SslCredentials().ssl_credentials
144
145 else:
146 if client_cert_source_for_mtls and not ssl_channel_credentials:
147 cert, key = client_cert_source_for_mtls()
148 self._ssl_channel_credentials = grpc.ssl_channel_credentials(
149 certificate_chain=cert, private_key=key
150 )
151
152 # The base transport sets the host, credentials and scopes
153 super().__init__(
154 host=host,
155 credentials=credentials,
156 credentials_file=credentials_file,
157 scopes=scopes,
158 quota_project_id=quota_project_id,
159 client_info=client_info,
160 always_use_jwt_access=always_use_jwt_access,
161 api_audience=api_audience,
162 )
163
164 if not self._grpc_channel:
165 self._grpc_channel = type(self).create_channel(
166 self._host,
167 # use the credentials which are saved
168 credentials=self._credentials,
169 # Set ``credentials_file`` to ``None`` here as
170 # the credentials that we saved earlier should be used.
171 credentials_file=None,
172 scopes=self._scopes,
173 ssl_credentials=self._ssl_channel_credentials,
174 quota_project_id=quota_project_id,
175 options=[
176 ("grpc.max_send_message_length", -1),
177 ("grpc.max_receive_message_length", -1),
178 ],
179 )
180
181 # Wrap messages. This must be done after self._grpc_channel exists
182 self._prep_wrapped_messages(client_info)
183
184 @classmethod
185 def create_channel(
186 cls,
187 host: str = "logging.googleapis.com",
188 credentials: Optional[ga_credentials.Credentials] = None,
189 credentials_file: Optional[str] = None,
190 scopes: Optional[Sequence[str]] = None,
191 quota_project_id: Optional[str] = None,
192 **kwargs,
193 ) -> grpc.Channel:
194 """Create and return a gRPC channel object.
195 Args:
196 host (Optional[str]): The host for the channel to use.
197 credentials (Optional[~.Credentials]): The
198 authorization credentials to attach to requests. These
199 credentials identify this application to the service. If
200 none are specified, the client will attempt to ascertain
201 the credentials from the environment.
202 credentials_file (Optional[str]): A file with credentials that can
203 be loaded with :func:`google.auth.load_credentials_from_file`.
204 This argument is mutually exclusive with credentials.
205 scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
206 service. These are only used when credentials are not specified and
207 are passed to :func:`google.auth.default`.
208 quota_project_id (Optional[str]): An optional project to use for billing
209 and quota.
210 kwargs (Optional[dict]): Keyword arguments, which are passed to the
211 channel creation.
212 Returns:
213 grpc.Channel: A gRPC channel object.
214
215 Raises:
216 google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
217 and ``credentials_file`` are passed.
218 """
219
220 return grpc_helpers.create_channel(
221 host,
222 credentials=credentials,
223 credentials_file=credentials_file,
224 quota_project_id=quota_project_id,
225 default_scopes=cls.AUTH_SCOPES,
226 scopes=scopes,
227 default_host=cls.DEFAULT_HOST,
228 **kwargs,
229 )
230
231 @property
232 def grpc_channel(self) -> grpc.Channel:
233 """Return the channel designed to connect to this service."""
234 return self._grpc_channel
235
236 @property
237 def operations_client(self) -> operations_v1.OperationsClient:
238 """Create the client designed to process long-running operations.
239
240 This property caches on the instance; repeated calls return the same
241 client.
242 """
243 # Quick check: Only create a new client if we do not already have one.
244 if self._operations_client is None:
245 self._operations_client = operations_v1.OperationsClient(self.grpc_channel)
246
247 # Return the client from cache.
248 return self._operations_client
249
250 @property
251 def list_buckets(
252 self,
253 ) -> Callable[
254 [logging_config.ListBucketsRequest], logging_config.ListBucketsResponse
255 ]:
256 r"""Return a callable for the list buckets method over gRPC.
257
258 Lists log buckets.
259
260 Returns:
261 Callable[[~.ListBucketsRequest],
262 ~.ListBucketsResponse]:
263 A function that, when called, will call the underlying RPC
264 on the server.
265 """
266 # Generate a "stub function" on-the-fly which will actually make
267 # the request.
268 # gRPC handles serialization and deserialization, so we just need
269 # to pass in the functions for each.
270 if "list_buckets" not in self._stubs:
271 self._stubs["list_buckets"] = self.grpc_channel.unary_unary(
272 "/google.logging.v2.ConfigServiceV2/ListBuckets",
273 request_serializer=logging_config.ListBucketsRequest.serialize,
274 response_deserializer=logging_config.ListBucketsResponse.deserialize,
275 )
276 return self._stubs["list_buckets"]
277
278 @property
279 def get_bucket(
280 self,
281 ) -> Callable[[logging_config.GetBucketRequest], logging_config.LogBucket]:
282 r"""Return a callable for the get bucket method over gRPC.
283
284 Gets a log bucket.
285
286 Returns:
287 Callable[[~.GetBucketRequest],
288 ~.LogBucket]:
289 A function that, when called, will call the underlying RPC
290 on the server.
291 """
292 # Generate a "stub function" on-the-fly which will actually make
293 # the request.
294 # gRPC handles serialization and deserialization, so we just need
295 # to pass in the functions for each.
296 if "get_bucket" not in self._stubs:
297 self._stubs["get_bucket"] = self.grpc_channel.unary_unary(
298 "/google.logging.v2.ConfigServiceV2/GetBucket",
299 request_serializer=logging_config.GetBucketRequest.serialize,
300 response_deserializer=logging_config.LogBucket.deserialize,
301 )
302 return self._stubs["get_bucket"]
303
304 @property
305 def create_bucket_async(
306 self,
307 ) -> Callable[[logging_config.CreateBucketRequest], operations_pb2.Operation]:
308 r"""Return a callable for the create bucket async method over gRPC.
309
310 Creates a log bucket asynchronously that can be used
311 to store log entries.
312 After a bucket has been created, the bucket's location
313 cannot be changed.
314
315 Returns:
316 Callable[[~.CreateBucketRequest],
317 ~.Operation]:
318 A function that, when called, will call the underlying RPC
319 on the server.
320 """
321 # Generate a "stub function" on-the-fly which will actually make
322 # the request.
323 # gRPC handles serialization and deserialization, so we just need
324 # to pass in the functions for each.
325 if "create_bucket_async" not in self._stubs:
326 self._stubs["create_bucket_async"] = self.grpc_channel.unary_unary(
327 "/google.logging.v2.ConfigServiceV2/CreateBucketAsync",
328 request_serializer=logging_config.CreateBucketRequest.serialize,
329 response_deserializer=operations_pb2.Operation.FromString,
330 )
331 return self._stubs["create_bucket_async"]
332
333 @property
334 def update_bucket_async(
335 self,
336 ) -> Callable[[logging_config.UpdateBucketRequest], operations_pb2.Operation]:
337 r"""Return a callable for the update bucket async method over gRPC.
338
339 Updates a log bucket asynchronously.
340
341 If the bucket has a ``lifecycle_state`` of ``DELETE_REQUESTED``,
342 then ``FAILED_PRECONDITION`` will be returned.
343
344 After a bucket has been created, the bucket's location cannot be
345 changed.
346
347 Returns:
348 Callable[[~.UpdateBucketRequest],
349 ~.Operation]:
350 A function that, when called, will call the underlying RPC
351 on the server.
352 """
353 # Generate a "stub function" on-the-fly which will actually make
354 # the request.
355 # gRPC handles serialization and deserialization, so we just need
356 # to pass in the functions for each.
357 if "update_bucket_async" not in self._stubs:
358 self._stubs["update_bucket_async"] = self.grpc_channel.unary_unary(
359 "/google.logging.v2.ConfigServiceV2/UpdateBucketAsync",
360 request_serializer=logging_config.UpdateBucketRequest.serialize,
361 response_deserializer=operations_pb2.Operation.FromString,
362 )
363 return self._stubs["update_bucket_async"]
364
365 @property
366 def create_bucket(
367 self,
368 ) -> Callable[[logging_config.CreateBucketRequest], logging_config.LogBucket]:
369 r"""Return a callable for the create bucket method over gRPC.
370
371 Creates a log bucket that can be used to store log
372 entries. After a bucket has been created, the bucket's
373 location cannot be changed.
374
375 Returns:
376 Callable[[~.CreateBucketRequest],
377 ~.LogBucket]:
378 A function that, when called, will call the underlying RPC
379 on the server.
380 """
381 # Generate a "stub function" on-the-fly which will actually make
382 # the request.
383 # gRPC handles serialization and deserialization, so we just need
384 # to pass in the functions for each.
385 if "create_bucket" not in self._stubs:
386 self._stubs["create_bucket"] = self.grpc_channel.unary_unary(
387 "/google.logging.v2.ConfigServiceV2/CreateBucket",
388 request_serializer=logging_config.CreateBucketRequest.serialize,
389 response_deserializer=logging_config.LogBucket.deserialize,
390 )
391 return self._stubs["create_bucket"]
392
393 @property
394 def update_bucket(
395 self,
396 ) -> Callable[[logging_config.UpdateBucketRequest], logging_config.LogBucket]:
397 r"""Return a callable for the update bucket method over gRPC.
398
399 Updates a log bucket.
400
401 If the bucket has a ``lifecycle_state`` of ``DELETE_REQUESTED``,
402 then ``FAILED_PRECONDITION`` will be returned.
403
404 After a bucket has been created, the bucket's location cannot be
405 changed.
406
407 Returns:
408 Callable[[~.UpdateBucketRequest],
409 ~.LogBucket]:
410 A function that, when called, will call the underlying RPC
411 on the server.
412 """
413 # Generate a "stub function" on-the-fly which will actually make
414 # the request.
415 # gRPC handles serialization and deserialization, so we just need
416 # to pass in the functions for each.
417 if "update_bucket" not in self._stubs:
418 self._stubs["update_bucket"] = self.grpc_channel.unary_unary(
419 "/google.logging.v2.ConfigServiceV2/UpdateBucket",
420 request_serializer=logging_config.UpdateBucketRequest.serialize,
421 response_deserializer=logging_config.LogBucket.deserialize,
422 )
423 return self._stubs["update_bucket"]
424
425 @property
426 def delete_bucket(
427 self,
428 ) -> Callable[[logging_config.DeleteBucketRequest], empty_pb2.Empty]:
429 r"""Return a callable for the delete bucket method over gRPC.
430
431 Deletes a log bucket.
432
433 Changes the bucket's ``lifecycle_state`` to the
434 ``DELETE_REQUESTED`` state. After 7 days, the bucket will be
435 purged and all log entries in the bucket will be permanently
436 deleted.
437
438 Returns:
439 Callable[[~.DeleteBucketRequest],
440 ~.Empty]:
441 A function that, when called, will call the underlying RPC
442 on the server.
443 """
444 # Generate a "stub function" on-the-fly which will actually make
445 # the request.
446 # gRPC handles serialization and deserialization, so we just need
447 # to pass in the functions for each.
448 if "delete_bucket" not in self._stubs:
449 self._stubs["delete_bucket"] = self.grpc_channel.unary_unary(
450 "/google.logging.v2.ConfigServiceV2/DeleteBucket",
451 request_serializer=logging_config.DeleteBucketRequest.serialize,
452 response_deserializer=empty_pb2.Empty.FromString,
453 )
454 return self._stubs["delete_bucket"]
455
456 @property
457 def undelete_bucket(
458 self,
459 ) -> Callable[[logging_config.UndeleteBucketRequest], empty_pb2.Empty]:
460 r"""Return a callable for the undelete bucket method over gRPC.
461
462 Undeletes a log bucket. A bucket that has been
463 deleted can be undeleted within the grace period of 7
464 days.
465
466 Returns:
467 Callable[[~.UndeleteBucketRequest],
468 ~.Empty]:
469 A function that, when called, will call the underlying RPC
470 on the server.
471 """
472 # Generate a "stub function" on-the-fly which will actually make
473 # the request.
474 # gRPC handles serialization and deserialization, so we just need
475 # to pass in the functions for each.
476 if "undelete_bucket" not in self._stubs:
477 self._stubs["undelete_bucket"] = self.grpc_channel.unary_unary(
478 "/google.logging.v2.ConfigServiceV2/UndeleteBucket",
479 request_serializer=logging_config.UndeleteBucketRequest.serialize,
480 response_deserializer=empty_pb2.Empty.FromString,
481 )
482 return self._stubs["undelete_bucket"]
483
484 @property
485 def list_views(
486 self,
487 ) -> Callable[[logging_config.ListViewsRequest], logging_config.ListViewsResponse]:
488 r"""Return a callable for the list views method over gRPC.
489
490 Lists views on a log bucket.
491
492 Returns:
493 Callable[[~.ListViewsRequest],
494 ~.ListViewsResponse]:
495 A function that, when called, will call the underlying RPC
496 on the server.
497 """
498 # Generate a "stub function" on-the-fly which will actually make
499 # the request.
500 # gRPC handles serialization and deserialization, so we just need
501 # to pass in the functions for each.
502 if "list_views" not in self._stubs:
503 self._stubs["list_views"] = self.grpc_channel.unary_unary(
504 "/google.logging.v2.ConfigServiceV2/ListViews",
505 request_serializer=logging_config.ListViewsRequest.serialize,
506 response_deserializer=logging_config.ListViewsResponse.deserialize,
507 )
508 return self._stubs["list_views"]
509
510 @property
511 def get_view(
512 self,
513 ) -> Callable[[logging_config.GetViewRequest], logging_config.LogView]:
514 r"""Return a callable for the get view method over gRPC.
515
516 Gets a view on a log bucket..
517
518 Returns:
519 Callable[[~.GetViewRequest],
520 ~.LogView]:
521 A function that, when called, will call the underlying RPC
522 on the server.
523 """
524 # Generate a "stub function" on-the-fly which will actually make
525 # the request.
526 # gRPC handles serialization and deserialization, so we just need
527 # to pass in the functions for each.
528 if "get_view" not in self._stubs:
529 self._stubs["get_view"] = self.grpc_channel.unary_unary(
530 "/google.logging.v2.ConfigServiceV2/GetView",
531 request_serializer=logging_config.GetViewRequest.serialize,
532 response_deserializer=logging_config.LogView.deserialize,
533 )
534 return self._stubs["get_view"]
535
536 @property
537 def create_view(
538 self,
539 ) -> Callable[[logging_config.CreateViewRequest], logging_config.LogView]:
540 r"""Return a callable for the create view method over gRPC.
541
542 Creates a view over log entries in a log bucket. A
543 bucket may contain a maximum of 30 views.
544
545 Returns:
546 Callable[[~.CreateViewRequest],
547 ~.LogView]:
548 A function that, when called, will call the underlying RPC
549 on the server.
550 """
551 # Generate a "stub function" on-the-fly which will actually make
552 # the request.
553 # gRPC handles serialization and deserialization, so we just need
554 # to pass in the functions for each.
555 if "create_view" not in self._stubs:
556 self._stubs["create_view"] = self.grpc_channel.unary_unary(
557 "/google.logging.v2.ConfigServiceV2/CreateView",
558 request_serializer=logging_config.CreateViewRequest.serialize,
559 response_deserializer=logging_config.LogView.deserialize,
560 )
561 return self._stubs["create_view"]
562
563 @property
564 def update_view(
565 self,
566 ) -> Callable[[logging_config.UpdateViewRequest], logging_config.LogView]:
567 r"""Return a callable for the update view method over gRPC.
568
569 Updates a view on a log bucket. This method replaces the
570 following fields in the existing view with values from the new
571 view: ``filter``. If an ``UNAVAILABLE`` error is returned, this
572 indicates that system is not in a state where it can update the
573 view. If this occurs, please try again in a few minutes.
574
575 Returns:
576 Callable[[~.UpdateViewRequest],
577 ~.LogView]:
578 A function that, when called, will call the underlying RPC
579 on the server.
580 """
581 # Generate a "stub function" on-the-fly which will actually make
582 # the request.
583 # gRPC handles serialization and deserialization, so we just need
584 # to pass in the functions for each.
585 if "update_view" not in self._stubs:
586 self._stubs["update_view"] = self.grpc_channel.unary_unary(
587 "/google.logging.v2.ConfigServiceV2/UpdateView",
588 request_serializer=logging_config.UpdateViewRequest.serialize,
589 response_deserializer=logging_config.LogView.deserialize,
590 )
591 return self._stubs["update_view"]
592
593 @property
594 def delete_view(
595 self,
596 ) -> Callable[[logging_config.DeleteViewRequest], empty_pb2.Empty]:
597 r"""Return a callable for the delete view method over gRPC.
598
599 Deletes a view on a log bucket. If an ``UNAVAILABLE`` error is
600 returned, this indicates that system is not in a state where it
601 can delete the view. If this occurs, please try again in a few
602 minutes.
603
604 Returns:
605 Callable[[~.DeleteViewRequest],
606 ~.Empty]:
607 A function that, when called, will call the underlying RPC
608 on the server.
609 """
610 # Generate a "stub function" on-the-fly which will actually make
611 # the request.
612 # gRPC handles serialization and deserialization, so we just need
613 # to pass in the functions for each.
614 if "delete_view" not in self._stubs:
615 self._stubs["delete_view"] = self.grpc_channel.unary_unary(
616 "/google.logging.v2.ConfigServiceV2/DeleteView",
617 request_serializer=logging_config.DeleteViewRequest.serialize,
618 response_deserializer=empty_pb2.Empty.FromString,
619 )
620 return self._stubs["delete_view"]
621
622 @property
623 def list_sinks(
624 self,
625 ) -> Callable[[logging_config.ListSinksRequest], logging_config.ListSinksResponse]:
626 r"""Return a callable for the list sinks method over gRPC.
627
628 Lists sinks.
629
630 Returns:
631 Callable[[~.ListSinksRequest],
632 ~.ListSinksResponse]:
633 A function that, when called, will call the underlying RPC
634 on the server.
635 """
636 # Generate a "stub function" on-the-fly which will actually make
637 # the request.
638 # gRPC handles serialization and deserialization, so we just need
639 # to pass in the functions for each.
640 if "list_sinks" not in self._stubs:
641 self._stubs["list_sinks"] = self.grpc_channel.unary_unary(
642 "/google.logging.v2.ConfigServiceV2/ListSinks",
643 request_serializer=logging_config.ListSinksRequest.serialize,
644 response_deserializer=logging_config.ListSinksResponse.deserialize,
645 )
646 return self._stubs["list_sinks"]
647
648 @property
649 def get_sink(
650 self,
651 ) -> Callable[[logging_config.GetSinkRequest], logging_config.LogSink]:
652 r"""Return a callable for the get sink method over gRPC.
653
654 Gets a sink.
655
656 Returns:
657 Callable[[~.GetSinkRequest],
658 ~.LogSink]:
659 A function that, when called, will call the underlying RPC
660 on the server.
661 """
662 # Generate a "stub function" on-the-fly which will actually make
663 # the request.
664 # gRPC handles serialization and deserialization, so we just need
665 # to pass in the functions for each.
666 if "get_sink" not in self._stubs:
667 self._stubs["get_sink"] = self.grpc_channel.unary_unary(
668 "/google.logging.v2.ConfigServiceV2/GetSink",
669 request_serializer=logging_config.GetSinkRequest.serialize,
670 response_deserializer=logging_config.LogSink.deserialize,
671 )
672 return self._stubs["get_sink"]
673
674 @property
675 def create_sink(
676 self,
677 ) -> Callable[[logging_config.CreateSinkRequest], logging_config.LogSink]:
678 r"""Return a callable for the create sink method over gRPC.
679
680 Creates a sink that exports specified log entries to a
681 destination. The export of newly-ingested log entries begins
682 immediately, unless the sink's ``writer_identity`` is not
683 permitted to write to the destination. A sink can export log
684 entries only from the resource owning the sink.
685
686 Returns:
687 Callable[[~.CreateSinkRequest],
688 ~.LogSink]:
689 A function that, when called, will call the underlying RPC
690 on the server.
691 """
692 # Generate a "stub function" on-the-fly which will actually make
693 # the request.
694 # gRPC handles serialization and deserialization, so we just need
695 # to pass in the functions for each.
696 if "create_sink" not in self._stubs:
697 self._stubs["create_sink"] = self.grpc_channel.unary_unary(
698 "/google.logging.v2.ConfigServiceV2/CreateSink",
699 request_serializer=logging_config.CreateSinkRequest.serialize,
700 response_deserializer=logging_config.LogSink.deserialize,
701 )
702 return self._stubs["create_sink"]
703
704 @property
705 def update_sink(
706 self,
707 ) -> Callable[[logging_config.UpdateSinkRequest], logging_config.LogSink]:
708 r"""Return a callable for the update sink method over gRPC.
709
710 Updates a sink. This method replaces the following fields in the
711 existing sink with values from the new sink: ``destination``,
712 and ``filter``.
713
714 The updated sink might also have a new ``writer_identity``; see
715 the ``unique_writer_identity`` field.
716
717 Returns:
718 Callable[[~.UpdateSinkRequest],
719 ~.LogSink]:
720 A function that, when called, will call the underlying RPC
721 on the server.
722 """
723 # Generate a "stub function" on-the-fly which will actually make
724 # the request.
725 # gRPC handles serialization and deserialization, so we just need
726 # to pass in the functions for each.
727 if "update_sink" not in self._stubs:
728 self._stubs["update_sink"] = self.grpc_channel.unary_unary(
729 "/google.logging.v2.ConfigServiceV2/UpdateSink",
730 request_serializer=logging_config.UpdateSinkRequest.serialize,
731 response_deserializer=logging_config.LogSink.deserialize,
732 )
733 return self._stubs["update_sink"]
734
735 @property
736 def delete_sink(
737 self,
738 ) -> Callable[[logging_config.DeleteSinkRequest], empty_pb2.Empty]:
739 r"""Return a callable for the delete sink method over gRPC.
740
741 Deletes a sink. If the sink has a unique ``writer_identity``,
742 then that service account is also deleted.
743
744 Returns:
745 Callable[[~.DeleteSinkRequest],
746 ~.Empty]:
747 A function that, when called, will call the underlying RPC
748 on the server.
749 """
750 # Generate a "stub function" on-the-fly which will actually make
751 # the request.
752 # gRPC handles serialization and deserialization, so we just need
753 # to pass in the functions for each.
754 if "delete_sink" not in self._stubs:
755 self._stubs["delete_sink"] = self.grpc_channel.unary_unary(
756 "/google.logging.v2.ConfigServiceV2/DeleteSink",
757 request_serializer=logging_config.DeleteSinkRequest.serialize,
758 response_deserializer=empty_pb2.Empty.FromString,
759 )
760 return self._stubs["delete_sink"]
761
762 @property
763 def create_link(
764 self,
765 ) -> Callable[[logging_config.CreateLinkRequest], operations_pb2.Operation]:
766 r"""Return a callable for the create link method over gRPC.
767
768 Asynchronously creates a linked dataset in BigQuery
769 which makes it possible to use BigQuery to read the logs
770 stored in the log bucket. A log bucket may currently
771 only contain one link.
772
773 Returns:
774 Callable[[~.CreateLinkRequest],
775 ~.Operation]:
776 A function that, when called, will call the underlying RPC
777 on the server.
778 """
779 # Generate a "stub function" on-the-fly which will actually make
780 # the request.
781 # gRPC handles serialization and deserialization, so we just need
782 # to pass in the functions for each.
783 if "create_link" not in self._stubs:
784 self._stubs["create_link"] = self.grpc_channel.unary_unary(
785 "/google.logging.v2.ConfigServiceV2/CreateLink",
786 request_serializer=logging_config.CreateLinkRequest.serialize,
787 response_deserializer=operations_pb2.Operation.FromString,
788 )
789 return self._stubs["create_link"]
790
791 @property
792 def delete_link(
793 self,
794 ) -> Callable[[logging_config.DeleteLinkRequest], operations_pb2.Operation]:
795 r"""Return a callable for the delete link method over gRPC.
796
797 Deletes a link. This will also delete the
798 corresponding BigQuery linked dataset.
799
800 Returns:
801 Callable[[~.DeleteLinkRequest],
802 ~.Operation]:
803 A function that, when called, will call the underlying RPC
804 on the server.
805 """
806 # Generate a "stub function" on-the-fly which will actually make
807 # the request.
808 # gRPC handles serialization and deserialization, so we just need
809 # to pass in the functions for each.
810 if "delete_link" not in self._stubs:
811 self._stubs["delete_link"] = self.grpc_channel.unary_unary(
812 "/google.logging.v2.ConfigServiceV2/DeleteLink",
813 request_serializer=logging_config.DeleteLinkRequest.serialize,
814 response_deserializer=operations_pb2.Operation.FromString,
815 )
816 return self._stubs["delete_link"]
817
818 @property
819 def list_links(
820 self,
821 ) -> Callable[[logging_config.ListLinksRequest], logging_config.ListLinksResponse]:
822 r"""Return a callable for the list links method over gRPC.
823
824 Lists links.
825
826 Returns:
827 Callable[[~.ListLinksRequest],
828 ~.ListLinksResponse]:
829 A function that, when called, will call the underlying RPC
830 on the server.
831 """
832 # Generate a "stub function" on-the-fly which will actually make
833 # the request.
834 # gRPC handles serialization and deserialization, so we just need
835 # to pass in the functions for each.
836 if "list_links" not in self._stubs:
837 self._stubs["list_links"] = self.grpc_channel.unary_unary(
838 "/google.logging.v2.ConfigServiceV2/ListLinks",
839 request_serializer=logging_config.ListLinksRequest.serialize,
840 response_deserializer=logging_config.ListLinksResponse.deserialize,
841 )
842 return self._stubs["list_links"]
843
844 @property
845 def get_link(
846 self,
847 ) -> Callable[[logging_config.GetLinkRequest], logging_config.Link]:
848 r"""Return a callable for the get link method over gRPC.
849
850 Gets a link.
851
852 Returns:
853 Callable[[~.GetLinkRequest],
854 ~.Link]:
855 A function that, when called, will call the underlying RPC
856 on the server.
857 """
858 # Generate a "stub function" on-the-fly which will actually make
859 # the request.
860 # gRPC handles serialization and deserialization, so we just need
861 # to pass in the functions for each.
862 if "get_link" not in self._stubs:
863 self._stubs["get_link"] = self.grpc_channel.unary_unary(
864 "/google.logging.v2.ConfigServiceV2/GetLink",
865 request_serializer=logging_config.GetLinkRequest.serialize,
866 response_deserializer=logging_config.Link.deserialize,
867 )
868 return self._stubs["get_link"]
869
870 @property
871 def list_exclusions(
872 self,
873 ) -> Callable[
874 [logging_config.ListExclusionsRequest], logging_config.ListExclusionsResponse
875 ]:
876 r"""Return a callable for the list exclusions method over gRPC.
877
878 Lists all the exclusions on the \_Default sink in a parent
879 resource.
880
881 Returns:
882 Callable[[~.ListExclusionsRequest],
883 ~.ListExclusionsResponse]:
884 A function that, when called, will call the underlying RPC
885 on the server.
886 """
887 # Generate a "stub function" on-the-fly which will actually make
888 # the request.
889 # gRPC handles serialization and deserialization, so we just need
890 # to pass in the functions for each.
891 if "list_exclusions" not in self._stubs:
892 self._stubs["list_exclusions"] = self.grpc_channel.unary_unary(
893 "/google.logging.v2.ConfigServiceV2/ListExclusions",
894 request_serializer=logging_config.ListExclusionsRequest.serialize,
895 response_deserializer=logging_config.ListExclusionsResponse.deserialize,
896 )
897 return self._stubs["list_exclusions"]
898
899 @property
900 def get_exclusion(
901 self,
902 ) -> Callable[[logging_config.GetExclusionRequest], logging_config.LogExclusion]:
903 r"""Return a callable for the get exclusion method over gRPC.
904
905 Gets the description of an exclusion in the \_Default sink.
906
907 Returns:
908 Callable[[~.GetExclusionRequest],
909 ~.LogExclusion]:
910 A function that, when called, will call the underlying RPC
911 on the server.
912 """
913 # Generate a "stub function" on-the-fly which will actually make
914 # the request.
915 # gRPC handles serialization and deserialization, so we just need
916 # to pass in the functions for each.
917 if "get_exclusion" not in self._stubs:
918 self._stubs["get_exclusion"] = self.grpc_channel.unary_unary(
919 "/google.logging.v2.ConfigServiceV2/GetExclusion",
920 request_serializer=logging_config.GetExclusionRequest.serialize,
921 response_deserializer=logging_config.LogExclusion.deserialize,
922 )
923 return self._stubs["get_exclusion"]
924
925 @property
926 def create_exclusion(
927 self,
928 ) -> Callable[[logging_config.CreateExclusionRequest], logging_config.LogExclusion]:
929 r"""Return a callable for the create exclusion method over gRPC.
930
931 Creates a new exclusion in the \_Default sink in a specified
932 parent resource. Only log entries belonging to that resource can
933 be excluded. You can have up to 10 exclusions in a resource.
934
935 Returns:
936 Callable[[~.CreateExclusionRequest],
937 ~.LogExclusion]:
938 A function that, when called, will call the underlying RPC
939 on the server.
940 """
941 # Generate a "stub function" on-the-fly which will actually make
942 # the request.
943 # gRPC handles serialization and deserialization, so we just need
944 # to pass in the functions for each.
945 if "create_exclusion" not in self._stubs:
946 self._stubs["create_exclusion"] = self.grpc_channel.unary_unary(
947 "/google.logging.v2.ConfigServiceV2/CreateExclusion",
948 request_serializer=logging_config.CreateExclusionRequest.serialize,
949 response_deserializer=logging_config.LogExclusion.deserialize,
950 )
951 return self._stubs["create_exclusion"]
952
953 @property
954 def update_exclusion(
955 self,
956 ) -> Callable[[logging_config.UpdateExclusionRequest], logging_config.LogExclusion]:
957 r"""Return a callable for the update exclusion method over gRPC.
958
959 Changes one or more properties of an existing exclusion in the
960 \_Default sink.
961
962 Returns:
963 Callable[[~.UpdateExclusionRequest],
964 ~.LogExclusion]:
965 A function that, when called, will call the underlying RPC
966 on the server.
967 """
968 # Generate a "stub function" on-the-fly which will actually make
969 # the request.
970 # gRPC handles serialization and deserialization, so we just need
971 # to pass in the functions for each.
972 if "update_exclusion" not in self._stubs:
973 self._stubs["update_exclusion"] = self.grpc_channel.unary_unary(
974 "/google.logging.v2.ConfigServiceV2/UpdateExclusion",
975 request_serializer=logging_config.UpdateExclusionRequest.serialize,
976 response_deserializer=logging_config.LogExclusion.deserialize,
977 )
978 return self._stubs["update_exclusion"]
979
980 @property
981 def delete_exclusion(
982 self,
983 ) -> Callable[[logging_config.DeleteExclusionRequest], empty_pb2.Empty]:
984 r"""Return a callable for the delete exclusion method over gRPC.
985
986 Deletes an exclusion in the \_Default sink.
987
988 Returns:
989 Callable[[~.DeleteExclusionRequest],
990 ~.Empty]:
991 A function that, when called, will call the underlying RPC
992 on the server.
993 """
994 # Generate a "stub function" on-the-fly which will actually make
995 # the request.
996 # gRPC handles serialization and deserialization, so we just need
997 # to pass in the functions for each.
998 if "delete_exclusion" not in self._stubs:
999 self._stubs["delete_exclusion"] = self.grpc_channel.unary_unary(
1000 "/google.logging.v2.ConfigServiceV2/DeleteExclusion",
1001 request_serializer=logging_config.DeleteExclusionRequest.serialize,
1002 response_deserializer=empty_pb2.Empty.FromString,
1003 )
1004 return self._stubs["delete_exclusion"]
1005
1006 @property
1007 def get_cmek_settings(
1008 self,
1009 ) -> Callable[[logging_config.GetCmekSettingsRequest], logging_config.CmekSettings]:
1010 r"""Return a callable for the get cmek settings method over gRPC.
1011
1012 Gets the Logging CMEK settings for the given resource.
1013
1014 Note: CMEK for the Log Router can be configured for Google Cloud
1015 projects, folders, organizations and billing accounts. Once
1016 configured for an organization, it applies to all projects and
1017 folders in the Google Cloud organization.
1018
1019 See `Enabling CMEK for Log
1020 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
1021 for more information.
1022
1023 Returns:
1024 Callable[[~.GetCmekSettingsRequest],
1025 ~.CmekSettings]:
1026 A function that, when called, will call the underlying RPC
1027 on the server.
1028 """
1029 # Generate a "stub function" on-the-fly which will actually make
1030 # the request.
1031 # gRPC handles serialization and deserialization, so we just need
1032 # to pass in the functions for each.
1033 if "get_cmek_settings" not in self._stubs:
1034 self._stubs["get_cmek_settings"] = self.grpc_channel.unary_unary(
1035 "/google.logging.v2.ConfigServiceV2/GetCmekSettings",
1036 request_serializer=logging_config.GetCmekSettingsRequest.serialize,
1037 response_deserializer=logging_config.CmekSettings.deserialize,
1038 )
1039 return self._stubs["get_cmek_settings"]
1040
1041 @property
1042 def update_cmek_settings(
1043 self,
1044 ) -> Callable[
1045 [logging_config.UpdateCmekSettingsRequest], logging_config.CmekSettings
1046 ]:
1047 r"""Return a callable for the update cmek settings method over gRPC.
1048
1049 Updates the Log Router CMEK settings for the given resource.
1050
1051 Note: CMEK for the Log Router can currently only be configured
1052 for Google Cloud organizations. Once configured, it applies to
1053 all projects and folders in the Google Cloud organization.
1054
1055 [UpdateCmekSettings][google.logging.v2.ConfigServiceV2.UpdateCmekSettings]
1056 will fail if 1) ``kms_key_name`` is invalid, or 2) the
1057 associated service account does not have the required
1058 ``roles/cloudkms.cryptoKeyEncrypterDecrypter`` role assigned for
1059 the key, or 3) access to the key is disabled.
1060
1061 See `Enabling CMEK for Log
1062 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
1063 for more information.
1064
1065 Returns:
1066 Callable[[~.UpdateCmekSettingsRequest],
1067 ~.CmekSettings]:
1068 A function that, when called, will call the underlying RPC
1069 on the server.
1070 """
1071 # Generate a "stub function" on-the-fly which will actually make
1072 # the request.
1073 # gRPC handles serialization and deserialization, so we just need
1074 # to pass in the functions for each.
1075 if "update_cmek_settings" not in self._stubs:
1076 self._stubs["update_cmek_settings"] = self.grpc_channel.unary_unary(
1077 "/google.logging.v2.ConfigServiceV2/UpdateCmekSettings",
1078 request_serializer=logging_config.UpdateCmekSettingsRequest.serialize,
1079 response_deserializer=logging_config.CmekSettings.deserialize,
1080 )
1081 return self._stubs["update_cmek_settings"]
1082
1083 @property
1084 def get_settings(
1085 self,
1086 ) -> Callable[[logging_config.GetSettingsRequest], logging_config.Settings]:
1087 r"""Return a callable for the get settings method over gRPC.
1088
1089 Gets the Log Router settings for the given resource.
1090
1091 Note: Settings for the Log Router can be get for Google Cloud
1092 projects, folders, organizations and billing accounts. Currently
1093 it can only be configured for organizations. Once configured for
1094 an organization, it applies to all projects and folders in the
1095 Google Cloud organization.
1096
1097 See `Enabling CMEK for Log
1098 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
1099 for more information.
1100
1101 Returns:
1102 Callable[[~.GetSettingsRequest],
1103 ~.Settings]:
1104 A function that, when called, will call the underlying RPC
1105 on the server.
1106 """
1107 # Generate a "stub function" on-the-fly which will actually make
1108 # the request.
1109 # gRPC handles serialization and deserialization, so we just need
1110 # to pass in the functions for each.
1111 if "get_settings" not in self._stubs:
1112 self._stubs["get_settings"] = self.grpc_channel.unary_unary(
1113 "/google.logging.v2.ConfigServiceV2/GetSettings",
1114 request_serializer=logging_config.GetSettingsRequest.serialize,
1115 response_deserializer=logging_config.Settings.deserialize,
1116 )
1117 return self._stubs["get_settings"]
1118
1119 @property
1120 def update_settings(
1121 self,
1122 ) -> Callable[[logging_config.UpdateSettingsRequest], logging_config.Settings]:
1123 r"""Return a callable for the update settings method over gRPC.
1124
1125 Updates the Log Router settings for the given resource.
1126
1127 Note: Settings for the Log Router can currently only be
1128 configured for Google Cloud organizations. Once configured, it
1129 applies to all projects and folders in the Google Cloud
1130 organization.
1131
1132 [UpdateSettings][google.logging.v2.ConfigServiceV2.UpdateSettings]
1133 will fail if 1) ``kms_key_name`` is invalid, or 2) the
1134 associated service account does not have the required
1135 ``roles/cloudkms.cryptoKeyEncrypterDecrypter`` role assigned for
1136 the key, or 3) access to the key is disabled. 4) ``location_id``
1137 is not supported by Logging. 5) ``location_id`` violate
1138 OrgPolicy.
1139
1140 See `Enabling CMEK for Log
1141 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
1142 for more information.
1143
1144 Returns:
1145 Callable[[~.UpdateSettingsRequest],
1146 ~.Settings]:
1147 A function that, when called, will call the underlying RPC
1148 on the server.
1149 """
1150 # Generate a "stub function" on-the-fly which will actually make
1151 # the request.
1152 # gRPC handles serialization and deserialization, so we just need
1153 # to pass in the functions for each.
1154 if "update_settings" not in self._stubs:
1155 self._stubs["update_settings"] = self.grpc_channel.unary_unary(
1156 "/google.logging.v2.ConfigServiceV2/UpdateSettings",
1157 request_serializer=logging_config.UpdateSettingsRequest.serialize,
1158 response_deserializer=logging_config.Settings.deserialize,
1159 )
1160 return self._stubs["update_settings"]
1161
1162 @property
1163 def copy_log_entries(
1164 self,
1165 ) -> Callable[[logging_config.CopyLogEntriesRequest], operations_pb2.Operation]:
1166 r"""Return a callable for the copy log entries method over gRPC.
1167
1168 Copies a set of log entries from a log bucket to a
1169 Cloud Storage bucket.
1170
1171 Returns:
1172 Callable[[~.CopyLogEntriesRequest],
1173 ~.Operation]:
1174 A function that, when called, will call the underlying RPC
1175 on the server.
1176 """
1177 # Generate a "stub function" on-the-fly which will actually make
1178 # the request.
1179 # gRPC handles serialization and deserialization, so we just need
1180 # to pass in the functions for each.
1181 if "copy_log_entries" not in self._stubs:
1182 self._stubs["copy_log_entries"] = self.grpc_channel.unary_unary(
1183 "/google.logging.v2.ConfigServiceV2/CopyLogEntries",
1184 request_serializer=logging_config.CopyLogEntriesRequest.serialize,
1185 response_deserializer=operations_pb2.Operation.FromString,
1186 )
1187 return self._stubs["copy_log_entries"]
1188
1189 def close(self):
1190 self.grpc_channel.close()
1191
1192 @property
1193 def cancel_operation(
1194 self,
1195 ) -> Callable[[operations_pb2.CancelOperationRequest], None]:
1196 r"""Return a callable for the cancel_operation method over gRPC."""
1197 # Generate a "stub function" on-the-fly which will actually make
1198 # the request.
1199 # gRPC handles serialization and deserialization, so we just need
1200 # to pass in the functions for each.
1201 if "cancel_operation" not in self._stubs:
1202 self._stubs["cancel_operation"] = self.grpc_channel.unary_unary(
1203 "/google.longrunning.Operations/CancelOperation",
1204 request_serializer=operations_pb2.CancelOperationRequest.SerializeToString,
1205 response_deserializer=None,
1206 )
1207 return self._stubs["cancel_operation"]
1208
1209 @property
1210 def get_operation(
1211 self,
1212 ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]:
1213 r"""Return a callable for the get_operation method over gRPC."""
1214 # Generate a "stub function" on-the-fly which will actually make
1215 # the request.
1216 # gRPC handles serialization and deserialization, so we just need
1217 # to pass in the functions for each.
1218 if "get_operation" not in self._stubs:
1219 self._stubs["get_operation"] = self.grpc_channel.unary_unary(
1220 "/google.longrunning.Operations/GetOperation",
1221 request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
1222 response_deserializer=operations_pb2.Operation.FromString,
1223 )
1224 return self._stubs["get_operation"]
1225
1226 @property
1227 def list_operations(
1228 self,
1229 ) -> Callable[
1230 [operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse
1231 ]:
1232 r"""Return a callable for the list_operations method over gRPC."""
1233 # Generate a "stub function" on-the-fly which will actually make
1234 # the request.
1235 # gRPC handles serialization and deserialization, so we just need
1236 # to pass in the functions for each.
1237 if "list_operations" not in self._stubs:
1238 self._stubs["list_operations"] = self.grpc_channel.unary_unary(
1239 "/google.longrunning.Operations/ListOperations",
1240 request_serializer=operations_pb2.ListOperationsRequest.SerializeToString,
1241 response_deserializer=operations_pb2.ListOperationsResponse.FromString,
1242 )
1243 return self._stubs["list_operations"]
1244
1245 @property
1246 def kind(self) -> str:
1247 return "grpc"
1248
1249
1250__all__ = ("ConfigServiceV2GrpcTransport",)