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)
31
32from google.cloud.errorreporting_v1beta1 import gapic_version as package_version
33
34from google.api_core.client_options import ClientOptions
35from google.api_core import exceptions as core_exceptions
36from google.api_core import gapic_v1
37from google.api_core import retry_async as retries
38from google.auth import credentials as ga_credentials # type: ignore
39from google.oauth2 import service_account # type: ignore
40import google.protobuf
41
42
43try:
44 OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None]
45except AttributeError: # pragma: NO COVER
46 OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore
47
48from google.cloud.errorreporting_v1beta1.services.error_stats_service import pagers
49from google.cloud.errorreporting_v1beta1.types import common
50from google.cloud.errorreporting_v1beta1.types import error_stats_service
51from .transports.base import ErrorStatsServiceTransport, DEFAULT_CLIENT_INFO
52from .transports.grpc_asyncio import ErrorStatsServiceGrpcAsyncIOTransport
53from .client import ErrorStatsServiceClient
54
55try:
56 from google.api_core import client_logging # type: ignore
57
58 CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
59except ImportError: # pragma: NO COVER
60 CLIENT_LOGGING_SUPPORTED = False
61
62_LOGGER = std_logging.getLogger(__name__)
63
64
65class ErrorStatsServiceAsyncClient:
66 """An API for retrieving and managing error statistics as well
67 as data for individual events.
68 """
69
70 _client: ErrorStatsServiceClient
71
72 # Copy defaults from the synchronous client for use here.
73 # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
74 DEFAULT_ENDPOINT = ErrorStatsServiceClient.DEFAULT_ENDPOINT
75 DEFAULT_MTLS_ENDPOINT = ErrorStatsServiceClient.DEFAULT_MTLS_ENDPOINT
76 _DEFAULT_ENDPOINT_TEMPLATE = ErrorStatsServiceClient._DEFAULT_ENDPOINT_TEMPLATE
77 _DEFAULT_UNIVERSE = ErrorStatsServiceClient._DEFAULT_UNIVERSE
78
79 error_group_path = staticmethod(ErrorStatsServiceClient.error_group_path)
80 parse_error_group_path = staticmethod(
81 ErrorStatsServiceClient.parse_error_group_path
82 )
83 common_billing_account_path = staticmethod(
84 ErrorStatsServiceClient.common_billing_account_path
85 )
86 parse_common_billing_account_path = staticmethod(
87 ErrorStatsServiceClient.parse_common_billing_account_path
88 )
89 common_folder_path = staticmethod(ErrorStatsServiceClient.common_folder_path)
90 parse_common_folder_path = staticmethod(
91 ErrorStatsServiceClient.parse_common_folder_path
92 )
93 common_organization_path = staticmethod(
94 ErrorStatsServiceClient.common_organization_path
95 )
96 parse_common_organization_path = staticmethod(
97 ErrorStatsServiceClient.parse_common_organization_path
98 )
99 common_project_path = staticmethod(ErrorStatsServiceClient.common_project_path)
100 parse_common_project_path = staticmethod(
101 ErrorStatsServiceClient.parse_common_project_path
102 )
103 common_location_path = staticmethod(ErrorStatsServiceClient.common_location_path)
104 parse_common_location_path = staticmethod(
105 ErrorStatsServiceClient.parse_common_location_path
106 )
107
108 @classmethod
109 def from_service_account_info(cls, info: dict, *args, **kwargs):
110 """Creates an instance of this client using the provided credentials
111 info.
112
113 Args:
114 info (dict): The service account private key info.
115 args: Additional arguments to pass to the constructor.
116 kwargs: Additional arguments to pass to the constructor.
117
118 Returns:
119 ErrorStatsServiceAsyncClient: The constructed client.
120 """
121 return ErrorStatsServiceClient.from_service_account_info.__func__(ErrorStatsServiceAsyncClient, info, *args, **kwargs) # type: ignore
122
123 @classmethod
124 def from_service_account_file(cls, filename: str, *args, **kwargs):
125 """Creates an instance of this client using the provided credentials
126 file.
127
128 Args:
129 filename (str): The path to the service account private key json
130 file.
131 args: Additional arguments to pass to the constructor.
132 kwargs: Additional arguments to pass to the constructor.
133
134 Returns:
135 ErrorStatsServiceAsyncClient: The constructed client.
136 """
137 return ErrorStatsServiceClient.from_service_account_file.__func__(ErrorStatsServiceAsyncClient, filename, *args, **kwargs) # type: ignore
138
139 from_service_account_json = from_service_account_file
140
141 @classmethod
142 def get_mtls_endpoint_and_cert_source(
143 cls, client_options: Optional[ClientOptions] = None
144 ):
145 """Return the API endpoint and client cert source for mutual TLS.
146
147 The client cert source is determined in the following order:
148 (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
149 client cert source is None.
150 (2) if `client_options.client_cert_source` is provided, use the provided one; if the
151 default client cert source exists, use the default one; otherwise the client cert
152 source is None.
153
154 The API endpoint is determined in the following order:
155 (1) if `client_options.api_endpoint` if provided, use the provided one.
156 (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
157 default mTLS endpoint; if the environment variable is "never", use the default API
158 endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
159 use the default API endpoint.
160
161 More details can be found at https://google.aip.dev/auth/4114.
162
163 Args:
164 client_options (google.api_core.client_options.ClientOptions): Custom options for the
165 client. Only the `api_endpoint` and `client_cert_source` properties may be used
166 in this method.
167
168 Returns:
169 Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
170 client cert source to use.
171
172 Raises:
173 google.auth.exceptions.MutualTLSChannelError: If any errors happen.
174 """
175 return ErrorStatsServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore
176
177 @property
178 def transport(self) -> ErrorStatsServiceTransport:
179 """Returns the transport used by the client instance.
180
181 Returns:
182 ErrorStatsServiceTransport: The transport used by the client instance.
183 """
184 return self._client.transport
185
186 @property
187 def api_endpoint(self):
188 """Return the API endpoint used by the client instance.
189
190 Returns:
191 str: The API endpoint used by the client instance.
192 """
193 return self._client._api_endpoint
194
195 @property
196 def universe_domain(self) -> str:
197 """Return the universe domain used by the client instance.
198
199 Returns:
200 str: The universe domain used
201 by the client instance.
202 """
203 return self._client._universe_domain
204
205 get_transport_class = ErrorStatsServiceClient.get_transport_class
206
207 def __init__(
208 self,
209 *,
210 credentials: Optional[ga_credentials.Credentials] = None,
211 transport: Optional[
212 Union[
213 str,
214 ErrorStatsServiceTransport,
215 Callable[..., ErrorStatsServiceTransport],
216 ]
217 ] = "grpc_asyncio",
218 client_options: Optional[ClientOptions] = None,
219 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
220 ) -> None:
221 """Instantiates the error stats service async client.
222
223 Args:
224 credentials (Optional[google.auth.credentials.Credentials]): The
225 authorization credentials to attach to requests. These
226 credentials identify the application to the service; if none
227 are specified, the client will attempt to ascertain the
228 credentials from the environment.
229 transport (Optional[Union[str,ErrorStatsServiceTransport,Callable[..., ErrorStatsServiceTransport]]]):
230 The transport to use, or a Callable that constructs and returns a new transport to use.
231 If a Callable is given, it will be called with the same set of initialization
232 arguments as used in the ErrorStatsServiceTransport constructor.
233 If set to None, a transport is chosen automatically.
234 client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
235 Custom options for the client.
236
237 1. The ``api_endpoint`` property can be used to override the
238 default endpoint provided by the client when ``transport`` is
239 not explicitly provided. Only if this property is not set and
240 ``transport`` was not explicitly provided, the endpoint is
241 determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
242 variable, which have one of the following values:
243 "always" (always use the default mTLS endpoint), "never" (always
244 use the default regular endpoint) and "auto" (auto-switch to the
245 default mTLS endpoint if client certificate is present; this is
246 the default value).
247
248 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
249 is "true", then the ``client_cert_source`` property can be used
250 to provide a client certificate for mTLS transport. If
251 not provided, the default SSL client certificate will be used if
252 present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
253 set, no client certificate will be used.
254
255 3. The ``universe_domain`` property can be used to override the
256 default "googleapis.com" universe. Note that ``api_endpoint``
257 property still takes precedence; and ``universe_domain`` is
258 currently not supported for mTLS.
259
260 client_info (google.api_core.gapic_v1.client_info.ClientInfo):
261 The client info used to send a user-agent string along with
262 API requests. If ``None``, then default info will be used.
263 Generally, you only need to set this if you're developing
264 your own client library.
265
266 Raises:
267 google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
268 creation failed for any reason.
269 """
270 self._client = ErrorStatsServiceClient(
271 credentials=credentials,
272 transport=transport,
273 client_options=client_options,
274 client_info=client_info,
275 )
276
277 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
278 std_logging.DEBUG
279 ): # pragma: NO COVER
280 _LOGGER.debug(
281 "Created client `google.devtools.clouderrorreporting_v1beta1.ErrorStatsServiceAsyncClient`.",
282 extra={
283 "serviceName": "google.devtools.clouderrorreporting.v1beta1.ErrorStatsService",
284 "universeDomain": getattr(
285 self._client._transport._credentials, "universe_domain", ""
286 ),
287 "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}",
288 "credentialsInfo": getattr(
289 self.transport._credentials, "get_cred_info", lambda: None
290 )(),
291 }
292 if hasattr(self._client._transport, "_credentials")
293 else {
294 "serviceName": "google.devtools.clouderrorreporting.v1beta1.ErrorStatsService",
295 "credentialsType": None,
296 },
297 )
298
299 async def list_group_stats(
300 self,
301 request: Optional[
302 Union[error_stats_service.ListGroupStatsRequest, dict]
303 ] = None,
304 *,
305 project_name: Optional[str] = None,
306 time_range: Optional[error_stats_service.QueryTimeRange] = None,
307 retry: OptionalRetry = gapic_v1.method.DEFAULT,
308 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
309 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
310 ) -> pagers.ListGroupStatsAsyncPager:
311 r"""Lists the specified groups.
312
313 .. code-block:: python
314
315 # This snippet has been automatically generated and should be regarded as a
316 # code template only.
317 # It will require modifications to work:
318 # - It may require correct/in-range values for request initialization.
319 # - It may require specifying regional endpoints when creating the service
320 # client as shown in:
321 # https://googleapis.dev/python/google-api-core/latest/client_options.html
322 from google.cloud import errorreporting_v1beta1
323
324 async def sample_list_group_stats():
325 # Create a client
326 client = errorreporting_v1beta1.ErrorStatsServiceAsyncClient()
327
328 # Initialize request argument(s)
329 request = errorreporting_v1beta1.ListGroupStatsRequest(
330 project_name="project_name_value",
331 )
332
333 # Make the request
334 page_result = client.list_group_stats(request=request)
335
336 # Handle the response
337 async for response in page_result:
338 print(response)
339
340 Args:
341 request (Optional[Union[google.cloud.errorreporting_v1beta1.types.ListGroupStatsRequest, dict]]):
342 The request object. Specifies a set of ``ErrorGroupStats`` to return.
343 project_name (:class:`str`):
344 Required. The resource name of the Google Cloud Platform
345 project. Written as ``projects/{projectID}`` or
346 ``projects/{projectNumber}``, where ``{projectID}`` and
347 ``{projectNumber}`` can be found in the `Google Cloud
348 console <https://support.google.com/cloud/answer/6158840>`__.
349 It may also include a location, such as
350 ``projects/{projectID}/locations/{location}`` where
351 ``{location}`` is a cloud region.
352
353 Examples: ``projects/my-project-123``,
354 ``projects/5551234``,
355 ``projects/my-project-123/locations/us-central1``,
356 ``projects/5551234/locations/us-central1``.
357
358 For a list of supported locations, see `Supported
359 Regions <https://cloud.google.com/logging/docs/region-support>`__.
360 ``global`` is the default when unspecified. Use ``-`` as
361 a wildcard to request group stats from all regions.
362
363 This corresponds to the ``project_name`` field
364 on the ``request`` instance; if ``request`` is provided, this
365 should not be set.
366 time_range (:class:`google.cloud.errorreporting_v1beta1.types.QueryTimeRange`):
367 Optional. List data for the given time range. If not
368 set, a default time range is used. The field
369 [time_range_begin]
370 [google.devtools.clouderrorreporting.v1beta1.ListGroupStatsResponse.time_range_begin]
371 in the response will specify the beginning of this time
372 range. Only [ErrorGroupStats]
373 [google.devtools.clouderrorreporting.v1beta1.ErrorGroupStats]
374 with a non-zero count in the given time range are
375 returned, unless the request contains an explicit
376 [group_id]
377 [google.devtools.clouderrorreporting.v1beta1.ListGroupStatsRequest.group_id]
378 list. If a [group_id]
379 [google.devtools.clouderrorreporting.v1beta1.ListGroupStatsRequest.group_id]
380 list is given, also [ErrorGroupStats]
381 [google.devtools.clouderrorreporting.v1beta1.ErrorGroupStats]
382 with zero occurrences are returned.
383
384 This corresponds to the ``time_range`` field
385 on the ``request`` instance; if ``request`` is provided, this
386 should not be set.
387 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
388 should be retried.
389 timeout (float): The timeout for this request.
390 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
391 sent along with the request as metadata. Normally, each value must be of type `str`,
392 but for metadata keys ending with the suffix `-bin`, the corresponding values must
393 be of type `bytes`.
394
395 Returns:
396 google.cloud.errorreporting_v1beta1.services.error_stats_service.pagers.ListGroupStatsAsyncPager:
397 Contains a set of requested error
398 group stats.
399 Iterating over this object will yield
400 results and resolve additional pages
401 automatically.
402
403 """
404 # Create or coerce a protobuf request object.
405 # - Quick check: If we got a request object, we should *not* have
406 # gotten any keyword arguments that map to the request.
407 flattened_params = [project_name, time_range]
408 has_flattened_params = (
409 len([param for param in flattened_params if param is not None]) > 0
410 )
411 if request is not None and has_flattened_params:
412 raise ValueError(
413 "If the `request` argument is set, then none of "
414 "the individual field arguments should be set."
415 )
416
417 # - Use the request object if provided (there's no risk of modifying the input as
418 # there are no flattened fields), or create one.
419 if not isinstance(request, error_stats_service.ListGroupStatsRequest):
420 request = error_stats_service.ListGroupStatsRequest(request)
421
422 # If we have keyword arguments corresponding to fields on the
423 # request, apply these.
424 if project_name is not None:
425 request.project_name = project_name
426 if time_range is not None:
427 request.time_range = time_range
428
429 # Wrap the RPC method; this adds retry and timeout information,
430 # and friendly error handling.
431 rpc = self._client._transport._wrapped_methods[
432 self._client._transport.list_group_stats
433 ]
434
435 # Certain fields should be provided within the metadata header;
436 # add these here.
437 metadata = tuple(metadata) + (
438 gapic_v1.routing_header.to_grpc_metadata(
439 (("project_name", request.project_name),)
440 ),
441 )
442
443 # Validate the universe domain.
444 self._client._validate_universe_domain()
445
446 # Send the request.
447 response = await rpc(
448 request,
449 retry=retry,
450 timeout=timeout,
451 metadata=metadata,
452 )
453
454 # This method is paged; wrap the response in a pager, which provides
455 # an `__aiter__` convenience method.
456 response = pagers.ListGroupStatsAsyncPager(
457 method=rpc,
458 request=request,
459 response=response,
460 retry=retry,
461 timeout=timeout,
462 metadata=metadata,
463 )
464
465 # Done; return the response.
466 return response
467
468 async def list_events(
469 self,
470 request: Optional[Union[error_stats_service.ListEventsRequest, dict]] = None,
471 *,
472 project_name: Optional[str] = None,
473 group_id: Optional[str] = None,
474 retry: OptionalRetry = gapic_v1.method.DEFAULT,
475 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
476 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
477 ) -> pagers.ListEventsAsyncPager:
478 r"""Lists the specified events.
479
480 .. code-block:: python
481
482 # This snippet has been automatically generated and should be regarded as a
483 # code template only.
484 # It will require modifications to work:
485 # - It may require correct/in-range values for request initialization.
486 # - It may require specifying regional endpoints when creating the service
487 # client as shown in:
488 # https://googleapis.dev/python/google-api-core/latest/client_options.html
489 from google.cloud import errorreporting_v1beta1
490
491 async def sample_list_events():
492 # Create a client
493 client = errorreporting_v1beta1.ErrorStatsServiceAsyncClient()
494
495 # Initialize request argument(s)
496 request = errorreporting_v1beta1.ListEventsRequest(
497 project_name="project_name_value",
498 group_id="group_id_value",
499 )
500
501 # Make the request
502 page_result = client.list_events(request=request)
503
504 # Handle the response
505 async for response in page_result:
506 print(response)
507
508 Args:
509 request (Optional[Union[google.cloud.errorreporting_v1beta1.types.ListEventsRequest, dict]]):
510 The request object. Specifies a set of error events to
511 return.
512 project_name (:class:`str`):
513 Required. The resource name of the Google Cloud Platform
514 project. Written as ``projects/{projectID}`` or
515 ``projects/{projectID}/locations/{location}``, where
516 ``{projectID}`` is the `Google Cloud Platform project
517 ID <https://support.google.com/cloud/answer/6158840>`__
518 and ``{location}`` is a Cloud region.
519
520 Examples: ``projects/my-project-123``,
521 ``projects/my-project-123/locations/global``.
522
523 For a list of supported locations, see `Supported
524 Regions <https://cloud.google.com/logging/docs/region-support>`__.
525 ``global`` is the default when unspecified.
526
527 This corresponds to the ``project_name`` field
528 on the ``request`` instance; if ``request`` is provided, this
529 should not be set.
530 group_id (:class:`str`):
531 Required. The group for which events shall be returned.
532 The ``group_id`` is a unique identifier for a particular
533 error group. The identifier is derived from key parts of
534 the error-log content and is treated as Service Data.
535 For information about how Service Data is handled, see
536 `Google Cloud Privacy
537 Notice <https://cloud.google.com/terms/cloud-privacy-notice>`__.
538
539 This corresponds to the ``group_id`` field
540 on the ``request`` instance; if ``request`` is provided, this
541 should not be set.
542 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
543 should be retried.
544 timeout (float): The timeout for this request.
545 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
546 sent along with the request as metadata. Normally, each value must be of type `str`,
547 but for metadata keys ending with the suffix `-bin`, the corresponding values must
548 be of type `bytes`.
549
550 Returns:
551 google.cloud.errorreporting_v1beta1.services.error_stats_service.pagers.ListEventsAsyncPager:
552 Contains a set of requested error
553 events.
554 Iterating over this object will yield
555 results and resolve additional pages
556 automatically.
557
558 """
559 # Create or coerce a protobuf request object.
560 # - Quick check: If we got a request object, we should *not* have
561 # gotten any keyword arguments that map to the request.
562 flattened_params = [project_name, group_id]
563 has_flattened_params = (
564 len([param for param in flattened_params if param is not None]) > 0
565 )
566 if request is not None and has_flattened_params:
567 raise ValueError(
568 "If the `request` argument is set, then none of "
569 "the individual field arguments should be set."
570 )
571
572 # - Use the request object if provided (there's no risk of modifying the input as
573 # there are no flattened fields), or create one.
574 if not isinstance(request, error_stats_service.ListEventsRequest):
575 request = error_stats_service.ListEventsRequest(request)
576
577 # If we have keyword arguments corresponding to fields on the
578 # request, apply these.
579 if project_name is not None:
580 request.project_name = project_name
581 if group_id is not None:
582 request.group_id = group_id
583
584 # Wrap the RPC method; this adds retry and timeout information,
585 # and friendly error handling.
586 rpc = self._client._transport._wrapped_methods[
587 self._client._transport.list_events
588 ]
589
590 # Certain fields should be provided within the metadata header;
591 # add these here.
592 metadata = tuple(metadata) + (
593 gapic_v1.routing_header.to_grpc_metadata(
594 (("project_name", request.project_name),)
595 ),
596 )
597
598 # Validate the universe domain.
599 self._client._validate_universe_domain()
600
601 # Send the request.
602 response = await rpc(
603 request,
604 retry=retry,
605 timeout=timeout,
606 metadata=metadata,
607 )
608
609 # This method is paged; wrap the response in a pager, which provides
610 # an `__aiter__` convenience method.
611 response = pagers.ListEventsAsyncPager(
612 method=rpc,
613 request=request,
614 response=response,
615 retry=retry,
616 timeout=timeout,
617 metadata=metadata,
618 )
619
620 # Done; return the response.
621 return response
622
623 async def delete_events(
624 self,
625 request: Optional[Union[error_stats_service.DeleteEventsRequest, dict]] = None,
626 *,
627 project_name: Optional[str] = None,
628 retry: OptionalRetry = gapic_v1.method.DEFAULT,
629 timeout: Union[float, object] = gapic_v1.method.DEFAULT,
630 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
631 ) -> error_stats_service.DeleteEventsResponse:
632 r"""Deletes all error events of a given project.
633
634 .. code-block:: python
635
636 # This snippet has been automatically generated and should be regarded as a
637 # code template only.
638 # It will require modifications to work:
639 # - It may require correct/in-range values for request initialization.
640 # - It may require specifying regional endpoints when creating the service
641 # client as shown in:
642 # https://googleapis.dev/python/google-api-core/latest/client_options.html
643 from google.cloud import errorreporting_v1beta1
644
645 async def sample_delete_events():
646 # Create a client
647 client = errorreporting_v1beta1.ErrorStatsServiceAsyncClient()
648
649 # Initialize request argument(s)
650 request = errorreporting_v1beta1.DeleteEventsRequest(
651 project_name="project_name_value",
652 )
653
654 # Make the request
655 response = await client.delete_events(request=request)
656
657 # Handle the response
658 print(response)
659
660 Args:
661 request (Optional[Union[google.cloud.errorreporting_v1beta1.types.DeleteEventsRequest, dict]]):
662 The request object. Deletes all events in the project.
663 project_name (:class:`str`):
664 Required. The resource name of the Google Cloud Platform
665 project. Written as ``projects/{projectID}`` or
666 ``projects/{projectID}/locations/{location}``, where
667 ``{projectID}`` is the `Google Cloud Platform project
668 ID <https://support.google.com/cloud/answer/6158840>`__
669 and ``{location}`` is a Cloud region.
670
671 Examples: ``projects/my-project-123``,
672 ``projects/my-project-123/locations/global``.
673
674 For a list of supported locations, see `Supported
675 Regions <https://cloud.google.com/logging/docs/region-support>`__.
676 ``global`` is the default when unspecified.
677
678 This corresponds to the ``project_name`` field
679 on the ``request`` instance; if ``request`` is provided, this
680 should not be set.
681 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
682 should be retried.
683 timeout (float): The timeout for this request.
684 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
685 sent along with the request as metadata. Normally, each value must be of type `str`,
686 but for metadata keys ending with the suffix `-bin`, the corresponding values must
687 be of type `bytes`.
688
689 Returns:
690 google.cloud.errorreporting_v1beta1.types.DeleteEventsResponse:
691 Response message for deleting error
692 events.
693
694 """
695 # Create or coerce a protobuf request object.
696 # - Quick check: If we got a request object, we should *not* have
697 # gotten any keyword arguments that map to the request.
698 flattened_params = [project_name]
699 has_flattened_params = (
700 len([param for param in flattened_params if param is not None]) > 0
701 )
702 if request is not None and has_flattened_params:
703 raise ValueError(
704 "If the `request` argument is set, then none of "
705 "the individual field arguments should be set."
706 )
707
708 # - Use the request object if provided (there's no risk of modifying the input as
709 # there are no flattened fields), or create one.
710 if not isinstance(request, error_stats_service.DeleteEventsRequest):
711 request = error_stats_service.DeleteEventsRequest(request)
712
713 # If we have keyword arguments corresponding to fields on the
714 # request, apply these.
715 if project_name is not None:
716 request.project_name = project_name
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.delete_events
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(
728 (("project_name", request.project_name),)
729 ),
730 )
731
732 # Validate the universe domain.
733 self._client._validate_universe_domain()
734
735 # Send the request.
736 response = await rpc(
737 request,
738 retry=retry,
739 timeout=timeout,
740 metadata=metadata,
741 )
742
743 # Done; return the response.
744 return response
745
746 async def __aenter__(self) -> "ErrorStatsServiceAsyncClient":
747 return self
748
749 async def __aexit__(self, exc_type, exc, tb):
750 await self.transport.close()
751
752
753DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
754 gapic_version=package_version.__version__
755)
756
757if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
758 DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
759
760
761__all__ = ("ErrorStatsServiceAsyncClient",)