diff --git a/.coveragerc b/.coveragerc index 130673a5..292fcda2 100644 --- a/.coveragerc +++ b/.coveragerc @@ -10,8 +10,3 @@ exclude_lines = pragma: NO COVER # Ignore debug-only repr def __repr__ - # Ignore pkg_resources exceptions. - # This is added at the module level as a safeguard for if someone - # generates the code and tries to run it without pip installing. This - # makes it virtually impossible to test properly. - except pkg_resources.DistributionNotFound diff --git a/.github/release-please.yml b/.github/release-please.yml index 29601ad4..fe749ff6 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1,5 +1,6 @@ releaseType: python handleGHRelease: true +manifest: true # NOTE: this section is generated by synthtool.languages.python # See https://github.com/googleapis/synthtool/blob/master/synthtool/languages/python.py branches: diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..38d4f032 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,4 @@ +{ + ".": "2.11.3" +} + \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index 27fc9024..cbc85f70 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -2,7 +2,8 @@ .. include:: multiprocessing.rst -Api Reference + +API Reference ------------- .. toctree:: :maxdepth: 2 @@ -11,20 +12,22 @@ Api Reference monitoring_v3/services monitoring_v3/types + Migration Guide --------------- -See the guide below for instructions on migrating to the 2.x release of this library. +See the guide below for instructions on migrating to the latest version. .. toctree:: :maxdepth: 2 - UPGRADING +  UPGRADING + Changelog --------- -For a list of all previous ``google-cloud-monitoring`` releases. +For a list of all ``google-cloud-monitoring`` releases: .. toctree:: :maxdepth: 2 diff --git a/docs/monitoring_v3/types.rst b/docs/monitoring_v3/types.rst index ed0eeeef..ae49a858 100644 --- a/docs/monitoring_v3/types.rst +++ b/docs/monitoring_v3/types.rst @@ -3,5 +3,4 @@ Types for Google Cloud Monitoring v3 API .. automodule:: google.cloud.monitoring_v3.types :members: - :undoc-members: :show-inheritance: diff --git a/google/cloud/monitoring/__init__.py b/google/cloud/monitoring/__init__.py index c978631f..342e79c4 100644 --- a/google/cloud/monitoring/__init__.py +++ b/google/cloud/monitoring/__init__.py @@ -13,6 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from google.cloud.monitoring import gapic_version as package_version + +__version__ = package_version.__version__ + from google.cloud.monitoring_v3.services.alert_policy_service.client import ( AlertPolicyServiceClient, diff --git a/google/cloud/monitoring/gapic_version.py b/google/cloud/monitoring/gapic_version.py new file mode 100644 index 00000000..66d9e30a --- /dev/null +++ b/google/cloud/monitoring/gapic_version.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +__version__ = "2.11.3" # {x-release-please-version} diff --git a/google/cloud/monitoring_v3/__init__.py b/google/cloud/monitoring_v3/__init__.py index 4f2e9cb2..f7e8c19f 100644 --- a/google/cloud/monitoring_v3/__init__.py +++ b/google/cloud/monitoring_v3/__init__.py @@ -13,6 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from google.cloud.monitoring import gapic_version as package_version + +__version__ = package_version.__version__ + from .services.alert_policy_service import AlertPolicyServiceClient from .services.alert_policy_service import AlertPolicyServiceAsyncClient diff --git a/google/cloud/monitoring_v3/gapic_version.py b/google/cloud/monitoring_v3/gapic_version.py new file mode 100644 index 00000000..66d9e30a --- /dev/null +++ b/google/cloud/monitoring_v3/gapic_version.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +__version__ = "2.11.3" # {x-release-please-version} diff --git a/google/cloud/monitoring_v3/services/alert_policy_service/async_client.py b/google/cloud/monitoring_v3/services/alert_policy_service/async_client.py index e92d8562..1d3f1206 100644 --- a/google/cloud/monitoring_v3/services/alert_policy_service/async_client.py +++ b/google/cloud/monitoring_v3/services/alert_policy_service/async_client.py @@ -16,8 +16,19 @@ from collections import OrderedDict import functools import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, +) + +from google.cloud.monitoring_v3 import gapic_version as package_version from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions @@ -181,9 +192,9 @@ def transport(self) -> AlertPolicyServiceTransport: def __init__( self, *, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, AlertPolicyServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, + client_options: Optional[ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the alert policy service client. @@ -227,11 +238,11 @@ def __init__( async def list_alert_policies( self, - request: Union[alert_service.ListAlertPoliciesRequest, dict] = None, + request: Optional[Union[alert_service.ListAlertPoliciesRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListAlertPoliciesAsyncPager: r"""Lists the existing alerting policies for the @@ -265,7 +276,7 @@ async def sample_list_alert_policies(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.ListAlertPoliciesRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.ListAlertPoliciesRequest, dict]]): The request object. The protocol for the `ListAlertPolicies` request. name (:class:`str`): @@ -362,11 +373,11 @@ async def sample_list_alert_policies(): async def get_alert_policy( self, - request: Union[alert_service.GetAlertPolicyRequest, dict] = None, + request: Optional[Union[alert_service.GetAlertPolicyRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> alert.AlertPolicy: r"""Gets a single alerting policy. @@ -398,7 +409,7 @@ async def sample_get_alert_policy(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.GetAlertPolicyRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.GetAlertPolicyRequest, dict]]): The request object. The protocol for the `GetAlertPolicy` request. name (:class:`str`): @@ -480,12 +491,12 @@ async def sample_get_alert_policy(): async def create_alert_policy( self, - request: Union[alert_service.CreateAlertPolicyRequest, dict] = None, + request: Optional[Union[alert_service.CreateAlertPolicyRequest, dict]] = None, *, - name: str = None, - alert_policy: alert.AlertPolicy = None, + name: Optional[str] = None, + alert_policy: Optional[alert.AlertPolicy] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> alert.AlertPolicy: r"""Creates a new alerting policy. @@ -517,7 +528,7 @@ async def sample_create_alert_policy(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.CreateAlertPolicyRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.CreateAlertPolicyRequest, dict]]): The request object. The protocol for the `CreateAlertPolicy` request. name (:class:`str`): @@ -612,11 +623,11 @@ async def sample_create_alert_policy(): async def delete_alert_policy( self, - request: Union[alert_service.DeleteAlertPolicyRequest, dict] = None, + request: Optional[Union[alert_service.DeleteAlertPolicyRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes an alerting policy. @@ -645,7 +656,7 @@ async def sample_delete_alert_policy(): await client.delete_alert_policy(request=request) Args: - request (Union[google.cloud.monitoring_v3.types.DeleteAlertPolicyRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.DeleteAlertPolicyRequest, dict]]): The request object. The protocol for the `DeleteAlertPolicy` request. name (:class:`str`): @@ -717,12 +728,12 @@ async def sample_delete_alert_policy(): async def update_alert_policy( self, - request: Union[alert_service.UpdateAlertPolicyRequest, dict] = None, + request: Optional[Union[alert_service.UpdateAlertPolicyRequest, dict]] = None, *, - update_mask: field_mask_pb2.FieldMask = None, - alert_policy: alert.AlertPolicy = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + alert_policy: Optional[alert.AlertPolicy] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> alert.AlertPolicy: r"""Updates an alerting policy. You can either replace the entire @@ -756,7 +767,7 @@ async def sample_update_alert_policy(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.UpdateAlertPolicyRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.UpdateAlertPolicyRequest, dict]]): The request object. The protocol for the `UpdateAlertPolicy` request. update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): @@ -869,14 +880,9 @@ async def __aexit__(self, exc_type, exc, tb): await self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-monitoring", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("AlertPolicyServiceAsyncClient",) diff --git a/google/cloud/monitoring_v3/services/alert_policy_service/client.py b/google/cloud/monitoring_v3/services/alert_policy_service/client.py index 39d7ead9..d736a914 100644 --- a/google/cloud/monitoring_v3/services/alert_policy_service/client.py +++ b/google/cloud/monitoring_v3/services/alert_policy_service/client.py @@ -16,8 +16,20 @@ from collections import OrderedDict import os import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, + cast, +) + +from google.cloud.monitoring_v3 import gapic_version as package_version from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions @@ -62,7 +74,7 @@ class AlertPolicyServiceClientMeta(type): def get_transport_class( cls, - label: str = None, + label: Optional[str] = None, ) -> Type[AlertPolicyServiceTransport]: """Returns an appropriate transport class. @@ -365,8 +377,8 @@ def __init__( self, *, credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, AlertPolicyServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, + transport: Optional[Union[str, AlertPolicyServiceTransport]] = None, + client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the alert policy service client. @@ -380,7 +392,7 @@ def __init__( transport (Union[str, AlertPolicyServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the + client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT @@ -410,6 +422,7 @@ def __init__( client_options = client_options_lib.from_dict(client_options) if client_options is None: client_options = client_options_lib.ClientOptions() + client_options = cast(client_options_lib.ClientOptions, client_options) api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( client_options @@ -462,11 +475,11 @@ def __init__( def list_alert_policies( self, - request: Union[alert_service.ListAlertPoliciesRequest, dict] = None, + request: Optional[Union[alert_service.ListAlertPoliciesRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListAlertPoliciesPager: r"""Lists the existing alerting policies for the @@ -588,11 +601,11 @@ def sample_list_alert_policies(): def get_alert_policy( self, - request: Union[alert_service.GetAlertPolicyRequest, dict] = None, + request: Optional[Union[alert_service.GetAlertPolicyRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> alert.AlertPolicy: r"""Gets a single alerting policy. @@ -697,12 +710,12 @@ def sample_get_alert_policy(): def create_alert_policy( self, - request: Union[alert_service.CreateAlertPolicyRequest, dict] = None, + request: Optional[Union[alert_service.CreateAlertPolicyRequest, dict]] = None, *, - name: str = None, - alert_policy: alert.AlertPolicy = None, + name: Optional[str] = None, + alert_policy: Optional[alert.AlertPolicy] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> alert.AlertPolicy: r"""Creates a new alerting policy. @@ -829,11 +842,11 @@ def sample_create_alert_policy(): def delete_alert_policy( self, - request: Union[alert_service.DeleteAlertPolicyRequest, dict] = None, + request: Optional[Union[alert_service.DeleteAlertPolicyRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes an alerting policy. @@ -925,12 +938,12 @@ def sample_delete_alert_policy(): def update_alert_policy( self, - request: Union[alert_service.UpdateAlertPolicyRequest, dict] = None, + request: Optional[Union[alert_service.UpdateAlertPolicyRequest, dict]] = None, *, - update_mask: field_mask_pb2.FieldMask = None, - alert_policy: alert.AlertPolicy = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + alert_policy: Optional[alert.AlertPolicy] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> alert.AlertPolicy: r"""Updates an alerting policy. You can either replace the entire @@ -1084,14 +1097,9 @@ def __exit__(self, type, value, traceback): self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-monitoring", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("AlertPolicyServiceClient",) diff --git a/google/cloud/monitoring_v3/services/alert_policy_service/transports/base.py b/google/cloud/monitoring_v3/services/alert_policy_service/transports/base.py index 9808d581..a7059c7f 100644 --- a/google/cloud/monitoring_v3/services/alert_policy_service/transports/base.py +++ b/google/cloud/monitoring_v3/services/alert_policy_service/transports/base.py @@ -15,7 +15,8 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources + +from google.cloud.monitoring_v3 import gapic_version as package_version import google.auth # type: ignore import google.api_core @@ -29,14 +30,9 @@ from google.cloud.monitoring_v3.types import alert_service from google.protobuf import empty_pb2 # type: ignore -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-monitoring", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) class AlertPolicyServiceTransport(abc.ABC): @@ -54,7 +50,7 @@ def __init__( self, *, host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, diff --git a/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc.py b/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc.py index 2e0b3ec1..38df436c 100644 --- a/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc.py +++ b/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc.py @@ -57,14 +57,14 @@ def __init__( self, *, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: Optional[grpc.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, @@ -191,8 +191,8 @@ def __init__( def create_channel( cls, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, **kwargs, diff --git a/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc_asyncio.py b/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc_asyncio.py index 547b645b..72b80b6e 100644 --- a/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc_asyncio.py +++ b/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc_asyncio.py @@ -59,7 +59,7 @@ class AlertPolicyServiceGrpcAsyncIOTransport(AlertPolicyServiceTransport): def create_channel( cls, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -102,15 +102,15 @@ def __init__( self, *, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, + channel: Optional[aio.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, api_audience: Optional[str] = None, diff --git a/google/cloud/monitoring_v3/services/group_service/async_client.py b/google/cloud/monitoring_v3/services/group_service/async_client.py index 07b299d6..b01c1471 100644 --- a/google/cloud/monitoring_v3/services/group_service/async_client.py +++ b/google/cloud/monitoring_v3/services/group_service/async_client.py @@ -16,8 +16,19 @@ from collections import OrderedDict import functools import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, +) + +from google.cloud.monitoring_v3 import gapic_version as package_version from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions @@ -169,9 +180,9 @@ def transport(self) -> GroupServiceTransport: def __init__( self, *, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, GroupServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, + client_options: Optional[ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the group service client. @@ -215,11 +226,11 @@ def __init__( async def list_groups( self, - request: Union[group_service.ListGroupsRequest, dict] = None, + request: Optional[Union[group_service.ListGroupsRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListGroupsAsyncPager: r"""Lists the existing groups. @@ -253,7 +264,7 @@ async def sample_list_groups(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.ListGroupsRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.ListGroupsRequest, dict]]): The request object. The `ListGroup` request. name (:class:`str`): Required. The @@ -343,11 +354,11 @@ async def sample_list_groups(): async def get_group( self, - request: Union[group_service.GetGroupRequest, dict] = None, + request: Optional[Union[group_service.GetGroupRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> group.Group: r"""Gets a single group. @@ -379,7 +390,7 @@ async def sample_get_group(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.GetGroupRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.GetGroupRequest, dict]]): The request object. The `GetGroup` request. name (:class:`str`): Required. The group to retrieve. The format is: @@ -487,12 +498,12 @@ async def sample_get_group(): async def create_group( self, - request: Union[group_service.CreateGroupRequest, dict] = None, + request: Optional[Union[group_service.CreateGroupRequest, dict]] = None, *, - name: str = None, - group: gm_group.Group = None, + name: Optional[str] = None, + group: Optional[gm_group.Group] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> gm_group.Group: r"""Creates a new group. @@ -524,7 +535,7 @@ async def sample_create_group(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.CreateGroupRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.CreateGroupRequest, dict]]): The request object. The `CreateGroup` request. name (:class:`str`): Required. The @@ -634,11 +645,11 @@ async def sample_create_group(): async def update_group( self, - request: Union[group_service.UpdateGroupRequest, dict] = None, + request: Optional[Union[group_service.UpdateGroupRequest, dict]] = None, *, - group: gm_group.Group = None, + group: Optional[gm_group.Group] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> gm_group.Group: r"""Updates an existing group. You can change any group attributes @@ -670,7 +681,7 @@ async def sample_update_group(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.UpdateGroupRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.UpdateGroupRequest, dict]]): The request object. The `UpdateGroup` request. group (:class:`google.cloud.monitoring_v3.types.Group`): Required. The new definition of the group. All fields of @@ -778,11 +789,11 @@ async def sample_update_group(): async def delete_group( self, - request: Union[group_service.DeleteGroupRequest, dict] = None, + request: Optional[Union[group_service.DeleteGroupRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes an existing group. @@ -811,7 +822,7 @@ async def sample_delete_group(): await client.delete_group(request=request) Args: - request (Union[google.cloud.monitoring_v3.types.DeleteGroupRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.DeleteGroupRequest, dict]]): The request object. The `DeleteGroup` request. The default behavior is to be able to delete a single group without any descendants. @@ -881,11 +892,11 @@ async def sample_delete_group(): async def list_group_members( self, - request: Union[group_service.ListGroupMembersRequest, dict] = None, + request: Optional[Union[group_service.ListGroupMembersRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListGroupMembersAsyncPager: r"""Lists the monitored resources that are members of a @@ -919,7 +930,7 @@ async def sample_list_group_members(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.ListGroupMembersRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.ListGroupMembersRequest, dict]]): The request object. The `ListGroupMembers` request. name (:class:`str`): Required. The group whose members are listed. The format @@ -1013,14 +1024,9 @@ async def __aexit__(self, exc_type, exc, tb): await self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-monitoring", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("GroupServiceAsyncClient",) diff --git a/google/cloud/monitoring_v3/services/group_service/client.py b/google/cloud/monitoring_v3/services/group_service/client.py index bf6ef6f4..4019983d 100644 --- a/google/cloud/monitoring_v3/services/group_service/client.py +++ b/google/cloud/monitoring_v3/services/group_service/client.py @@ -16,8 +16,20 @@ from collections import OrderedDict import os import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, + cast, +) + +from google.cloud.monitoring_v3 import gapic_version as package_version from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions @@ -58,7 +70,7 @@ class GroupServiceClientMeta(type): def get_transport_class( cls, - label: str = None, + label: Optional[str] = None, ) -> Type[GroupServiceTransport]: """Returns an appropriate transport class. @@ -340,8 +352,8 @@ def __init__( self, *, credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, GroupServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, + transport: Optional[Union[str, GroupServiceTransport]] = None, + client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the group service client. @@ -355,7 +367,7 @@ def __init__( transport (Union[str, GroupServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the + client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT @@ -385,6 +397,7 @@ def __init__( client_options = client_options_lib.from_dict(client_options) if client_options is None: client_options = client_options_lib.ClientOptions() + client_options = cast(client_options_lib.ClientOptions, client_options) api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( client_options @@ -437,11 +450,11 @@ def __init__( def list_groups( self, - request: Union[group_service.ListGroupsRequest, dict] = None, + request: Optional[Union[group_service.ListGroupsRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListGroupsPager: r"""Lists the existing groups. @@ -556,11 +569,11 @@ def sample_list_groups(): def get_group( self, - request: Union[group_service.GetGroupRequest, dict] = None, + request: Optional[Union[group_service.GetGroupRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> group.Group: r"""Gets a single group. @@ -691,12 +704,12 @@ def sample_get_group(): def create_group( self, - request: Union[group_service.CreateGroupRequest, dict] = None, + request: Optional[Union[group_service.CreateGroupRequest, dict]] = None, *, - name: str = None, - group: gm_group.Group = None, + name: Optional[str] = None, + group: Optional[gm_group.Group] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> gm_group.Group: r"""Creates a new group. @@ -838,11 +851,11 @@ def sample_create_group(): def update_group( self, - request: Union[group_service.UpdateGroupRequest, dict] = None, + request: Optional[Union[group_service.UpdateGroupRequest, dict]] = None, *, - group: gm_group.Group = None, + group: Optional[gm_group.Group] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> gm_group.Group: r"""Updates an existing group. You can change any group attributes @@ -973,11 +986,11 @@ def sample_update_group(): def delete_group( self, - request: Union[group_service.DeleteGroupRequest, dict] = None, + request: Optional[Union[group_service.DeleteGroupRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes an existing group. @@ -1067,11 +1080,11 @@ def sample_delete_group(): def list_group_members( self, - request: Union[group_service.ListGroupMembersRequest, dict] = None, + request: Optional[Union[group_service.ListGroupMembersRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListGroupMembersPager: r"""Lists the monitored resources that are members of a @@ -1197,14 +1210,9 @@ def __exit__(self, type, value, traceback): self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-monitoring", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("GroupServiceClient",) diff --git a/google/cloud/monitoring_v3/services/group_service/transports/base.py b/google/cloud/monitoring_v3/services/group_service/transports/base.py index a55b13f6..fee17266 100644 --- a/google/cloud/monitoring_v3/services/group_service/transports/base.py +++ b/google/cloud/monitoring_v3/services/group_service/transports/base.py @@ -15,7 +15,8 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources + +from google.cloud.monitoring_v3 import gapic_version as package_version import google.auth # type: ignore import google.api_core @@ -30,14 +31,9 @@ from google.cloud.monitoring_v3.types import group_service from google.protobuf import empty_pb2 # type: ignore -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-monitoring", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) class GroupServiceTransport(abc.ABC): @@ -55,7 +51,7 @@ def __init__( self, *, host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, diff --git a/google/cloud/monitoring_v3/services/group_service/transports/grpc.py b/google/cloud/monitoring_v3/services/group_service/transports/grpc.py index 90ef90a7..bae90bc0 100644 --- a/google/cloud/monitoring_v3/services/group_service/transports/grpc.py +++ b/google/cloud/monitoring_v3/services/group_service/transports/grpc.py @@ -61,14 +61,14 @@ def __init__( self, *, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: Optional[grpc.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, @@ -195,8 +195,8 @@ def __init__( def create_channel( cls, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, **kwargs, diff --git a/google/cloud/monitoring_v3/services/group_service/transports/grpc_asyncio.py b/google/cloud/monitoring_v3/services/group_service/transports/grpc_asyncio.py index 42294ced..5e73cf98 100644 --- a/google/cloud/monitoring_v3/services/group_service/transports/grpc_asyncio.py +++ b/google/cloud/monitoring_v3/services/group_service/transports/grpc_asyncio.py @@ -63,7 +63,7 @@ class GroupServiceGrpcAsyncIOTransport(GroupServiceTransport): def create_channel( cls, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -106,15 +106,15 @@ def __init__( self, *, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, + channel: Optional[aio.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, api_audience: Optional[str] = None, diff --git a/google/cloud/monitoring_v3/services/metric_service/async_client.py b/google/cloud/monitoring_v3/services/metric_service/async_client.py index 1e9dc7f1..ef58bc5c 100644 --- a/google/cloud/monitoring_v3/services/metric_service/async_client.py +++ b/google/cloud/monitoring_v3/services/metric_service/async_client.py @@ -16,8 +16,19 @@ from collections import OrderedDict import functools import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, +) + +from google.cloud.monitoring_v3 import gapic_version as package_version from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions @@ -174,9 +185,9 @@ def transport(self) -> MetricServiceTransport: def __init__( self, *, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, MetricServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, + client_options: Optional[ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the metric service client. @@ -220,13 +231,13 @@ def __init__( async def list_monitored_resource_descriptors( self, - request: Union[ - metric_service.ListMonitoredResourceDescriptorsRequest, dict + request: Optional[ + Union[metric_service.ListMonitoredResourceDescriptorsRequest, dict] ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListMonitoredResourceDescriptorsAsyncPager: r"""Lists monitored resource descriptors that match a @@ -260,7 +271,7 @@ async def sample_list_monitored_resource_descriptors(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.ListMonitoredResourceDescriptorsRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.ListMonitoredResourceDescriptorsRequest, dict]]): The request object. The `ListMonitoredResourceDescriptors` request. name (:class:`str`): @@ -351,13 +362,13 @@ async def sample_list_monitored_resource_descriptors(): async def get_monitored_resource_descriptor( self, - request: Union[ - metric_service.GetMonitoredResourceDescriptorRequest, dict + request: Optional[ + Union[metric_service.GetMonitoredResourceDescriptorRequest, dict] ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> monitored_resource_pb2.MonitoredResourceDescriptor: r"""Gets a single monitored resource descriptor. This @@ -390,7 +401,7 @@ async def sample_get_monitored_resource_descriptor(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.GetMonitoredResourceDescriptorRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.GetMonitoredResourceDescriptorRequest, dict]]): The request object. The `GetMonitoredResourceDescriptor` request. name (:class:`str`): @@ -481,11 +492,13 @@ async def sample_get_monitored_resource_descriptor(): async def list_metric_descriptors( self, - request: Union[metric_service.ListMetricDescriptorsRequest, dict] = None, + request: Optional[ + Union[metric_service.ListMetricDescriptorsRequest, dict] + ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListMetricDescriptorsAsyncPager: r"""Lists metric descriptors that match a filter. This @@ -519,7 +532,7 @@ async def sample_list_metric_descriptors(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.ListMetricDescriptorsRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.ListMetricDescriptorsRequest, dict]]): The request object. The `ListMetricDescriptors` request. name (:class:`str`): Required. The @@ -609,11 +622,13 @@ async def sample_list_metric_descriptors(): async def get_metric_descriptor( self, - request: Union[metric_service.GetMetricDescriptorRequest, dict] = None, + request: Optional[ + Union[metric_service.GetMetricDescriptorRequest, dict] + ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> metric_pb2.MetricDescriptor: r"""Gets a single metric descriptor. This method does not @@ -646,7 +661,7 @@ async def sample_get_metric_descriptor(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.GetMetricDescriptorRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.GetMetricDescriptorRequest, dict]]): The request object. The `GetMetricDescriptor` request. name (:class:`str`): Required. The metric descriptor on which to execute the @@ -730,12 +745,14 @@ async def sample_get_metric_descriptor(): async def create_metric_descriptor( self, - request: Union[metric_service.CreateMetricDescriptorRequest, dict] = None, + request: Optional[ + Union[metric_service.CreateMetricDescriptorRequest, dict] + ] = None, *, - name: str = None, - metric_descriptor: metric_pb2.MetricDescriptor = None, + name: Optional[str] = None, + metric_descriptor: Optional[metric_pb2.MetricDescriptor] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> metric_pb2.MetricDescriptor: r"""Creates a new metric descriptor. The creation is executed @@ -771,7 +788,7 @@ async def sample_create_metric_descriptor(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.CreateMetricDescriptorRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.CreateMetricDescriptorRequest, dict]]): The request object. The `CreateMetricDescriptor` request. name (:class:`str`): @@ -852,11 +869,13 @@ async def sample_create_metric_descriptor(): async def delete_metric_descriptor( self, - request: Union[metric_service.DeleteMetricDescriptorRequest, dict] = None, + request: Optional[ + Union[metric_service.DeleteMetricDescriptorRequest, dict] + ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes a metric descriptor. Only user-created `custom @@ -887,7 +906,7 @@ async def sample_delete_metric_descriptor(): await client.delete_metric_descriptor(request=request) Args: - request (Union[google.cloud.monitoring_v3.types.DeleteMetricDescriptorRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.DeleteMetricDescriptorRequest, dict]]): The request object. The `DeleteMetricDescriptor` request. name (:class:`str`): @@ -960,14 +979,14 @@ async def sample_delete_metric_descriptor(): async def list_time_series( self, - request: Union[metric_service.ListTimeSeriesRequest, dict] = None, + request: Optional[Union[metric_service.ListTimeSeriesRequest, dict]] = None, *, - name: str = None, - filter: str = None, - interval: common.TimeInterval = None, - view: metric_service.ListTimeSeriesRequest.TimeSeriesView = None, + name: Optional[str] = None, + filter: Optional[str] = None, + interval: Optional[common.TimeInterval] = None, + view: Optional[metric_service.ListTimeSeriesRequest.TimeSeriesView] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListTimeSeriesAsyncPager: r"""Lists time series that match a filter. This method @@ -1003,7 +1022,7 @@ async def sample_list_time_series(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.ListTimeSeriesRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.ListTimeSeriesRequest, dict]]): The request object. The `ListTimeSeries` request. name (:class:`str`): Required. The @@ -1135,12 +1154,12 @@ async def sample_list_time_series(): async def create_time_series( self, - request: Union[metric_service.CreateTimeSeriesRequest, dict] = None, + request: Optional[Union[metric_service.CreateTimeSeriesRequest, dict]] = None, *, - name: str = None, - time_series: Sequence[gm_metric.TimeSeries] = None, + name: Optional[str] = None, + time_series: Optional[MutableSequence[gm_metric.TimeSeries]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Creates or adds data to one or more time series. @@ -1173,7 +1192,7 @@ async def sample_create_time_series(): await client.create_time_series(request=request) Args: - request (Union[google.cloud.monitoring_v3.types.CreateTimeSeriesRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.CreateTimeSeriesRequest, dict]]): The request object. The `CreateTimeSeries` request. name (:class:`str`): Required. The @@ -1187,7 +1206,7 @@ async def sample_create_time_series(): This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - time_series (:class:`Sequence[google.cloud.monitoring_v3.types.TimeSeries]`): + time_series (:class:`MutableSequence[google.cloud.monitoring_v3.types.TimeSeries]`): Required. The new data to be added to a list of time series. Adds at most one data point to each of several time series. The new data point must be more recent than @@ -1251,12 +1270,12 @@ async def sample_create_time_series(): async def create_service_time_series( self, - request: Union[metric_service.CreateTimeSeriesRequest, dict] = None, + request: Optional[Union[metric_service.CreateTimeSeriesRequest, dict]] = None, *, - name: str = None, - time_series: Sequence[gm_metric.TimeSeries] = None, + name: Optional[str] = None, + time_series: Optional[MutableSequence[gm_metric.TimeSeries]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Creates or adds data to one or more service time series. A @@ -1293,7 +1312,7 @@ async def sample_create_service_time_series(): await client.create_service_time_series(request=request) Args: - request (Union[google.cloud.monitoring_v3.types.CreateTimeSeriesRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.CreateTimeSeriesRequest, dict]]): The request object. The `CreateTimeSeries` request. name (:class:`str`): Required. The @@ -1307,7 +1326,7 @@ async def sample_create_service_time_series(): This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - time_series (:class:`Sequence[google.cloud.monitoring_v3.types.TimeSeries]`): + time_series (:class:`MutableSequence[google.cloud.monitoring_v3.types.TimeSeries]`): Required. The new data to be added to a list of time series. Adds at most one data point to each of several time series. The new data point must be more recent than @@ -1376,14 +1395,9 @@ async def __aexit__(self, exc_type, exc, tb): await self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-monitoring", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("MetricServiceAsyncClient",) diff --git a/google/cloud/monitoring_v3/services/metric_service/client.py b/google/cloud/monitoring_v3/services/metric_service/client.py index f1b516d9..b21a1448 100644 --- a/google/cloud/monitoring_v3/services/metric_service/client.py +++ b/google/cloud/monitoring_v3/services/metric_service/client.py @@ -16,8 +16,20 @@ from collections import OrderedDict import os import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, + cast, +) + +from google.cloud.monitoring_v3 import gapic_version as package_version from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions @@ -61,7 +73,7 @@ class MetricServiceClientMeta(type): def get_transport_class( cls, - label: str = None, + label: Optional[str] = None, ) -> Type[MetricServiceTransport]: """Returns an appropriate transport class. @@ -366,8 +378,8 @@ def __init__( self, *, credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, MetricServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, + transport: Optional[Union[str, MetricServiceTransport]] = None, + client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the metric service client. @@ -381,7 +393,7 @@ def __init__( transport (Union[str, MetricServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the + client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT @@ -411,6 +423,7 @@ def __init__( client_options = client_options_lib.from_dict(client_options) if client_options is None: client_options = client_options_lib.ClientOptions() + client_options = cast(client_options_lib.ClientOptions, client_options) api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( client_options @@ -463,13 +476,13 @@ def __init__( def list_monitored_resource_descriptors( self, - request: Union[ - metric_service.ListMonitoredResourceDescriptorsRequest, dict + request: Optional[ + Union[metric_service.ListMonitoredResourceDescriptorsRequest, dict] ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListMonitoredResourceDescriptorsPager: r"""Lists monitored resource descriptors that match a @@ -589,13 +602,13 @@ def sample_list_monitored_resource_descriptors(): def get_monitored_resource_descriptor( self, - request: Union[ - metric_service.GetMonitoredResourceDescriptorRequest, dict + request: Optional[ + Union[metric_service.GetMonitoredResourceDescriptorRequest, dict] ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> monitored_resource_pb2.MonitoredResourceDescriptor: r"""Gets a single monitored resource descriptor. This @@ -714,11 +727,13 @@ def sample_get_monitored_resource_descriptor(): def list_metric_descriptors( self, - request: Union[metric_service.ListMetricDescriptorsRequest, dict] = None, + request: Optional[ + Union[metric_service.ListMetricDescriptorsRequest, dict] + ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListMetricDescriptorsPager: r"""Lists metric descriptors that match a filter. This @@ -833,11 +848,13 @@ def sample_list_metric_descriptors(): def get_metric_descriptor( self, - request: Union[metric_service.GetMetricDescriptorRequest, dict] = None, + request: Optional[ + Union[metric_service.GetMetricDescriptorRequest, dict] + ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> metric_pb2.MetricDescriptor: r"""Gets a single metric descriptor. This method does not @@ -945,12 +962,14 @@ def sample_get_metric_descriptor(): def create_metric_descriptor( self, - request: Union[metric_service.CreateMetricDescriptorRequest, dict] = None, + request: Optional[ + Union[metric_service.CreateMetricDescriptorRequest, dict] + ] = None, *, - name: str = None, - metric_descriptor: metric_pb2.MetricDescriptor = None, + name: Optional[str] = None, + metric_descriptor: Optional[metric_pb2.MetricDescriptor] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> metric_pb2.MetricDescriptor: r"""Creates a new metric descriptor. The creation is executed @@ -1067,11 +1086,13 @@ def sample_create_metric_descriptor(): def delete_metric_descriptor( self, - request: Union[metric_service.DeleteMetricDescriptorRequest, dict] = None, + request: Optional[ + Union[metric_service.DeleteMetricDescriptorRequest, dict] + ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes a metric descriptor. Only user-created `custom @@ -1166,14 +1187,14 @@ def sample_delete_metric_descriptor(): def list_time_series( self, - request: Union[metric_service.ListTimeSeriesRequest, dict] = None, + request: Optional[Union[metric_service.ListTimeSeriesRequest, dict]] = None, *, - name: str = None, - filter: str = None, - interval: common.TimeInterval = None, - view: metric_service.ListTimeSeriesRequest.TimeSeriesView = None, + name: Optional[str] = None, + filter: Optional[str] = None, + interval: Optional[common.TimeInterval] = None, + view: Optional[metric_service.ListTimeSeriesRequest.TimeSeriesView] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListTimeSeriesPager: r"""Lists time series that match a filter. This method @@ -1332,12 +1353,12 @@ def sample_list_time_series(): def create_time_series( self, - request: Union[metric_service.CreateTimeSeriesRequest, dict] = None, + request: Optional[Union[metric_service.CreateTimeSeriesRequest, dict]] = None, *, - name: str = None, - time_series: Sequence[gm_metric.TimeSeries] = None, + name: Optional[str] = None, + time_series: Optional[MutableSequence[gm_metric.TimeSeries]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Creates or adds data to one or more time series. @@ -1384,7 +1405,7 @@ def sample_create_time_series(): This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - time_series (Sequence[google.cloud.monitoring_v3.types.TimeSeries]): + time_series (MutableSequence[google.cloud.monitoring_v3.types.TimeSeries]): Required. The new data to be added to a list of time series. Adds at most one data point to each of several time series. The new data point must be more recent than @@ -1448,12 +1469,12 @@ def sample_create_time_series(): def create_service_time_series( self, - request: Union[metric_service.CreateTimeSeriesRequest, dict] = None, + request: Optional[Union[metric_service.CreateTimeSeriesRequest, dict]] = None, *, - name: str = None, - time_series: Sequence[gm_metric.TimeSeries] = None, + name: Optional[str] = None, + time_series: Optional[MutableSequence[gm_metric.TimeSeries]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Creates or adds data to one or more service time series. A @@ -1504,7 +1525,7 @@ def sample_create_service_time_series(): This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - time_series (Sequence[google.cloud.monitoring_v3.types.TimeSeries]): + time_series (MutableSequence[google.cloud.monitoring_v3.types.TimeSeries]): Required. The new data to be added to a list of time series. Adds at most one data point to each of several time series. The new data point must be more recent than @@ -1582,14 +1603,9 @@ def __exit__(self, type, value, traceback): self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-monitoring", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("MetricServiceClient",) diff --git a/google/cloud/monitoring_v3/services/metric_service/transports/base.py b/google/cloud/monitoring_v3/services/metric_service/transports/base.py index 1e4922d1..0c7bfc6e 100644 --- a/google/cloud/monitoring_v3/services/metric_service/transports/base.py +++ b/google/cloud/monitoring_v3/services/metric_service/transports/base.py @@ -15,7 +15,8 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources + +from google.cloud.monitoring_v3 import gapic_version as package_version import google.auth # type: ignore import google.api_core @@ -30,14 +31,9 @@ from google.cloud.monitoring_v3.types import metric_service from google.protobuf import empty_pb2 # type: ignore -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-monitoring", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) class MetricServiceTransport(abc.ABC): @@ -56,7 +52,7 @@ def __init__( self, *, host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, diff --git a/google/cloud/monitoring_v3/services/metric_service/transports/grpc.py b/google/cloud/monitoring_v3/services/metric_service/transports/grpc.py index 0b9e02d6..d8bb6457 100644 --- a/google/cloud/monitoring_v3/services/metric_service/transports/grpc.py +++ b/google/cloud/monitoring_v3/services/metric_service/transports/grpc.py @@ -51,14 +51,14 @@ def __init__( self, *, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: Optional[grpc.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, @@ -185,8 +185,8 @@ def __init__( def create_channel( cls, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, **kwargs, diff --git a/google/cloud/monitoring_v3/services/metric_service/transports/grpc_asyncio.py b/google/cloud/monitoring_v3/services/metric_service/transports/grpc_asyncio.py index 3d7fda0e..6bb1bec2 100644 --- a/google/cloud/monitoring_v3/services/metric_service/transports/grpc_asyncio.py +++ b/google/cloud/monitoring_v3/services/metric_service/transports/grpc_asyncio.py @@ -53,7 +53,7 @@ class MetricServiceGrpcAsyncIOTransport(MetricServiceTransport): def create_channel( cls, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -96,15 +96,15 @@ def __init__( self, *, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, + channel: Optional[aio.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, api_audience: Optional[str] = None, diff --git a/google/cloud/monitoring_v3/services/notification_channel_service/async_client.py b/google/cloud/monitoring_v3/services/notification_channel_service/async_client.py index 0b19fb28..96e9ea01 100644 --- a/google/cloud/monitoring_v3/services/notification_channel_service/async_client.py +++ b/google/cloud/monitoring_v3/services/notification_channel_service/async_client.py @@ -16,8 +16,19 @@ from collections import OrderedDict import functools import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, +) + +from google.cloud.monitoring_v3 import gapic_version as package_version from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions @@ -185,9 +196,9 @@ def transport(self) -> NotificationChannelServiceTransport: def __init__( self, *, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, NotificationChannelServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, + client_options: Optional[ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the notification channel service client. @@ -231,13 +242,13 @@ def __init__( async def list_notification_channel_descriptors( self, - request: Union[ - notification_service.ListNotificationChannelDescriptorsRequest, dict + request: Optional[ + Union[notification_service.ListNotificationChannelDescriptorsRequest, dict] ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListNotificationChannelDescriptorsAsyncPager: r"""Lists the descriptors for supported channel types. @@ -272,7 +283,7 @@ async def sample_list_notification_channel_descriptors(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.ListNotificationChannelDescriptorsRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.ListNotificationChannelDescriptorsRequest, dict]]): The request object. The `ListNotificationChannelDescriptors` request. name (:class:`str`): @@ -373,13 +384,13 @@ async def sample_list_notification_channel_descriptors(): async def get_notification_channel_descriptor( self, - request: Union[ - notification_service.GetNotificationChannelDescriptorRequest, dict + request: Optional[ + Union[notification_service.GetNotificationChannelDescriptorRequest, dict] ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> notification.NotificationChannelDescriptor: r"""Gets a single channel descriptor. The descriptor @@ -413,7 +424,7 @@ async def sample_get_notification_channel_descriptor(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.GetNotificationChannelDescriptorRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.GetNotificationChannelDescriptorRequest, dict]]): The request object. The `GetNotificationChannelDescriptor` response. name (:class:`str`): @@ -495,13 +506,13 @@ async def sample_get_notification_channel_descriptor(): async def list_notification_channels( self, - request: Union[ - notification_service.ListNotificationChannelsRequest, dict + request: Optional[ + Union[notification_service.ListNotificationChannelsRequest, dict] ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListNotificationChannelsAsyncPager: r"""Lists the notification channels that have been @@ -535,7 +546,7 @@ async def sample_list_notification_channels(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.ListNotificationChannelsRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.ListNotificationChannelsRequest, dict]]): The request object. The `ListNotificationChannels` request. name (:class:`str`): @@ -633,11 +644,13 @@ async def sample_list_notification_channels(): async def get_notification_channel( self, - request: Union[notification_service.GetNotificationChannelRequest, dict] = None, + request: Optional[ + Union[notification_service.GetNotificationChannelRequest, dict] + ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> notification.NotificationChannel: r"""Gets a single notification channel. The channel @@ -675,7 +688,7 @@ async def sample_get_notification_channel(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.GetNotificationChannelRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.GetNotificationChannelRequest, dict]]): The request object. The `GetNotificationChannel` request. name (:class:`str`): @@ -759,14 +772,14 @@ async def sample_get_notification_channel(): async def create_notification_channel( self, - request: Union[ - notification_service.CreateNotificationChannelRequest, dict + request: Optional[ + Union[notification_service.CreateNotificationChannelRequest, dict] ] = None, *, - name: str = None, - notification_channel: notification.NotificationChannel = None, + name: Optional[str] = None, + notification_channel: Optional[notification.NotificationChannel] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> notification.NotificationChannel: r"""Creates a new notification channel, representing a @@ -800,7 +813,7 @@ async def sample_create_notification_channel(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.CreateNotificationChannelRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.CreateNotificationChannelRequest, dict]]): The request object. The `CreateNotificationChannel` request. name (:class:`str`): @@ -892,14 +905,14 @@ async def sample_create_notification_channel(): async def update_notification_channel( self, - request: Union[ - notification_service.UpdateNotificationChannelRequest, dict + request: Optional[ + Union[notification_service.UpdateNotificationChannelRequest, dict] ] = None, *, - update_mask: field_mask_pb2.FieldMask = None, - notification_channel: notification.NotificationChannel = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + notification_channel: Optional[notification.NotificationChannel] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> notification.NotificationChannel: r"""Updates a notification channel. Fields not specified @@ -931,7 +944,7 @@ async def sample_update_notification_channel(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.UpdateNotificationChannelRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.UpdateNotificationChannelRequest, dict]]): The request object. The `UpdateNotificationChannel` request. update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): @@ -1014,14 +1027,14 @@ async def sample_update_notification_channel(): async def delete_notification_channel( self, - request: Union[ - notification_service.DeleteNotificationChannelRequest, dict + request: Optional[ + Union[notification_service.DeleteNotificationChannelRequest, dict] ] = None, *, - name: str = None, - force: bool = None, + name: Optional[str] = None, + force: Optional[bool] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes a notification channel. @@ -1050,7 +1063,7 @@ async def sample_delete_notification_channel(): await client.delete_notification_channel(request=request) Args: - request (Union[google.cloud.monitoring_v3.types.DeleteNotificationChannelRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.DeleteNotificationChannelRequest, dict]]): The request object. The `DeleteNotificationChannel` request. name (:class:`str`): @@ -1135,13 +1148,16 @@ async def sample_delete_notification_channel(): async def send_notification_channel_verification_code( self, - request: Union[ - notification_service.SendNotificationChannelVerificationCodeRequest, dict + request: Optional[ + Union[ + notification_service.SendNotificationChannelVerificationCodeRequest, + dict, + ] ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Causes a verification code to be delivered to the channel. The @@ -1172,7 +1188,7 @@ async def sample_send_notification_channel_verification_code(): await client.send_notification_channel_verification_code(request=request) Args: - request (Union[google.cloud.monitoring_v3.types.SendNotificationChannelVerificationCodeRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.SendNotificationChannelVerificationCodeRequest, dict]]): The request object. The `SendNotificationChannelVerificationCode` request. name (:class:`str`): @@ -1231,13 +1247,15 @@ async def sample_send_notification_channel_verification_code(): async def get_notification_channel_verification_code( self, - request: Union[ - notification_service.GetNotificationChannelVerificationCodeRequest, dict + request: Optional[ + Union[ + notification_service.GetNotificationChannelVerificationCodeRequest, dict + ] ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> notification_service.GetNotificationChannelVerificationCodeResponse: r"""Requests a verification code for an already verified @@ -1296,7 +1314,7 @@ async def sample_get_notification_channel_verification_code(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.GetNotificationChannelVerificationCodeRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.GetNotificationChannelVerificationCodeRequest, dict]]): The request object. The `GetNotificationChannelVerificationCode` request. name (:class:`str`): @@ -1375,14 +1393,14 @@ async def sample_get_notification_channel_verification_code(): async def verify_notification_channel( self, - request: Union[ - notification_service.VerifyNotificationChannelRequest, dict + request: Optional[ + Union[notification_service.VerifyNotificationChannelRequest, dict] ] = None, *, - name: str = None, - code: str = None, + name: Optional[str] = None, + code: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> notification.NotificationChannel: r"""Verifies a ``NotificationChannel`` by proving receipt of the @@ -1417,7 +1435,7 @@ async def sample_verify_notification_channel(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.VerifyNotificationChannelRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.VerifyNotificationChannelRequest, dict]]): The request object. The `VerifyNotificationChannel` request. name (:class:`str`): @@ -1518,14 +1536,9 @@ async def __aexit__(self, exc_type, exc, tb): await self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-monitoring", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("NotificationChannelServiceAsyncClient",) diff --git a/google/cloud/monitoring_v3/services/notification_channel_service/client.py b/google/cloud/monitoring_v3/services/notification_channel_service/client.py index 64360045..b1987573 100644 --- a/google/cloud/monitoring_v3/services/notification_channel_service/client.py +++ b/google/cloud/monitoring_v3/services/notification_channel_service/client.py @@ -16,8 +16,20 @@ from collections import OrderedDict import os import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, + cast, +) + +from google.cloud.monitoring_v3 import gapic_version as package_version from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions @@ -65,7 +77,7 @@ class NotificationChannelServiceClientMeta(type): def get_transport_class( cls, - label: str = None, + label: Optional[str] = None, ) -> Type[NotificationChannelServiceTransport]: """Returns an appropriate transport class. @@ -360,8 +372,8 @@ def __init__( self, *, credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, NotificationChannelServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, + transport: Optional[Union[str, NotificationChannelServiceTransport]] = None, + client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the notification channel service client. @@ -375,7 +387,7 @@ def __init__( transport (Union[str, NotificationChannelServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the + client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT @@ -405,6 +417,7 @@ def __init__( client_options = client_options_lib.from_dict(client_options) if client_options is None: client_options = client_options_lib.ClientOptions() + client_options = cast(client_options_lib.ClientOptions, client_options) api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( client_options @@ -457,13 +470,13 @@ def __init__( def list_notification_channel_descriptors( self, - request: Union[ - notification_service.ListNotificationChannelDescriptorsRequest, dict + request: Optional[ + Union[notification_service.ListNotificationChannelDescriptorsRequest, dict] ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListNotificationChannelDescriptorsPager: r"""Lists the descriptors for supported channel types. @@ -594,13 +607,13 @@ def sample_list_notification_channel_descriptors(): def get_notification_channel_descriptor( self, - request: Union[ - notification_service.GetNotificationChannelDescriptorRequest, dict + request: Optional[ + Union[notification_service.GetNotificationChannelDescriptorRequest, dict] ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> notification.NotificationChannelDescriptor: r"""Gets a single channel descriptor. The descriptor @@ -713,13 +726,13 @@ def sample_get_notification_channel_descriptor(): def list_notification_channels( self, - request: Union[ - notification_service.ListNotificationChannelsRequest, dict + request: Optional[ + Union[notification_service.ListNotificationChannelsRequest, dict] ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListNotificationChannelsPager: r"""Lists the notification channels that have been @@ -846,11 +859,13 @@ def sample_list_notification_channels(): def get_notification_channel( self, - request: Union[notification_service.GetNotificationChannelRequest, dict] = None, + request: Optional[ + Union[notification_service.GetNotificationChannelRequest, dict] + ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> notification.NotificationChannel: r"""Gets a single notification channel. The channel @@ -963,14 +978,14 @@ def sample_get_notification_channel(): def create_notification_channel( self, - request: Union[ - notification_service.CreateNotificationChannelRequest, dict + request: Optional[ + Union[notification_service.CreateNotificationChannelRequest, dict] ] = None, *, - name: str = None, - notification_channel: notification.NotificationChannel = None, + name: Optional[str] = None, + notification_channel: Optional[notification.NotificationChannel] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> notification.NotificationChannel: r"""Creates a new notification channel, representing a @@ -1100,14 +1115,14 @@ def sample_create_notification_channel(): def update_notification_channel( self, - request: Union[ - notification_service.UpdateNotificationChannelRequest, dict + request: Optional[ + Union[notification_service.UpdateNotificationChannelRequest, dict] ] = None, *, - update_mask: field_mask_pb2.FieldMask = None, - notification_channel: notification.NotificationChannel = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + notification_channel: Optional[notification.NotificationChannel] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> notification.NotificationChannel: r"""Updates a notification channel. Fields not specified @@ -1226,14 +1241,14 @@ def sample_update_notification_channel(): def delete_notification_channel( self, - request: Union[ - notification_service.DeleteNotificationChannelRequest, dict + request: Optional[ + Union[notification_service.DeleteNotificationChannelRequest, dict] ] = None, *, - name: str = None, - force: bool = None, + name: Optional[str] = None, + force: Optional[bool] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes a notification channel. @@ -1342,13 +1357,16 @@ def sample_delete_notification_channel(): def send_notification_channel_verification_code( self, - request: Union[ - notification_service.SendNotificationChannelVerificationCodeRequest, dict + request: Optional[ + Union[ + notification_service.SendNotificationChannelVerificationCodeRequest, + dict, + ] ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Causes a verification code to be delivered to the channel. The @@ -1444,13 +1462,15 @@ def sample_send_notification_channel_verification_code(): def get_notification_channel_verification_code( self, - request: Union[ - notification_service.GetNotificationChannelVerificationCodeRequest, dict + request: Optional[ + Union[ + notification_service.GetNotificationChannelVerificationCodeRequest, dict + ] ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> notification_service.GetNotificationChannelVerificationCodeResponse: r"""Requests a verification code for an already verified @@ -1585,14 +1605,14 @@ def sample_get_notification_channel_verification_code(): def verify_notification_channel( self, - request: Union[ - notification_service.VerifyNotificationChannelRequest, dict + request: Optional[ + Union[notification_service.VerifyNotificationChannelRequest, dict] ] = None, *, - name: str = None, - code: str = None, + name: Optional[str] = None, + code: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> notification.NotificationChannel: r"""Verifies a ``NotificationChannel`` by proving receipt of the @@ -1730,14 +1750,9 @@ def __exit__(self, type, value, traceback): self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-monitoring", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("NotificationChannelServiceClient",) diff --git a/google/cloud/monitoring_v3/services/notification_channel_service/transports/base.py b/google/cloud/monitoring_v3/services/notification_channel_service/transports/base.py index a76bee6c..914074eb 100644 --- a/google/cloud/monitoring_v3/services/notification_channel_service/transports/base.py +++ b/google/cloud/monitoring_v3/services/notification_channel_service/transports/base.py @@ -15,7 +15,8 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources + +from google.cloud.monitoring_v3 import gapic_version as package_version import google.auth # type: ignore import google.api_core @@ -29,14 +30,9 @@ from google.cloud.monitoring_v3.types import notification_service from google.protobuf import empty_pb2 # type: ignore -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-monitoring", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) class NotificationChannelServiceTransport(abc.ABC): @@ -54,7 +50,7 @@ def __init__( self, *, host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, diff --git a/google/cloud/monitoring_v3/services/notification_channel_service/transports/grpc.py b/google/cloud/monitoring_v3/services/notification_channel_service/transports/grpc.py index ee3db7ec..ebe382eb 100644 --- a/google/cloud/monitoring_v3/services/notification_channel_service/transports/grpc.py +++ b/google/cloud/monitoring_v3/services/notification_channel_service/transports/grpc.py @@ -50,14 +50,14 @@ def __init__( self, *, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: Optional[grpc.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, @@ -184,8 +184,8 @@ def __init__( def create_channel( cls, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, **kwargs, diff --git a/google/cloud/monitoring_v3/services/notification_channel_service/transports/grpc_asyncio.py b/google/cloud/monitoring_v3/services/notification_channel_service/transports/grpc_asyncio.py index f81f2a95..9a0e4059 100644 --- a/google/cloud/monitoring_v3/services/notification_channel_service/transports/grpc_asyncio.py +++ b/google/cloud/monitoring_v3/services/notification_channel_service/transports/grpc_asyncio.py @@ -54,7 +54,7 @@ class NotificationChannelServiceGrpcAsyncIOTransport( def create_channel( cls, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -97,15 +97,15 @@ def __init__( self, *, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, + channel: Optional[aio.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, api_audience: Optional[str] = None, diff --git a/google/cloud/monitoring_v3/services/query_service/async_client.py b/google/cloud/monitoring_v3/services/query_service/async_client.py index 3cc4dacd..68dc784f 100644 --- a/google/cloud/monitoring_v3/services/query_service/async_client.py +++ b/google/cloud/monitoring_v3/services/query_service/async_client.py @@ -16,8 +16,19 @@ from collections import OrderedDict import functools import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, +) + +from google.cloud.monitoring_v3 import gapic_version as package_version from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions @@ -156,9 +167,9 @@ def transport(self) -> QueryServiceTransport: def __init__( self, *, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, QueryServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, + client_options: Optional[ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the query service client. @@ -202,10 +213,10 @@ def __init__( async def query_time_series( self, - request: Union[metric_service.QueryTimeSeriesRequest, dict] = None, + request: Optional[Union[metric_service.QueryTimeSeriesRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.QueryTimeSeriesAsyncPager: r"""Queries time series using Monitoring Query Language. @@ -240,7 +251,7 @@ async def sample_query_time_series(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.QueryTimeSeriesRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.QueryTimeSeriesRequest, dict]]): The request object. The `QueryTimeSeries` request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. @@ -300,14 +311,9 @@ async def __aexit__(self, exc_type, exc, tb): await self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-monitoring", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("QueryServiceAsyncClient",) diff --git a/google/cloud/monitoring_v3/services/query_service/client.py b/google/cloud/monitoring_v3/services/query_service/client.py index 1bf2b78f..969bed72 100644 --- a/google/cloud/monitoring_v3/services/query_service/client.py +++ b/google/cloud/monitoring_v3/services/query_service/client.py @@ -16,8 +16,20 @@ from collections import OrderedDict import os import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, + cast, +) + +from google.cloud.monitoring_v3 import gapic_version as package_version from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions @@ -56,7 +68,7 @@ class QueryServiceClientMeta(type): def get_transport_class( cls, - label: str = None, + label: Optional[str] = None, ) -> Type[QueryServiceTransport]: """Returns an appropriate transport class. @@ -312,8 +324,8 @@ def __init__( self, *, credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, QueryServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, + transport: Optional[Union[str, QueryServiceTransport]] = None, + client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the query service client. @@ -327,7 +339,7 @@ def __init__( transport (Union[str, QueryServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the + client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT @@ -357,6 +369,7 @@ def __init__( client_options = client_options_lib.from_dict(client_options) if client_options is None: client_options = client_options_lib.ClientOptions() + client_options = cast(client_options_lib.ClientOptions, client_options) api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( client_options @@ -409,10 +422,10 @@ def __init__( def query_time_series( self, - request: Union[metric_service.QueryTimeSeriesRequest, dict] = None, + request: Optional[Union[metric_service.QueryTimeSeriesRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.QueryTimeSeriesPager: r"""Queries time series using Monitoring Query Language. @@ -515,14 +528,9 @@ def __exit__(self, type, value, traceback): self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-monitoring", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("QueryServiceClient",) diff --git a/google/cloud/monitoring_v3/services/query_service/transports/base.py b/google/cloud/monitoring_v3/services/query_service/transports/base.py index efddb1b8..e60ced7c 100644 --- a/google/cloud/monitoring_v3/services/query_service/transports/base.py +++ b/google/cloud/monitoring_v3/services/query_service/transports/base.py @@ -15,7 +15,8 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources + +from google.cloud.monitoring_v3 import gapic_version as package_version import google.auth # type: ignore import google.api_core @@ -27,14 +28,9 @@ from google.cloud.monitoring_v3.types import metric_service -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-monitoring", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) class QueryServiceTransport(abc.ABC): @@ -52,7 +48,7 @@ def __init__( self, *, host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, diff --git a/google/cloud/monitoring_v3/services/query_service/transports/grpc.py b/google/cloud/monitoring_v3/services/query_service/transports/grpc.py index e5c0496c..2e85015e 100644 --- a/google/cloud/monitoring_v3/services/query_service/transports/grpc.py +++ b/google/cloud/monitoring_v3/services/query_service/transports/grpc.py @@ -49,14 +49,14 @@ def __init__( self, *, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: Optional[grpc.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, @@ -183,8 +183,8 @@ def __init__( def create_channel( cls, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, **kwargs, diff --git a/google/cloud/monitoring_v3/services/query_service/transports/grpc_asyncio.py b/google/cloud/monitoring_v3/services/query_service/transports/grpc_asyncio.py index 87058273..55620ee7 100644 --- a/google/cloud/monitoring_v3/services/query_service/transports/grpc_asyncio.py +++ b/google/cloud/monitoring_v3/services/query_service/transports/grpc_asyncio.py @@ -51,7 +51,7 @@ class QueryServiceGrpcAsyncIOTransport(QueryServiceTransport): def create_channel( cls, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -94,15 +94,15 @@ def __init__( self, *, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, + channel: Optional[aio.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, api_audience: Optional[str] = None, diff --git a/google/cloud/monitoring_v3/services/service_monitoring_service/async_client.py b/google/cloud/monitoring_v3/services/service_monitoring_service/async_client.py index cce25848..3f30e62b 100644 --- a/google/cloud/monitoring_v3/services/service_monitoring_service/async_client.py +++ b/google/cloud/monitoring_v3/services/service_monitoring_service/async_client.py @@ -16,8 +16,19 @@ from collections import OrderedDict import functools import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, +) + +from google.cloud.monitoring_v3 import gapic_version as package_version from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions @@ -177,9 +188,9 @@ def transport(self) -> ServiceMonitoringServiceTransport: def __init__( self, *, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, ServiceMonitoringServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, + client_options: Optional[ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the service monitoring service client. @@ -223,12 +234,12 @@ def __init__( async def create_service( self, - request: Union[service_service.CreateServiceRequest, dict] = None, + request: Optional[Union[service_service.CreateServiceRequest, dict]] = None, *, - parent: str = None, - service: gm_service.Service = None, + parent: Optional[str] = None, + service: Optional[gm_service.Service] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> gm_service.Service: r"""Create a ``Service``. @@ -260,7 +271,7 @@ async def sample_create_service(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.CreateServiceRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.CreateServiceRequest, dict]]): The request object. The `CreateService` request. parent (:class:`str`): Required. Resource @@ -341,11 +352,11 @@ async def sample_create_service(): async def get_service( self, - request: Union[service_service.GetServiceRequest, dict] = None, + request: Optional[Union[service_service.GetServiceRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> service.Service: r"""Get the named ``Service``. @@ -377,7 +388,7 @@ async def sample_get_service(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.GetServiceRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.GetServiceRequest, dict]]): The request object. The `GetService` request. name (:class:`str`): Required. Resource name of the ``Service``. The format @@ -459,11 +470,11 @@ async def sample_get_service(): async def list_services( self, - request: Union[service_service.ListServicesRequest, dict] = None, + request: Optional[Union[service_service.ListServicesRequest, dict]] = None, *, - parent: str = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListServicesAsyncPager: r"""List ``Service``\ s for this workspace. @@ -496,7 +507,7 @@ async def sample_list_services(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.ListServicesRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.ListServicesRequest, dict]]): The request object. The `ListServices` request. parent (:class:`str`): Required. Resource name of the parent containing the @@ -588,11 +599,11 @@ async def sample_list_services(): async def update_service( self, - request: Union[service_service.UpdateServiceRequest, dict] = None, + request: Optional[Union[service_service.UpdateServiceRequest, dict]] = None, *, - service: gm_service.Service = None, + service: Optional[gm_service.Service] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> gm_service.Service: r"""Update this ``Service``. @@ -623,7 +634,7 @@ async def sample_update_service(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.UpdateServiceRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.UpdateServiceRequest, dict]]): The request object. The `UpdateService` request. service (:class:`google.cloud.monitoring_v3.types.Service`): Required. The ``Service`` to draw updates from. The @@ -694,11 +705,11 @@ async def sample_update_service(): async def delete_service( self, - request: Union[service_service.DeleteServiceRequest, dict] = None, + request: Optional[Union[service_service.DeleteServiceRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Soft delete this ``Service``. @@ -727,7 +738,7 @@ async def sample_delete_service(): await client.delete_service(request=request) Args: - request (Union[google.cloud.monitoring_v3.types.DeleteServiceRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.DeleteServiceRequest, dict]]): The request object. The `DeleteService` request. name (:class:`str`): Required. Resource name of the ``Service`` to delete. @@ -796,12 +807,14 @@ async def sample_delete_service(): async def create_service_level_objective( self, - request: Union[service_service.CreateServiceLevelObjectiveRequest, dict] = None, + request: Optional[ + Union[service_service.CreateServiceLevelObjectiveRequest, dict] + ] = None, *, - parent: str = None, - service_level_objective: service.ServiceLevelObjective = None, + parent: Optional[str] = None, + service_level_objective: Optional[service.ServiceLevelObjective] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> service.ServiceLevelObjective: r"""Create a ``ServiceLevelObjective`` for the given ``Service``. @@ -833,7 +846,7 @@ async def sample_create_service_level_objective(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.CreateServiceLevelObjectiveRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.CreateServiceLevelObjectiveRequest, dict]]): The request object. The `CreateServiceLevelObjective` request. parent (:class:`str`): @@ -924,11 +937,13 @@ async def sample_create_service_level_objective(): async def get_service_level_objective( self, - request: Union[service_service.GetServiceLevelObjectiveRequest, dict] = None, + request: Optional[ + Union[service_service.GetServiceLevelObjectiveRequest, dict] + ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> service.ServiceLevelObjective: r"""Get a ``ServiceLevelObjective`` by name. @@ -960,7 +975,7 @@ async def sample_get_service_level_objective(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.GetServiceLevelObjectiveRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.GetServiceLevelObjectiveRequest, dict]]): The request object. The `GetServiceLevelObjective` request. name (:class:`str`): @@ -1050,11 +1065,13 @@ async def sample_get_service_level_objective(): async def list_service_level_objectives( self, - request: Union[service_service.ListServiceLevelObjectivesRequest, dict] = None, + request: Optional[ + Union[service_service.ListServiceLevelObjectivesRequest, dict] + ] = None, *, - parent: str = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListServiceLevelObjectivesAsyncPager: r"""List the ``ServiceLevelObjective``\ s for the given ``Service``. @@ -1087,7 +1104,7 @@ async def sample_list_service_level_objectives(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.ListServiceLevelObjectivesRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.ListServiceLevelObjectivesRequest, dict]]): The request object. The `ListServiceLevelObjectives` request. parent (:class:`str`): @@ -1179,11 +1196,13 @@ async def sample_list_service_level_objectives(): async def update_service_level_objective( self, - request: Union[service_service.UpdateServiceLevelObjectiveRequest, dict] = None, + request: Optional[ + Union[service_service.UpdateServiceLevelObjectiveRequest, dict] + ] = None, *, - service_level_objective: service.ServiceLevelObjective = None, + service_level_objective: Optional[service.ServiceLevelObjective] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> service.ServiceLevelObjective: r"""Update the given ``ServiceLevelObjective``. @@ -1214,7 +1233,7 @@ async def sample_update_service_level_objective(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.UpdateServiceLevelObjectiveRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.UpdateServiceLevelObjectiveRequest, dict]]): The request object. The `UpdateServiceLevelObjective` request. service_level_objective (:class:`google.cloud.monitoring_v3.types.ServiceLevelObjective`): @@ -1299,11 +1318,13 @@ async def sample_update_service_level_objective(): async def delete_service_level_objective( self, - request: Union[service_service.DeleteServiceLevelObjectiveRequest, dict] = None, + request: Optional[ + Union[service_service.DeleteServiceLevelObjectiveRequest, dict] + ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Delete the given ``ServiceLevelObjective``. @@ -1332,7 +1353,7 @@ async def sample_delete_service_level_objective(): await client.delete_service_level_objective(request=request) Args: - request (Union[google.cloud.monitoring_v3.types.DeleteServiceLevelObjectiveRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.DeleteServiceLevelObjectiveRequest, dict]]): The request object. The `DeleteServiceLevelObjective` request. name (:class:`str`): @@ -1407,14 +1428,9 @@ async def __aexit__(self, exc_type, exc, tb): await self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-monitoring", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("ServiceMonitoringServiceAsyncClient",) diff --git a/google/cloud/monitoring_v3/services/service_monitoring_service/client.py b/google/cloud/monitoring_v3/services/service_monitoring_service/client.py index 215b4962..6d33ae2a 100644 --- a/google/cloud/monitoring_v3/services/service_monitoring_service/client.py +++ b/google/cloud/monitoring_v3/services/service_monitoring_service/client.py @@ -16,8 +16,20 @@ from collections import OrderedDict import os import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, + cast, +) + +from google.cloud.monitoring_v3 import gapic_version as package_version from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions @@ -61,7 +73,7 @@ class ServiceMonitoringServiceClientMeta(type): def get_transport_class( cls, - label: str = None, + label: Optional[str] = None, ) -> Type[ServiceMonitoringServiceTransport]: """Returns an appropriate transport class. @@ -357,8 +369,8 @@ def __init__( self, *, credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, ServiceMonitoringServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, + transport: Optional[Union[str, ServiceMonitoringServiceTransport]] = None, + client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the service monitoring service client. @@ -372,7 +384,7 @@ def __init__( transport (Union[str, ServiceMonitoringServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the + client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT @@ -402,6 +414,7 @@ def __init__( client_options = client_options_lib.from_dict(client_options) if client_options is None: client_options = client_options_lib.ClientOptions() + client_options = cast(client_options_lib.ClientOptions, client_options) api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( client_options @@ -454,12 +467,12 @@ def __init__( def create_service( self, - request: Union[service_service.CreateServiceRequest, dict] = None, + request: Optional[Union[service_service.CreateServiceRequest, dict]] = None, *, - parent: str = None, - service: gm_service.Service = None, + parent: Optional[str] = None, + service: Optional[gm_service.Service] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> gm_service.Service: r"""Create a ``Service``. @@ -572,11 +585,11 @@ def sample_create_service(): def get_service( self, - request: Union[service_service.GetServiceRequest, dict] = None, + request: Optional[Union[service_service.GetServiceRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> service.Service: r"""Get the named ``Service``. @@ -681,11 +694,11 @@ def sample_get_service(): def list_services( self, - request: Union[service_service.ListServicesRequest, dict] = None, + request: Optional[Union[service_service.ListServicesRequest, dict]] = None, *, - parent: str = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListServicesPager: r"""List ``Service``\ s for this workspace. @@ -801,11 +814,11 @@ def sample_list_services(): def update_service( self, - request: Union[service_service.UpdateServiceRequest, dict] = None, + request: Optional[Union[service_service.UpdateServiceRequest, dict]] = None, *, - service: gm_service.Service = None, + service: Optional[gm_service.Service] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> gm_service.Service: r"""Update this ``Service``. @@ -907,11 +920,11 @@ def sample_update_service(): def delete_service( self, - request: Union[service_service.DeleteServiceRequest, dict] = None, + request: Optional[Union[service_service.DeleteServiceRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Soft delete this ``Service``. @@ -1000,12 +1013,14 @@ def sample_delete_service(): def create_service_level_objective( self, - request: Union[service_service.CreateServiceLevelObjectiveRequest, dict] = None, + request: Optional[ + Union[service_service.CreateServiceLevelObjectiveRequest, dict] + ] = None, *, - parent: str = None, - service_level_objective: service.ServiceLevelObjective = None, + parent: Optional[str] = None, + service_level_objective: Optional[service.ServiceLevelObjective] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> service.ServiceLevelObjective: r"""Create a ``ServiceLevelObjective`` for the given ``Service``. @@ -1130,11 +1145,13 @@ def sample_create_service_level_objective(): def get_service_level_objective( self, - request: Union[service_service.GetServiceLevelObjectiveRequest, dict] = None, + request: Optional[ + Union[service_service.GetServiceLevelObjectiveRequest, dict] + ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> service.ServiceLevelObjective: r"""Get a ``ServiceLevelObjective`` by name. @@ -1249,11 +1266,13 @@ def sample_get_service_level_objective(): def list_service_level_objectives( self, - request: Union[service_service.ListServiceLevelObjectivesRequest, dict] = None, + request: Optional[ + Union[service_service.ListServiceLevelObjectivesRequest, dict] + ] = None, *, - parent: str = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListServiceLevelObjectivesPager: r"""List the ``ServiceLevelObjective``\ s for the given ``Service``. @@ -1371,11 +1390,13 @@ def sample_list_service_level_objectives(): def update_service_level_objective( self, - request: Union[service_service.UpdateServiceLevelObjectiveRequest, dict] = None, + request: Optional[ + Union[service_service.UpdateServiceLevelObjectiveRequest, dict] + ] = None, *, - service_level_objective: service.ServiceLevelObjective = None, + service_level_objective: Optional[service.ServiceLevelObjective] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> service.ServiceLevelObjective: r"""Update the given ``ServiceLevelObjective``. @@ -1493,11 +1514,13 @@ def sample_update_service_level_objective(): def delete_service_level_objective( self, - request: Union[service_service.DeleteServiceLevelObjectiveRequest, dict] = None, + request: Optional[ + Union[service_service.DeleteServiceLevelObjectiveRequest, dict] + ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Delete the given ``ServiceLevelObjective``. @@ -1601,14 +1624,9 @@ def __exit__(self, type, value, traceback): self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-monitoring", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("ServiceMonitoringServiceClient",) diff --git a/google/cloud/monitoring_v3/services/service_monitoring_service/transports/base.py b/google/cloud/monitoring_v3/services/service_monitoring_service/transports/base.py index 0c737414..dbc5ca5e 100644 --- a/google/cloud/monitoring_v3/services/service_monitoring_service/transports/base.py +++ b/google/cloud/monitoring_v3/services/service_monitoring_service/transports/base.py @@ -15,7 +15,8 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources + +from google.cloud.monitoring_v3 import gapic_version as package_version import google.auth # type: ignore import google.api_core @@ -30,14 +31,9 @@ from google.cloud.monitoring_v3.types import service_service from google.protobuf import empty_pb2 # type: ignore -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-monitoring", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) class ServiceMonitoringServiceTransport(abc.ABC): @@ -55,7 +51,7 @@ def __init__( self, *, host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, diff --git a/google/cloud/monitoring_v3/services/service_monitoring_service/transports/grpc.py b/google/cloud/monitoring_v3/services/service_monitoring_service/transports/grpc.py index 127b8e03..d0fe7ae2 100644 --- a/google/cloud/monitoring_v3/services/service_monitoring_service/transports/grpc.py +++ b/google/cloud/monitoring_v3/services/service_monitoring_service/transports/grpc.py @@ -53,14 +53,14 @@ def __init__( self, *, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: Optional[grpc.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, @@ -187,8 +187,8 @@ def __init__( def create_channel( cls, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, **kwargs, diff --git a/google/cloud/monitoring_v3/services/service_monitoring_service/transports/grpc_asyncio.py b/google/cloud/monitoring_v3/services/service_monitoring_service/transports/grpc_asyncio.py index 59321cff..b718fccc 100644 --- a/google/cloud/monitoring_v3/services/service_monitoring_service/transports/grpc_asyncio.py +++ b/google/cloud/monitoring_v3/services/service_monitoring_service/transports/grpc_asyncio.py @@ -55,7 +55,7 @@ class ServiceMonitoringServiceGrpcAsyncIOTransport(ServiceMonitoringServiceTrans def create_channel( cls, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -98,15 +98,15 @@ def __init__( self, *, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, + channel: Optional[aio.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, api_audience: Optional[str] = None, diff --git a/google/cloud/monitoring_v3/services/uptime_check_service/async_client.py b/google/cloud/monitoring_v3/services/uptime_check_service/async_client.py index 1756f9c3..7f66bbe3 100644 --- a/google/cloud/monitoring_v3/services/uptime_check_service/async_client.py +++ b/google/cloud/monitoring_v3/services/uptime_check_service/async_client.py @@ -16,8 +16,19 @@ from collections import OrderedDict import functools import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, +) + +from google.cloud.monitoring_v3 import gapic_version as package_version from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions @@ -174,9 +185,9 @@ def transport(self) -> UptimeCheckServiceTransport: def __init__( self, *, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, UptimeCheckServiceTransport] = "grpc_asyncio", - client_options: ClientOptions = None, + client_options: Optional[ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the uptime check service client. @@ -220,11 +231,13 @@ def __init__( async def list_uptime_check_configs( self, - request: Union[uptime_service.ListUptimeCheckConfigsRequest, dict] = None, + request: Optional[ + Union[uptime_service.ListUptimeCheckConfigsRequest, dict] + ] = None, *, - parent: str = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListUptimeCheckConfigsAsyncPager: r"""Lists the existing valid Uptime check configurations @@ -259,7 +272,7 @@ async def sample_list_uptime_check_configs(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.ListUptimeCheckConfigsRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.ListUptimeCheckConfigsRequest, dict]]): The request object. The protocol for the `ListUptimeCheckConfigs` request. parent (:class:`str`): @@ -351,11 +364,13 @@ async def sample_list_uptime_check_configs(): async def get_uptime_check_config( self, - request: Union[uptime_service.GetUptimeCheckConfigRequest, dict] = None, + request: Optional[ + Union[uptime_service.GetUptimeCheckConfigRequest, dict] + ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> uptime.UptimeCheckConfig: r"""Gets a single Uptime check configuration. @@ -387,7 +402,7 @@ async def sample_get_uptime_check_config(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.GetUptimeCheckConfigRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.GetUptimeCheckConfigRequest, dict]]): The request object. The protocol for the `GetUptimeCheckConfig` request. name (:class:`str`): @@ -467,12 +482,14 @@ async def sample_get_uptime_check_config(): async def create_uptime_check_config( self, - request: Union[uptime_service.CreateUptimeCheckConfigRequest, dict] = None, + request: Optional[ + Union[uptime_service.CreateUptimeCheckConfigRequest, dict] + ] = None, *, - parent: str = None, - uptime_check_config: uptime.UptimeCheckConfig = None, + parent: Optional[str] = None, + uptime_check_config: Optional[uptime.UptimeCheckConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> uptime.UptimeCheckConfig: r"""Creates a new Uptime check configuration. @@ -504,7 +521,7 @@ async def sample_create_uptime_check_config(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.CreateUptimeCheckConfigRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.CreateUptimeCheckConfigRequest, dict]]): The request object. The protocol for the `CreateUptimeCheckConfig` request. parent (:class:`str`): @@ -585,11 +602,13 @@ async def sample_create_uptime_check_config(): async def update_uptime_check_config( self, - request: Union[uptime_service.UpdateUptimeCheckConfigRequest, dict] = None, + request: Optional[ + Union[uptime_service.UpdateUptimeCheckConfigRequest, dict] + ] = None, *, - uptime_check_config: uptime.UptimeCheckConfig = None, + uptime_check_config: Optional[uptime.UptimeCheckConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> uptime.UptimeCheckConfig: r"""Updates an Uptime check configuration. You can either replace @@ -624,7 +643,7 @@ async def sample_update_uptime_check_config(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.UpdateUptimeCheckConfigRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.UpdateUptimeCheckConfigRequest, dict]]): The request object. The protocol for the `UpdateUptimeCheckConfig` request. uptime_check_config (:class:`google.cloud.monitoring_v3.types.UptimeCheckConfig`): @@ -704,11 +723,13 @@ async def sample_update_uptime_check_config(): async def delete_uptime_check_config( self, - request: Union[uptime_service.DeleteUptimeCheckConfigRequest, dict] = None, + request: Optional[ + Union[uptime_service.DeleteUptimeCheckConfigRequest, dict] + ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes an Uptime check configuration. Note that this @@ -740,7 +761,7 @@ async def sample_delete_uptime_check_config(): await client.delete_uptime_check_config(request=request) Args: - request (Union[google.cloud.monitoring_v3.types.DeleteUptimeCheckConfigRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.DeleteUptimeCheckConfigRequest, dict]]): The request object. The protocol for the `DeleteUptimeCheckConfig` request. name (:class:`str`): @@ -810,10 +831,10 @@ async def sample_delete_uptime_check_config(): async def list_uptime_check_ips( self, - request: Union[uptime_service.ListUptimeCheckIpsRequest, dict] = None, + request: Optional[Union[uptime_service.ListUptimeCheckIpsRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListUptimeCheckIpsAsyncPager: r"""Returns the list of IP addresses that checkers run @@ -846,7 +867,7 @@ async def sample_list_uptime_check_ips(): print(response) Args: - request (Union[google.cloud.monitoring_v3.types.ListUptimeCheckIpsRequest, dict]): + request (Optional[Union[google.cloud.monitoring_v3.types.ListUptimeCheckIpsRequest, dict]]): The request object. The protocol for the `ListUptimeCheckIps` request. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -910,14 +931,9 @@ async def __aexit__(self, exc_type, exc, tb): await self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-monitoring", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("UptimeCheckServiceAsyncClient",) diff --git a/google/cloud/monitoring_v3/services/uptime_check_service/client.py b/google/cloud/monitoring_v3/services/uptime_check_service/client.py index 3fce2c03..9544d2a7 100644 --- a/google/cloud/monitoring_v3/services/uptime_check_service/client.py +++ b/google/cloud/monitoring_v3/services/uptime_check_service/client.py @@ -16,8 +16,20 @@ from collections import OrderedDict import os import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, + cast, +) + +from google.cloud.monitoring_v3 import gapic_version as package_version from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions @@ -60,7 +72,7 @@ class UptimeCheckServiceClientMeta(type): def get_transport_class( cls, - label: str = None, + label: Optional[str] = None, ) -> Type[UptimeCheckServiceTransport]: """Returns an appropriate transport class. @@ -341,8 +353,8 @@ def __init__( self, *, credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, UptimeCheckServiceTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, + transport: Optional[Union[str, UptimeCheckServiceTransport]] = None, + client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the uptime check service client. @@ -356,7 +368,7 @@ def __init__( transport (Union[str, UptimeCheckServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the + client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT @@ -386,6 +398,7 @@ def __init__( client_options = client_options_lib.from_dict(client_options) if client_options is None: client_options = client_options_lib.ClientOptions() + client_options = cast(client_options_lib.ClientOptions, client_options) api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( client_options @@ -438,11 +451,13 @@ def __init__( def list_uptime_check_configs( self, - request: Union[uptime_service.ListUptimeCheckConfigsRequest, dict] = None, + request: Optional[ + Union[uptime_service.ListUptimeCheckConfigsRequest, dict] + ] = None, *, - parent: str = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListUptimeCheckConfigsPager: r"""Lists the existing valid Uptime check configurations @@ -562,11 +577,13 @@ def sample_list_uptime_check_configs(): def get_uptime_check_config( self, - request: Union[uptime_service.GetUptimeCheckConfigRequest, dict] = None, + request: Optional[ + Union[uptime_service.GetUptimeCheckConfigRequest, dict] + ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> uptime.UptimeCheckConfig: r"""Gets a single Uptime check configuration. @@ -669,12 +686,14 @@ def sample_get_uptime_check_config(): def create_uptime_check_config( self, - request: Union[uptime_service.CreateUptimeCheckConfigRequest, dict] = None, + request: Optional[ + Union[uptime_service.CreateUptimeCheckConfigRequest, dict] + ] = None, *, - parent: str = None, - uptime_check_config: uptime.UptimeCheckConfig = None, + parent: Optional[str] = None, + uptime_check_config: Optional[uptime.UptimeCheckConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> uptime.UptimeCheckConfig: r"""Creates a new Uptime check configuration. @@ -789,11 +808,13 @@ def sample_create_uptime_check_config(): def update_uptime_check_config( self, - request: Union[uptime_service.UpdateUptimeCheckConfigRequest, dict] = None, + request: Optional[ + Union[uptime_service.UpdateUptimeCheckConfigRequest, dict] + ] = None, *, - uptime_check_config: uptime.UptimeCheckConfig = None, + uptime_check_config: Optional[uptime.UptimeCheckConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> uptime.UptimeCheckConfig: r"""Updates an Uptime check configuration. You can either replace @@ -910,11 +931,13 @@ def sample_update_uptime_check_config(): def delete_uptime_check_config( self, - request: Union[uptime_service.DeleteUptimeCheckConfigRequest, dict] = None, + request: Optional[ + Union[uptime_service.DeleteUptimeCheckConfigRequest, dict] + ] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes an Uptime check configuration. Note that this @@ -1009,10 +1032,10 @@ def sample_delete_uptime_check_config(): def list_uptime_check_ips( self, - request: Union[uptime_service.ListUptimeCheckIpsRequest, dict] = None, + request: Optional[Union[uptime_service.ListUptimeCheckIpsRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListUptimeCheckIpsPager: r"""Returns the list of IP addresses that checkers run @@ -1108,14 +1131,9 @@ def __exit__(self, type, value, traceback): self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-monitoring", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("UptimeCheckServiceClient",) diff --git a/google/cloud/monitoring_v3/services/uptime_check_service/transports/base.py b/google/cloud/monitoring_v3/services/uptime_check_service/transports/base.py index 38eb3e65..e9c2091d 100644 --- a/google/cloud/monitoring_v3/services/uptime_check_service/transports/base.py +++ b/google/cloud/monitoring_v3/services/uptime_check_service/transports/base.py @@ -15,7 +15,8 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources + +from google.cloud.monitoring_v3 import gapic_version as package_version import google.auth # type: ignore import google.api_core @@ -29,14 +30,9 @@ from google.cloud.monitoring_v3.types import uptime_service from google.protobuf import empty_pb2 # type: ignore -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-monitoring", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) class UptimeCheckServiceTransport(abc.ABC): @@ -54,7 +50,7 @@ def __init__( self, *, host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, diff --git a/google/cloud/monitoring_v3/services/uptime_check_service/transports/grpc.py b/google/cloud/monitoring_v3/services/uptime_check_service/transports/grpc.py index a0535467..9806261b 100644 --- a/google/cloud/monitoring_v3/services/uptime_check_service/transports/grpc.py +++ b/google/cloud/monitoring_v3/services/uptime_check_service/transports/grpc.py @@ -56,14 +56,14 @@ def __init__( self, *, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: Optional[grpc.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, @@ -190,8 +190,8 @@ def __init__( def create_channel( cls, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, **kwargs, diff --git a/google/cloud/monitoring_v3/services/uptime_check_service/transports/grpc_asyncio.py b/google/cloud/monitoring_v3/services/uptime_check_service/transports/grpc_asyncio.py index 41ffee13..cd8f3182 100644 --- a/google/cloud/monitoring_v3/services/uptime_check_service/transports/grpc_asyncio.py +++ b/google/cloud/monitoring_v3/services/uptime_check_service/transports/grpc_asyncio.py @@ -58,7 +58,7 @@ class UptimeCheckServiceGrpcAsyncIOTransport(UptimeCheckServiceTransport): def create_channel( cls, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -101,15 +101,15 @@ def __init__( self, *, host: str = "monitoring.googleapis.com", - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, + channel: Optional[aio.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, api_audience: Optional[str] = None, diff --git a/google/cloud/monitoring_v3/types/alert.py b/google/cloud/monitoring_v3/types/alert.py index ec0e04cf..531ff9a5 100644 --- a/google/cloud/monitoring_v3/types/alert.py +++ b/google/cloud/monitoring_v3/types/alert.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence + import proto # type: ignore from google.cloud.monitoring_v3.types import common @@ -67,7 +69,7 @@ class AlertPolicy(proto.Message): underlying problems detected by the alerting policy. Notification channels that have limited capacity might not show this documentation. - user_labels (Mapping[str, str]): + user_labels (MutableMapping[str, str]): User-supplied key/value data to be used for organizing and identifying the ``AlertPolicy`` objects. @@ -76,7 +78,7 @@ class AlertPolicy(proto.Message): is smaller. Labels and values can contain only lowercase letters, numerals, underscores, and dashes. Keys must begin with a letter. - conditions (Sequence[google.cloud.monitoring_v3.types.AlertPolicy.Condition]): + conditions (MutableSequence[google.cloud.monitoring_v3.types.AlertPolicy.Condition]): A list of conditions for the policy. The conditions are combined by AND or OR according to the ``combiner`` field. If the combined conditions evaluate to true, then an @@ -102,7 +104,7 @@ class AlertPolicy(proto.Message): is invalid. OK if the alert policy is valid. If not OK, the alert policy will not generate incidents. - notification_channels (Sequence[str]): + notification_channels (MutableSequence[str]): Identifies the notification channels to which notifications should be sent when incidents are opened or closed or when new violations occur on an already opened incident. Each @@ -156,11 +158,11 @@ class Documentation(proto.Message): more information. """ - content = proto.Field( + content: str = proto.Field( proto.STRING, number=1, ) - mime_type = proto.Field( + mime_type: str = proto.Field( proto.STRING, number=2, ) @@ -272,12 +274,12 @@ class Trigger(proto.Message): This field is a member of `oneof`_ ``type``. """ - count = proto.Field( + count: int = proto.Field( proto.INT32, number=1, oneof="type", ) - percent = proto.Field( + percent: float = proto.Field( proto.DOUBLE, number=2, oneof="type", @@ -302,7 +304,7 @@ class MetricThreshold(proto.Message): type and the resource type. Optionally, it can specify resource labels and metric labels. This field must not exceed 2048 Unicode characters in length. - aggregations (Sequence[google.cloud.monitoring_v3.types.Aggregation]): + aggregations (MutableSequence[google.cloud.monitoring_v3.types.Aggregation]): Specifies the alignment of data points in individual time series as well as how to combine the retrieved time series together (such as when aggregating multiple streams on each @@ -328,7 +330,7 @@ class MetricThreshold(proto.Message): contain restrictions on resource type, resource labels, and metric labels. This field may not exceed 2048 Unicode characters in length. - denominator_aggregations (Sequence[google.cloud.monitoring_v3.types.Aggregation]): + denominator_aggregations (MutableSequence[google.cloud.monitoring_v3.types.Aggregation]): Specifies the alignment of data points in individual time series selected by ``denominatorFilter`` as well as how to combine the retrieved time series together (such as when @@ -378,47 +380,51 @@ class MetricThreshold(proto.Message): data stops arriving. """ - filter = proto.Field( + filter: str = proto.Field( proto.STRING, number=2, ) - aggregations = proto.RepeatedField( + aggregations: MutableSequence[common.Aggregation] = proto.RepeatedField( proto.MESSAGE, number=8, message=common.Aggregation, ) - denominator_filter = proto.Field( + denominator_filter: str = proto.Field( proto.STRING, number=9, ) - denominator_aggregations = proto.RepeatedField( + denominator_aggregations: MutableSequence[ + common.Aggregation + ] = proto.RepeatedField( proto.MESSAGE, number=10, message=common.Aggregation, ) - comparison = proto.Field( + comparison: common.ComparisonType = proto.Field( proto.ENUM, number=4, enum=common.ComparisonType, ) - threshold_value = proto.Field( + threshold_value: float = proto.Field( proto.DOUBLE, number=5, ) - duration = proto.Field( + duration: duration_pb2.Duration = proto.Field( proto.MESSAGE, number=6, message=duration_pb2.Duration, ) - trigger = proto.Field( + trigger: "AlertPolicy.Condition.Trigger" = proto.Field( proto.MESSAGE, number=7, message="AlertPolicy.Condition.Trigger", ) - evaluation_missing_data = proto.Field( - proto.ENUM, - number=11, - enum="AlertPolicy.Condition.EvaluationMissingData", + evaluation_missing_data: "AlertPolicy.Condition.EvaluationMissingData" = ( + proto.Field( + proto.ENUM, + number=11, + enum="AlertPolicy.Condition.EvaluationMissingData", + ) ) class MetricAbsence(proto.Message): @@ -443,7 +449,7 @@ class MetricAbsence(proto.Message): type and the resource type. Optionally, it can specify resource labels and metric labels. This field must not exceed 2048 Unicode characters in length. - aggregations (Sequence[google.cloud.monitoring_v3.types.Aggregation]): + aggregations (MutableSequence[google.cloud.monitoring_v3.types.Aggregation]): Specifies the alignment of data points in individual time series as well as how to combine the retrieved time series together (such as when aggregating multiple streams on each @@ -471,21 +477,21 @@ class MetricAbsence(proto.Message): identified by ``filter`` and ``aggregations``. """ - filter = proto.Field( + filter: str = proto.Field( proto.STRING, number=1, ) - aggregations = proto.RepeatedField( + aggregations: MutableSequence[common.Aggregation] = proto.RepeatedField( proto.MESSAGE, number=5, message=common.Aggregation, ) - duration = proto.Field( + duration: duration_pb2.Duration = proto.Field( proto.MESSAGE, number=2, message=duration_pb2.Duration, ) - trigger = proto.Field( + trigger: "AlertPolicy.Condition.Trigger" = proto.Field( proto.MESSAGE, number=3, message="AlertPolicy.Condition.Trigger", @@ -502,7 +508,7 @@ class LogMatch(proto.Message): Required. A logs-based filter. See `Advanced Logs Queries `__ for how this filter should be constructed. - label_extractors (Mapping[str, str]): + label_extractors (MutableMapping[str, str]): Optional. A map from a label key to an extractor expression, which is used to extract the value for this label key. Each entry in this map is a specification for how data should be @@ -517,11 +523,11 @@ class LogMatch(proto.Message): for syntax and examples. """ - filter = proto.Field( + filter: str = proto.Field( proto.STRING, number=1, ) - label_extractors = proto.MapField( + label_extractors: MutableMapping[str, str] = proto.MapField( proto.STRING, proto.STRING, number=2, @@ -563,53 +569,55 @@ class MonitoringQueryLanguageCondition(proto.Message): data stops arriving. """ - query = proto.Field( + query: str = proto.Field( proto.STRING, number=1, ) - duration = proto.Field( + duration: duration_pb2.Duration = proto.Field( proto.MESSAGE, number=2, message=duration_pb2.Duration, ) - trigger = proto.Field( + trigger: "AlertPolicy.Condition.Trigger" = proto.Field( proto.MESSAGE, number=3, message="AlertPolicy.Condition.Trigger", ) - evaluation_missing_data = proto.Field( - proto.ENUM, - number=4, - enum="AlertPolicy.Condition.EvaluationMissingData", + evaluation_missing_data: "AlertPolicy.Condition.EvaluationMissingData" = ( + proto.Field( + proto.ENUM, + number=4, + enum="AlertPolicy.Condition.EvaluationMissingData", + ) ) - name = proto.Field( + name: str = proto.Field( proto.STRING, number=12, ) - display_name = proto.Field( + display_name: str = proto.Field( proto.STRING, number=6, ) - condition_threshold = proto.Field( + condition_threshold: "AlertPolicy.Condition.MetricThreshold" = proto.Field( proto.MESSAGE, number=1, oneof="condition", message="AlertPolicy.Condition.MetricThreshold", ) - condition_absent = proto.Field( + condition_absent: "AlertPolicy.Condition.MetricAbsence" = proto.Field( proto.MESSAGE, number=2, oneof="condition", message="AlertPolicy.Condition.MetricAbsence", ) - condition_matched_log = proto.Field( + condition_matched_log: "AlertPolicy.Condition.LogMatch" = proto.Field( proto.MESSAGE, number=20, oneof="condition", message="AlertPolicy.Condition.LogMatch", ) - condition_monitoring_query_language = proto.Field( + condition_monitoring_query_language: "AlertPolicy.Condition.MonitoringQueryLanguageCondition" = proto.Field( proto.MESSAGE, number=19, oneof="condition", @@ -641,76 +649,78 @@ class NotificationRateLimit(proto.Message): Not more than one notification per ``period``. """ - period = proto.Field( + period: duration_pb2.Duration = proto.Field( proto.MESSAGE, number=1, message=duration_pb2.Duration, ) - notification_rate_limit = proto.Field( - proto.MESSAGE, - number=1, - message="AlertPolicy.AlertStrategy.NotificationRateLimit", + notification_rate_limit: "AlertPolicy.AlertStrategy.NotificationRateLimit" = ( + proto.Field( + proto.MESSAGE, + number=1, + message="AlertPolicy.AlertStrategy.NotificationRateLimit", + ) ) - auto_close = proto.Field( + auto_close: duration_pb2.Duration = proto.Field( proto.MESSAGE, number=3, message=duration_pb2.Duration, ) - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - display_name = proto.Field( + display_name: str = proto.Field( proto.STRING, number=2, ) - documentation = proto.Field( + documentation: Documentation = proto.Field( proto.MESSAGE, number=13, message=Documentation, ) - user_labels = proto.MapField( + user_labels: MutableMapping[str, str] = proto.MapField( proto.STRING, proto.STRING, number=16, ) - conditions = proto.RepeatedField( + conditions: MutableSequence[Condition] = proto.RepeatedField( proto.MESSAGE, number=12, message=Condition, ) - combiner = proto.Field( + combiner: ConditionCombinerType = proto.Field( proto.ENUM, number=6, enum=ConditionCombinerType, ) - enabled = proto.Field( + enabled: wrappers_pb2.BoolValue = proto.Field( proto.MESSAGE, number=17, message=wrappers_pb2.BoolValue, ) - validity = proto.Field( + validity: status_pb2.Status = proto.Field( proto.MESSAGE, number=18, message=status_pb2.Status, ) - notification_channels = proto.RepeatedField( + notification_channels: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=14, ) - creation_record = proto.Field( + creation_record: gm_mutation_record.MutationRecord = proto.Field( proto.MESSAGE, number=10, message=gm_mutation_record.MutationRecord, ) - mutation_record = proto.Field( + mutation_record: gm_mutation_record.MutationRecord = proto.Field( proto.MESSAGE, number=11, message=gm_mutation_record.MutationRecord, ) - alert_strategy = proto.Field( + alert_strategy: AlertStrategy = proto.Field( proto.MESSAGE, number=21, message=AlertStrategy, diff --git a/google/cloud/monitoring_v3/types/alert_service.py b/google/cloud/monitoring_v3/types/alert_service.py index 7cb0b0a3..bc92e77e 100644 --- a/google/cloud/monitoring_v3/types/alert_service.py +++ b/google/cloud/monitoring_v3/types/alert_service.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence + import proto # type: ignore from google.cloud.monitoring_v3.types import alert @@ -59,11 +61,11 @@ class CreateAlertPolicyRequest(proto.Message): the new policy, including a new ``[ALERT_POLICY_ID]`` value. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=3, ) - alert_policy = proto.Field( + alert_policy: alert.AlertPolicy = proto.Field( proto.MESSAGE, number=2, message=alert.AlertPolicy, @@ -82,7 +84,7 @@ class GetAlertPolicyRequest(proto.Message): projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=3, ) @@ -130,23 +132,23 @@ class ListAlertPoliciesRequest(proto.Message): results from the previous method call. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=4, ) - filter = proto.Field( + filter: str = proto.Field( proto.STRING, number=5, ) - order_by = proto.Field( + order_by: str = proto.Field( proto.STRING, number=6, ) - page_size = proto.Field( + page_size: int = proto.Field( proto.INT32, number=2, ) - page_token = proto.Field( + page_token: str = proto.Field( proto.STRING, number=3, ) @@ -156,7 +158,7 @@ class ListAlertPoliciesResponse(proto.Message): r"""The protocol for the ``ListAlertPolicies`` response. Attributes: - alert_policies (Sequence[google.cloud.monitoring_v3.types.AlertPolicy]): + alert_policies (MutableSequence[google.cloud.monitoring_v3.types.AlertPolicy]): The returned alert policies. next_page_token (str): If there might be more results than were returned, then this @@ -173,16 +175,16 @@ class ListAlertPoliciesResponse(proto.Message): def raw_page(self): return self - alert_policies = proto.RepeatedField( + alert_policies: MutableSequence[alert.AlertPolicy] = proto.RepeatedField( proto.MESSAGE, number=3, message=alert.AlertPolicy, ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=2, ) - total_size = proto.Field( + total_size: int = proto.Field( proto.INT32, number=4, ) @@ -227,12 +229,12 @@ class UpdateAlertPolicyRequest(proto.Message): ``update_mask`` are ignored. """ - update_mask = proto.Field( + update_mask: field_mask_pb2.FieldMask = proto.Field( proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, ) - alert_policy = proto.Field( + alert_policy: alert.AlertPolicy = proto.Field( proto.MESSAGE, number=3, message=alert.AlertPolicy, @@ -254,7 +256,7 @@ class DeleteAlertPolicyRequest(proto.Message): [AlertPolicy][google.monitoring.v3.AlertPolicy]. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=3, ) diff --git a/google/cloud/monitoring_v3/types/common.py b/google/cloud/monitoring_v3/types/common.py index 5a021a76..7d45d3a9 100644 --- a/google/cloud/monitoring_v3/types/common.py +++ b/google/cloud/monitoring_v3/types/common.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence + import proto # type: ignore from google.api import distribution_pb2 # type: ignore @@ -93,27 +95,27 @@ class TypedValue(proto.Message): This field is a member of `oneof`_ ``value``. """ - bool_value = proto.Field( + bool_value: bool = proto.Field( proto.BOOL, number=1, oneof="value", ) - int64_value = proto.Field( + int64_value: int = proto.Field( proto.INT64, number=2, oneof="value", ) - double_value = proto.Field( + double_value: float = proto.Field( proto.DOUBLE, number=3, oneof="value", ) - string_value = proto.Field( + string_value: str = proto.Field( proto.STRING, number=4, oneof="value", ) - distribution_value = proto.Field( + distribution_value: distribution_pb2.Distribution = proto.Field( proto.MESSAGE, number=5, oneof="value", @@ -169,12 +171,12 @@ class TimeInterval(proto.Message): end time. """ - end_time = proto.Field( + end_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp, ) - start_time = proto.Field( + start_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, @@ -266,7 +268,7 @@ class Aggregation(proto.Message): then ``per_series_aligner`` must be specified, and must not be ``ALIGN_NONE``. An ``alignment_period`` must also be specified; otherwise, an error is returned. - group_by_fields (Sequence[str]): + group_by_fields (MutableSequence[str]): The set of fields to preserve when ``cross_series_reducer`` is specified. The ``group_by_fields`` determine how the time series are partitioned into subsets prior to applying the @@ -340,22 +342,22 @@ class Reducer(proto.Enum): REDUCE_PERCENTILE_50 = 11 REDUCE_PERCENTILE_05 = 12 - alignment_period = proto.Field( + alignment_period: duration_pb2.Duration = proto.Field( proto.MESSAGE, number=1, message=duration_pb2.Duration, ) - per_series_aligner = proto.Field( + per_series_aligner: Aligner = proto.Field( proto.ENUM, number=2, enum=Aligner, ) - cross_series_reducer = proto.Field( + cross_series_reducer: Reducer = proto.Field( proto.ENUM, number=4, enum=Reducer, ) - group_by_fields = proto.RepeatedField( + group_by_fields: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=5, ) diff --git a/google/cloud/monitoring_v3/types/dropped_labels.py b/google/cloud/monitoring_v3/types/dropped_labels.py index b8b6cbce..8c35da2d 100644 --- a/google/cloud/monitoring_v3/types/dropped_labels.py +++ b/google/cloud/monitoring_v3/types/dropped_labels.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence + import proto # type: ignore @@ -44,12 +46,12 @@ class DroppedLabels(proto.Message): clients to resolve any ambiguities. Attributes: - label (Mapping[str, str]): + label (MutableMapping[str, str]): Map from label to its value, for all labels dropped in any aggregation. """ - label = proto.MapField( + label: MutableMapping[str, str] = proto.MapField( proto.STRING, proto.STRING, number=1, diff --git a/google/cloud/monitoring_v3/types/group.py b/google/cloud/monitoring_v3/types/group.py index bde854f2..27136380 100644 --- a/google/cloud/monitoring_v3/types/group.py +++ b/google/cloud/monitoring_v3/types/group.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence + import proto # type: ignore @@ -87,23 +89,23 @@ class Group(proto.Message): clusters. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - display_name = proto.Field( + display_name: str = proto.Field( proto.STRING, number=2, ) - parent_name = proto.Field( + parent_name: str = proto.Field( proto.STRING, number=3, ) - filter = proto.Field( + filter: str = proto.Field( proto.STRING, number=5, ) - is_cluster = proto.Field( + is_cluster: bool = proto.Field( proto.BOOL, number=6, ) diff --git a/google/cloud/monitoring_v3/types/group_service.py b/google/cloud/monitoring_v3/types/group_service.py index bd0231c5..c7551099 100644 --- a/google/cloud/monitoring_v3/types/group_service.py +++ b/google/cloud/monitoring_v3/types/group_service.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence + import proto # type: ignore from google.api import monitored_resource_pb2 # type: ignore @@ -103,30 +105,30 @@ class ListGroupsRequest(proto.Message): additional results from the previous method call. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=7, ) - children_of_group = proto.Field( + children_of_group: str = proto.Field( proto.STRING, number=2, oneof="filter", ) - ancestors_of_group = proto.Field( + ancestors_of_group: str = proto.Field( proto.STRING, number=3, oneof="filter", ) - descendants_of_group = proto.Field( + descendants_of_group: str = proto.Field( proto.STRING, number=4, oneof="filter", ) - page_size = proto.Field( + page_size: int = proto.Field( proto.INT32, number=5, ) - page_token = proto.Field( + page_token: str = proto.Field( proto.STRING, number=6, ) @@ -136,7 +138,7 @@ class ListGroupsResponse(proto.Message): r"""The ``ListGroups`` response. Attributes: - group (Sequence[google.cloud.monitoring_v3.types.Group]): + group (MutableSequence[google.cloud.monitoring_v3.types.Group]): The groups that match the specified filters. next_page_token (str): If there are more results than have been returned, then this @@ -149,12 +151,12 @@ class ListGroupsResponse(proto.Message): def raw_page(self): return self - group = proto.RepeatedField( + group: MutableSequence[gm_group.Group] = proto.RepeatedField( proto.MESSAGE, number=1, message=gm_group.Group, ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=2, ) @@ -172,7 +174,7 @@ class GetGroupRequest(proto.Message): projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=3, ) @@ -198,16 +200,16 @@ class CreateGroupRequest(proto.Message): create the group. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=4, ) - group = proto.Field( + group: gm_group.Group = proto.Field( proto.MESSAGE, number=2, message=gm_group.Group, ) - validate_only = proto.Field( + validate_only: bool = proto.Field( proto.BOOL, number=3, ) @@ -226,12 +228,12 @@ class UpdateGroupRequest(proto.Message): update the existing group. """ - group = proto.Field( + group: gm_group.Group = proto.Field( proto.MESSAGE, number=2, message=gm_group.Group, ) - validate_only = proto.Field( + validate_only: bool = proto.Field( proto.BOOL, number=3, ) @@ -256,11 +258,11 @@ class DeleteGroupRequest(proto.Message): value is false. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=3, ) - recursive = proto.Field( + recursive: bool = proto.Field( proto.BOOL, number=4, ) @@ -305,23 +307,23 @@ class ListGroupMembersRequest(proto.Message): minute is returned. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=7, ) - page_size = proto.Field( + page_size: int = proto.Field( proto.INT32, number=3, ) - page_token = proto.Field( + page_token: str = proto.Field( proto.STRING, number=4, ) - filter = proto.Field( + filter: str = proto.Field( proto.STRING, number=5, ) - interval = proto.Field( + interval: common.TimeInterval = proto.Field( proto.MESSAGE, number=6, message=common.TimeInterval, @@ -332,7 +334,7 @@ class ListGroupMembersResponse(proto.Message): r"""The ``ListGroupMembers`` response. Attributes: - members (Sequence[google.api.monitored_resource_pb2.MonitoredResource]): + members (MutableSequence[google.api.monitored_resource_pb2.MonitoredResource]): A set of monitored resources in the group. next_page_token (str): If there are more results than have been returned, then this @@ -348,16 +350,18 @@ class ListGroupMembersResponse(proto.Message): def raw_page(self): return self - members = proto.RepeatedField( + members: MutableSequence[ + monitored_resource_pb2.MonitoredResource + ] = proto.RepeatedField( proto.MESSAGE, number=1, message=monitored_resource_pb2.MonitoredResource, ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=2, ) - total_size = proto.Field( + total_size: int = proto.Field( proto.INT32, number=3, ) diff --git a/google/cloud/monitoring_v3/types/metric.py b/google/cloud/monitoring_v3/types/metric.py index a99581b0..50690db7 100644 --- a/google/cloud/monitoring_v3/types/metric.py +++ b/google/cloud/monitoring_v3/types/metric.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence + import proto # type: ignore from google.api import label_pb2 # type: ignore @@ -55,12 +57,12 @@ class Point(proto.Message): The value of the data point. """ - interval = proto.Field( + interval: common.TimeInterval = proto.Field( proto.MESSAGE, number=1, message=common.TimeInterval, ) - value = proto.Field( + value: common.TypedValue = proto.Field( proto.MESSAGE, number=2, message=common.TypedValue, @@ -111,7 +113,7 @@ class TimeSeries(proto.Message): When creating a time series, this field is optional. If present, it must be the same as the type of the data in the ``points`` field. - points (Sequence[google.cloud.monitoring_v3.types.Point]): + points (MutableSequence[google.cloud.monitoring_v3.types.Point]): The data points of this time series. When listing time series, points are returned in reverse time order. @@ -128,37 +130,37 @@ class TimeSeries(proto.Message): of the stored metric values. """ - metric = proto.Field( + metric: metric_pb2.Metric = proto.Field( proto.MESSAGE, number=1, message=metric_pb2.Metric, ) - resource = proto.Field( + resource: monitored_resource_pb2.MonitoredResource = proto.Field( proto.MESSAGE, number=2, message=monitored_resource_pb2.MonitoredResource, ) - metadata = proto.Field( + metadata: monitored_resource_pb2.MonitoredResourceMetadata = proto.Field( proto.MESSAGE, number=7, message=monitored_resource_pb2.MonitoredResourceMetadata, ) - metric_kind = proto.Field( + metric_kind: metric_pb2.MetricDescriptor.MetricKind = proto.Field( proto.ENUM, number=3, enum=metric_pb2.MetricDescriptor.MetricKind, ) - value_type = proto.Field( + value_type: metric_pb2.MetricDescriptor.ValueType = proto.Field( proto.ENUM, number=4, enum=metric_pb2.MetricDescriptor.ValueType, ) - points = proto.RepeatedField( + points: MutableSequence["Point"] = proto.RepeatedField( proto.MESSAGE, number=5, message="Point", ) - unit = proto.Field( + unit: str = proto.Field( proto.STRING, number=8, ) @@ -168,9 +170,9 @@ class TimeSeriesDescriptor(proto.Message): r"""A descriptor for the labels and points in a time series. Attributes: - label_descriptors (Sequence[google.api.label_pb2.LabelDescriptor]): + label_descriptors (MutableSequence[google.api.label_pb2.LabelDescriptor]): Descriptors for the labels. - point_descriptors (Sequence[google.cloud.monitoring_v3.types.TimeSeriesDescriptor.ValueDescriptor]): + point_descriptors (MutableSequence[google.cloud.monitoring_v3.types.TimeSeriesDescriptor.ValueDescriptor]): Descriptors for the point data value columns. """ @@ -191,31 +193,31 @@ class ValueDescriptor(proto.Message): if ``value_type`` is INTEGER, DOUBLE, DISTRIBUTION. """ - key = proto.Field( + key: str = proto.Field( proto.STRING, number=1, ) - value_type = proto.Field( + value_type: metric_pb2.MetricDescriptor.ValueType = proto.Field( proto.ENUM, number=2, enum=metric_pb2.MetricDescriptor.ValueType, ) - metric_kind = proto.Field( + metric_kind: metric_pb2.MetricDescriptor.MetricKind = proto.Field( proto.ENUM, number=3, enum=metric_pb2.MetricDescriptor.MetricKind, ) - unit = proto.Field( + unit: str = proto.Field( proto.STRING, number=4, ) - label_descriptors = proto.RepeatedField( + label_descriptors: MutableSequence[label_pb2.LabelDescriptor] = proto.RepeatedField( proto.MESSAGE, number=1, message=label_pb2.LabelDescriptor, ) - point_descriptors = proto.RepeatedField( + point_descriptors: MutableSequence[ValueDescriptor] = proto.RepeatedField( proto.MESSAGE, number=5, message=ValueDescriptor, @@ -227,13 +229,13 @@ class TimeSeriesData(proto.Message): TimeSeriesDescriptor. Attributes: - label_values (Sequence[google.cloud.monitoring_v3.types.LabelValue]): + label_values (MutableSequence[google.cloud.monitoring_v3.types.LabelValue]): The values of the labels in the time series identifier, given in the same order as the ``label_descriptors`` field of the TimeSeriesDescriptor associated with this object. Each value must have a value of the type given in the corresponding entry of ``label_descriptors``. - point_data (Sequence[google.cloud.monitoring_v3.types.TimeSeriesData.PointData]): + point_data (MutableSequence[google.cloud.monitoring_v3.types.TimeSeriesData.PointData]): The points in the time series. """ @@ -244,29 +246,29 @@ class PointData(proto.Message): with this object. Attributes: - values (Sequence[google.cloud.monitoring_v3.types.TypedValue]): + values (MutableSequence[google.cloud.monitoring_v3.types.TypedValue]): The values that make up the point. time_interval (google.cloud.monitoring_v3.types.TimeInterval): The time interval associated with the point. """ - values = proto.RepeatedField( + values: MutableSequence[common.TypedValue] = proto.RepeatedField( proto.MESSAGE, number=1, message=common.TypedValue, ) - time_interval = proto.Field( + time_interval: common.TimeInterval = proto.Field( proto.MESSAGE, number=2, message=common.TimeInterval, ) - label_values = proto.RepeatedField( + label_values: MutableSequence["LabelValue"] = proto.RepeatedField( proto.MESSAGE, number=1, message="LabelValue", ) - point_data = proto.RepeatedField( + point_data: MutableSequence[PointData] = proto.RepeatedField( proto.MESSAGE, number=2, message=PointData, @@ -298,17 +300,17 @@ class LabelValue(proto.Message): This field is a member of `oneof`_ ``value``. """ - bool_value = proto.Field( + bool_value: bool = proto.Field( proto.BOOL, number=1, oneof="value", ) - int64_value = proto.Field( + int64_value: int = proto.Field( proto.INT64, number=2, oneof="value", ) - string_value = proto.Field( + string_value: str = proto.Field( proto.STRING, number=3, oneof="value", @@ -327,12 +329,12 @@ class QueryError(proto.Message): The error message. """ - locator = proto.Field( + locator: "TextLocator" = proto.Field( proto.MESSAGE, number=1, message="TextLocator", ) - message = proto.Field( + message: str = proto.Field( proto.STRING, number=2, ) @@ -398,35 +400,35 @@ class Position(proto.Message): index even though the text is UTF-8. """ - line = proto.Field( + line: int = proto.Field( proto.INT32, number=1, ) - column = proto.Field( + column: int = proto.Field( proto.INT32, number=2, ) - source = proto.Field( + source: str = proto.Field( proto.STRING, number=1, ) - start_position = proto.Field( + start_position: Position = proto.Field( proto.MESSAGE, number=2, message=Position, ) - end_position = proto.Field( + end_position: Position = proto.Field( proto.MESSAGE, number=3, message=Position, ) - nested_locator = proto.Field( + nested_locator: "TextLocator" = proto.Field( proto.MESSAGE, number=4, message="TextLocator", ) - nesting_reason = proto.Field( + nesting_reason: str = proto.Field( proto.STRING, number=5, ) diff --git a/google/cloud/monitoring_v3/types/metric_service.py b/google/cloud/monitoring_v3/types/metric_service.py index 6c642bfd..ba934d72 100644 --- a/google/cloud/monitoring_v3/types/metric_service.py +++ b/google/cloud/monitoring_v3/types/metric_service.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence + import proto # type: ignore from google.api import metric_pb2 # type: ignore @@ -78,19 +80,19 @@ class ListMonitoredResourceDescriptorsRequest(proto.Message): additional results from the previous method call. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=5, ) - filter = proto.Field( + filter: str = proto.Field( proto.STRING, number=2, ) - page_size = proto.Field( + page_size: int = proto.Field( proto.INT32, number=3, ) - page_token = proto.Field( + page_token: str = proto.Field( proto.STRING, number=4, ) @@ -100,7 +102,7 @@ class ListMonitoredResourceDescriptorsResponse(proto.Message): r"""The ``ListMonitoredResourceDescriptors`` response. Attributes: - resource_descriptors (Sequence[google.api.monitored_resource_pb2.MonitoredResourceDescriptor]): + resource_descriptors (MutableSequence[google.api.monitored_resource_pb2.MonitoredResourceDescriptor]): The monitored resource descriptors that are available to this project and that match ``filter``, if present. next_page_token (str): @@ -114,12 +116,14 @@ class ListMonitoredResourceDescriptorsResponse(proto.Message): def raw_page(self): return self - resource_descriptors = proto.RepeatedField( + resource_descriptors: MutableSequence[ + monitored_resource_pb2.MonitoredResourceDescriptor + ] = proto.RepeatedField( proto.MESSAGE, number=1, message=monitored_resource_pb2.MonitoredResourceDescriptor, ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=2, ) @@ -141,7 +145,7 @@ class GetMonitoredResourceDescriptorRequest(proto.Message): ``cloudsql_database``. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=3, ) @@ -180,19 +184,19 @@ class ListMetricDescriptorsRequest(proto.Message): additional results from the previous method call. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=5, ) - filter = proto.Field( + filter: str = proto.Field( proto.STRING, number=2, ) - page_size = proto.Field( + page_size: int = proto.Field( proto.INT32, number=3, ) - page_token = proto.Field( + page_token: str = proto.Field( proto.STRING, number=4, ) @@ -202,7 +206,7 @@ class ListMetricDescriptorsResponse(proto.Message): r"""The ``ListMetricDescriptors`` response. Attributes: - metric_descriptors (Sequence[google.api.metric_pb2.MetricDescriptor]): + metric_descriptors (MutableSequence[google.api.metric_pb2.MetricDescriptor]): The metric descriptors that are available to the project and that match the value of ``filter``, if present. next_page_token (str): @@ -216,12 +220,14 @@ class ListMetricDescriptorsResponse(proto.Message): def raw_page(self): return self - metric_descriptors = proto.RepeatedField( + metric_descriptors: MutableSequence[ + metric_pb2.MetricDescriptor + ] = proto.RepeatedField( proto.MESSAGE, number=1, message=metric_pb2.MetricDescriptor, ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=2, ) @@ -243,7 +249,7 @@ class GetMetricDescriptorRequest(proto.Message): ``"compute.googleapis.com/instance/disk/read_bytes_count"``. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=3, ) @@ -264,11 +270,11 @@ class CreateMetricDescriptorRequest(proto.Message): descriptor. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=3, ) - metric_descriptor = proto.Field( + metric_descriptor: metric_pb2.MetricDescriptor = proto.Field( proto.MESSAGE, number=2, message=metric_pb2.MetricDescriptor, @@ -291,7 +297,7 @@ class DeleteMetricDescriptorRequest(proto.Message): ``"custom.googleapis.com/my_test_metric"``. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=3, ) @@ -365,43 +371,43 @@ class TimeSeriesView(proto.Enum): FULL = 0 HEADERS = 1 - name = proto.Field( + name: str = proto.Field( proto.STRING, number=10, ) - filter = proto.Field( + filter: str = proto.Field( proto.STRING, number=2, ) - interval = proto.Field( + interval: common.TimeInterval = proto.Field( proto.MESSAGE, number=4, message=common.TimeInterval, ) - aggregation = proto.Field( + aggregation: common.Aggregation = proto.Field( proto.MESSAGE, number=5, message=common.Aggregation, ) - secondary_aggregation = proto.Field( + secondary_aggregation: common.Aggregation = proto.Field( proto.MESSAGE, number=11, message=common.Aggregation, ) - order_by = proto.Field( + order_by: str = proto.Field( proto.STRING, number=6, ) - view = proto.Field( + view: TimeSeriesView = proto.Field( proto.ENUM, number=7, enum=TimeSeriesView, ) - page_size = proto.Field( + page_size: int = proto.Field( proto.INT32, number=8, ) - page_token = proto.Field( + page_token: str = proto.Field( proto.STRING, number=9, ) @@ -411,7 +417,7 @@ class ListTimeSeriesResponse(proto.Message): r"""The ``ListTimeSeries`` response. Attributes: - time_series (Sequence[google.cloud.monitoring_v3.types.TimeSeries]): + time_series (MutableSequence[google.cloud.monitoring_v3.types.TimeSeries]): One or more time series that match the filter included in the request. next_page_token (str): @@ -419,7 +425,7 @@ class ListTimeSeriesResponse(proto.Message): field is set to a non-empty value. To see the additional results, use that value as ``page_token`` in the next call to this method. - execution_errors (Sequence[google.rpc.status_pb2.Status]): + execution_errors (MutableSequence[google.rpc.status_pb2.Status]): Query execution errors that may have caused the time series data returned to be incomplete. unit (str): @@ -435,21 +441,21 @@ class ListTimeSeriesResponse(proto.Message): def raw_page(self): return self - time_series = proto.RepeatedField( + time_series: MutableSequence[gm_metric.TimeSeries] = proto.RepeatedField( proto.MESSAGE, number=1, message=gm_metric.TimeSeries, ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=2, ) - execution_errors = proto.RepeatedField( + execution_errors: MutableSequence[status_pb2.Status] = proto.RepeatedField( proto.MESSAGE, number=3, message=status_pb2.Status, ) - unit = proto.Field( + unit: str = proto.Field( proto.STRING, number=5, ) @@ -467,7 +473,7 @@ class CreateTimeSeriesRequest(proto.Message): :: projects/[PROJECT_ID_OR_NUMBER] - time_series (Sequence[google.cloud.monitoring_v3.types.TimeSeries]): + time_series (MutableSequence[google.cloud.monitoring_v3.types.TimeSeries]): Required. The new data to be added to a list of time series. Adds at most one data point to each of several time series. The new data point must be more recent than any other point @@ -479,11 +485,11 @@ class CreateTimeSeriesRequest(proto.Message): request is 200. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=3, ) - time_series = proto.RepeatedField( + time_series: MutableSequence[gm_metric.TimeSeries] = proto.RepeatedField( proto.MESSAGE, number=2, message=gm_metric.TimeSeries, @@ -502,12 +508,12 @@ class CreateTimeSeriesError(proto.Message): ``time_series``. """ - time_series = proto.Field( + time_series: gm_metric.TimeSeries = proto.Field( proto.MESSAGE, number=1, message=gm_metric.TimeSeries, ) - status = proto.Field( + status: status_pb2.Status = proto.Field( proto.MESSAGE, number=2, message=status_pb2.Status, @@ -524,7 +530,7 @@ class CreateTimeSeriesSummary(proto.Message): success_point_count (int): The number of points that were successfully written. - errors (Sequence[google.cloud.monitoring_v3.types.CreateTimeSeriesSummary.Error]): + errors (MutableSequence[google.cloud.monitoring_v3.types.CreateTimeSeriesSummary.Error]): The number of points that failed to be written. Order is not guaranteed. """ @@ -540,25 +546,25 @@ class Error(proto.Message): ``status``. """ - status = proto.Field( + status: status_pb2.Status = proto.Field( proto.MESSAGE, number=1, message=status_pb2.Status, ) - point_count = proto.Field( + point_count: int = proto.Field( proto.INT32, number=2, ) - total_point_count = proto.Field( + total_point_count: int = proto.Field( proto.INT32, number=1, ) - success_point_count = proto.Field( + success_point_count: int = proto.Field( proto.INT32, number=2, ) - errors = proto.RepeatedField( + errors: MutableSequence[Error] = proto.RepeatedField( proto.MESSAGE, number=3, message=Error, @@ -591,19 +597,19 @@ class QueryTimeSeriesRequest(proto.Message): additional results from the previous method call. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - query = proto.Field( + query: str = proto.Field( proto.STRING, number=7, ) - page_size = proto.Field( + page_size: int = proto.Field( proto.INT32, number=9, ) - page_token = proto.Field( + page_token: str = proto.Field( proto.STRING, number=10, ) @@ -615,14 +621,14 @@ class QueryTimeSeriesResponse(proto.Message): Attributes: time_series_descriptor (google.cloud.monitoring_v3.types.TimeSeriesDescriptor): The descriptor for the time series data. - time_series_data (Sequence[google.cloud.monitoring_v3.types.TimeSeriesData]): + time_series_data (MutableSequence[google.cloud.monitoring_v3.types.TimeSeriesData]): The time series data. next_page_token (str): If there are more results than have been returned, then this field is set to a non-empty value. To see the additional results, use that value as ``page_token`` in the next call to this method. - partial_errors (Sequence[google.rpc.status_pb2.Status]): + partial_errors (MutableSequence[google.rpc.status_pb2.Status]): Query execution errors that may have caused the time series data returned to be incomplete. The available data will be available in the @@ -633,21 +639,21 @@ class QueryTimeSeriesResponse(proto.Message): def raw_page(self): return self - time_series_descriptor = proto.Field( + time_series_descriptor: gm_metric.TimeSeriesDescriptor = proto.Field( proto.MESSAGE, number=8, message=gm_metric.TimeSeriesDescriptor, ) - time_series_data = proto.RepeatedField( + time_series_data: MutableSequence[gm_metric.TimeSeriesData] = proto.RepeatedField( proto.MESSAGE, number=9, message=gm_metric.TimeSeriesData, ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=10, ) - partial_errors = proto.RepeatedField( + partial_errors: MutableSequence[status_pb2.Status] = proto.RepeatedField( proto.MESSAGE, number=11, message=status_pb2.Status, @@ -659,7 +665,7 @@ class QueryErrorList(proto.Message): errors. Attributes: - errors (Sequence[google.cloud.monitoring_v3.types.QueryError]): + errors (MutableSequence[google.cloud.monitoring_v3.types.QueryError]): Errors in parsing the time series query language text. The number of errors in the response may be limited. @@ -667,12 +673,12 @@ class QueryErrorList(proto.Message): A summary of all the errors. """ - errors = proto.RepeatedField( + errors: MutableSequence[gm_metric.QueryError] = proto.RepeatedField( proto.MESSAGE, number=1, message=gm_metric.QueryError, ) - error_summary = proto.Field( + error_summary: str = proto.Field( proto.STRING, number=2, ) diff --git a/google/cloud/monitoring_v3/types/mutation_record.py b/google/cloud/monitoring_v3/types/mutation_record.py index 3fc2842c..1a56ac68 100644 --- a/google/cloud/monitoring_v3/types/mutation_record.py +++ b/google/cloud/monitoring_v3/types/mutation_record.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence + import proto # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -37,12 +39,12 @@ class MutationRecord(proto.Message): change. """ - mutate_time = proto.Field( + mutate_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, ) - mutated_by = proto.Field( + mutated_by: str = proto.Field( proto.STRING, number=2, ) diff --git a/google/cloud/monitoring_v3/types/notification.py b/google/cloud/monitoring_v3/types/notification.py index 184cb6a8..c845dd8c 100644 --- a/google/cloud/monitoring_v3/types/notification.py +++ b/google/cloud/monitoring_v3/types/notification.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence + import proto # type: ignore from google.api import label_pb2 # type: ignore @@ -61,13 +63,13 @@ class NotificationChannelDescriptor(proto.Message): notification channel type. The description may include a description of the properties of the channel and pointers to external documentation. - labels (Sequence[google.api.label_pb2.LabelDescriptor]): + labels (MutableSequence[google.api.label_pb2.LabelDescriptor]): The set of labels that must be defined to identify a particular channel of the corresponding type. Each label includes a description for how that field should be populated. - supported_tiers (Sequence[google.cloud.monitoring_v3.types.ServiceTier]): + supported_tiers (MutableSequence[google.cloud.monitoring_v3.types.ServiceTier]): The tiers that support this notification channel; the project service tier must be one of the supported_tiers. launch_stage (google.api.launch_stage_pb2.LaunchStage): @@ -75,33 +77,33 @@ class NotificationChannelDescriptor(proto.Message): type. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=6, ) - type_ = proto.Field( + type_: str = proto.Field( proto.STRING, number=1, ) - display_name = proto.Field( + display_name: str = proto.Field( proto.STRING, number=2, ) - description = proto.Field( + description: str = proto.Field( proto.STRING, number=3, ) - labels = proto.RepeatedField( + labels: MutableSequence[label_pb2.LabelDescriptor] = proto.RepeatedField( proto.MESSAGE, number=4, message=label_pb2.LabelDescriptor, ) - supported_tiers = proto.RepeatedField( + supported_tiers: MutableSequence[common.ServiceTier] = proto.RepeatedField( proto.ENUM, number=5, enum=common.ServiceTier, ) - launch_stage = proto.Field( + launch_stage: launch_stage_pb2.LaunchStage = proto.Field( proto.ENUM, number=7, enum=launch_stage_pb2.LaunchStage, @@ -144,14 +146,14 @@ class NotificationChannel(proto.Message): provide additional details, beyond the display name, for the channel. This may not exceed 1024 Unicode characters. - labels (Mapping[str, str]): + labels (MutableMapping[str, str]): Configuration fields that define the channel and its behavior. The permissible and required labels are specified in the [NotificationChannelDescriptor.labels][google.monitoring.v3.NotificationChannelDescriptor.labels] of the ``NotificationChannelDescriptor`` corresponding to the ``type`` field. - user_labels (Mapping[str, str]): + user_labels (MutableMapping[str, str]): User-supplied key/value data that does not need to conform to the corresponding ``NotificationChannelDescriptor``'s schema, unlike the ``labels`` field. This field is intended @@ -199,7 +201,7 @@ class NotificationChannel(proto.Message): future. creation_record (google.cloud.monitoring_v3.types.MutationRecord): Record of the creation of this channel. - mutation_records (Sequence[google.cloud.monitoring_v3.types.MutationRecord]): + mutation_records (MutableSequence[google.cloud.monitoring_v3.types.MutationRecord]): Records of the modification of this channel. """ @@ -215,48 +217,50 @@ class VerificationStatus(proto.Enum): UNVERIFIED = 1 VERIFIED = 2 - type_ = proto.Field( + type_: str = proto.Field( proto.STRING, number=1, ) - name = proto.Field( + name: str = proto.Field( proto.STRING, number=6, ) - display_name = proto.Field( + display_name: str = proto.Field( proto.STRING, number=3, ) - description = proto.Field( + description: str = proto.Field( proto.STRING, number=4, ) - labels = proto.MapField( + labels: MutableMapping[str, str] = proto.MapField( proto.STRING, proto.STRING, number=5, ) - user_labels = proto.MapField( + user_labels: MutableMapping[str, str] = proto.MapField( proto.STRING, proto.STRING, number=8, ) - verification_status = proto.Field( + verification_status: VerificationStatus = proto.Field( proto.ENUM, number=9, enum=VerificationStatus, ) - enabled = proto.Field( + enabled: wrappers_pb2.BoolValue = proto.Field( proto.MESSAGE, number=11, message=wrappers_pb2.BoolValue, ) - creation_record = proto.Field( + creation_record: mutation_record.MutationRecord = proto.Field( proto.MESSAGE, number=12, message=mutation_record.MutationRecord, ) - mutation_records = proto.RepeatedField( + mutation_records: MutableSequence[ + mutation_record.MutationRecord + ] = proto.RepeatedField( proto.MESSAGE, number=13, message=mutation_record.MutationRecord, diff --git a/google/cloud/monitoring_v3/types/notification_service.py b/google/cloud/monitoring_v3/types/notification_service.py index b05c3767..29cc64a1 100644 --- a/google/cloud/monitoring_v3/types/notification_service.py +++ b/google/cloud/monitoring_v3/types/notification_service.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence + import proto # type: ignore from google.cloud.monitoring_v3.types import notification @@ -70,15 +72,15 @@ class ListNotificationChannelDescriptorsRequest(proto.Message): the next set of results. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=4, ) - page_size = proto.Field( + page_size: int = proto.Field( proto.INT32, number=2, ) - page_token = proto.Field( + page_token: str = proto.Field( proto.STRING, number=3, ) @@ -88,7 +90,7 @@ class ListNotificationChannelDescriptorsResponse(proto.Message): r"""The ``ListNotificationChannelDescriptors`` response. Attributes: - channel_descriptors (Sequence[google.cloud.monitoring_v3.types.NotificationChannelDescriptor]): + channel_descriptors (MutableSequence[google.cloud.monitoring_v3.types.NotificationChannelDescriptor]): The monitored resource descriptors supported for the specified project, optionally filtered. next_page_token (str): @@ -102,12 +104,14 @@ class ListNotificationChannelDescriptorsResponse(proto.Message): def raw_page(self): return self - channel_descriptors = proto.RepeatedField( + channel_descriptors: MutableSequence[ + notification.NotificationChannelDescriptor + ] = proto.RepeatedField( proto.MESSAGE, number=1, message=notification.NotificationChannelDescriptor, ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=2, ) @@ -126,7 +130,7 @@ class GetNotificationChannelDescriptorRequest(proto.Message): projects/[PROJECT_ID_OR_NUMBER]/notificationChannelDescriptors/[CHANNEL_TYPE] """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=3, ) @@ -156,11 +160,11 @@ class CreateNotificationChannelRequest(proto.Message): create. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=3, ) - notification_channel = proto.Field( + notification_channel: notification.NotificationChannel = proto.Field( proto.MESSAGE, number=2, message=notification.NotificationChannel, @@ -210,23 +214,23 @@ class ListNotificationChannelsRequest(proto.Message): the next set of results. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=5, ) - filter = proto.Field( + filter: str = proto.Field( proto.STRING, number=6, ) - order_by = proto.Field( + order_by: str = proto.Field( proto.STRING, number=7, ) - page_size = proto.Field( + page_size: int = proto.Field( proto.INT32, number=3, ) - page_token = proto.Field( + page_token: str = proto.Field( proto.STRING, number=4, ) @@ -236,7 +240,7 @@ class ListNotificationChannelsResponse(proto.Message): r"""The ``ListNotificationChannels`` response. Attributes: - notification_channels (Sequence[google.cloud.monitoring_v3.types.NotificationChannel]): + notification_channels (MutableSequence[google.cloud.monitoring_v3.types.NotificationChannel]): The notification channels defined for the specified project. next_page_token (str): @@ -255,16 +259,18 @@ class ListNotificationChannelsResponse(proto.Message): def raw_page(self): return self - notification_channels = proto.RepeatedField( + notification_channels: MutableSequence[ + notification.NotificationChannel + ] = proto.RepeatedField( proto.MESSAGE, number=3, message=notification.NotificationChannel, ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=2, ) - total_size = proto.Field( + total_size: int = proto.Field( proto.INT32, number=4, ) @@ -283,7 +289,7 @@ class GetNotificationChannelRequest(proto.Message): projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID] """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=3, ) @@ -302,12 +308,12 @@ class UpdateNotificationChannelRequest(proto.Message): fields should also be included in the ``update_mask``. """ - update_mask = proto.Field( + update_mask: field_mask_pb2.FieldMask = proto.Field( proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, ) - notification_channel = proto.Field( + notification_channel: notification.NotificationChannel = proto.Field( proto.MESSAGE, number=3, message=notification.NotificationChannel, @@ -334,11 +340,11 @@ class DeleteNotificationChannelRequest(proto.Message): fail to be deleted in a delete operation. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=3, ) - force = proto.Field( + force: bool = proto.Field( proto.BOOL, number=5, ) @@ -353,7 +359,7 @@ class SendNotificationChannelVerificationCodeRequest(proto.Message): to send a verification code. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -386,11 +392,11 @@ class GetNotificationChannelVerificationCodeRequest(proto.Message): that is permitted). """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - expire_time = proto.Field( + expire_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp, @@ -416,11 +422,11 @@ class GetNotificationChannelVerificationCodeResponse(proto.Message): permitted expiration. """ - code = proto.Field( + code: str = proto.Field( proto.STRING, number=1, ) - expire_time = proto.Field( + expire_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp, @@ -445,11 +451,11 @@ class VerifyNotificationChannelRequest(proto.Message): structure or format of the code). """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - code = proto.Field( + code: str = proto.Field( proto.STRING, number=2, ) diff --git a/google/cloud/monitoring_v3/types/service.py b/google/cloud/monitoring_v3/types/service.py index f0f10b36..07a0be7c 100644 --- a/google/cloud/monitoring_v3/types/service.py +++ b/google/cloud/monitoring_v3/types/service.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence + import proto # type: ignore from google.protobuf import duration_pb2 # type: ignore @@ -90,7 +92,7 @@ class Service(proto.Message): telemetry (google.cloud.monitoring_v3.types.Service.Telemetry): Configuration for how to query telemetry on a Service. - user_labels (Mapping[str, str]): + user_labels (MutableMapping[str, str]): Labels which have been used to annotate the service. Label keys must start with a letter. Label keys and values may contain lowercase @@ -121,7 +123,7 @@ class AppEngine(proto.Message): https://cloud.google.com/monitoring/api/resources#tag_gae_app """ - module_id = proto.Field( + module_id: str = proto.Field( proto.STRING, number=1, ) @@ -138,7 +140,7 @@ class CloudEndpoints(proto.Message): https://cloud.google.com/monitoring/api/resources#tag_api """ - service = proto.Field( + service: str = proto.Field( proto.STRING, number=1, ) @@ -167,19 +169,19 @@ class ClusterIstio(proto.Message): in Istio metrics. """ - location = proto.Field( + location: str = proto.Field( proto.STRING, number=1, ) - cluster_name = proto.Field( + cluster_name: str = proto.Field( proto.STRING, number=2, ) - service_namespace = proto.Field( + service_namespace: str = proto.Field( proto.STRING, number=3, ) - service_name = proto.Field( + service_name: str = proto.Field( proto.STRING, number=4, ) @@ -204,15 +206,15 @@ class MeshIstio(proto.Message): in Istio metrics. """ - mesh_uid = proto.Field( + mesh_uid: str = proto.Field( proto.STRING, number=1, ) - service_namespace = proto.Field( + service_namespace: str = proto.Field( proto.STRING, number=3, ) - service_name = proto.Field( + service_name: str = proto.Field( proto.STRING, number=4, ) @@ -241,15 +243,15 @@ class IstioCanonicalService(proto.Message): metrics `__. """ - mesh_uid = proto.Field( + mesh_uid: str = proto.Field( proto.STRING, number=1, ) - canonical_service_namespace = proto.Field( + canonical_service_namespace: str = proto.Field( proto.STRING, number=3, ) - canonical_service = proto.Field( + canonical_service: str = proto.Field( proto.STRING, number=4, ) @@ -264,61 +266,61 @@ class Telemetry(proto.Message): https://cloud.google.com/apis/design/resource_names. """ - resource_name = proto.Field( + resource_name: str = proto.Field( proto.STRING, number=1, ) - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - display_name = proto.Field( + display_name: str = proto.Field( proto.STRING, number=2, ) - custom = proto.Field( + custom: Custom = proto.Field( proto.MESSAGE, number=6, oneof="identifier", message=Custom, ) - app_engine = proto.Field( + app_engine: AppEngine = proto.Field( proto.MESSAGE, number=7, oneof="identifier", message=AppEngine, ) - cloud_endpoints = proto.Field( + cloud_endpoints: CloudEndpoints = proto.Field( proto.MESSAGE, number=8, oneof="identifier", message=CloudEndpoints, ) - cluster_istio = proto.Field( + cluster_istio: ClusterIstio = proto.Field( proto.MESSAGE, number=9, oneof="identifier", message=ClusterIstio, ) - mesh_istio = proto.Field( + mesh_istio: MeshIstio = proto.Field( proto.MESSAGE, number=10, oneof="identifier", message=MeshIstio, ) - istio_canonical_service = proto.Field( + istio_canonical_service: IstioCanonicalService = proto.Field( proto.MESSAGE, number=11, oneof="identifier", message=IstioCanonicalService, ) - telemetry = proto.Field( + telemetry: Telemetry = proto.Field( proto.MESSAGE, number=13, message=Telemetry, ) - user_labels = proto.MapField( + user_labels: MutableMapping[str, str] = proto.MapField( proto.STRING, proto.STRING, number=14, @@ -371,7 +373,7 @@ class ServiceLevelObjective(proto.Message): ``WEEK``, ``FORTNIGHT``, and ``MONTH`` are supported. This field is a member of `oneof`_ ``period``. - user_labels (Mapping[str, str]): + user_labels (MutableMapping[str, str]): Labels which have been used to annotate the service-level objective. Label keys must start with a letter. Label keys and values may contain @@ -394,36 +396,36 @@ class View(proto.Enum): FULL = 2 EXPLICIT = 1 - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - display_name = proto.Field( + display_name: str = proto.Field( proto.STRING, number=11, ) - service_level_indicator = proto.Field( + service_level_indicator: "ServiceLevelIndicator" = proto.Field( proto.MESSAGE, number=3, message="ServiceLevelIndicator", ) - goal = proto.Field( + goal: float = proto.Field( proto.DOUBLE, number=4, ) - rolling_period = proto.Field( + rolling_period: duration_pb2.Duration = proto.Field( proto.MESSAGE, number=5, oneof="period", message=duration_pb2.Duration, ) - calendar_period = proto.Field( + calendar_period: calendar_period_pb2.CalendarPeriod = proto.Field( proto.ENUM, number=6, oneof="period", enum=calendar_period_pb2.CalendarPeriod, ) - user_labels = proto.MapField( + user_labels: MutableMapping[str, str] = proto.MapField( proto.STRING, proto.STRING, number=12, @@ -469,19 +471,19 @@ class ServiceLevelIndicator(proto.Message): This field is a member of `oneof`_ ``type``. """ - basic_sli = proto.Field( + basic_sli: "BasicSli" = proto.Field( proto.MESSAGE, number=4, oneof="type", message="BasicSli", ) - request_based = proto.Field( + request_based: "RequestBasedSli" = proto.Field( proto.MESSAGE, number=1, oneof="type", message="RequestBasedSli", ) - windows_based = proto.Field( + windows_based: "WindowsBasedSli" = proto.Field( proto.MESSAGE, number=2, oneof="type", @@ -505,7 +507,7 @@ class BasicSli(proto.Message): .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields Attributes: - method (Sequence[str]): + method (MutableSequence[str]): OPTIONAL: The set of RPCs to which this SLI is relevant. Telemetry from other methods will not be used to calculate performance for this @@ -513,7 +515,7 @@ class BasicSli(proto.Message): Service's methods. For service types that don't support breaking down by method, setting this field will result in an error. - location (Sequence[str]): + location (MutableSequence[str]): OPTIONAL: The set of locations to which this SLI is relevant. Telemetry from other locations will not be used to calculate performance for @@ -522,7 +524,7 @@ class BasicSli(proto.Message): service types that don't support breaking down by location, setting this field will result in an error. - version (Sequence[str]): + version (MutableSequence[str]): OPTIONAL: The set of API versions to which this SLI is relevant. Telemetry from other API versions will not be used to calculate @@ -556,31 +558,31 @@ class LatencyCriteria(proto.Message): this service that return in no more than ``threshold``. """ - threshold = proto.Field( + threshold: duration_pb2.Duration = proto.Field( proto.MESSAGE, number=3, message=duration_pb2.Duration, ) - method = proto.RepeatedField( + method: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=7, ) - location = proto.RepeatedField( + location: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=8, ) - version = proto.RepeatedField( + version: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=9, ) - availability = proto.Field( + availability: AvailabilityCriteria = proto.Field( proto.MESSAGE, number=2, oneof="sli_criteria", message=AvailabilityCriteria, ) - latency = proto.Field( + latency: LatencyCriteria = proto.Field( proto.MESSAGE, number=3, oneof="sli_criteria", @@ -598,11 +600,11 @@ class Range(proto.Message): Range maximum. """ - min_ = proto.Field( + min_: float = proto.Field( proto.DOUBLE, number=1, ) - max_ = proto.Field( + max_: float = proto.Field( proto.DOUBLE, number=2, ) @@ -635,13 +637,13 @@ class RequestBasedSli(proto.Message): This field is a member of `oneof`_ ``method``. """ - good_total_ratio = proto.Field( + good_total_ratio: "TimeSeriesRatio" = proto.Field( proto.MESSAGE, number=1, oneof="method", message="TimeSeriesRatio", ) - distribution_cut = proto.Field( + distribution_cut: "DistributionCut" = proto.Field( proto.MESSAGE, number=3, oneof="method", @@ -683,15 +685,15 @@ class TimeSeriesRatio(proto.Message): or ``MetricKind = CUMULATIVE``. """ - good_service_filter = proto.Field( + good_service_filter: str = proto.Field( proto.STRING, number=4, ) - bad_service_filter = proto.Field( + bad_service_filter: str = proto.Field( proto.STRING, number=5, ) - total_service_filter = proto.Field( + total_service_filter: str = proto.Field( proto.STRING, number=6, ) @@ -718,11 +720,11 @@ class DistributionCut(proto.Message): value. """ - distribution_filter = proto.Field( + distribution_filter: str = proto.Field( proto.STRING, number=4, ) - range_ = proto.Field( + range_: "Range" = proto.Field( proto.MESSAGE, number=5, message="Range", @@ -794,19 +796,19 @@ class PerformanceThreshold(proto.Message): counted as good. """ - performance = proto.Field( + performance: "RequestBasedSli" = proto.Field( proto.MESSAGE, number=1, oneof="type", message="RequestBasedSli", ) - basic_sli_performance = proto.Field( + basic_sli_performance: "BasicSli" = proto.Field( proto.MESSAGE, number=3, oneof="type", message="BasicSli", ) - threshold = proto.Field( + threshold: float = proto.Field( proto.DOUBLE, number=2, ) @@ -830,40 +832,40 @@ class MetricRange(proto.Message): value. """ - time_series = proto.Field( + time_series: str = proto.Field( proto.STRING, number=1, ) - range_ = proto.Field( + range_: "Range" = proto.Field( proto.MESSAGE, number=4, message="Range", ) - good_bad_metric_filter = proto.Field( + good_bad_metric_filter: str = proto.Field( proto.STRING, number=5, oneof="window_criterion", ) - good_total_ratio_threshold = proto.Field( + good_total_ratio_threshold: PerformanceThreshold = proto.Field( proto.MESSAGE, number=2, oneof="window_criterion", message=PerformanceThreshold, ) - metric_mean_in_range = proto.Field( + metric_mean_in_range: MetricRange = proto.Field( proto.MESSAGE, number=6, oneof="window_criterion", message=MetricRange, ) - metric_sum_in_range = proto.Field( + metric_sum_in_range: MetricRange = proto.Field( proto.MESSAGE, number=7, oneof="window_criterion", message=MetricRange, ) - window_period = proto.Field( + window_period: duration_pb2.Duration = proto.Field( proto.MESSAGE, number=4, message=duration_pb2.Duration, diff --git a/google/cloud/monitoring_v3/types/service_service.py b/google/cloud/monitoring_v3/types/service_service.py index 01a26ba5..b86a0cfe 100644 --- a/google/cloud/monitoring_v3/types/service_service.py +++ b/google/cloud/monitoring_v3/types/service_service.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence + import proto # type: ignore from google.cloud.monitoring_v3.types import service as gm_service @@ -58,15 +60,15 @@ class CreateServiceRequest(proto.Message): Required. The ``Service`` to create. """ - parent = proto.Field( + parent: str = proto.Field( proto.STRING, number=1, ) - service_id = proto.Field( + service_id: str = proto.Field( proto.STRING, number=3, ) - service = proto.Field( + service: gm_service.Service = proto.Field( proto.MESSAGE, number=2, message=gm_service.Service, @@ -85,7 +87,7 @@ class GetServiceRequest(proto.Message): projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -140,19 +142,19 @@ class ListServicesRequest(proto.Message): additional results from the previous method call. """ - parent = proto.Field( + parent: str = proto.Field( proto.STRING, number=1, ) - filter = proto.Field( + filter: str = proto.Field( proto.STRING, number=2, ) - page_size = proto.Field( + page_size: int = proto.Field( proto.INT32, number=3, ) - page_token = proto.Field( + page_token: str = proto.Field( proto.STRING, number=4, ) @@ -162,7 +164,7 @@ class ListServicesResponse(proto.Message): r"""The ``ListServices`` response. Attributes: - services (Sequence[google.cloud.monitoring_v3.types.Service]): + services (MutableSequence[google.cloud.monitoring_v3.types.Service]): The ``Service``\ s matching the specified filter. next_page_token (str): If there are more results than have been returned, then this @@ -175,12 +177,12 @@ class ListServicesResponse(proto.Message): def raw_page(self): return self - services = proto.RepeatedField( + services: MutableSequence[gm_service.Service] = proto.RepeatedField( proto.MESSAGE, number=1, message=gm_service.Service, ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=2, ) @@ -198,12 +200,12 @@ class UpdateServiceRequest(proto.Message): use for the update. """ - service = proto.Field( + service: gm_service.Service = proto.Field( proto.MESSAGE, number=1, message=gm_service.Service, ) - update_mask = proto.Field( + update_mask: field_mask_pb2.FieldMask = proto.Field( proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, @@ -223,7 +225,7 @@ class DeleteServiceRequest(proto.Message): projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -250,15 +252,15 @@ class CreateServiceLevelObjectiveRequest(proto.Message): ``ServiceLevelObjective`` exists with this name. """ - parent = proto.Field( + parent: str = proto.Field( proto.STRING, number=1, ) - service_level_objective_id = proto.Field( + service_level_objective_id: str = proto.Field( proto.STRING, number=3, ) - service_level_objective = proto.Field( + service_level_objective: gm_service.ServiceLevelObjective = proto.Field( proto.MESSAGE, number=2, message=gm_service.ServiceLevelObjective, @@ -285,11 +287,11 @@ class GetServiceLevelObjectiveRequest(proto.Message): ``RequestBasedSli`` spelling out how the SLI is computed. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - view = proto.Field( + view: gm_service.ServiceLevelObjective.View = proto.Field( proto.ENUM, number=2, enum=gm_service.ServiceLevelObjective.View, @@ -330,23 +332,23 @@ class ListServiceLevelObjectivesRequest(proto.Message): ``RequestBasedSli`` spelling out how the SLI is computed. """ - parent = proto.Field( + parent: str = proto.Field( proto.STRING, number=1, ) - filter = proto.Field( + filter: str = proto.Field( proto.STRING, number=2, ) - page_size = proto.Field( + page_size: int = proto.Field( proto.INT32, number=3, ) - page_token = proto.Field( + page_token: str = proto.Field( proto.STRING, number=4, ) - view = proto.Field( + view: gm_service.ServiceLevelObjective.View = proto.Field( proto.ENUM, number=5, enum=gm_service.ServiceLevelObjective.View, @@ -357,7 +359,7 @@ class ListServiceLevelObjectivesResponse(proto.Message): r"""The ``ListServiceLevelObjectives`` response. Attributes: - service_level_objectives (Sequence[google.cloud.monitoring_v3.types.ServiceLevelObjective]): + service_level_objectives (MutableSequence[google.cloud.monitoring_v3.types.ServiceLevelObjective]): The ``ServiceLevelObjective``\ s matching the specified filter. next_page_token (str): @@ -371,12 +373,14 @@ class ListServiceLevelObjectivesResponse(proto.Message): def raw_page(self): return self - service_level_objectives = proto.RepeatedField( + service_level_objectives: MutableSequence[ + gm_service.ServiceLevelObjective + ] = proto.RepeatedField( proto.MESSAGE, number=1, message=gm_service.ServiceLevelObjective, ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=2, ) @@ -394,12 +398,12 @@ class UpdateServiceLevelObjectiveRequest(proto.Message): use for the update. """ - service_level_objective = proto.Field( + service_level_objective: gm_service.ServiceLevelObjective = proto.Field( proto.MESSAGE, number=1, message=gm_service.ServiceLevelObjective, ) - update_mask = proto.Field( + update_mask: field_mask_pb2.FieldMask = proto.Field( proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, @@ -419,7 +423,7 @@ class DeleteServiceLevelObjectiveRequest(proto.Message): projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME] """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) diff --git a/google/cloud/monitoring_v3/types/span_context.py b/google/cloud/monitoring_v3/types/span_context.py index f2e50f05..173bbf0f 100644 --- a/google/cloud/monitoring_v3/types/span_context.py +++ b/google/cloud/monitoring_v3/types/span_context.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence + import proto # type: ignore @@ -52,7 +54,7 @@ class SpanContext(proto.Message): 8-byte array. """ - span_name = proto.Field( + span_name: str = proto.Field( proto.STRING, number=1, ) diff --git a/google/cloud/monitoring_v3/types/uptime.py b/google/cloud/monitoring_v3/types/uptime.py index 9abcf08e..505ddd43 100644 --- a/google/cloud/monitoring_v3/types/uptime.py +++ b/google/cloud/monitoring_v3/types/uptime.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence + import proto # type: ignore from google.api import monitored_resource_pb2 # type: ignore @@ -97,27 +99,27 @@ class State(proto.Enum): CREATING = 1 RUNNING = 2 - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - display_name = proto.Field( + display_name: str = proto.Field( proto.STRING, number=2, ) - network = proto.Field( + network: str = proto.Field( proto.STRING, number=3, ) - gcp_zone = proto.Field( + gcp_zone: str = proto.Field( proto.STRING, number=4, ) - peer_project_id = proto.Field( + peer_project_id: str = proto.Field( proto.STRING, number=6, ) - state = proto.Field( + state: State = proto.Field( proto.ENUM, number=7, enum=State, @@ -189,14 +191,14 @@ class UptimeCheckConfig(proto.Message): The maximum amount of time to wait for the request to complete (must be between 1 and 60 seconds). Required. - content_matchers (Sequence[google.cloud.monitoring_v3.types.UptimeCheckConfig.ContentMatcher]): + content_matchers (MutableSequence[google.cloud.monitoring_v3.types.UptimeCheckConfig.ContentMatcher]): The content that is expected to appear in the data returned by the target server against which the check is run. Currently, only the first entry in the ``content_matchers`` list is supported, and additional entries will be ignored. This field is optional and should only be specified if a content match is required as part of the/ Uptime check. - selected_regions (Sequence[google.cloud.monitoring_v3.types.UptimeCheckRegion]): + selected_regions (MutableSequence[google.cloud.monitoring_v3.types.UptimeCheckRegion]): The list of regions from which the check will be run. Some regions contain one location, and others contain more than one. If this field is @@ -211,7 +213,7 @@ class UptimeCheckConfig(proto.Message): provide 'selected_regions' when is_internal is ``true``, or to provide 'internal_checkers' when is_internal is ``false``. - internal_checkers (Sequence[google.cloud.monitoring_v3.types.InternalChecker]): + internal_checkers (MutableSequence[google.cloud.monitoring_v3.types.InternalChecker]): The internal checkers that this check will egress from. If ``is_internal`` is ``true`` and this list is empty, the check will egress from all the InternalCheckers configured @@ -232,11 +234,11 @@ class ResourceGroup(proto.Message): The resource type of the group members. """ - group_id = proto.Field( + group_id: str = proto.Field( proto.STRING, number=1, ) - resource_type = proto.Field( + resource_type: "GroupResourceType" = proto.Field( proto.ENUM, number=2, enum="GroupResourceType", @@ -275,7 +277,7 @@ class HttpCheck(proto.Message): responsible for encrypting the headers. On Get/List calls, if ``mask_headers`` is set to ``true`` then the headers will be obscured with ``******.`` - headers (Mapping[str, str]): + headers (MutableMapping[str, str]): The list of headers to send as part of the Uptime check request. If two headers have the same key and different values, they should be @@ -347,56 +349,56 @@ class BasicAuthentication(proto.Message): the HTTP server. """ - username = proto.Field( + username: str = proto.Field( proto.STRING, number=1, ) - password = proto.Field( + password: str = proto.Field( proto.STRING, number=2, ) - request_method = proto.Field( + request_method: "UptimeCheckConfig.HttpCheck.RequestMethod" = proto.Field( proto.ENUM, number=8, enum="UptimeCheckConfig.HttpCheck.RequestMethod", ) - use_ssl = proto.Field( + use_ssl: bool = proto.Field( proto.BOOL, number=1, ) - path = proto.Field( + path: str = proto.Field( proto.STRING, number=2, ) - port = proto.Field( + port: int = proto.Field( proto.INT32, number=3, ) - auth_info = proto.Field( + auth_info: "UptimeCheckConfig.HttpCheck.BasicAuthentication" = proto.Field( proto.MESSAGE, number=4, message="UptimeCheckConfig.HttpCheck.BasicAuthentication", ) - mask_headers = proto.Field( + mask_headers: bool = proto.Field( proto.BOOL, number=5, ) - headers = proto.MapField( + headers: MutableMapping[str, str] = proto.MapField( proto.STRING, proto.STRING, number=6, ) - content_type = proto.Field( + content_type: "UptimeCheckConfig.HttpCheck.ContentType" = proto.Field( proto.ENUM, number=9, enum="UptimeCheckConfig.HttpCheck.ContentType", ) - validate_ssl = proto.Field( + validate_ssl: bool = proto.Field( proto.BOOL, number=7, ) - body = proto.Field( + body: bytes = proto.Field( proto.BYTES, number=10, ) @@ -411,7 +413,7 @@ class TcpCheck(proto.Message): ``monitored_resource``) to construct the full URL. Required. """ - port = proto.Field( + port: int = proto.Field( proto.INT32, number=1, ) @@ -442,73 +444,73 @@ class ContentMatcherOption(proto.Enum): MATCHES_REGEX = 3 NOT_MATCHES_REGEX = 4 - content = proto.Field( + content: str = proto.Field( proto.STRING, number=1, ) - matcher = proto.Field( + matcher: "UptimeCheckConfig.ContentMatcher.ContentMatcherOption" = proto.Field( proto.ENUM, number=2, enum="UptimeCheckConfig.ContentMatcher.ContentMatcherOption", ) - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - display_name = proto.Field( + display_name: str = proto.Field( proto.STRING, number=2, ) - monitored_resource = proto.Field( + monitored_resource: monitored_resource_pb2.MonitoredResource = proto.Field( proto.MESSAGE, number=3, oneof="resource", message=monitored_resource_pb2.MonitoredResource, ) - resource_group = proto.Field( + resource_group: ResourceGroup = proto.Field( proto.MESSAGE, number=4, oneof="resource", message=ResourceGroup, ) - http_check = proto.Field( + http_check: HttpCheck = proto.Field( proto.MESSAGE, number=5, oneof="check_request_type", message=HttpCheck, ) - tcp_check = proto.Field( + tcp_check: TcpCheck = proto.Field( proto.MESSAGE, number=6, oneof="check_request_type", message=TcpCheck, ) - period = proto.Field( + period: duration_pb2.Duration = proto.Field( proto.MESSAGE, number=7, message=duration_pb2.Duration, ) - timeout = proto.Field( + timeout: duration_pb2.Duration = proto.Field( proto.MESSAGE, number=8, message=duration_pb2.Duration, ) - content_matchers = proto.RepeatedField( + content_matchers: MutableSequence[ContentMatcher] = proto.RepeatedField( proto.MESSAGE, number=9, message=ContentMatcher, ) - selected_regions = proto.RepeatedField( + selected_regions: MutableSequence["UptimeCheckRegion"] = proto.RepeatedField( proto.ENUM, number=10, enum="UptimeCheckRegion", ) - is_internal = proto.Field( + is_internal: bool = proto.Field( proto.BOOL, number=15, ) - internal_checkers = proto.RepeatedField( + internal_checkers: MutableSequence["InternalChecker"] = proto.RepeatedField( proto.MESSAGE, number=14, message="InternalChecker", @@ -540,16 +542,16 @@ class UptimeCheckIp(proto.Message): or IPv6 format. """ - region = proto.Field( + region: "UptimeCheckRegion" = proto.Field( proto.ENUM, number=1, enum="UptimeCheckRegion", ) - location = proto.Field( + location: str = proto.Field( proto.STRING, number=2, ) - ip_address = proto.Field( + ip_address: str = proto.Field( proto.STRING, number=3, ) diff --git a/google/cloud/monitoring_v3/types/uptime_service.py b/google/cloud/monitoring_v3/types/uptime_service.py index 3b96adfe..e433b8df 100644 --- a/google/cloud/monitoring_v3/types/uptime_service.py +++ b/google/cloud/monitoring_v3/types/uptime_service.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence + import proto # type: ignore from google.cloud.monitoring_v3.types import uptime @@ -59,15 +61,15 @@ class ListUptimeCheckConfigsRequest(proto.Message): results from the previous method call. """ - parent = proto.Field( + parent: str = proto.Field( proto.STRING, number=1, ) - page_size = proto.Field( + page_size: int = proto.Field( proto.INT32, number=3, ) - page_token = proto.Field( + page_token: str = proto.Field( proto.STRING, number=4, ) @@ -77,7 +79,7 @@ class ListUptimeCheckConfigsResponse(proto.Message): r"""The protocol for the ``ListUptimeCheckConfigs`` response. Attributes: - uptime_check_configs (Sequence[google.cloud.monitoring_v3.types.UptimeCheckConfig]): + uptime_check_configs (MutableSequence[google.cloud.monitoring_v3.types.UptimeCheckConfig]): The returned Uptime check configurations. next_page_token (str): This field represents the pagination token to retrieve the @@ -96,16 +98,18 @@ class ListUptimeCheckConfigsResponse(proto.Message): def raw_page(self): return self - uptime_check_configs = proto.RepeatedField( + uptime_check_configs: MutableSequence[ + uptime.UptimeCheckConfig + ] = proto.RepeatedField( proto.MESSAGE, number=1, message=uptime.UptimeCheckConfig, ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=2, ) - total_size = proto.Field( + total_size: int = proto.Field( proto.INT32, number=3, ) @@ -124,7 +128,7 @@ class GetUptimeCheckConfigRequest(proto.Message): projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID] """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -146,11 +150,11 @@ class CreateUptimeCheckConfigRequest(proto.Message): Required. The new Uptime check configuration. """ - parent = proto.Field( + parent: str = proto.Field( proto.STRING, number=1, ) - uptime_check_config = proto.Field( + uptime_check_config: uptime.UptimeCheckConfig = proto.Field( proto.MESSAGE, number=2, message=uptime.UptimeCheckConfig, @@ -183,12 +187,12 @@ class UpdateUptimeCheckConfigRequest(proto.Message): ``content_matchers``, and ``selected_regions``. """ - update_mask = proto.Field( + update_mask: field_mask_pb2.FieldMask = proto.Field( proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, ) - uptime_check_config = proto.Field( + uptime_check_config: uptime.UptimeCheckConfig = proto.Field( proto.MESSAGE, number=3, message=uptime.UptimeCheckConfig, @@ -208,7 +212,7 @@ class DeleteUptimeCheckConfigRequest(proto.Message): projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID] """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -233,11 +237,11 @@ class ListUptimeCheckIpsRequest(proto.Message): not yet implemented """ - page_size = proto.Field( + page_size: int = proto.Field( proto.INT32, number=2, ) - page_token = proto.Field( + page_token: str = proto.Field( proto.STRING, number=3, ) @@ -247,7 +251,7 @@ class ListUptimeCheckIpsResponse(proto.Message): r"""The protocol for the ``ListUptimeCheckIps`` response. Attributes: - uptime_check_ips (Sequence[google.cloud.monitoring_v3.types.UptimeCheckIp]): + uptime_check_ips (MutableSequence[google.cloud.monitoring_v3.types.UptimeCheckIp]): The returned list of IP addresses (including region and location) that the checkers run from. next_page_token (str): @@ -263,12 +267,12 @@ class ListUptimeCheckIpsResponse(proto.Message): def raw_page(self): return self - uptime_check_ips = proto.RepeatedField( + uptime_check_ips: MutableSequence[uptime.UptimeCheckIp] = proto.RepeatedField( proto.MESSAGE, number=1, message=uptime.UptimeCheckIp, ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=2, ) diff --git a/owlbot.py b/owlbot.py index 9323371d..5a446143 100644 --- a/owlbot.py +++ b/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2018 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,42 +12,31 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""This script is used to synthesize generated parts of this library.""" -import re +import json import os +from pathlib import Path +import re +import shutil import synthtool as s import synthtool.gcp as gcp from synthtool.languages import python -import logging - -AUTOSYNTH_MULTIPLE_COMMITS = True -logging.basicConfig(level=logging.DEBUG) +# ---------------------------------------------------------------------------- +# Copy the generated client from the owl-bot staging directory +# ---------------------------------------------------------------------------- -common = gcp.CommonTemplates() +clean_up_generated_samples = True -default_version = "v3" +# Load the default version defined in .repo-metadata.json. +default_version = json.load(open(".repo-metadata.json", "rt")).get( + "default_version" +) for library in s.get_staging_dirs(default_version): - # Synth hack due to googleapis and python-api-common-protos out of sync. - for pattern in [ - "monitored_resource_types=\['monitored_resource_types_value'\],", - "assert response.monitored_resource_types == \['monitored_resource_types_value'\]", - "launch_stage=launch_stage_pb2.LaunchStage.UNIMPLEMENTED,", - "assert response.launch_stage == launch_stage_pb2.LaunchStage.UNIMPLEMENTED", - ]: - s.replace(library / "tests/unit/gapic/monitoring_v3/test_*.py", - pattern, - "" - ) - - # Synth hack due to microgenerator uses "type_" while api-common-protos uses "type". - for file in ["test_uptime_check_service.py", "test_metric_service.py"]: - s.replace(library / f"tests/unit/gapic/monitoring_v3/{file}", - "type_", - "type" - ) + if clean_up_generated_samples: + shutil.rmtree("samples/generated_samples", ignore_errors=True) + clean_up_generated_samples = False # Comment out broken path helper 'metric_descriptor_path' # https://github.com/googleapis/gapic-generator-python/issues/701 @@ -71,86 +60,28 @@ '''"""\g<1>"""\ndef''', re.MULTILINE| re.DOTALL ) - - # Work around gapic generator bug https://github.com/googleapis/gapic-generator-python/issues/902 - s.replace(library / f"google/cloud/monitoring_{library.name}/types/service.py", - r""". - Attributes:""", - r""".\n - Attributes:""", - ) - - # don't copy nox.py, setup.py, README.rst, docs/index.rst - excludes = ["nox.py", "setup.py", "README.rst", "docs/index.rst"] - s.move(library, excludes=excludes) - + s.move([library], excludes=["**/gapic_version.py", "docs/index.rst", "setup.py", "testing/constraints-3.7.txt"]) s.remove_staging_dirs() # ---------------------------------------------------------------------------- # Add templated files # ---------------------------------------------------------------------------- -templated_files = common.py_library( - samples=True, # set to True only if there are samples - microgenerator=True, + +templated_files = gcp.CommonTemplates().py_library( + cov_level=99, + samples=True, unit_test_extras=["pandas"], system_test_extras=["pandas"], - cov_level=99 -) -s.move(templated_files, excludes=[".coveragerc"]) # microgenerator has a good .coveragerc file - -# ---------------------------------------------------------------------------- -# master --> main edits; context: https://github.com/googleapis/google-cloud-python/issues/10579 -# ---------------------------------------------------------------------------- - -s.replace( - "docs/conf.py", - "master_doc", - "root_doc", -) - -s.replace( - "docs/conf.py", - "# The master toctree document.", - "# The root toctree document.", -) - -s.replace( - ".kokoro/test-samples-impl.sh", - "https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot.", - "https://github.com/googleapis/repo-automation-bots/tree/main/packages/flakybot.", -) - -s.replace( - ".kokoro/build.sh", - "https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot.", - "https://github.com/googleapis/repo-automation-bots/tree/main/packages/flakybot.", -) - -s.replace( - "CONTRIBUTING.rst", - "master", - "main", -) - -# Revert the change from above, because kubernetes is still using master: -s.replace( - "CONTRIBUTING.rst", - r"https://github.com/kubernetes/community/blob/main/contributors/guide/pull-requests.md#best-practices-for-faster-reviews", - r"https://github.com/kubernetes/community/blob/master/contributors/guide/pull-requests.md#best-practices-for-faster-reviews", + microgenerator=True, + versions=gcp.common.detect_versions(path="./google", default_first=True), ) +s.move(templated_files, excludes=[".coveragerc", ".github/release-please.yml", "docs/index.rst"]) -# ---------------------------------------------------------------------------- -# Samples templates -# ---------------------------------------------------------------------------- python.py_samples(skip_readmes=True) -# Work around bug in templates https://github.com/googleapis/synthtool/pull/1335 -s.replace(".github/workflows/unittest.yml", "--fail-under=100", "--fail-under=99") - -python.configure_previous_major_version_branches() - -s.shell.run(["nox", "-s", "blacken"], hide_output=False) - +# run format session for all directories which have a noxfile +for noxfile in Path(".").glob("**/noxfile.py"): + s.shell.run(["nox", "-s", "blacken"], cwd=noxfile.parent, hide_output=False) # -------------------------------------------------------------------------- # Modify test configs diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..8ea43394 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,25 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "packages": { + ".": { + "release-type": "python", + "extra-files": [ + "google/cloud/monitoring/gapic_version.py", + "google/cloud/monitoring_v3/gapic_version.py", + { + "type": "json", + "path": "samples/generated_samples/snippet_metadata_google.monitoring.v3.json", + "jsonpath": "$.clientLibrary.version" + } + ] + } + }, + "release-type": "python", + "plugins": [ + { + "type": "sentence-case" + } + ], + "initial-version": "0.1.0" +} + diff --git a/samples/generated_samples/snippet_metadata_monitoring_v3.json b/samples/generated_samples/snippet_metadata_google.monitoring.v3.json similarity index 99% rename from samples/generated_samples/snippet_metadata_monitoring_v3.json rename to samples/generated_samples/snippet_metadata_google.monitoring.v3.json index 0eef96cd..20bc9c48 100644 --- a/samples/generated_samples/snippet_metadata_monitoring_v3.json +++ b/samples/generated_samples/snippet_metadata_google.monitoring.v3.json @@ -7,7 +7,8 @@ } ], "language": "PYTHON", - "name": "google-cloud-monitoring" + "name": "google-cloud-monitoring", + "version": "0.1.0" }, "snippets": [ { @@ -1990,7 +1991,7 @@ }, { "name": "time_series", - "type": "Sequence[google.cloud.monitoring_v3.types.TimeSeries]" + "type": "MutableSequence[google.cloud.monitoring_v3.types.TimeSeries]" }, { "name": "retry", @@ -2071,7 +2072,7 @@ }, { "name": "time_series", - "type": "Sequence[google.cloud.monitoring_v3.types.TimeSeries]" + "type": "MutableSequence[google.cloud.monitoring_v3.types.TimeSeries]" }, { "name": "retry", @@ -2153,7 +2154,7 @@ }, { "name": "time_series", - "type": "Sequence[google.cloud.monitoring_v3.types.TimeSeries]" + "type": "MutableSequence[google.cloud.monitoring_v3.types.TimeSeries]" }, { "name": "retry", @@ -2234,7 +2235,7 @@ }, { "name": "time_series", - "type": "Sequence[google.cloud.monitoring_v3.types.TimeSeries]" + "type": "MutableSequence[google.cloud.monitoring_v3.types.TimeSeries]" }, { "name": "retry", diff --git a/setup.py b/setup.py index 3b2c26a7..33d7e797 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ -# Copyright 2018 Google LLC +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -11,32 +12,37 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - +# import io import os -import setuptools +import setuptools # type: ignore - -# Package metadata. +package_root = os.path.abspath(os.path.dirname(__file__)) name = "google-cloud-monitoring" + + description = "Stackdriver Monitoring API client library" -version = "2.11.3" -# Should be one of: -# 'Development Status :: 3 - Alpha' -# 'Development Status :: 4 - Beta' -# 'Development Status :: 5 - Production/Stable' -release_status = "Development Status :: 5 - Production/Stable" + +version = {} +with open(os.path.join(package_root, "google/cloud/monitoring/gapic_version.py")) as fp: + exec(fp.read(), version) +version = version["__version__"] + +if version[0] == "0": + release_status = "Development Status :: 4 - Beta" +else: + release_status = "Development Status :: 5 - Production/Stable" + dependencies = [ - "google-api-core[grpc] >= 1.32.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*", + "google-api-core[grpc] >= 1.33.2, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*", "proto-plus >= 1.22.0, <2.0.0dev", "protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", ] extras = {"pandas": "pandas >= 0.17.1"} - -# Setup boilerplate below this line. +url = "https://github.com/googleapis/python-monitoring" package_root = os.path.abspath(os.path.dirname(__file__)) @@ -44,20 +50,16 @@ with io.open(readme_filename, encoding="utf-8") as readme_file: readme = readme_file.read() -# Only include packages under the 'google' namespace. Do not include tests, -# benchmarks, etc. packages = [ package for package in setuptools.PEP420PackageFinder.find() if package.startswith("google") ] -# Determine which namespaces are needed. namespaces = ["google"] if "google.cloud" in packages: namespaces.append("google.cloud") - setuptools.setup( name=name, version=version, @@ -66,7 +68,7 @@ author="Google LLC", author_email="googleapis-packages@google.com", license="Apache 2.0", - url="https://github.com/googleapis/python-monitoring", + url=url, classifiers=[ release_status, "Intended Audience :: Developers", @@ -75,16 +77,17 @@ "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Operating System :: OS Independent", "Topic :: Internet", ], platforms="Posix; MacOS X; Windows", packages=packages, + python_requires=">=3.7", namespace_packages=namespaces, install_requires=dependencies, extras_require=extras, - python_requires=">=3.7", - scripts=["scripts/fixup_monitoring_v3_keywords.py"], include_package_data=True, zip_safe=False, ) diff --git a/testing/constraints-3.10.txt b/testing/constraints-3.10.txt index e69de29b..ed7f9aed 100644 --- a/testing/constraints-3.10.txt +++ b/testing/constraints-3.10.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/testing/constraints-3.11.txt b/testing/constraints-3.11.txt index e69de29b..ed7f9aed 100644 --- a/testing/constraints-3.11.txt +++ b/testing/constraints-3.11.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt index b69e6917..f84d1b75 100644 --- a/testing/constraints-3.7.txt +++ b/testing/constraints-3.7.txt @@ -4,7 +4,7 @@ # Pin the version to the lower bound. # e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", # Then this file should have google-cloud-foo==1.14.0 -google-api-core==1.32.0 +google-api-core==1.33.2 proto-plus==1.22.0 -pandas==0.23.2 protobuf==3.19.5 +pandas==0.23.2 diff --git a/testing/constraints-3.8.txt b/testing/constraints-3.8.txt index da93009b..ed7f9aed 100644 --- a/testing/constraints-3.8.txt +++ b/testing/constraints-3.8.txt @@ -1,2 +1,6 @@ -# This constraints file is left inentionally empty -# so the latest version of dependencies is installed \ No newline at end of file +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/testing/constraints-3.9.txt b/testing/constraints-3.9.txt index da93009b..ed7f9aed 100644 --- a/testing/constraints-3.9.txt +++ b/testing/constraints-3.9.txt @@ -1,2 +1,6 @@ -# This constraints file is left inentionally empty -# so the latest version of dependencies is installed \ No newline at end of file +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/tests/unit/gapic/monitoring_v3/test_metric_service.py b/tests/unit/gapic/monitoring_v3/test_metric_service.py index 6263293d..0f5c34b7 100644 --- a/tests/unit/gapic/monitoring_v3/test_metric_service.py +++ b/tests/unit/gapic/monitoring_v3/test_metric_service.py @@ -1172,6 +1172,7 @@ def test_get_monitored_resource_descriptor(request_type, transport: str = "grpc" type="type_value", display_name="display_name_value", description="description_value", + launch_stage=launch_stage_pb2.LaunchStage.UNIMPLEMENTED, ) response = client.get_monitored_resource_descriptor(request) @@ -1186,6 +1187,7 @@ def test_get_monitored_resource_descriptor(request_type, transport: str = "grpc" assert response.type == "type_value" assert response.display_name == "display_name_value" assert response.description == "description_value" + assert response.launch_stage == launch_stage_pb2.LaunchStage.UNIMPLEMENTED def test_get_monitored_resource_descriptor_empty_call(): @@ -1231,6 +1233,7 @@ async def test_get_monitored_resource_descriptor_async( type="type_value", display_name="display_name_value", description="description_value", + launch_stage=launch_stage_pb2.LaunchStage.UNIMPLEMENTED, ) ) response = await client.get_monitored_resource_descriptor(request) @@ -1246,6 +1249,7 @@ async def test_get_monitored_resource_descriptor_async( assert response.type == "type_value" assert response.display_name == "display_name_value" assert response.description == "description_value" + assert response.launch_stage == launch_stage_pb2.LaunchStage.UNIMPLEMENTED @pytest.mark.asyncio @@ -1877,6 +1881,8 @@ def test_get_metric_descriptor(request_type, transport: str = "grpc"): unit="unit_value", description="description_value", display_name="display_name_value", + launch_stage=launch_stage_pb2.LaunchStage.UNIMPLEMENTED, + monitored_resource_types=["monitored_resource_types_value"], ) response = client.get_metric_descriptor(request) @@ -1894,6 +1900,8 @@ def test_get_metric_descriptor(request_type, transport: str = "grpc"): assert response.unit == "unit_value" assert response.description == "description_value" assert response.display_name == "display_name_value" + assert response.launch_stage == launch_stage_pb2.LaunchStage.UNIMPLEMENTED + assert response.monitored_resource_types == ["monitored_resource_types_value"] def test_get_metric_descriptor_empty_call(): @@ -1942,6 +1950,8 @@ async def test_get_metric_descriptor_async( unit="unit_value", description="description_value", display_name="display_name_value", + launch_stage=launch_stage_pb2.LaunchStage.UNIMPLEMENTED, + monitored_resource_types=["monitored_resource_types_value"], ) ) response = await client.get_metric_descriptor(request) @@ -1960,6 +1970,8 @@ async def test_get_metric_descriptor_async( assert response.unit == "unit_value" assert response.description == "description_value" assert response.display_name == "display_name_value" + assert response.launch_stage == launch_stage_pb2.LaunchStage.UNIMPLEMENTED + assert response.monitored_resource_types == ["monitored_resource_types_value"] @pytest.mark.asyncio @@ -2148,6 +2160,8 @@ def test_create_metric_descriptor(request_type, transport: str = "grpc"): unit="unit_value", description="description_value", display_name="display_name_value", + launch_stage=launch_stage_pb2.LaunchStage.UNIMPLEMENTED, + monitored_resource_types=["monitored_resource_types_value"], ) response = client.create_metric_descriptor(request) @@ -2165,6 +2179,8 @@ def test_create_metric_descriptor(request_type, transport: str = "grpc"): assert response.unit == "unit_value" assert response.description == "description_value" assert response.display_name == "display_name_value" + assert response.launch_stage == launch_stage_pb2.LaunchStage.UNIMPLEMENTED + assert response.monitored_resource_types == ["monitored_resource_types_value"] def test_create_metric_descriptor_empty_call(): @@ -2213,6 +2229,8 @@ async def test_create_metric_descriptor_async( unit="unit_value", description="description_value", display_name="display_name_value", + launch_stage=launch_stage_pb2.LaunchStage.UNIMPLEMENTED, + monitored_resource_types=["monitored_resource_types_value"], ) ) response = await client.create_metric_descriptor(request) @@ -2231,6 +2249,8 @@ async def test_create_metric_descriptor_async( assert response.unit == "unit_value" assert response.description == "description_value" assert response.display_name == "display_name_value" + assert response.launch_stage == launch_stage_pb2.LaunchStage.UNIMPLEMENTED + assert response.monitored_resource_types == ["monitored_resource_types_value"] @pytest.mark.asyncio diff --git a/tests/unit/gapic/monitoring_v3/test_notification_channel_service.py b/tests/unit/gapic/monitoring_v3/test_notification_channel_service.py index bce38cdf..e979d915 100644 --- a/tests/unit/gapic/monitoring_v3/test_notification_channel_service.py +++ b/tests/unit/gapic/monitoring_v3/test_notification_channel_service.py @@ -1217,6 +1217,7 @@ def test_get_notification_channel_descriptor(request_type, transport: str = "grp display_name="display_name_value", description="description_value", supported_tiers=[common.ServiceTier.SERVICE_TIER_BASIC], + launch_stage=launch_stage_pb2.LaunchStage.UNIMPLEMENTED, ) response = client.get_notification_channel_descriptor(request) @@ -1232,6 +1233,7 @@ def test_get_notification_channel_descriptor(request_type, transport: str = "grp assert response.display_name == "display_name_value" assert response.description == "description_value" assert response.supported_tiers == [common.ServiceTier.SERVICE_TIER_BASIC] + assert response.launch_stage == launch_stage_pb2.LaunchStage.UNIMPLEMENTED def test_get_notification_channel_descriptor_empty_call(): @@ -1278,6 +1280,7 @@ async def test_get_notification_channel_descriptor_async( display_name="display_name_value", description="description_value", supported_tiers=[common.ServiceTier.SERVICE_TIER_BASIC], + launch_stage=launch_stage_pb2.LaunchStage.UNIMPLEMENTED, ) ) response = await client.get_notification_channel_descriptor(request) @@ -1294,6 +1297,7 @@ async def test_get_notification_channel_descriptor_async( assert response.display_name == "display_name_value" assert response.description == "description_value" assert response.supported_tiers == [common.ServiceTier.SERVICE_TIER_BASIC] + assert response.launch_stage == launch_stage_pb2.LaunchStage.UNIMPLEMENTED @pytest.mark.asyncio