1# -*- coding: utf-8 -*-
2# Copyright 2022 Google LLC
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
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(
306 self,
307 ) -> Callable[[logging_config.CreateBucketRequest], logging_config.LogBucket]:
308 r"""Return a callable for the create bucket method over gRPC.
309
310 Creates a log bucket that can be used to store log
311 entries. After a bucket has been created, the bucket's
312 location cannot be changed.
313
314 Returns:
315 Callable[[~.CreateBucketRequest],
316 ~.LogBucket]:
317 A function that, when called, will call the underlying RPC
318 on the server.
319 """
320 # Generate a "stub function" on-the-fly which will actually make
321 # the request.
322 # gRPC handles serialization and deserialization, so we just need
323 # to pass in the functions for each.
324 if "create_bucket" not in self._stubs:
325 self._stubs["create_bucket"] = self.grpc_channel.unary_unary(
326 "/google.logging.v2.ConfigServiceV2/CreateBucket",
327 request_serializer=logging_config.CreateBucketRequest.serialize,
328 response_deserializer=logging_config.LogBucket.deserialize,
329 )
330 return self._stubs["create_bucket"]
331
332 @property
333 def update_bucket(
334 self,
335 ) -> Callable[[logging_config.UpdateBucketRequest], logging_config.LogBucket]:
336 r"""Return a callable for the update bucket method over gRPC.
337
338 Updates a log bucket. This method replaces the following fields
339 in the existing bucket with values from the new bucket:
340 ``retention_period``
341
342 If the retention period is decreased and the bucket is locked,
343 ``FAILED_PRECONDITION`` will be returned.
344
345 If the bucket has a ``lifecycle_state`` of ``DELETE_REQUESTED``,
346 then ``FAILED_PRECONDITION`` will be returned.
347
348 After a bucket has been created, the bucket's location cannot be
349 changed.
350
351 Returns:
352 Callable[[~.UpdateBucketRequest],
353 ~.LogBucket]:
354 A function that, when called, will call the underlying RPC
355 on the server.
356 """
357 # Generate a "stub function" on-the-fly which will actually make
358 # the request.
359 # gRPC handles serialization and deserialization, so we just need
360 # to pass in the functions for each.
361 if "update_bucket" not in self._stubs:
362 self._stubs["update_bucket"] = self.grpc_channel.unary_unary(
363 "/google.logging.v2.ConfigServiceV2/UpdateBucket",
364 request_serializer=logging_config.UpdateBucketRequest.serialize,
365 response_deserializer=logging_config.LogBucket.deserialize,
366 )
367 return self._stubs["update_bucket"]
368
369 @property
370 def delete_bucket(
371 self,
372 ) -> Callable[[logging_config.DeleteBucketRequest], empty_pb2.Empty]:
373 r"""Return a callable for the delete bucket method over gRPC.
374
375 Deletes a log bucket.
376
377 Changes the bucket's ``lifecycle_state`` to the
378 ``DELETE_REQUESTED`` state. After 7 days, the bucket will be
379 purged and all log entries in the bucket will be permanently
380 deleted.
381
382 Returns:
383 Callable[[~.DeleteBucketRequest],
384 ~.Empty]:
385 A function that, when called, will call the underlying RPC
386 on the server.
387 """
388 # Generate a "stub function" on-the-fly which will actually make
389 # the request.
390 # gRPC handles serialization and deserialization, so we just need
391 # to pass in the functions for each.
392 if "delete_bucket" not in self._stubs:
393 self._stubs["delete_bucket"] = self.grpc_channel.unary_unary(
394 "/google.logging.v2.ConfigServiceV2/DeleteBucket",
395 request_serializer=logging_config.DeleteBucketRequest.serialize,
396 response_deserializer=empty_pb2.Empty.FromString,
397 )
398 return self._stubs["delete_bucket"]
399
400 @property
401 def undelete_bucket(
402 self,
403 ) -> Callable[[logging_config.UndeleteBucketRequest], empty_pb2.Empty]:
404 r"""Return a callable for the undelete bucket method over gRPC.
405
406 Undeletes a log bucket. A bucket that has been
407 deleted can be undeleted within the grace period of 7
408 days.
409
410 Returns:
411 Callable[[~.UndeleteBucketRequest],
412 ~.Empty]:
413 A function that, when called, will call the underlying RPC
414 on the server.
415 """
416 # Generate a "stub function" on-the-fly which will actually make
417 # the request.
418 # gRPC handles serialization and deserialization, so we just need
419 # to pass in the functions for each.
420 if "undelete_bucket" not in self._stubs:
421 self._stubs["undelete_bucket"] = self.grpc_channel.unary_unary(
422 "/google.logging.v2.ConfigServiceV2/UndeleteBucket",
423 request_serializer=logging_config.UndeleteBucketRequest.serialize,
424 response_deserializer=empty_pb2.Empty.FromString,
425 )
426 return self._stubs["undelete_bucket"]
427
428 @property
429 def list_views(
430 self,
431 ) -> Callable[[logging_config.ListViewsRequest], logging_config.ListViewsResponse]:
432 r"""Return a callable for the list views method over gRPC.
433
434 Lists views on a log bucket.
435
436 Returns:
437 Callable[[~.ListViewsRequest],
438 ~.ListViewsResponse]:
439 A function that, when called, will call the underlying RPC
440 on the server.
441 """
442 # Generate a "stub function" on-the-fly which will actually make
443 # the request.
444 # gRPC handles serialization and deserialization, so we just need
445 # to pass in the functions for each.
446 if "list_views" not in self._stubs:
447 self._stubs["list_views"] = self.grpc_channel.unary_unary(
448 "/google.logging.v2.ConfigServiceV2/ListViews",
449 request_serializer=logging_config.ListViewsRequest.serialize,
450 response_deserializer=logging_config.ListViewsResponse.deserialize,
451 )
452 return self._stubs["list_views"]
453
454 @property
455 def get_view(
456 self,
457 ) -> Callable[[logging_config.GetViewRequest], logging_config.LogView]:
458 r"""Return a callable for the get view method over gRPC.
459
460 Gets a view on a log bucket..
461
462 Returns:
463 Callable[[~.GetViewRequest],
464 ~.LogView]:
465 A function that, when called, will call the underlying RPC
466 on the server.
467 """
468 # Generate a "stub function" on-the-fly which will actually make
469 # the request.
470 # gRPC handles serialization and deserialization, so we just need
471 # to pass in the functions for each.
472 if "get_view" not in self._stubs:
473 self._stubs["get_view"] = self.grpc_channel.unary_unary(
474 "/google.logging.v2.ConfigServiceV2/GetView",
475 request_serializer=logging_config.GetViewRequest.serialize,
476 response_deserializer=logging_config.LogView.deserialize,
477 )
478 return self._stubs["get_view"]
479
480 @property
481 def create_view(
482 self,
483 ) -> Callable[[logging_config.CreateViewRequest], logging_config.LogView]:
484 r"""Return a callable for the create view method over gRPC.
485
486 Creates a view over log entries in a log bucket. A
487 bucket may contain a maximum of 30 views.
488
489 Returns:
490 Callable[[~.CreateViewRequest],
491 ~.LogView]:
492 A function that, when called, will call the underlying RPC
493 on the server.
494 """
495 # Generate a "stub function" on-the-fly which will actually make
496 # the request.
497 # gRPC handles serialization and deserialization, so we just need
498 # to pass in the functions for each.
499 if "create_view" not in self._stubs:
500 self._stubs["create_view"] = self.grpc_channel.unary_unary(
501 "/google.logging.v2.ConfigServiceV2/CreateView",
502 request_serializer=logging_config.CreateViewRequest.serialize,
503 response_deserializer=logging_config.LogView.deserialize,
504 )
505 return self._stubs["create_view"]
506
507 @property
508 def update_view(
509 self,
510 ) -> Callable[[logging_config.UpdateViewRequest], logging_config.LogView]:
511 r"""Return a callable for the update view method over gRPC.
512
513 Updates a view on a log bucket. This method replaces the
514 following fields in the existing view with values from the new
515 view: ``filter``. If an ``UNAVAILABLE`` error is returned, this
516 indicates that system is not in a state where it can update the
517 view. If this occurs, please try again in a few minutes.
518
519 Returns:
520 Callable[[~.UpdateViewRequest],
521 ~.LogView]:
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_view" not in self._stubs:
530 self._stubs["update_view"] = self.grpc_channel.unary_unary(
531 "/google.logging.v2.ConfigServiceV2/UpdateView",
532 request_serializer=logging_config.UpdateViewRequest.serialize,
533 response_deserializer=logging_config.LogView.deserialize,
534 )
535 return self._stubs["update_view"]
536
537 @property
538 def delete_view(
539 self,
540 ) -> Callable[[logging_config.DeleteViewRequest], empty_pb2.Empty]:
541 r"""Return a callable for the delete view method over gRPC.
542
543 Deletes a view on a log bucket. If an ``UNAVAILABLE`` error is
544 returned, this indicates that system is not in a state where it
545 can delete the view. If this occurs, please try again in a few
546 minutes.
547
548 Returns:
549 Callable[[~.DeleteViewRequest],
550 ~.Empty]:
551 A function that, when called, will call the underlying RPC
552 on the server.
553 """
554 # Generate a "stub function" on-the-fly which will actually make
555 # the request.
556 # gRPC handles serialization and deserialization, so we just need
557 # to pass in the functions for each.
558 if "delete_view" not in self._stubs:
559 self._stubs["delete_view"] = self.grpc_channel.unary_unary(
560 "/google.logging.v2.ConfigServiceV2/DeleteView",
561 request_serializer=logging_config.DeleteViewRequest.serialize,
562 response_deserializer=empty_pb2.Empty.FromString,
563 )
564 return self._stubs["delete_view"]
565
566 @property
567 def list_sinks(
568 self,
569 ) -> Callable[[logging_config.ListSinksRequest], logging_config.ListSinksResponse]:
570 r"""Return a callable for the list sinks method over gRPC.
571
572 Lists sinks.
573
574 Returns:
575 Callable[[~.ListSinksRequest],
576 ~.ListSinksResponse]:
577 A function that, when called, will call the underlying RPC
578 on the server.
579 """
580 # Generate a "stub function" on-the-fly which will actually make
581 # the request.
582 # gRPC handles serialization and deserialization, so we just need
583 # to pass in the functions for each.
584 if "list_sinks" not in self._stubs:
585 self._stubs["list_sinks"] = self.grpc_channel.unary_unary(
586 "/google.logging.v2.ConfigServiceV2/ListSinks",
587 request_serializer=logging_config.ListSinksRequest.serialize,
588 response_deserializer=logging_config.ListSinksResponse.deserialize,
589 )
590 return self._stubs["list_sinks"]
591
592 @property
593 def get_sink(
594 self,
595 ) -> Callable[[logging_config.GetSinkRequest], logging_config.LogSink]:
596 r"""Return a callable for the get sink method over gRPC.
597
598 Gets a sink.
599
600 Returns:
601 Callable[[~.GetSinkRequest],
602 ~.LogSink]:
603 A function that, when called, will call the underlying RPC
604 on the server.
605 """
606 # Generate a "stub function" on-the-fly which will actually make
607 # the request.
608 # gRPC handles serialization and deserialization, so we just need
609 # to pass in the functions for each.
610 if "get_sink" not in self._stubs:
611 self._stubs["get_sink"] = self.grpc_channel.unary_unary(
612 "/google.logging.v2.ConfigServiceV2/GetSink",
613 request_serializer=logging_config.GetSinkRequest.serialize,
614 response_deserializer=logging_config.LogSink.deserialize,
615 )
616 return self._stubs["get_sink"]
617
618 @property
619 def create_sink(
620 self,
621 ) -> Callable[[logging_config.CreateSinkRequest], logging_config.LogSink]:
622 r"""Return a callable for the create sink method over gRPC.
623
624 Creates a sink that exports specified log entries to a
625 destination. The export of newly-ingested log entries begins
626 immediately, unless the sink's ``writer_identity`` is not
627 permitted to write to the destination. A sink can export log
628 entries only from the resource owning the sink.
629
630 Returns:
631 Callable[[~.CreateSinkRequest],
632 ~.LogSink]:
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 "create_sink" not in self._stubs:
641 self._stubs["create_sink"] = self.grpc_channel.unary_unary(
642 "/google.logging.v2.ConfigServiceV2/CreateSink",
643 request_serializer=logging_config.CreateSinkRequest.serialize,
644 response_deserializer=logging_config.LogSink.deserialize,
645 )
646 return self._stubs["create_sink"]
647
648 @property
649 def update_sink(
650 self,
651 ) -> Callable[[logging_config.UpdateSinkRequest], logging_config.LogSink]:
652 r"""Return a callable for the update sink method over gRPC.
653
654 Updates a sink. This method replaces the following fields in the
655 existing sink with values from the new sink: ``destination``,
656 and ``filter``.
657
658 The updated sink might also have a new ``writer_identity``; see
659 the ``unique_writer_identity`` field.
660
661 Returns:
662 Callable[[~.UpdateSinkRequest],
663 ~.LogSink]:
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 "update_sink" not in self._stubs:
672 self._stubs["update_sink"] = self.grpc_channel.unary_unary(
673 "/google.logging.v2.ConfigServiceV2/UpdateSink",
674 request_serializer=logging_config.UpdateSinkRequest.serialize,
675 response_deserializer=logging_config.LogSink.deserialize,
676 )
677 return self._stubs["update_sink"]
678
679 @property
680 def delete_sink(
681 self,
682 ) -> Callable[[logging_config.DeleteSinkRequest], empty_pb2.Empty]:
683 r"""Return a callable for the delete sink method over gRPC.
684
685 Deletes a sink. If the sink has a unique ``writer_identity``,
686 then that service account is also deleted.
687
688 Returns:
689 Callable[[~.DeleteSinkRequest],
690 ~.Empty]:
691 A function that, when called, will call the underlying RPC
692 on the server.
693 """
694 # Generate a "stub function" on-the-fly which will actually make
695 # the request.
696 # gRPC handles serialization and deserialization, so we just need
697 # to pass in the functions for each.
698 if "delete_sink" not in self._stubs:
699 self._stubs["delete_sink"] = self.grpc_channel.unary_unary(
700 "/google.logging.v2.ConfigServiceV2/DeleteSink",
701 request_serializer=logging_config.DeleteSinkRequest.serialize,
702 response_deserializer=empty_pb2.Empty.FromString,
703 )
704 return self._stubs["delete_sink"]
705
706 @property
707 def list_exclusions(
708 self,
709 ) -> Callable[
710 [logging_config.ListExclusionsRequest], logging_config.ListExclusionsResponse
711 ]:
712 r"""Return a callable for the list exclusions method over gRPC.
713
714 Lists all the exclusions on the \_Default sink in a parent
715 resource.
716
717 Returns:
718 Callable[[~.ListExclusionsRequest],
719 ~.ListExclusionsResponse]:
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 "list_exclusions" not in self._stubs:
728 self._stubs["list_exclusions"] = self.grpc_channel.unary_unary(
729 "/google.logging.v2.ConfigServiceV2/ListExclusions",
730 request_serializer=logging_config.ListExclusionsRequest.serialize,
731 response_deserializer=logging_config.ListExclusionsResponse.deserialize,
732 )
733 return self._stubs["list_exclusions"]
734
735 @property
736 def get_exclusion(
737 self,
738 ) -> Callable[[logging_config.GetExclusionRequest], logging_config.LogExclusion]:
739 r"""Return a callable for the get exclusion method over gRPC.
740
741 Gets the description of an exclusion in the \_Default sink.
742
743 Returns:
744 Callable[[~.GetExclusionRequest],
745 ~.LogExclusion]:
746 A function that, when called, will call the underlying RPC
747 on the server.
748 """
749 # Generate a "stub function" on-the-fly which will actually make
750 # the request.
751 # gRPC handles serialization and deserialization, so we just need
752 # to pass in the functions for each.
753 if "get_exclusion" not in self._stubs:
754 self._stubs["get_exclusion"] = self.grpc_channel.unary_unary(
755 "/google.logging.v2.ConfigServiceV2/GetExclusion",
756 request_serializer=logging_config.GetExclusionRequest.serialize,
757 response_deserializer=logging_config.LogExclusion.deserialize,
758 )
759 return self._stubs["get_exclusion"]
760
761 @property
762 def create_exclusion(
763 self,
764 ) -> Callable[[logging_config.CreateExclusionRequest], logging_config.LogExclusion]:
765 r"""Return a callable for the create exclusion method over gRPC.
766
767 Creates a new exclusion in the \_Default sink in a specified
768 parent resource. Only log entries belonging to that resource can
769 be excluded. You can have up to 10 exclusions in a resource.
770
771 Returns:
772 Callable[[~.CreateExclusionRequest],
773 ~.LogExclusion]:
774 A function that, when called, will call the underlying RPC
775 on the server.
776 """
777 # Generate a "stub function" on-the-fly which will actually make
778 # the request.
779 # gRPC handles serialization and deserialization, so we just need
780 # to pass in the functions for each.
781 if "create_exclusion" not in self._stubs:
782 self._stubs["create_exclusion"] = self.grpc_channel.unary_unary(
783 "/google.logging.v2.ConfigServiceV2/CreateExclusion",
784 request_serializer=logging_config.CreateExclusionRequest.serialize,
785 response_deserializer=logging_config.LogExclusion.deserialize,
786 )
787 return self._stubs["create_exclusion"]
788
789 @property
790 def update_exclusion(
791 self,
792 ) -> Callable[[logging_config.UpdateExclusionRequest], logging_config.LogExclusion]:
793 r"""Return a callable for the update exclusion method over gRPC.
794
795 Changes one or more properties of an existing exclusion in the
796 \_Default sink.
797
798 Returns:
799 Callable[[~.UpdateExclusionRequest],
800 ~.LogExclusion]:
801 A function that, when called, will call the underlying RPC
802 on the server.
803 """
804 # Generate a "stub function" on-the-fly which will actually make
805 # the request.
806 # gRPC handles serialization and deserialization, so we just need
807 # to pass in the functions for each.
808 if "update_exclusion" not in self._stubs:
809 self._stubs["update_exclusion"] = self.grpc_channel.unary_unary(
810 "/google.logging.v2.ConfigServiceV2/UpdateExclusion",
811 request_serializer=logging_config.UpdateExclusionRequest.serialize,
812 response_deserializer=logging_config.LogExclusion.deserialize,
813 )
814 return self._stubs["update_exclusion"]
815
816 @property
817 def delete_exclusion(
818 self,
819 ) -> Callable[[logging_config.DeleteExclusionRequest], empty_pb2.Empty]:
820 r"""Return a callable for the delete exclusion method over gRPC.
821
822 Deletes an exclusion in the \_Default sink.
823
824 Returns:
825 Callable[[~.DeleteExclusionRequest],
826 ~.Empty]:
827 A function that, when called, will call the underlying RPC
828 on the server.
829 """
830 # Generate a "stub function" on-the-fly which will actually make
831 # the request.
832 # gRPC handles serialization and deserialization, so we just need
833 # to pass in the functions for each.
834 if "delete_exclusion" not in self._stubs:
835 self._stubs["delete_exclusion"] = self.grpc_channel.unary_unary(
836 "/google.logging.v2.ConfigServiceV2/DeleteExclusion",
837 request_serializer=logging_config.DeleteExclusionRequest.serialize,
838 response_deserializer=empty_pb2.Empty.FromString,
839 )
840 return self._stubs["delete_exclusion"]
841
842 @property
843 def get_cmek_settings(
844 self,
845 ) -> Callable[[logging_config.GetCmekSettingsRequest], logging_config.CmekSettings]:
846 r"""Return a callable for the get cmek settings method over gRPC.
847
848 Gets the Logging CMEK settings for the given resource.
849
850 Note: CMEK for the Log Router can be configured for Google Cloud
851 projects, folders, organizations and billing accounts. Once
852 configured for an organization, it applies to all projects and
853 folders in the Google Cloud organization.
854
855 See `Enabling CMEK for Log
856 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
857 for more information.
858
859 Returns:
860 Callable[[~.GetCmekSettingsRequest],
861 ~.CmekSettings]:
862 A function that, when called, will call the underlying RPC
863 on the server.
864 """
865 # Generate a "stub function" on-the-fly which will actually make
866 # the request.
867 # gRPC handles serialization and deserialization, so we just need
868 # to pass in the functions for each.
869 if "get_cmek_settings" not in self._stubs:
870 self._stubs["get_cmek_settings"] = self.grpc_channel.unary_unary(
871 "/google.logging.v2.ConfigServiceV2/GetCmekSettings",
872 request_serializer=logging_config.GetCmekSettingsRequest.serialize,
873 response_deserializer=logging_config.CmekSettings.deserialize,
874 )
875 return self._stubs["get_cmek_settings"]
876
877 @property
878 def update_cmek_settings(
879 self,
880 ) -> Callable[
881 [logging_config.UpdateCmekSettingsRequest], logging_config.CmekSettings
882 ]:
883 r"""Return a callable for the update cmek settings method over gRPC.
884
885 Updates the Log Router CMEK settings for the given resource.
886
887 Note: CMEK for the Log Router can currently only be configured
888 for Google Cloud organizations. Once configured, it applies to
889 all projects and folders in the Google Cloud organization.
890
891 [UpdateCmekSettings][google.logging.v2.ConfigServiceV2.UpdateCmekSettings]
892 will fail if 1) ``kms_key_name`` is invalid, or 2) the
893 associated service account does not have the required
894 ``roles/cloudkms.cryptoKeyEncrypterDecrypter`` role assigned for
895 the key, or 3) access to the key is disabled.
896
897 See `Enabling CMEK for Log
898 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
899 for more information.
900
901 Returns:
902 Callable[[~.UpdateCmekSettingsRequest],
903 ~.CmekSettings]:
904 A function that, when called, will call the underlying RPC
905 on the server.
906 """
907 # Generate a "stub function" on-the-fly which will actually make
908 # the request.
909 # gRPC handles serialization and deserialization, so we just need
910 # to pass in the functions for each.
911 if "update_cmek_settings" not in self._stubs:
912 self._stubs["update_cmek_settings"] = self.grpc_channel.unary_unary(
913 "/google.logging.v2.ConfigServiceV2/UpdateCmekSettings",
914 request_serializer=logging_config.UpdateCmekSettingsRequest.serialize,
915 response_deserializer=logging_config.CmekSettings.deserialize,
916 )
917 return self._stubs["update_cmek_settings"]
918
919 @property
920 def get_settings(
921 self,
922 ) -> Callable[[logging_config.GetSettingsRequest], logging_config.Settings]:
923 r"""Return a callable for the get settings method over gRPC.
924
925 Gets the Log Router settings for the given resource.
926
927 Note: Settings for the Log Router can be get for Google Cloud
928 projects, folders, organizations and billing accounts. Currently
929 it can only be configured for organizations. Once configured for
930 an organization, it applies to all projects and folders in the
931 Google Cloud organization.
932
933 See `Enabling CMEK for Log
934 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
935 for more information.
936
937 Returns:
938 Callable[[~.GetSettingsRequest],
939 ~.Settings]:
940 A function that, when called, will call the underlying RPC
941 on the server.
942 """
943 # Generate a "stub function" on-the-fly which will actually make
944 # the request.
945 # gRPC handles serialization and deserialization, so we just need
946 # to pass in the functions for each.
947 if "get_settings" not in self._stubs:
948 self._stubs["get_settings"] = self.grpc_channel.unary_unary(
949 "/google.logging.v2.ConfigServiceV2/GetSettings",
950 request_serializer=logging_config.GetSettingsRequest.serialize,
951 response_deserializer=logging_config.Settings.deserialize,
952 )
953 return self._stubs["get_settings"]
954
955 @property
956 def update_settings(
957 self,
958 ) -> Callable[[logging_config.UpdateSettingsRequest], logging_config.Settings]:
959 r"""Return a callable for the update settings method over gRPC.
960
961 Updates the Log Router settings for the given resource.
962
963 Note: Settings for the Log Router can currently only be
964 configured for Google Cloud organizations. Once configured, it
965 applies to all projects and folders in the Google Cloud
966 organization.
967
968 [UpdateSettings][google.logging.v2.ConfigServiceV2.UpdateSettings]
969 will fail if 1) ``kms_key_name`` is invalid, or 2) the
970 associated service account does not have the required
971 ``roles/cloudkms.cryptoKeyEncrypterDecrypter`` role assigned for
972 the key, or 3) access to the key is disabled. 4) ``location_id``
973 is not supported by Logging. 5) ``location_id`` violate
974 OrgPolicy.
975
976 See `Enabling CMEK for Log
977 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
978 for more information.
979
980 Returns:
981 Callable[[~.UpdateSettingsRequest],
982 ~.Settings]:
983 A function that, when called, will call the underlying RPC
984 on the server.
985 """
986 # Generate a "stub function" on-the-fly which will actually make
987 # the request.
988 # gRPC handles serialization and deserialization, so we just need
989 # to pass in the functions for each.
990 if "update_settings" not in self._stubs:
991 self._stubs["update_settings"] = self.grpc_channel.unary_unary(
992 "/google.logging.v2.ConfigServiceV2/UpdateSettings",
993 request_serializer=logging_config.UpdateSettingsRequest.serialize,
994 response_deserializer=logging_config.Settings.deserialize,
995 )
996 return self._stubs["update_settings"]
997
998 @property
999 def copy_log_entries(
1000 self,
1001 ) -> Callable[[logging_config.CopyLogEntriesRequest], operations_pb2.Operation]:
1002 r"""Return a callable for the copy log entries method over gRPC.
1003
1004 Copies a set of log entries from a log bucket to a
1005 Cloud Storage bucket.
1006
1007 Returns:
1008 Callable[[~.CopyLogEntriesRequest],
1009 ~.Operation]:
1010 A function that, when called, will call the underlying RPC
1011 on the server.
1012 """
1013 # Generate a "stub function" on-the-fly which will actually make
1014 # the request.
1015 # gRPC handles serialization and deserialization, so we just need
1016 # to pass in the functions for each.
1017 if "copy_log_entries" not in self._stubs:
1018 self._stubs["copy_log_entries"] = self.grpc_channel.unary_unary(
1019 "/google.logging.v2.ConfigServiceV2/CopyLogEntries",
1020 request_serializer=logging_config.CopyLogEntriesRequest.serialize,
1021 response_deserializer=operations_pb2.Operation.FromString,
1022 )
1023 return self._stubs["copy_log_entries"]
1024
1025 def close(self):
1026 self.grpc_channel.close()
1027
1028 @property
1029 def kind(self) -> str:
1030 return "grpc"
1031
1032
1033__all__ = ("ConfigServiceV2GrpcTransport",)