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#
16from collections import OrderedDict
17import functools
18import re
19from typing import (
20 Dict,
21 Mapping,
22 MutableMapping,
23 MutableSequence,
24 Optional,
25 Sequence,
26 Tuple,
27 Type,
28 Union,
29)
30
31from google.cloud.logging_v2 import gapic_version as package_version
32
33from google.api_core.client_options import ClientOptions
34from google.api_core import exceptions as core_exceptions
35from google.api_core import gapic_v1
36from google.api_core import retry as retries
37from google.auth import credentials as ga_credentials # type: ignore
38from google.oauth2 import service_account # type: ignore
39
40try:
41 OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
42except AttributeError: # pragma: NO COVER
43 OptionalRetry = Union[retries.Retry, object] # type: ignore
44
45from google.api_core import operation # type: ignore
46from google.api_core import operation_async # type: ignore
47from google.cloud.logging_v2.services.config_service_v2 import pagers
48from google.cloud.logging_v2.types import logging_config
49from google.longrunning import operations_pb2 # type: ignore
50from google.protobuf import empty_pb2 # type: ignore
51from google.protobuf import field_mask_pb2 # type: ignore
52from google.protobuf import timestamp_pb2 # type: ignore
53from .transports.base import ConfigServiceV2Transport, DEFAULT_CLIENT_INFO
54from .transports.grpc_asyncio import ConfigServiceV2GrpcAsyncIOTransport
55from .client import ConfigServiceV2Client
56
57
58class ConfigServiceV2AsyncClient:
59 """Service for configuring sinks used to route log entries."""
60
61 _client: ConfigServiceV2Client
62
63 DEFAULT_ENDPOINT = ConfigServiceV2Client.DEFAULT_ENDPOINT
64 DEFAULT_MTLS_ENDPOINT = ConfigServiceV2Client.DEFAULT_MTLS_ENDPOINT
65
66 cmek_settings_path = staticmethod(ConfigServiceV2Client.cmek_settings_path)
67 parse_cmek_settings_path = staticmethod(
68 ConfigServiceV2Client.parse_cmek_settings_path
69 )
70 link_path = staticmethod(ConfigServiceV2Client.link_path)
71 parse_link_path = staticmethod(ConfigServiceV2Client.parse_link_path)
72 log_bucket_path = staticmethod(ConfigServiceV2Client.log_bucket_path)
73 parse_log_bucket_path = staticmethod(ConfigServiceV2Client.parse_log_bucket_path)
74 log_exclusion_path = staticmethod(ConfigServiceV2Client.log_exclusion_path)
75 parse_log_exclusion_path = staticmethod(
76 ConfigServiceV2Client.parse_log_exclusion_path
77 )
78 log_sink_path = staticmethod(ConfigServiceV2Client.log_sink_path)
79 parse_log_sink_path = staticmethod(ConfigServiceV2Client.parse_log_sink_path)
80 log_view_path = staticmethod(ConfigServiceV2Client.log_view_path)
81 parse_log_view_path = staticmethod(ConfigServiceV2Client.parse_log_view_path)
82 settings_path = staticmethod(ConfigServiceV2Client.settings_path)
83 parse_settings_path = staticmethod(ConfigServiceV2Client.parse_settings_path)
84 common_billing_account_path = staticmethod(
85 ConfigServiceV2Client.common_billing_account_path
86 )
87 parse_common_billing_account_path = staticmethod(
88 ConfigServiceV2Client.parse_common_billing_account_path
89 )
90 common_folder_path = staticmethod(ConfigServiceV2Client.common_folder_path)
91 parse_common_folder_path = staticmethod(
92 ConfigServiceV2Client.parse_common_folder_path
93 )
94 common_organization_path = staticmethod(
95 ConfigServiceV2Client.common_organization_path
96 )
97 parse_common_organization_path = staticmethod(
98 ConfigServiceV2Client.parse_common_organization_path
99 )
100 common_project_path = staticmethod(ConfigServiceV2Client.common_project_path)
101 parse_common_project_path = staticmethod(
102 ConfigServiceV2Client.parse_common_project_path
103 )
104 common_location_path = staticmethod(ConfigServiceV2Client.common_location_path)
105 parse_common_location_path = staticmethod(
106 ConfigServiceV2Client.parse_common_location_path
107 )
108
109 @classmethod
110 def from_service_account_info(cls, info: dict, *args, **kwargs):
111 """Creates an instance of this client using the provided credentials
112 info.
113
114 Args:
115 info (dict): The service account private key info.
116 args: Additional arguments to pass to the constructor.
117 kwargs: Additional arguments to pass to the constructor.
118
119 Returns:
120 ConfigServiceV2AsyncClient: The constructed client.
121 """
122 return ConfigServiceV2Client.from_service_account_info.__func__(ConfigServiceV2AsyncClient, info, *args, **kwargs) # type: ignore
123
124 @classmethod
125 def from_service_account_file(cls, filename: str, *args, **kwargs):
126 """Creates an instance of this client using the provided credentials
127 file.
128
129 Args:
130 filename (str): The path to the service account private key json
131 file.
132 args: Additional arguments to pass to the constructor.
133 kwargs: Additional arguments to pass to the constructor.
134
135 Returns:
136 ConfigServiceV2AsyncClient: The constructed client.
137 """
138 return ConfigServiceV2Client.from_service_account_file.__func__(ConfigServiceV2AsyncClient, filename, *args, **kwargs) # type: ignore
139
140 from_service_account_json = from_service_account_file
141
142 @classmethod
143 def get_mtls_endpoint_and_cert_source(
144 cls, client_options: Optional[ClientOptions] = None
145 ):
146 """Return the API endpoint and client cert source for mutual TLS.
147
148 The client cert source is determined in the following order:
149 (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
150 client cert source is None.
151 (2) if `client_options.client_cert_source` is provided, use the provided one; if the
152 default client cert source exists, use the default one; otherwise the client cert
153 source is None.
154
155 The API endpoint is determined in the following order:
156 (1) if `client_options.api_endpoint` if provided, use the provided one.
157 (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
158 default mTLS endpoint; if the environment variable is "never", use the default API
159 endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
160 use the default API endpoint.
161
162 More details can be found at https://google.aip.dev/auth/4114.
163
164 Args:
165 client_options (google.api_core.client_options.ClientOptions): Custom options for the
166 client. Only the `api_endpoint` and `client_cert_source` properties may be used
167 in this method.
168
169 Returns:
170 Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
171 client cert source to use.
172
173 Raises:
174 google.auth.exceptions.MutualTLSChannelError: If any errors happen.
175 """
176 return ConfigServiceV2Client.get_mtls_endpoint_and_cert_source(client_options) # type: ignore
177
178 @property
179 def transport(self) -> ConfigServiceV2Transport:
180 """Returns the transport used by the client instance.
181
182 Returns:
183 ConfigServiceV2Transport: The transport used by the client instance.
184 """
185 return self._client.transport
186
187 get_transport_class = functools.partial(
188 type(ConfigServiceV2Client).get_transport_class, type(ConfigServiceV2Client)
189 )
190
191 def __init__(
192 self,
193 *,
194 credentials: Optional[ga_credentials.Credentials] = None,
195 transport: Union[str, ConfigServiceV2Transport] = "grpc_asyncio",
196 client_options: Optional[ClientOptions] = None,
197 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
198 ) -> None:
199 """Instantiates the config service v2 client.
200
201 Args:
202 credentials (Optional[google.auth.credentials.Credentials]): The
203 authorization credentials to attach to requests. These
204 credentials identify the application to the service; if none
205 are specified, the client will attempt to ascertain the
206 credentials from the environment.
207 transport (Union[str, ~.ConfigServiceV2Transport]): The
208 transport to use. If set to None, a transport is chosen
209 automatically.
210 client_options (ClientOptions): Custom options for the client. It
211 won't take effect if a ``transport`` instance is provided.
212 (1) The ``api_endpoint`` property can be used to override the
213 default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
214 environment variable can also be used to override the endpoint:
215 "always" (always use the default mTLS endpoint), "never" (always
216 use the default regular endpoint) and "auto" (auto switch to the
217 default mTLS endpoint if client certificate is present, this is
218 the default value). However, the ``api_endpoint`` property takes
219 precedence if provided.
220 (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
221 is "true", then the ``client_cert_source`` property can be used
222 to provide client certificate for mutual TLS transport. If
223 not provided, the default SSL client certificate will be used if
224 present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
225 set, no client certificate will be used.
226
227 Raises:
228 google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
229 creation failed for any reason.
230 """
231 self._client = ConfigServiceV2Client(
232 credentials=credentials,
233 transport=transport,
234 client_options=client_options,
235 client_info=client_info,
236 )
237
238 async def list_buckets(
239 self,
240 request: Optional[Union[logging_config.ListBucketsRequest, dict]] = None,
241 *,
242 parent: Optional[str] = None,
243 retry: OptionalRetry = gapic_v1.method.DEFAULT,
244 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
245 metadata: Sequence[Tuple[str, str]] = (),
246 ) -> pagers.ListBucketsAsyncPager:
247 r"""Lists log buckets.
248
249 .. code-block:: python
250
251 # This snippet has been automatically generated and should be regarded as a
252 # code template only.
253 # It will require modifications to work:
254 # - It may require correct/in-range values for request initialization.
255 # - It may require specifying regional endpoints when creating the service
256 # client as shown in:
257 # https://googleapis.dev/python/google-api-core/latest/client_options.html
258 from google.cloud import logging_v2
259
260 async def sample_list_buckets():
261 # Create a client
262 client = logging_v2.ConfigServiceV2AsyncClient()
263
264 # Initialize request argument(s)
265 request = logging_v2.ListBucketsRequest(
266 parent="parent_value",
267 )
268
269 # Make the request
270 page_result = client.list_buckets(request=request)
271
272 # Handle the response
273 async for response in page_result:
274 print(response)
275
276 Args:
277 request (Optional[Union[google.cloud.logging_v2.types.ListBucketsRequest, dict]]):
278 The request object. The parameters to ``ListBuckets``.
279 parent (:class:`str`):
280 Required. The parent resource whose buckets are to be
281 listed:
282
283 ::
284
285 "projects/[PROJECT_ID]/locations/[LOCATION_ID]"
286 "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]"
287 "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]"
288 "folders/[FOLDER_ID]/locations/[LOCATION_ID]"
289
290 Note: The locations portion of the resource must be
291 specified, but supplying the character ``-`` in place of
292 [LOCATION_ID] will return all buckets.
293
294 This corresponds to the ``parent`` field
295 on the ``request`` instance; if ``request`` is provided, this
296 should not be set.
297 retry (google.api_core.retry.Retry): Designation of what errors, if any,
298 should be retried.
299 timeout (float): The timeout for this request.
300 metadata (Sequence[Tuple[str, str]]): Strings which should be
301 sent along with the request as metadata.
302
303 Returns:
304 google.cloud.logging_v2.services.config_service_v2.pagers.ListBucketsAsyncPager:
305 The response from ListBuckets.
306
307 Iterating over this object will yield
308 results and resolve additional pages
309 automatically.
310
311 """
312 # Create or coerce a protobuf request object.
313 # Quick check: If we got a request object, we should *not* have
314 # gotten any keyword arguments that map to the request.
315 has_flattened_params = any([parent])
316 if request is not None and has_flattened_params:
317 raise ValueError(
318 "If the `request` argument is set, then none of "
319 "the individual field arguments should be set."
320 )
321
322 request = logging_config.ListBucketsRequest(request)
323
324 # If we have keyword arguments corresponding to fields on the
325 # request, apply these.
326 if parent is not None:
327 request.parent = parent
328
329 # Wrap the RPC method; this adds retry and timeout information,
330 # and friendly error handling.
331 rpc = gapic_v1.method_async.wrap_method(
332 self._client._transport.list_buckets,
333 default_timeout=None,
334 client_info=DEFAULT_CLIENT_INFO,
335 )
336
337 # Certain fields should be provided within the metadata header;
338 # add these here.
339 metadata = tuple(metadata) + (
340 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
341 )
342
343 # Send the request.
344 response = await rpc(
345 request,
346 retry=retry,
347 timeout=timeout,
348 metadata=metadata,
349 )
350
351 # This method is paged; wrap the response in a pager, which provides
352 # an `__aiter__` convenience method.
353 response = pagers.ListBucketsAsyncPager(
354 method=rpc,
355 request=request,
356 response=response,
357 metadata=metadata,
358 )
359
360 # Done; return the response.
361 return response
362
363 async def get_bucket(
364 self,
365 request: Optional[Union[logging_config.GetBucketRequest, dict]] = None,
366 *,
367 retry: OptionalRetry = gapic_v1.method.DEFAULT,
368 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
369 metadata: Sequence[Tuple[str, str]] = (),
370 ) -> logging_config.LogBucket:
371 r"""Gets a log bucket.
372
373 .. code-block:: python
374
375 # This snippet has been automatically generated and should be regarded as a
376 # code template only.
377 # It will require modifications to work:
378 # - It may require correct/in-range values for request initialization.
379 # - It may require specifying regional endpoints when creating the service
380 # client as shown in:
381 # https://googleapis.dev/python/google-api-core/latest/client_options.html
382 from google.cloud import logging_v2
383
384 async def sample_get_bucket():
385 # Create a client
386 client = logging_v2.ConfigServiceV2AsyncClient()
387
388 # Initialize request argument(s)
389 request = logging_v2.GetBucketRequest(
390 name="name_value",
391 )
392
393 # Make the request
394 response = await client.get_bucket(request=request)
395
396 # Handle the response
397 print(response)
398
399 Args:
400 request (Optional[Union[google.cloud.logging_v2.types.GetBucketRequest, dict]]):
401 The request object. The parameters to ``GetBucket``.
402 retry (google.api_core.retry.Retry): Designation of what errors, if any,
403 should be retried.
404 timeout (float): The timeout for this request.
405 metadata (Sequence[Tuple[str, str]]): Strings which should be
406 sent along with the request as metadata.
407
408 Returns:
409 google.cloud.logging_v2.types.LogBucket:
410 Describes a repository in which log
411 entries are stored.
412
413 """
414 # Create or coerce a protobuf request object.
415 request = logging_config.GetBucketRequest(request)
416
417 # Wrap the RPC method; this adds retry and timeout information,
418 # and friendly error handling.
419 rpc = gapic_v1.method_async.wrap_method(
420 self._client._transport.get_bucket,
421 default_timeout=None,
422 client_info=DEFAULT_CLIENT_INFO,
423 )
424
425 # Certain fields should be provided within the metadata header;
426 # add these here.
427 metadata = tuple(metadata) + (
428 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
429 )
430
431 # Send the request.
432 response = await rpc(
433 request,
434 retry=retry,
435 timeout=timeout,
436 metadata=metadata,
437 )
438
439 # Done; return the response.
440 return response
441
442 async def create_bucket_async(
443 self,
444 request: Optional[Union[logging_config.CreateBucketRequest, dict]] = None,
445 *,
446 retry: OptionalRetry = gapic_v1.method.DEFAULT,
447 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
448 metadata: Sequence[Tuple[str, str]] = (),
449 ) -> operation_async.AsyncOperation:
450 r"""Creates a log bucket asynchronously that can be used
451 to store log entries.
452 After a bucket has been created, the bucket's location
453 cannot be changed.
454
455 .. code-block:: python
456
457 # This snippet has been automatically generated and should be regarded as a
458 # code template only.
459 # It will require modifications to work:
460 # - It may require correct/in-range values for request initialization.
461 # - It may require specifying regional endpoints when creating the service
462 # client as shown in:
463 # https://googleapis.dev/python/google-api-core/latest/client_options.html
464 from google.cloud import logging_v2
465
466 async def sample_create_bucket_async():
467 # Create a client
468 client = logging_v2.ConfigServiceV2AsyncClient()
469
470 # Initialize request argument(s)
471 request = logging_v2.CreateBucketRequest(
472 parent="parent_value",
473 bucket_id="bucket_id_value",
474 )
475
476 # Make the request
477 operation = client.create_bucket_async(request=request)
478
479 print("Waiting for operation to complete...")
480
481 response = (await operation).result()
482
483 # Handle the response
484 print(response)
485
486 Args:
487 request (Optional[Union[google.cloud.logging_v2.types.CreateBucketRequest, dict]]):
488 The request object. The parameters to ``CreateBucket``.
489 retry (google.api_core.retry.Retry): Designation of what errors, if any,
490 should be retried.
491 timeout (float): The timeout for this request.
492 metadata (Sequence[Tuple[str, str]]): Strings which should be
493 sent along with the request as metadata.
494
495 Returns:
496 google.api_core.operation_async.AsyncOperation:
497 An object representing a long-running operation.
498
499 The result type for the operation will be
500 :class:`google.cloud.logging_v2.types.LogBucket`
501 Describes a repository in which log entries are stored.
502
503 """
504 # Create or coerce a protobuf request object.
505 request = logging_config.CreateBucketRequest(request)
506
507 # Wrap the RPC method; this adds retry and timeout information,
508 # and friendly error handling.
509 rpc = gapic_v1.method_async.wrap_method(
510 self._client._transport.create_bucket_async,
511 default_timeout=None,
512 client_info=DEFAULT_CLIENT_INFO,
513 )
514
515 # Certain fields should be provided within the metadata header;
516 # add these here.
517 metadata = tuple(metadata) + (
518 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
519 )
520
521 # Send the request.
522 response = await rpc(
523 request,
524 retry=retry,
525 timeout=timeout,
526 metadata=metadata,
527 )
528
529 # Wrap the response in an operation future.
530 response = operation_async.from_gapic(
531 response,
532 self._client._transport.operations_client,
533 logging_config.LogBucket,
534 metadata_type=logging_config.BucketMetadata,
535 )
536
537 # Done; return the response.
538 return response
539
540 async def update_bucket_async(
541 self,
542 request: Optional[Union[logging_config.UpdateBucketRequest, dict]] = None,
543 *,
544 retry: OptionalRetry = gapic_v1.method.DEFAULT,
545 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
546 metadata: Sequence[Tuple[str, str]] = (),
547 ) -> operation_async.AsyncOperation:
548 r"""Updates a log bucket asynchronously.
549
550 If the bucket has a ``lifecycle_state`` of ``DELETE_REQUESTED``,
551 then ``FAILED_PRECONDITION`` will be returned.
552
553 After a bucket has been created, the bucket's location cannot be
554 changed.
555
556 .. code-block:: python
557
558 # This snippet has been automatically generated and should be regarded as a
559 # code template only.
560 # It will require modifications to work:
561 # - It may require correct/in-range values for request initialization.
562 # - It may require specifying regional endpoints when creating the service
563 # client as shown in:
564 # https://googleapis.dev/python/google-api-core/latest/client_options.html
565 from google.cloud import logging_v2
566
567 async def sample_update_bucket_async():
568 # Create a client
569 client = logging_v2.ConfigServiceV2AsyncClient()
570
571 # Initialize request argument(s)
572 request = logging_v2.UpdateBucketRequest(
573 name="name_value",
574 )
575
576 # Make the request
577 operation = client.update_bucket_async(request=request)
578
579 print("Waiting for operation to complete...")
580
581 response = (await operation).result()
582
583 # Handle the response
584 print(response)
585
586 Args:
587 request (Optional[Union[google.cloud.logging_v2.types.UpdateBucketRequest, dict]]):
588 The request object. The parameters to ``UpdateBucket``.
589 retry (google.api_core.retry.Retry): Designation of what errors, if any,
590 should be retried.
591 timeout (float): The timeout for this request.
592 metadata (Sequence[Tuple[str, str]]): Strings which should be
593 sent along with the request as metadata.
594
595 Returns:
596 google.api_core.operation_async.AsyncOperation:
597 An object representing a long-running operation.
598
599 The result type for the operation will be
600 :class:`google.cloud.logging_v2.types.LogBucket`
601 Describes a repository in which log entries are stored.
602
603 """
604 # Create or coerce a protobuf request object.
605 request = logging_config.UpdateBucketRequest(request)
606
607 # Wrap the RPC method; this adds retry and timeout information,
608 # and friendly error handling.
609 rpc = gapic_v1.method_async.wrap_method(
610 self._client._transport.update_bucket_async,
611 default_timeout=None,
612 client_info=DEFAULT_CLIENT_INFO,
613 )
614
615 # Certain fields should be provided within the metadata header;
616 # add these here.
617 metadata = tuple(metadata) + (
618 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
619 )
620
621 # Send the request.
622 response = await rpc(
623 request,
624 retry=retry,
625 timeout=timeout,
626 metadata=metadata,
627 )
628
629 # Wrap the response in an operation future.
630 response = operation_async.from_gapic(
631 response,
632 self._client._transport.operations_client,
633 logging_config.LogBucket,
634 metadata_type=logging_config.BucketMetadata,
635 )
636
637 # Done; return the response.
638 return response
639
640 async def create_bucket(
641 self,
642 request: Optional[Union[logging_config.CreateBucketRequest, dict]] = None,
643 *,
644 retry: OptionalRetry = gapic_v1.method.DEFAULT,
645 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
646 metadata: Sequence[Tuple[str, str]] = (),
647 ) -> logging_config.LogBucket:
648 r"""Creates a log bucket that can be used to store log
649 entries. After a bucket has been created, the bucket's
650 location cannot be changed.
651
652 .. code-block:: python
653
654 # This snippet has been automatically generated and should be regarded as a
655 # code template only.
656 # It will require modifications to work:
657 # - It may require correct/in-range values for request initialization.
658 # - It may require specifying regional endpoints when creating the service
659 # client as shown in:
660 # https://googleapis.dev/python/google-api-core/latest/client_options.html
661 from google.cloud import logging_v2
662
663 async def sample_create_bucket():
664 # Create a client
665 client = logging_v2.ConfigServiceV2AsyncClient()
666
667 # Initialize request argument(s)
668 request = logging_v2.CreateBucketRequest(
669 parent="parent_value",
670 bucket_id="bucket_id_value",
671 )
672
673 # Make the request
674 response = await client.create_bucket(request=request)
675
676 # Handle the response
677 print(response)
678
679 Args:
680 request (Optional[Union[google.cloud.logging_v2.types.CreateBucketRequest, dict]]):
681 The request object. The parameters to ``CreateBucket``.
682 retry (google.api_core.retry.Retry): Designation of what errors, if any,
683 should be retried.
684 timeout (float): The timeout for this request.
685 metadata (Sequence[Tuple[str, str]]): Strings which should be
686 sent along with the request as metadata.
687
688 Returns:
689 google.cloud.logging_v2.types.LogBucket:
690 Describes a repository in which log
691 entries are stored.
692
693 """
694 # Create or coerce a protobuf request object.
695 request = logging_config.CreateBucketRequest(request)
696
697 # Wrap the RPC method; this adds retry and timeout information,
698 # and friendly error handling.
699 rpc = gapic_v1.method_async.wrap_method(
700 self._client._transport.create_bucket,
701 default_timeout=None,
702 client_info=DEFAULT_CLIENT_INFO,
703 )
704
705 # Certain fields should be provided within the metadata header;
706 # add these here.
707 metadata = tuple(metadata) + (
708 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
709 )
710
711 # Send the request.
712 response = await rpc(
713 request,
714 retry=retry,
715 timeout=timeout,
716 metadata=metadata,
717 )
718
719 # Done; return the response.
720 return response
721
722 async def update_bucket(
723 self,
724 request: Optional[Union[logging_config.UpdateBucketRequest, dict]] = None,
725 *,
726 retry: OptionalRetry = gapic_v1.method.DEFAULT,
727 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
728 metadata: Sequence[Tuple[str, str]] = (),
729 ) -> logging_config.LogBucket:
730 r"""Updates a log bucket.
731
732 If the bucket has a ``lifecycle_state`` of ``DELETE_REQUESTED``,
733 then ``FAILED_PRECONDITION`` will be returned.
734
735 After a bucket has been created, the bucket's location cannot be
736 changed.
737
738 .. code-block:: python
739
740 # This snippet has been automatically generated and should be regarded as a
741 # code template only.
742 # It will require modifications to work:
743 # - It may require correct/in-range values for request initialization.
744 # - It may require specifying regional endpoints when creating the service
745 # client as shown in:
746 # https://googleapis.dev/python/google-api-core/latest/client_options.html
747 from google.cloud import logging_v2
748
749 async def sample_update_bucket():
750 # Create a client
751 client = logging_v2.ConfigServiceV2AsyncClient()
752
753 # Initialize request argument(s)
754 request = logging_v2.UpdateBucketRequest(
755 name="name_value",
756 )
757
758 # Make the request
759 response = await client.update_bucket(request=request)
760
761 # Handle the response
762 print(response)
763
764 Args:
765 request (Optional[Union[google.cloud.logging_v2.types.UpdateBucketRequest, dict]]):
766 The request object. The parameters to ``UpdateBucket``.
767 retry (google.api_core.retry.Retry): Designation of what errors, if any,
768 should be retried.
769 timeout (float): The timeout for this request.
770 metadata (Sequence[Tuple[str, str]]): Strings which should be
771 sent along with the request as metadata.
772
773 Returns:
774 google.cloud.logging_v2.types.LogBucket:
775 Describes a repository in which log
776 entries are stored.
777
778 """
779 # Create or coerce a protobuf request object.
780 request = logging_config.UpdateBucketRequest(request)
781
782 # Wrap the RPC method; this adds retry and timeout information,
783 # and friendly error handling.
784 rpc = gapic_v1.method_async.wrap_method(
785 self._client._transport.update_bucket,
786 default_timeout=None,
787 client_info=DEFAULT_CLIENT_INFO,
788 )
789
790 # Certain fields should be provided within the metadata header;
791 # add these here.
792 metadata = tuple(metadata) + (
793 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
794 )
795
796 # Send the request.
797 response = await rpc(
798 request,
799 retry=retry,
800 timeout=timeout,
801 metadata=metadata,
802 )
803
804 # Done; return the response.
805 return response
806
807 async def delete_bucket(
808 self,
809 request: Optional[Union[logging_config.DeleteBucketRequest, dict]] = None,
810 *,
811 retry: OptionalRetry = gapic_v1.method.DEFAULT,
812 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
813 metadata: Sequence[Tuple[str, str]] = (),
814 ) -> None:
815 r"""Deletes a log bucket.
816
817 Changes the bucket's ``lifecycle_state`` to the
818 ``DELETE_REQUESTED`` state. After 7 days, the bucket will be
819 purged and all log entries in the bucket will be permanently
820 deleted.
821
822 .. code-block:: python
823
824 # This snippet has been automatically generated and should be regarded as a
825 # code template only.
826 # It will require modifications to work:
827 # - It may require correct/in-range values for request initialization.
828 # - It may require specifying regional endpoints when creating the service
829 # client as shown in:
830 # https://googleapis.dev/python/google-api-core/latest/client_options.html
831 from google.cloud import logging_v2
832
833 async def sample_delete_bucket():
834 # Create a client
835 client = logging_v2.ConfigServiceV2AsyncClient()
836
837 # Initialize request argument(s)
838 request = logging_v2.DeleteBucketRequest(
839 name="name_value",
840 )
841
842 # Make the request
843 await client.delete_bucket(request=request)
844
845 Args:
846 request (Optional[Union[google.cloud.logging_v2.types.DeleteBucketRequest, dict]]):
847 The request object. The parameters to ``DeleteBucket``.
848 retry (google.api_core.retry.Retry): Designation of what errors, if any,
849 should be retried.
850 timeout (float): The timeout for this request.
851 metadata (Sequence[Tuple[str, str]]): Strings which should be
852 sent along with the request as metadata.
853 """
854 # Create or coerce a protobuf request object.
855 request = logging_config.DeleteBucketRequest(request)
856
857 # Wrap the RPC method; this adds retry and timeout information,
858 # and friendly error handling.
859 rpc = gapic_v1.method_async.wrap_method(
860 self._client._transport.delete_bucket,
861 default_timeout=None,
862 client_info=DEFAULT_CLIENT_INFO,
863 )
864
865 # Certain fields should be provided within the metadata header;
866 # add these here.
867 metadata = tuple(metadata) + (
868 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
869 )
870
871 # Send the request.
872 await rpc(
873 request,
874 retry=retry,
875 timeout=timeout,
876 metadata=metadata,
877 )
878
879 async def undelete_bucket(
880 self,
881 request: Optional[Union[logging_config.UndeleteBucketRequest, dict]] = None,
882 *,
883 retry: OptionalRetry = gapic_v1.method.DEFAULT,
884 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
885 metadata: Sequence[Tuple[str, str]] = (),
886 ) -> None:
887 r"""Undeletes a log bucket. A bucket that has been
888 deleted can be undeleted within the grace period of 7
889 days.
890
891 .. code-block:: python
892
893 # This snippet has been automatically generated and should be regarded as a
894 # code template only.
895 # It will require modifications to work:
896 # - It may require correct/in-range values for request initialization.
897 # - It may require specifying regional endpoints when creating the service
898 # client as shown in:
899 # https://googleapis.dev/python/google-api-core/latest/client_options.html
900 from google.cloud import logging_v2
901
902 async def sample_undelete_bucket():
903 # Create a client
904 client = logging_v2.ConfigServiceV2AsyncClient()
905
906 # Initialize request argument(s)
907 request = logging_v2.UndeleteBucketRequest(
908 name="name_value",
909 )
910
911 # Make the request
912 await client.undelete_bucket(request=request)
913
914 Args:
915 request (Optional[Union[google.cloud.logging_v2.types.UndeleteBucketRequest, dict]]):
916 The request object. The parameters to ``UndeleteBucket``.
917 retry (google.api_core.retry.Retry): Designation of what errors, if any,
918 should be retried.
919 timeout (float): The timeout for this request.
920 metadata (Sequence[Tuple[str, str]]): Strings which should be
921 sent along with the request as metadata.
922 """
923 # Create or coerce a protobuf request object.
924 request = logging_config.UndeleteBucketRequest(request)
925
926 # Wrap the RPC method; this adds retry and timeout information,
927 # and friendly error handling.
928 rpc = gapic_v1.method_async.wrap_method(
929 self._client._transport.undelete_bucket,
930 default_timeout=None,
931 client_info=DEFAULT_CLIENT_INFO,
932 )
933
934 # Certain fields should be provided within the metadata header;
935 # add these here.
936 metadata = tuple(metadata) + (
937 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
938 )
939
940 # Send the request.
941 await rpc(
942 request,
943 retry=retry,
944 timeout=timeout,
945 metadata=metadata,
946 )
947
948 async def list_views(
949 self,
950 request: Optional[Union[logging_config.ListViewsRequest, dict]] = None,
951 *,
952 parent: Optional[str] = None,
953 retry: OptionalRetry = gapic_v1.method.DEFAULT,
954 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
955 metadata: Sequence[Tuple[str, str]] = (),
956 ) -> pagers.ListViewsAsyncPager:
957 r"""Lists views on a log bucket.
958
959 .. code-block:: python
960
961 # This snippet has been automatically generated and should be regarded as a
962 # code template only.
963 # It will require modifications to work:
964 # - It may require correct/in-range values for request initialization.
965 # - It may require specifying regional endpoints when creating the service
966 # client as shown in:
967 # https://googleapis.dev/python/google-api-core/latest/client_options.html
968 from google.cloud import logging_v2
969
970 async def sample_list_views():
971 # Create a client
972 client = logging_v2.ConfigServiceV2AsyncClient()
973
974 # Initialize request argument(s)
975 request = logging_v2.ListViewsRequest(
976 parent="parent_value",
977 )
978
979 # Make the request
980 page_result = client.list_views(request=request)
981
982 # Handle the response
983 async for response in page_result:
984 print(response)
985
986 Args:
987 request (Optional[Union[google.cloud.logging_v2.types.ListViewsRequest, dict]]):
988 The request object. The parameters to ``ListViews``.
989 parent (:class:`str`):
990 Required. The bucket whose views are to be listed:
991
992 ::
993
994 "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]"
995
996 This corresponds to the ``parent`` field
997 on the ``request`` instance; if ``request`` is provided, this
998 should not be set.
999 retry (google.api_core.retry.Retry): Designation of what errors, if any,
1000 should be retried.
1001 timeout (float): The timeout for this request.
1002 metadata (Sequence[Tuple[str, str]]): Strings which should be
1003 sent along with the request as metadata.
1004
1005 Returns:
1006 google.cloud.logging_v2.services.config_service_v2.pagers.ListViewsAsyncPager:
1007 The response from ListViews.
1008
1009 Iterating over this object will yield
1010 results and resolve additional pages
1011 automatically.
1012
1013 """
1014 # Create or coerce a protobuf request object.
1015 # Quick check: If we got a request object, we should *not* have
1016 # gotten any keyword arguments that map to the request.
1017 has_flattened_params = any([parent])
1018 if request is not None and has_flattened_params:
1019 raise ValueError(
1020 "If the `request` argument is set, then none of "
1021 "the individual field arguments should be set."
1022 )
1023
1024 request = logging_config.ListViewsRequest(request)
1025
1026 # If we have keyword arguments corresponding to fields on the
1027 # request, apply these.
1028 if parent is not None:
1029 request.parent = parent
1030
1031 # Wrap the RPC method; this adds retry and timeout information,
1032 # and friendly error handling.
1033 rpc = gapic_v1.method_async.wrap_method(
1034 self._client._transport.list_views,
1035 default_timeout=None,
1036 client_info=DEFAULT_CLIENT_INFO,
1037 )
1038
1039 # Certain fields should be provided within the metadata header;
1040 # add these here.
1041 metadata = tuple(metadata) + (
1042 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1043 )
1044
1045 # Send the request.
1046 response = await rpc(
1047 request,
1048 retry=retry,
1049 timeout=timeout,
1050 metadata=metadata,
1051 )
1052
1053 # This method is paged; wrap the response in a pager, which provides
1054 # an `__aiter__` convenience method.
1055 response = pagers.ListViewsAsyncPager(
1056 method=rpc,
1057 request=request,
1058 response=response,
1059 metadata=metadata,
1060 )
1061
1062 # Done; return the response.
1063 return response
1064
1065 async def get_view(
1066 self,
1067 request: Optional[Union[logging_config.GetViewRequest, dict]] = None,
1068 *,
1069 retry: OptionalRetry = gapic_v1.method.DEFAULT,
1070 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1071 metadata: Sequence[Tuple[str, str]] = (),
1072 ) -> logging_config.LogView:
1073 r"""Gets a view on a log bucket..
1074
1075 .. code-block:: python
1076
1077 # This snippet has been automatically generated and should be regarded as a
1078 # code template only.
1079 # It will require modifications to work:
1080 # - It may require correct/in-range values for request initialization.
1081 # - It may require specifying regional endpoints when creating the service
1082 # client as shown in:
1083 # https://googleapis.dev/python/google-api-core/latest/client_options.html
1084 from google.cloud import logging_v2
1085
1086 async def sample_get_view():
1087 # Create a client
1088 client = logging_v2.ConfigServiceV2AsyncClient()
1089
1090 # Initialize request argument(s)
1091 request = logging_v2.GetViewRequest(
1092 name="name_value",
1093 )
1094
1095 # Make the request
1096 response = await client.get_view(request=request)
1097
1098 # Handle the response
1099 print(response)
1100
1101 Args:
1102 request (Optional[Union[google.cloud.logging_v2.types.GetViewRequest, dict]]):
1103 The request object. The parameters to ``GetView``.
1104 retry (google.api_core.retry.Retry): Designation of what errors, if any,
1105 should be retried.
1106 timeout (float): The timeout for this request.
1107 metadata (Sequence[Tuple[str, str]]): Strings which should be
1108 sent along with the request as metadata.
1109
1110 Returns:
1111 google.cloud.logging_v2.types.LogView:
1112 Describes a view over log entries in
1113 a bucket.
1114
1115 """
1116 # Create or coerce a protobuf request object.
1117 request = logging_config.GetViewRequest(request)
1118
1119 # Wrap the RPC method; this adds retry and timeout information,
1120 # and friendly error handling.
1121 rpc = gapic_v1.method_async.wrap_method(
1122 self._client._transport.get_view,
1123 default_timeout=None,
1124 client_info=DEFAULT_CLIENT_INFO,
1125 )
1126
1127 # Certain fields should be provided within the metadata header;
1128 # add these here.
1129 metadata = tuple(metadata) + (
1130 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1131 )
1132
1133 # Send the request.
1134 response = await rpc(
1135 request,
1136 retry=retry,
1137 timeout=timeout,
1138 metadata=metadata,
1139 )
1140
1141 # Done; return the response.
1142 return response
1143
1144 async def create_view(
1145 self,
1146 request: Optional[Union[logging_config.CreateViewRequest, dict]] = None,
1147 *,
1148 retry: OptionalRetry = gapic_v1.method.DEFAULT,
1149 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1150 metadata: Sequence[Tuple[str, str]] = (),
1151 ) -> logging_config.LogView:
1152 r"""Creates a view over log entries in a log bucket. A
1153 bucket may contain a maximum of 30 views.
1154
1155 .. code-block:: python
1156
1157 # This snippet has been automatically generated and should be regarded as a
1158 # code template only.
1159 # It will require modifications to work:
1160 # - It may require correct/in-range values for request initialization.
1161 # - It may require specifying regional endpoints when creating the service
1162 # client as shown in:
1163 # https://googleapis.dev/python/google-api-core/latest/client_options.html
1164 from google.cloud import logging_v2
1165
1166 async def sample_create_view():
1167 # Create a client
1168 client = logging_v2.ConfigServiceV2AsyncClient()
1169
1170 # Initialize request argument(s)
1171 request = logging_v2.CreateViewRequest(
1172 parent="parent_value",
1173 view_id="view_id_value",
1174 )
1175
1176 # Make the request
1177 response = await client.create_view(request=request)
1178
1179 # Handle the response
1180 print(response)
1181
1182 Args:
1183 request (Optional[Union[google.cloud.logging_v2.types.CreateViewRequest, dict]]):
1184 The request object. The parameters to ``CreateView``.
1185 retry (google.api_core.retry.Retry): Designation of what errors, if any,
1186 should be retried.
1187 timeout (float): The timeout for this request.
1188 metadata (Sequence[Tuple[str, str]]): Strings which should be
1189 sent along with the request as metadata.
1190
1191 Returns:
1192 google.cloud.logging_v2.types.LogView:
1193 Describes a view over log entries in
1194 a bucket.
1195
1196 """
1197 # Create or coerce a protobuf request object.
1198 request = logging_config.CreateViewRequest(request)
1199
1200 # Wrap the RPC method; this adds retry and timeout information,
1201 # and friendly error handling.
1202 rpc = gapic_v1.method_async.wrap_method(
1203 self._client._transport.create_view,
1204 default_timeout=None,
1205 client_info=DEFAULT_CLIENT_INFO,
1206 )
1207
1208 # Certain fields should be provided within the metadata header;
1209 # add these here.
1210 metadata = tuple(metadata) + (
1211 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1212 )
1213
1214 # Send the request.
1215 response = await rpc(
1216 request,
1217 retry=retry,
1218 timeout=timeout,
1219 metadata=metadata,
1220 )
1221
1222 # Done; return the response.
1223 return response
1224
1225 async def update_view(
1226 self,
1227 request: Optional[Union[logging_config.UpdateViewRequest, dict]] = None,
1228 *,
1229 retry: OptionalRetry = gapic_v1.method.DEFAULT,
1230 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1231 metadata: Sequence[Tuple[str, str]] = (),
1232 ) -> logging_config.LogView:
1233 r"""Updates a view on a log bucket. This method replaces the
1234 following fields in the existing view with values from the new
1235 view: ``filter``. If an ``UNAVAILABLE`` error is returned, this
1236 indicates that system is not in a state where it can update the
1237 view. If this occurs, please try again in a few minutes.
1238
1239 .. code-block:: python
1240
1241 # This snippet has been automatically generated and should be regarded as a
1242 # code template only.
1243 # It will require modifications to work:
1244 # - It may require correct/in-range values for request initialization.
1245 # - It may require specifying regional endpoints when creating the service
1246 # client as shown in:
1247 # https://googleapis.dev/python/google-api-core/latest/client_options.html
1248 from google.cloud import logging_v2
1249
1250 async def sample_update_view():
1251 # Create a client
1252 client = logging_v2.ConfigServiceV2AsyncClient()
1253
1254 # Initialize request argument(s)
1255 request = logging_v2.UpdateViewRequest(
1256 name="name_value",
1257 )
1258
1259 # Make the request
1260 response = await client.update_view(request=request)
1261
1262 # Handle the response
1263 print(response)
1264
1265 Args:
1266 request (Optional[Union[google.cloud.logging_v2.types.UpdateViewRequest, dict]]):
1267 The request object. The parameters to ``UpdateView``.
1268 retry (google.api_core.retry.Retry): Designation of what errors, if any,
1269 should be retried.
1270 timeout (float): The timeout for this request.
1271 metadata (Sequence[Tuple[str, str]]): Strings which should be
1272 sent along with the request as metadata.
1273
1274 Returns:
1275 google.cloud.logging_v2.types.LogView:
1276 Describes a view over log entries in
1277 a bucket.
1278
1279 """
1280 # Create or coerce a protobuf request object.
1281 request = logging_config.UpdateViewRequest(request)
1282
1283 # Wrap the RPC method; this adds retry and timeout information,
1284 # and friendly error handling.
1285 rpc = gapic_v1.method_async.wrap_method(
1286 self._client._transport.update_view,
1287 default_timeout=None,
1288 client_info=DEFAULT_CLIENT_INFO,
1289 )
1290
1291 # Certain fields should be provided within the metadata header;
1292 # add these here.
1293 metadata = tuple(metadata) + (
1294 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1295 )
1296
1297 # Send the request.
1298 response = await rpc(
1299 request,
1300 retry=retry,
1301 timeout=timeout,
1302 metadata=metadata,
1303 )
1304
1305 # Done; return the response.
1306 return response
1307
1308 async def delete_view(
1309 self,
1310 request: Optional[Union[logging_config.DeleteViewRequest, dict]] = None,
1311 *,
1312 retry: OptionalRetry = gapic_v1.method.DEFAULT,
1313 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1314 metadata: Sequence[Tuple[str, str]] = (),
1315 ) -> None:
1316 r"""Deletes a view on a log bucket. If an ``UNAVAILABLE`` error is
1317 returned, this indicates that system is not in a state where it
1318 can delete the view. If this occurs, please try again in a few
1319 minutes.
1320
1321 .. code-block:: python
1322
1323 # This snippet has been automatically generated and should be regarded as a
1324 # code template only.
1325 # It will require modifications to work:
1326 # - It may require correct/in-range values for request initialization.
1327 # - It may require specifying regional endpoints when creating the service
1328 # client as shown in:
1329 # https://googleapis.dev/python/google-api-core/latest/client_options.html
1330 from google.cloud import logging_v2
1331
1332 async def sample_delete_view():
1333 # Create a client
1334 client = logging_v2.ConfigServiceV2AsyncClient()
1335
1336 # Initialize request argument(s)
1337 request = logging_v2.DeleteViewRequest(
1338 name="name_value",
1339 )
1340
1341 # Make the request
1342 await client.delete_view(request=request)
1343
1344 Args:
1345 request (Optional[Union[google.cloud.logging_v2.types.DeleteViewRequest, dict]]):
1346 The request object. The parameters to ``DeleteView``.
1347 retry (google.api_core.retry.Retry): Designation of what errors, if any,
1348 should be retried.
1349 timeout (float): The timeout for this request.
1350 metadata (Sequence[Tuple[str, str]]): Strings which should be
1351 sent along with the request as metadata.
1352 """
1353 # Create or coerce a protobuf request object.
1354 request = logging_config.DeleteViewRequest(request)
1355
1356 # Wrap the RPC method; this adds retry and timeout information,
1357 # and friendly error handling.
1358 rpc = gapic_v1.method_async.wrap_method(
1359 self._client._transport.delete_view,
1360 default_timeout=None,
1361 client_info=DEFAULT_CLIENT_INFO,
1362 )
1363
1364 # Certain fields should be provided within the metadata header;
1365 # add these here.
1366 metadata = tuple(metadata) + (
1367 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1368 )
1369
1370 # Send the request.
1371 await rpc(
1372 request,
1373 retry=retry,
1374 timeout=timeout,
1375 metadata=metadata,
1376 )
1377
1378 async def list_sinks(
1379 self,
1380 request: Optional[Union[logging_config.ListSinksRequest, dict]] = None,
1381 *,
1382 parent: Optional[str] = None,
1383 retry: OptionalRetry = gapic_v1.method.DEFAULT,
1384 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1385 metadata: Sequence[Tuple[str, str]] = (),
1386 ) -> pagers.ListSinksAsyncPager:
1387 r"""Lists sinks.
1388
1389 .. code-block:: python
1390
1391 # This snippet has been automatically generated and should be regarded as a
1392 # code template only.
1393 # It will require modifications to work:
1394 # - It may require correct/in-range values for request initialization.
1395 # - It may require specifying regional endpoints when creating the service
1396 # client as shown in:
1397 # https://googleapis.dev/python/google-api-core/latest/client_options.html
1398 from google.cloud import logging_v2
1399
1400 async def sample_list_sinks():
1401 # Create a client
1402 client = logging_v2.ConfigServiceV2AsyncClient()
1403
1404 # Initialize request argument(s)
1405 request = logging_v2.ListSinksRequest(
1406 parent="parent_value",
1407 )
1408
1409 # Make the request
1410 page_result = client.list_sinks(request=request)
1411
1412 # Handle the response
1413 async for response in page_result:
1414 print(response)
1415
1416 Args:
1417 request (Optional[Union[google.cloud.logging_v2.types.ListSinksRequest, dict]]):
1418 The request object. The parameters to ``ListSinks``.
1419 parent (:class:`str`):
1420 Required. The parent resource whose sinks are to be
1421 listed:
1422
1423 ::
1424
1425 "projects/[PROJECT_ID]"
1426 "organizations/[ORGANIZATION_ID]"
1427 "billingAccounts/[BILLING_ACCOUNT_ID]"
1428 "folders/[FOLDER_ID]"
1429
1430 This corresponds to the ``parent`` field
1431 on the ``request`` instance; if ``request`` is provided, this
1432 should not be set.
1433 retry (google.api_core.retry.Retry): Designation of what errors, if any,
1434 should be retried.
1435 timeout (float): The timeout for this request.
1436 metadata (Sequence[Tuple[str, str]]): Strings which should be
1437 sent along with the request as metadata.
1438
1439 Returns:
1440 google.cloud.logging_v2.services.config_service_v2.pagers.ListSinksAsyncPager:
1441 Result returned from ListSinks.
1442
1443 Iterating over this object will yield results and
1444 resolve additional pages automatically.
1445
1446 """
1447 # Create or coerce a protobuf request object.
1448 # Quick check: If we got a request object, we should *not* have
1449 # gotten any keyword arguments that map to the request.
1450 has_flattened_params = any([parent])
1451 if request is not None and has_flattened_params:
1452 raise ValueError(
1453 "If the `request` argument is set, then none of "
1454 "the individual field arguments should be set."
1455 )
1456
1457 request = logging_config.ListSinksRequest(request)
1458
1459 # If we have keyword arguments corresponding to fields on the
1460 # request, apply these.
1461 if parent is not None:
1462 request.parent = parent
1463
1464 # Wrap the RPC method; this adds retry and timeout information,
1465 # and friendly error handling.
1466 rpc = gapic_v1.method_async.wrap_method(
1467 self._client._transport.list_sinks,
1468 default_retry=retries.Retry(
1469 initial=0.1,
1470 maximum=60.0,
1471 multiplier=1.3,
1472 predicate=retries.if_exception_type(
1473 core_exceptions.DeadlineExceeded,
1474 core_exceptions.InternalServerError,
1475 core_exceptions.ServiceUnavailable,
1476 ),
1477 deadline=60.0,
1478 ),
1479 default_timeout=60.0,
1480 client_info=DEFAULT_CLIENT_INFO,
1481 )
1482
1483 # Certain fields should be provided within the metadata header;
1484 # add these here.
1485 metadata = tuple(metadata) + (
1486 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1487 )
1488
1489 # Send the request.
1490 response = await rpc(
1491 request,
1492 retry=retry,
1493 timeout=timeout,
1494 metadata=metadata,
1495 )
1496
1497 # This method is paged; wrap the response in a pager, which provides
1498 # an `__aiter__` convenience method.
1499 response = pagers.ListSinksAsyncPager(
1500 method=rpc,
1501 request=request,
1502 response=response,
1503 metadata=metadata,
1504 )
1505
1506 # Done; return the response.
1507 return response
1508
1509 async def get_sink(
1510 self,
1511 request: Optional[Union[logging_config.GetSinkRequest, dict]] = None,
1512 *,
1513 sink_name: Optional[str] = None,
1514 retry: OptionalRetry = gapic_v1.method.DEFAULT,
1515 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1516 metadata: Sequence[Tuple[str, str]] = (),
1517 ) -> logging_config.LogSink:
1518 r"""Gets a sink.
1519
1520 .. code-block:: python
1521
1522 # This snippet has been automatically generated and should be regarded as a
1523 # code template only.
1524 # It will require modifications to work:
1525 # - It may require correct/in-range values for request initialization.
1526 # - It may require specifying regional endpoints when creating the service
1527 # client as shown in:
1528 # https://googleapis.dev/python/google-api-core/latest/client_options.html
1529 from google.cloud import logging_v2
1530
1531 async def sample_get_sink():
1532 # Create a client
1533 client = logging_v2.ConfigServiceV2AsyncClient()
1534
1535 # Initialize request argument(s)
1536 request = logging_v2.GetSinkRequest(
1537 sink_name="sink_name_value",
1538 )
1539
1540 # Make the request
1541 response = await client.get_sink(request=request)
1542
1543 # Handle the response
1544 print(response)
1545
1546 Args:
1547 request (Optional[Union[google.cloud.logging_v2.types.GetSinkRequest, dict]]):
1548 The request object. The parameters to ``GetSink``.
1549 sink_name (:class:`str`):
1550 Required. The resource name of the sink:
1551
1552 ::
1553
1554 "projects/[PROJECT_ID]/sinks/[SINK_ID]"
1555 "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]"
1556 "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]"
1557 "folders/[FOLDER_ID]/sinks/[SINK_ID]"
1558
1559 For example:
1560
1561 ``"projects/my-project/sinks/my-sink"``
1562
1563 This corresponds to the ``sink_name`` field
1564 on the ``request`` instance; if ``request`` is provided, this
1565 should not be set.
1566 retry (google.api_core.retry.Retry): Designation of what errors, if any,
1567 should be retried.
1568 timeout (float): The timeout for this request.
1569 metadata (Sequence[Tuple[str, str]]): Strings which should be
1570 sent along with the request as metadata.
1571
1572 Returns:
1573 google.cloud.logging_v2.types.LogSink:
1574 Describes a sink used to export log
1575 entries to one of the following
1576 destinations in any project: a Cloud
1577 Storage bucket, a BigQuery dataset, a
1578 Pub/Sub topic or a Cloud Logging log
1579 bucket. A logs filter controls which log
1580 entries are exported. The sink must be
1581 created within a project, organization,
1582 billing account, or folder.
1583
1584 """
1585 # Create or coerce a protobuf request object.
1586 # Quick check: If we got a request object, we should *not* have
1587 # gotten any keyword arguments that map to the request.
1588 has_flattened_params = any([sink_name])
1589 if request is not None and has_flattened_params:
1590 raise ValueError(
1591 "If the `request` argument is set, then none of "
1592 "the individual field arguments should be set."
1593 )
1594
1595 request = logging_config.GetSinkRequest(request)
1596
1597 # If we have keyword arguments corresponding to fields on the
1598 # request, apply these.
1599 if sink_name is not None:
1600 request.sink_name = sink_name
1601
1602 # Wrap the RPC method; this adds retry and timeout information,
1603 # and friendly error handling.
1604 rpc = gapic_v1.method_async.wrap_method(
1605 self._client._transport.get_sink,
1606 default_retry=retries.Retry(
1607 initial=0.1,
1608 maximum=60.0,
1609 multiplier=1.3,
1610 predicate=retries.if_exception_type(
1611 core_exceptions.DeadlineExceeded,
1612 core_exceptions.InternalServerError,
1613 core_exceptions.ServiceUnavailable,
1614 ),
1615 deadline=60.0,
1616 ),
1617 default_timeout=60.0,
1618 client_info=DEFAULT_CLIENT_INFO,
1619 )
1620
1621 # Certain fields should be provided within the metadata header;
1622 # add these here.
1623 metadata = tuple(metadata) + (
1624 gapic_v1.routing_header.to_grpc_metadata(
1625 (("sink_name", request.sink_name),)
1626 ),
1627 )
1628
1629 # Send the request.
1630 response = await rpc(
1631 request,
1632 retry=retry,
1633 timeout=timeout,
1634 metadata=metadata,
1635 )
1636
1637 # Done; return the response.
1638 return response
1639
1640 async def create_sink(
1641 self,
1642 request: Optional[Union[logging_config.CreateSinkRequest, dict]] = None,
1643 *,
1644 parent: Optional[str] = None,
1645 sink: Optional[logging_config.LogSink] = None,
1646 retry: OptionalRetry = gapic_v1.method.DEFAULT,
1647 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1648 metadata: Sequence[Tuple[str, str]] = (),
1649 ) -> logging_config.LogSink:
1650 r"""Creates a sink that exports specified log entries to a
1651 destination. The export of newly-ingested log entries begins
1652 immediately, unless the sink's ``writer_identity`` is not
1653 permitted to write to the destination. A sink can export log
1654 entries only from the resource owning the sink.
1655
1656 .. code-block:: python
1657
1658 # This snippet has been automatically generated and should be regarded as a
1659 # code template only.
1660 # It will require modifications to work:
1661 # - It may require correct/in-range values for request initialization.
1662 # - It may require specifying regional endpoints when creating the service
1663 # client as shown in:
1664 # https://googleapis.dev/python/google-api-core/latest/client_options.html
1665 from google.cloud import logging_v2
1666
1667 async def sample_create_sink():
1668 # Create a client
1669 client = logging_v2.ConfigServiceV2AsyncClient()
1670
1671 # Initialize request argument(s)
1672 sink = logging_v2.LogSink()
1673 sink.name = "name_value"
1674 sink.destination = "destination_value"
1675
1676 request = logging_v2.CreateSinkRequest(
1677 parent="parent_value",
1678 sink=sink,
1679 )
1680
1681 # Make the request
1682 response = await client.create_sink(request=request)
1683
1684 # Handle the response
1685 print(response)
1686
1687 Args:
1688 request (Optional[Union[google.cloud.logging_v2.types.CreateSinkRequest, dict]]):
1689 The request object. The parameters to ``CreateSink``.
1690 parent (:class:`str`):
1691 Required. The resource in which to create the sink:
1692
1693 ::
1694
1695 "projects/[PROJECT_ID]"
1696 "organizations/[ORGANIZATION_ID]"
1697 "billingAccounts/[BILLING_ACCOUNT_ID]"
1698 "folders/[FOLDER_ID]"
1699
1700 For examples:
1701
1702 ``"projects/my-project"`` ``"organizations/123456789"``
1703
1704 This corresponds to the ``parent`` field
1705 on the ``request`` instance; if ``request`` is provided, this
1706 should not be set.
1707 sink (:class:`google.cloud.logging_v2.types.LogSink`):
1708 Required. The new sink, whose ``name`` parameter is a
1709 sink identifier that is not already in use.
1710
1711 This corresponds to the ``sink`` field
1712 on the ``request`` instance; if ``request`` is provided, this
1713 should not be set.
1714 retry (google.api_core.retry.Retry): Designation of what errors, if any,
1715 should be retried.
1716 timeout (float): The timeout for this request.
1717 metadata (Sequence[Tuple[str, str]]): Strings which should be
1718 sent along with the request as metadata.
1719
1720 Returns:
1721 google.cloud.logging_v2.types.LogSink:
1722 Describes a sink used to export log
1723 entries to one of the following
1724 destinations in any project: a Cloud
1725 Storage bucket, a BigQuery dataset, a
1726 Pub/Sub topic or a Cloud Logging log
1727 bucket. A logs filter controls which log
1728 entries are exported. The sink must be
1729 created within a project, organization,
1730 billing account, or folder.
1731
1732 """
1733 # Create or coerce a protobuf request object.
1734 # Quick check: If we got a request object, we should *not* have
1735 # gotten any keyword arguments that map to the request.
1736 has_flattened_params = any([parent, sink])
1737 if request is not None and has_flattened_params:
1738 raise ValueError(
1739 "If the `request` argument is set, then none of "
1740 "the individual field arguments should be set."
1741 )
1742
1743 request = logging_config.CreateSinkRequest(request)
1744
1745 # If we have keyword arguments corresponding to fields on the
1746 # request, apply these.
1747 if parent is not None:
1748 request.parent = parent
1749 if sink is not None:
1750 request.sink = sink
1751
1752 # Wrap the RPC method; this adds retry and timeout information,
1753 # and friendly error handling.
1754 rpc = gapic_v1.method_async.wrap_method(
1755 self._client._transport.create_sink,
1756 default_timeout=120.0,
1757 client_info=DEFAULT_CLIENT_INFO,
1758 )
1759
1760 # Certain fields should be provided within the metadata header;
1761 # add these here.
1762 metadata = tuple(metadata) + (
1763 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1764 )
1765
1766 # Send the request.
1767 response = await rpc(
1768 request,
1769 retry=retry,
1770 timeout=timeout,
1771 metadata=metadata,
1772 )
1773
1774 # Done; return the response.
1775 return response
1776
1777 async def update_sink(
1778 self,
1779 request: Optional[Union[logging_config.UpdateSinkRequest, dict]] = None,
1780 *,
1781 sink_name: Optional[str] = None,
1782 sink: Optional[logging_config.LogSink] = None,
1783 update_mask: Optional[field_mask_pb2.FieldMask] = None,
1784 retry: OptionalRetry = gapic_v1.method.DEFAULT,
1785 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1786 metadata: Sequence[Tuple[str, str]] = (),
1787 ) -> logging_config.LogSink:
1788 r"""Updates a sink. This method replaces the following fields in the
1789 existing sink with values from the new sink: ``destination``,
1790 and ``filter``.
1791
1792 The updated sink might also have a new ``writer_identity``; see
1793 the ``unique_writer_identity`` field.
1794
1795 .. code-block:: python
1796
1797 # This snippet has been automatically generated and should be regarded as a
1798 # code template only.
1799 # It will require modifications to work:
1800 # - It may require correct/in-range values for request initialization.
1801 # - It may require specifying regional endpoints when creating the service
1802 # client as shown in:
1803 # https://googleapis.dev/python/google-api-core/latest/client_options.html
1804 from google.cloud import logging_v2
1805
1806 async def sample_update_sink():
1807 # Create a client
1808 client = logging_v2.ConfigServiceV2AsyncClient()
1809
1810 # Initialize request argument(s)
1811 sink = logging_v2.LogSink()
1812 sink.name = "name_value"
1813 sink.destination = "destination_value"
1814
1815 request = logging_v2.UpdateSinkRequest(
1816 sink_name="sink_name_value",
1817 sink=sink,
1818 )
1819
1820 # Make the request
1821 response = await client.update_sink(request=request)
1822
1823 # Handle the response
1824 print(response)
1825
1826 Args:
1827 request (Optional[Union[google.cloud.logging_v2.types.UpdateSinkRequest, dict]]):
1828 The request object. The parameters to ``UpdateSink``.
1829 sink_name (:class:`str`):
1830 Required. The full resource name of the sink to update,
1831 including the parent resource and the sink identifier:
1832
1833 ::
1834
1835 "projects/[PROJECT_ID]/sinks/[SINK_ID]"
1836 "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]"
1837 "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]"
1838 "folders/[FOLDER_ID]/sinks/[SINK_ID]"
1839
1840 For example:
1841
1842 ``"projects/my-project/sinks/my-sink"``
1843
1844 This corresponds to the ``sink_name`` field
1845 on the ``request`` instance; if ``request`` is provided, this
1846 should not be set.
1847 sink (:class:`google.cloud.logging_v2.types.LogSink`):
1848 Required. The updated sink, whose name is the same
1849 identifier that appears as part of ``sink_name``.
1850
1851 This corresponds to the ``sink`` field
1852 on the ``request`` instance; if ``request`` is provided, this
1853 should not be set.
1854 update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
1855 Optional. Field mask that specifies the fields in
1856 ``sink`` that need an update. A sink field will be
1857 overwritten if, and only if, it is in the update mask.
1858 ``name`` and output only fields cannot be updated.
1859
1860 An empty ``updateMask`` is temporarily treated as using
1861 the following mask for backwards compatibility purposes:
1862
1863 ``destination,filter,includeChildren``
1864
1865 At some point in the future, behavior will be removed
1866 and specifying an empty ``updateMask`` will be an error.
1867
1868 For a detailed ``FieldMask`` definition, see
1869 https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask
1870
1871 For example: ``updateMask=filter``
1872
1873 This corresponds to the ``update_mask`` field
1874 on the ``request`` instance; if ``request`` is provided, this
1875 should not be set.
1876 retry (google.api_core.retry.Retry): Designation of what errors, if any,
1877 should be retried.
1878 timeout (float): The timeout for this request.
1879 metadata (Sequence[Tuple[str, str]]): Strings which should be
1880 sent along with the request as metadata.
1881
1882 Returns:
1883 google.cloud.logging_v2.types.LogSink:
1884 Describes a sink used to export log
1885 entries to one of the following
1886 destinations in any project: a Cloud
1887 Storage bucket, a BigQuery dataset, a
1888 Pub/Sub topic or a Cloud Logging log
1889 bucket. A logs filter controls which log
1890 entries are exported. The sink must be
1891 created within a project, organization,
1892 billing account, or folder.
1893
1894 """
1895 # Create or coerce a protobuf request object.
1896 # Quick check: If we got a request object, we should *not* have
1897 # gotten any keyword arguments that map to the request.
1898 has_flattened_params = any([sink_name, sink, update_mask])
1899 if request is not None and has_flattened_params:
1900 raise ValueError(
1901 "If the `request` argument is set, then none of "
1902 "the individual field arguments should be set."
1903 )
1904
1905 request = logging_config.UpdateSinkRequest(request)
1906
1907 # If we have keyword arguments corresponding to fields on the
1908 # request, apply these.
1909 if sink_name is not None:
1910 request.sink_name = sink_name
1911 if sink is not None:
1912 request.sink = sink
1913 if update_mask is not None:
1914 request.update_mask = update_mask
1915
1916 # Wrap the RPC method; this adds retry and timeout information,
1917 # and friendly error handling.
1918 rpc = gapic_v1.method_async.wrap_method(
1919 self._client._transport.update_sink,
1920 default_retry=retries.Retry(
1921 initial=0.1,
1922 maximum=60.0,
1923 multiplier=1.3,
1924 predicate=retries.if_exception_type(
1925 core_exceptions.DeadlineExceeded,
1926 core_exceptions.InternalServerError,
1927 core_exceptions.ServiceUnavailable,
1928 ),
1929 deadline=60.0,
1930 ),
1931 default_timeout=60.0,
1932 client_info=DEFAULT_CLIENT_INFO,
1933 )
1934
1935 # Certain fields should be provided within the metadata header;
1936 # add these here.
1937 metadata = tuple(metadata) + (
1938 gapic_v1.routing_header.to_grpc_metadata(
1939 (("sink_name", request.sink_name),)
1940 ),
1941 )
1942
1943 # Send the request.
1944 response = await rpc(
1945 request,
1946 retry=retry,
1947 timeout=timeout,
1948 metadata=metadata,
1949 )
1950
1951 # Done; return the response.
1952 return response
1953
1954 async def delete_sink(
1955 self,
1956 request: Optional[Union[logging_config.DeleteSinkRequest, dict]] = None,
1957 *,
1958 sink_name: Optional[str] = None,
1959 retry: OptionalRetry = gapic_v1.method.DEFAULT,
1960 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1961 metadata: Sequence[Tuple[str, str]] = (),
1962 ) -> None:
1963 r"""Deletes a sink. If the sink has a unique ``writer_identity``,
1964 then that service account is also deleted.
1965
1966 .. code-block:: python
1967
1968 # This snippet has been automatically generated and should be regarded as a
1969 # code template only.
1970 # It will require modifications to work:
1971 # - It may require correct/in-range values for request initialization.
1972 # - It may require specifying regional endpoints when creating the service
1973 # client as shown in:
1974 # https://googleapis.dev/python/google-api-core/latest/client_options.html
1975 from google.cloud import logging_v2
1976
1977 async def sample_delete_sink():
1978 # Create a client
1979 client = logging_v2.ConfigServiceV2AsyncClient()
1980
1981 # Initialize request argument(s)
1982 request = logging_v2.DeleteSinkRequest(
1983 sink_name="sink_name_value",
1984 )
1985
1986 # Make the request
1987 await client.delete_sink(request=request)
1988
1989 Args:
1990 request (Optional[Union[google.cloud.logging_v2.types.DeleteSinkRequest, dict]]):
1991 The request object. The parameters to ``DeleteSink``.
1992 sink_name (:class:`str`):
1993 Required. The full resource name of the sink to delete,
1994 including the parent resource and the sink identifier:
1995
1996 ::
1997
1998 "projects/[PROJECT_ID]/sinks/[SINK_ID]"
1999 "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]"
2000 "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]"
2001 "folders/[FOLDER_ID]/sinks/[SINK_ID]"
2002
2003 For example:
2004
2005 ``"projects/my-project/sinks/my-sink"``
2006
2007 This corresponds to the ``sink_name`` field
2008 on the ``request`` instance; if ``request`` is provided, this
2009 should not be set.
2010 retry (google.api_core.retry.Retry): Designation of what errors, if any,
2011 should be retried.
2012 timeout (float): The timeout for this request.
2013 metadata (Sequence[Tuple[str, str]]): Strings which should be
2014 sent along with the request as metadata.
2015 """
2016 # Create or coerce a protobuf request object.
2017 # Quick check: If we got a request object, we should *not* have
2018 # gotten any keyword arguments that map to the request.
2019 has_flattened_params = any([sink_name])
2020 if request is not None and has_flattened_params:
2021 raise ValueError(
2022 "If the `request` argument is set, then none of "
2023 "the individual field arguments should be set."
2024 )
2025
2026 request = logging_config.DeleteSinkRequest(request)
2027
2028 # If we have keyword arguments corresponding to fields on the
2029 # request, apply these.
2030 if sink_name is not None:
2031 request.sink_name = sink_name
2032
2033 # Wrap the RPC method; this adds retry and timeout information,
2034 # and friendly error handling.
2035 rpc = gapic_v1.method_async.wrap_method(
2036 self._client._transport.delete_sink,
2037 default_retry=retries.Retry(
2038 initial=0.1,
2039 maximum=60.0,
2040 multiplier=1.3,
2041 predicate=retries.if_exception_type(
2042 core_exceptions.DeadlineExceeded,
2043 core_exceptions.InternalServerError,
2044 core_exceptions.ServiceUnavailable,
2045 ),
2046 deadline=60.0,
2047 ),
2048 default_timeout=60.0,
2049 client_info=DEFAULT_CLIENT_INFO,
2050 )
2051
2052 # Certain fields should be provided within the metadata header;
2053 # add these here.
2054 metadata = tuple(metadata) + (
2055 gapic_v1.routing_header.to_grpc_metadata(
2056 (("sink_name", request.sink_name),)
2057 ),
2058 )
2059
2060 # Send the request.
2061 await rpc(
2062 request,
2063 retry=retry,
2064 timeout=timeout,
2065 metadata=metadata,
2066 )
2067
2068 async def create_link(
2069 self,
2070 request: Optional[Union[logging_config.CreateLinkRequest, dict]] = None,
2071 *,
2072 parent: Optional[str] = None,
2073 link: Optional[logging_config.Link] = None,
2074 link_id: Optional[str] = None,
2075 retry: OptionalRetry = gapic_v1.method.DEFAULT,
2076 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2077 metadata: Sequence[Tuple[str, str]] = (),
2078 ) -> operation_async.AsyncOperation:
2079 r"""Asynchronously creates a linked dataset in BigQuery
2080 which makes it possible to use BigQuery to read the logs
2081 stored in the log bucket. A log bucket may currently
2082 only contain one link.
2083
2084 .. code-block:: python
2085
2086 # This snippet has been automatically generated and should be regarded as a
2087 # code template only.
2088 # It will require modifications to work:
2089 # - It may require correct/in-range values for request initialization.
2090 # - It may require specifying regional endpoints when creating the service
2091 # client as shown in:
2092 # https://googleapis.dev/python/google-api-core/latest/client_options.html
2093 from google.cloud import logging_v2
2094
2095 async def sample_create_link():
2096 # Create a client
2097 client = logging_v2.ConfigServiceV2AsyncClient()
2098
2099 # Initialize request argument(s)
2100 request = logging_v2.CreateLinkRequest(
2101 parent="parent_value",
2102 link_id="link_id_value",
2103 )
2104
2105 # Make the request
2106 operation = client.create_link(request=request)
2107
2108 print("Waiting for operation to complete...")
2109
2110 response = (await operation).result()
2111
2112 # Handle the response
2113 print(response)
2114
2115 Args:
2116 request (Optional[Union[google.cloud.logging_v2.types.CreateLinkRequest, dict]]):
2117 The request object. The parameters to CreateLink.
2118 parent (:class:`str`):
2119 Required. The full resource name of the bucket to create
2120 a link for.
2121
2122 ::
2123
2124 "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]"
2125 "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]"
2126 "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]"
2127 "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]"
2128
2129 This corresponds to the ``parent`` field
2130 on the ``request`` instance; if ``request`` is provided, this
2131 should not be set.
2132 link (:class:`google.cloud.logging_v2.types.Link`):
2133 Required. The new link.
2134 This corresponds to the ``link`` field
2135 on the ``request`` instance; if ``request`` is provided, this
2136 should not be set.
2137 link_id (:class:`str`):
2138 Required. The ID to use for the link. The link_id can
2139 have up to 100 characters. A valid link_id must only
2140 have alphanumeric characters and underscores within it.
2141
2142 This corresponds to the ``link_id`` field
2143 on the ``request`` instance; if ``request`` is provided, this
2144 should not be set.
2145 retry (google.api_core.retry.Retry): Designation of what errors, if any,
2146 should be retried.
2147 timeout (float): The timeout for this request.
2148 metadata (Sequence[Tuple[str, str]]): Strings which should be
2149 sent along with the request as metadata.
2150
2151 Returns:
2152 google.api_core.operation_async.AsyncOperation:
2153 An object representing a long-running operation.
2154
2155 The result type for the operation will be
2156 :class:`google.cloud.logging_v2.types.Link` Describes a
2157 link connected to an analytics enabled bucket.
2158
2159 """
2160 # Create or coerce a protobuf request object.
2161 # Quick check: If we got a request object, we should *not* have
2162 # gotten any keyword arguments that map to the request.
2163 has_flattened_params = any([parent, link, link_id])
2164 if request is not None and has_flattened_params:
2165 raise ValueError(
2166 "If the `request` argument is set, then none of "
2167 "the individual field arguments should be set."
2168 )
2169
2170 request = logging_config.CreateLinkRequest(request)
2171
2172 # If we have keyword arguments corresponding to fields on the
2173 # request, apply these.
2174 if parent is not None:
2175 request.parent = parent
2176 if link is not None:
2177 request.link = link
2178 if link_id is not None:
2179 request.link_id = link_id
2180
2181 # Wrap the RPC method; this adds retry and timeout information,
2182 # and friendly error handling.
2183 rpc = gapic_v1.method_async.wrap_method(
2184 self._client._transport.create_link,
2185 default_timeout=None,
2186 client_info=DEFAULT_CLIENT_INFO,
2187 )
2188
2189 # Certain fields should be provided within the metadata header;
2190 # add these here.
2191 metadata = tuple(metadata) + (
2192 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
2193 )
2194
2195 # Send the request.
2196 response = await rpc(
2197 request,
2198 retry=retry,
2199 timeout=timeout,
2200 metadata=metadata,
2201 )
2202
2203 # Wrap the response in an operation future.
2204 response = operation_async.from_gapic(
2205 response,
2206 self._client._transport.operations_client,
2207 logging_config.Link,
2208 metadata_type=logging_config.LinkMetadata,
2209 )
2210
2211 # Done; return the response.
2212 return response
2213
2214 async def delete_link(
2215 self,
2216 request: Optional[Union[logging_config.DeleteLinkRequest, dict]] = None,
2217 *,
2218 name: Optional[str] = None,
2219 retry: OptionalRetry = gapic_v1.method.DEFAULT,
2220 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2221 metadata: Sequence[Tuple[str, str]] = (),
2222 ) -> operation_async.AsyncOperation:
2223 r"""Deletes a link. This will also delete the
2224 corresponding BigQuery linked dataset.
2225
2226 .. code-block:: python
2227
2228 # This snippet has been automatically generated and should be regarded as a
2229 # code template only.
2230 # It will require modifications to work:
2231 # - It may require correct/in-range values for request initialization.
2232 # - It may require specifying regional endpoints when creating the service
2233 # client as shown in:
2234 # https://googleapis.dev/python/google-api-core/latest/client_options.html
2235 from google.cloud import logging_v2
2236
2237 async def sample_delete_link():
2238 # Create a client
2239 client = logging_v2.ConfigServiceV2AsyncClient()
2240
2241 # Initialize request argument(s)
2242 request = logging_v2.DeleteLinkRequest(
2243 name="name_value",
2244 )
2245
2246 # Make the request
2247 operation = client.delete_link(request=request)
2248
2249 print("Waiting for operation to complete...")
2250
2251 response = (await operation).result()
2252
2253 # Handle the response
2254 print(response)
2255
2256 Args:
2257 request (Optional[Union[google.cloud.logging_v2.types.DeleteLinkRequest, dict]]):
2258 The request object. The parameters to DeleteLink.
2259 name (:class:`str`):
2260 Required. The full resource name of the link to delete.
2261
2262 "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]"
2263 "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]"
2264 "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]"
2265 "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]"
2266
2267 This corresponds to the ``name`` field
2268 on the ``request`` instance; if ``request`` is provided, this
2269 should not be set.
2270 retry (google.api_core.retry.Retry): Designation of what errors, if any,
2271 should be retried.
2272 timeout (float): The timeout for this request.
2273 metadata (Sequence[Tuple[str, str]]): Strings which should be
2274 sent along with the request as metadata.
2275
2276 Returns:
2277 google.api_core.operation_async.AsyncOperation:
2278 An object representing a long-running operation.
2279
2280 The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated
2281 empty messages in your APIs. A typical example is to
2282 use it as the request or the response type of an API
2283 method. For instance:
2284
2285 service Foo {
2286 rpc Bar(google.protobuf.Empty) returns
2287 (google.protobuf.Empty);
2288
2289 }
2290
2291 """
2292 # Create or coerce a protobuf request object.
2293 # Quick check: If we got a request object, we should *not* have
2294 # gotten any keyword arguments that map to the request.
2295 has_flattened_params = any([name])
2296 if request is not None and has_flattened_params:
2297 raise ValueError(
2298 "If the `request` argument is set, then none of "
2299 "the individual field arguments should be set."
2300 )
2301
2302 request = logging_config.DeleteLinkRequest(request)
2303
2304 # If we have keyword arguments corresponding to fields on the
2305 # request, apply these.
2306 if name is not None:
2307 request.name = name
2308
2309 # Wrap the RPC method; this adds retry and timeout information,
2310 # and friendly error handling.
2311 rpc = gapic_v1.method_async.wrap_method(
2312 self._client._transport.delete_link,
2313 default_timeout=None,
2314 client_info=DEFAULT_CLIENT_INFO,
2315 )
2316
2317 # Certain fields should be provided within the metadata header;
2318 # add these here.
2319 metadata = tuple(metadata) + (
2320 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2321 )
2322
2323 # Send the request.
2324 response = await rpc(
2325 request,
2326 retry=retry,
2327 timeout=timeout,
2328 metadata=metadata,
2329 )
2330
2331 # Wrap the response in an operation future.
2332 response = operation_async.from_gapic(
2333 response,
2334 self._client._transport.operations_client,
2335 empty_pb2.Empty,
2336 metadata_type=logging_config.LinkMetadata,
2337 )
2338
2339 # Done; return the response.
2340 return response
2341
2342 async def list_links(
2343 self,
2344 request: Optional[Union[logging_config.ListLinksRequest, dict]] = None,
2345 *,
2346 parent: Optional[str] = None,
2347 retry: OptionalRetry = gapic_v1.method.DEFAULT,
2348 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2349 metadata: Sequence[Tuple[str, str]] = (),
2350 ) -> pagers.ListLinksAsyncPager:
2351 r"""Lists links.
2352
2353 .. code-block:: python
2354
2355 # This snippet has been automatically generated and should be regarded as a
2356 # code template only.
2357 # It will require modifications to work:
2358 # - It may require correct/in-range values for request initialization.
2359 # - It may require specifying regional endpoints when creating the service
2360 # client as shown in:
2361 # https://googleapis.dev/python/google-api-core/latest/client_options.html
2362 from google.cloud import logging_v2
2363
2364 async def sample_list_links():
2365 # Create a client
2366 client = logging_v2.ConfigServiceV2AsyncClient()
2367
2368 # Initialize request argument(s)
2369 request = logging_v2.ListLinksRequest(
2370 parent="parent_value",
2371 )
2372
2373 # Make the request
2374 page_result = client.list_links(request=request)
2375
2376 # Handle the response
2377 async for response in page_result:
2378 print(response)
2379
2380 Args:
2381 request (Optional[Union[google.cloud.logging_v2.types.ListLinksRequest, dict]]):
2382 The request object. The parameters to ListLinks.
2383 parent (:class:`str`):
2384 Required. The parent resource whose links are to be
2385 listed:
2386
2387 "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/"
2388 "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/"
2389 "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/"
2390 "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/
2391
2392 This corresponds to the ``parent`` field
2393 on the ``request`` instance; if ``request`` is provided, this
2394 should not be set.
2395 retry (google.api_core.retry.Retry): Designation of what errors, if any,
2396 should be retried.
2397 timeout (float): The timeout for this request.
2398 metadata (Sequence[Tuple[str, str]]): Strings which should be
2399 sent along with the request as metadata.
2400
2401 Returns:
2402 google.cloud.logging_v2.services.config_service_v2.pagers.ListLinksAsyncPager:
2403 The response from ListLinks.
2404
2405 Iterating over this object will yield
2406 results and resolve additional pages
2407 automatically.
2408
2409 """
2410 # Create or coerce a protobuf request object.
2411 # Quick check: If we got a request object, we should *not* have
2412 # gotten any keyword arguments that map to the request.
2413 has_flattened_params = any([parent])
2414 if request is not None and has_flattened_params:
2415 raise ValueError(
2416 "If the `request` argument is set, then none of "
2417 "the individual field arguments should be set."
2418 )
2419
2420 request = logging_config.ListLinksRequest(request)
2421
2422 # If we have keyword arguments corresponding to fields on the
2423 # request, apply these.
2424 if parent is not None:
2425 request.parent = parent
2426
2427 # Wrap the RPC method; this adds retry and timeout information,
2428 # and friendly error handling.
2429 rpc = gapic_v1.method_async.wrap_method(
2430 self._client._transport.list_links,
2431 default_timeout=None,
2432 client_info=DEFAULT_CLIENT_INFO,
2433 )
2434
2435 # Certain fields should be provided within the metadata header;
2436 # add these here.
2437 metadata = tuple(metadata) + (
2438 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
2439 )
2440
2441 # Send the request.
2442 response = await rpc(
2443 request,
2444 retry=retry,
2445 timeout=timeout,
2446 metadata=metadata,
2447 )
2448
2449 # This method is paged; wrap the response in a pager, which provides
2450 # an `__aiter__` convenience method.
2451 response = pagers.ListLinksAsyncPager(
2452 method=rpc,
2453 request=request,
2454 response=response,
2455 metadata=metadata,
2456 )
2457
2458 # Done; return the response.
2459 return response
2460
2461 async def get_link(
2462 self,
2463 request: Optional[Union[logging_config.GetLinkRequest, dict]] = None,
2464 *,
2465 name: Optional[str] = None,
2466 retry: OptionalRetry = gapic_v1.method.DEFAULT,
2467 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2468 metadata: Sequence[Tuple[str, str]] = (),
2469 ) -> logging_config.Link:
2470 r"""Gets a link.
2471
2472 .. code-block:: python
2473
2474 # This snippet has been automatically generated and should be regarded as a
2475 # code template only.
2476 # It will require modifications to work:
2477 # - It may require correct/in-range values for request initialization.
2478 # - It may require specifying regional endpoints when creating the service
2479 # client as shown in:
2480 # https://googleapis.dev/python/google-api-core/latest/client_options.html
2481 from google.cloud import logging_v2
2482
2483 async def sample_get_link():
2484 # Create a client
2485 client = logging_v2.ConfigServiceV2AsyncClient()
2486
2487 # Initialize request argument(s)
2488 request = logging_v2.GetLinkRequest(
2489 name="name_value",
2490 )
2491
2492 # Make the request
2493 response = await client.get_link(request=request)
2494
2495 # Handle the response
2496 print(response)
2497
2498 Args:
2499 request (Optional[Union[google.cloud.logging_v2.types.GetLinkRequest, dict]]):
2500 The request object. The parameters to GetLink.
2501 name (:class:`str`):
2502 Required. The resource name of the link:
2503
2504 "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]"
2505 "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]"
2506 "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]"
2507 "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]
2508
2509 This corresponds to the ``name`` field
2510 on the ``request`` instance; if ``request`` is provided, this
2511 should not be set.
2512 retry (google.api_core.retry.Retry): Designation of what errors, if any,
2513 should be retried.
2514 timeout (float): The timeout for this request.
2515 metadata (Sequence[Tuple[str, str]]): Strings which should be
2516 sent along with the request as metadata.
2517
2518 Returns:
2519 google.cloud.logging_v2.types.Link:
2520 Describes a link connected to an
2521 analytics enabled bucket.
2522
2523 """
2524 # Create or coerce a protobuf request object.
2525 # Quick check: If we got a request object, we should *not* have
2526 # gotten any keyword arguments that map to the request.
2527 has_flattened_params = any([name])
2528 if request is not None and has_flattened_params:
2529 raise ValueError(
2530 "If the `request` argument is set, then none of "
2531 "the individual field arguments should be set."
2532 )
2533
2534 request = logging_config.GetLinkRequest(request)
2535
2536 # If we have keyword arguments corresponding to fields on the
2537 # request, apply these.
2538 if name is not None:
2539 request.name = name
2540
2541 # Wrap the RPC method; this adds retry and timeout information,
2542 # and friendly error handling.
2543 rpc = gapic_v1.method_async.wrap_method(
2544 self._client._transport.get_link,
2545 default_timeout=None,
2546 client_info=DEFAULT_CLIENT_INFO,
2547 )
2548
2549 # Certain fields should be provided within the metadata header;
2550 # add these here.
2551 metadata = tuple(metadata) + (
2552 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2553 )
2554
2555 # Send the request.
2556 response = await rpc(
2557 request,
2558 retry=retry,
2559 timeout=timeout,
2560 metadata=metadata,
2561 )
2562
2563 # Done; return the response.
2564 return response
2565
2566 async def list_exclusions(
2567 self,
2568 request: Optional[Union[logging_config.ListExclusionsRequest, dict]] = None,
2569 *,
2570 parent: Optional[str] = None,
2571 retry: OptionalRetry = gapic_v1.method.DEFAULT,
2572 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2573 metadata: Sequence[Tuple[str, str]] = (),
2574 ) -> pagers.ListExclusionsAsyncPager:
2575 r"""Lists all the exclusions on the \_Default sink in a parent
2576 resource.
2577
2578 .. code-block:: python
2579
2580 # This snippet has been automatically generated and should be regarded as a
2581 # code template only.
2582 # It will require modifications to work:
2583 # - It may require correct/in-range values for request initialization.
2584 # - It may require specifying regional endpoints when creating the service
2585 # client as shown in:
2586 # https://googleapis.dev/python/google-api-core/latest/client_options.html
2587 from google.cloud import logging_v2
2588
2589 async def sample_list_exclusions():
2590 # Create a client
2591 client = logging_v2.ConfigServiceV2AsyncClient()
2592
2593 # Initialize request argument(s)
2594 request = logging_v2.ListExclusionsRequest(
2595 parent="parent_value",
2596 )
2597
2598 # Make the request
2599 page_result = client.list_exclusions(request=request)
2600
2601 # Handle the response
2602 async for response in page_result:
2603 print(response)
2604
2605 Args:
2606 request (Optional[Union[google.cloud.logging_v2.types.ListExclusionsRequest, dict]]):
2607 The request object. The parameters to ``ListExclusions``.
2608 parent (:class:`str`):
2609 Required. The parent resource whose exclusions are to be
2610 listed.
2611
2612 ::
2613
2614 "projects/[PROJECT_ID]"
2615 "organizations/[ORGANIZATION_ID]"
2616 "billingAccounts/[BILLING_ACCOUNT_ID]"
2617 "folders/[FOLDER_ID]"
2618
2619 This corresponds to the ``parent`` field
2620 on the ``request`` instance; if ``request`` is provided, this
2621 should not be set.
2622 retry (google.api_core.retry.Retry): Designation of what errors, if any,
2623 should be retried.
2624 timeout (float): The timeout for this request.
2625 metadata (Sequence[Tuple[str, str]]): Strings which should be
2626 sent along with the request as metadata.
2627
2628 Returns:
2629 google.cloud.logging_v2.services.config_service_v2.pagers.ListExclusionsAsyncPager:
2630 Result returned from ListExclusions.
2631
2632 Iterating over this object will yield results and
2633 resolve additional pages automatically.
2634
2635 """
2636 # Create or coerce a protobuf request object.
2637 # Quick check: If we got a request object, we should *not* have
2638 # gotten any keyword arguments that map to the request.
2639 has_flattened_params = any([parent])
2640 if request is not None and has_flattened_params:
2641 raise ValueError(
2642 "If the `request` argument is set, then none of "
2643 "the individual field arguments should be set."
2644 )
2645
2646 request = logging_config.ListExclusionsRequest(request)
2647
2648 # If we have keyword arguments corresponding to fields on the
2649 # request, apply these.
2650 if parent is not None:
2651 request.parent = parent
2652
2653 # Wrap the RPC method; this adds retry and timeout information,
2654 # and friendly error handling.
2655 rpc = gapic_v1.method_async.wrap_method(
2656 self._client._transport.list_exclusions,
2657 default_retry=retries.Retry(
2658 initial=0.1,
2659 maximum=60.0,
2660 multiplier=1.3,
2661 predicate=retries.if_exception_type(
2662 core_exceptions.DeadlineExceeded,
2663 core_exceptions.InternalServerError,
2664 core_exceptions.ServiceUnavailable,
2665 ),
2666 deadline=60.0,
2667 ),
2668 default_timeout=60.0,
2669 client_info=DEFAULT_CLIENT_INFO,
2670 )
2671
2672 # Certain fields should be provided within the metadata header;
2673 # add these here.
2674 metadata = tuple(metadata) + (
2675 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
2676 )
2677
2678 # Send the request.
2679 response = await rpc(
2680 request,
2681 retry=retry,
2682 timeout=timeout,
2683 metadata=metadata,
2684 )
2685
2686 # This method is paged; wrap the response in a pager, which provides
2687 # an `__aiter__` convenience method.
2688 response = pagers.ListExclusionsAsyncPager(
2689 method=rpc,
2690 request=request,
2691 response=response,
2692 metadata=metadata,
2693 )
2694
2695 # Done; return the response.
2696 return response
2697
2698 async def get_exclusion(
2699 self,
2700 request: Optional[Union[logging_config.GetExclusionRequest, dict]] = None,
2701 *,
2702 name: Optional[str] = None,
2703 retry: OptionalRetry = gapic_v1.method.DEFAULT,
2704 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2705 metadata: Sequence[Tuple[str, str]] = (),
2706 ) -> logging_config.LogExclusion:
2707 r"""Gets the description of an exclusion in the \_Default sink.
2708
2709 .. code-block:: python
2710
2711 # This snippet has been automatically generated and should be regarded as a
2712 # code template only.
2713 # It will require modifications to work:
2714 # - It may require correct/in-range values for request initialization.
2715 # - It may require specifying regional endpoints when creating the service
2716 # client as shown in:
2717 # https://googleapis.dev/python/google-api-core/latest/client_options.html
2718 from google.cloud import logging_v2
2719
2720 async def sample_get_exclusion():
2721 # Create a client
2722 client = logging_v2.ConfigServiceV2AsyncClient()
2723
2724 # Initialize request argument(s)
2725 request = logging_v2.GetExclusionRequest(
2726 name="name_value",
2727 )
2728
2729 # Make the request
2730 response = await client.get_exclusion(request=request)
2731
2732 # Handle the response
2733 print(response)
2734
2735 Args:
2736 request (Optional[Union[google.cloud.logging_v2.types.GetExclusionRequest, dict]]):
2737 The request object. The parameters to ``GetExclusion``.
2738 name (:class:`str`):
2739 Required. The resource name of an existing exclusion:
2740
2741 ::
2742
2743 "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]"
2744 "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]"
2745 "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]"
2746 "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]"
2747
2748 For example:
2749
2750 ``"projects/my-project/exclusions/my-exclusion"``
2751
2752 This corresponds to the ``name`` field
2753 on the ``request`` instance; if ``request`` is provided, this
2754 should not be set.
2755 retry (google.api_core.retry.Retry): Designation of what errors, if any,
2756 should be retried.
2757 timeout (float): The timeout for this request.
2758 metadata (Sequence[Tuple[str, str]]): Strings which should be
2759 sent along with the request as metadata.
2760
2761 Returns:
2762 google.cloud.logging_v2.types.LogExclusion:
2763 Specifies a set of log entries that are filtered out by a sink. If
2764 your Google Cloud resource receives a large volume of
2765 log entries, you can use exclusions to reduce your
2766 chargeable logs. Note that exclusions on
2767 organization-level and folder-level sinks don't apply
2768 to child resources. Note also that you cannot modify
2769 the \_Required sink or exclude logs from it.
2770
2771 """
2772 # Create or coerce a protobuf request object.
2773 # Quick check: If we got a request object, we should *not* have
2774 # gotten any keyword arguments that map to the request.
2775 has_flattened_params = any([name])
2776 if request is not None and has_flattened_params:
2777 raise ValueError(
2778 "If the `request` argument is set, then none of "
2779 "the individual field arguments should be set."
2780 )
2781
2782 request = logging_config.GetExclusionRequest(request)
2783
2784 # If we have keyword arguments corresponding to fields on the
2785 # request, apply these.
2786 if name is not None:
2787 request.name = name
2788
2789 # Wrap the RPC method; this adds retry and timeout information,
2790 # and friendly error handling.
2791 rpc = gapic_v1.method_async.wrap_method(
2792 self._client._transport.get_exclusion,
2793 default_retry=retries.Retry(
2794 initial=0.1,
2795 maximum=60.0,
2796 multiplier=1.3,
2797 predicate=retries.if_exception_type(
2798 core_exceptions.DeadlineExceeded,
2799 core_exceptions.InternalServerError,
2800 core_exceptions.ServiceUnavailable,
2801 ),
2802 deadline=60.0,
2803 ),
2804 default_timeout=60.0,
2805 client_info=DEFAULT_CLIENT_INFO,
2806 )
2807
2808 # Certain fields should be provided within the metadata header;
2809 # add these here.
2810 metadata = tuple(metadata) + (
2811 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2812 )
2813
2814 # Send the request.
2815 response = await rpc(
2816 request,
2817 retry=retry,
2818 timeout=timeout,
2819 metadata=metadata,
2820 )
2821
2822 # Done; return the response.
2823 return response
2824
2825 async def create_exclusion(
2826 self,
2827 request: Optional[Union[logging_config.CreateExclusionRequest, dict]] = None,
2828 *,
2829 parent: Optional[str] = None,
2830 exclusion: Optional[logging_config.LogExclusion] = None,
2831 retry: OptionalRetry = gapic_v1.method.DEFAULT,
2832 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2833 metadata: Sequence[Tuple[str, str]] = (),
2834 ) -> logging_config.LogExclusion:
2835 r"""Creates a new exclusion in the \_Default sink in a specified
2836 parent resource. Only log entries belonging to that resource can
2837 be excluded. You can have up to 10 exclusions in a resource.
2838
2839 .. code-block:: python
2840
2841 # This snippet has been automatically generated and should be regarded as a
2842 # code template only.
2843 # It will require modifications to work:
2844 # - It may require correct/in-range values for request initialization.
2845 # - It may require specifying regional endpoints when creating the service
2846 # client as shown in:
2847 # https://googleapis.dev/python/google-api-core/latest/client_options.html
2848 from google.cloud import logging_v2
2849
2850 async def sample_create_exclusion():
2851 # Create a client
2852 client = logging_v2.ConfigServiceV2AsyncClient()
2853
2854 # Initialize request argument(s)
2855 exclusion = logging_v2.LogExclusion()
2856 exclusion.name = "name_value"
2857 exclusion.filter = "filter_value"
2858
2859 request = logging_v2.CreateExclusionRequest(
2860 parent="parent_value",
2861 exclusion=exclusion,
2862 )
2863
2864 # Make the request
2865 response = await client.create_exclusion(request=request)
2866
2867 # Handle the response
2868 print(response)
2869
2870 Args:
2871 request (Optional[Union[google.cloud.logging_v2.types.CreateExclusionRequest, dict]]):
2872 The request object. The parameters to ``CreateExclusion``.
2873 parent (:class:`str`):
2874 Required. The parent resource in which to create the
2875 exclusion:
2876
2877 ::
2878
2879 "projects/[PROJECT_ID]"
2880 "organizations/[ORGANIZATION_ID]"
2881 "billingAccounts/[BILLING_ACCOUNT_ID]"
2882 "folders/[FOLDER_ID]"
2883
2884 For examples:
2885
2886 ``"projects/my-logging-project"``
2887 ``"organizations/123456789"``
2888
2889 This corresponds to the ``parent`` field
2890 on the ``request`` instance; if ``request`` is provided, this
2891 should not be set.
2892 exclusion (:class:`google.cloud.logging_v2.types.LogExclusion`):
2893 Required. The new exclusion, whose ``name`` parameter is
2894 an exclusion name that is not already used in the parent
2895 resource.
2896
2897 This corresponds to the ``exclusion`` field
2898 on the ``request`` instance; if ``request`` is provided, this
2899 should not be set.
2900 retry (google.api_core.retry.Retry): Designation of what errors, if any,
2901 should be retried.
2902 timeout (float): The timeout for this request.
2903 metadata (Sequence[Tuple[str, str]]): Strings which should be
2904 sent along with the request as metadata.
2905
2906 Returns:
2907 google.cloud.logging_v2.types.LogExclusion:
2908 Specifies a set of log entries that are filtered out by a sink. If
2909 your Google Cloud resource receives a large volume of
2910 log entries, you can use exclusions to reduce your
2911 chargeable logs. Note that exclusions on
2912 organization-level and folder-level sinks don't apply
2913 to child resources. Note also that you cannot modify
2914 the \_Required sink or exclude logs from it.
2915
2916 """
2917 # Create or coerce a protobuf request object.
2918 # Quick check: If we got a request object, we should *not* have
2919 # gotten any keyword arguments that map to the request.
2920 has_flattened_params = any([parent, exclusion])
2921 if request is not None and has_flattened_params:
2922 raise ValueError(
2923 "If the `request` argument is set, then none of "
2924 "the individual field arguments should be set."
2925 )
2926
2927 request = logging_config.CreateExclusionRequest(request)
2928
2929 # If we have keyword arguments corresponding to fields on the
2930 # request, apply these.
2931 if parent is not None:
2932 request.parent = parent
2933 if exclusion is not None:
2934 request.exclusion = exclusion
2935
2936 # Wrap the RPC method; this adds retry and timeout information,
2937 # and friendly error handling.
2938 rpc = gapic_v1.method_async.wrap_method(
2939 self._client._transport.create_exclusion,
2940 default_timeout=120.0,
2941 client_info=DEFAULT_CLIENT_INFO,
2942 )
2943
2944 # Certain fields should be provided within the metadata header;
2945 # add these here.
2946 metadata = tuple(metadata) + (
2947 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
2948 )
2949
2950 # Send the request.
2951 response = await rpc(
2952 request,
2953 retry=retry,
2954 timeout=timeout,
2955 metadata=metadata,
2956 )
2957
2958 # Done; return the response.
2959 return response
2960
2961 async def update_exclusion(
2962 self,
2963 request: Optional[Union[logging_config.UpdateExclusionRequest, dict]] = None,
2964 *,
2965 name: Optional[str] = None,
2966 exclusion: Optional[logging_config.LogExclusion] = None,
2967 update_mask: Optional[field_mask_pb2.FieldMask] = None,
2968 retry: OptionalRetry = gapic_v1.method.DEFAULT,
2969 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2970 metadata: Sequence[Tuple[str, str]] = (),
2971 ) -> logging_config.LogExclusion:
2972 r"""Changes one or more properties of an existing exclusion in the
2973 \_Default sink.
2974
2975 .. code-block:: python
2976
2977 # This snippet has been automatically generated and should be regarded as a
2978 # code template only.
2979 # It will require modifications to work:
2980 # - It may require correct/in-range values for request initialization.
2981 # - It may require specifying regional endpoints when creating the service
2982 # client as shown in:
2983 # https://googleapis.dev/python/google-api-core/latest/client_options.html
2984 from google.cloud import logging_v2
2985
2986 async def sample_update_exclusion():
2987 # Create a client
2988 client = logging_v2.ConfigServiceV2AsyncClient()
2989
2990 # Initialize request argument(s)
2991 exclusion = logging_v2.LogExclusion()
2992 exclusion.name = "name_value"
2993 exclusion.filter = "filter_value"
2994
2995 request = logging_v2.UpdateExclusionRequest(
2996 name="name_value",
2997 exclusion=exclusion,
2998 )
2999
3000 # Make the request
3001 response = await client.update_exclusion(request=request)
3002
3003 # Handle the response
3004 print(response)
3005
3006 Args:
3007 request (Optional[Union[google.cloud.logging_v2.types.UpdateExclusionRequest, dict]]):
3008 The request object. The parameters to ``UpdateExclusion``.
3009 name (:class:`str`):
3010 Required. The resource name of the exclusion to update:
3011
3012 ::
3013
3014 "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]"
3015 "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]"
3016 "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]"
3017 "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]"
3018
3019 For example:
3020
3021 ``"projects/my-project/exclusions/my-exclusion"``
3022
3023 This corresponds to the ``name`` field
3024 on the ``request`` instance; if ``request`` is provided, this
3025 should not be set.
3026 exclusion (:class:`google.cloud.logging_v2.types.LogExclusion`):
3027 Required. New values for the existing exclusion. Only
3028 the fields specified in ``update_mask`` are relevant.
3029
3030 This corresponds to the ``exclusion`` field
3031 on the ``request`` instance; if ``request`` is provided, this
3032 should not be set.
3033 update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
3034 Required. A non-empty list of fields to change in the
3035 existing exclusion. New values for the fields are taken
3036 from the corresponding fields in the
3037 [LogExclusion][google.logging.v2.LogExclusion] included
3038 in this request. Fields not mentioned in ``update_mask``
3039 are not changed and are ignored in the request.
3040
3041 For example, to change the filter and description of an
3042 exclusion, specify an ``update_mask`` of
3043 ``"filter,description"``.
3044
3045 This corresponds to the ``update_mask`` field
3046 on the ``request`` instance; if ``request`` is provided, this
3047 should not be set.
3048 retry (google.api_core.retry.Retry): Designation of what errors, if any,
3049 should be retried.
3050 timeout (float): The timeout for this request.
3051 metadata (Sequence[Tuple[str, str]]): Strings which should be
3052 sent along with the request as metadata.
3053
3054 Returns:
3055 google.cloud.logging_v2.types.LogExclusion:
3056 Specifies a set of log entries that are filtered out by a sink. If
3057 your Google Cloud resource receives a large volume of
3058 log entries, you can use exclusions to reduce your
3059 chargeable logs. Note that exclusions on
3060 organization-level and folder-level sinks don't apply
3061 to child resources. Note also that you cannot modify
3062 the \_Required sink or exclude logs from it.
3063
3064 """
3065 # Create or coerce a protobuf request object.
3066 # Quick check: If we got a request object, we should *not* have
3067 # gotten any keyword arguments that map to the request.
3068 has_flattened_params = any([name, exclusion, update_mask])
3069 if request is not None and has_flattened_params:
3070 raise ValueError(
3071 "If the `request` argument is set, then none of "
3072 "the individual field arguments should be set."
3073 )
3074
3075 request = logging_config.UpdateExclusionRequest(request)
3076
3077 # If we have keyword arguments corresponding to fields on the
3078 # request, apply these.
3079 if name is not None:
3080 request.name = name
3081 if exclusion is not None:
3082 request.exclusion = exclusion
3083 if update_mask is not None:
3084 request.update_mask = update_mask
3085
3086 # Wrap the RPC method; this adds retry and timeout information,
3087 # and friendly error handling.
3088 rpc = gapic_v1.method_async.wrap_method(
3089 self._client._transport.update_exclusion,
3090 default_timeout=120.0,
3091 client_info=DEFAULT_CLIENT_INFO,
3092 )
3093
3094 # Certain fields should be provided within the metadata header;
3095 # add these here.
3096 metadata = tuple(metadata) + (
3097 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
3098 )
3099
3100 # Send the request.
3101 response = await rpc(
3102 request,
3103 retry=retry,
3104 timeout=timeout,
3105 metadata=metadata,
3106 )
3107
3108 # Done; return the response.
3109 return response
3110
3111 async def delete_exclusion(
3112 self,
3113 request: Optional[Union[logging_config.DeleteExclusionRequest, dict]] = None,
3114 *,
3115 name: Optional[str] = None,
3116 retry: OptionalRetry = gapic_v1.method.DEFAULT,
3117 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3118 metadata: Sequence[Tuple[str, str]] = (),
3119 ) -> None:
3120 r"""Deletes an exclusion in the \_Default sink.
3121
3122 .. code-block:: python
3123
3124 # This snippet has been automatically generated and should be regarded as a
3125 # code template only.
3126 # It will require modifications to work:
3127 # - It may require correct/in-range values for request initialization.
3128 # - It may require specifying regional endpoints when creating the service
3129 # client as shown in:
3130 # https://googleapis.dev/python/google-api-core/latest/client_options.html
3131 from google.cloud import logging_v2
3132
3133 async def sample_delete_exclusion():
3134 # Create a client
3135 client = logging_v2.ConfigServiceV2AsyncClient()
3136
3137 # Initialize request argument(s)
3138 request = logging_v2.DeleteExclusionRequest(
3139 name="name_value",
3140 )
3141
3142 # Make the request
3143 await client.delete_exclusion(request=request)
3144
3145 Args:
3146 request (Optional[Union[google.cloud.logging_v2.types.DeleteExclusionRequest, dict]]):
3147 The request object. The parameters to ``DeleteExclusion``.
3148 name (:class:`str`):
3149 Required. The resource name of an existing exclusion to
3150 delete:
3151
3152 ::
3153
3154 "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]"
3155 "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]"
3156 "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]"
3157 "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]"
3158
3159 For example:
3160
3161 ``"projects/my-project/exclusions/my-exclusion"``
3162
3163 This corresponds to the ``name`` field
3164 on the ``request`` instance; if ``request`` is provided, this
3165 should not be set.
3166 retry (google.api_core.retry.Retry): Designation of what errors, if any,
3167 should be retried.
3168 timeout (float): The timeout for this request.
3169 metadata (Sequence[Tuple[str, str]]): Strings which should be
3170 sent along with the request as metadata.
3171 """
3172 # Create or coerce a protobuf request object.
3173 # Quick check: If we got a request object, we should *not* have
3174 # gotten any keyword arguments that map to the request.
3175 has_flattened_params = any([name])
3176 if request is not None and has_flattened_params:
3177 raise ValueError(
3178 "If the `request` argument is set, then none of "
3179 "the individual field arguments should be set."
3180 )
3181
3182 request = logging_config.DeleteExclusionRequest(request)
3183
3184 # If we have keyword arguments corresponding to fields on the
3185 # request, apply these.
3186 if name is not None:
3187 request.name = name
3188
3189 # Wrap the RPC method; this adds retry and timeout information,
3190 # and friendly error handling.
3191 rpc = gapic_v1.method_async.wrap_method(
3192 self._client._transport.delete_exclusion,
3193 default_retry=retries.Retry(
3194 initial=0.1,
3195 maximum=60.0,
3196 multiplier=1.3,
3197 predicate=retries.if_exception_type(
3198 core_exceptions.DeadlineExceeded,
3199 core_exceptions.InternalServerError,
3200 core_exceptions.ServiceUnavailable,
3201 ),
3202 deadline=60.0,
3203 ),
3204 default_timeout=60.0,
3205 client_info=DEFAULT_CLIENT_INFO,
3206 )
3207
3208 # Certain fields should be provided within the metadata header;
3209 # add these here.
3210 metadata = tuple(metadata) + (
3211 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
3212 )
3213
3214 # Send the request.
3215 await rpc(
3216 request,
3217 retry=retry,
3218 timeout=timeout,
3219 metadata=metadata,
3220 )
3221
3222 async def get_cmek_settings(
3223 self,
3224 request: Optional[Union[logging_config.GetCmekSettingsRequest, dict]] = None,
3225 *,
3226 retry: OptionalRetry = gapic_v1.method.DEFAULT,
3227 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3228 metadata: Sequence[Tuple[str, str]] = (),
3229 ) -> logging_config.CmekSettings:
3230 r"""Gets the Logging CMEK settings for the given resource.
3231
3232 Note: CMEK for the Log Router can be configured for Google Cloud
3233 projects, folders, organizations and billing accounts. Once
3234 configured for an organization, it applies to all projects and
3235 folders in the Google Cloud organization.
3236
3237 See `Enabling CMEK for Log
3238 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
3239 for more information.
3240
3241 .. code-block:: python
3242
3243 # This snippet has been automatically generated and should be regarded as a
3244 # code template only.
3245 # It will require modifications to work:
3246 # - It may require correct/in-range values for request initialization.
3247 # - It may require specifying regional endpoints when creating the service
3248 # client as shown in:
3249 # https://googleapis.dev/python/google-api-core/latest/client_options.html
3250 from google.cloud import logging_v2
3251
3252 async def sample_get_cmek_settings():
3253 # Create a client
3254 client = logging_v2.ConfigServiceV2AsyncClient()
3255
3256 # Initialize request argument(s)
3257 request = logging_v2.GetCmekSettingsRequest(
3258 name="name_value",
3259 )
3260
3261 # Make the request
3262 response = await client.get_cmek_settings(request=request)
3263
3264 # Handle the response
3265 print(response)
3266
3267 Args:
3268 request (Optional[Union[google.cloud.logging_v2.types.GetCmekSettingsRequest, dict]]):
3269 The request object. The parameters to
3270 [GetCmekSettings][google.logging.v2.ConfigServiceV2.GetCmekSettings].
3271
3272 See `Enabling CMEK for Log
3273 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
3274 for more information.
3275 retry (google.api_core.retry.Retry): Designation of what errors, if any,
3276 should be retried.
3277 timeout (float): The timeout for this request.
3278 metadata (Sequence[Tuple[str, str]]): Strings which should be
3279 sent along with the request as metadata.
3280
3281 Returns:
3282 google.cloud.logging_v2.types.CmekSettings:
3283 Describes the customer-managed encryption key (CMEK) settings associated with
3284 a project, folder, organization, billing account, or
3285 flexible resource.
3286
3287 Note: CMEK for the Log Router can currently only be
3288 configured for Google Cloud organizations. Once
3289 configured, it applies to all projects and folders in
3290 the Google Cloud organization.
3291
3292 See [Enabling CMEK for Log
3293 Router](\ https://cloud.google.com/logging/docs/routing/managed-encryption)
3294 for more information.
3295
3296 """
3297 # Create or coerce a protobuf request object.
3298 request = logging_config.GetCmekSettingsRequest(request)
3299
3300 # Wrap the RPC method; this adds retry and timeout information,
3301 # and friendly error handling.
3302 rpc = gapic_v1.method_async.wrap_method(
3303 self._client._transport.get_cmek_settings,
3304 default_timeout=None,
3305 client_info=DEFAULT_CLIENT_INFO,
3306 )
3307
3308 # Certain fields should be provided within the metadata header;
3309 # add these here.
3310 metadata = tuple(metadata) + (
3311 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
3312 )
3313
3314 # Send the request.
3315 response = await rpc(
3316 request,
3317 retry=retry,
3318 timeout=timeout,
3319 metadata=metadata,
3320 )
3321
3322 # Done; return the response.
3323 return response
3324
3325 async def update_cmek_settings(
3326 self,
3327 request: Optional[Union[logging_config.UpdateCmekSettingsRequest, dict]] = None,
3328 *,
3329 retry: OptionalRetry = gapic_v1.method.DEFAULT,
3330 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3331 metadata: Sequence[Tuple[str, str]] = (),
3332 ) -> logging_config.CmekSettings:
3333 r"""Updates the Log Router CMEK settings for the given resource.
3334
3335 Note: CMEK for the Log Router can currently only be configured
3336 for Google Cloud organizations. Once configured, it applies to
3337 all projects and folders in the Google Cloud organization.
3338
3339 [UpdateCmekSettings][google.logging.v2.ConfigServiceV2.UpdateCmekSettings]
3340 will fail if 1) ``kms_key_name`` is invalid, or 2) the
3341 associated service account does not have the required
3342 ``roles/cloudkms.cryptoKeyEncrypterDecrypter`` role assigned for
3343 the key, or 3) access to the key is disabled.
3344
3345 See `Enabling CMEK for Log
3346 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
3347 for more information.
3348
3349 .. code-block:: python
3350
3351 # This snippet has been automatically generated and should be regarded as a
3352 # code template only.
3353 # It will require modifications to work:
3354 # - It may require correct/in-range values for request initialization.
3355 # - It may require specifying regional endpoints when creating the service
3356 # client as shown in:
3357 # https://googleapis.dev/python/google-api-core/latest/client_options.html
3358 from google.cloud import logging_v2
3359
3360 async def sample_update_cmek_settings():
3361 # Create a client
3362 client = logging_v2.ConfigServiceV2AsyncClient()
3363
3364 # Initialize request argument(s)
3365 request = logging_v2.UpdateCmekSettingsRequest(
3366 name="name_value",
3367 )
3368
3369 # Make the request
3370 response = await client.update_cmek_settings(request=request)
3371
3372 # Handle the response
3373 print(response)
3374
3375 Args:
3376 request (Optional[Union[google.cloud.logging_v2.types.UpdateCmekSettingsRequest, dict]]):
3377 The request object. The parameters to
3378 [UpdateCmekSettings][google.logging.v2.ConfigServiceV2.UpdateCmekSettings].
3379
3380 See `Enabling CMEK for Log
3381 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
3382 for more information.
3383 retry (google.api_core.retry.Retry): Designation of what errors, if any,
3384 should be retried.
3385 timeout (float): The timeout for this request.
3386 metadata (Sequence[Tuple[str, str]]): Strings which should be
3387 sent along with the request as metadata.
3388
3389 Returns:
3390 google.cloud.logging_v2.types.CmekSettings:
3391 Describes the customer-managed encryption key (CMEK) settings associated with
3392 a project, folder, organization, billing account, or
3393 flexible resource.
3394
3395 Note: CMEK for the Log Router can currently only be
3396 configured for Google Cloud organizations. Once
3397 configured, it applies to all projects and folders in
3398 the Google Cloud organization.
3399
3400 See [Enabling CMEK for Log
3401 Router](\ https://cloud.google.com/logging/docs/routing/managed-encryption)
3402 for more information.
3403
3404 """
3405 # Create or coerce a protobuf request object.
3406 request = logging_config.UpdateCmekSettingsRequest(request)
3407
3408 # Wrap the RPC method; this adds retry and timeout information,
3409 # and friendly error handling.
3410 rpc = gapic_v1.method_async.wrap_method(
3411 self._client._transport.update_cmek_settings,
3412 default_timeout=None,
3413 client_info=DEFAULT_CLIENT_INFO,
3414 )
3415
3416 # Certain fields should be provided within the metadata header;
3417 # add these here.
3418 metadata = tuple(metadata) + (
3419 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
3420 )
3421
3422 # Send the request.
3423 response = await rpc(
3424 request,
3425 retry=retry,
3426 timeout=timeout,
3427 metadata=metadata,
3428 )
3429
3430 # Done; return the response.
3431 return response
3432
3433 async def get_settings(
3434 self,
3435 request: Optional[Union[logging_config.GetSettingsRequest, dict]] = None,
3436 *,
3437 name: Optional[str] = None,
3438 retry: OptionalRetry = gapic_v1.method.DEFAULT,
3439 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3440 metadata: Sequence[Tuple[str, str]] = (),
3441 ) -> logging_config.Settings:
3442 r"""Gets the Log Router settings for the given resource.
3443
3444 Note: Settings for the Log Router can be get for Google Cloud
3445 projects, folders, organizations and billing accounts. Currently
3446 it can only be configured for organizations. Once configured for
3447 an organization, it applies to all projects and folders in the
3448 Google Cloud organization.
3449
3450 See `Enabling CMEK for Log
3451 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
3452 for more information.
3453
3454 .. code-block:: python
3455
3456 # This snippet has been automatically generated and should be regarded as a
3457 # code template only.
3458 # It will require modifications to work:
3459 # - It may require correct/in-range values for request initialization.
3460 # - It may require specifying regional endpoints when creating the service
3461 # client as shown in:
3462 # https://googleapis.dev/python/google-api-core/latest/client_options.html
3463 from google.cloud import logging_v2
3464
3465 async def sample_get_settings():
3466 # Create a client
3467 client = logging_v2.ConfigServiceV2AsyncClient()
3468
3469 # Initialize request argument(s)
3470 request = logging_v2.GetSettingsRequest(
3471 name="name_value",
3472 )
3473
3474 # Make the request
3475 response = await client.get_settings(request=request)
3476
3477 # Handle the response
3478 print(response)
3479
3480 Args:
3481 request (Optional[Union[google.cloud.logging_v2.types.GetSettingsRequest, dict]]):
3482 The request object. The parameters to
3483 [GetSettings][google.logging.v2.ConfigServiceV2.GetSettings].
3484
3485 See `Enabling CMEK for Log
3486 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
3487 for more information.
3488 name (:class:`str`):
3489 Required. The resource for which to retrieve settings.
3490
3491 ::
3492
3493 "projects/[PROJECT_ID]/settings"
3494 "organizations/[ORGANIZATION_ID]/settings"
3495 "billingAccounts/[BILLING_ACCOUNT_ID]/settings"
3496 "folders/[FOLDER_ID]/settings"
3497
3498 For example:
3499
3500 ``"organizations/12345/settings"``
3501
3502 Note: Settings for the Log Router can be get for Google
3503 Cloud projects, folders, organizations and billing
3504 accounts. Currently it can only be configured for
3505 organizations. Once configured for an organization, it
3506 applies to all projects and folders in the Google Cloud
3507 organization.
3508
3509 This corresponds to the ``name`` field
3510 on the ``request`` instance; if ``request`` is provided, this
3511 should not be set.
3512 retry (google.api_core.retry.Retry): Designation of what errors, if any,
3513 should be retried.
3514 timeout (float): The timeout for this request.
3515 metadata (Sequence[Tuple[str, str]]): Strings which should be
3516 sent along with the request as metadata.
3517
3518 Returns:
3519 google.cloud.logging_v2.types.Settings:
3520 Describes the settings associated
3521 with a project, folder, organization,
3522 billing account, or flexible resource.
3523
3524 """
3525 # Create or coerce a protobuf request object.
3526 # Quick check: If we got a request object, we should *not* have
3527 # gotten any keyword arguments that map to the request.
3528 has_flattened_params = any([name])
3529 if request is not None and has_flattened_params:
3530 raise ValueError(
3531 "If the `request` argument is set, then none of "
3532 "the individual field arguments should be set."
3533 )
3534
3535 request = logging_config.GetSettingsRequest(request)
3536
3537 # If we have keyword arguments corresponding to fields on the
3538 # request, apply these.
3539 if name is not None:
3540 request.name = name
3541
3542 # Wrap the RPC method; this adds retry and timeout information,
3543 # and friendly error handling.
3544 rpc = gapic_v1.method_async.wrap_method(
3545 self._client._transport.get_settings,
3546 default_timeout=None,
3547 client_info=DEFAULT_CLIENT_INFO,
3548 )
3549
3550 # Certain fields should be provided within the metadata header;
3551 # add these here.
3552 metadata = tuple(metadata) + (
3553 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
3554 )
3555
3556 # Send the request.
3557 response = await rpc(
3558 request,
3559 retry=retry,
3560 timeout=timeout,
3561 metadata=metadata,
3562 )
3563
3564 # Done; return the response.
3565 return response
3566
3567 async def update_settings(
3568 self,
3569 request: Optional[Union[logging_config.UpdateSettingsRequest, dict]] = None,
3570 *,
3571 settings: Optional[logging_config.Settings] = None,
3572 update_mask: Optional[field_mask_pb2.FieldMask] = None,
3573 retry: OptionalRetry = gapic_v1.method.DEFAULT,
3574 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3575 metadata: Sequence[Tuple[str, str]] = (),
3576 ) -> logging_config.Settings:
3577 r"""Updates the Log Router settings for the given resource.
3578
3579 Note: Settings for the Log Router can currently only be
3580 configured for Google Cloud organizations. Once configured, it
3581 applies to all projects and folders in the Google Cloud
3582 organization.
3583
3584 [UpdateSettings][google.logging.v2.ConfigServiceV2.UpdateSettings]
3585 will fail if 1) ``kms_key_name`` is invalid, or 2) the
3586 associated service account does not have the required
3587 ``roles/cloudkms.cryptoKeyEncrypterDecrypter`` role assigned for
3588 the key, or 3) access to the key is disabled. 4) ``location_id``
3589 is not supported by Logging. 5) ``location_id`` violate
3590 OrgPolicy.
3591
3592 See `Enabling CMEK for Log
3593 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
3594 for more information.
3595
3596 .. code-block:: python
3597
3598 # This snippet has been automatically generated and should be regarded as a
3599 # code template only.
3600 # It will require modifications to work:
3601 # - It may require correct/in-range values for request initialization.
3602 # - It may require specifying regional endpoints when creating the service
3603 # client as shown in:
3604 # https://googleapis.dev/python/google-api-core/latest/client_options.html
3605 from google.cloud import logging_v2
3606
3607 async def sample_update_settings():
3608 # Create a client
3609 client = logging_v2.ConfigServiceV2AsyncClient()
3610
3611 # Initialize request argument(s)
3612 request = logging_v2.UpdateSettingsRequest(
3613 name="name_value",
3614 )
3615
3616 # Make the request
3617 response = await client.update_settings(request=request)
3618
3619 # Handle the response
3620 print(response)
3621
3622 Args:
3623 request (Optional[Union[google.cloud.logging_v2.types.UpdateSettingsRequest, dict]]):
3624 The request object. The parameters to
3625 [UpdateSettings][google.logging.v2.ConfigServiceV2.UpdateSettings].
3626
3627 See `Enabling CMEK for Log
3628 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
3629 for more information.
3630 settings (:class:`google.cloud.logging_v2.types.Settings`):
3631 Required. The settings to update.
3632
3633 See `Enabling CMEK for Log
3634 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
3635 for more information.
3636
3637 This corresponds to the ``settings`` field
3638 on the ``request`` instance; if ``request`` is provided, this
3639 should not be set.
3640 update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
3641 Optional. Field mask identifying which fields from
3642 ``settings`` should be updated. A field will be
3643 overwritten if and only if it is in the update mask.
3644 Output only fields cannot be updated.
3645
3646 See [FieldMask][google.protobuf.FieldMask] for more
3647 information.
3648
3649 For example: ``"updateMask=kmsKeyName"``
3650
3651 This corresponds to the ``update_mask`` field
3652 on the ``request`` instance; if ``request`` is provided, this
3653 should not be set.
3654 retry (google.api_core.retry.Retry): Designation of what errors, if any,
3655 should be retried.
3656 timeout (float): The timeout for this request.
3657 metadata (Sequence[Tuple[str, str]]): Strings which should be
3658 sent along with the request as metadata.
3659
3660 Returns:
3661 google.cloud.logging_v2.types.Settings:
3662 Describes the settings associated
3663 with a project, folder, organization,
3664 billing account, or flexible resource.
3665
3666 """
3667 # Create or coerce a protobuf request object.
3668 # Quick check: If we got a request object, we should *not* have
3669 # gotten any keyword arguments that map to the request.
3670 has_flattened_params = any([settings, update_mask])
3671 if request is not None and has_flattened_params:
3672 raise ValueError(
3673 "If the `request` argument is set, then none of "
3674 "the individual field arguments should be set."
3675 )
3676
3677 request = logging_config.UpdateSettingsRequest(request)
3678
3679 # If we have keyword arguments corresponding to fields on the
3680 # request, apply these.
3681 if settings is not None:
3682 request.settings = settings
3683 if update_mask is not None:
3684 request.update_mask = update_mask
3685
3686 # Wrap the RPC method; this adds retry and timeout information,
3687 # and friendly error handling.
3688 rpc = gapic_v1.method_async.wrap_method(
3689 self._client._transport.update_settings,
3690 default_timeout=None,
3691 client_info=DEFAULT_CLIENT_INFO,
3692 )
3693
3694 # Certain fields should be provided within the metadata header;
3695 # add these here.
3696 metadata = tuple(metadata) + (
3697 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
3698 )
3699
3700 # Send the request.
3701 response = await rpc(
3702 request,
3703 retry=retry,
3704 timeout=timeout,
3705 metadata=metadata,
3706 )
3707
3708 # Done; return the response.
3709 return response
3710
3711 async def copy_log_entries(
3712 self,
3713 request: Optional[Union[logging_config.CopyLogEntriesRequest, dict]] = None,
3714 *,
3715 retry: OptionalRetry = gapic_v1.method.DEFAULT,
3716 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3717 metadata: Sequence[Tuple[str, str]] = (),
3718 ) -> operation_async.AsyncOperation:
3719 r"""Copies a set of log entries from a log bucket to a
3720 Cloud Storage bucket.
3721
3722 .. code-block:: python
3723
3724 # This snippet has been automatically generated and should be regarded as a
3725 # code template only.
3726 # It will require modifications to work:
3727 # - It may require correct/in-range values for request initialization.
3728 # - It may require specifying regional endpoints when creating the service
3729 # client as shown in:
3730 # https://googleapis.dev/python/google-api-core/latest/client_options.html
3731 from google.cloud import logging_v2
3732
3733 async def sample_copy_log_entries():
3734 # Create a client
3735 client = logging_v2.ConfigServiceV2AsyncClient()
3736
3737 # Initialize request argument(s)
3738 request = logging_v2.CopyLogEntriesRequest(
3739 name="name_value",
3740 destination="destination_value",
3741 )
3742
3743 # Make the request
3744 operation = client.copy_log_entries(request=request)
3745
3746 print("Waiting for operation to complete...")
3747
3748 response = (await operation).result()
3749
3750 # Handle the response
3751 print(response)
3752
3753 Args:
3754 request (Optional[Union[google.cloud.logging_v2.types.CopyLogEntriesRequest, dict]]):
3755 The request object. The parameters to CopyLogEntries.
3756 retry (google.api_core.retry.Retry): Designation of what errors, if any,
3757 should be retried.
3758 timeout (float): The timeout for this request.
3759 metadata (Sequence[Tuple[str, str]]): Strings which should be
3760 sent along with the request as metadata.
3761
3762 Returns:
3763 google.api_core.operation_async.AsyncOperation:
3764 An object representing a long-running operation.
3765
3766 The result type for the operation will be
3767 :class:`google.cloud.logging_v2.types.CopyLogEntriesResponse`
3768 Response type for CopyLogEntries long running
3769 operations.
3770
3771 """
3772 # Create or coerce a protobuf request object.
3773 request = logging_config.CopyLogEntriesRequest(request)
3774
3775 # Wrap the RPC method; this adds retry and timeout information,
3776 # and friendly error handling.
3777 rpc = gapic_v1.method_async.wrap_method(
3778 self._client._transport.copy_log_entries,
3779 default_timeout=None,
3780 client_info=DEFAULT_CLIENT_INFO,
3781 )
3782
3783 # Send the request.
3784 response = await rpc(
3785 request,
3786 retry=retry,
3787 timeout=timeout,
3788 metadata=metadata,
3789 )
3790
3791 # Wrap the response in an operation future.
3792 response = operation_async.from_gapic(
3793 response,
3794 self._client._transport.operations_client,
3795 logging_config.CopyLogEntriesResponse,
3796 metadata_type=logging_config.CopyLogEntriesMetadata,
3797 )
3798
3799 # Done; return the response.
3800 return response
3801
3802 async def list_operations(
3803 self,
3804 request: Optional[operations_pb2.ListOperationsRequest] = None,
3805 *,
3806 retry: OptionalRetry = gapic_v1.method.DEFAULT,
3807 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3808 metadata: Sequence[Tuple[str, str]] = (),
3809 ) -> operations_pb2.ListOperationsResponse:
3810 r"""Lists operations that match the specified filter in the request.
3811
3812 Args:
3813 request (:class:`~.operations_pb2.ListOperationsRequest`):
3814 The request object. Request message for
3815 `ListOperations` method.
3816 retry (google.api_core.retry.Retry): Designation of what errors,
3817 if any, should be retried.
3818 timeout (float): The timeout for this request.
3819 metadata (Sequence[Tuple[str, str]]): Strings which should be
3820 sent along with the request as metadata.
3821 Returns:
3822 ~.operations_pb2.ListOperationsResponse:
3823 Response message for ``ListOperations`` method.
3824 """
3825 # Create or coerce a protobuf request object.
3826 # The request isn't a proto-plus wrapped type,
3827 # so it must be constructed via keyword expansion.
3828 if isinstance(request, dict):
3829 request = operations_pb2.ListOperationsRequest(**request)
3830
3831 # Wrap the RPC method; this adds retry and timeout information,
3832 # and friendly error handling.
3833 rpc = gapic_v1.method.wrap_method(
3834 self._client._transport.list_operations,
3835 default_timeout=None,
3836 client_info=DEFAULT_CLIENT_INFO,
3837 )
3838
3839 # Certain fields should be provided within the metadata header;
3840 # add these here.
3841 metadata = tuple(metadata) + (
3842 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
3843 )
3844
3845 # Send the request.
3846 response = await rpc(
3847 request,
3848 retry=retry,
3849 timeout=timeout,
3850 metadata=metadata,
3851 )
3852
3853 # Done; return the response.
3854 return response
3855
3856 async def get_operation(
3857 self,
3858 request: Optional[operations_pb2.GetOperationRequest] = None,
3859 *,
3860 retry: OptionalRetry = gapic_v1.method.DEFAULT,
3861 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3862 metadata: Sequence[Tuple[str, str]] = (),
3863 ) -> operations_pb2.Operation:
3864 r"""Gets the latest state of a long-running operation.
3865
3866 Args:
3867 request (:class:`~.operations_pb2.GetOperationRequest`):
3868 The request object. Request message for
3869 `GetOperation` method.
3870 retry (google.api_core.retry.Retry): Designation of what errors,
3871 if any, should be retried.
3872 timeout (float): The timeout for this request.
3873 metadata (Sequence[Tuple[str, str]]): Strings which should be
3874 sent along with the request as metadata.
3875 Returns:
3876 ~.operations_pb2.Operation:
3877 An ``Operation`` object.
3878 """
3879 # Create or coerce a protobuf request object.
3880 # The request isn't a proto-plus wrapped type,
3881 # so it must be constructed via keyword expansion.
3882 if isinstance(request, dict):
3883 request = operations_pb2.GetOperationRequest(**request)
3884
3885 # Wrap the RPC method; this adds retry and timeout information,
3886 # and friendly error handling.
3887 rpc = gapic_v1.method.wrap_method(
3888 self._client._transport.get_operation,
3889 default_timeout=None,
3890 client_info=DEFAULT_CLIENT_INFO,
3891 )
3892
3893 # Certain fields should be provided within the metadata header;
3894 # add these here.
3895 metadata = tuple(metadata) + (
3896 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
3897 )
3898
3899 # Send the request.
3900 response = await rpc(
3901 request,
3902 retry=retry,
3903 timeout=timeout,
3904 metadata=metadata,
3905 )
3906
3907 # Done; return the response.
3908 return response
3909
3910 async def cancel_operation(
3911 self,
3912 request: Optional[operations_pb2.CancelOperationRequest] = None,
3913 *,
3914 retry: OptionalRetry = gapic_v1.method.DEFAULT,
3915 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
3916 metadata: Sequence[Tuple[str, str]] = (),
3917 ) -> None:
3918 r"""Starts asynchronous cancellation on a long-running operation.
3919
3920 The server makes a best effort to cancel the operation, but success
3921 is not guaranteed. If the server doesn't support this method, it returns
3922 `google.rpc.Code.UNIMPLEMENTED`.
3923
3924 Args:
3925 request (:class:`~.operations_pb2.CancelOperationRequest`):
3926 The request object. Request message for
3927 `CancelOperation` method.
3928 retry (google.api_core.retry.Retry): Designation of what errors,
3929 if any, should be retried.
3930 timeout (float): The timeout for this request.
3931 metadata (Sequence[Tuple[str, str]]): Strings which should be
3932 sent along with the request as metadata.
3933 Returns:
3934 None
3935 """
3936 # Create or coerce a protobuf request object.
3937 # The request isn't a proto-plus wrapped type,
3938 # so it must be constructed via keyword expansion.
3939 if isinstance(request, dict):
3940 request = operations_pb2.CancelOperationRequest(**request)
3941
3942 # Wrap the RPC method; this adds retry and timeout information,
3943 # and friendly error handling.
3944 rpc = gapic_v1.method.wrap_method(
3945 self._client._transport.cancel_operation,
3946 default_timeout=None,
3947 client_info=DEFAULT_CLIENT_INFO,
3948 )
3949
3950 # Certain fields should be provided within the metadata header;
3951 # add these here.
3952 metadata = tuple(metadata) + (
3953 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
3954 )
3955
3956 # Send the request.
3957 await rpc(
3958 request,
3959 retry=retry,
3960 timeout=timeout,
3961 metadata=metadata,
3962 )
3963
3964 async def __aenter__(self) -> "ConfigServiceV2AsyncClient":
3965 return self
3966
3967 async def __aexit__(self, exc_type, exc, tb):
3968 await self.transport.close()
3969
3970
3971DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
3972 gapic_version=package_version.__version__
3973)
3974
3975
3976__all__ = ("ConfigServiceV2AsyncClient",)