diff --git a/packages/google-cloud-monitoring/README.rst b/packages/google-cloud-monitoring/README.rst index 4732056b99de..093a9582cb23 100644 --- a/packages/google-cloud-monitoring/README.rst +++ b/packages/google-cloud-monitoring/README.rst @@ -15,7 +15,7 @@ Python Client for Stackdriver Monitoring .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-monitoring.svg :target: https://pypi.org/project/google-cloud-monitoring/ .. _Stackdriver Monitoring: https://cloud.google.com/monitoring/docs -.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/monitoring/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/monitoring/latest/summary_overview .. _Product Documentation: https://cloud.google.com/monitoring/docs Quick Start diff --git a/packages/google-cloud-monitoring/docs/index.rst b/packages/google-cloud-monitoring/docs/index.rst index dc5e1fbf9bd0..c5d664834c34 100644 --- a/packages/google-cloud-monitoring/docs/index.rst +++ b/packages/google-cloud-monitoring/docs/index.rst @@ -22,3 +22,8 @@ For a list of all ``google-cloud-monitoring`` releases: :maxdepth: 2 CHANGELOG + +.. toctree:: + :hidden: + + summary_overview.md diff --git a/packages/google-cloud-monitoring/docs/summary_overview.md b/packages/google-cloud-monitoring/docs/summary_overview.md new file mode 100644 index 000000000000..5174b1030122 --- /dev/null +++ b/packages/google-cloud-monitoring/docs/summary_overview.md @@ -0,0 +1,22 @@ +[ +This is a templated file. Adding content to this file may result in it being +reverted. Instead, if you want to place additional content, create an +"overview_content.md" file in `docs/` directory. The Sphinx tool will +pick up on the content and merge the content. +]: # + +# Stackdriver Monitoring API + +Overview of the APIs available for Stackdriver Monitoring API. + +## All entries + +Classes, methods and properties & attributes for +Stackdriver Monitoring API. + +[classes](https://cloud.google.com/python/docs/reference/monitoring/latest/summary_class.html) + +[methods](https://cloud.google.com/python/docs/reference/monitoring/latest/summary_method.html) + +[properties and +attributes](https://cloud.google.com/python/docs/reference/monitoring/latest/summary_property.html) diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring/gapic_version.py b/packages/google-cloud-monitoring/google/cloud/monitoring/gapic_version.py index aa0e1f9b4b88..558c8aab67c5 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring/gapic_version.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.22.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/gapic_version.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/gapic_version.py index aa0e1f9b4b88..558c8aab67c5 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/gapic_version.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.22.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/alert_policy_service/transports/base.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/alert_policy_service/transports/base.py index 9d9d4685bfe2..de1349d796ee 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/alert_policy_service/transports/base.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/alert_policy_service/transports/base.py @@ -87,6 +87,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -99,7 +101,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc.py index cbe4cb49a20d..96de20d94999 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc.py @@ -131,7 +131,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc_asyncio.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc_asyncio.py index 8f9d38547be2..1f8f7b11c98c 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc_asyncio.py @@ -178,7 +178,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/group_service/transports/base.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/group_service/transports/base.py index 79543044f425..8a81ee4a152b 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/group_service/transports/base.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/group_service/transports/base.py @@ -89,6 +89,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -101,7 +103,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/group_service/transports/grpc.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/group_service/transports/grpc.py index 72989887ae5a..abe476db15a8 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/group_service/transports/grpc.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/group_service/transports/grpc.py @@ -136,7 +136,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/group_service/transports/grpc_asyncio.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/group_service/transports/grpc_asyncio.py index ff93a41513b1..e27f6bb7eef4 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/group_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/group_service/transports/grpc_asyncio.py @@ -183,7 +183,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/metric_service/transports/base.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/metric_service/transports/base.py index 02f9dfe78f6e..303d6adbc9d6 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/metric_service/transports/base.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/metric_service/transports/base.py @@ -90,6 +90,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -102,7 +104,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/metric_service/transports/grpc.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/metric_service/transports/grpc.py index 9ab9a20cba8f..982b7fb88406 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/metric_service/transports/grpc.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/metric_service/transports/grpc.py @@ -126,7 +126,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/metric_service/transports/grpc_asyncio.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/metric_service/transports/grpc_asyncio.py index d8a4b5ce6431..f1118c65d87b 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/metric_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/metric_service/transports/grpc_asyncio.py @@ -173,7 +173,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/notification_channel_service/transports/base.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/notification_channel_service/transports/base.py index 798de20c5d3f..b4a173233429 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/notification_channel_service/transports/base.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/notification_channel_service/transports/base.py @@ -87,6 +87,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -99,7 +101,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/notification_channel_service/transports/grpc.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/notification_channel_service/transports/grpc.py index 8715a06b8493..37bb0b940052 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/notification_channel_service/transports/grpc.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/notification_channel_service/transports/grpc.py @@ -124,7 +124,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/notification_channel_service/transports/grpc_asyncio.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/notification_channel_service/transports/grpc_asyncio.py index cbd467ae4326..d2dd582bbee3 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/notification_channel_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/notification_channel_service/transports/grpc_asyncio.py @@ -173,7 +173,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/query_service/transports/base.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/query_service/transports/base.py index 3942db8df8dc..d9b22d4aa22e 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/query_service/transports/base.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/query_service/transports/base.py @@ -86,6 +86,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -98,7 +100,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/query_service/transports/grpc.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/query_service/transports/grpc.py index a148b1868629..eabb5834db97 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/query_service/transports/grpc.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/query_service/transports/grpc.py @@ -124,7 +124,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/query_service/transports/grpc_asyncio.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/query_service/transports/grpc_asyncio.py index 414a8e0bdc2d..ec346f5f8b05 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/query_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/query_service/transports/grpc_asyncio.py @@ -171,7 +171,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/service_monitoring_service/transports/base.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/service_monitoring_service/transports/base.py index d5b45945bcb4..ee6adb277502 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/service_monitoring_service/transports/base.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/service_monitoring_service/transports/base.py @@ -89,6 +89,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -101,7 +103,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/service_monitoring_service/transports/grpc.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/service_monitoring_service/transports/grpc.py index e88b1ecc17b0..b2fcc707570f 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/service_monitoring_service/transports/grpc.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/service_monitoring_service/transports/grpc.py @@ -129,7 +129,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/service_monitoring_service/transports/grpc_asyncio.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/service_monitoring_service/transports/grpc_asyncio.py index 42871f5c68c7..43af95fcdbdb 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/service_monitoring_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/service_monitoring_service/transports/grpc_asyncio.py @@ -176,7 +176,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/snooze_service/transports/base.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/snooze_service/transports/base.py index 7cf87672f280..586edf670ba7 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/snooze_service/transports/base.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/snooze_service/transports/base.py @@ -88,6 +88,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -100,7 +102,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/snooze_service/transports/grpc.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/snooze_service/transports/grpc.py index 7a72c51809b4..be273dcff29b 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/snooze_service/transports/grpc.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/snooze_service/transports/grpc.py @@ -127,7 +127,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/snooze_service/transports/grpc_asyncio.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/snooze_service/transports/grpc_asyncio.py index 27219cf18951..4181f120d388 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/snooze_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/snooze_service/transports/grpc_asyncio.py @@ -174,7 +174,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/uptime_check_service/transports/base.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/uptime_check_service/transports/base.py index 953a2648a434..7d22cc5c7cf6 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/uptime_check_service/transports/base.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/uptime_check_service/transports/base.py @@ -87,6 +87,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -99,7 +101,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/uptime_check_service/transports/grpc.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/uptime_check_service/transports/grpc.py index db64101b8f59..3b09aa399f60 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/uptime_check_service/transports/grpc.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/uptime_check_service/transports/grpc.py @@ -130,7 +130,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/uptime_check_service/transports/grpc_asyncio.py b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/uptime_check_service/transports/grpc_asyncio.py index 8cc7668763b1..2e27a508ed75 100644 --- a/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/uptime_check_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/uptime_check_service/transports/grpc_asyncio.py @@ -177,7 +177,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-monitoring/noxfile.py b/packages/google-cloud-monitoring/noxfile.py index 0c40d43a82b2..d5b7db54ef8b 100644 --- a/packages/google-cloud-monitoring/noxfile.py +++ b/packages/google-cloud-monitoring/noxfile.py @@ -160,14 +160,28 @@ def install_unittest_dependencies(session, *constraints): session.install("-e", ".", *constraints) -def default(session): +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def unit(session, protobuf_implementation): # Install all test dependencies, then install this package in-place. + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) install_unittest_dependencies(session, "-c", constraints_path) + # TODO(https://github.com/googleapis/synthtool/issues/1976): + # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. + # The 'cpp' implementation requires Protobuf<4. + if protobuf_implementation == "cpp": + session.install("protobuf<4") + # Run py.test against the unit tests. session.run( "py.test", @@ -181,15 +195,12 @@ def default(session): "--cov-fail-under=0", os.path.join("tests", "unit"), *session.posargs, + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, ) -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) -def unit(session): - """Run the unit test suite.""" - default(session) - - def install_systemtest_dependencies(session, *constraints): # Use pre-release gRPC for system tests. # Exclude version 1.52.0rc1 which has a known issue. @@ -358,9 +369,16 @@ def docfx(session): @nox.session(python="3.12") -def prerelease_deps(session): +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def prerelease_deps(session, protobuf_implementation): """Run all tests with prerelease versions of dependencies installed.""" + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + # Install all dependencies session.install("-e", ".[all, tests, tracing]") unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES @@ -397,9 +415,9 @@ def prerelease_deps(session): "protobuf", # dependency of grpc "six", + "grpc-google-iam-v1", "googleapis-common-protos", - # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163 - "grpcio!=1.52.0rc1", + "grpcio", "grpcio-status", "google-api-core", "google-auth", @@ -425,4 +443,10 @@ def prerelease_deps(session): session.run("python", "-c", "import grpc; print(grpc.__version__)") session.run("python", "-c", "import google.auth; print(google.auth.__version__)") - session.run("py.test", "tests/unit") + session.run( + "py.test", + "tests/unit", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) diff --git a/packages/google-cloud-monitoring/samples/generated_samples/snippet_metadata_google.monitoring.v3.json b/packages/google-cloud-monitoring/samples/generated_samples/snippet_metadata_google.monitoring.v3.json index cfe64565e3cc..04888a5ff523 100644 --- a/packages/google-cloud-monitoring/samples/generated_samples/snippet_metadata_google.monitoring.v3.json +++ b/packages/google-cloud-monitoring/samples/generated_samples/snippet_metadata_google.monitoring.v3.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-monitoring", - "version": "2.22.0" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-monitoring/setup.py b/packages/google-cloud-monitoring/setup.py index 81c3694a168e..ff9db6ddc0eb 100644 --- a/packages/google-cloud-monitoring/setup.py +++ b/packages/google-cloud-monitoring/setup.py @@ -44,7 +44,7 @@ # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", "proto-plus >= 1.22.3, <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", + "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", ] extras = {"pandas": "pandas >= 0.23.2"} diff --git a/packages/google-cloud-monitoring/testing/constraints-3.7.txt b/packages/google-cloud-monitoring/testing/constraints-3.7.txt index 7e226b67e49d..8b5950bc263e 100644 --- a/packages/google-cloud-monitoring/testing/constraints-3.7.txt +++ b/packages/google-cloud-monitoring/testing/constraints-3.7.txt @@ -8,4 +8,4 @@ google-api-core==1.34.1 google-auth==2.14.1 pandas==0.23.2 proto-plus==1.22.3 -protobuf==3.19.5 +protobuf==3.20.2 diff --git a/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_alert_policy_service.py b/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_alert_policy_service.py index 23812b682a72..412ea17b93fb 100644 --- a/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_alert_policy_service.py +++ b/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_alert_policy_service.py @@ -1321,12 +1321,7 @@ async def test_list_alert_policies_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_alert_policies ] = mock_object @@ -1914,12 +1909,7 @@ async def test_get_alert_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_alert_policy ] = mock_object @@ -2311,12 +2301,7 @@ async def test_create_alert_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_alert_policy ] = mock_object @@ -2709,12 +2694,7 @@ async def test_delete_alert_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_alert_policy ] = mock_object @@ -3099,12 +3079,7 @@ async def test_update_alert_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_alert_policy ] = mock_object diff --git a/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_group_service.py b/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_group_service.py index 18cd4534722a..943713841df1 100644 --- a/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_group_service.py +++ b/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_group_service.py @@ -1252,12 +1252,7 @@ async def test_list_groups_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_groups ] = mock_object @@ -1821,12 +1816,7 @@ async def test_get_group_async_use_cached_wrapped_rpc(transport: str = "grpc_asy ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_group ] = mock_object @@ -2206,12 +2196,7 @@ async def test_create_group_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_group ] = mock_object @@ -2597,12 +2582,7 @@ async def test_update_group_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_group ] = mock_object @@ -2963,12 +2943,7 @@ async def test_delete_group_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_group ] = mock_object @@ -3342,12 +3317,7 @@ async def test_list_group_members_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_group_members ] = mock_object diff --git a/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_metric_service.py b/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_metric_service.py index 83642e80b470..8a0b1e4aa55e 100644 --- a/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_metric_service.py +++ b/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_metric_service.py @@ -1287,12 +1287,7 @@ async def test_list_monitored_resource_descriptors_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_monitored_resource_descriptors ] = mock_object @@ -1896,12 +1891,7 @@ async def test_get_monitored_resource_descriptor_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_monitored_resource_descriptor ] = mock_object @@ -2301,12 +2291,7 @@ async def test_list_metric_descriptors_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_metric_descriptors ] = mock_object @@ -2916,12 +2901,7 @@ async def test_get_metric_descriptor_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_metric_descriptor ] = mock_object @@ -3349,12 +3329,7 @@ async def test_create_metric_descriptor_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_metric_descriptor ] = mock_object @@ -3761,12 +3736,7 @@ async def test_delete_metric_descriptor_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_metric_descriptor ] = mock_object @@ -4143,12 +4113,7 @@ async def test_list_time_series_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_time_series ] = mock_object @@ -4739,12 +4704,7 @@ async def test_create_time_series_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_time_series ] = mock_object @@ -5133,12 +5093,7 @@ async def test_create_service_time_series_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_service_time_series ] = mock_object diff --git a/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_notification_channel_service.py b/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_notification_channel_service.py index e91cb4c6b2e1..db3b10769952 100644 --- a/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_notification_channel_service.py +++ b/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_notification_channel_service.py @@ -1352,12 +1352,7 @@ async def test_list_notification_channel_descriptors_async_use_cached_wrapped_rp ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_notification_channel_descriptors ] = mock_object @@ -1968,12 +1963,7 @@ async def test_get_notification_channel_descriptor_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_notification_channel_descriptor ] = mock_object @@ -2380,12 +2370,7 @@ async def test_list_notification_channels_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_notification_channels ] = mock_object @@ -2988,12 +2973,7 @@ async def test_get_notification_channel_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_notification_channel ] = mock_object @@ -3407,12 +3387,7 @@ async def test_create_notification_channel_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_notification_channel ] = mock_object @@ -3832,12 +3807,7 @@ async def test_update_notification_channel_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_notification_channel ] = mock_object @@ -4239,12 +4209,7 @@ async def test_delete_notification_channel_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_notification_channel ] = mock_object @@ -4636,12 +4601,7 @@ async def test_send_notification_channel_verification_code_async_use_cached_wrap ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.send_notification_channel_verification_code ] = mock_object @@ -5034,12 +4994,7 @@ async def test_get_notification_channel_verification_code_async_use_cached_wrapp ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_notification_channel_verification_code ] = mock_object @@ -5452,12 +5407,7 @@ async def test_verify_notification_channel_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.verify_notification_channel ] = mock_object diff --git a/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_query_service.py b/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_query_service.py index 07ce7ca91a60..9372ba2eb421 100644 --- a/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_query_service.py +++ b/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_query_service.py @@ -1253,12 +1253,7 @@ async def test_query_time_series_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.query_time_series ] = mock_object diff --git a/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_service_monitoring_service.py b/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_service_monitoring_service.py index 3c80982ff82b..12440b37e5e2 100644 --- a/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_service_monitoring_service.py +++ b/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_service_monitoring_service.py @@ -1323,12 +1323,7 @@ async def test_create_service_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_service ] = mock_object @@ -1703,12 +1698,7 @@ async def test_get_service_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_service ] = mock_object @@ -2074,12 +2064,7 @@ async def test_list_services_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_services ] = mock_object @@ -2632,12 +2617,7 @@ async def test_update_service_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_service ] = mock_object @@ -2992,12 +2972,7 @@ async def test_delete_service_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_service ] = mock_object @@ -3374,12 +3349,7 @@ async def test_create_service_level_objective_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_service_level_objective ] = mock_object @@ -3788,12 +3758,7 @@ async def test_get_service_level_objective_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_service_level_objective ] = mock_object @@ -4189,12 +4154,7 @@ async def test_list_service_level_objectives_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_service_level_objectives ] = mock_object @@ -4783,12 +4743,7 @@ async def test_update_service_level_objective_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_service_level_objective ] = mock_object @@ -5173,12 +5128,7 @@ async def test_delete_service_level_objective_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_service_level_objective ] = mock_object diff --git a/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_snooze_service.py b/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_snooze_service.py index 115175e3ef0d..d27e1be67b93 100644 --- a/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_snooze_service.py +++ b/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_snooze_service.py @@ -1266,12 +1266,7 @@ async def test_create_snooze_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_snooze ] = mock_object @@ -1647,12 +1642,7 @@ async def test_list_snoozes_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_snoozes ] = mock_object @@ -2207,12 +2197,7 @@ async def test_get_snooze_async_use_cached_wrapped_rpc(transport: str = "grpc_as ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_snooze ] = mock_object @@ -2573,12 +2558,7 @@ async def test_update_snooze_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_snooze ] = mock_object diff --git a/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_uptime_check_service.py b/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_uptime_check_service.py index 753fceaaab4c..1425f29e9c8d 100644 --- a/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_uptime_check_service.py +++ b/packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_uptime_check_service.py @@ -1312,12 +1312,7 @@ async def test_list_uptime_check_configs_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_uptime_check_configs ] = mock_object @@ -1919,12 +1914,7 @@ async def test_get_uptime_check_config_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_uptime_check_config ] = mock_object @@ -2336,12 +2326,7 @@ async def test_create_uptime_check_config_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_uptime_check_config ] = mock_object @@ -2759,12 +2744,7 @@ async def test_update_uptime_check_config_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_uptime_check_config ] = mock_object @@ -3155,12 +3135,7 @@ async def test_delete_uptime_check_config_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_uptime_check_config ] = mock_object @@ -3539,12 +3514,7 @@ async def test_list_uptime_check_ips_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_uptime_check_ips ] = mock_object diff --git a/packages/google-cloud-netapp/README.rst b/packages/google-cloud-netapp/README.rst index 1d831e7f2457..9c1ad401d800 100644 --- a/packages/google-cloud-netapp/README.rst +++ b/packages/google-cloud-netapp/README.rst @@ -15,7 +15,7 @@ Python Client for NetApp API .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-netapp.svg :target: https://pypi.org/project/google-cloud-netapp/ .. _NetApp API: https://cloud.google.com/netapp/volumes/docs/discover/overview -.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/netapp/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/netapp/latest/summary_overview .. _Product Documentation: https://cloud.google.com/netapp/volumes/docs/discover/overview Quick Start diff --git a/packages/google-cloud-netapp/docs/index.rst b/packages/google-cloud-netapp/docs/index.rst index 6e91c8c0b1d6..4f98163a4637 100644 --- a/packages/google-cloud-netapp/docs/index.rst +++ b/packages/google-cloud-netapp/docs/index.rst @@ -21,3 +21,8 @@ For a list of all ``google-cloud-netapp`` releases: :maxdepth: 2 CHANGELOG + +.. toctree:: + :hidden: + + summary_overview.md diff --git a/packages/google-cloud-netapp/docs/summary_overview.md b/packages/google-cloud-netapp/docs/summary_overview.md new file mode 100644 index 000000000000..70d83bccbc66 --- /dev/null +++ b/packages/google-cloud-netapp/docs/summary_overview.md @@ -0,0 +1,22 @@ +[ +This is a templated file. Adding content to this file may result in it being +reverted. Instead, if you want to place additional content, create an +"overview_content.md" file in `docs/` directory. The Sphinx tool will +pick up on the content and merge the content. +]: # + +# NetApp API API + +Overview of the APIs available for NetApp API API. + +## All entries + +Classes, methods and properties & attributes for +NetApp API API. + +[classes](https://cloud.google.com/python/docs/reference/netapp/latest/summary_class.html) + +[methods](https://cloud.google.com/python/docs/reference/netapp/latest/summary_method.html) + +[properties and +attributes](https://cloud.google.com/python/docs/reference/netapp/latest/summary_property.html) diff --git a/packages/google-cloud-netapp/google/cloud/netapp_v1/services/net_app/transports/base.py b/packages/google-cloud-netapp/google/cloud/netapp_v1/services/net_app/transports/base.py index 3d6fe9def1c1..19de7acc8804 100644 --- a/packages/google-cloud-netapp/google/cloud/netapp_v1/services/net_app/transports/base.py +++ b/packages/google-cloud-netapp/google/cloud/netapp_v1/services/net_app/transports/base.py @@ -99,6 +99,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -111,7 +113,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-netapp/google/cloud/netapp_v1/services/net_app/transports/grpc.py b/packages/google-cloud-netapp/google/cloud/netapp_v1/services/net_app/transports/grpc.py index 8ce2e99fc68c..023b562b7012 100644 --- a/packages/google-cloud-netapp/google/cloud/netapp_v1/services/net_app/transports/grpc.py +++ b/packages/google-cloud-netapp/google/cloud/netapp_v1/services/net_app/transports/grpc.py @@ -140,7 +140,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-netapp/google/cloud/netapp_v1/services/net_app/transports/grpc_asyncio.py b/packages/google-cloud-netapp/google/cloud/netapp_v1/services/net_app/transports/grpc_asyncio.py index b43ad52f7181..933f69b45e91 100644 --- a/packages/google-cloud-netapp/google/cloud/netapp_v1/services/net_app/transports/grpc_asyncio.py +++ b/packages/google-cloud-netapp/google/cloud/netapp_v1/services/net_app/transports/grpc_asyncio.py @@ -187,7 +187,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-netapp/noxfile.py b/packages/google-cloud-netapp/noxfile.py index 1e6cd48d0529..67b7265f7586 100644 --- a/packages/google-cloud-netapp/noxfile.py +++ b/packages/google-cloud-netapp/noxfile.py @@ -160,14 +160,28 @@ def install_unittest_dependencies(session, *constraints): session.install("-e", ".", *constraints) -def default(session): +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def unit(session, protobuf_implementation): # Install all test dependencies, then install this package in-place. + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) install_unittest_dependencies(session, "-c", constraints_path) + # TODO(https://github.com/googleapis/synthtool/issues/1976): + # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. + # The 'cpp' implementation requires Protobuf<4. + if protobuf_implementation == "cpp": + session.install("protobuf<4") + # Run py.test against the unit tests. session.run( "py.test", @@ -181,15 +195,12 @@ def default(session): "--cov-fail-under=0", os.path.join("tests", "unit"), *session.posargs, + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, ) -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) -def unit(session): - """Run the unit test suite.""" - default(session) - - def install_systemtest_dependencies(session, *constraints): # Use pre-release gRPC for system tests. # Exclude version 1.52.0rc1 which has a known issue. @@ -358,9 +369,16 @@ def docfx(session): @nox.session(python="3.12") -def prerelease_deps(session): +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def prerelease_deps(session, protobuf_implementation): """Run all tests with prerelease versions of dependencies installed.""" + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + # Install all dependencies session.install("-e", ".[all, tests, tracing]") unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES @@ -397,9 +415,9 @@ def prerelease_deps(session): "protobuf", # dependency of grpc "six", + "grpc-google-iam-v1", "googleapis-common-protos", - # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163 - "grpcio!=1.52.0rc1", + "grpcio", "grpcio-status", "google-api-core", "google-auth", @@ -425,4 +443,10 @@ def prerelease_deps(session): session.run("python", "-c", "import grpc; print(grpc.__version__)") session.run("python", "-c", "import google.auth; print(google.auth.__version__)") - session.run("py.test", "tests/unit") + session.run( + "py.test", + "tests/unit", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) diff --git a/packages/google-cloud-netapp/setup.py b/packages/google-cloud-netapp/setup.py index 08dc0c34f1b4..45ce8d8efe01 100644 --- a/packages/google-cloud-netapp/setup.py +++ b/packages/google-cloud-netapp/setup.py @@ -44,7 +44,7 @@ # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", "proto-plus >= 1.22.3, <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", + "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", ] url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-netapp" diff --git a/packages/google-cloud-netapp/testing/constraints-3.7.txt b/packages/google-cloud-netapp/testing/constraints-3.7.txt index b8a550c73855..fc812592b0ee 100644 --- a/packages/google-cloud-netapp/testing/constraints-3.7.txt +++ b/packages/google-cloud-netapp/testing/constraints-3.7.txt @@ -7,4 +7,4 @@ google-api-core==1.34.1 google-auth==2.14.1 proto-plus==1.22.3 -protobuf==3.19.5 +protobuf==3.20.2 diff --git a/packages/google-cloud-netapp/tests/unit/gapic/netapp_v1/test_net_app.py b/packages/google-cloud-netapp/tests/unit/gapic/netapp_v1/test_net_app.py index cf1b2874291e..894286aaf4b7 100644 --- a/packages/google-cloud-netapp/tests/unit/gapic/netapp_v1/test_net_app.py +++ b/packages/google-cloud-netapp/tests/unit/gapic/netapp_v1/test_net_app.py @@ -1264,12 +1264,7 @@ async def test_list_storage_pools_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_storage_pools ] = mock_object @@ -1856,12 +1851,7 @@ async def test_create_storage_pool_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_storage_pool ] = mock_object @@ -2301,12 +2291,7 @@ async def test_get_storage_pool_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_storage_pool ] = mock_object @@ -2705,12 +2690,7 @@ async def test_update_storage_pool_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_storage_pool ] = mock_object @@ -3107,12 +3087,7 @@ async def test_delete_storage_pool_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_storage_pool ] = mock_object @@ -3496,12 +3471,7 @@ async def test_list_volumes_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_volumes ] = mock_object @@ -4124,12 +4094,7 @@ async def test_get_volume_async_use_cached_wrapped_rpc(transport: str = "grpc_as ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_volume ] = mock_object @@ -4536,12 +4501,7 @@ async def test_create_volume_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_volume ] = mock_object @@ -4921,12 +4881,7 @@ async def test_update_volume_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_volume ] = mock_object @@ -5300,12 +5255,7 @@ async def test_delete_volume_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_volume ] = mock_object @@ -5671,12 +5621,7 @@ async def test_revert_volume_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.revert_volume ] = mock_object @@ -5968,12 +5913,7 @@ async def test_list_snapshots_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_snapshots ] = mock_object @@ -6541,12 +6481,7 @@ async def test_get_snapshot_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_snapshot ] = mock_object @@ -6915,12 +6850,7 @@ async def test_create_snapshot_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_snapshot ] = mock_object @@ -7304,12 +7234,7 @@ async def test_delete_snapshot_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_snapshot ] = mock_object @@ -7669,12 +7594,7 @@ async def test_update_snapshot_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_snapshot ] = mock_object @@ -8071,12 +7991,7 @@ async def test_list_active_directories_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_active_directories ] = mock_object @@ -8717,12 +8632,7 @@ async def test_get_active_directory_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_active_directory ] = mock_object @@ -9147,12 +9057,7 @@ async def test_create_active_directory_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_active_directory ] = mock_object @@ -9556,12 +9461,7 @@ async def test_update_active_directory_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_active_directory ] = mock_object @@ -9959,12 +9859,7 @@ async def test_delete_active_directory_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_active_directory ] = mock_object @@ -10351,12 +10246,7 @@ async def test_list_kms_configs_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_kms_configs ] = mock_object @@ -10923,12 +10813,7 @@ async def test_create_kms_config_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_kms_config ] = mock_object @@ -11341,12 +11226,7 @@ async def test_get_kms_config_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_kms_config ] = mock_object @@ -11723,12 +11603,7 @@ async def test_update_kms_config_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_kms_config ] = mock_object @@ -12112,12 +11987,7 @@ async def test_encrypt_volumes_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.encrypt_volumes ] = mock_object @@ -12416,12 +12286,7 @@ async def test_verify_kms_config_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.verify_kms_config ] = mock_object @@ -12722,12 +12587,7 @@ async def test_delete_kms_config_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_kms_config ] = mock_object @@ -13121,12 +12981,7 @@ async def test_list_replications_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_replications ] = mock_object @@ -13730,12 +13585,7 @@ async def test_get_replication_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_replication ] = mock_object @@ -14133,12 +13983,7 @@ async def test_create_replication_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_replication ] = mock_object @@ -14545,12 +14390,7 @@ async def test_delete_replication_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_replication ] = mock_object @@ -14932,12 +14772,7 @@ async def test_update_replication_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_replication ] = mock_object @@ -15324,12 +15159,7 @@ async def test_stop_replication_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.stop_replication ] = mock_object @@ -15623,12 +15453,7 @@ async def test_resume_replication_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.resume_replication ] = mock_object @@ -15929,12 +15754,7 @@ async def test_reverse_replication_direction_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.reverse_replication_direction ] = mock_object @@ -16237,12 +16057,7 @@ async def test_create_backup_vault_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_backup_vault ] = mock_object @@ -16646,12 +16461,7 @@ async def test_get_backup_vault_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_backup_vault ] = mock_object @@ -17040,12 +16850,7 @@ async def test_list_backup_vaults_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_backup_vaults ] = mock_object @@ -17626,12 +17431,7 @@ async def test_update_backup_vault_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_backup_vault ] = mock_object @@ -18028,12 +17828,7 @@ async def test_delete_backup_vault_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_backup_vault ] = mock_object @@ -18409,12 +18204,7 @@ async def test_create_backup_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_backup ] = mock_object @@ -18818,12 +18608,7 @@ async def test_get_backup_async_use_cached_wrapped_rpc(transport: str = "grpc_as ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_backup ] = mock_object @@ -19206,12 +18991,7 @@ async def test_list_backups_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_backups ] = mock_object @@ -19766,12 +19546,7 @@ async def test_delete_backup_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_backup ] = mock_object @@ -20131,12 +19906,7 @@ async def test_update_backup_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_backup ] = mock_object @@ -20524,12 +20294,7 @@ async def test_create_backup_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_backup_policy ] = mock_object @@ -20956,12 +20721,7 @@ async def test_get_backup_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_backup_policy ] = mock_object @@ -21370,12 +21130,7 @@ async def test_list_backup_policies_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_backup_policies ] = mock_object @@ -21957,12 +21712,7 @@ async def test_update_backup_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_backup_policy ] = mock_object @@ -22359,12 +22109,7 @@ async def test_delete_backup_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_backup_policy ] = mock_object diff --git a/packages/google-cloud-network-connectivity/README.rst b/packages/google-cloud-network-connectivity/README.rst index 7d9f75315afd..ab925f3165e0 100644 --- a/packages/google-cloud-network-connectivity/README.rst +++ b/packages/google-cloud-network-connectivity/README.rst @@ -15,7 +15,7 @@ Python Client for Network Connectivity Center .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-network-connectivity.svg :target: https://pypi.org/project/google-cloud-network-connectivity/ .. _Network Connectivity Center: https://cloud.google.com/network-connectivity/ -.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/networkconnectivity/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/networkconnectivity/latest/summary_overview .. _Product Documentation: https://cloud.google.com/network-connectivity/ Quick Start diff --git a/packages/google-cloud-network-connectivity/docs/index.rst b/packages/google-cloud-network-connectivity/docs/index.rst index 4ecfc2a64791..c4f656bd8358 100644 --- a/packages/google-cloud-network-connectivity/docs/index.rst +++ b/packages/google-cloud-network-connectivity/docs/index.rst @@ -32,3 +32,8 @@ For a list of all ``google-cloud-network-connectivity`` releases: :maxdepth: 2 CHANGELOG + +.. toctree:: + :hidden: + + summary_overview.md diff --git a/packages/google-cloud-network-connectivity/docs/summary_overview.md b/packages/google-cloud-network-connectivity/docs/summary_overview.md new file mode 100644 index 000000000000..84fb524985d9 --- /dev/null +++ b/packages/google-cloud-network-connectivity/docs/summary_overview.md @@ -0,0 +1,22 @@ +[ +This is a templated file. Adding content to this file may result in it being +reverted. Instead, if you want to place additional content, create an +"overview_content.md" file in `docs/` directory. The Sphinx tool will +pick up on the content and merge the content. +]: # + +# Network Connectivity Center API + +Overview of the APIs available for Network Connectivity Center API. + +## All entries + +Classes, methods and properties & attributes for +Network Connectivity Center API. + +[classes](https://cloud.google.com/python/docs/reference/networkconnectivity/latest/summary_class.html) + +[methods](https://cloud.google.com/python/docs/reference/networkconnectivity/latest/summary_method.html) + +[properties and +attributes](https://cloud.google.com/python/docs/reference/networkconnectivity/latest/summary_property.html) diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/base.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/base.py index 78c7b684602c..229a690c39ba 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/base.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/base.py @@ -86,6 +86,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -98,7 +100,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc.py index 96756763ac50..096f0c3b2daa 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc.py @@ -130,7 +130,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc_asyncio.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc_asyncio.py index a1100ddfb97d..ed3d0d56de86 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/hub_service/transports/grpc_asyncio.py @@ -177,7 +177,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/transports/base.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/transports/base.py index 4a536ab72905..cbba191c4161 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/transports/base.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/transports/base.py @@ -85,6 +85,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -97,7 +99,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/transports/grpc.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/transports/grpc.py index 94dc004a60ab..99f3bae667cb 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/transports/grpc.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/transports/grpc.py @@ -128,7 +128,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/transports/grpc_asyncio.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/transports/grpc_asyncio.py index 67a4da9f1fd3..011b23d059dc 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1/services/policy_based_routing_service/transports/grpc_asyncio.py @@ -175,7 +175,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/transports/base.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/transports/base.py index f11889b7e4e7..214081ce7b73 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/transports/base.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/transports/base.py @@ -83,6 +83,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -95,7 +97,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/transports/grpc.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/transports/grpc.py index 96d5748073f6..fd220d77566c 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/transports/grpc.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/transports/grpc.py @@ -127,7 +127,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/transports/grpc_asyncio.py b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/transports/grpc_asyncio.py index 72db378ba83d..b23e6d7f2405 100644 --- a/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-network-connectivity/google/cloud/networkconnectivity_v1alpha1/services/hub_service/transports/grpc_asyncio.py @@ -174,7 +174,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-network-connectivity/noxfile.py b/packages/google-cloud-network-connectivity/noxfile.py index 1e6cd48d0529..67b7265f7586 100644 --- a/packages/google-cloud-network-connectivity/noxfile.py +++ b/packages/google-cloud-network-connectivity/noxfile.py @@ -160,14 +160,28 @@ def install_unittest_dependencies(session, *constraints): session.install("-e", ".", *constraints) -def default(session): +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def unit(session, protobuf_implementation): # Install all test dependencies, then install this package in-place. + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) install_unittest_dependencies(session, "-c", constraints_path) + # TODO(https://github.com/googleapis/synthtool/issues/1976): + # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. + # The 'cpp' implementation requires Protobuf<4. + if protobuf_implementation == "cpp": + session.install("protobuf<4") + # Run py.test against the unit tests. session.run( "py.test", @@ -181,15 +195,12 @@ def default(session): "--cov-fail-under=0", os.path.join("tests", "unit"), *session.posargs, + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, ) -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) -def unit(session): - """Run the unit test suite.""" - default(session) - - def install_systemtest_dependencies(session, *constraints): # Use pre-release gRPC for system tests. # Exclude version 1.52.0rc1 which has a known issue. @@ -358,9 +369,16 @@ def docfx(session): @nox.session(python="3.12") -def prerelease_deps(session): +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def prerelease_deps(session, protobuf_implementation): """Run all tests with prerelease versions of dependencies installed.""" + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + # Install all dependencies session.install("-e", ".[all, tests, tracing]") unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES @@ -397,9 +415,9 @@ def prerelease_deps(session): "protobuf", # dependency of grpc "six", + "grpc-google-iam-v1", "googleapis-common-protos", - # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163 - "grpcio!=1.52.0rc1", + "grpcio", "grpcio-status", "google-api-core", "google-auth", @@ -425,4 +443,10 @@ def prerelease_deps(session): session.run("python", "-c", "import grpc; print(grpc.__version__)") session.run("python", "-c", "import google.auth; print(google.auth.__version__)") - session.run("py.test", "tests/unit") + session.run( + "py.test", + "tests/unit", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) diff --git a/packages/google-cloud-network-connectivity/setup.py b/packages/google-cloud-network-connectivity/setup.py index 689612d16875..2989bf22bac2 100644 --- a/packages/google-cloud-network-connectivity/setup.py +++ b/packages/google-cloud-network-connectivity/setup.py @@ -46,7 +46,7 @@ # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", "proto-plus >= 1.22.3, <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", + "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", "grpc-google-iam-v1 >= 0.12.4, <1.0.0dev", ] url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-network-connectivity" diff --git a/packages/google-cloud-network-connectivity/testing/constraints-3.7.txt b/packages/google-cloud-network-connectivity/testing/constraints-3.7.txt index 4cd2782277d4..a81fb6bcd05c 100644 --- a/packages/google-cloud-network-connectivity/testing/constraints-3.7.txt +++ b/packages/google-cloud-network-connectivity/testing/constraints-3.7.txt @@ -7,5 +7,5 @@ google-api-core==1.34.1 google-auth==2.14.1 proto-plus==1.22.3 -protobuf==3.19.5 +protobuf==3.20.2 grpc-google-iam-v1==0.12.4 diff --git a/packages/google-cloud-network-connectivity/tests/unit/gapic/networkconnectivity_v1/test_hub_service.py b/packages/google-cloud-network-connectivity/tests/unit/gapic/networkconnectivity_v1/test_hub_service.py index 8849d705d609..6b3e7c444981 100644 --- a/packages/google-cloud-network-connectivity/tests/unit/gapic/networkconnectivity_v1/test_hub_service.py +++ b/packages/google-cloud-network-connectivity/tests/unit/gapic/networkconnectivity_v1/test_hub_service.py @@ -1242,12 +1242,7 @@ async def test_list_hubs_async_use_cached_wrapped_rpc(transport: str = "grpc_asy ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_hubs ] = mock_object @@ -1813,12 +1808,7 @@ async def test_get_hub_async_use_cached_wrapped_rpc(transport: str = "grpc_async ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_hub ] = mock_object @@ -2187,12 +2177,7 @@ async def test_create_hub_async_use_cached_wrapped_rpc(transport: str = "grpc_as ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_hub ] = mock_object @@ -2574,12 +2559,7 @@ async def test_update_hub_async_use_cached_wrapped_rpc(transport: str = "grpc_as ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_hub ] = mock_object @@ -2953,12 +2933,7 @@ async def test_delete_hub_async_use_cached_wrapped_rpc(transport: str = "grpc_as ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_hub ] = mock_object @@ -3332,12 +3307,7 @@ async def test_list_hub_spokes_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_hub_spokes ] = mock_object @@ -3902,12 +3872,7 @@ async def test_list_spokes_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_spokes ] = mock_object @@ -4479,12 +4444,7 @@ async def test_get_spoke_async_use_cached_wrapped_rpc(transport: str = "grpc_asy ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_spoke ] = mock_object @@ -4859,12 +4819,7 @@ async def test_create_spoke_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_spoke ] = mock_object @@ -5248,12 +5203,7 @@ async def test_update_spoke_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_spoke ] = mock_object @@ -5635,12 +5585,7 @@ async def test_reject_hub_spoke_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.reject_hub_spoke ] = mock_object @@ -6020,12 +5965,7 @@ async def test_accept_hub_spoke_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.accept_hub_spoke ] = mock_object @@ -6401,12 +6341,7 @@ async def test_delete_spoke_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_spoke ] = mock_object @@ -6780,12 +6715,7 @@ async def test_get_route_table_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_route_table ] = mock_object @@ -7170,12 +7100,7 @@ async def test_get_route_async_use_cached_wrapped_rpc(transport: str = "grpc_asy ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_route ] = mock_object @@ -7558,12 +7483,7 @@ async def test_list_routes_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_routes ] = mock_object @@ -8138,12 +8058,7 @@ async def test_list_route_tables_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_route_tables ] = mock_object @@ -8724,12 +8639,7 @@ async def test_get_group_async_use_cached_wrapped_rpc(transport: str = "grpc_asy ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_group ] = mock_object @@ -9104,12 +9014,7 @@ async def test_list_groups_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_groups ] = mock_object diff --git a/packages/google-cloud-network-connectivity/tests/unit/gapic/networkconnectivity_v1/test_policy_based_routing_service.py b/packages/google-cloud-network-connectivity/tests/unit/gapic/networkconnectivity_v1/test_policy_based_routing_service.py index 436c306b3aa4..16421f695ef6 100644 --- a/packages/google-cloud-network-connectivity/tests/unit/gapic/networkconnectivity_v1/test_policy_based_routing_service.py +++ b/packages/google-cloud-network-connectivity/tests/unit/gapic/networkconnectivity_v1/test_policy_based_routing_service.py @@ -1352,12 +1352,7 @@ async def test_list_policy_based_routes_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_policy_based_routes ] = mock_object @@ -1965,12 +1960,7 @@ async def test_get_policy_based_route_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_policy_based_route ] = mock_object @@ -2371,12 +2361,7 @@ async def test_create_policy_based_route_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_policy_based_route ] = mock_object @@ -2810,12 +2795,7 @@ async def test_delete_policy_based_route_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_policy_based_route ] = mock_object diff --git a/packages/google-cloud-network-connectivity/tests/unit/gapic/networkconnectivity_v1alpha1/test_hub_service.py b/packages/google-cloud-network-connectivity/tests/unit/gapic/networkconnectivity_v1alpha1/test_hub_service.py index 27c27df1b5ca..539245527ee9 100644 --- a/packages/google-cloud-network-connectivity/tests/unit/gapic/networkconnectivity_v1alpha1/test_hub_service.py +++ b/packages/google-cloud-network-connectivity/tests/unit/gapic/networkconnectivity_v1alpha1/test_hub_service.py @@ -1238,12 +1238,7 @@ async def test_list_hubs_async_use_cached_wrapped_rpc(transport: str = "grpc_asy ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_hubs ] = mock_object @@ -1809,12 +1804,7 @@ async def test_get_hub_async_use_cached_wrapped_rpc(transport: str = "grpc_async ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_hub ] = mock_object @@ -2183,12 +2173,7 @@ async def test_create_hub_async_use_cached_wrapped_rpc(transport: str = "grpc_as ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_hub ] = mock_object @@ -2570,12 +2555,7 @@ async def test_update_hub_async_use_cached_wrapped_rpc(transport: str = "grpc_as ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_hub ] = mock_object @@ -2949,12 +2929,7 @@ async def test_delete_hub_async_use_cached_wrapped_rpc(transport: str = "grpc_as ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_hub ] = mock_object @@ -3328,12 +3303,7 @@ async def test_list_spokes_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_spokes ] = mock_object @@ -3909,12 +3879,7 @@ async def test_get_spoke_async_use_cached_wrapped_rpc(transport: str = "grpc_asy ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_spoke ] = mock_object @@ -4293,12 +4258,7 @@ async def test_create_spoke_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_spoke ] = mock_object @@ -4682,12 +4642,7 @@ async def test_update_spoke_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_spoke ] = mock_object @@ -5063,12 +5018,7 @@ async def test_delete_spoke_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_spoke ] = mock_object diff --git a/packages/google-cloud-network-management/README.rst b/packages/google-cloud-network-management/README.rst index 8d4a5257e834..8210c6ca3072 100644 --- a/packages/google-cloud-network-management/README.rst +++ b/packages/google-cloud-network-management/README.rst @@ -15,7 +15,7 @@ Python Client for Network Management .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-network-management.svg :target: https://pypi.org/project/google-cloud-network-management/ .. _Network Management: https://cloud.google.com/network-management -.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/networkmanagement/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/networkmanagement/latest/summary_overview .. _Product Documentation: https://cloud.google.com/network-management Quick Start diff --git a/packages/google-cloud-network-management/docs/index.rst b/packages/google-cloud-network-management/docs/index.rst index e303857cb4e4..a905ea00c832 100644 --- a/packages/google-cloud-network-management/docs/index.rst +++ b/packages/google-cloud-network-management/docs/index.rst @@ -21,3 +21,8 @@ For a list of all ``google-cloud-network-management`` releases: :maxdepth: 2 CHANGELOG + +.. toctree:: + :hidden: + + summary_overview.md diff --git a/packages/google-cloud-network-management/docs/summary_overview.md b/packages/google-cloud-network-management/docs/summary_overview.md new file mode 100644 index 000000000000..68ecf8540d59 --- /dev/null +++ b/packages/google-cloud-network-management/docs/summary_overview.md @@ -0,0 +1,22 @@ +[ +This is a templated file. Adding content to this file may result in it being +reverted. Instead, if you want to place additional content, create an +"overview_content.md" file in `docs/` directory. The Sphinx tool will +pick up on the content and merge the content. +]: # + +# Network Management API + +Overview of the APIs available for Network Management API. + +## All entries + +Classes, methods and properties & attributes for +Network Management API. + +[classes](https://cloud.google.com/python/docs/reference/networkmanagement/latest/summary_class.html) + +[methods](https://cloud.google.com/python/docs/reference/networkmanagement/latest/summary_method.html) + +[properties and +attributes](https://cloud.google.com/python/docs/reference/networkmanagement/latest/summary_property.html) diff --git a/packages/google-cloud-network-management/google/cloud/network_management_v1/services/reachability_service/transports/base.py b/packages/google-cloud-network-management/google/cloud/network_management_v1/services/reachability_service/transports/base.py index 7393aaa1450c..dcb162c17712 100644 --- a/packages/google-cloud-network-management/google/cloud/network_management_v1/services/reachability_service/transports/base.py +++ b/packages/google-cloud-network-management/google/cloud/network_management_v1/services/reachability_service/transports/base.py @@ -85,6 +85,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -97,7 +99,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-network-management/google/cloud/network_management_v1/services/reachability_service/transports/grpc.py b/packages/google-cloud-network-management/google/cloud/network_management_v1/services/reachability_service/transports/grpc.py index 996f3c2efb26..47e2877b95ec 100644 --- a/packages/google-cloud-network-management/google/cloud/network_management_v1/services/reachability_service/transports/grpc.py +++ b/packages/google-cloud-network-management/google/cloud/network_management_v1/services/reachability_service/transports/grpc.py @@ -135,7 +135,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-network-management/google/cloud/network_management_v1/services/reachability_service/transports/grpc_asyncio.py b/packages/google-cloud-network-management/google/cloud/network_management_v1/services/reachability_service/transports/grpc_asyncio.py index 9ddd5394fda9..a736f2108156 100644 --- a/packages/google-cloud-network-management/google/cloud/network_management_v1/services/reachability_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-network-management/google/cloud/network_management_v1/services/reachability_service/transports/grpc_asyncio.py @@ -182,7 +182,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-network-management/google/cloud/network_management_v1/types/connectivity_test.py b/packages/google-cloud-network-management/google/cloud/network_management_v1/types/connectivity_test.py index 4f46fe720b10..b500fa10e786 100644 --- a/packages/google-cloud-network-management/google/cloud/network_management_v1/types/connectivity_test.py +++ b/packages/google-cloud-network-management/google/cloud/network_management_v1/types/connectivity_test.py @@ -221,7 +221,7 @@ class Endpoint(proto.Message): provide forwarding information in the control plane. Format: - projects/{project}/global/forwardingRules/{id} + projects/{project}/global/forwardingRules/{id} or projects/{project}/regions/{region}/forwardingRules/{id} forwarding_rule_target (google.cloud.network_management_v1.types.Endpoint.ForwardingRuleTarget): diff --git a/packages/google-cloud-network-management/noxfile.py b/packages/google-cloud-network-management/noxfile.py index 1e6cd48d0529..67b7265f7586 100644 --- a/packages/google-cloud-network-management/noxfile.py +++ b/packages/google-cloud-network-management/noxfile.py @@ -160,14 +160,28 @@ def install_unittest_dependencies(session, *constraints): session.install("-e", ".", *constraints) -def default(session): +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def unit(session, protobuf_implementation): # Install all test dependencies, then install this package in-place. + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) install_unittest_dependencies(session, "-c", constraints_path) + # TODO(https://github.com/googleapis/synthtool/issues/1976): + # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. + # The 'cpp' implementation requires Protobuf<4. + if protobuf_implementation == "cpp": + session.install("protobuf<4") + # Run py.test against the unit tests. session.run( "py.test", @@ -181,15 +195,12 @@ def default(session): "--cov-fail-under=0", os.path.join("tests", "unit"), *session.posargs, + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, ) -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) -def unit(session): - """Run the unit test suite.""" - default(session) - - def install_systemtest_dependencies(session, *constraints): # Use pre-release gRPC for system tests. # Exclude version 1.52.0rc1 which has a known issue. @@ -358,9 +369,16 @@ def docfx(session): @nox.session(python="3.12") -def prerelease_deps(session): +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def prerelease_deps(session, protobuf_implementation): """Run all tests with prerelease versions of dependencies installed.""" + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + # Install all dependencies session.install("-e", ".[all, tests, tracing]") unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES @@ -397,9 +415,9 @@ def prerelease_deps(session): "protobuf", # dependency of grpc "six", + "grpc-google-iam-v1", "googleapis-common-protos", - # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163 - "grpcio!=1.52.0rc1", + "grpcio", "grpcio-status", "google-api-core", "google-auth", @@ -425,4 +443,10 @@ def prerelease_deps(session): session.run("python", "-c", "import grpc; print(grpc.__version__)") session.run("python", "-c", "import google.auth; print(google.auth.__version__)") - session.run("py.test", "tests/unit") + session.run( + "py.test", + "tests/unit", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) diff --git a/packages/google-cloud-network-management/setup.py b/packages/google-cloud-network-management/setup.py index 9d1648c3ef33..af8b754c60e2 100644 --- a/packages/google-cloud-network-management/setup.py +++ b/packages/google-cloud-network-management/setup.py @@ -46,7 +46,7 @@ # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", "proto-plus >= 1.22.3, <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", + "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", "grpc-google-iam-v1 >= 0.12.4, <1.0.0dev", ] url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-network-management" diff --git a/packages/google-cloud-network-management/testing/constraints-3.7.txt b/packages/google-cloud-network-management/testing/constraints-3.7.txt index 4cd2782277d4..a81fb6bcd05c 100644 --- a/packages/google-cloud-network-management/testing/constraints-3.7.txt +++ b/packages/google-cloud-network-management/testing/constraints-3.7.txt @@ -7,5 +7,5 @@ google-api-core==1.34.1 google-auth==2.14.1 proto-plus==1.22.3 -protobuf==3.19.5 +protobuf==3.20.2 grpc-google-iam-v1==0.12.4 diff --git a/packages/google-cloud-network-management/tests/unit/gapic/network_management_v1/test_reachability_service.py b/packages/google-cloud-network-management/tests/unit/gapic/network_management_v1/test_reachability_service.py index f9575d2945d0..f72ee5512658 100644 --- a/packages/google-cloud-network-management/tests/unit/gapic/network_management_v1/test_reachability_service.py +++ b/packages/google-cloud-network-management/tests/unit/gapic/network_management_v1/test_reachability_service.py @@ -1393,12 +1393,7 @@ async def test_list_connectivity_tests_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_connectivity_tests ] = mock_object @@ -2001,12 +1996,7 @@ async def test_get_connectivity_test_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_connectivity_test ] = mock_object @@ -2405,12 +2395,7 @@ async def test_create_connectivity_test_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_connectivity_test ] = mock_object @@ -2814,12 +2799,7 @@ async def test_update_connectivity_test_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_connectivity_test ] = mock_object @@ -3217,12 +3197,7 @@ async def test_rerun_connectivity_test_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.rerun_connectivity_test ] = mock_object @@ -3524,12 +3499,7 @@ async def test_delete_connectivity_test_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_connectivity_test ] = mock_object diff --git a/packages/google-cloud-network-security/README.rst b/packages/google-cloud-network-security/README.rst index d26aa1f37d9e..9e689a9c033a 100644 --- a/packages/google-cloud-network-security/README.rst +++ b/packages/google-cloud-network-security/README.rst @@ -15,7 +15,7 @@ Python Client for Network Security .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-network-security.svg :target: https://pypi.org/project/google-cloud-network-security/ .. _Network Security: https://cloud.google.com/traffic-director/docs/reference/network-security/rest -.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/networksecurity/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/networksecurity/latest/summary_overview .. _Product Documentation: https://cloud.google.com/traffic-director/docs/reference/network-security/rest Quick Start diff --git a/packages/google-cloud-network-security/docs/index.rst b/packages/google-cloud-network-security/docs/index.rst index ed500a63d1d5..adf26cf41af1 100644 --- a/packages/google-cloud-network-security/docs/index.rst +++ b/packages/google-cloud-network-security/docs/index.rst @@ -32,3 +32,8 @@ For a list of all ``google-cloud-network-security`` releases: :maxdepth: 2 CHANGELOG + +.. toctree:: + :hidden: + + summary_overview.md diff --git a/packages/google-cloud-network-security/docs/summary_overview.md b/packages/google-cloud-network-security/docs/summary_overview.md new file mode 100644 index 000000000000..3d814f3f9bec --- /dev/null +++ b/packages/google-cloud-network-security/docs/summary_overview.md @@ -0,0 +1,22 @@ +[ +This is a templated file. Adding content to this file may result in it being +reverted. Instead, if you want to place additional content, create an +"overview_content.md" file in `docs/` directory. The Sphinx tool will +pick up on the content and merge the content. +]: # + +# Network Security API + +Overview of the APIs available for Network Security API. + +## All entries + +Classes, methods and properties & attributes for +Network Security API. + +[classes](https://cloud.google.com/python/docs/reference/networksecurity/latest/summary_class.html) + +[methods](https://cloud.google.com/python/docs/reference/networksecurity/latest/summary_method.html) + +[properties and +attributes](https://cloud.google.com/python/docs/reference/networksecurity/latest/summary_property.html) diff --git a/packages/google-cloud-network-security/google/cloud/network_security_v1/services/network_security/transports/base.py b/packages/google-cloud-network-security/google/cloud/network_security_v1/services/network_security/transports/base.py index d812e45eb736..f5f870afaa84 100644 --- a/packages/google-cloud-network-security/google/cloud/network_security_v1/services/network_security/transports/base.py +++ b/packages/google-cloud-network-security/google/cloud/network_security_v1/services/network_security/transports/base.py @@ -96,6 +96,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -108,7 +110,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-network-security/google/cloud/network_security_v1/services/network_security/transports/grpc.py b/packages/google-cloud-network-security/google/cloud/network_security_v1/services/network_security/transports/grpc.py index 75ab0217c132..cfeeeab2e393 100644 --- a/packages/google-cloud-network-security/google/cloud/network_security_v1/services/network_security/transports/grpc.py +++ b/packages/google-cloud-network-security/google/cloud/network_security_v1/services/network_security/transports/grpc.py @@ -139,7 +139,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-network-security/google/cloud/network_security_v1/services/network_security/transports/grpc_asyncio.py b/packages/google-cloud-network-security/google/cloud/network_security_v1/services/network_security/transports/grpc_asyncio.py index 3c7a07c712cb..db8ffc38a68e 100644 --- a/packages/google-cloud-network-security/google/cloud/network_security_v1/services/network_security/transports/grpc_asyncio.py +++ b/packages/google-cloud-network-security/google/cloud/network_security_v1/services/network_security/transports/grpc_asyncio.py @@ -186,7 +186,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-network-security/google/cloud/network_security_v1beta1/services/network_security/transports/base.py b/packages/google-cloud-network-security/google/cloud/network_security_v1beta1/services/network_security/transports/base.py index 632fb70ffd1d..7de4a3dd374e 100644 --- a/packages/google-cloud-network-security/google/cloud/network_security_v1beta1/services/network_security/transports/base.py +++ b/packages/google-cloud-network-security/google/cloud/network_security_v1beta1/services/network_security/transports/base.py @@ -96,6 +96,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -108,7 +110,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-network-security/google/cloud/network_security_v1beta1/services/network_security/transports/grpc.py b/packages/google-cloud-network-security/google/cloud/network_security_v1beta1/services/network_security/transports/grpc.py index 9bff493a56b1..a7f5ea0994fd 100644 --- a/packages/google-cloud-network-security/google/cloud/network_security_v1beta1/services/network_security/transports/grpc.py +++ b/packages/google-cloud-network-security/google/cloud/network_security_v1beta1/services/network_security/transports/grpc.py @@ -139,7 +139,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-network-security/google/cloud/network_security_v1beta1/services/network_security/transports/grpc_asyncio.py b/packages/google-cloud-network-security/google/cloud/network_security_v1beta1/services/network_security/transports/grpc_asyncio.py index 79df87283a59..9b28d057db43 100644 --- a/packages/google-cloud-network-security/google/cloud/network_security_v1beta1/services/network_security/transports/grpc_asyncio.py +++ b/packages/google-cloud-network-security/google/cloud/network_security_v1beta1/services/network_security/transports/grpc_asyncio.py @@ -186,7 +186,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-network-security/noxfile.py b/packages/google-cloud-network-security/noxfile.py index 1e6cd48d0529..67b7265f7586 100644 --- a/packages/google-cloud-network-security/noxfile.py +++ b/packages/google-cloud-network-security/noxfile.py @@ -160,14 +160,28 @@ def install_unittest_dependencies(session, *constraints): session.install("-e", ".", *constraints) -def default(session): +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def unit(session, protobuf_implementation): # Install all test dependencies, then install this package in-place. + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) install_unittest_dependencies(session, "-c", constraints_path) + # TODO(https://github.com/googleapis/synthtool/issues/1976): + # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. + # The 'cpp' implementation requires Protobuf<4. + if protobuf_implementation == "cpp": + session.install("protobuf<4") + # Run py.test against the unit tests. session.run( "py.test", @@ -181,15 +195,12 @@ def default(session): "--cov-fail-under=0", os.path.join("tests", "unit"), *session.posargs, + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, ) -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) -def unit(session): - """Run the unit test suite.""" - default(session) - - def install_systemtest_dependencies(session, *constraints): # Use pre-release gRPC for system tests. # Exclude version 1.52.0rc1 which has a known issue. @@ -358,9 +369,16 @@ def docfx(session): @nox.session(python="3.12") -def prerelease_deps(session): +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def prerelease_deps(session, protobuf_implementation): """Run all tests with prerelease versions of dependencies installed.""" + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + # Install all dependencies session.install("-e", ".[all, tests, tracing]") unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES @@ -397,9 +415,9 @@ def prerelease_deps(session): "protobuf", # dependency of grpc "six", + "grpc-google-iam-v1", "googleapis-common-protos", - # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163 - "grpcio!=1.52.0rc1", + "grpcio", "grpcio-status", "google-api-core", "google-auth", @@ -425,4 +443,10 @@ def prerelease_deps(session): session.run("python", "-c", "import grpc; print(grpc.__version__)") session.run("python", "-c", "import google.auth; print(google.auth.__version__)") - session.run("py.test", "tests/unit") + session.run( + "py.test", + "tests/unit", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) diff --git a/packages/google-cloud-network-security/setup.py b/packages/google-cloud-network-security/setup.py index 20c00f5f6a19..03978fc9c162 100644 --- a/packages/google-cloud-network-security/setup.py +++ b/packages/google-cloud-network-security/setup.py @@ -46,7 +46,7 @@ # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", "proto-plus >= 1.22.3, <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", + "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", "grpc-google-iam-v1 >= 0.12.4, <1.0.0dev", ] url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-network-security" diff --git a/packages/google-cloud-network-security/testing/constraints-3.7.txt b/packages/google-cloud-network-security/testing/constraints-3.7.txt index 4cd2782277d4..a81fb6bcd05c 100644 --- a/packages/google-cloud-network-security/testing/constraints-3.7.txt +++ b/packages/google-cloud-network-security/testing/constraints-3.7.txt @@ -7,5 +7,5 @@ google-api-core==1.34.1 google-auth==2.14.1 proto-plus==1.22.3 -protobuf==3.19.5 +protobuf==3.20.2 grpc-google-iam-v1==0.12.4 diff --git a/packages/google-cloud-network-security/tests/unit/gapic/network_security_v1/test_network_security.py b/packages/google-cloud-network-security/tests/unit/gapic/network_security_v1/test_network_security.py index d2abcfd520ba..6d6f346e151f 100644 --- a/packages/google-cloud-network-security/tests/unit/gapic/network_security_v1/test_network_security.py +++ b/packages/google-cloud-network-security/tests/unit/gapic/network_security_v1/test_network_security.py @@ -1349,12 +1349,7 @@ async def test_list_authorization_policies_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_authorization_policies ] = mock_object @@ -1950,12 +1945,7 @@ async def test_get_authorization_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_authorization_policy ] = mock_object @@ -2348,12 +2338,7 @@ async def test_create_authorization_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_authorization_policy ] = mock_object @@ -2765,12 +2750,7 @@ async def test_update_authorization_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_authorization_policy ] = mock_object @@ -3176,12 +3156,7 @@ async def test_delete_authorization_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_authorization_policy ] = mock_object @@ -3572,12 +3547,7 @@ async def test_list_server_tls_policies_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_server_tls_policies ] = mock_object @@ -4169,12 +4139,7 @@ async def test_get_server_tls_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_server_tls_policy ] = mock_object @@ -4567,12 +4532,7 @@ async def test_create_server_tls_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_server_tls_policy ] = mock_object @@ -4976,12 +4936,7 @@ async def test_update_server_tls_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_server_tls_policy ] = mock_object @@ -5379,12 +5334,7 @@ async def test_delete_server_tls_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_server_tls_policy ] = mock_object @@ -5775,12 +5725,7 @@ async def test_list_client_tls_policies_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_client_tls_policies ] = mock_object @@ -6372,12 +6317,7 @@ async def test_get_client_tls_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_client_tls_policy ] = mock_object @@ -6770,12 +6710,7 @@ async def test_create_client_tls_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_client_tls_policy ] = mock_object @@ -7179,12 +7114,7 @@ async def test_update_client_tls_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_client_tls_policy ] = mock_object @@ -7582,12 +7512,7 @@ async def test_delete_client_tls_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_client_tls_policy ] = mock_object diff --git a/packages/google-cloud-network-security/tests/unit/gapic/network_security_v1beta1/test_network_security.py b/packages/google-cloud-network-security/tests/unit/gapic/network_security_v1beta1/test_network_security.py index b3f5257f5c48..ad78aa8d9b25 100644 --- a/packages/google-cloud-network-security/tests/unit/gapic/network_security_v1beta1/test_network_security.py +++ b/packages/google-cloud-network-security/tests/unit/gapic/network_security_v1beta1/test_network_security.py @@ -1316,12 +1316,7 @@ async def test_list_authorization_policies_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_authorization_policies ] = mock_object @@ -1917,12 +1912,7 @@ async def test_get_authorization_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_authorization_policy ] = mock_object @@ -2315,12 +2305,7 @@ async def test_create_authorization_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_authorization_policy ] = mock_object @@ -2732,12 +2717,7 @@ async def test_update_authorization_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_authorization_policy ] = mock_object @@ -3143,12 +3123,7 @@ async def test_delete_authorization_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_authorization_policy ] = mock_object @@ -3539,12 +3514,7 @@ async def test_list_server_tls_policies_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_server_tls_policies ] = mock_object @@ -4136,12 +4106,7 @@ async def test_get_server_tls_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_server_tls_policy ] = mock_object @@ -4534,12 +4499,7 @@ async def test_create_server_tls_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_server_tls_policy ] = mock_object @@ -4943,12 +4903,7 @@ async def test_update_server_tls_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_server_tls_policy ] = mock_object @@ -5346,12 +5301,7 @@ async def test_delete_server_tls_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_server_tls_policy ] = mock_object @@ -5742,12 +5692,7 @@ async def test_list_client_tls_policies_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_client_tls_policies ] = mock_object @@ -6339,12 +6284,7 @@ async def test_get_client_tls_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_client_tls_policy ] = mock_object @@ -6737,12 +6677,7 @@ async def test_create_client_tls_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_client_tls_policy ] = mock_object @@ -7146,12 +7081,7 @@ async def test_update_client_tls_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_client_tls_policy ] = mock_object @@ -7549,12 +7479,7 @@ async def test_delete_client_tls_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_client_tls_policy ] = mock_object diff --git a/packages/google-cloud-network-services/README.rst b/packages/google-cloud-network-services/README.rst index f291f5253a93..925ef2bc8feb 100644 --- a/packages/google-cloud-network-services/README.rst +++ b/packages/google-cloud-network-services/README.rst @@ -15,7 +15,7 @@ Python Client for Network Services .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-network-services.svg :target: https://pypi.org/project/google-cloud-network-services/ .. _Network Services: https://cloud.google.com -.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/networkservices/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/networkservices/latest/summary_overview .. _Product Documentation: https://cloud.google.com Quick Start diff --git a/packages/google-cloud-network-services/docs/index.rst b/packages/google-cloud-network-services/docs/index.rst index 614723ccd755..88cf30851edc 100644 --- a/packages/google-cloud-network-services/docs/index.rst +++ b/packages/google-cloud-network-services/docs/index.rst @@ -21,3 +21,8 @@ For a list of all ``google-cloud-network-services`` releases: :maxdepth: 2 CHANGELOG + +.. toctree:: + :hidden: + + summary_overview.md diff --git a/packages/google-cloud-network-services/docs/summary_overview.md b/packages/google-cloud-network-services/docs/summary_overview.md new file mode 100644 index 000000000000..bf4a717c0b09 --- /dev/null +++ b/packages/google-cloud-network-services/docs/summary_overview.md @@ -0,0 +1,22 @@ +[ +This is a templated file. Adding content to this file may result in it being +reverted. Instead, if you want to place additional content, create an +"overview_content.md" file in `docs/` directory. The Sphinx tool will +pick up on the content and merge the content. +]: # + +# Network Services API + +Overview of the APIs available for Network Services API. + +## All entries + +Classes, methods and properties & attributes for +Network Services API. + +[classes](https://cloud.google.com/python/docs/reference/networkservices/latest/summary_class.html) + +[methods](https://cloud.google.com/python/docs/reference/networkservices/latest/summary_method.html) + +[properties and +attributes](https://cloud.google.com/python/docs/reference/networkservices/latest/summary_property.html) diff --git a/packages/google-cloud-network-services/google/cloud/network_services/gapic_version.py b/packages/google-cloud-network-services/google/cloud/network_services/gapic_version.py index cc43a639a105..558c8aab67c5 100644 --- a/packages/google-cloud-network-services/google/cloud/network_services/gapic_version.py +++ b/packages/google-cloud-network-services/google/cloud/network_services/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.5.12" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-network-services/google/cloud/network_services_v1/gapic_version.py b/packages/google-cloud-network-services/google/cloud/network_services_v1/gapic_version.py index cc43a639a105..558c8aab67c5 100644 --- a/packages/google-cloud-network-services/google/cloud/network_services_v1/gapic_version.py +++ b/packages/google-cloud-network-services/google/cloud/network_services_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.5.12" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-network-services/google/cloud/network_services_v1/services/dep_service/transports/base.py b/packages/google-cloud-network-services/google/cloud/network_services_v1/services/dep_service/transports/base.py index c3fadf057c03..1817a5b219d9 100644 --- a/packages/google-cloud-network-services/google/cloud/network_services_v1/services/dep_service/transports/base.py +++ b/packages/google-cloud-network-services/google/cloud/network_services_v1/services/dep_service/transports/base.py @@ -85,6 +85,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -97,7 +99,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-network-services/google/cloud/network_services_v1/services/dep_service/transports/grpc.py b/packages/google-cloud-network-services/google/cloud/network_services_v1/services/dep_service/transports/grpc.py index 3fbd6dfa6128..12c7abda7609 100644 --- a/packages/google-cloud-network-services/google/cloud/network_services_v1/services/dep_service/transports/grpc.py +++ b/packages/google-cloud-network-services/google/cloud/network_services_v1/services/dep_service/transports/grpc.py @@ -126,7 +126,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-network-services/google/cloud/network_services_v1/services/dep_service/transports/grpc_asyncio.py b/packages/google-cloud-network-services/google/cloud/network_services_v1/services/dep_service/transports/grpc_asyncio.py index f4509b3b8f8e..ce3a7c3a8756 100644 --- a/packages/google-cloud-network-services/google/cloud/network_services_v1/services/dep_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-network-services/google/cloud/network_services_v1/services/dep_service/transports/grpc_asyncio.py @@ -173,7 +173,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-network-services/google/cloud/network_services_v1/services/network_services/transports/base.py b/packages/google-cloud-network-services/google/cloud/network_services_v1/services/network_services/transports/base.py index bede93e23140..65313327ec59 100644 --- a/packages/google-cloud-network-services/google/cloud/network_services_v1/services/network_services/transports/base.py +++ b/packages/google-cloud-network-services/google/cloud/network_services_v1/services/network_services/transports/base.py @@ -104,6 +104,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -116,7 +118,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-network-services/google/cloud/network_services_v1/services/network_services/transports/grpc.py b/packages/google-cloud-network-services/google/cloud/network_services_v1/services/network_services/transports/grpc.py index 0b44b15e333b..ef6189627953 100644 --- a/packages/google-cloud-network-services/google/cloud/network_services_v1/services/network_services/transports/grpc.py +++ b/packages/google-cloud-network-services/google/cloud/network_services_v1/services/network_services/transports/grpc.py @@ -145,7 +145,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-network-services/google/cloud/network_services_v1/services/network_services/transports/grpc_asyncio.py b/packages/google-cloud-network-services/google/cloud/network_services_v1/services/network_services/transports/grpc_asyncio.py index 56f0b6376ee3..1f2bec018aef 100644 --- a/packages/google-cloud-network-services/google/cloud/network_services_v1/services/network_services/transports/grpc_asyncio.py +++ b/packages/google-cloud-network-services/google/cloud/network_services_v1/services/network_services/transports/grpc_asyncio.py @@ -192,7 +192,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-network-services/noxfile.py b/packages/google-cloud-network-services/noxfile.py index 1e6cd48d0529..67b7265f7586 100644 --- a/packages/google-cloud-network-services/noxfile.py +++ b/packages/google-cloud-network-services/noxfile.py @@ -160,14 +160,28 @@ def install_unittest_dependencies(session, *constraints): session.install("-e", ".", *constraints) -def default(session): +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def unit(session, protobuf_implementation): # Install all test dependencies, then install this package in-place. + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) install_unittest_dependencies(session, "-c", constraints_path) + # TODO(https://github.com/googleapis/synthtool/issues/1976): + # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. + # The 'cpp' implementation requires Protobuf<4. + if protobuf_implementation == "cpp": + session.install("protobuf<4") + # Run py.test against the unit tests. session.run( "py.test", @@ -181,15 +195,12 @@ def default(session): "--cov-fail-under=0", os.path.join("tests", "unit"), *session.posargs, + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, ) -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) -def unit(session): - """Run the unit test suite.""" - default(session) - - def install_systemtest_dependencies(session, *constraints): # Use pre-release gRPC for system tests. # Exclude version 1.52.0rc1 which has a known issue. @@ -358,9 +369,16 @@ def docfx(session): @nox.session(python="3.12") -def prerelease_deps(session): +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def prerelease_deps(session, protobuf_implementation): """Run all tests with prerelease versions of dependencies installed.""" + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + # Install all dependencies session.install("-e", ".[all, tests, tracing]") unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES @@ -397,9 +415,9 @@ def prerelease_deps(session): "protobuf", # dependency of grpc "six", + "grpc-google-iam-v1", "googleapis-common-protos", - # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163 - "grpcio!=1.52.0rc1", + "grpcio", "grpcio-status", "google-api-core", "google-auth", @@ -425,4 +443,10 @@ def prerelease_deps(session): session.run("python", "-c", "import grpc; print(grpc.__version__)") session.run("python", "-c", "import google.auth; print(google.auth.__version__)") - session.run("py.test", "tests/unit") + session.run( + "py.test", + "tests/unit", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) diff --git a/packages/google-cloud-network-services/samples/generated_samples/snippet_metadata_google.cloud.networkservices.v1.json b/packages/google-cloud-network-services/samples/generated_samples/snippet_metadata_google.cloud.networkservices.v1.json index 3ac26a8ec5dc..5efe8fa4280b 100644 --- a/packages/google-cloud-network-services/samples/generated_samples/snippet_metadata_google.cloud.networkservices.v1.json +++ b/packages/google-cloud-network-services/samples/generated_samples/snippet_metadata_google.cloud.networkservices.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-network-services", - "version": "0.5.12" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-network-services/setup.py b/packages/google-cloud-network-services/setup.py index 9c375b52b72e..ec3290a23788 100644 --- a/packages/google-cloud-network-services/setup.py +++ b/packages/google-cloud-network-services/setup.py @@ -46,7 +46,7 @@ # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", "proto-plus >= 1.22.3, <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", + "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", "grpc-google-iam-v1 >= 0.12.4, <1.0.0dev", ] url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-network-services" diff --git a/packages/google-cloud-network-services/testing/constraints-3.7.txt b/packages/google-cloud-network-services/testing/constraints-3.7.txt index 4cd2782277d4..a81fb6bcd05c 100644 --- a/packages/google-cloud-network-services/testing/constraints-3.7.txt +++ b/packages/google-cloud-network-services/testing/constraints-3.7.txt @@ -7,5 +7,5 @@ google-api-core==1.34.1 google-auth==2.14.1 proto-plus==1.22.3 -protobuf==3.19.5 +protobuf==3.20.2 grpc-google-iam-v1==0.12.4 diff --git a/packages/google-cloud-network-services/tests/unit/gapic/network_services_v1/test_dep_service.py b/packages/google-cloud-network-services/tests/unit/gapic/network_services_v1/test_dep_service.py index 8520369230fd..51be873436a2 100644 --- a/packages/google-cloud-network-services/tests/unit/gapic/network_services_v1/test_dep_service.py +++ b/packages/google-cloud-network-services/tests/unit/gapic/network_services_v1/test_dep_service.py @@ -1280,12 +1280,7 @@ async def test_list_lb_traffic_extensions_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_lb_traffic_extensions ] = mock_object @@ -1881,12 +1876,7 @@ async def test_get_lb_traffic_extension_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_lb_traffic_extension ] = mock_object @@ -2280,12 +2270,7 @@ async def test_create_lb_traffic_extension_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_lb_traffic_extension ] = mock_object @@ -2688,12 +2673,7 @@ async def test_update_lb_traffic_extension_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_lb_traffic_extension ] = mock_object @@ -3090,12 +3070,7 @@ async def test_delete_lb_traffic_extension_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_lb_traffic_extension ] = mock_object @@ -3492,12 +3467,7 @@ async def test_list_lb_route_extensions_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_lb_route_extensions ] = mock_object @@ -4093,12 +4063,7 @@ async def test_get_lb_route_extension_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_lb_route_extension ] = mock_object @@ -4492,12 +4457,7 @@ async def test_create_lb_route_extension_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_lb_route_extension ] = mock_object @@ -4900,12 +4860,7 @@ async def test_update_lb_route_extension_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_lb_route_extension ] = mock_object @@ -5302,12 +5257,7 @@ async def test_delete_lb_route_extension_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_lb_route_extension ] = mock_object diff --git a/packages/google-cloud-network-services/tests/unit/gapic/network_services_v1/test_network_services.py b/packages/google-cloud-network-services/tests/unit/gapic/network_services_v1/test_network_services.py index 7561bcd01d2d..3dca216e1bbc 100644 --- a/packages/google-cloud-network-services/tests/unit/gapic/network_services_v1/test_network_services.py +++ b/packages/google-cloud-network-services/tests/unit/gapic/network_services_v1/test_network_services.py @@ -1357,12 +1357,7 @@ async def test_list_endpoint_policies_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_endpoint_policies ] = mock_object @@ -1965,12 +1960,7 @@ async def test_get_endpoint_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_endpoint_policy ] = mock_object @@ -2372,12 +2362,7 @@ async def test_create_endpoint_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_endpoint_policy ] = mock_object @@ -2781,12 +2766,7 @@ async def test_update_endpoint_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_endpoint_policy ] = mock_object @@ -3184,12 +3164,7 @@ async def test_delete_endpoint_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_endpoint_policy ] = mock_object @@ -3567,12 +3542,7 @@ async def test_list_gateways_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_gateways ] = mock_object @@ -4144,12 +4114,7 @@ async def test_get_gateway_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_gateway ] = mock_object @@ -4522,12 +4487,7 @@ async def test_create_gateway_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_gateway ] = mock_object @@ -4907,12 +4867,7 @@ async def test_update_gateway_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_gateway ] = mock_object @@ -5286,12 +5241,7 @@ async def test_delete_gateway_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_gateway ] = mock_object @@ -5660,12 +5610,7 @@ async def test_list_grpc_routes_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_grpc_routes ] = mock_object @@ -6234,12 +6179,7 @@ async def test_get_grpc_route_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_grpc_route ] = mock_object @@ -6624,12 +6564,7 @@ async def test_create_grpc_route_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_grpc_route ] = mock_object @@ -7029,12 +6964,7 @@ async def test_update_grpc_route_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_grpc_route ] = mock_object @@ -7428,12 +7358,7 @@ async def test_delete_grpc_route_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_grpc_route ] = mock_object @@ -7812,12 +7737,7 @@ async def test_list_http_routes_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_http_routes ] = mock_object @@ -8386,12 +8306,7 @@ async def test_get_http_route_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_http_route ] = mock_object @@ -8776,12 +8691,7 @@ async def test_create_http_route_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_http_route ] = mock_object @@ -9181,12 +9091,7 @@ async def test_update_http_route_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_http_route ] = mock_object @@ -9580,12 +9485,7 @@ async def test_delete_http_route_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_http_route ] = mock_object @@ -9962,12 +9862,7 @@ async def test_list_tcp_routes_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_tcp_routes ] = mock_object @@ -10533,12 +10428,7 @@ async def test_get_tcp_route_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_tcp_route ] = mock_object @@ -10909,12 +10799,7 @@ async def test_create_tcp_route_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_tcp_route ] = mock_object @@ -11296,12 +11181,7 @@ async def test_update_tcp_route_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_tcp_route ] = mock_object @@ -11677,12 +11557,7 @@ async def test_delete_tcp_route_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_tcp_route ] = mock_object @@ -12049,12 +11924,7 @@ async def test_list_tls_routes_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_tls_routes ] = mock_object @@ -12620,12 +12490,7 @@ async def test_get_tls_route_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_tls_route ] = mock_object @@ -12996,12 +12861,7 @@ async def test_create_tls_route_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_tls_route ] = mock_object @@ -13383,12 +13243,7 @@ async def test_update_tls_route_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_tls_route ] = mock_object @@ -13764,12 +13619,7 @@ async def test_delete_tls_route_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_tls_route ] = mock_object @@ -14149,12 +13999,7 @@ async def test_list_service_bindings_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_service_bindings ] = mock_object @@ -14745,12 +14590,7 @@ async def test_get_service_binding_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_service_binding ] = mock_object @@ -15143,12 +14983,7 @@ async def test_create_service_binding_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_service_binding ] = mock_object @@ -15556,12 +15391,7 @@ async def test_delete_service_binding_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_service_binding ] = mock_object @@ -15939,12 +15769,7 @@ async def test_list_meshes_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_meshes ] = mock_object @@ -16505,12 +16330,7 @@ async def test_get_mesh_async_use_cached_wrapped_rpc(transport: str = "grpc_asyn ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_mesh ] = mock_object @@ -16877,12 +16697,7 @@ async def test_create_mesh_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_mesh ] = mock_object @@ -17262,12 +17077,7 @@ async def test_update_mesh_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_mesh ] = mock_object @@ -17641,12 +17451,7 @@ async def test_delete_mesh_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_mesh ] = mock_object diff --git a/packages/google-cloud-notebooks/README.rst b/packages/google-cloud-notebooks/README.rst index ff03d431e82e..552adb66e6b3 100644 --- a/packages/google-cloud-notebooks/README.rst +++ b/packages/google-cloud-notebooks/README.rst @@ -15,7 +15,7 @@ Python Client for AI Platform Notebooks .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-notebooks.svg :target: https://pypi.org/project/google-cloud-notebooks/ .. _AI Platform Notebooks: https://cloud.google.com/ai-platform/notebooks/ -.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/notebooks/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/notebooks/latest/summary_overview .. _Product Documentation: https://cloud.google.com/ai-platform/notebooks/ Quick Start diff --git a/packages/google-cloud-notebooks/docs/index.rst b/packages/google-cloud-notebooks/docs/index.rst index cde8be0c2c5b..be774268933e 100644 --- a/packages/google-cloud-notebooks/docs/index.rst +++ b/packages/google-cloud-notebooks/docs/index.rst @@ -40,3 +40,8 @@ For a list of all ``google-cloud-notebooks`` releases: :maxdepth: 2 CHANGELOG + +.. toctree:: + :hidden: + + summary_overview.md diff --git a/packages/google-cloud-notebooks/docs/summary_overview.md b/packages/google-cloud-notebooks/docs/summary_overview.md new file mode 100644 index 000000000000..4a5c090c9984 --- /dev/null +++ b/packages/google-cloud-notebooks/docs/summary_overview.md @@ -0,0 +1,22 @@ +[ +This is a templated file. Adding content to this file may result in it being +reverted. Instead, if you want to place additional content, create an +"overview_content.md" file in `docs/` directory. The Sphinx tool will +pick up on the content and merge the content. +]: # + +# AI Platform Notebooks API + +Overview of the APIs available for AI Platform Notebooks API. + +## All entries + +Classes, methods and properties & attributes for +AI Platform Notebooks API. + +[classes](https://cloud.google.com/python/docs/reference/notebooks/latest/summary_class.html) + +[methods](https://cloud.google.com/python/docs/reference/notebooks/latest/summary_method.html) + +[properties and +attributes](https://cloud.google.com/python/docs/reference/notebooks/latest/summary_property.html) diff --git a/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/managed_notebook_service/transports/base.py b/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/managed_notebook_service/transports/base.py index 731cd7a96088..5631739a8de8 100644 --- a/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/managed_notebook_service/transports/base.py +++ b/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/managed_notebook_service/transports/base.py @@ -85,6 +85,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -97,7 +99,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/managed_notebook_service/transports/grpc.py b/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/managed_notebook_service/transports/grpc.py index 17faf7906401..dbc66b701e79 100644 --- a/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/managed_notebook_service/transports/grpc.py +++ b/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/managed_notebook_service/transports/grpc.py @@ -126,7 +126,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/managed_notebook_service/transports/grpc_asyncio.py b/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/managed_notebook_service/transports/grpc_asyncio.py index 87f5629db71c..eaa0c7771a56 100644 --- a/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/managed_notebook_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/managed_notebook_service/transports/grpc_asyncio.py @@ -173,7 +173,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/notebook_service/transports/base.py b/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/notebook_service/transports/base.py index 0feb527e97e0..ba31e07a786b 100644 --- a/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/notebook_service/transports/base.py +++ b/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/notebook_service/transports/base.py @@ -91,6 +91,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -103,7 +105,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/notebook_service/transports/grpc.py b/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/notebook_service/transports/grpc.py index 8ddd29c64980..8fef2b90fbf3 100644 --- a/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/notebook_service/transports/grpc.py +++ b/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/notebook_service/transports/grpc.py @@ -132,7 +132,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/notebook_service/transports/grpc_asyncio.py b/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/notebook_service/transports/grpc_asyncio.py index 1497ef2ac993..6765833d4560 100644 --- a/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/notebook_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-notebooks/google/cloud/notebooks_v1/services/notebook_service/transports/grpc_asyncio.py @@ -179,7 +179,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-notebooks/google/cloud/notebooks_v1beta1/services/notebook_service/transports/base.py b/packages/google-cloud-notebooks/google/cloud/notebooks_v1beta1/services/notebook_service/transports/base.py index f6c650dc209c..b3d7c883d223 100644 --- a/packages/google-cloud-notebooks/google/cloud/notebooks_v1beta1/services/notebook_service/transports/base.py +++ b/packages/google-cloud-notebooks/google/cloud/notebooks_v1beta1/services/notebook_service/transports/base.py @@ -85,6 +85,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -97,7 +99,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-notebooks/google/cloud/notebooks_v1beta1/services/notebook_service/transports/grpc.py b/packages/google-cloud-notebooks/google/cloud/notebooks_v1beta1/services/notebook_service/transports/grpc.py index 5ab26138bb41..020352de216a 100644 --- a/packages/google-cloud-notebooks/google/cloud/notebooks_v1beta1/services/notebook_service/transports/grpc.py +++ b/packages/google-cloud-notebooks/google/cloud/notebooks_v1beta1/services/notebook_service/transports/grpc.py @@ -126,7 +126,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-notebooks/google/cloud/notebooks_v1beta1/services/notebook_service/transports/grpc_asyncio.py b/packages/google-cloud-notebooks/google/cloud/notebooks_v1beta1/services/notebook_service/transports/grpc_asyncio.py index 5d6c6e478115..9c3749e1bc8e 100644 --- a/packages/google-cloud-notebooks/google/cloud/notebooks_v1beta1/services/notebook_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-notebooks/google/cloud/notebooks_v1beta1/services/notebook_service/transports/grpc_asyncio.py @@ -173,7 +173,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-notebooks/google/cloud/notebooks_v2/services/notebook_service/transports/base.py b/packages/google-cloud-notebooks/google/cloud/notebooks_v2/services/notebook_service/transports/base.py index 2a9d9a9c5267..ca54c17a61bd 100644 --- a/packages/google-cloud-notebooks/google/cloud/notebooks_v2/services/notebook_service/transports/base.py +++ b/packages/google-cloud-notebooks/google/cloud/notebooks_v2/services/notebook_service/transports/base.py @@ -85,6 +85,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -97,7 +99,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-notebooks/google/cloud/notebooks_v2/services/notebook_service/transports/grpc.py b/packages/google-cloud-notebooks/google/cloud/notebooks_v2/services/notebook_service/transports/grpc.py index 558a87631e43..fa6d6e1416fd 100644 --- a/packages/google-cloud-notebooks/google/cloud/notebooks_v2/services/notebook_service/transports/grpc.py +++ b/packages/google-cloud-notebooks/google/cloud/notebooks_v2/services/notebook_service/transports/grpc.py @@ -126,7 +126,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-notebooks/google/cloud/notebooks_v2/services/notebook_service/transports/grpc_asyncio.py b/packages/google-cloud-notebooks/google/cloud/notebooks_v2/services/notebook_service/transports/grpc_asyncio.py index fd7639006342..6d0bd7218897 100644 --- a/packages/google-cloud-notebooks/google/cloud/notebooks_v2/services/notebook_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-notebooks/google/cloud/notebooks_v2/services/notebook_service/transports/grpc_asyncio.py @@ -173,7 +173,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-notebooks/noxfile.py b/packages/google-cloud-notebooks/noxfile.py index 1e6cd48d0529..67b7265f7586 100644 --- a/packages/google-cloud-notebooks/noxfile.py +++ b/packages/google-cloud-notebooks/noxfile.py @@ -160,14 +160,28 @@ def install_unittest_dependencies(session, *constraints): session.install("-e", ".", *constraints) -def default(session): +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def unit(session, protobuf_implementation): # Install all test dependencies, then install this package in-place. + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) install_unittest_dependencies(session, "-c", constraints_path) + # TODO(https://github.com/googleapis/synthtool/issues/1976): + # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. + # The 'cpp' implementation requires Protobuf<4. + if protobuf_implementation == "cpp": + session.install("protobuf<4") + # Run py.test against the unit tests. session.run( "py.test", @@ -181,15 +195,12 @@ def default(session): "--cov-fail-under=0", os.path.join("tests", "unit"), *session.posargs, + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, ) -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) -def unit(session): - """Run the unit test suite.""" - default(session) - - def install_systemtest_dependencies(session, *constraints): # Use pre-release gRPC for system tests. # Exclude version 1.52.0rc1 which has a known issue. @@ -358,9 +369,16 @@ def docfx(session): @nox.session(python="3.12") -def prerelease_deps(session): +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def prerelease_deps(session, protobuf_implementation): """Run all tests with prerelease versions of dependencies installed.""" + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + # Install all dependencies session.install("-e", ".[all, tests, tracing]") unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES @@ -397,9 +415,9 @@ def prerelease_deps(session): "protobuf", # dependency of grpc "six", + "grpc-google-iam-v1", "googleapis-common-protos", - # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163 - "grpcio!=1.52.0rc1", + "grpcio", "grpcio-status", "google-api-core", "google-auth", @@ -425,4 +443,10 @@ def prerelease_deps(session): session.run("python", "-c", "import grpc; print(grpc.__version__)") session.run("python", "-c", "import google.auth; print(google.auth.__version__)") - session.run("py.test", "tests/unit") + session.run( + "py.test", + "tests/unit", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) diff --git a/packages/google-cloud-notebooks/setup.py b/packages/google-cloud-notebooks/setup.py index 0b64021ea0cb..31c9f61f6433 100644 --- a/packages/google-cloud-notebooks/setup.py +++ b/packages/google-cloud-notebooks/setup.py @@ -44,7 +44,7 @@ # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", "proto-plus >= 1.22.3, <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", + "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", "grpc-google-iam-v1 >= 0.12.4, <1.0.0dev", ] url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-notebooks" diff --git a/packages/google-cloud-notebooks/testing/constraints-3.7.txt b/packages/google-cloud-notebooks/testing/constraints-3.7.txt index 4cd2782277d4..a81fb6bcd05c 100644 --- a/packages/google-cloud-notebooks/testing/constraints-3.7.txt +++ b/packages/google-cloud-notebooks/testing/constraints-3.7.txt @@ -7,5 +7,5 @@ google-api-core==1.34.1 google-auth==2.14.1 proto-plus==1.22.3 -protobuf==3.19.5 +protobuf==3.20.2 grpc-google-iam-v1==0.12.4 diff --git a/packages/google-cloud-notebooks/tests/unit/gapic/notebooks_v1/test_managed_notebook_service.py b/packages/google-cloud-notebooks/tests/unit/gapic/notebooks_v1/test_managed_notebook_service.py index ed5b83eca02b..082e22650dae 100644 --- a/packages/google-cloud-notebooks/tests/unit/gapic/notebooks_v1/test_managed_notebook_service.py +++ b/packages/google-cloud-notebooks/tests/unit/gapic/notebooks_v1/test_managed_notebook_service.py @@ -1328,12 +1328,7 @@ async def test_list_runtimes_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_runtimes ] = mock_object @@ -1895,12 +1890,7 @@ async def test_get_runtime_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_runtime ] = mock_object @@ -2267,12 +2257,7 @@ async def test_create_runtime_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_runtime ] = mock_object @@ -2656,12 +2641,7 @@ async def test_update_runtime_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_runtime ] = mock_object @@ -3037,12 +3017,7 @@ async def test_delete_runtime_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_runtime ] = mock_object @@ -3408,12 +3383,7 @@ async def test_start_runtime_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.start_runtime ] = mock_object @@ -3779,12 +3749,7 @@ async def test_stop_runtime_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.stop_runtime ] = mock_object @@ -4152,12 +4117,7 @@ async def test_switch_runtime_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.switch_runtime ] = mock_object @@ -4523,12 +4483,7 @@ async def test_reset_runtime_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.reset_runtime ] = mock_object @@ -4894,12 +4849,7 @@ async def test_upgrade_runtime_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.upgrade_runtime ] = mock_object @@ -5277,12 +5227,7 @@ async def test_report_runtime_event_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.report_runtime_event ] = mock_object @@ -5673,12 +5618,7 @@ async def test_refresh_runtime_token_internal_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.refresh_runtime_token_internal ] = mock_object @@ -6064,12 +6004,7 @@ async def test_diagnose_runtime_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.diagnose_runtime ] = mock_object diff --git a/packages/google-cloud-notebooks/tests/unit/gapic/notebooks_v1/test_notebook_service.py b/packages/google-cloud-notebooks/tests/unit/gapic/notebooks_v1/test_notebook_service.py index a0cd43e6a216..17e83d3850f4 100644 --- a/packages/google-cloud-notebooks/tests/unit/gapic/notebooks_v1/test_notebook_service.py +++ b/packages/google-cloud-notebooks/tests/unit/gapic/notebooks_v1/test_notebook_service.py @@ -1302,12 +1302,7 @@ async def test_list_instances_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_instances ] = mock_object @@ -1935,12 +1930,7 @@ async def test_get_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_instance ] = mock_object @@ -2349,12 +2339,7 @@ async def test_create_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_instance ] = mock_object @@ -2750,12 +2735,7 @@ async def test_register_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.register_instance ] = mock_object @@ -3056,12 +3036,7 @@ async def test_set_instance_accelerator_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.set_instance_accelerator ] = mock_object @@ -3364,12 +3339,7 @@ async def test_set_instance_machine_type_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.set_instance_machine_type ] = mock_object @@ -3670,12 +3640,7 @@ async def test_update_instance_config_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_instance_config ] = mock_object @@ -3976,12 +3941,7 @@ async def test_update_shielded_instance_config_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_shielded_instance_config ] = mock_object @@ -4282,12 +4242,7 @@ async def test_set_instance_labels_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.set_instance_labels ] = mock_object @@ -4584,12 +4539,7 @@ async def test_update_instance_metadata_items_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_instance_metadata_items ] = mock_object @@ -4874,12 +4824,7 @@ async def test_delete_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_instance ] = mock_object @@ -5243,12 +5188,7 @@ async def test_start_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.start_instance ] = mock_object @@ -5530,12 +5470,7 @@ async def test_stop_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.stop_instance ] = mock_object @@ -5817,12 +5752,7 @@ async def test_reset_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.reset_instance ] = mock_object @@ -6118,12 +6048,7 @@ async def test_report_instance_info_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.report_instance_info ] = mock_object @@ -6434,12 +6359,7 @@ async def test_is_instance_upgradeable_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.is_instance_upgradeable ] = mock_object @@ -6747,12 +6667,7 @@ async def test_get_instance_health_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_instance_health ] = mock_object @@ -7129,12 +7044,7 @@ async def test_upgrade_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.upgrade_instance ] = mock_object @@ -7428,12 +7338,7 @@ async def test_rollback_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.rollback_instance ] = mock_object @@ -7731,12 +7636,7 @@ async def test_diagnose_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.diagnose_instance ] = mock_object @@ -8143,12 +8043,7 @@ async def test_upgrade_instance_internal_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.upgrade_instance_internal ] = mock_object @@ -8452,12 +8347,7 @@ async def test_list_environments_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_environments ] = mock_object @@ -9040,12 +8930,7 @@ async def test_get_environment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_environment ] = mock_object @@ -9428,12 +9313,7 @@ async def test_create_environment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_environment ] = mock_object @@ -9839,12 +9719,7 @@ async def test_delete_environment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_environment ] = mock_object @@ -10228,12 +10103,7 @@ async def test_list_schedules_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_schedules ] = mock_object @@ -10804,12 +10674,7 @@ async def test_get_schedule_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_schedule ] = mock_object @@ -11178,12 +11043,7 @@ async def test_delete_schedule_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_schedule ] = mock_object @@ -11549,12 +11409,7 @@ async def test_create_schedule_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_schedule ] = mock_object @@ -11940,12 +11795,7 @@ async def test_trigger_schedule_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.trigger_schedule ] = mock_object @@ -12237,12 +12087,7 @@ async def test_list_executions_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_executions ] = mock_object @@ -12813,12 +12658,7 @@ async def test_get_execution_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_execution ] = mock_object @@ -13189,12 +13029,7 @@ async def test_delete_execution_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_execution ] = mock_object @@ -13562,12 +13397,7 @@ async def test_create_execution_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_execution ] = mock_object diff --git a/packages/google-cloud-notebooks/tests/unit/gapic/notebooks_v1beta1/test_notebook_service.py b/packages/google-cloud-notebooks/tests/unit/gapic/notebooks_v1beta1/test_notebook_service.py index 9e826bf15fe7..a237cd6fa362 100644 --- a/packages/google-cloud-notebooks/tests/unit/gapic/notebooks_v1beta1/test_notebook_service.py +++ b/packages/google-cloud-notebooks/tests/unit/gapic/notebooks_v1beta1/test_notebook_service.py @@ -1325,12 +1325,7 @@ async def test_list_instances_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_instances ] = mock_object @@ -1867,12 +1862,7 @@ async def test_get_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_instance ] = mock_object @@ -2195,12 +2185,7 @@ async def test_create_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_instance ] = mock_object @@ -2494,12 +2479,7 @@ async def test_register_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.register_instance ] = mock_object @@ -2800,12 +2780,7 @@ async def test_set_instance_accelerator_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.set_instance_accelerator ] = mock_object @@ -3108,12 +3083,7 @@ async def test_set_instance_machine_type_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.set_instance_machine_type ] = mock_object @@ -3413,12 +3383,7 @@ async def test_set_instance_labels_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.set_instance_labels ] = mock_object @@ -3706,12 +3671,7 @@ async def test_delete_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_instance ] = mock_object @@ -3993,12 +3953,7 @@ async def test_start_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.start_instance ] = mock_object @@ -4280,12 +4235,7 @@ async def test_stop_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.stop_instance ] = mock_object @@ -4567,12 +4517,7 @@ async def test_reset_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.reset_instance ] = mock_object @@ -4868,12 +4813,7 @@ async def test_report_instance_info_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.report_instance_info ] = mock_object @@ -5184,12 +5124,7 @@ async def test_is_instance_upgradeable_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.is_instance_upgradeable ] = mock_object @@ -5484,12 +5419,7 @@ async def test_upgrade_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.upgrade_instance ] = mock_object @@ -5786,12 +5716,7 @@ async def test_upgrade_instance_internal_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.upgrade_instance_internal ] = mock_object @@ -6095,12 +6020,7 @@ async def test_list_environments_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_environments ] = mock_object @@ -6597,12 +6517,7 @@ async def test_get_environment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_environment ] = mock_object @@ -6903,12 +6818,7 @@ async def test_create_environment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_environment ] = mock_object @@ -7208,12 +7118,7 @@ async def test_delete_environment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_environment ] = mock_object diff --git a/packages/google-cloud-notebooks/tests/unit/gapic/notebooks_v2/test_notebook_service.py b/packages/google-cloud-notebooks/tests/unit/gapic/notebooks_v2/test_notebook_service.py index 62999d1c70e4..9d50898ffa10 100644 --- a/packages/google-cloud-notebooks/tests/unit/gapic/notebooks_v2/test_notebook_service.py +++ b/packages/google-cloud-notebooks/tests/unit/gapic/notebooks_v2/test_notebook_service.py @@ -1334,12 +1334,7 @@ async def test_list_instances_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_instances ] = mock_object @@ -1916,12 +1911,7 @@ async def test_get_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_instance ] = mock_object @@ -2298,12 +2288,7 @@ async def test_create_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_instance ] = mock_object @@ -2687,12 +2672,7 @@ async def test_update_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_instance ] = mock_object @@ -3068,12 +3048,7 @@ async def test_delete_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_instance ] = mock_object @@ -3437,12 +3412,7 @@ async def test_start_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.start_instance ] = mock_object @@ -3724,12 +3694,7 @@ async def test_stop_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.stop_instance ] = mock_object @@ -4011,12 +3976,7 @@ async def test_reset_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.reset_instance ] = mock_object @@ -4321,12 +4281,7 @@ async def test_check_instance_upgradability_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.check_instance_upgradability ] = mock_object @@ -4622,12 +4577,7 @@ async def test_upgrade_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.upgrade_instance ] = mock_object @@ -4923,12 +4873,7 @@ async def test_rollback_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.rollback_instance ] = mock_object @@ -5226,12 +5171,7 @@ async def test_diagnose_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.diagnose_instance ] = mock_object diff --git a/packages/google-cloud-optimization/README.rst b/packages/google-cloud-optimization/README.rst index b9f40aeedfb9..221c6a586c0e 100644 --- a/packages/google-cloud-optimization/README.rst +++ b/packages/google-cloud-optimization/README.rst @@ -15,7 +15,7 @@ Python Client for Cloud Optimization .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-optimization.svg :target: https://pypi.org/project/google-cloud-optimization/ .. _Cloud Optimization: https://cloud.google.com/optimization/docs -.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/optimization/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/optimization/latest/summary_overview .. _Product Documentation: https://cloud.google.com/optimization/docs Quick Start diff --git a/packages/google-cloud-optimization/docs/index.rst b/packages/google-cloud-optimization/docs/index.rst index c11cc20b201c..0ca984d217cf 100644 --- a/packages/google-cloud-optimization/docs/index.rst +++ b/packages/google-cloud-optimization/docs/index.rst @@ -21,3 +21,8 @@ For a list of all ``google-cloud-optimization`` releases: :maxdepth: 2 CHANGELOG + +.. toctree:: + :hidden: + + summary_overview.md diff --git a/packages/google-cloud-optimization/docs/summary_overview.md b/packages/google-cloud-optimization/docs/summary_overview.md new file mode 100644 index 000000000000..c07a06d842a2 --- /dev/null +++ b/packages/google-cloud-optimization/docs/summary_overview.md @@ -0,0 +1,22 @@ +[ +This is a templated file. Adding content to this file may result in it being +reverted. Instead, if you want to place additional content, create an +"overview_content.md" file in `docs/` directory. The Sphinx tool will +pick up on the content and merge the content. +]: # + +# Cloud Optimization API + +Overview of the APIs available for Cloud Optimization API. + +## All entries + +Classes, methods and properties & attributes for +Cloud Optimization API. + +[classes](https://cloud.google.com/python/docs/reference/optimization/latest/summary_class.html) + +[methods](https://cloud.google.com/python/docs/reference/optimization/latest/summary_method.html) + +[properties and +attributes](https://cloud.google.com/python/docs/reference/optimization/latest/summary_property.html) diff --git a/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/base.py b/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/base.py index a3cc256db261..f9e9b33e3d54 100644 --- a/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/base.py +++ b/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/base.py @@ -82,6 +82,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -94,7 +96,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/grpc.py b/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/grpc.py index 45a34b227e88..07ce13a7de88 100644 --- a/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/grpc.py +++ b/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/grpc.py @@ -145,7 +145,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/grpc_asyncio.py b/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/grpc_asyncio.py index c05c583c7fe0..2fca6fe4acbb 100644 --- a/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/grpc_asyncio.py +++ b/packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/transports/grpc_asyncio.py @@ -192,7 +192,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-optimization/noxfile.py b/packages/google-cloud-optimization/noxfile.py index 1e6cd48d0529..67b7265f7586 100644 --- a/packages/google-cloud-optimization/noxfile.py +++ b/packages/google-cloud-optimization/noxfile.py @@ -160,14 +160,28 @@ def install_unittest_dependencies(session, *constraints): session.install("-e", ".", *constraints) -def default(session): +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def unit(session, protobuf_implementation): # Install all test dependencies, then install this package in-place. + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) install_unittest_dependencies(session, "-c", constraints_path) + # TODO(https://github.com/googleapis/synthtool/issues/1976): + # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. + # The 'cpp' implementation requires Protobuf<4. + if protobuf_implementation == "cpp": + session.install("protobuf<4") + # Run py.test against the unit tests. session.run( "py.test", @@ -181,15 +195,12 @@ def default(session): "--cov-fail-under=0", os.path.join("tests", "unit"), *session.posargs, + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, ) -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) -def unit(session): - """Run the unit test suite.""" - default(session) - - def install_systemtest_dependencies(session, *constraints): # Use pre-release gRPC for system tests. # Exclude version 1.52.0rc1 which has a known issue. @@ -358,9 +369,16 @@ def docfx(session): @nox.session(python="3.12") -def prerelease_deps(session): +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def prerelease_deps(session, protobuf_implementation): """Run all tests with prerelease versions of dependencies installed.""" + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + # Install all dependencies session.install("-e", ".[all, tests, tracing]") unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES @@ -397,9 +415,9 @@ def prerelease_deps(session): "protobuf", # dependency of grpc "six", + "grpc-google-iam-v1", "googleapis-common-protos", - # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163 - "grpcio!=1.52.0rc1", + "grpcio", "grpcio-status", "google-api-core", "google-auth", @@ -425,4 +443,10 @@ def prerelease_deps(session): session.run("python", "-c", "import grpc; print(grpc.__version__)") session.run("python", "-c", "import google.auth; print(google.auth.__version__)") - session.run("py.test", "tests/unit") + session.run( + "py.test", + "tests/unit", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) diff --git a/packages/google-cloud-optimization/setup.py b/packages/google-cloud-optimization/setup.py index 62cf3b5f4bae..60f7997d273a 100644 --- a/packages/google-cloud-optimization/setup.py +++ b/packages/google-cloud-optimization/setup.py @@ -46,7 +46,7 @@ # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", "proto-plus >= 1.22.3, <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", + "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", ] url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-optimization" diff --git a/packages/google-cloud-optimization/testing/constraints-3.7.txt b/packages/google-cloud-optimization/testing/constraints-3.7.txt index b8a550c73855..fc812592b0ee 100644 --- a/packages/google-cloud-optimization/testing/constraints-3.7.txt +++ b/packages/google-cloud-optimization/testing/constraints-3.7.txt @@ -7,4 +7,4 @@ google-api-core==1.34.1 google-auth==2.14.1 proto-plus==1.22.3 -protobuf==3.19.5 +protobuf==3.20.2 diff --git a/packages/google-cloud-optimization/tests/unit/gapic/optimization_v1/test_fleet_routing.py b/packages/google-cloud-optimization/tests/unit/gapic/optimization_v1/test_fleet_routing.py index 99727e4f2474..f97a2c9c89b6 100644 --- a/packages/google-cloud-optimization/tests/unit/gapic/optimization_v1/test_fleet_routing.py +++ b/packages/google-cloud-optimization/tests/unit/gapic/optimization_v1/test_fleet_routing.py @@ -1274,12 +1274,7 @@ async def test_optimize_tours_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.optimize_tours ] = mock_object @@ -1574,12 +1569,7 @@ async def test_batch_optimize_tours_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.batch_optimize_tours ] = mock_object diff --git a/packages/google-cloud-orchestration-airflow/README.rst b/packages/google-cloud-orchestration-airflow/README.rst index 781b3783de18..02df3a98bf97 100644 --- a/packages/google-cloud-orchestration-airflow/README.rst +++ b/packages/google-cloud-orchestration-airflow/README.rst @@ -15,7 +15,7 @@ Python Client for Cloud Composer .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-orchestration-airflow.svg :target: https://pypi.org/project/google-cloud-orchestration-airflow/ .. _Cloud Composer: https://cloud.google.com/composer/ -.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/composer/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/composer/latest/summary_overview .. _Product Documentation: https://cloud.google.com/composer/ Quick Start diff --git a/packages/google-cloud-orchestration-airflow/docs/index.rst b/packages/google-cloud-orchestration-airflow/docs/index.rst index 2d4aabcffab4..15e791890291 100644 --- a/packages/google-cloud-orchestration-airflow/docs/index.rst +++ b/packages/google-cloud-orchestration-airflow/docs/index.rst @@ -32,3 +32,8 @@ For a list of all ``google-cloud-orchestration-airflow`` releases: :maxdepth: 2 CHANGELOG + +.. toctree:: + :hidden: + + summary_overview.md diff --git a/packages/google-cloud-orchestration-airflow/docs/summary_overview.md b/packages/google-cloud-orchestration-airflow/docs/summary_overview.md new file mode 100644 index 000000000000..97a5ddf5ce72 --- /dev/null +++ b/packages/google-cloud-orchestration-airflow/docs/summary_overview.md @@ -0,0 +1,22 @@ +[ +This is a templated file. Adding content to this file may result in it being +reverted. Instead, if you want to place additional content, create an +"overview_content.md" file in `docs/` directory. The Sphinx tool will +pick up on the content and merge the content. +]: # + +# Cloud Composer API + +Overview of the APIs available for Cloud Composer API. + +## All entries + +Classes, methods and properties & attributes for +Cloud Composer API. + +[classes](https://cloud.google.com/python/docs/reference/composer/latest/summary_class.html) + +[methods](https://cloud.google.com/python/docs/reference/composer/latest/summary_method.html) + +[properties and +attributes](https://cloud.google.com/python/docs/reference/composer/latest/summary_property.html) diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/transports/base.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/transports/base.py index d9cdbc5d8aa6..735acee260d9 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/transports/base.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/transports/base.py @@ -85,6 +85,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -97,7 +99,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/transports/grpc.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/transports/grpc.py index ae886e014c32..78c4216a1d96 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/transports/grpc.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/transports/grpc.py @@ -124,7 +124,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/transports/grpc_asyncio.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/transports/grpc_asyncio.py index 150d5ba37553..cbe9ca640a9c 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/transports/grpc_asyncio.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/environments/transports/grpc_asyncio.py @@ -171,7 +171,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/base.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/base.py index 14b66fbf290d..31207ac5dbff 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/base.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/base.py @@ -84,6 +84,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -96,7 +98,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/grpc.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/grpc.py index ce7e45191ee7..f9256deebd89 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/grpc.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/grpc.py @@ -122,7 +122,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/grpc_asyncio.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/grpc_asyncio.py index ccd193c56748..2a9df730fdab 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/grpc_asyncio.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/grpc_asyncio.py @@ -169,7 +169,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/base.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/base.py index 76f3750ced3d..4c29bd8a7e28 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/base.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/base.py @@ -85,6 +85,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -97,7 +99,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/grpc.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/grpc.py index 6a5cf8b834ee..6acb73c34b4e 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/grpc.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/grpc.py @@ -124,7 +124,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/grpc_asyncio.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/grpc_asyncio.py index bd199fcb4b45..30fd40a7608e 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/grpc_asyncio.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/grpc_asyncio.py @@ -171,7 +171,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/base.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/base.py index af5baecbacbc..ae17dc14d81f 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/base.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/base.py @@ -84,6 +84,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -96,7 +98,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/grpc.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/grpc.py index ee76070cf608..fdb8735fc30e 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/grpc.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/grpc.py @@ -122,7 +122,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/grpc_asyncio.py b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/grpc_asyncio.py index 4e45ac3491d1..4544ba73e7a5 100644 --- a/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/grpc_asyncio.py +++ b/packages/google-cloud-orchestration-airflow/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/grpc_asyncio.py @@ -169,7 +169,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-orchestration-airflow/noxfile.py b/packages/google-cloud-orchestration-airflow/noxfile.py index 1e6cd48d0529..67b7265f7586 100644 --- a/packages/google-cloud-orchestration-airflow/noxfile.py +++ b/packages/google-cloud-orchestration-airflow/noxfile.py @@ -160,14 +160,28 @@ def install_unittest_dependencies(session, *constraints): session.install("-e", ".", *constraints) -def default(session): +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def unit(session, protobuf_implementation): # Install all test dependencies, then install this package in-place. + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) install_unittest_dependencies(session, "-c", constraints_path) + # TODO(https://github.com/googleapis/synthtool/issues/1976): + # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. + # The 'cpp' implementation requires Protobuf<4. + if protobuf_implementation == "cpp": + session.install("protobuf<4") + # Run py.test against the unit tests. session.run( "py.test", @@ -181,15 +195,12 @@ def default(session): "--cov-fail-under=0", os.path.join("tests", "unit"), *session.posargs, + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, ) -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) -def unit(session): - """Run the unit test suite.""" - default(session) - - def install_systemtest_dependencies(session, *constraints): # Use pre-release gRPC for system tests. # Exclude version 1.52.0rc1 which has a known issue. @@ -358,9 +369,16 @@ def docfx(session): @nox.session(python="3.12") -def prerelease_deps(session): +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def prerelease_deps(session, protobuf_implementation): """Run all tests with prerelease versions of dependencies installed.""" + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + # Install all dependencies session.install("-e", ".[all, tests, tracing]") unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES @@ -397,9 +415,9 @@ def prerelease_deps(session): "protobuf", # dependency of grpc "six", + "grpc-google-iam-v1", "googleapis-common-protos", - # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163 - "grpcio!=1.52.0rc1", + "grpcio", "grpcio-status", "google-api-core", "google-auth", @@ -425,4 +443,10 @@ def prerelease_deps(session): session.run("python", "-c", "import grpc; print(grpc.__version__)") session.run("python", "-c", "import google.auth; print(google.auth.__version__)") - session.run("py.test", "tests/unit") + session.run( + "py.test", + "tests/unit", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) diff --git a/packages/google-cloud-orchestration-airflow/setup.py b/packages/google-cloud-orchestration-airflow/setup.py index 26ad35d8146b..94964825473e 100644 --- a/packages/google-cloud-orchestration-airflow/setup.py +++ b/packages/google-cloud-orchestration-airflow/setup.py @@ -48,7 +48,7 @@ # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", "proto-plus >= 1.22.3, <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", + "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", ] url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-orchestration-airflow" diff --git a/packages/google-cloud-orchestration-airflow/testing/constraints-3.7.txt b/packages/google-cloud-orchestration-airflow/testing/constraints-3.7.txt index b8a550c73855..fc812592b0ee 100644 --- a/packages/google-cloud-orchestration-airflow/testing/constraints-3.7.txt +++ b/packages/google-cloud-orchestration-airflow/testing/constraints-3.7.txt @@ -7,4 +7,4 @@ google-api-core==1.34.1 google-auth==2.14.1 proto-plus==1.22.3 -protobuf==3.19.5 +protobuf==3.20.2 diff --git a/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1/test_environments.py b/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1/test_environments.py index 5655d2c079ee..075210baac64 100644 --- a/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1/test_environments.py +++ b/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1/test_environments.py @@ -1281,12 +1281,7 @@ async def test_create_environment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_environment ] = mock_object @@ -1680,12 +1675,7 @@ async def test_get_environment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_environment ] = mock_object @@ -2067,12 +2057,7 @@ async def test_list_environments_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_environments ] = mock_object @@ -2655,12 +2640,7 @@ async def test_update_environment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_environment ] = mock_object @@ -3066,12 +3046,7 @@ async def test_delete_environment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_environment ] = mock_object @@ -3472,12 +3447,7 @@ async def test_execute_airflow_command_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.execute_airflow_command ] = mock_object @@ -3793,12 +3763,7 @@ async def test_stop_airflow_command_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.stop_airflow_command ] = mock_object @@ -4106,12 +4071,7 @@ async def test_poll_airflow_command_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.poll_airflow_command ] = mock_object @@ -4403,12 +4363,7 @@ async def test_list_workloads_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_workloads ] = mock_object @@ -4981,12 +4936,7 @@ async def test_create_user_workloads_secret_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_user_workloads_secret ] = mock_object @@ -5384,12 +5334,7 @@ async def test_get_user_workloads_secret_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_user_workloads_secret ] = mock_object @@ -5779,12 +5724,7 @@ async def test_list_user_workloads_secrets_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_user_workloads_secrets ] = mock_object @@ -6366,12 +6306,7 @@ async def test_update_user_workloads_secret_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_user_workloads_secret ] = mock_object @@ -6752,12 +6687,7 @@ async def test_delete_user_workloads_secret_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_user_workloads_secret ] = mock_object @@ -7136,12 +7066,7 @@ async def test_create_user_workloads_config_map_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_user_workloads_config_map ] = mock_object @@ -7547,12 +7472,7 @@ async def test_get_user_workloads_config_map_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_user_workloads_config_map ] = mock_object @@ -7942,12 +7862,7 @@ async def test_list_user_workloads_config_maps_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_user_workloads_config_maps ] = mock_object @@ -8531,12 +8446,7 @@ async def test_update_user_workloads_config_map_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_user_workloads_config_map ] = mock_object @@ -8925,12 +8835,7 @@ async def test_delete_user_workloads_config_map_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_user_workloads_config_map ] = mock_object @@ -9297,12 +9202,7 @@ async def test_save_snapshot_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.save_snapshot ] = mock_object @@ -9586,12 +9486,7 @@ async def test_load_snapshot_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.load_snapshot ] = mock_object @@ -9883,12 +9778,7 @@ async def test_database_failover_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.database_failover ] = mock_object @@ -10196,12 +10086,7 @@ async def test_fetch_database_properties_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.fetch_database_properties ] = mock_object diff --git a/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1/test_image_versions.py b/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1/test_image_versions.py index c7bfdc3319a4..1cb3ce65feef 100644 --- a/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1/test_image_versions.py +++ b/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1/test_image_versions.py @@ -1291,12 +1291,7 @@ async def test_list_image_versions_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_image_versions ] = mock_object diff --git a/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1beta1/test_environments.py b/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1beta1/test_environments.py index 5b0c6ad52bfc..3065d1a2d3eb 100644 --- a/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1beta1/test_environments.py +++ b/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1beta1/test_environments.py @@ -1284,12 +1284,7 @@ async def test_create_environment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_environment ] = mock_object @@ -1683,12 +1678,7 @@ async def test_get_environment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_environment ] = mock_object @@ -2070,12 +2060,7 @@ async def test_list_environments_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_environments ] = mock_object @@ -2658,12 +2643,7 @@ async def test_update_environment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_environment ] = mock_object @@ -3069,12 +3049,7 @@ async def test_delete_environment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_environment ] = mock_object @@ -3460,12 +3435,7 @@ async def test_restart_web_server_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.restart_web_server ] = mock_object @@ -3755,12 +3725,7 @@ async def test_check_upgrade_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.check_upgrade ] = mock_object @@ -4069,12 +4034,7 @@ async def test_execute_airflow_command_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.execute_airflow_command ] = mock_object @@ -4390,12 +4350,7 @@ async def test_stop_airflow_command_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.stop_airflow_command ] = mock_object @@ -4703,12 +4658,7 @@ async def test_poll_airflow_command_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.poll_airflow_command ] = mock_object @@ -5000,12 +4950,7 @@ async def test_list_workloads_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_workloads ] = mock_object @@ -5578,12 +5523,7 @@ async def test_create_user_workloads_secret_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_user_workloads_secret ] = mock_object @@ -5981,12 +5921,7 @@ async def test_get_user_workloads_secret_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_user_workloads_secret ] = mock_object @@ -6376,12 +6311,7 @@ async def test_list_user_workloads_secrets_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_user_workloads_secrets ] = mock_object @@ -6963,12 +6893,7 @@ async def test_update_user_workloads_secret_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_user_workloads_secret ] = mock_object @@ -7349,12 +7274,7 @@ async def test_delete_user_workloads_secret_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_user_workloads_secret ] = mock_object @@ -7733,12 +7653,7 @@ async def test_create_user_workloads_config_map_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_user_workloads_config_map ] = mock_object @@ -8144,12 +8059,7 @@ async def test_get_user_workloads_config_map_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_user_workloads_config_map ] = mock_object @@ -8539,12 +8449,7 @@ async def test_list_user_workloads_config_maps_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_user_workloads_config_maps ] = mock_object @@ -9128,12 +9033,7 @@ async def test_update_user_workloads_config_map_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_user_workloads_config_map ] = mock_object @@ -9522,12 +9422,7 @@ async def test_delete_user_workloads_config_map_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_user_workloads_config_map ] = mock_object @@ -9894,12 +9789,7 @@ async def test_save_snapshot_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.save_snapshot ] = mock_object @@ -10183,12 +10073,7 @@ async def test_load_snapshot_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.load_snapshot ] = mock_object @@ -10480,12 +10365,7 @@ async def test_database_failover_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.database_failover ] = mock_object @@ -10793,12 +10673,7 @@ async def test_fetch_database_properties_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.fetch_database_properties ] = mock_object diff --git a/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1beta1/test_image_versions.py b/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1beta1/test_image_versions.py index ba178970a565..982d4c632779 100644 --- a/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1beta1/test_image_versions.py +++ b/packages/google-cloud-orchestration-airflow/tests/unit/gapic/service_v1beta1/test_image_versions.py @@ -1291,12 +1291,7 @@ async def test_list_image_versions_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_image_versions ] = mock_object diff --git a/packages/google-cloud-os-config/README.rst b/packages/google-cloud-os-config/README.rst index 067a953263fe..b35008061713 100644 --- a/packages/google-cloud-os-config/README.rst +++ b/packages/google-cloud-os-config/README.rst @@ -15,7 +15,7 @@ Python Client for OS Config .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-os-config.svg :target: https://pypi.org/project/google-cloud-os-config/ .. _OS Config: https://cloud.google.com/compute/docs/manage-os -.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/osconfig/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/osconfig/latest/summary_overview .. _Product Documentation: https://cloud.google.com/compute/docs/manage-os Quick Start diff --git a/packages/google-cloud-os-config/docs/index.rst b/packages/google-cloud-os-config/docs/index.rst index 82c6942d7f64..4b5bf92d7d51 100644 --- a/packages/google-cloud-os-config/docs/index.rst +++ b/packages/google-cloud-os-config/docs/index.rst @@ -32,3 +32,8 @@ For a list of all ``google-cloud-os-config`` releases: :maxdepth: 2 CHANGELOG + +.. toctree:: + :hidden: + + summary_overview.md diff --git a/packages/google-cloud-os-config/docs/summary_overview.md b/packages/google-cloud-os-config/docs/summary_overview.md new file mode 100644 index 000000000000..4c20af4b4838 --- /dev/null +++ b/packages/google-cloud-os-config/docs/summary_overview.md @@ -0,0 +1,22 @@ +[ +This is a templated file. Adding content to this file may result in it being +reverted. Instead, if you want to place additional content, create an +"overview_content.md" file in `docs/` directory. The Sphinx tool will +pick up on the content and merge the content. +]: # + +# OS Config API + +Overview of the APIs available for OS Config API. + +## All entries + +Classes, methods and properties & attributes for +OS Config API. + +[classes](https://cloud.google.com/python/docs/reference/osconfig/latest/summary_class.html) + +[methods](https://cloud.google.com/python/docs/reference/osconfig/latest/summary_method.html) + +[properties and +attributes](https://cloud.google.com/python/docs/reference/osconfig/latest/summary_property.html) diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/base.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/base.py index 9978f1d5cc87..1cf3331629d7 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/base.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/base.py @@ -82,6 +82,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -94,7 +96,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc.py index f86eaebe6e28..f39ce31eb33b 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc.py @@ -126,7 +126,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc_asyncio.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc_asyncio.py index 52ef93039807..96a20717509d 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc_asyncio.py @@ -173,7 +173,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/base.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/base.py index 1d7e65e00cd3..2d062afada79 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/base.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/base.py @@ -87,6 +87,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -99,7 +101,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/grpc.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/grpc.py index 88b7dfe6edba..b7e66e6c4240 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/grpc.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/grpc.py @@ -132,7 +132,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/grpc_asyncio.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/grpc_asyncio.py index a1d00e519502..de12396beb27 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_zonal_service/transports/grpc_asyncio.py @@ -179,7 +179,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/base.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/base.py index ee3151198420..685223f68bc3 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/base.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/base.py @@ -88,6 +88,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -100,7 +102,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/grpc.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/grpc.py index 3f957bd7faf9..e76fe82fc2bc 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/grpc.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/grpc.py @@ -133,7 +133,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/grpc_asyncio.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/grpc_asyncio.py index ec7c9ab7044f..f9b384cbc319 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/grpc_asyncio.py @@ -180,7 +180,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-os-config/noxfile.py b/packages/google-cloud-os-config/noxfile.py index 1e6cd48d0529..67b7265f7586 100644 --- a/packages/google-cloud-os-config/noxfile.py +++ b/packages/google-cloud-os-config/noxfile.py @@ -160,14 +160,28 @@ def install_unittest_dependencies(session, *constraints): session.install("-e", ".", *constraints) -def default(session): +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def unit(session, protobuf_implementation): # Install all test dependencies, then install this package in-place. + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) install_unittest_dependencies(session, "-c", constraints_path) + # TODO(https://github.com/googleapis/synthtool/issues/1976): + # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. + # The 'cpp' implementation requires Protobuf<4. + if protobuf_implementation == "cpp": + session.install("protobuf<4") + # Run py.test against the unit tests. session.run( "py.test", @@ -181,15 +195,12 @@ def default(session): "--cov-fail-under=0", os.path.join("tests", "unit"), *session.posargs, + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, ) -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) -def unit(session): - """Run the unit test suite.""" - default(session) - - def install_systemtest_dependencies(session, *constraints): # Use pre-release gRPC for system tests. # Exclude version 1.52.0rc1 which has a known issue. @@ -358,9 +369,16 @@ def docfx(session): @nox.session(python="3.12") -def prerelease_deps(session): +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def prerelease_deps(session, protobuf_implementation): """Run all tests with prerelease versions of dependencies installed.""" + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + # Install all dependencies session.install("-e", ".[all, tests, tracing]") unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES @@ -397,9 +415,9 @@ def prerelease_deps(session): "protobuf", # dependency of grpc "six", + "grpc-google-iam-v1", "googleapis-common-protos", - # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163 - "grpcio!=1.52.0rc1", + "grpcio", "grpcio-status", "google-api-core", "google-auth", @@ -425,4 +443,10 @@ def prerelease_deps(session): session.run("python", "-c", "import grpc; print(grpc.__version__)") session.run("python", "-c", "import google.auth; print(google.auth.__version__)") - session.run("py.test", "tests/unit") + session.run( + "py.test", + "tests/unit", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) diff --git a/packages/google-cloud-os-config/setup.py b/packages/google-cloud-os-config/setup.py index e79936d49da2..c18b9052cfa7 100644 --- a/packages/google-cloud-os-config/setup.py +++ b/packages/google-cloud-os-config/setup.py @@ -44,7 +44,7 @@ # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", "proto-plus >= 1.22.3, <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", + "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", ] url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-os-config" diff --git a/packages/google-cloud-os-config/testing/constraints-3.7.txt b/packages/google-cloud-os-config/testing/constraints-3.7.txt index b8a550c73855..fc812592b0ee 100644 --- a/packages/google-cloud-os-config/testing/constraints-3.7.txt +++ b/packages/google-cloud-os-config/testing/constraints-3.7.txt @@ -7,4 +7,4 @@ google-api-core==1.34.1 google-auth==2.14.1 proto-plus==1.22.3 -protobuf==3.19.5 +protobuf==3.20.2 diff --git a/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/test_os_config_service.py b/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/test_os_config_service.py index 3d893556e952..d053aa016536 100644 --- a/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/test_os_config_service.py +++ b/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/test_os_config_service.py @@ -1349,12 +1349,7 @@ async def test_execute_patch_job_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.execute_patch_job ] = mock_object @@ -1675,12 +1670,7 @@ async def test_get_patch_job_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_patch_job ] = mock_object @@ -2077,12 +2067,7 @@ async def test_cancel_patch_job_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.cancel_patch_job ] = mock_object @@ -2380,12 +2365,7 @@ async def test_list_patch_jobs_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_patch_jobs ] = mock_object @@ -2956,12 +2936,7 @@ async def test_list_patch_job_instance_details_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_patch_job_instance_details ] = mock_object @@ -3555,12 +3530,7 @@ async def test_create_patch_deployment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_patch_deployment ] = mock_object @@ -3977,12 +3947,7 @@ async def test_get_patch_deployment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_patch_deployment ] = mock_object @@ -4376,12 +4341,7 @@ async def test_list_patch_deployments_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_patch_deployments ] = mock_object @@ -4960,12 +4920,7 @@ async def test_delete_patch_deployment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_patch_deployment ] = mock_object @@ -5346,12 +5301,7 @@ async def test_update_patch_deployment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_patch_deployment ] = mock_object @@ -5759,12 +5709,7 @@ async def test_pause_patch_deployment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.pause_patch_deployment ] = mock_object @@ -6162,12 +6107,7 @@ async def test_resume_patch_deployment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.resume_patch_deployment ] = mock_object diff --git a/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/test_os_config_zonal_service.py b/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/test_os_config_zonal_service.py index ba4c23bc42f6..7d1a994d5beb 100644 --- a/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/test_os_config_zonal_service.py +++ b/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/test_os_config_zonal_service.py @@ -1383,12 +1383,7 @@ async def test_create_os_policy_assignment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_os_policy_assignment ] = mock_object @@ -1800,12 +1795,7 @@ async def test_update_os_policy_assignment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_os_policy_assignment ] = mock_object @@ -2239,12 +2229,7 @@ async def test_get_os_policy_assignment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_os_policy_assignment ] = mock_object @@ -2653,12 +2638,7 @@ async def test_list_os_policy_assignments_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_os_policy_assignments ] = mock_object @@ -3252,12 +3232,7 @@ async def test_list_os_policy_assignment_revisions_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_os_policy_assignment_revisions ] = mock_object @@ -3852,12 +3827,7 @@ async def test_delete_os_policy_assignment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_os_policy_assignment ] = mock_object @@ -4261,12 +4231,7 @@ async def test_get_os_policy_assignment_report_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_os_policy_assignment_report ] = mock_object @@ -4674,12 +4639,7 @@ async def test_list_os_policy_assignment_reports_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_os_policy_assignment_reports ] = mock_object @@ -5264,12 +5224,7 @@ async def test_get_inventory_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_inventory ] = mock_object @@ -5635,12 +5590,7 @@ async def test_list_inventories_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_inventories ] = mock_object @@ -6207,12 +6157,7 @@ async def test_get_vulnerability_report_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_vulnerability_report ] = mock_object @@ -6604,12 +6549,7 @@ async def test_list_vulnerability_reports_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_vulnerability_reports ] = mock_object diff --git a/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1alpha/test_os_config_zonal_service.py b/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1alpha/test_os_config_zonal_service.py index d4afeabd98bf..7cbed50451a0 100644 --- a/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1alpha/test_os_config_zonal_service.py +++ b/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1alpha/test_os_config_zonal_service.py @@ -1385,12 +1385,7 @@ async def test_create_os_policy_assignment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_os_policy_assignment ] = mock_object @@ -1802,12 +1797,7 @@ async def test_update_os_policy_assignment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_os_policy_assignment ] = mock_object @@ -2241,12 +2231,7 @@ async def test_get_os_policy_assignment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_os_policy_assignment ] = mock_object @@ -2655,12 +2640,7 @@ async def test_list_os_policy_assignments_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_os_policy_assignments ] = mock_object @@ -3254,12 +3234,7 @@ async def test_list_os_policy_assignment_revisions_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_os_policy_assignment_revisions ] = mock_object @@ -3854,12 +3829,7 @@ async def test_delete_os_policy_assignment_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_os_policy_assignment ] = mock_object @@ -4277,12 +4247,7 @@ async def test_get_instance_os_policies_compliance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_instance_os_policies_compliance ] = mock_object @@ -4706,12 +4671,7 @@ async def test_list_instance_os_policies_compliances_async_use_cached_wrapped_rp ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_instance_os_policies_compliances ] = mock_object @@ -5326,12 +5286,7 @@ async def test_get_os_policy_assignment_report_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_os_policy_assignment_report ] = mock_object @@ -5739,12 +5694,7 @@ async def test_list_os_policy_assignment_reports_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_os_policy_assignment_reports ] = mock_object @@ -6329,12 +6279,7 @@ async def test_get_inventory_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_inventory ] = mock_object @@ -6700,12 +6645,7 @@ async def test_list_inventories_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_inventories ] = mock_object @@ -7272,12 +7212,7 @@ async def test_get_vulnerability_report_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_vulnerability_report ] = mock_object @@ -7669,12 +7604,7 @@ async def test_list_vulnerability_reports_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_vulnerability_reports ] = mock_object diff --git a/packages/google-cloud-os-login/google/cloud/oslogin/gapic_version.py b/packages/google-cloud-os-login/google/cloud/oslogin/gapic_version.py index e37a1814aa29..558c8aab67c5 100644 --- a/packages/google-cloud-os-login/google/cloud/oslogin/gapic_version.py +++ b/packages/google-cloud-os-login/google/cloud/oslogin/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.14.4" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-os-login/google/cloud/oslogin_v1/gapic_version.py b/packages/google-cloud-os-login/google/cloud/oslogin_v1/gapic_version.py index e37a1814aa29..558c8aab67c5 100644 --- a/packages/google-cloud-os-login/google/cloud/oslogin_v1/gapic_version.py +++ b/packages/google-cloud-os-login/google/cloud/oslogin_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.14.4" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/base.py b/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/base.py index c3b1b25a2c57..72b97182d80c 100644 --- a/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/base.py +++ b/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/base.py @@ -88,6 +88,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -100,7 +102,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/grpc.py b/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/grpc.py index 84a7bda22f73..c039c044aad3 100644 --- a/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/grpc.py +++ b/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/grpc.py @@ -127,7 +127,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/grpc_asyncio.py b/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/grpc_asyncio.py index 0e9957332246..17425643447a 100644 --- a/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-os-login/google/cloud/oslogin_v1/services/os_login_service/transports/grpc_asyncio.py @@ -174,7 +174,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-os-login/samples/generated_samples/snippet_metadata_google.cloud.oslogin.v1.json b/packages/google-cloud-os-login/samples/generated_samples/snippet_metadata_google.cloud.oslogin.v1.json index 3de8efd2a769..92b367f767a3 100644 --- a/packages/google-cloud-os-login/samples/generated_samples/snippet_metadata_google.cloud.oslogin.v1.json +++ b/packages/google-cloud-os-login/samples/generated_samples/snippet_metadata_google.cloud.oslogin.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-os-login", - "version": "2.14.4" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-os-login/setup.py b/packages/google-cloud-os-login/setup.py index ae2e32f181a6..c395b1ea84fc 100644 --- a/packages/google-cloud-os-login/setup.py +++ b/packages/google-cloud-os-login/setup.py @@ -44,7 +44,7 @@ # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", "proto-plus >= 1.22.3, <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", + "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", ] url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-os-login" diff --git a/packages/google-cloud-os-login/testing/constraints-3.7.txt b/packages/google-cloud-os-login/testing/constraints-3.7.txt index b8a550c73855..fc812592b0ee 100644 --- a/packages/google-cloud-os-login/testing/constraints-3.7.txt +++ b/packages/google-cloud-os-login/testing/constraints-3.7.txt @@ -7,4 +7,4 @@ google-api-core==1.34.1 google-auth==2.14.1 proto-plus==1.22.3 -protobuf==3.19.5 +protobuf==3.20.2 diff --git a/packages/google-cloud-os-login/tests/unit/gapic/oslogin_v1/test_os_login_service.py b/packages/google-cloud-os-login/tests/unit/gapic/oslogin_v1/test_os_login_service.py index 4ecc11beaf7e..c5ffea0b2182 100644 --- a/packages/google-cloud-os-login/tests/unit/gapic/oslogin_v1/test_os_login_service.py +++ b/packages/google-cloud-os-login/tests/unit/gapic/oslogin_v1/test_os_login_service.py @@ -1312,12 +1312,7 @@ async def test_create_ssh_public_key_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_ssh_public_key ] = mock_object @@ -1708,12 +1703,7 @@ async def test_delete_posix_account_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_posix_account ] = mock_object @@ -2084,12 +2074,7 @@ async def test_delete_ssh_public_key_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_ssh_public_key ] = mock_object @@ -2468,12 +2453,7 @@ async def test_get_login_profile_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_login_profile ] = mock_object @@ -2868,12 +2848,7 @@ async def test_get_ssh_public_key_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_ssh_public_key ] = mock_object @@ -3264,12 +3239,7 @@ async def test_import_ssh_public_key_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.import_ssh_public_key ] = mock_object @@ -3685,12 +3655,7 @@ async def test_update_ssh_public_key_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_ssh_public_key ] = mock_object diff --git a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/base.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/base.py index a414178d2276..e263205b5290 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/base.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/base.py @@ -83,6 +83,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -95,7 +97,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/grpc.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/grpc.py index bb94e0e25505..4e6eb0b5ad05 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/grpc.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/grpc.py @@ -144,7 +144,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/grpc_asyncio.py b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/grpc_asyncio.py index 80c84700cb07..67196ef6b27f 100644 --- a/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/grpc_asyncio.py +++ b/packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/grpc_asyncio.py @@ -191,7 +191,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-parallelstore/setup.py b/packages/google-cloud-parallelstore/setup.py index 6fa151e7d535..56d3bc3d4cd7 100644 --- a/packages/google-cloud-parallelstore/setup.py +++ b/packages/google-cloud-parallelstore/setup.py @@ -46,7 +46,7 @@ # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", "proto-plus >= 1.22.3, <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", + "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", ] url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-parallelstore" diff --git a/packages/google-cloud-parallelstore/testing/constraints-3.7.txt b/packages/google-cloud-parallelstore/testing/constraints-3.7.txt index b8a550c73855..fc812592b0ee 100644 --- a/packages/google-cloud-parallelstore/testing/constraints-3.7.txt +++ b/packages/google-cloud-parallelstore/testing/constraints-3.7.txt @@ -7,4 +7,4 @@ google-api-core==1.34.1 google-auth==2.14.1 proto-plus==1.22.3 -protobuf==3.19.5 +protobuf==3.20.2 diff --git a/packages/google-cloud-parallelstore/tests/unit/gapic/parallelstore_v1beta/test_parallelstore.py b/packages/google-cloud-parallelstore/tests/unit/gapic/parallelstore_v1beta/test_parallelstore.py index f86229704fa6..a92948b118d3 100644 --- a/packages/google-cloud-parallelstore/tests/unit/gapic/parallelstore_v1beta/test_parallelstore.py +++ b/packages/google-cloud-parallelstore/tests/unit/gapic/parallelstore_v1beta/test_parallelstore.py @@ -1299,12 +1299,7 @@ async def test_list_instances_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_instances ] = mock_object @@ -1884,12 +1879,7 @@ async def test_get_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_instance ] = mock_object @@ -2272,12 +2262,7 @@ async def test_create_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_instance ] = mock_object @@ -2661,12 +2646,7 @@ async def test_update_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_instance ] = mock_object @@ -3042,12 +3022,7 @@ async def test_delete_instance_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_instance ] = mock_object @@ -3413,12 +3388,7 @@ async def test_import_data_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.import_data ] = mock_object @@ -3702,12 +3672,7 @@ async def test_export_data_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.export_data ] = mock_object diff --git a/packages/google-cloud-phishing-protection/README.rst b/packages/google-cloud-phishing-protection/README.rst index 5a5f322caf9d..328c65a99026 100644 --- a/packages/google-cloud-phishing-protection/README.rst +++ b/packages/google-cloud-phishing-protection/README.rst @@ -15,7 +15,7 @@ Python Client for Phishing Protection .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-phishing-protection.svg :target: https://pypi.org/project/google-cloud-phishing-protection/ .. _Phishing Protection: https://cloud.google.com/phishing-protection/docs/ -.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/phishingprotection/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/phishingprotection/latest/summary_overview .. _Product Documentation: https://cloud.google.com/phishing-protection/docs/ Quick Start diff --git a/packages/google-cloud-phishing-protection/docs/index.rst b/packages/google-cloud-phishing-protection/docs/index.rst index 3b8fc7c1a3de..29374ae7a329 100644 --- a/packages/google-cloud-phishing-protection/docs/index.rst +++ b/packages/google-cloud-phishing-protection/docs/index.rst @@ -21,3 +21,8 @@ For a list of all ``google-cloud-phishing-protection`` releases: :maxdepth: 2 CHANGELOG + +.. toctree:: + :hidden: + + summary_overview.md diff --git a/packages/google-cloud-phishing-protection/docs/summary_overview.md b/packages/google-cloud-phishing-protection/docs/summary_overview.md new file mode 100644 index 000000000000..4de0a15aac6d --- /dev/null +++ b/packages/google-cloud-phishing-protection/docs/summary_overview.md @@ -0,0 +1,22 @@ +[ +This is a templated file. Adding content to this file may result in it being +reverted. Instead, if you want to place additional content, create an +"overview_content.md" file in `docs/` directory. The Sphinx tool will +pick up on the content and merge the content. +]: # + +# Phishing Protection API + +Overview of the APIs available for Phishing Protection API. + +## All entries + +Classes, methods and properties & attributes for +Phishing Protection API. + +[classes](https://cloud.google.com/python/docs/reference/phishingprotection/latest/summary_class.html) + +[methods](https://cloud.google.com/python/docs/reference/phishingprotection/latest/summary_method.html) + +[properties and +attributes](https://cloud.google.com/python/docs/reference/phishingprotection/latest/summary_property.html) diff --git a/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/base.py b/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/base.py index 0304f328621f..07e60933a189 100644 --- a/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/base.py +++ b/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/base.py @@ -81,6 +81,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -93,7 +95,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/grpc.py b/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/grpc.py index 56a4b91884ae..a502e62d0a3e 100644 --- a/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/grpc.py +++ b/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/grpc.py @@ -123,7 +123,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/grpc_asyncio.py b/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/grpc_asyncio.py index acd5ae956901..097a73af97d5 100644 --- a/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/grpc_asyncio.py +++ b/packages/google-cloud-phishing-protection/google/cloud/phishingprotection_v1beta1/services/phishing_protection_service_v1_beta1/transports/grpc_asyncio.py @@ -170,7 +170,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-phishing-protection/noxfile.py b/packages/google-cloud-phishing-protection/noxfile.py index 1e6cd48d0529..67b7265f7586 100644 --- a/packages/google-cloud-phishing-protection/noxfile.py +++ b/packages/google-cloud-phishing-protection/noxfile.py @@ -160,14 +160,28 @@ def install_unittest_dependencies(session, *constraints): session.install("-e", ".", *constraints) -def default(session): +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def unit(session, protobuf_implementation): # Install all test dependencies, then install this package in-place. + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) install_unittest_dependencies(session, "-c", constraints_path) + # TODO(https://github.com/googleapis/synthtool/issues/1976): + # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. + # The 'cpp' implementation requires Protobuf<4. + if protobuf_implementation == "cpp": + session.install("protobuf<4") + # Run py.test against the unit tests. session.run( "py.test", @@ -181,15 +195,12 @@ def default(session): "--cov-fail-under=0", os.path.join("tests", "unit"), *session.posargs, + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, ) -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) -def unit(session): - """Run the unit test suite.""" - default(session) - - def install_systemtest_dependencies(session, *constraints): # Use pre-release gRPC for system tests. # Exclude version 1.52.0rc1 which has a known issue. @@ -358,9 +369,16 @@ def docfx(session): @nox.session(python="3.12") -def prerelease_deps(session): +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def prerelease_deps(session, protobuf_implementation): """Run all tests with prerelease versions of dependencies installed.""" + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + # Install all dependencies session.install("-e", ".[all, tests, tracing]") unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES @@ -397,9 +415,9 @@ def prerelease_deps(session): "protobuf", # dependency of grpc "six", + "grpc-google-iam-v1", "googleapis-common-protos", - # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163 - "grpcio!=1.52.0rc1", + "grpcio", "grpcio-status", "google-api-core", "google-auth", @@ -425,4 +443,10 @@ def prerelease_deps(session): session.run("python", "-c", "import grpc; print(grpc.__version__)") session.run("python", "-c", "import google.auth; print(google.auth.__version__)") - session.run("py.test", "tests/unit") + session.run( + "py.test", + "tests/unit", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) diff --git a/packages/google-cloud-phishing-protection/setup.py b/packages/google-cloud-phishing-protection/setup.py index 7b338283c27b..10ffc1145e1f 100644 --- a/packages/google-cloud-phishing-protection/setup.py +++ b/packages/google-cloud-phishing-protection/setup.py @@ -46,7 +46,7 @@ # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", "proto-plus >= 1.22.3, <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", + "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", ] url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-phishing-protection" diff --git a/packages/google-cloud-phishing-protection/testing/constraints-3.7.txt b/packages/google-cloud-phishing-protection/testing/constraints-3.7.txt index b8a550c73855..fc812592b0ee 100644 --- a/packages/google-cloud-phishing-protection/testing/constraints-3.7.txt +++ b/packages/google-cloud-phishing-protection/testing/constraints-3.7.txt @@ -7,4 +7,4 @@ google-api-core==1.34.1 google-auth==2.14.1 proto-plus==1.22.3 -protobuf==3.19.5 +protobuf==3.20.2 diff --git a/packages/google-cloud-phishing-protection/tests/unit/gapic/phishingprotection_v1beta1/test_phishing_protection_service_v1_beta1.py b/packages/google-cloud-phishing-protection/tests/unit/gapic/phishingprotection_v1beta1/test_phishing_protection_service_v1_beta1.py index 3547c14dc738..fd775839db3d 100644 --- a/packages/google-cloud-phishing-protection/tests/unit/gapic/phishingprotection_v1beta1/test_phishing_protection_service_v1_beta1.py +++ b/packages/google-cloud-phishing-protection/tests/unit/gapic/phishingprotection_v1beta1/test_phishing_protection_service_v1_beta1.py @@ -1386,12 +1386,7 @@ async def test_report_phishing_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.report_phishing ] = mock_object diff --git a/packages/google-cloud-policy-troubleshooter/README.rst b/packages/google-cloud-policy-troubleshooter/README.rst index e499013e10cf..5930501e4ad7 100644 --- a/packages/google-cloud-policy-troubleshooter/README.rst +++ b/packages/google-cloud-policy-troubleshooter/README.rst @@ -15,7 +15,7 @@ Python Client for IAM Policy Troubleshooter API .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-policy-troubleshooter.svg :target: https://pypi.org/project/google-cloud-policy-troubleshooter/ .. _IAM Policy Troubleshooter API: https://cloud.google.com/iam/docs/troubleshooting-access#rest-api/ -.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/policytroubleshooter/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/policytroubleshooter/latest/summary_overview .. _Product Documentation: https://cloud.google.com/iam/docs/troubleshooting-access#rest-api/ Quick Start diff --git a/packages/google-cloud-policy-troubleshooter/docs/index.rst b/packages/google-cloud-policy-troubleshooter/docs/index.rst index 815be52682b9..fa53fb808890 100644 --- a/packages/google-cloud-policy-troubleshooter/docs/index.rst +++ b/packages/google-cloud-policy-troubleshooter/docs/index.rst @@ -21,3 +21,8 @@ For a list of all ``google-cloud-policy-troubleshooter`` releases: :maxdepth: 2 CHANGELOG + +.. toctree:: + :hidden: + + summary_overview.md diff --git a/packages/google-cloud-policy-troubleshooter/docs/summary_overview.md b/packages/google-cloud-policy-troubleshooter/docs/summary_overview.md new file mode 100644 index 000000000000..7265ff52e2fd --- /dev/null +++ b/packages/google-cloud-policy-troubleshooter/docs/summary_overview.md @@ -0,0 +1,22 @@ +[ +This is a templated file. Adding content to this file may result in it being +reverted. Instead, if you want to place additional content, create an +"overview_content.md" file in `docs/` directory. The Sphinx tool will +pick up on the content and merge the content. +]: # + +# IAM Policy Troubleshooter API API + +Overview of the APIs available for IAM Policy Troubleshooter API API. + +## All entries + +Classes, methods and properties & attributes for +IAM Policy Troubleshooter API API. + +[classes](https://cloud.google.com/python/docs/reference/policytroubleshooter/latest/summary_class.html) + +[methods](https://cloud.google.com/python/docs/reference/policytroubleshooter/latest/summary_method.html) + +[properties and +attributes](https://cloud.google.com/python/docs/reference/policytroubleshooter/latest/summary_property.html) diff --git a/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/base.py b/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/base.py index d057adadcc50..725b4f4374f1 100644 --- a/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/base.py +++ b/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/base.py @@ -81,6 +81,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -93,7 +95,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/grpc.py b/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/grpc.py index 710383474aed..c89ebf478473 100644 --- a/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/grpc.py +++ b/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/grpc.py @@ -124,7 +124,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/grpc_asyncio.py b/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/grpc_asyncio.py index b8512ed632e3..acc7f9e9791a 100644 --- a/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/grpc_asyncio.py +++ b/packages/google-cloud-policy-troubleshooter/google/cloud/policytroubleshooter_v1/services/iam_checker/transports/grpc_asyncio.py @@ -171,7 +171,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-policy-troubleshooter/noxfile.py b/packages/google-cloud-policy-troubleshooter/noxfile.py index 1e6cd48d0529..67b7265f7586 100644 --- a/packages/google-cloud-policy-troubleshooter/noxfile.py +++ b/packages/google-cloud-policy-troubleshooter/noxfile.py @@ -160,14 +160,28 @@ def install_unittest_dependencies(session, *constraints): session.install("-e", ".", *constraints) -def default(session): +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def unit(session, protobuf_implementation): # Install all test dependencies, then install this package in-place. + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) install_unittest_dependencies(session, "-c", constraints_path) + # TODO(https://github.com/googleapis/synthtool/issues/1976): + # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. + # The 'cpp' implementation requires Protobuf<4. + if protobuf_implementation == "cpp": + session.install("protobuf<4") + # Run py.test against the unit tests. session.run( "py.test", @@ -181,15 +195,12 @@ def default(session): "--cov-fail-under=0", os.path.join("tests", "unit"), *session.posargs, + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, ) -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) -def unit(session): - """Run the unit test suite.""" - default(session) - - def install_systemtest_dependencies(session, *constraints): # Use pre-release gRPC for system tests. # Exclude version 1.52.0rc1 which has a known issue. @@ -358,9 +369,16 @@ def docfx(session): @nox.session(python="3.12") -def prerelease_deps(session): +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def prerelease_deps(session, protobuf_implementation): """Run all tests with prerelease versions of dependencies installed.""" + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + # Install all dependencies session.install("-e", ".[all, tests, tracing]") unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES @@ -397,9 +415,9 @@ def prerelease_deps(session): "protobuf", # dependency of grpc "six", + "grpc-google-iam-v1", "googleapis-common-protos", - # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163 - "grpcio!=1.52.0rc1", + "grpcio", "grpcio-status", "google-api-core", "google-auth", @@ -425,4 +443,10 @@ def prerelease_deps(session): session.run("python", "-c", "import grpc; print(grpc.__version__)") session.run("python", "-c", "import google.auth; print(google.auth.__version__)") - session.run("py.test", "tests/unit") + session.run( + "py.test", + "tests/unit", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) diff --git a/packages/google-cloud-policy-troubleshooter/setup.py b/packages/google-cloud-policy-troubleshooter/setup.py index 6e433b83845c..6606f4f60b24 100644 --- a/packages/google-cloud-policy-troubleshooter/setup.py +++ b/packages/google-cloud-policy-troubleshooter/setup.py @@ -46,7 +46,7 @@ # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", "proto-plus >= 1.22.3, <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", + "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", "grpc-google-iam-v1 >= 0.12.4, <1.0.0dev", ] url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-policy-troubleshooter" diff --git a/packages/google-cloud-policy-troubleshooter/testing/constraints-3.7.txt b/packages/google-cloud-policy-troubleshooter/testing/constraints-3.7.txt index 4cd2782277d4..a81fb6bcd05c 100644 --- a/packages/google-cloud-policy-troubleshooter/testing/constraints-3.7.txt +++ b/packages/google-cloud-policy-troubleshooter/testing/constraints-3.7.txt @@ -7,5 +7,5 @@ google-api-core==1.34.1 google-auth==2.14.1 proto-plus==1.22.3 -protobuf==3.19.5 +protobuf==3.20.2 grpc-google-iam-v1==0.12.4 diff --git a/packages/google-cloud-policy-troubleshooter/tests/unit/gapic/policytroubleshooter_v1/test_iam_checker.py b/packages/google-cloud-policy-troubleshooter/tests/unit/gapic/policytroubleshooter_v1/test_iam_checker.py index 5084b8672d9b..625d63726d49 100644 --- a/packages/google-cloud-policy-troubleshooter/tests/unit/gapic/policytroubleshooter_v1/test_iam_checker.py +++ b/packages/google-cloud-policy-troubleshooter/tests/unit/gapic/policytroubleshooter_v1/test_iam_checker.py @@ -1248,12 +1248,7 @@ async def test_troubleshoot_iam_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.troubleshoot_iam_policy ] = mock_object diff --git a/packages/google-cloud-policysimulator/README.rst b/packages/google-cloud-policysimulator/README.rst index 86617b80c468..35b8b7db54eb 100644 --- a/packages/google-cloud-policysimulator/README.rst +++ b/packages/google-cloud-policysimulator/README.rst @@ -15,7 +15,7 @@ Python Client for Policy Simulator API .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-policysimulator.svg :target: https://pypi.org/project/google-cloud-policysimulator/ .. _Policy Simulator API: https://cloud.google.com/policy-intelligence/docs/iam-simulator-overview -.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/policysimulator/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/policysimulator/latest/summary_overview .. _Product Documentation: https://cloud.google.com/policy-intelligence/docs/iam-simulator-overview Quick Start diff --git a/packages/google-cloud-policysimulator/docs/index.rst b/packages/google-cloud-policysimulator/docs/index.rst index 5302cf3995c7..96c501b9ff3e 100644 --- a/packages/google-cloud-policysimulator/docs/index.rst +++ b/packages/google-cloud-policysimulator/docs/index.rst @@ -21,3 +21,8 @@ For a list of all ``google-cloud-policysimulator`` releases: :maxdepth: 2 CHANGELOG + +.. toctree:: + :hidden: + + summary_overview.md diff --git a/packages/google-cloud-policysimulator/docs/summary_overview.md b/packages/google-cloud-policysimulator/docs/summary_overview.md new file mode 100644 index 000000000000..8c3e231a7062 --- /dev/null +++ b/packages/google-cloud-policysimulator/docs/summary_overview.md @@ -0,0 +1,22 @@ +[ +This is a templated file. Adding content to this file may result in it being +reverted. Instead, if you want to place additional content, create an +"overview_content.md" file in `docs/` directory. The Sphinx tool will +pick up on the content and merge the content. +]: # + +# Policy Simulator API API + +Overview of the APIs available for Policy Simulator API API. + +## All entries + +Classes, methods and properties & attributes for +Policy Simulator API API. + +[classes](https://cloud.google.com/python/docs/reference/policysimulator/latest/summary_class.html) + +[methods](https://cloud.google.com/python/docs/reference/policysimulator/latest/summary_method.html) + +[properties and +attributes](https://cloud.google.com/python/docs/reference/policysimulator/latest/summary_property.html) diff --git a/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/base.py b/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/base.py index 976ee23fbb6a..7994ca3c0d15 100644 --- a/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/base.py +++ b/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/base.py @@ -82,6 +82,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -94,7 +96,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/grpc.py b/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/grpc.py index 16a3a79a13a6..155223150c30 100644 --- a/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/grpc.py +++ b/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/grpc.py @@ -135,7 +135,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/grpc_asyncio.py b/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/grpc_asyncio.py index 4e150282f36c..d0241fb22ceb 100644 --- a/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/grpc_asyncio.py +++ b/packages/google-cloud-policysimulator/google/cloud/policysimulator_v1/services/simulator/transports/grpc_asyncio.py @@ -182,7 +182,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-policysimulator/noxfile.py b/packages/google-cloud-policysimulator/noxfile.py index 1e6cd48d0529..67b7265f7586 100644 --- a/packages/google-cloud-policysimulator/noxfile.py +++ b/packages/google-cloud-policysimulator/noxfile.py @@ -160,14 +160,28 @@ def install_unittest_dependencies(session, *constraints): session.install("-e", ".", *constraints) -def default(session): +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def unit(session, protobuf_implementation): # Install all test dependencies, then install this package in-place. + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) install_unittest_dependencies(session, "-c", constraints_path) + # TODO(https://github.com/googleapis/synthtool/issues/1976): + # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. + # The 'cpp' implementation requires Protobuf<4. + if protobuf_implementation == "cpp": + session.install("protobuf<4") + # Run py.test against the unit tests. session.run( "py.test", @@ -181,15 +195,12 @@ def default(session): "--cov-fail-under=0", os.path.join("tests", "unit"), *session.posargs, + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, ) -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) -def unit(session): - """Run the unit test suite.""" - default(session) - - def install_systemtest_dependencies(session, *constraints): # Use pre-release gRPC for system tests. # Exclude version 1.52.0rc1 which has a known issue. @@ -358,9 +369,16 @@ def docfx(session): @nox.session(python="3.12") -def prerelease_deps(session): +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def prerelease_deps(session, protobuf_implementation): """Run all tests with prerelease versions of dependencies installed.""" + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + # Install all dependencies session.install("-e", ".[all, tests, tracing]") unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES @@ -397,9 +415,9 @@ def prerelease_deps(session): "protobuf", # dependency of grpc "six", + "grpc-google-iam-v1", "googleapis-common-protos", - # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163 - "grpcio!=1.52.0rc1", + "grpcio", "grpcio-status", "google-api-core", "google-auth", @@ -425,4 +443,10 @@ def prerelease_deps(session): session.run("python", "-c", "import grpc; print(grpc.__version__)") session.run("python", "-c", "import google.auth; print(google.auth.__version__)") - session.run("py.test", "tests/unit") + session.run( + "py.test", + "tests/unit", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) diff --git a/packages/google-cloud-policysimulator/setup.py b/packages/google-cloud-policysimulator/setup.py index 720e32567040..d3bc5eb70f95 100644 --- a/packages/google-cloud-policysimulator/setup.py +++ b/packages/google-cloud-policysimulator/setup.py @@ -46,7 +46,7 @@ # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", "proto-plus >= 1.22.3, <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", + "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", "grpc-google-iam-v1 >= 0.12.4, <1.0.0dev", ] url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-policysimulator" diff --git a/packages/google-cloud-policysimulator/testing/constraints-3.7.txt b/packages/google-cloud-policysimulator/testing/constraints-3.7.txt index 4cd2782277d4..a81fb6bcd05c 100644 --- a/packages/google-cloud-policysimulator/testing/constraints-3.7.txt +++ b/packages/google-cloud-policysimulator/testing/constraints-3.7.txt @@ -7,5 +7,5 @@ google-api-core==1.34.1 google-auth==2.14.1 proto-plus==1.22.3 -protobuf==3.19.5 +protobuf==3.20.2 grpc-google-iam-v1==0.12.4 diff --git a/packages/google-cloud-policysimulator/tests/unit/gapic/policysimulator_v1/test_simulator.py b/packages/google-cloud-policysimulator/tests/unit/gapic/policysimulator_v1/test_simulator.py index dccc48abbe3b..8b4d4e57e12b 100644 --- a/packages/google-cloud-policysimulator/tests/unit/gapic/policysimulator_v1/test_simulator.py +++ b/packages/google-cloud-policysimulator/tests/unit/gapic/policysimulator_v1/test_simulator.py @@ -1249,12 +1249,7 @@ async def test_get_replay_async_use_cached_wrapped_rpc(transport: str = "grpc_as ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_replay ] = mock_object @@ -1615,12 +1610,7 @@ async def test_create_replay_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_replay ] = mock_object @@ -2009,12 +1999,7 @@ async def test_list_replay_results_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_replay_results ] = mock_object diff --git a/packages/google-cloud-policytroubleshooter-iam/README.rst b/packages/google-cloud-policytroubleshooter-iam/README.rst index fb0aa870b2b2..cb8030c0a888 100644 --- a/packages/google-cloud-policytroubleshooter-iam/README.rst +++ b/packages/google-cloud-policytroubleshooter-iam/README.rst @@ -15,7 +15,7 @@ Python Client for Policy Troubleshooter API .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-policytroubleshooter-iam.svg :target: https://pypi.org/project/google-cloud-policytroubleshooter-iam/ .. _Policy Troubleshooter API: https://cloud.google.com/policy-intelligence/docs/troubleshoot-access -.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/policytroubleshooter-iam/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/policytroubleshooter-iam/latest/summary_overview .. _Product Documentation: https://cloud.google.com/policy-intelligence/docs/troubleshoot-access Quick Start diff --git a/packages/google-cloud-policytroubleshooter-iam/docs/index.rst b/packages/google-cloud-policytroubleshooter-iam/docs/index.rst index 3507b5efd18f..1765c9ec4f63 100644 --- a/packages/google-cloud-policytroubleshooter-iam/docs/index.rst +++ b/packages/google-cloud-policytroubleshooter-iam/docs/index.rst @@ -21,3 +21,8 @@ For a list of all ``google-cloud-policytroubleshooter-iam`` releases: :maxdepth: 2 CHANGELOG + +.. toctree:: + :hidden: + + summary_overview.md diff --git a/packages/google-cloud-policytroubleshooter-iam/docs/summary_overview.md b/packages/google-cloud-policytroubleshooter-iam/docs/summary_overview.md new file mode 100644 index 000000000000..67203e8245c1 --- /dev/null +++ b/packages/google-cloud-policytroubleshooter-iam/docs/summary_overview.md @@ -0,0 +1,22 @@ +[ +This is a templated file. Adding content to this file may result in it being +reverted. Instead, if you want to place additional content, create an +"overview_content.md" file in `docs/` directory. The Sphinx tool will +pick up on the content and merge the content. +]: # + +# Policy Troubleshooter API API + +Overview of the APIs available for Policy Troubleshooter API API. + +## All entries + +Classes, methods and properties & attributes for +Policy Troubleshooter API API. + +[classes](https://cloud.google.com/python/docs/reference/policytroubleshooter-iam/latest/summary_class.html) + +[methods](https://cloud.google.com/python/docs/reference/policytroubleshooter-iam/latest/summary_method.html) + +[properties and +attributes](https://cloud.google.com/python/docs/reference/policytroubleshooter-iam/latest/summary_property.html) diff --git a/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/base.py b/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/base.py index 629184bbba47..f6f2d2025304 100644 --- a/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/base.py +++ b/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/base.py @@ -81,6 +81,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -93,7 +95,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/grpc.py b/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/grpc.py index d8937a20b1a0..b6199bf0aee5 100644 --- a/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/grpc.py +++ b/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/grpc.py @@ -124,7 +124,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/grpc_asyncio.py b/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/grpc_asyncio.py index e8ddfafea030..4705939f2cca 100644 --- a/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/grpc_asyncio.py +++ b/packages/google-cloud-policytroubleshooter-iam/google/cloud/policytroubleshooter_iam_v3/services/policy_troubleshooter/transports/grpc_asyncio.py @@ -171,7 +171,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-policytroubleshooter-iam/noxfile.py b/packages/google-cloud-policytroubleshooter-iam/noxfile.py index 1e6cd48d0529..67b7265f7586 100644 --- a/packages/google-cloud-policytroubleshooter-iam/noxfile.py +++ b/packages/google-cloud-policytroubleshooter-iam/noxfile.py @@ -160,14 +160,28 @@ def install_unittest_dependencies(session, *constraints): session.install("-e", ".", *constraints) -def default(session): +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def unit(session, protobuf_implementation): # Install all test dependencies, then install this package in-place. + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) install_unittest_dependencies(session, "-c", constraints_path) + # TODO(https://github.com/googleapis/synthtool/issues/1976): + # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. + # The 'cpp' implementation requires Protobuf<4. + if protobuf_implementation == "cpp": + session.install("protobuf<4") + # Run py.test against the unit tests. session.run( "py.test", @@ -181,15 +195,12 @@ def default(session): "--cov-fail-under=0", os.path.join("tests", "unit"), *session.posargs, + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, ) -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) -def unit(session): - """Run the unit test suite.""" - default(session) - - def install_systemtest_dependencies(session, *constraints): # Use pre-release gRPC for system tests. # Exclude version 1.52.0rc1 which has a known issue. @@ -358,9 +369,16 @@ def docfx(session): @nox.session(python="3.12") -def prerelease_deps(session): +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def prerelease_deps(session, protobuf_implementation): """Run all tests with prerelease versions of dependencies installed.""" + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + # Install all dependencies session.install("-e", ".[all, tests, tracing]") unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES @@ -397,9 +415,9 @@ def prerelease_deps(session): "protobuf", # dependency of grpc "six", + "grpc-google-iam-v1", "googleapis-common-protos", - # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163 - "grpcio!=1.52.0rc1", + "grpcio", "grpcio-status", "google-api-core", "google-auth", @@ -425,4 +443,10 @@ def prerelease_deps(session): session.run("python", "-c", "import grpc; print(grpc.__version__)") session.run("python", "-c", "import google.auth; print(google.auth.__version__)") - session.run("py.test", "tests/unit") + session.run( + "py.test", + "tests/unit", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) diff --git a/packages/google-cloud-policytroubleshooter-iam/setup.py b/packages/google-cloud-policytroubleshooter-iam/setup.py index 68293ac9c7d1..c75da84e2152 100644 --- a/packages/google-cloud-policytroubleshooter-iam/setup.py +++ b/packages/google-cloud-policytroubleshooter-iam/setup.py @@ -46,7 +46,7 @@ # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", "proto-plus >= 1.22.3, <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", + "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", "grpc-google-iam-v1 >= 0.12.4, <1.0.0dev", "google-cloud-iam >= 2.12.2, <3.0.0dev", ] diff --git a/packages/google-cloud-policytroubleshooter-iam/testing/constraints-3.7.txt b/packages/google-cloud-policytroubleshooter-iam/testing/constraints-3.7.txt index 5c8e739070e6..351bc6a04ece 100644 --- a/packages/google-cloud-policytroubleshooter-iam/testing/constraints-3.7.txt +++ b/packages/google-cloud-policytroubleshooter-iam/testing/constraints-3.7.txt @@ -7,6 +7,6 @@ google-api-core==1.34.1 google-auth==2.14.1 proto-plus==1.22.3 -protobuf==3.19.5 +protobuf==3.20.2 grpc-google-iam-v1==0.12.4 google-cloud-iam==2.12.2 diff --git a/packages/google-cloud-policytroubleshooter-iam/tests/unit/gapic/policytroubleshooter_iam_v3/test_policy_troubleshooter.py b/packages/google-cloud-policytroubleshooter-iam/tests/unit/gapic/policytroubleshooter_iam_v3/test_policy_troubleshooter.py index f723ed2daad5..854670e35af7 100644 --- a/packages/google-cloud-policytroubleshooter-iam/tests/unit/gapic/policytroubleshooter_iam_v3/test_policy_troubleshooter.py +++ b/packages/google-cloud-policytroubleshooter-iam/tests/unit/gapic/policytroubleshooter_iam_v3/test_policy_troubleshooter.py @@ -1360,12 +1360,7 @@ async def test_troubleshoot_iam_policy_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.troubleshoot_iam_policy ] = mock_object diff --git a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/base.py b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/base.py index fdc511f57833..8952efa43c53 100644 --- a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/base.py +++ b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/base.py @@ -85,6 +85,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -97,7 +99,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc.py b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc.py index 569b2911f26c..8f8c6b8e9fa2 100644 --- a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc.py +++ b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc.py @@ -128,7 +128,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc_asyncio.py b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc_asyncio.py index 8b22776859b3..758b1b1c8878 100644 --- a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1/services/certificate_authority_service/transports/grpc_asyncio.py @@ -177,7 +177,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/base.py b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/base.py index b1265370a111..4a5c4091ecea 100644 --- a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/base.py +++ b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/base.py @@ -82,6 +82,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -94,7 +96,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc.py b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc.py index 93bee921f7fd..307cf82aff76 100644 --- a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc.py +++ b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc.py @@ -125,7 +125,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc_asyncio.py b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc_asyncio.py index ec7346385cc9..6b994c9725b1 100644 --- a/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-private-ca/google/cloud/security/privateca_v1beta1/services/certificate_authority_service/transports/grpc_asyncio.py @@ -174,7 +174,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-private-ca/setup.py b/packages/google-cloud-private-ca/setup.py index 6f3bd8e1280d..a96f4b54fd6d 100644 --- a/packages/google-cloud-private-ca/setup.py +++ b/packages/google-cloud-private-ca/setup.py @@ -46,7 +46,7 @@ # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", "proto-plus >= 1.22.3, <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", + "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", "grpc-google-iam-v1 >= 0.12.4, <1.0.0dev", ] url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-private-ca" diff --git a/packages/google-cloud-private-ca/testing/constraints-3.7.txt b/packages/google-cloud-private-ca/testing/constraints-3.7.txt index 4cd2782277d4..a81fb6bcd05c 100644 --- a/packages/google-cloud-private-ca/testing/constraints-3.7.txt +++ b/packages/google-cloud-private-ca/testing/constraints-3.7.txt @@ -7,5 +7,5 @@ google-api-core==1.34.1 google-auth==2.14.1 proto-plus==1.22.3 -protobuf==3.19.5 +protobuf==3.20.2 grpc-google-iam-v1==0.12.4 diff --git a/packages/google-cloud-private-ca/tests/unit/gapic/privateca_v1/test_certificate_authority_service.py b/packages/google-cloud-private-ca/tests/unit/gapic/privateca_v1/test_certificate_authority_service.py index a659b075f25a..f3b884a2ee7e 100644 --- a/packages/google-cloud-private-ca/tests/unit/gapic/privateca_v1/test_certificate_authority_service.py +++ b/packages/google-cloud-private-ca/tests/unit/gapic/privateca_v1/test_certificate_authority_service.py @@ -1421,12 +1421,7 @@ async def test_create_certificate_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_certificate ] = mock_object @@ -1846,12 +1841,7 @@ async def test_get_certificate_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_certificate ] = mock_object @@ -2244,12 +2234,7 @@ async def test_list_certificates_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_certificates ] = mock_object @@ -2853,12 +2838,7 @@ async def test_revoke_certificate_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.revoke_certificate ] = mock_object @@ -3270,12 +3250,7 @@ async def test_update_certificate_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_certificate ] = mock_object @@ -3685,12 +3660,7 @@ async def test_activate_certificate_authority_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.activate_certificate_authority ] = mock_object @@ -4082,12 +4052,7 @@ async def test_create_certificate_authority_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_certificate_authority ] = mock_object @@ -4497,12 +4462,7 @@ async def test_disable_certificate_authority_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.disable_certificate_authority ] = mock_object @@ -4892,12 +4852,7 @@ async def test_enable_certificate_authority_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.enable_certificate_authority ] = mock_object @@ -5286,12 +5241,7 @@ async def test_fetch_certificate_authority_csr_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.fetch_certificate_authority_csr ] = mock_object @@ -5694,12 +5644,7 @@ async def test_get_certificate_authority_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_certificate_authority ] = mock_object @@ -6105,12 +6050,7 @@ async def test_list_certificate_authorities_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_certificate_authorities ] = mock_object @@ -6699,12 +6639,7 @@ async def test_undelete_certificate_authority_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.undelete_certificate_authority ] = mock_object @@ -7094,12 +7029,7 @@ async def test_delete_certificate_authority_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_certificate_authority ] = mock_object @@ -7487,12 +7417,7 @@ async def test_update_certificate_authority_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_certificate_authority ] = mock_object @@ -7881,12 +7806,7 @@ async def test_create_ca_pool_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_ca_pool ] = mock_object @@ -8270,12 +8190,7 @@ async def test_update_ca_pool_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_ca_pool ] = mock_object @@ -8653,12 +8568,7 @@ async def test_get_ca_pool_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_ca_pool ] = mock_object @@ -9029,12 +8939,7 @@ async def test_list_ca_pools_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_ca_pools ] = mock_object @@ -9591,12 +9496,7 @@ async def test_delete_ca_pool_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_ca_pool ] = mock_object @@ -9958,12 +9858,7 @@ async def test_fetch_ca_certs_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.fetch_ca_certs ] = mock_object @@ -10352,12 +10247,7 @@ async def test_get_certificate_revocation_list_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_certificate_revocation_list ] = mock_object @@ -10764,12 +10654,7 @@ async def test_list_certificate_revocation_lists_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_certificate_revocation_lists ] = mock_object @@ -11358,12 +11243,7 @@ async def test_update_certificate_revocation_list_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_certificate_revocation_list ] = mock_object @@ -11773,12 +11653,7 @@ async def test_create_certificate_template_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_certificate_template ] = mock_object @@ -12188,12 +12063,7 @@ async def test_delete_certificate_template_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_certificate_template ] = mock_object @@ -12585,12 +12455,7 @@ async def test_get_certificate_template_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_certificate_template ] = mock_object @@ -12988,12 +12853,7 @@ async def test_list_certificate_templates_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_certificate_templates ] = mock_object @@ -13580,12 +13440,7 @@ async def test_update_certificate_template_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_certificate_template ] = mock_object diff --git a/packages/google-cloud-private-ca/tests/unit/gapic/privateca_v1beta1/test_certificate_authority_service.py b/packages/google-cloud-private-ca/tests/unit/gapic/privateca_v1beta1/test_certificate_authority_service.py index 985a23b3ccb8..9c7b9d2f031f 100644 --- a/packages/google-cloud-private-ca/tests/unit/gapic/privateca_v1beta1/test_certificate_authority_service.py +++ b/packages/google-cloud-private-ca/tests/unit/gapic/privateca_v1beta1/test_certificate_authority_service.py @@ -1405,12 +1405,7 @@ async def test_create_certificate_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_certificate ] = mock_object @@ -1815,12 +1810,7 @@ async def test_get_certificate_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_certificate ] = mock_object @@ -2207,12 +2197,7 @@ async def test_list_certificates_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_certificates ] = mock_object @@ -2807,12 +2792,7 @@ async def test_revoke_certificate_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.revoke_certificate ] = mock_object @@ -3209,12 +3189,7 @@ async def test_update_certificate_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_certificate ] = mock_object @@ -3618,12 +3593,7 @@ async def test_activate_certificate_authority_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.activate_certificate_authority ] = mock_object @@ -4015,12 +3985,7 @@ async def test_create_certificate_authority_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_certificate_authority ] = mock_object @@ -4430,12 +4395,7 @@ async def test_disable_certificate_authority_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.disable_certificate_authority ] = mock_object @@ -4825,12 +4785,7 @@ async def test_enable_certificate_authority_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.enable_certificate_authority ] = mock_object @@ -5219,12 +5174,7 @@ async def test_fetch_certificate_authority_csr_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.fetch_certificate_authority_csr ] = mock_object @@ -5627,12 +5577,7 @@ async def test_get_certificate_authority_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_certificate_authority ] = mock_object @@ -6038,12 +5983,7 @@ async def test_list_certificate_authorities_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_certificate_authorities ] = mock_object @@ -6632,12 +6572,7 @@ async def test_restore_certificate_authority_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.restore_certificate_authority ] = mock_object @@ -7027,12 +6962,7 @@ async def test_schedule_delete_certificate_authority_async_use_cached_wrapped_rp ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.schedule_delete_certificate_authority ] = mock_object @@ -7420,12 +7350,7 @@ async def test_update_certificate_authority_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_certificate_authority ] = mock_object @@ -7836,12 +7761,7 @@ async def test_get_certificate_revocation_list_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_certificate_revocation_list ] = mock_object @@ -8246,12 +8166,7 @@ async def test_list_certificate_revocation_lists_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_certificate_revocation_lists ] = mock_object @@ -8840,12 +8755,7 @@ async def test_update_certificate_revocation_list_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_certificate_revocation_list ] = mock_object @@ -9254,12 +9164,7 @@ async def test_get_reusable_config_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_reusable_config ] = mock_object @@ -9657,12 +9562,7 @@ async def test_list_reusable_configs_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_reusable_configs ] = mock_object diff --git a/packages/google-cloud-private-catalog/README.rst b/packages/google-cloud-private-catalog/README.rst index 6b31ce58a51a..b6e1627d35a5 100644 --- a/packages/google-cloud-private-catalog/README.rst +++ b/packages/google-cloud-private-catalog/README.rst @@ -15,7 +15,7 @@ Python Client for Private Catalog .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-private-catalog.svg :target: https://pypi.org/project/google-cloud-private-catalog/ .. _Private Catalog: https://cloud.google.com/private-catalog/ -.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/cloudprivatecatalog/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/cloudprivatecatalog/latest/summary_overview .. _Product Documentation: https://cloud.google.com/private-catalog/ Quick Start diff --git a/packages/google-cloud-private-catalog/docs/index.rst b/packages/google-cloud-private-catalog/docs/index.rst index 40612039a42e..a426812686f6 100644 --- a/packages/google-cloud-private-catalog/docs/index.rst +++ b/packages/google-cloud-private-catalog/docs/index.rst @@ -21,3 +21,8 @@ For a list of all ``google-cloud-private-catalog`` releases: :maxdepth: 2 CHANGELOG + +.. toctree:: + :hidden: + + summary_overview.md diff --git a/packages/google-cloud-private-catalog/docs/summary_overview.md b/packages/google-cloud-private-catalog/docs/summary_overview.md new file mode 100644 index 000000000000..3e1dcbd6fc36 --- /dev/null +++ b/packages/google-cloud-private-catalog/docs/summary_overview.md @@ -0,0 +1,22 @@ +[ +This is a templated file. Adding content to this file may result in it being +reverted. Instead, if you want to place additional content, create an +"overview_content.md" file in `docs/` directory. The Sphinx tool will +pick up on the content and merge the content. +]: # + +# Private Catalog API + +Overview of the APIs available for Private Catalog API. + +## All entries + +Classes, methods and properties & attributes for +Private Catalog API. + +[classes](https://cloud.google.com/python/docs/reference/cloudprivatecatalog/latest/summary_class.html) + +[methods](https://cloud.google.com/python/docs/reference/cloudprivatecatalog/latest/summary_method.html) + +[properties and +attributes](https://cloud.google.com/python/docs/reference/cloudprivatecatalog/latest/summary_property.html) diff --git a/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/base.py b/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/base.py index c85a40435ea4..91c74ae34b28 100644 --- a/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/base.py +++ b/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/base.py @@ -81,6 +81,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -93,7 +95,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc.py b/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc.py index 4efc696b9fad..5a588074064a 100644 --- a/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc.py +++ b/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc.py @@ -142,7 +142,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc_asyncio.py b/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc_asyncio.py index 6471ca3349e6..be13be41ecc1 100644 --- a/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc_asyncio.py +++ b/packages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc_asyncio.py @@ -189,7 +189,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-private-catalog/noxfile.py b/packages/google-cloud-private-catalog/noxfile.py index 1e6cd48d0529..67b7265f7586 100644 --- a/packages/google-cloud-private-catalog/noxfile.py +++ b/packages/google-cloud-private-catalog/noxfile.py @@ -160,14 +160,28 @@ def install_unittest_dependencies(session, *constraints): session.install("-e", ".", *constraints) -def default(session): +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def unit(session, protobuf_implementation): # Install all test dependencies, then install this package in-place. + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) install_unittest_dependencies(session, "-c", constraints_path) + # TODO(https://github.com/googleapis/synthtool/issues/1976): + # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. + # The 'cpp' implementation requires Protobuf<4. + if protobuf_implementation == "cpp": + session.install("protobuf<4") + # Run py.test against the unit tests. session.run( "py.test", @@ -181,15 +195,12 @@ def default(session): "--cov-fail-under=0", os.path.join("tests", "unit"), *session.posargs, + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, ) -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) -def unit(session): - """Run the unit test suite.""" - default(session) - - def install_systemtest_dependencies(session, *constraints): # Use pre-release gRPC for system tests. # Exclude version 1.52.0rc1 which has a known issue. @@ -358,9 +369,16 @@ def docfx(session): @nox.session(python="3.12") -def prerelease_deps(session): +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def prerelease_deps(session, protobuf_implementation): """Run all tests with prerelease versions of dependencies installed.""" + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + # Install all dependencies session.install("-e", ".[all, tests, tracing]") unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES @@ -397,9 +415,9 @@ def prerelease_deps(session): "protobuf", # dependency of grpc "six", + "grpc-google-iam-v1", "googleapis-common-protos", - # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163 - "grpcio!=1.52.0rc1", + "grpcio", "grpcio-status", "google-api-core", "google-auth", @@ -425,4 +443,10 @@ def prerelease_deps(session): session.run("python", "-c", "import grpc; print(grpc.__version__)") session.run("python", "-c", "import google.auth; print(google.auth.__version__)") - session.run("py.test", "tests/unit") + session.run( + "py.test", + "tests/unit", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) diff --git a/packages/google-cloud-private-catalog/setup.py b/packages/google-cloud-private-catalog/setup.py index dd84087d2e0b..3b6583ed4400 100644 --- a/packages/google-cloud-private-catalog/setup.py +++ b/packages/google-cloud-private-catalog/setup.py @@ -46,7 +46,7 @@ # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", "proto-plus >= 1.22.3, <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", + "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", ] url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-private-catalog" diff --git a/packages/google-cloud-private-catalog/testing/constraints-3.7.txt b/packages/google-cloud-private-catalog/testing/constraints-3.7.txt index b8a550c73855..fc812592b0ee 100644 --- a/packages/google-cloud-private-catalog/testing/constraints-3.7.txt +++ b/packages/google-cloud-private-catalog/testing/constraints-3.7.txt @@ -7,4 +7,4 @@ google-api-core==1.34.1 google-auth==2.14.1 proto-plus==1.22.3 -protobuf==3.19.5 +protobuf==3.20.2 diff --git a/packages/google-cloud-private-catalog/tests/unit/gapic/privatecatalog_v1beta1/test_private_catalog.py b/packages/google-cloud-private-catalog/tests/unit/gapic/privatecatalog_v1beta1/test_private_catalog.py index 133b2255e673..ef18d16ee451 100644 --- a/packages/google-cloud-private-catalog/tests/unit/gapic/privatecatalog_v1beta1/test_private_catalog.py +++ b/packages/google-cloud-private-catalog/tests/unit/gapic/privatecatalog_v1beta1/test_private_catalog.py @@ -1284,12 +1284,7 @@ async def test_search_catalogs_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.search_catalogs ] = mock_object @@ -1765,12 +1760,7 @@ async def test_search_products_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.search_products ] = mock_object @@ -2246,12 +2236,7 @@ async def test_search_versions_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.search_versions ] = mock_object diff --git a/packages/google-cloud-public-ca/README.rst b/packages/google-cloud-public-ca/README.rst index 9898d19cff15..c4649b75a970 100644 --- a/packages/google-cloud-public-ca/README.rst +++ b/packages/google-cloud-public-ca/README.rst @@ -15,7 +15,7 @@ Python Client for Public Certificate Authority .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-public-ca.svg :target: https://pypi.org/project/google-cloud-public-ca/ .. _Public Certificate Authority: https://cloud.google.com/certificate-manager/docs/public-ca -.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/publicca/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/publicca/latest/summary_overview .. _Product Documentation: https://cloud.google.com/certificate-manager/docs/public-ca Quick Start diff --git a/packages/google-cloud-public-ca/docs/index.rst b/packages/google-cloud-public-ca/docs/index.rst index 55459a78d26d..c470d7a356bb 100644 --- a/packages/google-cloud-public-ca/docs/index.rst +++ b/packages/google-cloud-public-ca/docs/index.rst @@ -32,3 +32,8 @@ For a list of all ``google-cloud-public-ca`` releases: :maxdepth: 2 CHANGELOG + +.. toctree:: + :hidden: + + summary_overview.md diff --git a/packages/google-cloud-public-ca/docs/summary_overview.md b/packages/google-cloud-public-ca/docs/summary_overview.md new file mode 100644 index 000000000000..a0dcc7228350 --- /dev/null +++ b/packages/google-cloud-public-ca/docs/summary_overview.md @@ -0,0 +1,22 @@ +[ +This is a templated file. Adding content to this file may result in it being +reverted. Instead, if you want to place additional content, create an +"overview_content.md" file in `docs/` directory. The Sphinx tool will +pick up on the content and merge the content. +]: # + +# Public Certificate Authority API + +Overview of the APIs available for Public Certificate Authority API. + +## All entries + +Classes, methods and properties & attributes for +Public Certificate Authority API. + +[classes](https://cloud.google.com/python/docs/reference/publicca/latest/summary_class.html) + +[methods](https://cloud.google.com/python/docs/reference/publicca/latest/summary_method.html) + +[properties and +attributes](https://cloud.google.com/python/docs/reference/publicca/latest/summary_property.html) diff --git a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/base.py b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/base.py index d9c1af012ccb..65125bfd2930 100644 --- a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/base.py +++ b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/base.py @@ -81,6 +81,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -93,7 +95,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/grpc.py b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/grpc.py index d6ba11857e43..5d2e89cf2619 100644 --- a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/grpc.py +++ b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/grpc.py @@ -125,7 +125,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/grpc_asyncio.py b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/grpc_asyncio.py index 2ea244d5b665..257a5bd257ae 100644 --- a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1/services/public_certificate_authority_service/transports/grpc_asyncio.py @@ -172,7 +172,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/base.py b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/base.py index b81606a5e6ad..2067db847f6a 100644 --- a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/base.py +++ b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/base.py @@ -81,6 +81,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -93,7 +95,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/grpc.py b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/grpc.py index 767362adfa53..7f3329c34327 100644 --- a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/grpc.py +++ b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/grpc.py @@ -125,7 +125,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/grpc_asyncio.py b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/grpc_asyncio.py index 0750caf38edb..6cfd29b66bee 100644 --- a/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-public-ca/google/cloud/security/publicca_v1beta1/services/public_certificate_authority_service/transports/grpc_asyncio.py @@ -172,7 +172,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-public-ca/noxfile.py b/packages/google-cloud-public-ca/noxfile.py index 1e6cd48d0529..67b7265f7586 100644 --- a/packages/google-cloud-public-ca/noxfile.py +++ b/packages/google-cloud-public-ca/noxfile.py @@ -160,14 +160,28 @@ def install_unittest_dependencies(session, *constraints): session.install("-e", ".", *constraints) -def default(session): +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def unit(session, protobuf_implementation): # Install all test dependencies, then install this package in-place. + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) install_unittest_dependencies(session, "-c", constraints_path) + # TODO(https://github.com/googleapis/synthtool/issues/1976): + # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. + # The 'cpp' implementation requires Protobuf<4. + if protobuf_implementation == "cpp": + session.install("protobuf<4") + # Run py.test against the unit tests. session.run( "py.test", @@ -181,15 +195,12 @@ def default(session): "--cov-fail-under=0", os.path.join("tests", "unit"), *session.posargs, + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, ) -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) -def unit(session): - """Run the unit test suite.""" - default(session) - - def install_systemtest_dependencies(session, *constraints): # Use pre-release gRPC for system tests. # Exclude version 1.52.0rc1 which has a known issue. @@ -358,9 +369,16 @@ def docfx(session): @nox.session(python="3.12") -def prerelease_deps(session): +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def prerelease_deps(session, protobuf_implementation): """Run all tests with prerelease versions of dependencies installed.""" + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + # Install all dependencies session.install("-e", ".[all, tests, tracing]") unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES @@ -397,9 +415,9 @@ def prerelease_deps(session): "protobuf", # dependency of grpc "six", + "grpc-google-iam-v1", "googleapis-common-protos", - # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163 - "grpcio!=1.52.0rc1", + "grpcio", "grpcio-status", "google-api-core", "google-auth", @@ -425,4 +443,10 @@ def prerelease_deps(session): session.run("python", "-c", "import grpc; print(grpc.__version__)") session.run("python", "-c", "import google.auth; print(google.auth.__version__)") - session.run("py.test", "tests/unit") + session.run( + "py.test", + "tests/unit", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) diff --git a/packages/google-cloud-public-ca/setup.py b/packages/google-cloud-public-ca/setup.py index 40c4baadb067..c2c6eef7b56f 100644 --- a/packages/google-cloud-public-ca/setup.py +++ b/packages/google-cloud-public-ca/setup.py @@ -46,7 +46,7 @@ # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", "proto-plus >= 1.22.3, <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", + "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", ] url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-security-publicca" diff --git a/packages/google-cloud-public-ca/testing/constraints-3.7.txt b/packages/google-cloud-public-ca/testing/constraints-3.7.txt index b8a550c73855..fc812592b0ee 100644 --- a/packages/google-cloud-public-ca/testing/constraints-3.7.txt +++ b/packages/google-cloud-public-ca/testing/constraints-3.7.txt @@ -7,4 +7,4 @@ google-api-core==1.34.1 google-auth==2.14.1 proto-plus==1.22.3 -protobuf==3.19.5 +protobuf==3.20.2 diff --git a/packages/google-cloud-public-ca/tests/unit/gapic/publicca_v1/test_public_certificate_authority_service.py b/packages/google-cloud-public-ca/tests/unit/gapic/publicca_v1/test_public_certificate_authority_service.py index 83106e0b261c..9b942e10029b 100644 --- a/packages/google-cloud-public-ca/tests/unit/gapic/publicca_v1/test_public_certificate_authority_service.py +++ b/packages/google-cloud-public-ca/tests/unit/gapic/publicca_v1/test_public_certificate_authority_service.py @@ -1404,12 +1404,7 @@ async def test_create_external_account_key_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_external_account_key ] = mock_object diff --git a/packages/google-cloud-public-ca/tests/unit/gapic/publicca_v1beta1/test_public_certificate_authority_service.py b/packages/google-cloud-public-ca/tests/unit/gapic/publicca_v1beta1/test_public_certificate_authority_service.py index 47ed3985d6f8..73224809edd1 100644 --- a/packages/google-cloud-public-ca/tests/unit/gapic/publicca_v1beta1/test_public_certificate_authority_service.py +++ b/packages/google-cloud-public-ca/tests/unit/gapic/publicca_v1beta1/test_public_certificate_authority_service.py @@ -1404,12 +1404,7 @@ async def test_create_external_account_key_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_external_account_key ] = mock_object diff --git a/packages/google-cloud-rapidmigrationassessment/README.rst b/packages/google-cloud-rapidmigrationassessment/README.rst index 12c5003a20aa..b071b480ec38 100644 --- a/packages/google-cloud-rapidmigrationassessment/README.rst +++ b/packages/google-cloud-rapidmigrationassessment/README.rst @@ -15,7 +15,7 @@ Python Client for Rapid Migration Assessment API .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-rapidmigrationassessment.svg :target: https://pypi.org/project/google-cloud-rapidmigrationassessment/ .. _Rapid Migration Assessment API: https://cloud.google.com/migration-center/docs -.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/rapidmigrationassessment/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/rapidmigrationassessment/latest/summary_overview .. _Product Documentation: https://cloud.google.com/migration-center/docs Quick Start diff --git a/packages/google-cloud-rapidmigrationassessment/docs/index.rst b/packages/google-cloud-rapidmigrationassessment/docs/index.rst index d8b1dec4227a..057ee0daefd1 100644 --- a/packages/google-cloud-rapidmigrationassessment/docs/index.rst +++ b/packages/google-cloud-rapidmigrationassessment/docs/index.rst @@ -21,3 +21,8 @@ For a list of all ``google-cloud-rapidmigrationassessment`` releases: :maxdepth: 2 CHANGELOG + +.. toctree:: + :hidden: + + summary_overview.md diff --git a/packages/google-cloud-rapidmigrationassessment/docs/summary_overview.md b/packages/google-cloud-rapidmigrationassessment/docs/summary_overview.md new file mode 100644 index 000000000000..514f110d4bf4 --- /dev/null +++ b/packages/google-cloud-rapidmigrationassessment/docs/summary_overview.md @@ -0,0 +1,22 @@ +[ +This is a templated file. Adding content to this file may result in it being +reverted. Instead, if you want to place additional content, create an +"overview_content.md" file in `docs/` directory. The Sphinx tool will +pick up on the content and merge the content. +]: # + +# Rapid Migration Assessment API API + +Overview of the APIs available for Rapid Migration Assessment API API. + +## All entries + +Classes, methods and properties & attributes for +Rapid Migration Assessment API API. + +[classes](https://cloud.google.com/python/docs/reference/rapidmigrationassessment/latest/summary_class.html) + +[methods](https://cloud.google.com/python/docs/reference/rapidmigrationassessment/latest/summary_method.html) + +[properties and +attributes](https://cloud.google.com/python/docs/reference/rapidmigrationassessment/latest/summary_property.html) diff --git a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/base.py b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/base.py index 09371318f30f..b26a736de659 100644 --- a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/base.py +++ b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/base.py @@ -86,6 +86,8 @@ def __init__( # Save the scopes. self._scopes = scopes + if not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False # If no credentials are provided, then determine the appropriate # defaults. @@ -98,7 +100,7 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: + elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id ) diff --git a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/grpc.py b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/grpc.py index da06477a7291..15c865e79d20 100644 --- a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/grpc.py +++ b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/grpc.py @@ -127,7 +127,8 @@ def __init__( if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/grpc_asyncio.py b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/grpc_asyncio.py index 081035c1bebc..32e69e076296 100644 --- a/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/grpc_asyncio.py +++ b/packages/google-cloud-rapidmigrationassessment/google/cloud/rapidmigrationassessment_v1/services/rapid_migration_assessment/transports/grpc_asyncio.py @@ -174,7 +174,8 @@ def __init__( if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. - credentials = False + credentials = None + self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None diff --git a/packages/google-cloud-rapidmigrationassessment/noxfile.py b/packages/google-cloud-rapidmigrationassessment/noxfile.py index 1e6cd48d0529..67b7265f7586 100644 --- a/packages/google-cloud-rapidmigrationassessment/noxfile.py +++ b/packages/google-cloud-rapidmigrationassessment/noxfile.py @@ -160,14 +160,28 @@ def install_unittest_dependencies(session, *constraints): session.install("-e", ".", *constraints) -def default(session): +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def unit(session, protobuf_implementation): # Install all test dependencies, then install this package in-place. + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) install_unittest_dependencies(session, "-c", constraints_path) + # TODO(https://github.com/googleapis/synthtool/issues/1976): + # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. + # The 'cpp' implementation requires Protobuf<4. + if protobuf_implementation == "cpp": + session.install("protobuf<4") + # Run py.test against the unit tests. session.run( "py.test", @@ -181,15 +195,12 @@ def default(session): "--cov-fail-under=0", os.path.join("tests", "unit"), *session.posargs, + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, ) -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) -def unit(session): - """Run the unit test suite.""" - default(session) - - def install_systemtest_dependencies(session, *constraints): # Use pre-release gRPC for system tests. # Exclude version 1.52.0rc1 which has a known issue. @@ -358,9 +369,16 @@ def docfx(session): @nox.session(python="3.12") -def prerelease_deps(session): +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def prerelease_deps(session, protobuf_implementation): """Run all tests with prerelease versions of dependencies installed.""" + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + # Install all dependencies session.install("-e", ".[all, tests, tracing]") unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES @@ -397,9 +415,9 @@ def prerelease_deps(session): "protobuf", # dependency of grpc "six", + "grpc-google-iam-v1", "googleapis-common-protos", - # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163 - "grpcio!=1.52.0rc1", + "grpcio", "grpcio-status", "google-api-core", "google-auth", @@ -425,4 +443,10 @@ def prerelease_deps(session): session.run("python", "-c", "import grpc; print(grpc.__version__)") session.run("python", "-c", "import google.auth; print(google.auth.__version__)") - session.run("py.test", "tests/unit") + session.run( + "py.test", + "tests/unit", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) diff --git a/packages/google-cloud-rapidmigrationassessment/setup.py b/packages/google-cloud-rapidmigrationassessment/setup.py index 27ab7ddf9b9e..ab9e4549907d 100644 --- a/packages/google-cloud-rapidmigrationassessment/setup.py +++ b/packages/google-cloud-rapidmigrationassessment/setup.py @@ -46,7 +46,7 @@ # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", "proto-plus >= 1.22.3, <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", + "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", ] url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-rapidmigrationassessment" diff --git a/packages/google-cloud-rapidmigrationassessment/testing/constraints-3.7.txt b/packages/google-cloud-rapidmigrationassessment/testing/constraints-3.7.txt index b8a550c73855..fc812592b0ee 100644 --- a/packages/google-cloud-rapidmigrationassessment/testing/constraints-3.7.txt +++ b/packages/google-cloud-rapidmigrationassessment/testing/constraints-3.7.txt @@ -7,4 +7,4 @@ google-api-core==1.34.1 google-auth==2.14.1 proto-plus==1.22.3 -protobuf==3.19.5 +protobuf==3.20.2 diff --git a/packages/google-cloud-rapidmigrationassessment/tests/unit/gapic/rapidmigrationassessment_v1/test_rapid_migration_assessment.py b/packages/google-cloud-rapidmigrationassessment/tests/unit/gapic/rapidmigrationassessment_v1/test_rapid_migration_assessment.py index 539843b1103a..e84b4b9df5b6 100644 --- a/packages/google-cloud-rapidmigrationassessment/tests/unit/gapic/rapidmigrationassessment_v1/test_rapid_migration_assessment.py +++ b/packages/google-cloud-rapidmigrationassessment/tests/unit/gapic/rapidmigrationassessment_v1/test_rapid_migration_assessment.py @@ -1379,12 +1379,7 @@ async def test_create_collector_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_collector ] = mock_object @@ -1781,12 +1776,7 @@ async def test_create_annotation_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.create_annotation ] = mock_object @@ -2175,12 +2165,7 @@ async def test_get_annotation_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_annotation ] = mock_object @@ -2556,12 +2541,7 @@ async def test_list_collectors_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.list_collectors ] = mock_object @@ -3145,12 +3125,7 @@ async def test_get_collector_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.get_collector ] = mock_object @@ -3534,12 +3509,7 @@ async def test_update_collector_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.update_collector ] = mock_object @@ -3918,12 +3888,7 @@ async def test_delete_collector_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.delete_collector ] = mock_object @@ -4292,12 +4257,7 @@ async def test_resume_collector_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.resume_collector ] = mock_object @@ -4676,12 +4636,7 @@ async def test_register_collector_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.register_collector ] = mock_object @@ -5058,12 +5013,7 @@ async def test_pause_collector_async_use_cached_wrapped_rpc( ) # Replace cached wrapped function with mock - class AwaitableMock(mock.AsyncMock): - def __await__(self): - self.await_count += 1 - return iter([]) - - mock_object = AwaitableMock() + mock_object = mock.AsyncMock() client._client._transport._wrapped_methods[ client._client._transport.pause_collector ] = mock_object