|
16 | 16 | from collections import OrderedDict
|
17 | 17 | import functools
|
18 | 18 | import re
|
19 |
| -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union |
20 |
| -import pkg_resources |
| 19 | +from typing import ( |
| 20 | + Dict, |
| 21 | + Mapping, |
| 22 | + MutableMapping, |
| 23 | + MutableSequence, |
| 24 | + Optional, |
| 25 | + Sequence, |
| 26 | + Tuple, |
| 27 | + Type, |
| 28 | + Union, |
| 29 | +) |
| 30 | + |
| 31 | +from google.cloud.monitoring_v3 import gapic_version as package_version |
21 | 32 |
|
22 | 33 | from google.api_core.client_options import ClientOptions
|
23 | 34 | from google.api_core import exceptions as core_exceptions
|
@@ -181,9 +192,9 @@ def transport(self) -> AlertPolicyServiceTransport:
|
181 | 192 | def __init__(
|
182 | 193 | self,
|
183 | 194 | *,
|
184 |
| - credentials: ga_credentials.Credentials = None, |
| 195 | + credentials: Optional[ga_credentials.Credentials] = None, |
185 | 196 | transport: Union[str, AlertPolicyServiceTransport] = "grpc_asyncio",
|
186 |
| - client_options: ClientOptions = None, |
| 197 | + client_options: Optional[ClientOptions] = None, |
187 | 198 | client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
188 | 199 | ) -> None:
|
189 | 200 | """Instantiates the alert policy service client.
|
@@ -227,11 +238,11 @@ def __init__(
|
227 | 238 |
|
228 | 239 | async def list_alert_policies(
|
229 | 240 | self,
|
230 |
| - request: Union[alert_service.ListAlertPoliciesRequest, dict] = None, |
| 241 | + request: Optional[Union[alert_service.ListAlertPoliciesRequest, dict]] = None, |
231 | 242 | *,
|
232 |
| - name: str = None, |
| 243 | + name: Optional[str] = None, |
233 | 244 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
234 |
| - timeout: float = None, |
| 245 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
235 | 246 | metadata: Sequence[Tuple[str, str]] = (),
|
236 | 247 | ) -> pagers.ListAlertPoliciesAsyncPager:
|
237 | 248 | r"""Lists the existing alerting policies for the
|
@@ -265,7 +276,7 @@ async def sample_list_alert_policies():
|
265 | 276 | print(response)
|
266 | 277 |
|
267 | 278 | Args:
|
268 |
| - request (Union[google.cloud.monitoring_v3.types.ListAlertPoliciesRequest, dict]): |
| 279 | + request (Optional[Union[google.cloud.monitoring_v3.types.ListAlertPoliciesRequest, dict]]): |
269 | 280 | The request object. The protocol for the
|
270 | 281 | `ListAlertPolicies` request.
|
271 | 282 | name (:class:`str`):
|
@@ -362,11 +373,11 @@ async def sample_list_alert_policies():
|
362 | 373 |
|
363 | 374 | async def get_alert_policy(
|
364 | 375 | self,
|
365 |
| - request: Union[alert_service.GetAlertPolicyRequest, dict] = None, |
| 376 | + request: Optional[Union[alert_service.GetAlertPolicyRequest, dict]] = None, |
366 | 377 | *,
|
367 |
| - name: str = None, |
| 378 | + name: Optional[str] = None, |
368 | 379 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
369 |
| - timeout: float = None, |
| 380 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
370 | 381 | metadata: Sequence[Tuple[str, str]] = (),
|
371 | 382 | ) -> alert.AlertPolicy:
|
372 | 383 | r"""Gets a single alerting policy.
|
@@ -398,7 +409,7 @@ async def sample_get_alert_policy():
|
398 | 409 | print(response)
|
399 | 410 |
|
400 | 411 | Args:
|
401 |
| - request (Union[google.cloud.monitoring_v3.types.GetAlertPolicyRequest, dict]): |
| 412 | + request (Optional[Union[google.cloud.monitoring_v3.types.GetAlertPolicyRequest, dict]]): |
402 | 413 | The request object. The protocol for the
|
403 | 414 | `GetAlertPolicy` request.
|
404 | 415 | name (:class:`str`):
|
@@ -480,12 +491,12 @@ async def sample_get_alert_policy():
|
480 | 491 |
|
481 | 492 | async def create_alert_policy(
|
482 | 493 | self,
|
483 |
| - request: Union[alert_service.CreateAlertPolicyRequest, dict] = None, |
| 494 | + request: Optional[Union[alert_service.CreateAlertPolicyRequest, dict]] = None, |
484 | 495 | *,
|
485 |
| - name: str = None, |
486 |
| - alert_policy: alert.AlertPolicy = None, |
| 496 | + name: Optional[str] = None, |
| 497 | + alert_policy: Optional[alert.AlertPolicy] = None, |
487 | 498 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
488 |
| - timeout: float = None, |
| 499 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
489 | 500 | metadata: Sequence[Tuple[str, str]] = (),
|
490 | 501 | ) -> alert.AlertPolicy:
|
491 | 502 | r"""Creates a new alerting policy.
|
@@ -517,7 +528,7 @@ async def sample_create_alert_policy():
|
517 | 528 | print(response)
|
518 | 529 |
|
519 | 530 | Args:
|
520 |
| - request (Union[google.cloud.monitoring_v3.types.CreateAlertPolicyRequest, dict]): |
| 531 | + request (Optional[Union[google.cloud.monitoring_v3.types.CreateAlertPolicyRequest, dict]]): |
521 | 532 | The request object. The protocol for the
|
522 | 533 | `CreateAlertPolicy` request.
|
523 | 534 | name (:class:`str`):
|
@@ -612,11 +623,11 @@ async def sample_create_alert_policy():
|
612 | 623 |
|
613 | 624 | async def delete_alert_policy(
|
614 | 625 | self,
|
615 |
| - request: Union[alert_service.DeleteAlertPolicyRequest, dict] = None, |
| 626 | + request: Optional[Union[alert_service.DeleteAlertPolicyRequest, dict]] = None, |
616 | 627 | *,
|
617 |
| - name: str = None, |
| 628 | + name: Optional[str] = None, |
618 | 629 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
619 |
| - timeout: float = None, |
| 630 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
620 | 631 | metadata: Sequence[Tuple[str, str]] = (),
|
621 | 632 | ) -> None:
|
622 | 633 | r"""Deletes an alerting policy.
|
@@ -645,7 +656,7 @@ async def sample_delete_alert_policy():
|
645 | 656 | await client.delete_alert_policy(request=request)
|
646 | 657 |
|
647 | 658 | Args:
|
648 |
| - request (Union[google.cloud.monitoring_v3.types.DeleteAlertPolicyRequest, dict]): |
| 659 | + request (Optional[Union[google.cloud.monitoring_v3.types.DeleteAlertPolicyRequest, dict]]): |
649 | 660 | The request object. The protocol for the
|
650 | 661 | `DeleteAlertPolicy` request.
|
651 | 662 | name (:class:`str`):
|
@@ -717,12 +728,12 @@ async def sample_delete_alert_policy():
|
717 | 728 |
|
718 | 729 | async def update_alert_policy(
|
719 | 730 | self,
|
720 |
| - request: Union[alert_service.UpdateAlertPolicyRequest, dict] = None, |
| 731 | + request: Optional[Union[alert_service.UpdateAlertPolicyRequest, dict]] = None, |
721 | 732 | *,
|
722 |
| - update_mask: field_mask_pb2.FieldMask = None, |
723 |
| - alert_policy: alert.AlertPolicy = None, |
| 733 | + update_mask: Optional[field_mask_pb2.FieldMask] = None, |
| 734 | + alert_policy: Optional[alert.AlertPolicy] = None, |
724 | 735 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
725 |
| - timeout: float = None, |
| 736 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
726 | 737 | metadata: Sequence[Tuple[str, str]] = (),
|
727 | 738 | ) -> alert.AlertPolicy:
|
728 | 739 | r"""Updates an alerting policy. You can either replace the entire
|
@@ -756,7 +767,7 @@ async def sample_update_alert_policy():
|
756 | 767 | print(response)
|
757 | 768 |
|
758 | 769 | Args:
|
759 |
| - request (Union[google.cloud.monitoring_v3.types.UpdateAlertPolicyRequest, dict]): |
| 770 | + request (Optional[Union[google.cloud.monitoring_v3.types.UpdateAlertPolicyRequest, dict]]): |
760 | 771 | The request object. The protocol for the
|
761 | 772 | `UpdateAlertPolicy` request.
|
762 | 773 | update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
|
@@ -869,14 +880,9 @@ async def __aexit__(self, exc_type, exc, tb):
|
869 | 880 | await self.transport.close()
|
870 | 881 |
|
871 | 882 |
|
872 |
| -try: |
873 |
| - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( |
874 |
| - gapic_version=pkg_resources.get_distribution( |
875 |
| - "google-cloud-monitoring", |
876 |
| - ).version, |
877 |
| - ) |
878 |
| -except pkg_resources.DistributionNotFound: |
879 |
| - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() |
| 883 | +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( |
| 884 | + gapic_version=package_version.__version__ |
| 885 | +) |
880 | 886 |
|
881 | 887 |
|
882 | 888 | __all__ = ("AlertPolicyServiceAsyncClient",)
|
0 commit comments