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