diff --git a/.flake8 b/.flake8 index 29227d4c..2e438749 100644 --- a/.flake8 +++ b/.flake8 @@ -16,7 +16,7 @@ # Generated by synthtool. DO NOT EDIT! [flake8] -ignore = E203, E266, E501, W503 +ignore = E203, E231, E266, E501, W503 exclude = # Exclude generated code. **/proto/** diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 44c78f7c..757c9dca 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:4e1991042fe54b991db9ca17c8fb386e61b22fe4d1472a568bf0fcac85dcf5d3 + digest: sha256:81ed5ecdfc7cac5b699ba4537376f3563f6f04122c4ec9e735d3b3dc1d43dd32 +# created: 2022-05-05T22:08:23.383410683Z diff --git a/.github/auto-approve.yml b/.github/auto-approve.yml new file mode 100644 index 00000000..311ebbb8 --- /dev/null +++ b/.github/auto-approve.yml @@ -0,0 +1,3 @@ +# https://github.com/googleapis/repo-automation-bots/tree/main/packages/auto-approve +processes: + - "OwlBotTemplateChanges" diff --git a/.github/auto-label.yaml b/.github/auto-label.yaml new file mode 100644 index 00000000..41bff0b5 --- /dev/null +++ b/.github/auto-label.yaml @@ -0,0 +1,15 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +requestsize: + enabled: true diff --git a/.kokoro/docker/docs/Dockerfile b/.kokoro/docker/docs/Dockerfile index 4e1b1fb8..238b87b9 100644 --- a/.kokoro/docker/docs/Dockerfile +++ b/.kokoro/docker/docs/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ubuntu:20.04 +from ubuntu:22.04 ENV DEBIAN_FRONTEND noninteractive @@ -60,8 +60,24 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* \ && rm -f /var/cache/apt/archives/*.deb +###################### Install python 3.8.11 + +# Download python 3.8.11 +RUN wget https://www.python.org/ftp/python/3.8.11/Python-3.8.11.tgz + +# Extract files +RUN tar -xvf Python-3.8.11.tgz + +# Install python 3.8.11 +RUN ./Python-3.8.11/configure --enable-optimizations +RUN make altinstall + +###################### Install pip RUN wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \ - && python3.8 /tmp/get-pip.py \ + && python3 /tmp/get-pip.py \ && rm /tmp/get-pip.py +# Test pip +RUN python3 -m pip + CMD ["python3.8"] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62eb5a77..46d23716 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/psf/black - rev: 19.10b0 + rev: 22.3.0 hooks: - id: black - repo: https://gitlab.com/pycqa/flake8 diff --git a/CHANGELOG.md b/CHANGELOG.md index 33c52344..6a6a916d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,18 @@ # Changelog -### [0.6.1](https://github.com/googleapis/python-recommendations-ai/compare/v0.6.0...v0.6.1) (2022-03-05) +## [0.6.2](https://github.com/googleapis/python-recommendations-ai/compare/v0.6.1...v0.6.2) (2022-06-06) + + +### Bug Fixes + +* **deps:** require protobuf <4.0.0dev ([#152](https://github.com/googleapis/python-recommendations-ai/issues/152)) ([5368548](https://github.com/googleapis/python-recommendations-ai/commit/53685485b60cca5338a1df7af22c64024cc17167)) + + +### Documentation + +* fix changelog header to consistent size ([#153](https://github.com/googleapis/python-recommendations-ai/issues/153)) ([35a440a](https://github.com/googleapis/python-recommendations-ai/commit/35a440a1606398fc7fae60c28c21df52058e043b)) + +## [0.6.1](https://github.com/googleapis/python-recommendations-ai/compare/v0.6.0...v0.6.1) (2022-03-05) ### Bug Fixes @@ -24,7 +36,7 @@ * add generated snippets ([#122](https://github.com/googleapis/python-recommendations-ai/issues/122)) ([eebbeb6](https://github.com/googleapis/python-recommendations-ai/commit/eebbeb618b6dc62a1103cb6b3cbc9df65630fff3)) -### [0.5.1](https://www.github.com/googleapis/python-recommendations-ai/compare/v0.5.0...v0.5.1) (2021-11-01) +## [0.5.1](https://www.github.com/googleapis/python-recommendations-ai/compare/v0.5.0...v0.5.1) (2021-11-01) ### Bug Fixes @@ -61,14 +73,14 @@ * improper types in pagers generation ([2d73287](https://www.github.com/googleapis/python-recommendations-ai/commit/2d732875566d49e9eed8702a40120c427222d529)) -### [0.3.3](https://www.github.com/googleapis/python-recommendations-ai/compare/v0.3.2...v0.3.3) (2021-09-24) +## [0.3.3](https://www.github.com/googleapis/python-recommendations-ai/compare/v0.3.2...v0.3.3) (2021-09-24) ### Bug Fixes * add 'dict' annotation type to 'request' ([ff8c418](https://www.github.com/googleapis/python-recommendations-ai/commit/ff8c4189e70770b83b84eb0d6cf886104d62d36a)) -### [0.3.2](https://www.github.com/googleapis/python-recommendations-ai/compare/v0.3.1...v0.3.2) (2021-07-28) +## [0.3.2](https://www.github.com/googleapis/python-recommendations-ai/compare/v0.3.1...v0.3.2) (2021-07-28) ### Bug Fixes @@ -85,7 +97,7 @@ * release as 0.3.2 ([#73](https://www.github.com/googleapis/python-recommendations-ai/issues/73)) ([67460b7](https://www.github.com/googleapis/python-recommendations-ai/commit/67460b7c78ebbdbc0b3fd45623a8ff325f1bb86e)) -### [0.3.1](https://www.github.com/googleapis/python-recommendations-ai/compare/v0.3.0...v0.3.1) (2021-07-20) +## [0.3.1](https://www.github.com/googleapis/python-recommendations-ai/compare/v0.3.0...v0.3.1) (2021-07-20) ### Bug Fixes @@ -109,14 +121,14 @@ * omit mention of Python 2.7 in 'CONTRIBUTING.rst' ([#1127](https://www.github.com/googleapis/python-recommendations-ai/issues/1127)) ([#55](https://www.github.com/googleapis/python-recommendations-ai/issues/55)) ([47faef8](https://www.github.com/googleapis/python-recommendations-ai/commit/47faef890d8356ce60da06925b92a50f23a34e20)), closes [#1126](https://www.github.com/googleapis/python-recommendations-ai/issues/1126) -### [0.2.2](https://www.github.com/googleapis/python-recommendations-ai/compare/v0.2.1...v0.2.2) (2021-06-16) +## [0.2.2](https://www.github.com/googleapis/python-recommendations-ai/compare/v0.2.1...v0.2.2) (2021-06-16) ### Bug Fixes * exclude docs and tests from package ([#52](https://www.github.com/googleapis/python-recommendations-ai/issues/52)) ([5d4926d](https://www.github.com/googleapis/python-recommendations-ai/commit/5d4926d7220f924ba296098e102d8c64b010ad36)) -### [0.2.1](https://www.github.com/googleapis/python-recommendations-ai/compare/v0.2.0...v0.2.1) (2021-05-28) +## [0.2.1](https://www.github.com/googleapis/python-recommendations-ai/compare/v0.2.0...v0.2.1) (2021-05-28) ### Bug Fixes diff --git a/docs/conf.py b/docs/conf.py index 626ef613..77cfe26e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -361,7 +361,10 @@ intersphinx_mapping = { "python": ("https://python.readthedocs.org/en/latest/", None), "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), + "google.api_core": ( + "https://googleapis.dev/python/google-api-core/latest/", + None, + ), "grpc": ("https://grpc.github.io/grpc/python/", None), "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), diff --git a/google/cloud/recommendationengine_v1beta1/services/catalog_service/async_client.py b/google/cloud/recommendationengine_v1beta1/services/catalog_service/async_client.py index a7f67de8..7a7bb015 100644 --- a/google/cloud/recommendationengine_v1beta1/services/catalog_service/async_client.py +++ b/google/cloud/recommendationengine_v1beta1/services/catalog_service/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -227,9 +227,9 @@ async def create_catalog_item( from google.cloud import recommendationengine_v1beta1 - def sample_create_catalog_item(): + async def sample_create_catalog_item(): # Create a client - client = recommendationengine_v1beta1.CatalogServiceClient() + client = recommendationengine_v1beta1.CatalogServiceAsyncClient() # Initialize request argument(s) catalog_item = recommendationengine_v1beta1.CatalogItem() @@ -243,7 +243,7 @@ def sample_create_catalog_item(): ) # Make the request - response = client.create_catalog_item(request=request) + response = await client.create_catalog_item(request=request) # Handle the response print(response) @@ -320,7 +320,12 @@ def sample_create_catalog_item(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -340,9 +345,9 @@ async def get_catalog_item( from google.cloud import recommendationengine_v1beta1 - def sample_get_catalog_item(): + async def sample_get_catalog_item(): # Create a client - client = recommendationengine_v1beta1.CatalogServiceClient() + client = recommendationengine_v1beta1.CatalogServiceAsyncClient() # Initialize request argument(s) request = recommendationengine_v1beta1.GetCatalogItemRequest( @@ -350,7 +355,7 @@ def sample_get_catalog_item(): ) # Make the request - response = client.get_catalog_item(request=request) + response = await client.get_catalog_item(request=request) # Handle the response print(response) @@ -420,7 +425,12 @@ def sample_get_catalog_item(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -441,9 +451,9 @@ async def list_catalog_items( from google.cloud import recommendationengine_v1beta1 - def sample_list_catalog_items(): + async def sample_list_catalog_items(): # Create a client - client = recommendationengine_v1beta1.CatalogServiceClient() + client = recommendationengine_v1beta1.CatalogServiceAsyncClient() # Initialize request argument(s) request = recommendationengine_v1beta1.ListCatalogItemsRequest( @@ -454,7 +464,7 @@ def sample_list_catalog_items(): page_result = client.list_catalog_items(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -534,12 +544,20 @@ def sample_list_catalog_items(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListCatalogItemsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -559,14 +577,13 @@ async def update_catalog_item( r"""Updates a catalog item. Partial updating is supported. Non-existing items will be created. - .. code-block:: python from google.cloud import recommendationengine_v1beta1 - def sample_update_catalog_item(): + async def sample_update_catalog_item(): # Create a client - client = recommendationengine_v1beta1.CatalogServiceClient() + client = recommendationengine_v1beta1.CatalogServiceAsyncClient() # Initialize request argument(s) catalog_item = recommendationengine_v1beta1.CatalogItem() @@ -580,7 +597,7 @@ def sample_update_catalog_item(): ) # Make the request - response = client.update_catalog_item(request=request) + response = await client.update_catalog_item(request=request) # Handle the response print(response) @@ -669,7 +686,12 @@ def sample_update_catalog_item(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -689,9 +711,9 @@ async def delete_catalog_item( from google.cloud import recommendationengine_v1beta1 - def sample_delete_catalog_item(): + async def sample_delete_catalog_item(): # Create a client - client = recommendationengine_v1beta1.CatalogServiceClient() + client = recommendationengine_v1beta1.CatalogServiceAsyncClient() # Initialize request argument(s) request = recommendationengine_v1beta1.DeleteCatalogItemRequest( @@ -699,7 +721,7 @@ def sample_delete_catalog_item(): ) # Make the request - client.delete_catalog_item(request=request) + await client.delete_catalog_item(request=request) Args: request (Union[google.cloud.recommendationengine_v1beta1.types.DeleteCatalogItemRequest, dict]): @@ -761,7 +783,10 @@ def sample_delete_catalog_item(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def import_catalog_items( @@ -784,14 +809,13 @@ async def import_catalog_items( it is possible for a subset of the items to be successfully updated. - .. code-block:: python from google.cloud import recommendationengine_v1beta1 - def sample_import_catalog_items(): + async def sample_import_catalog_items(): # Create a client - client = recommendationengine_v1beta1.CatalogServiceClient() + client = recommendationengine_v1beta1.CatalogServiceAsyncClient() # Initialize request argument(s) request = recommendationengine_v1beta1.ImportCatalogItemsRequest( @@ -803,7 +827,7 @@ def sample_import_catalog_items(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -909,7 +933,12 @@ def sample_import_catalog_items(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( diff --git a/google/cloud/recommendationengine_v1beta1/services/catalog_service/client.py b/google/cloud/recommendationengine_v1beta1/services/catalog_service/client.py index 3980674e..c837d295 100644 --- a/google/cloud/recommendationengine_v1beta1/services/catalog_service/client.py +++ b/google/cloud/recommendationengine_v1beta1/services/catalog_service/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -61,7 +61,10 @@ class CatalogServiceClientMeta(type): _transport_registry["grpc"] = CatalogServiceGrpcTransport _transport_registry["grpc_asyncio"] = CatalogServiceGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[CatalogServiceTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[CatalogServiceTransport]: """Returns an appropriate transport class. Args: @@ -168,10 +171,16 @@ def transport(self) -> CatalogServiceTransport: return self._transport @staticmethod - def catalog_path(project: str, location: str, catalog: str,) -> str: + def catalog_path( + project: str, + location: str, + catalog: str, + ) -> str: """Returns a fully-qualified catalog string.""" return "projects/{project}/locations/{location}/catalogs/{catalog}".format( - project=project, location=location, catalog=catalog, + project=project, + location=location, + catalog=catalog, ) @staticmethod @@ -184,7 +193,9 @@ def parse_catalog_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -197,9 +208,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -208,9 +223,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -219,9 +238,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -230,10 +253,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -506,7 +533,12 @@ def sample_create_catalog_item(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -596,7 +628,12 @@ def sample_get_catalog_item(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -700,12 +737,20 @@ def sample_list_catalog_items(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListCatalogItemsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -725,7 +770,6 @@ def update_catalog_item( r"""Updates a catalog item. Partial updating is supported. Non-existing items will be created. - .. code-block:: python from google.cloud import recommendationengine_v1beta1 @@ -825,7 +869,12 @@ def sample_update_catalog_item(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -907,7 +956,10 @@ def sample_delete_catalog_item(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def import_catalog_items( @@ -930,7 +982,6 @@ def import_catalog_items( it is possible for a subset of the items to be successfully updated. - .. code-block:: python from google.cloud import recommendationengine_v1beta1 @@ -1045,7 +1096,12 @@ def sample_import_catalog_items(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( diff --git a/google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/base.py b/google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/base.py index 65f1bd79..fce50654 100644 --- a/google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/base.py +++ b/google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/base.py @@ -85,6 +85,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -220,9 +221,9 @@ def _prep_wrapped_messages(self, client_info): def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() @@ -288,5 +289,9 @@ def import_catalog_items( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("CatalogServiceTransport",) diff --git a/google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/grpc.py b/google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/grpc.py index e356ef61..5a898464 100644 --- a/google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/grpc.py +++ b/google/cloud/recommendationengine_v1beta1/services/catalog_service/transports/grpc.py @@ -231,8 +231,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property @@ -418,5 +417,9 @@ def import_catalog_items( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("CatalogServiceGrpcTransport",) diff --git a/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/async_client.py b/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/async_client.py index b4aeee73..d89261ad 100644 --- a/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/async_client.py +++ b/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -244,9 +244,9 @@ async def create_prediction_api_key_registration( from google.cloud import recommendationengine_v1beta1 - def sample_create_prediction_api_key_registration(): + async def sample_create_prediction_api_key_registration(): # Create a client - client = recommendationengine_v1beta1.PredictionApiKeyRegistryClient() + client = recommendationengine_v1beta1.PredictionApiKeyRegistryAsyncClient() # Initialize request argument(s) request = recommendationengine_v1beta1.CreatePredictionApiKeyRegistrationRequest( @@ -254,7 +254,7 @@ def sample_create_prediction_api_key_registration(): ) # Make the request - response = client.create_prediction_api_key_registration(request=request) + response = await client.create_prediction_api_key_registration(request=request) # Handle the response print(response) @@ -333,7 +333,12 @@ def sample_create_prediction_api_key_registration(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -353,14 +358,13 @@ async def list_prediction_api_key_registrations( r"""List the registered apiKeys for use with predict method. - .. code-block:: python from google.cloud import recommendationengine_v1beta1 - def sample_list_prediction_api_key_registrations(): + async def sample_list_prediction_api_key_registrations(): # Create a client - client = recommendationengine_v1beta1.PredictionApiKeyRegistryClient() + client = recommendationengine_v1beta1.PredictionApiKeyRegistryAsyncClient() # Initialize request argument(s) request = recommendationengine_v1beta1.ListPredictionApiKeyRegistrationsRequest( @@ -371,7 +375,7 @@ def sample_list_prediction_api_key_registrations(): page_result = client.list_prediction_api_key_registrations(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -410,8 +414,10 @@ def sample_list_prediction_api_key_registrations(): "the individual field arguments should be set." ) - request = prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsRequest( - request + request = ( + prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsRequest( + request + ) ) # If we have keyword arguments corresponding to fields on the @@ -444,12 +450,20 @@ def sample_list_prediction_api_key_registrations(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListPredictionApiKeyRegistrationsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -473,9 +487,9 @@ async def delete_prediction_api_key_registration( from google.cloud import recommendationengine_v1beta1 - def sample_delete_prediction_api_key_registration(): + async def sample_delete_prediction_api_key_registration(): # Create a client - client = recommendationengine_v1beta1.PredictionApiKeyRegistryClient() + client = recommendationengine_v1beta1.PredictionApiKeyRegistryAsyncClient() # Initialize request argument(s) request = recommendationengine_v1beta1.DeletePredictionApiKeyRegistrationRequest( @@ -483,7 +497,7 @@ def sample_delete_prediction_api_key_registration(): ) # Make the request - client.delete_prediction_api_key_registration(request=request) + await client.delete_prediction_api_key_registration(request=request) Args: request (Union[google.cloud.recommendationengine_v1beta1.types.DeletePredictionApiKeyRegistrationRequest, dict]): @@ -548,7 +562,10 @@ def sample_delete_prediction_api_key_registration(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def __aenter__(self): diff --git a/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/client.py b/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/client.py index 8b457520..b50ab737 100644 --- a/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/client.py +++ b/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -60,7 +60,8 @@ class PredictionApiKeyRegistryClientMeta(type): _transport_registry["grpc_asyncio"] = PredictionApiKeyRegistryGrpcAsyncIOTransport def get_transport_class( - cls, label: str = None, + cls, + label: str = None, ) -> Type[PredictionApiKeyRegistryTransport]: """Returns an appropriate transport class. @@ -173,7 +174,10 @@ def transport(self) -> PredictionApiKeyRegistryTransport: @staticmethod def event_store_path( - project: str, location: str, catalog: str, event_store: str, + project: str, + location: str, + catalog: str, + event_store: str, ) -> str: """Returns a fully-qualified event_store string.""" return "projects/{project}/locations/{location}/catalogs/{catalog}/eventStores/{event_store}".format( @@ -219,7 +223,9 @@ def parse_prediction_api_key_registration_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -232,9 +238,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -243,9 +253,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -254,9 +268,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -265,10 +283,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -547,7 +569,12 @@ def sample_create_prediction_api_key_registration(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -567,7 +594,6 @@ def list_prediction_api_key_registrations( r"""List the registered apiKeys for use with predict method. - .. code-block:: python from google.cloud import recommendationengine_v1beta1 @@ -653,12 +679,20 @@ def sample_list_prediction_api_key_registrations(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListPredictionApiKeyRegistrationsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -752,7 +786,10 @@ def sample_delete_prediction_api_key_registration(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def __enter__(self): diff --git a/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/pagers.py b/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/pagers.py index c658450f..5de5ab50 100644 --- a/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/pagers.py +++ b/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/pagers.py @@ -71,8 +71,10 @@ def __init__( sent along with the request as metadata. """ self._method = method - self._request = prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsRequest( - request + self._request = ( + prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsRequest( + request + ) ) self._response = response self._metadata = metadata @@ -146,8 +148,10 @@ def __init__( sent along with the request as metadata. """ self._method = method - self._request = prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsRequest( - request + self._request = ( + prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsRequest( + request + ) ) self._response = response self._metadata = metadata diff --git a/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/base.py b/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/base.py index 24b6a10f..8fdd60aa 100644 --- a/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/base.py +++ b/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/base.py @@ -83,6 +83,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -173,9 +174,9 @@ def _prep_wrapped_messages(self, client_info): def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() @@ -214,5 +215,9 @@ def delete_prediction_api_key_registration( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("PredictionApiKeyRegistryTransport",) diff --git a/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/grpc.py b/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/grpc.py index 8ae1d305..8391f031 100644 --- a/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/grpc.py +++ b/google/cloud/recommendationengine_v1beta1/services/prediction_api_key_registry/transports/grpc.py @@ -232,8 +232,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property @@ -336,5 +335,9 @@ def delete_prediction_api_key_registration( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("PredictionApiKeyRegistryGrpcTransport",) diff --git a/google/cloud/recommendationengine_v1beta1/services/prediction_service/async_client.py b/google/cloud/recommendationengine_v1beta1/services/prediction_service/async_client.py index 07a39569..0becfa2c 100644 --- a/google/cloud/recommendationengine_v1beta1/services/prediction_service/async_client.py +++ b/google/cloud/recommendationengine_v1beta1/services/prediction_service/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -219,14 +219,13 @@ async def predict( service. `Learn more `__. - .. code-block:: python from google.cloud import recommendationengine_v1beta1 - def sample_predict(): + async def sample_predict(): # Create a client - client = recommendationengine_v1beta1.PredictionServiceClient() + client = recommendationengine_v1beta1.PredictionServiceAsyncClient() # Initialize request argument(s) user_event = recommendationengine_v1beta1.UserEvent() @@ -242,7 +241,7 @@ def sample_predict(): page_result = client.predict(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -360,12 +359,20 @@ def sample_predict(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.PredictAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. diff --git a/google/cloud/recommendationengine_v1beta1/services/prediction_service/client.py b/google/cloud/recommendationengine_v1beta1/services/prediction_service/client.py index bb41a348..5e804e89 100644 --- a/google/cloud/recommendationengine_v1beta1/services/prediction_service/client.py +++ b/google/cloud/recommendationengine_v1beta1/services/prediction_service/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -57,7 +57,8 @@ class PredictionServiceClientMeta(type): _transport_registry["grpc_asyncio"] = PredictionServiceGrpcAsyncIOTransport def get_transport_class( - cls, label: str = None, + cls, + label: str = None, ) -> Type[PredictionServiceTransport]: """Returns an appropriate transport class. @@ -164,7 +165,11 @@ def transport(self) -> PredictionServiceTransport: @staticmethod def placement_path( - project: str, location: str, catalog: str, event_store: str, placement: str, + project: str, + location: str, + catalog: str, + event_store: str, + placement: str, ) -> str: """Returns a fully-qualified placement string.""" return "projects/{project}/locations/{location}/catalogs/{catalog}/eventStores/{event_store}/placements/{placement}".format( @@ -185,7 +190,9 @@ def parse_placement_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -198,9 +205,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -209,9 +220,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -220,9 +235,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -231,10 +250,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -424,7 +447,6 @@ def predict( service. `Learn more `__. - .. code-block:: python from google.cloud import recommendationengine_v1beta1 @@ -555,12 +577,20 @@ def sample_predict(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.PredictPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. diff --git a/google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/base.py b/google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/base.py index 6eb54c95..72fa33e5 100644 --- a/google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/base.py +++ b/google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/base.py @@ -80,6 +80,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -140,9 +141,9 @@ def _prep_wrapped_messages(self, client_info): def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() @@ -158,5 +159,9 @@ def predict( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("PredictionServiceTransport",) diff --git a/google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/grpc.py b/google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/grpc.py index e4db259c..c765bf3b 100644 --- a/google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/grpc.py +++ b/google/cloud/recommendationengine_v1beta1/services/prediction_service/transports/grpc.py @@ -224,8 +224,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property @@ -263,5 +262,9 @@ def predict( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("PredictionServiceGrpcTransport",) diff --git a/google/cloud/recommendationengine_v1beta1/services/user_event_service/async_client.py b/google/cloud/recommendationengine_v1beta1/services/user_event_service/async_client.py index 55dbfa7f..1df4282d 100644 --- a/google/cloud/recommendationengine_v1beta1/services/user_event_service/async_client.py +++ b/google/cloud/recommendationengine_v1beta1/services/user_event_service/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -228,9 +228,9 @@ async def write_user_event( from google.cloud import recommendationengine_v1beta1 - def sample_write_user_event(): + async def sample_write_user_event(): # Create a client - client = recommendationengine_v1beta1.UserEventServiceClient() + client = recommendationengine_v1beta1.UserEventServiceAsyncClient() # Initialize request argument(s) user_event = recommendationengine_v1beta1.UserEvent() @@ -243,7 +243,7 @@ def sample_write_user_event(): ) # Make the request - response = client.write_user_event(request=request) + response = await client.write_user_event(request=request) # Handle the response print(response) @@ -322,7 +322,12 @@ def sample_write_user_event(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -346,14 +351,13 @@ async def collect_user_event( JavaScript pixel. Users should not call this method directly. - .. code-block:: python from google.cloud import recommendationengine_v1beta1 - def sample_collect_user_event(): + async def sample_collect_user_event(): # Create a client - client = recommendationengine_v1beta1.UserEventServiceClient() + client = recommendationengine_v1beta1.UserEventServiceAsyncClient() # Initialize request argument(s) request = recommendationengine_v1beta1.CollectUserEventRequest( @@ -362,7 +366,7 @@ def sample_collect_user_event(): ) # Make the request - response = client.collect_user_event(request=request) + response = await client.collect_user_event(request=request) # Handle the response print(response) @@ -512,7 +516,12 @@ def sample_collect_user_event(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -530,14 +539,13 @@ async def list_user_events( r"""Gets a list of user events within a time range, with potential filtering. - .. code-block:: python from google.cloud import recommendationengine_v1beta1 - def sample_list_user_events(): + async def sample_list_user_events(): # Create a client - client = recommendationengine_v1beta1.UserEventServiceClient() + client = recommendationengine_v1beta1.UserEventServiceAsyncClient() # Initialize request argument(s) request = recommendationengine_v1beta1.ListUserEventsRequest( @@ -548,7 +556,7 @@ def sample_list_user_events(): page_result = client.list_user_events(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -662,12 +670,20 @@ def sample_list_user_events(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListUserEventsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -690,14 +706,13 @@ async def purge_user_events( or days to complete. To test a filter, use the list command first. - .. code-block:: python from google.cloud import recommendationengine_v1beta1 - def sample_purge_user_events(): + async def sample_purge_user_events(): # Create a client - client = recommendationengine_v1beta1.UserEventServiceClient() + client = recommendationengine_v1beta1.UserEventServiceAsyncClient() # Initialize request argument(s) request = recommendationengine_v1beta1.PurgeUserEventsRequest( @@ -710,7 +725,7 @@ def sample_purge_user_events(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -822,7 +837,12 @@ def sample_purge_user_events(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -855,14 +875,13 @@ async def import_user_events( successfully inserted. Operation.metadata is of type ImportMetadata. - .. code-block:: python from google.cloud import recommendationengine_v1beta1 - def sample_import_user_events(): + async def sample_import_user_events(): # Create a client - client = recommendationengine_v1beta1.UserEventServiceClient() + client = recommendationengine_v1beta1.UserEventServiceAsyncClient() # Initialize request argument(s) request = recommendationengine_v1beta1.ImportUserEventsRequest( @@ -874,7 +893,7 @@ def sample_import_user_events(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -981,7 +1000,12 @@ def sample_import_user_events(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( diff --git a/google/cloud/recommendationengine_v1beta1/services/user_event_service/client.py b/google/cloud/recommendationengine_v1beta1/services/user_event_service/client.py index 4cb8a18f..17523b75 100644 --- a/google/cloud/recommendationengine_v1beta1/services/user_event_service/client.py +++ b/google/cloud/recommendationengine_v1beta1/services/user_event_service/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -63,7 +63,10 @@ class UserEventServiceClientMeta(type): _transport_registry["grpc"] = UserEventServiceGrpcTransport _transport_registry["grpc_asyncio"] = UserEventServiceGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[UserEventServiceTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[UserEventServiceTransport]: """Returns an appropriate transport class. Args: @@ -171,7 +174,10 @@ def transport(self) -> UserEventServiceTransport: @staticmethod def event_store_path( - project: str, location: str, catalog: str, event_store: str, + project: str, + location: str, + catalog: str, + event_store: str, ) -> str: """Returns a fully-qualified event_store string.""" return "projects/{project}/locations/{location}/catalogs/{catalog}/eventStores/{event_store}".format( @@ -191,7 +197,9 @@ def parse_event_store_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -204,9 +212,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -215,9 +227,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -226,9 +242,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -237,10 +257,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -514,7 +538,12 @@ def sample_write_user_event(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -538,7 +567,6 @@ def collect_user_event( JavaScript pixel. Users should not call this method directly. - .. code-block:: python from google.cloud import recommendationengine_v1beta1 @@ -694,7 +722,12 @@ def sample_collect_user_event(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -712,7 +745,6 @@ def list_user_events( r"""Gets a list of user events within a time range, with potential filtering. - .. code-block:: python from google.cloud import recommendationengine_v1beta1 @@ -834,12 +866,20 @@ def sample_list_user_events(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListUserEventsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -862,7 +902,6 @@ def purge_user_events( or days to complete. To test a filter, use the list command first. - .. code-block:: python from google.cloud import recommendationengine_v1beta1 @@ -984,7 +1023,12 @@ def sample_purge_user_events(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -1017,7 +1061,6 @@ def import_user_events( successfully inserted. Operation.metadata is of type ImportMetadata. - .. code-block:: python from google.cloud import recommendationengine_v1beta1 @@ -1133,7 +1176,12 @@ def sample_import_user_events(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( diff --git a/google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/base.py b/google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/base.py index ccfb7cac..f28c8e92 100644 --- a/google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/base.py +++ b/google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/base.py @@ -85,6 +85,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -205,9 +206,9 @@ def _prep_wrapped_messages(self, client_info): def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() @@ -264,5 +265,9 @@ def import_user_events( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("UserEventServiceTransport",) diff --git a/google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/grpc.py b/google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/grpc.py index a55c231c..7f41c702 100644 --- a/google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/grpc.py +++ b/google/cloud/recommendationengine_v1beta1/services/user_event_service/transports/grpc.py @@ -231,8 +231,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property @@ -403,5 +402,9 @@ def import_user_events( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("UserEventServiceGrpcTransport",) diff --git a/google/cloud/recommendationengine_v1beta1/types/__init__.py b/google/cloud/recommendationengine_v1beta1/types/__init__.py index 355c7890..c64229fe 100644 --- a/google/cloud/recommendationengine_v1beta1/types/__init__.py +++ b/google/cloud/recommendationengine_v1beta1/types/__init__.py @@ -26,7 +26,9 @@ ListCatalogItemsResponse, UpdateCatalogItemRequest, ) -from .common import FeatureMap +from .common import ( + FeatureMap, +) from .import_ import ( CatalogInlineSource, GcsSource, diff --git a/google/cloud/recommendationengine_v1beta1/types/catalog.py b/google/cloud/recommendationengine_v1beta1/types/catalog.py index c4fa5f31..ee6bcac2 100644 --- a/google/cloud/recommendationengine_v1beta1/types/catalog.py +++ b/google/cloud/recommendationengine_v1beta1/types/catalog.py @@ -20,7 +20,11 @@ __protobuf__ = proto.module( package="google.cloud.recommendationengine.v1beta1", - manifest={"CatalogItem", "ProductCatalogItem", "Image",}, + manifest={ + "CatalogItem", + "ProductCatalogItem", + "Image", + }, ) @@ -107,18 +111,45 @@ class CategoryHierarchy(proto.Message): specificity (from least to most specific). """ - categories = proto.RepeatedField(proto.STRING, number=1,) + categories = proto.RepeatedField( + proto.STRING, + number=1, + ) - id = proto.Field(proto.STRING, number=1,) + id = proto.Field( + proto.STRING, + number=1, + ) category_hierarchies = proto.RepeatedField( - proto.MESSAGE, number=2, message=CategoryHierarchy, - ) - title = proto.Field(proto.STRING, number=3,) - description = proto.Field(proto.STRING, number=4,) - item_attributes = proto.Field(proto.MESSAGE, number=5, message=common.FeatureMap,) - language_code = proto.Field(proto.STRING, number=6,) - tags = proto.RepeatedField(proto.STRING, number=8,) - item_group_id = proto.Field(proto.STRING, number=9,) + proto.MESSAGE, + number=2, + message=CategoryHierarchy, + ) + title = proto.Field( + proto.STRING, + number=3, + ) + description = proto.Field( + proto.STRING, + number=4, + ) + item_attributes = proto.Field( + proto.MESSAGE, + number=5, + message=common.FeatureMap, + ) + language_code = proto.Field( + proto.STRING, + number=6, + ) + tags = proto.RepeatedField( + proto.STRING, + number=8, + ) + item_group_id = proto.Field( + proto.STRING, + number=9, + ) product_metadata = proto.Field( proto.MESSAGE, number=10, @@ -147,7 +178,7 @@ class ProductCatalogItem(proto.Message): Optional. The product price range. This field is a member of `oneof`_ ``price``. - costs (Sequence[google.cloud.recommendationengine_v1beta1.types.ProductCatalogItem.CostsEntry]): + costs (Mapping[str, float]): Optional. A map to pass the costs associated with the product. @@ -199,8 +230,14 @@ class ExactPrice(proto.Message): 'displayPrice'. """ - display_price = proto.Field(proto.FLOAT, number=1,) - original_price = proto.Field(proto.FLOAT, number=2,) + display_price = proto.Field( + proto.FLOAT, + number=1, + ) + original_price = proto.Field( + proto.FLOAT, + number=2, + ) class PriceRange(proto.Message): r"""Product price range when there are a range of prices for @@ -213,21 +250,54 @@ class PriceRange(proto.Message): Required. The maximum product price. """ - min_ = proto.Field(proto.FLOAT, number=1,) - max_ = proto.Field(proto.FLOAT, number=2,) + min_ = proto.Field( + proto.FLOAT, + number=1, + ) + max_ = proto.Field( + proto.FLOAT, + number=2, + ) exact_price = proto.Field( - proto.MESSAGE, number=1, oneof="price", message=ExactPrice, + proto.MESSAGE, + number=1, + oneof="price", + message=ExactPrice, ) price_range = proto.Field( - proto.MESSAGE, number=2, oneof="price", message=PriceRange, + proto.MESSAGE, + number=2, + oneof="price", + message=PriceRange, + ) + costs = proto.MapField( + proto.STRING, + proto.FLOAT, + number=3, + ) + currency_code = proto.Field( + proto.STRING, + number=4, + ) + stock_state = proto.Field( + proto.ENUM, + number=5, + enum=StockState, + ) + available_quantity = proto.Field( + proto.INT64, + number=6, + ) + canonical_product_uri = proto.Field( + proto.STRING, + number=7, + ) + images = proto.RepeatedField( + proto.MESSAGE, + number=8, + message="Image", ) - costs = proto.MapField(proto.STRING, proto.FLOAT, number=3,) - currency_code = proto.Field(proto.STRING, number=4,) - stock_state = proto.Field(proto.ENUM, number=5, enum=StockState,) - available_quantity = proto.Field(proto.INT64, number=6,) - canonical_product_uri = proto.Field(proto.STRING, number=7,) - images = proto.RepeatedField(proto.MESSAGE, number=8, message="Image",) class Image(proto.Message): @@ -245,9 +315,18 @@ class Image(proto.Message): pixels. """ - uri = proto.Field(proto.STRING, number=1,) - height = proto.Field(proto.INT32, number=2,) - width = proto.Field(proto.INT32, number=3,) + uri = proto.Field( + proto.STRING, + number=1, + ) + height = proto.Field( + proto.INT32, + number=2, + ) + width = proto.Field( + proto.INT32, + number=3, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/recommendationengine_v1beta1/types/catalog_service.py b/google/cloud/recommendationengine_v1beta1/types/catalog_service.py index 96b734d4..76ed466a 100644 --- a/google/cloud/recommendationengine_v1beta1/types/catalog_service.py +++ b/google/cloud/recommendationengine_v1beta1/types/catalog_service.py @@ -43,8 +43,15 @@ class CreateCatalogItemRequest(proto.Message): Required. The catalog item to create. """ - parent = proto.Field(proto.STRING, number=1,) - catalog_item = proto.Field(proto.MESSAGE, number=2, message=catalog.CatalogItem,) + parent = proto.Field( + proto.STRING, + number=1, + ) + catalog_item = proto.Field( + proto.MESSAGE, + number=2, + message=catalog.CatalogItem, + ) class GetCatalogItemRequest(proto.Message): @@ -56,7 +63,10 @@ class GetCatalogItemRequest(proto.Message): ``projects/*/locations/global/catalogs/default_catalog/catalogitems/some_catalog_item_id``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class ListCatalogItemsRequest(proto.Message): @@ -78,10 +88,22 @@ class ListCatalogItemsRequest(proto.Message): results. """ - parent = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) - filter = proto.Field(proto.STRING, number=4,) + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) class ListCatalogItemsResponse(proto.Message): @@ -101,9 +123,14 @@ def raw_page(self): return self catalog_items = proto.RepeatedField( - proto.MESSAGE, number=1, message=catalog.CatalogItem, + proto.MESSAGE, + number=1, + message=catalog.CatalogItem, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, ) - next_page_token = proto.Field(proto.STRING, number=2,) class UpdateCatalogItemRequest(proto.Message): @@ -122,10 +149,19 @@ class UpdateCatalogItemRequest(proto.Message): default update all fields. """ - name = proto.Field(proto.STRING, number=1,) - catalog_item = proto.Field(proto.MESSAGE, number=2, message=catalog.CatalogItem,) + name = proto.Field( + proto.STRING, + number=1, + ) + catalog_item = proto.Field( + proto.MESSAGE, + number=2, + message=catalog.CatalogItem, + ) update_mask = proto.Field( - proto.MESSAGE, number=3, message=field_mask_pb2.FieldMask, + proto.MESSAGE, + number=3, + message=field_mask_pb2.FieldMask, ) @@ -138,7 +174,10 @@ class DeleteCatalogItemRequest(proto.Message): ``projects/*/locations/global/catalogs/default_catalog/catalogItems/some_catalog_item_id``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/recommendationengine_v1beta1/types/common.py b/google/cloud/recommendationengine_v1beta1/types/common.py index 1f43577c..4927ef10 100644 --- a/google/cloud/recommendationengine_v1beta1/types/common.py +++ b/google/cloud/recommendationengine_v1beta1/types/common.py @@ -17,7 +17,10 @@ __protobuf__ = proto.module( - package="google.cloud.recommendationengine.v1beta1", manifest={"FeatureMap",}, + package="google.cloud.recommendationengine.v1beta1", + manifest={ + "FeatureMap", + }, ) @@ -27,7 +30,7 @@ class FeatureMap(proto.Message): categorical/numerical features. Attributes: - categorical_features (Sequence[google.cloud.recommendationengine_v1beta1.types.FeatureMap.CategoricalFeaturesEntry]): + categorical_features (Mapping[str, google.cloud.recommendationengine_v1beta1.types.FeatureMap.StringList]): Categorical features that can take on one of a limited number of possible values. Some examples would be the brand/maker of a product, or country of a customer. @@ -36,7 +39,7 @@ class FeatureMap(proto.Message): For example: ``{ "colors": {"value": ["yellow", "green"]}, "sizes": {"value":["S", "M"]}`` - numerical_features (Sequence[google.cloud.recommendationengine_v1beta1.types.FeatureMap.NumericalFeaturesEntry]): + numerical_features (Mapping[str, google.cloud.recommendationengine_v1beta1.types.FeatureMap.FloatList]): Numerical features. Some examples would be the height/weight of a product, or age of a customer. @@ -55,7 +58,10 @@ class StringList(proto.Message): 128 bytes. """ - value = proto.RepeatedField(proto.STRING, number=1,) + value = proto.RepeatedField( + proto.STRING, + number=1, + ) class FloatList(proto.Message): r"""A list of float features. @@ -65,13 +71,22 @@ class FloatList(proto.Message): Float feature value. """ - value = proto.RepeatedField(proto.FLOAT, number=1,) + value = proto.RepeatedField( + proto.FLOAT, + number=1, + ) categorical_features = proto.MapField( - proto.STRING, proto.MESSAGE, number=1, message=StringList, + proto.STRING, + proto.MESSAGE, + number=1, + message=StringList, ) numerical_features = proto.MapField( - proto.STRING, proto.MESSAGE, number=2, message=FloatList, + proto.STRING, + proto.MESSAGE, + number=2, + message=FloatList, ) diff --git a/google/cloud/recommendationengine_v1beta1/types/import_.py b/google/cloud/recommendationengine_v1beta1/types/import_.py index e0d798d9..c238c75c 100644 --- a/google/cloud/recommendationengine_v1beta1/types/import_.py +++ b/google/cloud/recommendationengine_v1beta1/types/import_.py @@ -56,7 +56,10 @@ class GcsSource(proto.Message): the expected file format and setup instructions. """ - input_uris = proto.RepeatedField(proto.STRING, number=1,) + input_uris = proto.RepeatedField( + proto.STRING, + number=1, + ) class CatalogInlineSource(proto.Message): @@ -70,7 +73,9 @@ class CatalogInlineSource(proto.Message): """ catalog_items = proto.RepeatedField( - proto.MESSAGE, number=1, message=catalog.CatalogItem, + proto.MESSAGE, + number=1, + message=catalog.CatalogItem, ) @@ -85,7 +90,9 @@ class UserEventInlineSource(proto.Message): """ user_events = proto.RepeatedField( - proto.MESSAGE, number=1, message=user_event.UserEvent, + proto.MESSAGE, + number=1, + message=user_event.UserEvent, ) @@ -104,7 +111,11 @@ class ImportErrorsConfig(proto.Message): This field is a member of `oneof`_ ``destination``. """ - gcs_prefix = proto.Field(proto.STRING, number=1, oneof="destination",) + gcs_prefix = proto.Field( + proto.STRING, + number=1, + oneof="destination", + ) class ImportCatalogItemsRequest(proto.Message): @@ -130,10 +141,24 @@ class ImportCatalogItemsRequest(proto.Message): incurred during the Import. """ - parent = proto.Field(proto.STRING, number=1,) - request_id = proto.Field(proto.STRING, number=2,) - input_config = proto.Field(proto.MESSAGE, number=3, message="InputConfig",) - errors_config = proto.Field(proto.MESSAGE, number=4, message="ImportErrorsConfig",) + parent = proto.Field( + proto.STRING, + number=1, + ) + request_id = proto.Field( + proto.STRING, + number=2, + ) + input_config = proto.Field( + proto.MESSAGE, + number=3, + message="InputConfig", + ) + errors_config = proto.Field( + proto.MESSAGE, + number=4, + message="ImportErrorsConfig", + ) class ImportUserEventsRequest(proto.Message): @@ -159,10 +184,24 @@ class ImportUserEventsRequest(proto.Message): incurred during the Import. """ - parent = proto.Field(proto.STRING, number=1,) - request_id = proto.Field(proto.STRING, number=2,) - input_config = proto.Field(proto.MESSAGE, number=3, message="InputConfig",) - errors_config = proto.Field(proto.MESSAGE, number=4, message="ImportErrorsConfig",) + parent = proto.Field( + proto.STRING, + number=1, + ) + request_id = proto.Field( + proto.STRING, + number=2, + ) + input_config = proto.Field( + proto.MESSAGE, + number=3, + message="InputConfig", + ) + errors_config = proto.Field( + proto.MESSAGE, + number=4, + message="ImportErrorsConfig", + ) class InputConfig(proto.Message): @@ -194,13 +233,22 @@ class InputConfig(proto.Message): """ catalog_inline_source = proto.Field( - proto.MESSAGE, number=1, oneof="source", message="CatalogInlineSource", + proto.MESSAGE, + number=1, + oneof="source", + message="CatalogInlineSource", ) gcs_source = proto.Field( - proto.MESSAGE, number=2, oneof="source", message="GcsSource", + proto.MESSAGE, + number=2, + oneof="source", + message="GcsSource", ) user_event_inline_source = proto.Field( - proto.MESSAGE, number=3, oneof="source", message="UserEventInlineSource", + proto.MESSAGE, + number=3, + oneof="source", + message="UserEventInlineSource", ) @@ -229,12 +277,32 @@ class ImportMetadata(proto.Message): is done, this is also the finish time. """ - operation_name = proto.Field(proto.STRING, number=5,) - request_id = proto.Field(proto.STRING, number=3,) - create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) - success_count = proto.Field(proto.INT64, number=1,) - failure_count = proto.Field(proto.INT64, number=2,) - update_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) + operation_name = proto.Field( + proto.STRING, + number=5, + ) + request_id = proto.Field( + proto.STRING, + number=3, + ) + create_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + success_count = proto.Field( + proto.INT64, + number=1, + ) + failure_count = proto.Field( + proto.INT64, + number=2, + ) + update_time = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) class ImportCatalogItemsResponse(proto.Message): @@ -253,9 +321,15 @@ class ImportCatalogItemsResponse(proto.Message): """ error_samples = proto.RepeatedField( - proto.MESSAGE, number=1, message=status_pb2.Status, + proto.MESSAGE, + number=1, + message=status_pb2.Status, + ) + errors_config = proto.Field( + proto.MESSAGE, + number=2, + message="ImportErrorsConfig", ) - errors_config = proto.Field(proto.MESSAGE, number=2, message="ImportErrorsConfig",) class ImportUserEventsResponse(proto.Message): @@ -277,11 +351,19 @@ class ImportUserEventsResponse(proto.Message): """ error_samples = proto.RepeatedField( - proto.MESSAGE, number=1, message=status_pb2.Status, + proto.MESSAGE, + number=1, + message=status_pb2.Status, + ) + errors_config = proto.Field( + proto.MESSAGE, + number=2, + message="ImportErrorsConfig", ) - errors_config = proto.Field(proto.MESSAGE, number=2, message="ImportErrorsConfig",) import_summary = proto.Field( - proto.MESSAGE, number=3, message="UserEventImportSummary", + proto.MESSAGE, + number=3, + message="UserEventImportSummary", ) @@ -299,8 +381,14 @@ class UserEventImportSummary(proto.Message): catalog. """ - joined_events_count = proto.Field(proto.INT64, number=1,) - unjoined_events_count = proto.Field(proto.INT64, number=2,) + joined_events_count = proto.Field( + proto.INT64, + number=1, + ) + unjoined_events_count = proto.Field( + proto.INT64, + number=2, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/recommendationengine_v1beta1/types/prediction_apikey_registry_service.py b/google/cloud/recommendationengine_v1beta1/types/prediction_apikey_registry_service.py index 003edc71..037e784a 100644 --- a/google/cloud/recommendationengine_v1beta1/types/prediction_apikey_registry_service.py +++ b/google/cloud/recommendationengine_v1beta1/types/prediction_apikey_registry_service.py @@ -36,7 +36,10 @@ class PredictionApiKeyRegistration(proto.Message): The API key. """ - api_key = proto.Field(proto.STRING, number=1,) + api_key = proto.Field( + proto.STRING, + number=1, + ) class CreatePredictionApiKeyRegistrationRequest(proto.Message): @@ -52,9 +55,14 @@ class CreatePredictionApiKeyRegistrationRequest(proto.Message): registration. """ - parent = proto.Field(proto.STRING, number=1,) + parent = proto.Field( + proto.STRING, + number=1, + ) prediction_api_key_registration = proto.Field( - proto.MESSAGE, number=2, message="PredictionApiKeyRegistration", + proto.MESSAGE, + number=2, + message="PredictionApiKeyRegistration", ) @@ -74,9 +82,18 @@ class ListPredictionApiKeyRegistrationsRequest(proto.Message): ``ListPredictionApiKeyRegistration.nextPageToken``. """ - parent = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) class ListPredictionApiKeyRegistrationsResponse(proto.Message): @@ -96,9 +113,14 @@ def raw_page(self): return self prediction_api_key_registrations = proto.RepeatedField( - proto.MESSAGE, number=1, message="PredictionApiKeyRegistration", + proto.MESSAGE, + number=1, + message="PredictionApiKeyRegistration", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, ) - next_page_token = proto.Field(proto.STRING, number=2,) class DeletePredictionApiKeyRegistrationRequest(proto.Message): @@ -111,7 +133,10 @@ class DeletePredictionApiKeyRegistrationRequest(proto.Message): ``projects/*/locations/global/catalogs/default_catalog/eventStores/default_event_store/predictionApiKeyRegistrations/`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/recommendationengine_v1beta1/types/prediction_service.py b/google/cloud/recommendationengine_v1beta1/types/prediction_service.py index ae51ef75..7c16f2c4 100644 --- a/google/cloud/recommendationengine_v1beta1/types/prediction_service.py +++ b/google/cloud/recommendationengine_v1beta1/types/prediction_service.py @@ -21,7 +21,10 @@ __protobuf__ = proto.module( package="google.cloud.recommendationengine.v1beta1", - manifest={"PredictRequest", "PredictResponse",}, + manifest={ + "PredictRequest", + "PredictResponse", + }, ) @@ -106,7 +109,7 @@ class PredictRequest(proto.Message): used that returns arbitrary catalog items. Note that the dryRun mode should only be used for testing the API, or if the model is not ready. - params (Sequence[google.cloud.recommendationengine_v1beta1.types.PredictRequest.ParamsEntry]): + params (Mapping[str, google.protobuf.struct_pb2.Value]): Optional. Additional domain specific parameters for the predictions. @@ -122,7 +125,7 @@ class PredictRequest(proto.Message): response. The given 'score' indicates the probability of an item being clicked/purchased given the user's context and history. - labels (Sequence[google.cloud.recommendationengine_v1beta1.types.PredictRequest.LabelsEntry]): + labels (Mapping[str, str]): Optional. The labels for the predict request. - Label keys can contain lowercase letters, digits and @@ -138,16 +141,42 @@ class PredictRequest(proto.Message): examples of labels. """ - name = proto.Field(proto.STRING, number=1,) - user_event = proto.Field(proto.MESSAGE, number=2, message=gcr_user_event.UserEvent,) - page_size = proto.Field(proto.INT32, number=7,) - page_token = proto.Field(proto.STRING, number=8,) - filter = proto.Field(proto.STRING, number=3,) - dry_run = proto.Field(proto.BOOL, number=4,) + name = proto.Field( + proto.STRING, + number=1, + ) + user_event = proto.Field( + proto.MESSAGE, + number=2, + message=gcr_user_event.UserEvent, + ) + page_size = proto.Field( + proto.INT32, + number=7, + ) + page_token = proto.Field( + proto.STRING, + number=8, + ) + filter = proto.Field( + proto.STRING, + number=3, + ) + dry_run = proto.Field( + proto.BOOL, + number=4, + ) params = proto.MapField( - proto.STRING, proto.MESSAGE, number=6, message=struct_pb2.Value, + proto.STRING, + proto.MESSAGE, + number=6, + message=struct_pb2.Value, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=9, ) - labels = proto.MapField(proto.STRING, proto.STRING, number=9,) class PredictResponse(proto.Message): @@ -169,7 +198,7 @@ class PredictResponse(proto.Message): dry_run (bool): True if the dryRun property was set in the request. - metadata (Sequence[google.cloud.recommendationengine_v1beta1.types.PredictResponse.MetadataEntry]): + metadata (Mapping[str, google.protobuf.struct_pb2.Value]): Additional domain specific prediction response metadata. next_page_token (str): @@ -184,7 +213,7 @@ class PredictionResult(proto.Message): Attributes: id (str): ID of the recommended catalog item - item_metadata (Sequence[google.cloud.recommendationengine_v1beta1.types.PredictResponse.PredictionResult.ItemMetadataEntry]): + item_metadata (Mapping[str, google.protobuf.struct_pb2.Value]): Additional item metadata / annotations. Possible values: @@ -197,23 +226,48 @@ class PredictionResult(proto.Message): ``PredictRequest.params``. """ - id = proto.Field(proto.STRING, number=1,) + id = proto.Field( + proto.STRING, + number=1, + ) item_metadata = proto.MapField( - proto.STRING, proto.MESSAGE, number=2, message=struct_pb2.Value, + proto.STRING, + proto.MESSAGE, + number=2, + message=struct_pb2.Value, ) @property def raw_page(self): return self - results = proto.RepeatedField(proto.MESSAGE, number=1, message=PredictionResult,) - recommendation_token = proto.Field(proto.STRING, number=2,) - items_missing_in_catalog = proto.RepeatedField(proto.STRING, number=3,) - dry_run = proto.Field(proto.BOOL, number=4,) + results = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=PredictionResult, + ) + recommendation_token = proto.Field( + proto.STRING, + number=2, + ) + items_missing_in_catalog = proto.RepeatedField( + proto.STRING, + number=3, + ) + dry_run = proto.Field( + proto.BOOL, + number=4, + ) metadata = proto.MapField( - proto.STRING, proto.MESSAGE, number=5, message=struct_pb2.Value, + proto.STRING, + proto.MESSAGE, + number=5, + message=struct_pb2.Value, + ) + next_page_token = proto.Field( + proto.STRING, + number=6, ) - next_page_token = proto.Field(proto.STRING, number=6,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/recommendationengine_v1beta1/types/recommendationengine_resources.py b/google/cloud/recommendationengine_v1beta1/types/recommendationengine_resources.py index 167f688d..54e4ad48 100644 --- a/google/cloud/recommendationengine_v1beta1/types/recommendationengine_resources.py +++ b/google/cloud/recommendationengine_v1beta1/types/recommendationengine_resources.py @@ -16,7 +16,8 @@ __protobuf__ = proto.module( - package="google.cloud.recommendationengine.v1beta1", manifest={}, + package="google.cloud.recommendationengine.v1beta1", + manifest={}, ) diff --git a/google/cloud/recommendationengine_v1beta1/types/user_event.py b/google/cloud/recommendationengine_v1beta1/types/user_event.py index be5331ad..eff2df19 100644 --- a/google/cloud/recommendationengine_v1beta1/types/user_event.py +++ b/google/cloud/recommendationengine_v1beta1/types/user_event.py @@ -107,14 +107,35 @@ class EventSource(proto.Enum): ECOMMERCE = 2 BATCH_UPLOAD = 3 - event_type = proto.Field(proto.STRING, number=1,) - user_info = proto.Field(proto.MESSAGE, number=2, message="UserInfo",) - event_detail = proto.Field(proto.MESSAGE, number=3, message="EventDetail",) + event_type = proto.Field( + proto.STRING, + number=1, + ) + user_info = proto.Field( + proto.MESSAGE, + number=2, + message="UserInfo", + ) + event_detail = proto.Field( + proto.MESSAGE, + number=3, + message="EventDetail", + ) product_event_detail = proto.Field( - proto.MESSAGE, number=4, message="ProductEventDetail", + proto.MESSAGE, + number=4, + message="ProductEventDetail", + ) + event_time = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, + ) + event_source = proto.Field( + proto.ENUM, + number=6, + enum=EventSource, ) - event_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) - event_source = proto.Field(proto.ENUM, number=6, enum=EventSource,) class UserInfo(proto.Message): @@ -158,11 +179,26 @@ class UserInfo(proto.Message): processing and pushing the user events). """ - visitor_id = proto.Field(proto.STRING, number=1,) - user_id = proto.Field(proto.STRING, number=2,) - ip_address = proto.Field(proto.STRING, number=3,) - user_agent = proto.Field(proto.STRING, number=4,) - direct_user_request = proto.Field(proto.BOOL, number=5,) + visitor_id = proto.Field( + proto.STRING, + number=1, + ) + user_id = proto.Field( + proto.STRING, + number=2, + ) + ip_address = proto.Field( + proto.STRING, + number=3, + ) + user_agent = proto.Field( + proto.STRING, + number=4, + ) + direct_user_request = proto.Field( + proto.BOOL, + number=5, + ) class EventDetail(proto.Message): @@ -222,12 +258,31 @@ class EventDetail(proto.Message): directly, or coming through Google search, and etc. """ - uri = proto.Field(proto.STRING, number=1,) - referrer_uri = proto.Field(proto.STRING, number=6,) - page_view_id = proto.Field(proto.STRING, number=2,) - experiment_ids = proto.RepeatedField(proto.STRING, number=3,) - recommendation_token = proto.Field(proto.STRING, number=4,) - event_attributes = proto.Field(proto.MESSAGE, number=5, message=common.FeatureMap,) + uri = proto.Field( + proto.STRING, + number=1, + ) + referrer_uri = proto.Field( + proto.STRING, + number=6, + ) + page_view_id = proto.Field( + proto.STRING, + number=2, + ) + experiment_ids = proto.RepeatedField( + proto.STRING, + number=3, + ) + recommendation_token = proto.Field( + proto.STRING, + number=4, + ) + event_attributes = proto.Field( + proto.MESSAGE, + number=5, + message=common.FeatureMap, + ) class ProductEventDetail(proto.Message): @@ -292,17 +347,32 @@ class ProductEventDetail(proto.Message): should not set this field. """ - search_query = proto.Field(proto.STRING, number=1,) + search_query = proto.Field( + proto.STRING, + number=1, + ) page_categories = proto.RepeatedField( - proto.MESSAGE, number=2, message=catalog.CatalogItem.CategoryHierarchy, + proto.MESSAGE, + number=2, + message=catalog.CatalogItem.CategoryHierarchy, ) product_details = proto.RepeatedField( - proto.MESSAGE, number=3, message="ProductDetail", + proto.MESSAGE, + number=3, + message="ProductDetail", + ) + list_id = proto.Field( + proto.STRING, + number=4, + ) + cart_id = proto.Field( + proto.STRING, + number=5, ) - list_id = proto.Field(proto.STRING, number=4,) - cart_id = proto.Field(proto.STRING, number=5,) purchase_transaction = proto.Field( - proto.MESSAGE, number=6, message="PurchaseTransaction", + proto.MESSAGE, + number=6, + message="PurchaseTransaction", ) @@ -319,10 +389,10 @@ class PurchaseTransaction(proto.Message): adjustments to total revenue that you want to include as part of your revenue calculations. This field is not required if the event type is ``refund``. - taxes (Sequence[google.cloud.recommendationengine_v1beta1.types.PurchaseTransaction.TaxesEntry]): + taxes (Mapping[str, float]): Optional. All the taxes associated with the transaction. - costs (Sequence[google.cloud.recommendationengine_v1beta1.types.PurchaseTransaction.CostsEntry]): + costs (Mapping[str, float]): Optional. All the costs associated with the product. These can be manufacturing costs, shipping expenses not borne by the end user, or any other costs. @@ -339,11 +409,28 @@ class PurchaseTransaction(proto.Message): This field is not required if the event type is ``refund``. """ - id = proto.Field(proto.STRING, number=1,) - revenue = proto.Field(proto.FLOAT, number=2,) - taxes = proto.MapField(proto.STRING, proto.FLOAT, number=3,) - costs = proto.MapField(proto.STRING, proto.FLOAT, number=4,) - currency_code = proto.Field(proto.STRING, number=6,) + id = proto.Field( + proto.STRING, + number=1, + ) + revenue = proto.Field( + proto.FLOAT, + number=2, + ) + taxes = proto.MapField( + proto.STRING, + proto.FLOAT, + number=3, + ) + costs = proto.MapField( + proto.STRING, + proto.FLOAT, + number=4, + ) + currency_code = proto.Field( + proto.STRING, + number=6, + ) class ProductDetail(proto.Message): @@ -392,16 +479,40 @@ class ProductDetail(proto.Message): product in the user event. """ - id = proto.Field(proto.STRING, number=1,) - currency_code = proto.Field(proto.STRING, number=2,) - original_price = proto.Field(proto.FLOAT, number=3,) - display_price = proto.Field(proto.FLOAT, number=4,) + id = proto.Field( + proto.STRING, + number=1, + ) + currency_code = proto.Field( + proto.STRING, + number=2, + ) + original_price = proto.Field( + proto.FLOAT, + number=3, + ) + display_price = proto.Field( + proto.FLOAT, + number=4, + ) stock_state = proto.Field( - proto.ENUM, number=5, enum=catalog.ProductCatalogItem.StockState, + proto.ENUM, + number=5, + enum=catalog.ProductCatalogItem.StockState, + ) + quantity = proto.Field( + proto.INT32, + number=6, + ) + available_quantity = proto.Field( + proto.INT32, + number=7, + ) + item_attributes = proto.Field( + proto.MESSAGE, + number=8, + message=common.FeatureMap, ) - quantity = proto.Field(proto.INT32, number=6,) - available_quantity = proto.Field(proto.INT32, number=7,) - item_attributes = proto.Field(proto.MESSAGE, number=8, message=common.FeatureMap,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/recommendationengine_v1beta1/types/user_event_service.py b/google/cloud/recommendationengine_v1beta1/types/user_event_service.py index c23ea78b..330e0613 100644 --- a/google/cloud/recommendationengine_v1beta1/types/user_event_service.py +++ b/google/cloud/recommendationengine_v1beta1/types/user_event_service.py @@ -68,9 +68,18 @@ class PurgeUserEventsRequest(proto.Message): returned. """ - parent = proto.Field(proto.STRING, number=1,) - filter = proto.Field(proto.STRING, number=2,) - force = proto.Field(proto.BOOL, number=3,) + parent = proto.Field( + proto.STRING, + number=1, + ) + filter = proto.Field( + proto.STRING, + number=2, + ) + force = proto.Field( + proto.BOOL, + number=3, + ) class PurgeUserEventsMetadata(proto.Message): @@ -85,8 +94,15 @@ class PurgeUserEventsMetadata(proto.Message): Operation create time. """ - operation_name = proto.Field(proto.STRING, number=1,) - create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + operation_name = proto.Field( + proto.STRING, + number=1, + ) + create_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) class PurgeUserEventsResponse(proto.Message): @@ -104,9 +120,14 @@ class PurgeUserEventsResponse(proto.Message): will be returned. """ - purged_events_count = proto.Field(proto.INT64, number=1,) + purged_events_count = proto.Field( + proto.INT64, + number=1, + ) user_events_sample = proto.RepeatedField( - proto.MESSAGE, number=2, message=gcr_user_event.UserEvent, + proto.MESSAGE, + number=2, + message=gcr_user_event.UserEvent, ) @@ -121,8 +142,15 @@ class WriteUserEventRequest(proto.Message): Required. User event to write. """ - parent = proto.Field(proto.STRING, number=1,) - user_event = proto.Field(proto.MESSAGE, number=2, message=gcr_user_event.UserEvent,) + parent = proto.Field( + proto.STRING, + number=1, + ) + user_event = proto.Field( + proto.MESSAGE, + number=2, + message=gcr_user_event.UserEvent, + ) class CollectUserEventRequest(proto.Message): @@ -148,10 +176,22 @@ class CollectUserEventRequest(proto.Message): abbreviated to reduce the payload bytes. """ - parent = proto.Field(proto.STRING, number=1,) - user_event = proto.Field(proto.STRING, number=2,) - uri = proto.Field(proto.STRING, number=3,) - ets = proto.Field(proto.INT64, number=4,) + parent = proto.Field( + proto.STRING, + number=1, + ) + user_event = proto.Field( + proto.STRING, + number=2, + ) + uri = proto.Field( + proto.STRING, + number=3, + ) + ets = proto.Field( + proto.INT64, + number=4, + ) class ListUserEventsRequest(proto.Message): @@ -207,10 +247,22 @@ class ListUserEventsRequest(proto.Message): - Example 6: eventsMissingCatalogItems """ - parent = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) - filter = proto.Field(proto.STRING, number=4,) + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) + filter = proto.Field( + proto.STRING, + number=4, + ) class ListUserEventsResponse(proto.Message): @@ -229,9 +281,14 @@ def raw_page(self): return self user_events = proto.RepeatedField( - proto.MESSAGE, number=1, message=gcr_user_event.UserEvent, + proto.MESSAGE, + number=1, + message=gcr_user_event.UserEvent, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, ) - next_page_token = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/noxfile.py b/noxfile.py index 2a2001c4..92da31f8 100644 --- a/noxfile.py +++ b/noxfile.py @@ -20,16 +20,41 @@ import os import pathlib import shutil +import warnings import nox - -BLACK_VERSION = "black==19.10b0" -BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] +BLACK_VERSION = "black==22.3.0" +ISORT_VERSION = "isort==5.10.1" +LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" -SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] + UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"] +UNIT_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "asyncmock", + "pytest", + "pytest-cov", + "pytest-asyncio", +] +UNIT_TEST_EXTERNAL_DEPENDENCIES = [] +UNIT_TEST_LOCAL_DEPENDENCIES = [] +UNIT_TEST_DEPENDENCIES = [] +UNIT_TEST_EXTRAS = [] +UNIT_TEST_EXTRAS_BY_PYTHON = {} + +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] +SYSTEM_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "pytest", + "google-cloud-testutils", +] +SYSTEM_TEST_EXTERNAL_DEPENDENCIES = [] +SYSTEM_TEST_LOCAL_DEPENDENCIES = [] +SYSTEM_TEST_DEPENDENCIES = [] +SYSTEM_TEST_EXTRAS = [] +SYSTEM_TEST_EXTRAS_BY_PYTHON = {} CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() @@ -57,7 +82,9 @@ def lint(session): """ session.install("flake8", BLACK_VERSION) session.run( - "black", "--check", *BLACK_PATHS, + "black", + "--check", + *LINT_PATHS, ) session.run("flake8", "google", "tests") @@ -67,7 +94,28 @@ def blacken(session): """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) session.run( - "black", *BLACK_PATHS, + "black", + *LINT_PATHS, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def format(session): + """ + Run isort to sort imports. Then run black + to format code to uniform standard. + """ + session.install(BLACK_VERSION, ISORT_VERSION) + # Use the --fss option to sort imports using strict alphabetical order. + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections + session.run( + "isort", + "--fss", + *LINT_PATHS, + ) + session.run( + "black", + *LINT_PATHS, ) @@ -78,23 +126,41 @@ def lint_setup_py(session): session.run("python", "setup.py", "check", "--restructuredtext", "--strict") +def install_unittest_dependencies(session, *constraints): + standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES + session.install(*standard_deps, *constraints) + + if UNIT_TEST_EXTERNAL_DEPENDENCIES: + warnings.warn( + "'unit_test_external_dependencies' is deprecated. Instead, please " + "use 'unit_test_dependencies' or 'unit_test_local_dependencies'.", + DeprecationWarning, + ) + session.install(*UNIT_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_LOCAL_DEPENDENCIES: + session.install(*UNIT_TEST_LOCAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_EXTRAS_BY_PYTHON: + extras = UNIT_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif UNIT_TEST_EXTRAS: + extras = UNIT_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + def default(session): # Install all test dependencies, then install this package in-place. constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) - session.install( - "mock", - "asyncmock", - "pytest", - "pytest-cov", - "pytest-asyncio", - "-c", - constraints_path, - ) - - session.install("-e", ".", "-c", constraints_path) + install_unittest_dependencies(session, "-c", constraints_path) # Run py.test against the unit tests. session.run( @@ -118,6 +184,35 @@ def unit(session): default(session) +def install_systemtest_dependencies(session, *constraints): + + # Use pre-release gRPC for system tests. + session.install("--pre", "grpcio") + + session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTERNAL_DEPENDENCIES: + session.install(*SYSTEM_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_LOCAL_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_LOCAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTRAS_BY_PYTHON: + extras = SYSTEM_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif SYSTEM_TEST_EXTRAS: + extras = SYSTEM_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) def system(session): """Run the system test suite.""" @@ -140,13 +235,7 @@ def system(session): if not system_test_exists and not system_test_folder_exists: session.skip("System tests were not found") - # Use pre-release gRPC for system tests. - session.install("--pre", "grpcio") - - # Install all test dependencies, then install this package into the - # virtualenv's dist-packages. - session.install("mock", "pytest", "google-cloud-testutils", "-c", constraints_path) - session.install("-e", ".", "-c", constraints_path) + install_systemtest_dependencies(session, "-c", constraints_path) # Run py.test against the system tests. if system_test_exists: diff --git a/samples/generated_samples/snippet_metadata_recommendationengine_v1beta1.json b/samples/generated_samples/snippet_metadata_recommendationengine_v1beta1.json index d911073b..c58bae73 100644 --- a/samples/generated_samples/snippet_metadata_recommendationengine_v1beta1.json +++ b/samples/generated_samples/snippet_metadata_recommendationengine_v1beta1.json @@ -1,16 +1,65 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.recommendationengine.v1beta1", + "version": "v1beta1" + } + ], + "language": "PYTHON", + "name": "google-cloud-recommendations-ai" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceAsyncClient", + "shortName": "CatalogServiceAsyncClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceAsyncClient.create_catalog_item", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService.CreateCatalogItem", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService", "shortName": "CatalogService" }, "shortName": "CreateCatalogItem" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.CreateCatalogItemRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "catalog_item", + "type": "google.cloud.recommendationengine_v1beta1.types.CatalogItem" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recommendationengine_v1beta1.types.CatalogItem", + "shortName": "create_catalog_item" }, + "description": "Sample for CreateCatalogItem", "file": "recommendationengine_v1beta1_generated_catalog_service_create_catalog_item_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_CatalogService_CreateCatalogItem_async", "segments": [ { @@ -43,18 +92,58 @@ "start": 48, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_catalog_service_create_catalog_item_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceClient", + "shortName": "CatalogServiceClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceClient.create_catalog_item", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService.CreateCatalogItem", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService", "shortName": "CatalogService" }, "shortName": "CreateCatalogItem" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.CreateCatalogItemRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "catalog_item", + "type": "google.cloud.recommendationengine_v1beta1.types.CatalogItem" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recommendationengine_v1beta1.types.CatalogItem", + "shortName": "create_catalog_item" }, + "description": "Sample for CreateCatalogItem", "file": "recommendationengine_v1beta1_generated_catalog_service_create_catalog_item_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_CatalogService_CreateCatalogItem_sync", "segments": [ { @@ -87,19 +176,54 @@ "start": 48, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_catalog_service_create_catalog_item_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceAsyncClient", + "shortName": "CatalogServiceAsyncClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceAsyncClient.delete_catalog_item", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService.DeleteCatalogItem", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService", "shortName": "CatalogService" }, "shortName": "DeleteCatalogItem" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.DeleteCatalogItemRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_catalog_item" }, + "description": "Sample for DeleteCatalogItem", "file": "recommendationengine_v1beta1_generated_catalog_service_delete_catalog_item_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_CatalogService_DeleteCatalogItem_async", "segments": [ { @@ -130,18 +254,53 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_catalog_service_delete_catalog_item_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceClient", + "shortName": "CatalogServiceClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceClient.delete_catalog_item", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService.DeleteCatalogItem", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService", "shortName": "CatalogService" }, "shortName": "DeleteCatalogItem" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.DeleteCatalogItemRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_catalog_item" }, + "description": "Sample for DeleteCatalogItem", "file": "recommendationengine_v1beta1_generated_catalog_service_delete_catalog_item_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_CatalogService_DeleteCatalogItem_sync", "segments": [ { @@ -172,19 +331,55 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_catalog_service_delete_catalog_item_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceAsyncClient", + "shortName": "CatalogServiceAsyncClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceAsyncClient.get_catalog_item", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService.GetCatalogItem", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService", "shortName": "CatalogService" }, "shortName": "GetCatalogItem" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.GetCatalogItemRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recommendationengine_v1beta1.types.CatalogItem", + "shortName": "get_catalog_item" }, + "description": "Sample for GetCatalogItem", "file": "recommendationengine_v1beta1_generated_catalog_service_get_catalog_item_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_CatalogService_GetCatalogItem_async", "segments": [ { @@ -217,18 +412,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_catalog_service_get_catalog_item_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceClient", + "shortName": "CatalogServiceClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceClient.get_catalog_item", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService.GetCatalogItem", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService", "shortName": "CatalogService" }, "shortName": "GetCatalogItem" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.GetCatalogItemRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recommendationengine_v1beta1.types.CatalogItem", + "shortName": "get_catalog_item" }, + "description": "Sample for GetCatalogItem", "file": "recommendationengine_v1beta1_generated_catalog_service_get_catalog_item_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_CatalogService_GetCatalogItem_sync", "segments": [ { @@ -261,19 +492,67 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_catalog_service_get_catalog_item_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceAsyncClient", + "shortName": "CatalogServiceAsyncClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceAsyncClient.import_catalog_items", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService.ImportCatalogItems", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService", "shortName": "CatalogService" }, "shortName": "ImportCatalogItems" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.ImportCatalogItemsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "request_id", + "type": "str" + }, + { + "name": "input_config", + "type": "google.cloud.recommendationengine_v1beta1.types.InputConfig" + }, + { + "name": "errors_config", + "type": "google.cloud.recommendationengine_v1beta1.types.ImportErrorsConfig" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "import_catalog_items" }, + "description": "Sample for ImportCatalogItems", "file": "recommendationengine_v1beta1_generated_catalog_service_import_catalog_items_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_CatalogService_ImportCatalogItems_async", "segments": [ { @@ -306,18 +585,66 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_catalog_service_import_catalog_items_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceClient", + "shortName": "CatalogServiceClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceClient.import_catalog_items", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService.ImportCatalogItems", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService", "shortName": "CatalogService" }, "shortName": "ImportCatalogItems" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.ImportCatalogItemsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "request_id", + "type": "str" + }, + { + "name": "input_config", + "type": "google.cloud.recommendationengine_v1beta1.types.InputConfig" + }, + { + "name": "errors_config", + "type": "google.cloud.recommendationengine_v1beta1.types.ImportErrorsConfig" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "import_catalog_items" }, + "description": "Sample for ImportCatalogItems", "file": "recommendationengine_v1beta1_generated_catalog_service_import_catalog_items_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_CatalogService_ImportCatalogItems_sync", "segments": [ { @@ -350,19 +677,59 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_catalog_service_import_catalog_items_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceAsyncClient", + "shortName": "CatalogServiceAsyncClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceAsyncClient.list_catalog_items", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService.ListCatalogItems", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService", "shortName": "CatalogService" }, "shortName": "ListCatalogItems" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.ListCatalogItemsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "filter", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recommendationengine_v1beta1.services.catalog_service.pagers.ListCatalogItemsAsyncPager", + "shortName": "list_catalog_items" }, + "description": "Sample for ListCatalogItems", "file": "recommendationengine_v1beta1_generated_catalog_service_list_catalog_items_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_CatalogService_ListCatalogItems_async", "segments": [ { @@ -395,18 +762,58 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_catalog_service_list_catalog_items_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceClient", + "shortName": "CatalogServiceClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceClient.list_catalog_items", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService.ListCatalogItems", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService", "shortName": "CatalogService" }, "shortName": "ListCatalogItems" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.ListCatalogItemsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "filter", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recommendationengine_v1beta1.services.catalog_service.pagers.ListCatalogItemsPager", + "shortName": "list_catalog_items" }, + "description": "Sample for ListCatalogItems", "file": "recommendationengine_v1beta1_generated_catalog_service_list_catalog_items_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_CatalogService_ListCatalogItems_sync", "segments": [ { @@ -439,19 +846,63 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_catalog_service_list_catalog_items_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceAsyncClient", + "shortName": "CatalogServiceAsyncClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceAsyncClient.update_catalog_item", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService.UpdateCatalogItem", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService", "shortName": "CatalogService" }, "shortName": "UpdateCatalogItem" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.UpdateCatalogItemRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "catalog_item", + "type": "google.cloud.recommendationengine_v1beta1.types.CatalogItem" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recommendationengine_v1beta1.types.CatalogItem", + "shortName": "update_catalog_item" }, + "description": "Sample for UpdateCatalogItem", "file": "recommendationengine_v1beta1_generated_catalog_service_update_catalog_item_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_CatalogService_UpdateCatalogItem_async", "segments": [ { @@ -484,18 +935,62 @@ "start": 48, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_catalog_service_update_catalog_item_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceClient", + "shortName": "CatalogServiceClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.CatalogServiceClient.update_catalog_item", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService.UpdateCatalogItem", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.CatalogService", "shortName": "CatalogService" }, "shortName": "UpdateCatalogItem" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.UpdateCatalogItemRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "catalog_item", + "type": "google.cloud.recommendationengine_v1beta1.types.CatalogItem" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recommendationengine_v1beta1.types.CatalogItem", + "shortName": "update_catalog_item" }, + "description": "Sample for UpdateCatalogItem", "file": "recommendationengine_v1beta1_generated_catalog_service_update_catalog_item_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_CatalogService_UpdateCatalogItem_sync", "segments": [ { @@ -528,19 +1023,59 @@ "start": 48, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_catalog_service_update_catalog_item_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.PredictionApiKeyRegistryAsyncClient", + "shortName": "PredictionApiKeyRegistryAsyncClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.PredictionApiKeyRegistryAsyncClient.create_prediction_api_key_registration", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry.CreatePredictionApiKeyRegistration", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry", "shortName": "PredictionApiKeyRegistry" }, "shortName": "CreatePredictionApiKeyRegistration" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.CreatePredictionApiKeyRegistrationRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "prediction_api_key_registration", + "type": "google.cloud.recommendationengine_v1beta1.types.PredictionApiKeyRegistration" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recommendationengine_v1beta1.types.PredictionApiKeyRegistration", + "shortName": "create_prediction_api_key_registration" }, + "description": "Sample for CreatePredictionApiKeyRegistration", "file": "recommendationengine_v1beta1_generated_prediction_api_key_registry_create_prediction_api_key_registration_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_PredictionApiKeyRegistry_CreatePredictionApiKeyRegistration_async", "segments": [ { @@ -573,18 +1108,58 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_prediction_api_key_registry_create_prediction_api_key_registration_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.PredictionApiKeyRegistryClient", + "shortName": "PredictionApiKeyRegistryClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.PredictionApiKeyRegistryClient.create_prediction_api_key_registration", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry.CreatePredictionApiKeyRegistration", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry", "shortName": "PredictionApiKeyRegistry" }, "shortName": "CreatePredictionApiKeyRegistration" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.CreatePredictionApiKeyRegistrationRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "prediction_api_key_registration", + "type": "google.cloud.recommendationengine_v1beta1.types.PredictionApiKeyRegistration" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recommendationengine_v1beta1.types.PredictionApiKeyRegistration", + "shortName": "create_prediction_api_key_registration" }, + "description": "Sample for CreatePredictionApiKeyRegistration", "file": "recommendationengine_v1beta1_generated_prediction_api_key_registry_create_prediction_api_key_registration_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_PredictionApiKeyRegistry_CreatePredictionApiKeyRegistration_sync", "segments": [ { @@ -617,19 +1192,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_prediction_api_key_registry_create_prediction_api_key_registration_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.PredictionApiKeyRegistryAsyncClient", + "shortName": "PredictionApiKeyRegistryAsyncClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.PredictionApiKeyRegistryAsyncClient.delete_prediction_api_key_registration", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry.DeletePredictionApiKeyRegistration", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry", "shortName": "PredictionApiKeyRegistry" }, "shortName": "DeletePredictionApiKeyRegistration" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.DeletePredictionApiKeyRegistrationRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_prediction_api_key_registration" }, + "description": "Sample for DeletePredictionApiKeyRegistration", "file": "recommendationengine_v1beta1_generated_prediction_api_key_registry_delete_prediction_api_key_registration_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_PredictionApiKeyRegistry_DeletePredictionApiKeyRegistration_async", "segments": [ { @@ -660,18 +1270,53 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_prediction_api_key_registry_delete_prediction_api_key_registration_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.PredictionApiKeyRegistryClient", + "shortName": "PredictionApiKeyRegistryClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.PredictionApiKeyRegistryClient.delete_prediction_api_key_registration", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry.DeletePredictionApiKeyRegistration", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry", "shortName": "PredictionApiKeyRegistry" }, "shortName": "DeletePredictionApiKeyRegistration" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.DeletePredictionApiKeyRegistrationRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_prediction_api_key_registration" }, + "description": "Sample for DeletePredictionApiKeyRegistration", "file": "recommendationengine_v1beta1_generated_prediction_api_key_registry_delete_prediction_api_key_registration_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_PredictionApiKeyRegistry_DeletePredictionApiKeyRegistration_sync", "segments": [ { @@ -702,19 +1347,55 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_prediction_api_key_registry_delete_prediction_api_key_registration_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.PredictionApiKeyRegistryAsyncClient", + "shortName": "PredictionApiKeyRegistryAsyncClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.PredictionApiKeyRegistryAsyncClient.list_prediction_api_key_registrations", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry.ListPredictionApiKeyRegistrations", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry", "shortName": "PredictionApiKeyRegistry" }, "shortName": "ListPredictionApiKeyRegistrations" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.ListPredictionApiKeyRegistrationsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recommendationengine_v1beta1.services.prediction_api_key_registry.pagers.ListPredictionApiKeyRegistrationsAsyncPager", + "shortName": "list_prediction_api_key_registrations" }, + "description": "Sample for ListPredictionApiKeyRegistrations", "file": "recommendationengine_v1beta1_generated_prediction_api_key_registry_list_prediction_api_key_registrations_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_PredictionApiKeyRegistry_ListPredictionApiKeyRegistrations_async", "segments": [ { @@ -747,18 +1428,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_prediction_api_key_registry_list_prediction_api_key_registrations_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.PredictionApiKeyRegistryClient", + "shortName": "PredictionApiKeyRegistryClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.PredictionApiKeyRegistryClient.list_prediction_api_key_registrations", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry.ListPredictionApiKeyRegistrations", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry", "shortName": "PredictionApiKeyRegistry" }, "shortName": "ListPredictionApiKeyRegistrations" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.ListPredictionApiKeyRegistrationsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recommendationengine_v1beta1.services.prediction_api_key_registry.pagers.ListPredictionApiKeyRegistrationsPager", + "shortName": "list_prediction_api_key_registrations" }, + "description": "Sample for ListPredictionApiKeyRegistrations", "file": "recommendationengine_v1beta1_generated_prediction_api_key_registry_list_prediction_api_key_registrations_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_PredictionApiKeyRegistry_ListPredictionApiKeyRegistrations_sync", "segments": [ { @@ -791,19 +1508,59 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_prediction_api_key_registry_list_prediction_api_key_registrations_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.PredictionServiceAsyncClient", + "shortName": "PredictionServiceAsyncClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.PredictionServiceAsyncClient.predict", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.PredictionService.Predict", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.PredictionService", "shortName": "PredictionService" }, "shortName": "Predict" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.PredictRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "user_event", + "type": "google.cloud.recommendationengine_v1beta1.types.UserEvent" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recommendationengine_v1beta1.services.prediction_service.pagers.PredictAsyncPager", + "shortName": "predict" }, + "description": "Sample for Predict", "file": "recommendationengine_v1beta1_generated_prediction_service_predict_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_PredictionService_Predict_async", "segments": [ { @@ -836,18 +1593,58 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_prediction_service_predict_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.PredictionServiceClient", + "shortName": "PredictionServiceClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.PredictionServiceClient.predict", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.PredictionService.Predict", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.PredictionService", "shortName": "PredictionService" }, "shortName": "Predict" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.PredictRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "user_event", + "type": "google.cloud.recommendationengine_v1beta1.types.UserEvent" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recommendationengine_v1beta1.services.prediction_service.pagers.PredictPager", + "shortName": "predict" }, + "description": "Sample for Predict", "file": "recommendationengine_v1beta1_generated_prediction_service_predict_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_PredictionService_Predict_sync", "segments": [ { @@ -880,19 +1677,67 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_prediction_service_predict_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.UserEventServiceAsyncClient", + "shortName": "UserEventServiceAsyncClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.UserEventServiceAsyncClient.collect_user_event", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.UserEventService.CollectUserEvent", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.UserEventService", "shortName": "UserEventService" }, "shortName": "CollectUserEvent" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.CollectUserEventRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "user_event", + "type": "str" + }, + { + "name": "uri", + "type": "str" + }, + { + "name": "ets", + "type": "int" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api.httpbody_pb2.HttpBody", + "shortName": "collect_user_event" }, + "description": "Sample for CollectUserEvent", "file": "recommendationengine_v1beta1_generated_user_event_service_collect_user_event_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_UserEventService_CollectUserEvent_async", "segments": [ { @@ -925,18 +1770,66 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_user_event_service_collect_user_event_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.UserEventServiceClient", + "shortName": "UserEventServiceClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.UserEventServiceClient.collect_user_event", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.UserEventService.CollectUserEvent", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.UserEventService", "shortName": "UserEventService" }, "shortName": "CollectUserEvent" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.CollectUserEventRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "user_event", + "type": "str" + }, + { + "name": "uri", + "type": "str" + }, + { + "name": "ets", + "type": "int" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api.httpbody_pb2.HttpBody", + "shortName": "collect_user_event" }, + "description": "Sample for CollectUserEvent", "file": "recommendationengine_v1beta1_generated_user_event_service_collect_user_event_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_UserEventService_CollectUserEvent_sync", "segments": [ { @@ -969,19 +1862,67 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_user_event_service_collect_user_event_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.UserEventServiceAsyncClient", + "shortName": "UserEventServiceAsyncClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.UserEventServiceAsyncClient.import_user_events", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.UserEventService.ImportUserEvents", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.UserEventService", "shortName": "UserEventService" }, "shortName": "ImportUserEvents" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.ImportUserEventsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "request_id", + "type": "str" + }, + { + "name": "input_config", + "type": "google.cloud.recommendationengine_v1beta1.types.InputConfig" + }, + { + "name": "errors_config", + "type": "google.cloud.recommendationengine_v1beta1.types.ImportErrorsConfig" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "import_user_events" }, + "description": "Sample for ImportUserEvents", "file": "recommendationengine_v1beta1_generated_user_event_service_import_user_events_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_UserEventService_ImportUserEvents_async", "segments": [ { @@ -1014,18 +1955,66 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_user_event_service_import_user_events_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.UserEventServiceClient", + "shortName": "UserEventServiceClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.UserEventServiceClient.import_user_events", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.UserEventService.ImportUserEvents", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.UserEventService", "shortName": "UserEventService" }, "shortName": "ImportUserEvents" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.ImportUserEventsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "request_id", + "type": "str" + }, + { + "name": "input_config", + "type": "google.cloud.recommendationengine_v1beta1.types.InputConfig" + }, + { + "name": "errors_config", + "type": "google.cloud.recommendationengine_v1beta1.types.ImportErrorsConfig" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "import_user_events" }, + "description": "Sample for ImportUserEvents", "file": "recommendationengine_v1beta1_generated_user_event_service_import_user_events_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_UserEventService_ImportUserEvents_sync", "segments": [ { @@ -1058,19 +2047,59 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_user_event_service_import_user_events_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.UserEventServiceAsyncClient", + "shortName": "UserEventServiceAsyncClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.UserEventServiceAsyncClient.list_user_events", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.UserEventService.ListUserEvents", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.UserEventService", "shortName": "UserEventService" }, "shortName": "ListUserEvents" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.ListUserEventsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "filter", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recommendationengine_v1beta1.services.user_event_service.pagers.ListUserEventsAsyncPager", + "shortName": "list_user_events" }, + "description": "Sample for ListUserEvents", "file": "recommendationengine_v1beta1_generated_user_event_service_list_user_events_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_UserEventService_ListUserEvents_async", "segments": [ { @@ -1103,18 +2132,58 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_user_event_service_list_user_events_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.UserEventServiceClient", + "shortName": "UserEventServiceClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.UserEventServiceClient.list_user_events", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.UserEventService.ListUserEvents", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.UserEventService", "shortName": "UserEventService" }, "shortName": "ListUserEvents" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.ListUserEventsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "filter", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recommendationengine_v1beta1.services.user_event_service.pagers.ListUserEventsPager", + "shortName": "list_user_events" }, + "description": "Sample for ListUserEvents", "file": "recommendationengine_v1beta1_generated_user_event_service_list_user_events_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_UserEventService_ListUserEvents_sync", "segments": [ { @@ -1147,19 +2216,63 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_user_event_service_list_user_events_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.UserEventServiceAsyncClient", + "shortName": "UserEventServiceAsyncClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.UserEventServiceAsyncClient.purge_user_events", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.UserEventService.PurgeUserEvents", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.UserEventService", "shortName": "UserEventService" }, "shortName": "PurgeUserEvents" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.PurgeUserEventsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "filter", + "type": "str" + }, + { + "name": "force", + "type": "bool" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "purge_user_events" }, + "description": "Sample for PurgeUserEvents", "file": "recommendationengine_v1beta1_generated_user_event_service_purge_user_events_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_UserEventService_PurgeUserEvents_async", "segments": [ { @@ -1192,18 +2305,62 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_user_event_service_purge_user_events_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.UserEventServiceClient", + "shortName": "UserEventServiceClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.UserEventServiceClient.purge_user_events", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.UserEventService.PurgeUserEvents", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.UserEventService", "shortName": "UserEventService" }, "shortName": "PurgeUserEvents" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.PurgeUserEventsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "filter", + "type": "str" + }, + { + "name": "force", + "type": "bool" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "purge_user_events" }, + "description": "Sample for PurgeUserEvents", "file": "recommendationengine_v1beta1_generated_user_event_service_purge_user_events_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_UserEventService_PurgeUserEvents_sync", "segments": [ { @@ -1236,19 +2393,59 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_user_event_service_purge_user_events_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.UserEventServiceAsyncClient", + "shortName": "UserEventServiceAsyncClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.UserEventServiceAsyncClient.write_user_event", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.UserEventService.WriteUserEvent", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.UserEventService", "shortName": "UserEventService" }, "shortName": "WriteUserEvent" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.WriteUserEventRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "user_event", + "type": "google.cloud.recommendationengine_v1beta1.types.UserEvent" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recommendationengine_v1beta1.types.UserEvent", + "shortName": "write_user_event" }, + "description": "Sample for WriteUserEvent", "file": "recommendationengine_v1beta1_generated_user_event_service_write_user_event_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_UserEventService_WriteUserEvent_async", "segments": [ { @@ -1281,18 +2478,58 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_user_event_service_write_user_event_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.recommendationengine_v1beta1.UserEventServiceClient", + "shortName": "UserEventServiceClient" + }, + "fullName": "google.cloud.recommendationengine_v1beta1.UserEventServiceClient.write_user_event", "method": { + "fullName": "google.cloud.recommendationengine.v1beta1.UserEventService.WriteUserEvent", "service": { + "fullName": "google.cloud.recommendationengine.v1beta1.UserEventService", "shortName": "UserEventService" }, "shortName": "WriteUserEvent" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recommendationengine_v1beta1.types.WriteUserEventRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "user_event", + "type": "google.cloud.recommendationengine_v1beta1.types.UserEvent" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recommendationengine_v1beta1.types.UserEvent", + "shortName": "write_user_event" }, + "description": "Sample for WriteUserEvent", "file": "recommendationengine_v1beta1_generated_user_event_service_write_user_event_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "recommendationengine_v1beta1_generated_UserEventService_WriteUserEvent_sync", "segments": [ { @@ -1325,7 +2562,8 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "recommendationengine_v1beta1_generated_user_event_service_write_user_event_sync.py" } ] } diff --git a/scripts/readme-gen/readme_gen.py b/scripts/readme-gen/readme_gen.py index d309d6e9..91b59676 100644 --- a/scripts/readme-gen/readme_gen.py +++ b/scripts/readme-gen/readme_gen.py @@ -28,7 +28,10 @@ jinja_env = jinja2.Environment( trim_blocks=True, loader=jinja2.FileSystemLoader( - os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates')))) + os.path.abspath(os.path.join(os.path.dirname(__file__), "templates")) + ), + autoescape=True, +) README_TMPL = jinja_env.get_template('README.tmpl.rst') diff --git a/setup.py b/setup.py index 2c22a5e4..de4608a9 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ import os import setuptools # type: ignore -version = "0.6.1" +version = "0.6.2" package_root = os.path.abspath(os.path.dirname(__file__)) @@ -48,7 +48,8 @@ # Until this issue is closed # https://github.com/googleapis/google-cloud-python/issues/10566 "google-api-core[grpc] >= 1.31.5, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0", - "proto-plus >= 1.15.0", + "proto-plus >= 1.15.0, <2.0.0dev", + "protobuf >= 3.19.0, <4.0.0dev", ), python_requires=">=3.6", classifiers=[ diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index be5a64f3..786e6373 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -6,3 +6,4 @@ # Then this file should have google-cloud-foo==1.14.0 google-api-core==1.31.5 proto-plus==1.15.0 +protobuf==3.19.0 diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt index da93009b..786e6373 100644 --- a/testing/constraints-3.7.txt +++ b/testing/constraints-3.7.txt @@ -1,2 +1,9 @@ -# This constraints file is left inentionally empty -# so the latest version of dependencies is installed \ No newline at end of file +# This constraints file is used to check that lower bounds +# are correct in setup.py +# List all library dependencies and extras in this file. +# Pin the version to the lower bound. +# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", +# Then this file should have google-cloud-foo==1.14.0 +google-api-core==1.31.5 +proto-plus==1.15.0 +protobuf==3.19.0 diff --git a/tests/unit/gapic/recommendationengine_v1beta1/test_catalog_service.py b/tests/unit/gapic/recommendationengine_v1beta1/test_catalog_service.py index c803293a..a1e4a16a 100644 --- a/tests/unit/gapic/recommendationengine_v1beta1/test_catalog_service.py +++ b/tests/unit/gapic/recommendationengine_v1beta1/test_catalog_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio @@ -102,20 +108,24 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", [CatalogServiceClient, CatalogServiceAsyncClient,] + "client_class,transport_name", + [ + (CatalogServiceClient, "grpc"), + (CatalogServiceAsyncClient, "grpc_asyncio"), + ], ) -def test_catalog_service_client_from_service_account_info(client_class): +def test_catalog_service_client_from_service_account_info(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "recommendationengine.googleapis.com:443" + assert client.transport._host == ("recommendationengine.googleapis.com:443") @pytest.mark.parametrize( @@ -144,23 +154,31 @@ def test_catalog_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", [CatalogServiceClient, CatalogServiceAsyncClient,] + "client_class,transport_name", + [ + (CatalogServiceClient, "grpc"), + (CatalogServiceAsyncClient, "grpc_asyncio"), + ], ) -def test_catalog_service_client_from_service_account_file(client_class): +def test_catalog_service_client_from_service_account_file(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "recommendationengine.googleapis.com:443" + assert client.transport._host == ("recommendationengine.googleapis.com:443") def test_catalog_service_client_get_transport_class(): @@ -508,7 +526,9 @@ def test_catalog_service_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -649,11 +669,16 @@ def test_catalog_service_client_create_channel_credentials_file( @pytest.mark.parametrize( - "request_type", [catalog_service.CreateCatalogItemRequest, dict,] + "request_type", + [ + catalog_service.CreateCatalogItemRequest, + dict, + ], ) def test_create_catalog_item(request_type, transport: str = "grpc"): client = CatalogServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -697,7 +722,8 @@ def test_create_catalog_item_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CatalogServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -716,7 +742,8 @@ async def test_create_catalog_item_async( request_type=catalog_service.CreateCatalogItemRequest, ): client = CatalogServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -761,13 +788,15 @@ async def test_create_catalog_item_async_from_dict(): def test_create_catalog_item_field_headers(): - client = CatalogServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CatalogServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = catalog_service.CreateCatalogItemRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -783,7 +812,10 @@ def test_create_catalog_item_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -796,7 +828,7 @@ async def test_create_catalog_item_field_headers_async(): # a field header. Set these to a non-empty value. request = catalog_service.CreateCatalogItemRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -812,11 +844,16 @@ async def test_create_catalog_item_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_create_catalog_item_flattened(): - client = CatalogServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CatalogServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -827,7 +864,8 @@ def test_create_catalog_item_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_catalog_item( - parent="parent_value", catalog_item=catalog.CatalogItem(id="id_value"), + parent="parent_value", + catalog_item=catalog.CatalogItem(id="id_value"), ) # Establish that the underlying call was made with the expected @@ -843,7 +881,9 @@ def test_create_catalog_item_flattened(): def test_create_catalog_item_flattened_error(): - client = CatalogServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CatalogServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -872,7 +912,8 @@ async def test_create_catalog_item_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_catalog_item( - parent="parent_value", catalog_item=catalog.CatalogItem(id="id_value"), + parent="parent_value", + catalog_item=catalog.CatalogItem(id="id_value"), ) # Establish that the underlying call was made with the expected @@ -903,10 +944,17 @@ async def test_create_catalog_item_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [catalog_service.GetCatalogItemRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + catalog_service.GetCatalogItemRequest, + dict, + ], +) def test_get_catalog_item(request_type, transport: str = "grpc"): client = CatalogServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -948,7 +996,8 @@ def test_get_catalog_item_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CatalogServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -964,7 +1013,8 @@ async def test_get_catalog_item_async( transport: str = "grpc_asyncio", request_type=catalog_service.GetCatalogItemRequest ): client = CatalogServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1007,13 +1057,15 @@ async def test_get_catalog_item_async_from_dict(): def test_get_catalog_item_field_headers(): - client = CatalogServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CatalogServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = catalog_service.GetCatalogItemRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_catalog_item), "__call__") as call: @@ -1027,7 +1079,10 @@ def test_get_catalog_item_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1040,7 +1095,7 @@ async def test_get_catalog_item_field_headers_async(): # a field header. Set these to a non-empty value. request = catalog_service.GetCatalogItemRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_catalog_item), "__call__") as call: @@ -1054,11 +1109,16 @@ async def test_get_catalog_item_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_get_catalog_item_flattened(): - client = CatalogServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CatalogServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_catalog_item), "__call__") as call: @@ -1066,7 +1126,9 @@ def test_get_catalog_item_flattened(): call.return_value = catalog.CatalogItem() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_catalog_item(name="name_value",) + client.get_catalog_item( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1078,13 +1140,16 @@ def test_get_catalog_item_flattened(): def test_get_catalog_item_flattened_error(): - client = CatalogServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CatalogServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_catalog_item( - catalog_service.GetCatalogItemRequest(), name="name_value", + catalog_service.GetCatalogItemRequest(), + name="name_value", ) @@ -1102,7 +1167,9 @@ async def test_get_catalog_item_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(catalog.CatalogItem()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_catalog_item(name="name_value",) + response = await client.get_catalog_item( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1123,16 +1190,22 @@ async def test_get_catalog_item_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_catalog_item( - catalog_service.GetCatalogItemRequest(), name="name_value", + catalog_service.GetCatalogItemRequest(), + name="name_value", ) @pytest.mark.parametrize( - "request_type", [catalog_service.ListCatalogItemsRequest, dict,] + "request_type", + [ + catalog_service.ListCatalogItemsRequest, + dict, + ], ) def test_list_catalog_items(request_type, transport: str = "grpc"): client = CatalogServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1163,7 +1236,8 @@ def test_list_catalog_items_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CatalogServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1182,7 +1256,8 @@ async def test_list_catalog_items_async( request_type=catalog_service.ListCatalogItemsRequest, ): client = CatalogServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1217,13 +1292,15 @@ async def test_list_catalog_items_async_from_dict(): def test_list_catalog_items_field_headers(): - client = CatalogServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CatalogServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = catalog_service.ListCatalogItemsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1239,7 +1316,10 @@ def test_list_catalog_items_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1252,7 +1332,7 @@ async def test_list_catalog_items_field_headers_async(): # a field header. Set these to a non-empty value. request = catalog_service.ListCatalogItemsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1270,11 +1350,16 @@ async def test_list_catalog_items_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_list_catalog_items_flattened(): - client = CatalogServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CatalogServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1285,7 +1370,8 @@ def test_list_catalog_items_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_catalog_items( - parent="parent_value", filter="filter_value", + parent="parent_value", + filter="filter_value", ) # Establish that the underlying call was made with the expected @@ -1301,7 +1387,9 @@ def test_list_catalog_items_flattened(): def test_list_catalog_items_flattened_error(): - client = CatalogServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CatalogServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1332,7 +1420,8 @@ async def test_list_catalog_items_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.list_catalog_items( - parent="parent_value", filter="filter_value", + parent="parent_value", + filter="filter_value", ) # Establish that the underlying call was made with the expected @@ -1365,7 +1454,8 @@ async def test_list_catalog_items_flattened_error_async(): def test_list_catalog_items_pager(transport_name: str = "grpc"): client = CatalogServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1383,13 +1473,20 @@ def test_list_catalog_items_pager(transport_name: str = "grpc"): next_page_token="abc", ), catalog_service.ListCatalogItemsResponse( - catalog_items=[], next_page_token="def", + catalog_items=[], + next_page_token="def", ), catalog_service.ListCatalogItemsResponse( - catalog_items=[catalog.CatalogItem(),], next_page_token="ghi", + catalog_items=[ + catalog.CatalogItem(), + ], + next_page_token="ghi", ), catalog_service.ListCatalogItemsResponse( - catalog_items=[catalog.CatalogItem(), catalog.CatalogItem(),], + catalog_items=[ + catalog.CatalogItem(), + catalog.CatalogItem(), + ], ), RuntimeError, ) @@ -1402,14 +1499,15 @@ def test_list_catalog_items_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, catalog.CatalogItem) for i in results) def test_list_catalog_items_pages(transport_name: str = "grpc"): client = CatalogServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1427,13 +1525,20 @@ def test_list_catalog_items_pages(transport_name: str = "grpc"): next_page_token="abc", ), catalog_service.ListCatalogItemsResponse( - catalog_items=[], next_page_token="def", + catalog_items=[], + next_page_token="def", ), catalog_service.ListCatalogItemsResponse( - catalog_items=[catalog.CatalogItem(),], next_page_token="ghi", + catalog_items=[ + catalog.CatalogItem(), + ], + next_page_token="ghi", ), catalog_service.ListCatalogItemsResponse( - catalog_items=[catalog.CatalogItem(), catalog.CatalogItem(),], + catalog_items=[ + catalog.CatalogItem(), + catalog.CatalogItem(), + ], ), RuntimeError, ) @@ -1444,7 +1549,9 @@ def test_list_catalog_items_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_catalog_items_async_pager(): - client = CatalogServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CatalogServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1463,20 +1570,29 @@ async def test_list_catalog_items_async_pager(): next_page_token="abc", ), catalog_service.ListCatalogItemsResponse( - catalog_items=[], next_page_token="def", + catalog_items=[], + next_page_token="def", ), catalog_service.ListCatalogItemsResponse( - catalog_items=[catalog.CatalogItem(),], next_page_token="ghi", + catalog_items=[ + catalog.CatalogItem(), + ], + next_page_token="ghi", ), catalog_service.ListCatalogItemsResponse( - catalog_items=[catalog.CatalogItem(), catalog.CatalogItem(),], + catalog_items=[ + catalog.CatalogItem(), + catalog.CatalogItem(), + ], ), RuntimeError, ) - async_pager = await client.list_catalog_items(request={},) + async_pager = await client.list_catalog_items( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -1485,7 +1601,9 @@ async def test_list_catalog_items_async_pager(): @pytest.mark.asyncio async def test_list_catalog_items_async_pages(): - client = CatalogServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CatalogServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1504,29 +1622,43 @@ async def test_list_catalog_items_async_pages(): next_page_token="abc", ), catalog_service.ListCatalogItemsResponse( - catalog_items=[], next_page_token="def", + catalog_items=[], + next_page_token="def", ), catalog_service.ListCatalogItemsResponse( - catalog_items=[catalog.CatalogItem(),], next_page_token="ghi", + catalog_items=[ + catalog.CatalogItem(), + ], + next_page_token="ghi", ), catalog_service.ListCatalogItemsResponse( - catalog_items=[catalog.CatalogItem(), catalog.CatalogItem(),], + catalog_items=[ + catalog.CatalogItem(), + catalog.CatalogItem(), + ], ), RuntimeError, ) pages = [] - async for page_ in (await client.list_catalog_items(request={})).pages: + async for page_ in ( + await client.list_catalog_items(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @pytest.mark.parametrize( - "request_type", [catalog_service.UpdateCatalogItemRequest, dict,] + "request_type", + [ + catalog_service.UpdateCatalogItemRequest, + dict, + ], ) def test_update_catalog_item(request_type, transport: str = "grpc"): client = CatalogServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1570,7 +1702,8 @@ def test_update_catalog_item_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CatalogServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1589,7 +1722,8 @@ async def test_update_catalog_item_async( request_type=catalog_service.UpdateCatalogItemRequest, ): client = CatalogServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1634,13 +1768,15 @@ async def test_update_catalog_item_async_from_dict(): def test_update_catalog_item_field_headers(): - client = CatalogServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CatalogServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = catalog_service.UpdateCatalogItemRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1656,7 +1792,10 @@ def test_update_catalog_item_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1669,7 +1808,7 @@ async def test_update_catalog_item_field_headers_async(): # a field header. Set these to a non-empty value. request = catalog_service.UpdateCatalogItemRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1685,11 +1824,16 @@ async def test_update_catalog_item_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_update_catalog_item_flattened(): - client = CatalogServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CatalogServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1721,7 +1865,9 @@ def test_update_catalog_item_flattened(): def test_update_catalog_item_flattened_error(): - client = CatalogServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CatalogServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1789,11 +1935,16 @@ async def test_update_catalog_item_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [catalog_service.DeleteCatalogItemRequest, dict,] + "request_type", + [ + catalog_service.DeleteCatalogItemRequest, + dict, + ], ) def test_delete_catalog_item(request_type, transport: str = "grpc"): client = CatalogServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1821,7 +1972,8 @@ def test_delete_catalog_item_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CatalogServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1840,7 +1992,8 @@ async def test_delete_catalog_item_async( request_type=catalog_service.DeleteCatalogItemRequest, ): client = CatalogServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1870,13 +2023,15 @@ async def test_delete_catalog_item_async_from_dict(): def test_delete_catalog_item_field_headers(): - client = CatalogServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CatalogServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = catalog_service.DeleteCatalogItemRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1892,7 +2047,10 @@ def test_delete_catalog_item_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1905,7 +2063,7 @@ async def test_delete_catalog_item_field_headers_async(): # a field header. Set these to a non-empty value. request = catalog_service.DeleteCatalogItemRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1921,11 +2079,16 @@ async def test_delete_catalog_item_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_delete_catalog_item_flattened(): - client = CatalogServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CatalogServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1935,7 +2098,9 @@ def test_delete_catalog_item_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_catalog_item(name="name_value",) + client.delete_catalog_item( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1947,13 +2112,16 @@ def test_delete_catalog_item_flattened(): def test_delete_catalog_item_flattened_error(): - client = CatalogServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CatalogServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.delete_catalog_item( - catalog_service.DeleteCatalogItemRequest(), name="name_value", + catalog_service.DeleteCatalogItemRequest(), + name="name_value", ) @@ -1973,7 +2141,9 @@ async def test_delete_catalog_item_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_catalog_item(name="name_value",) + response = await client.delete_catalog_item( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1994,14 +2164,22 @@ async def test_delete_catalog_item_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.delete_catalog_item( - catalog_service.DeleteCatalogItemRequest(), name="name_value", + catalog_service.DeleteCatalogItemRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [import_.ImportCatalogItemsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + import_.ImportCatalogItemsRequest, + dict, + ], +) def test_import_catalog_items(request_type, transport: str = "grpc"): client = CatalogServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2029,7 +2207,8 @@ def test_import_catalog_items_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CatalogServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2047,7 +2226,8 @@ async def test_import_catalog_items_async( transport: str = "grpc_asyncio", request_type=import_.ImportCatalogItemsRequest ): client = CatalogServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2079,13 +2259,15 @@ async def test_import_catalog_items_async_from_dict(): def test_import_catalog_items_field_headers(): - client = CatalogServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CatalogServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = import_.ImportCatalogItemsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2101,7 +2283,10 @@ def test_import_catalog_items_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2114,7 +2299,7 @@ async def test_import_catalog_items_field_headers_async(): # a field header. Set these to a non-empty value. request = import_.ImportCatalogItemsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2132,11 +2317,16 @@ async def test_import_catalog_items_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_import_catalog_items_flattened(): - client = CatalogServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CatalogServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2180,7 +2370,9 @@ def test_import_catalog_items_flattened(): def test_import_catalog_items_flattened_error(): - client = CatalogServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CatalogServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2278,7 +2470,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = CatalogServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -2298,7 +2491,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = CatalogServiceClient(client_options=options, transport=transport,) + client = CatalogServiceClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -2314,7 +2510,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = CatalogServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -2357,10 +2554,28 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = CatalogServiceClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = CatalogServiceClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.CatalogServiceGrpcTransport,) + client = CatalogServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.CatalogServiceGrpcTransport, + ) def test_catalog_service_base_transport_error(): @@ -2404,6 +2619,14 @@ def test_catalog_service_base_transport(): with pytest.raises(NotImplementedError): transport.operations_client + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_catalog_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -2415,7 +2638,8 @@ def test_catalog_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.CatalogServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -2548,24 +2772,40 @@ def test_catalog_service_grpc_transport_client_cert_source_for_mtls(transport_cl ) -def test_catalog_service_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_catalog_service_host_no_port(transport_name): client = CatalogServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="recommendationengine.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "recommendationengine.googleapis.com:443" + assert client.transport._host == ("recommendationengine.googleapis.com:443") -def test_catalog_service_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_catalog_service_host_with_port(transport_name): client = CatalogServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="recommendationengine.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "recommendationengine.googleapis.com:8000" + assert client.transport._host == ("recommendationengine.googleapis.com:8000") def test_catalog_service_grpc_transport_channel(): @@ -2573,7 +2813,8 @@ def test_catalog_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.CatalogServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2585,7 +2826,8 @@ def test_catalog_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.CatalogServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2694,12 +2936,16 @@ def test_catalog_service_transport_channel_mtls_with_adc(transport_class): def test_catalog_service_grpc_lro_client(): client = CatalogServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsClient,) + assert isinstance( + transport.operations_client, + operations_v1.OperationsClient, + ) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -2707,12 +2953,16 @@ def test_catalog_service_grpc_lro_client(): def test_catalog_service_grpc_lro_async_client(): client = CatalogServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,) + assert isinstance( + transport.operations_client, + operations_v1.OperationsAsyncClient, + ) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -2723,7 +2973,9 @@ def test_catalog_path(): location = "clam" catalog = "whelk" expected = "projects/{project}/locations/{location}/catalogs/{catalog}".format( - project=project, location=location, catalog=catalog, + project=project, + location=location, + catalog=catalog, ) actual = CatalogServiceClient.catalog_path(project, location, catalog) assert expected == actual @@ -2764,7 +3016,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "oyster" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = CatalogServiceClient.common_folder_path(folder) assert expected == actual @@ -2782,7 +3036,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "cuttlefish" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = CatalogServiceClient.common_organization_path(organization) assert expected == actual @@ -2800,7 +3056,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "winkle" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = CatalogServiceClient.common_project_path(project) assert expected == actual @@ -2820,7 +3078,8 @@ def test_common_location_path(): project = "scallop" location = "abalone" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = CatalogServiceClient.common_location_path(project, location) assert expected == actual @@ -2845,7 +3104,8 @@ def test_client_with_default_client_info(): transports.CatalogServiceTransport, "_prep_wrapped_messages" ) as prep: client = CatalogServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2854,7 +3114,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = CatalogServiceClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2862,7 +3123,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = CatalogServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/recommendationengine_v1beta1/test_prediction_api_key_registry.py b/tests/unit/gapic/recommendationengine_v1beta1/test_prediction_api_key_registry.py index 308eb44c..01a81365 100644 --- a/tests/unit/gapic/recommendationengine_v1beta1/test_prediction_api_key_registry.py +++ b/tests/unit/gapic/recommendationengine_v1beta1/test_prediction_api_key_registry.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio @@ -96,21 +102,26 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", - [PredictionApiKeyRegistryClient, PredictionApiKeyRegistryAsyncClient,], + "client_class,transport_name", + [ + (PredictionApiKeyRegistryClient, "grpc"), + (PredictionApiKeyRegistryAsyncClient, "grpc_asyncio"), + ], ) -def test_prediction_api_key_registry_client_from_service_account_info(client_class): +def test_prediction_api_key_registry_client_from_service_account_info( + client_class, transport_name +): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "recommendationengine.googleapis.com:443" + assert client.transport._host == ("recommendationengine.googleapis.com:443") @pytest.mark.parametrize( @@ -139,24 +150,33 @@ def test_prediction_api_key_registry_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", - [PredictionApiKeyRegistryClient, PredictionApiKeyRegistryAsyncClient,], + "client_class,transport_name", + [ + (PredictionApiKeyRegistryClient, "grpc"), + (PredictionApiKeyRegistryAsyncClient, "grpc_asyncio"), + ], ) -def test_prediction_api_key_registry_client_from_service_account_file(client_class): +def test_prediction_api_key_registry_client_from_service_account_file( + client_class, transport_name +): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "recommendationengine.googleapis.com:443" + assert client.transport._host == ("recommendationengine.googleapis.com:443") def test_prediction_api_key_registry_client_get_transport_class(): @@ -529,7 +549,9 @@ def test_prediction_api_key_registry_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -678,7 +700,8 @@ def test_prediction_api_key_registry_client_create_channel_credentials_file( ) def test_create_prediction_api_key_registration(request_type, transport: str = "grpc"): client = PredictionApiKeyRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -690,8 +713,10 @@ def test_create_prediction_api_key_registration(request_type, transport: str = " type(client.transport.create_prediction_api_key_registration), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = prediction_apikey_registry_service.PredictionApiKeyRegistration( - api_key="api_key_value", + call.return_value = ( + prediction_apikey_registry_service.PredictionApiKeyRegistration( + api_key="api_key_value", + ) ) response = client.create_prediction_api_key_registration(request) @@ -714,7 +739,8 @@ def test_create_prediction_api_key_registration_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PredictionApiKeyRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -736,7 +762,8 @@ async def test_create_prediction_api_key_registration_async( request_type=prediction_apikey_registry_service.CreatePredictionApiKeyRegistrationRequest, ): client = PredictionApiKeyRegistryAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -786,7 +813,7 @@ def test_create_prediction_api_key_registration_field_headers(): prediction_apikey_registry_service.CreatePredictionApiKeyRegistrationRequest() ) - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -804,7 +831,10 @@ def test_create_prediction_api_key_registration_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -819,7 +849,7 @@ async def test_create_prediction_api_key_registration_field_headers_async(): prediction_apikey_registry_service.CreatePredictionApiKeyRegistrationRequest() ) - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -837,7 +867,10 @@ async def test_create_prediction_api_key_registration_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_create_prediction_api_key_registration_flattened(): @@ -961,7 +994,8 @@ async def test_create_prediction_api_key_registration_flattened_error_async(): ) def test_list_prediction_api_key_registrations(request_type, transport: str = "grpc"): client = PredictionApiKeyRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -995,7 +1029,8 @@ def test_list_prediction_api_key_registrations_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PredictionApiKeyRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1017,7 +1052,8 @@ async def test_list_prediction_api_key_registrations_async( request_type=prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsRequest, ): client = PredictionApiKeyRegistryAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1065,7 +1101,7 @@ def test_list_prediction_api_key_registrations_field_headers(): prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsRequest() ) - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1083,7 +1119,10 @@ def test_list_prediction_api_key_registrations_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1098,7 +1137,7 @@ async def test_list_prediction_api_key_registrations_field_headers_async(): prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsRequest() ) - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1116,7 +1155,10 @@ async def test_list_prediction_api_key_registrations_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_list_prediction_api_key_registrations_flattened(): @@ -1134,7 +1176,9 @@ def test_list_prediction_api_key_registrations_flattened(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_prediction_api_key_registrations(parent="parent_value",) + client.list_prediction_api_key_registrations( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1209,7 +1253,8 @@ async def test_list_prediction_api_key_registrations_flattened_error_async(): def test_list_prediction_api_key_registrations_pager(transport_name: str = "grpc"): client = PredictionApiKeyRegistryClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1227,7 +1272,8 @@ def test_list_prediction_api_key_registrations_pager(transport_name: str = "grpc next_page_token="abc", ), prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsResponse( - prediction_api_key_registrations=[], next_page_token="def", + prediction_api_key_registrations=[], + next_page_token="def", ), prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsResponse( prediction_api_key_registrations=[ @@ -1252,7 +1298,7 @@ def test_list_prediction_api_key_registrations_pager(transport_name: str = "grpc assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all( isinstance( @@ -1264,7 +1310,8 @@ def test_list_prediction_api_key_registrations_pager(transport_name: str = "grpc def test_list_prediction_api_key_registrations_pages(transport_name: str = "grpc"): client = PredictionApiKeyRegistryClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1282,7 +1329,8 @@ def test_list_prediction_api_key_registrations_pages(transport_name: str = "grpc next_page_token="abc", ), prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsResponse( - prediction_api_key_registrations=[], next_page_token="def", + prediction_api_key_registrations=[], + next_page_token="def", ), prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsResponse( prediction_api_key_registrations=[ @@ -1326,7 +1374,8 @@ async def test_list_prediction_api_key_registrations_async_pager(): next_page_token="abc", ), prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsResponse( - prediction_api_key_registrations=[], next_page_token="def", + prediction_api_key_registrations=[], + next_page_token="def", ), prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsResponse( prediction_api_key_registrations=[ @@ -1342,10 +1391,12 @@ async def test_list_prediction_api_key_registrations_async_pager(): ), RuntimeError, ) - async_pager = await client.list_prediction_api_key_registrations(request={},) + async_pager = await client.list_prediction_api_key_registrations( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -1380,7 +1431,8 @@ async def test_list_prediction_api_key_registrations_async_pages(): next_page_token="abc", ), prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsResponse( - prediction_api_key_registrations=[], next_page_token="def", + prediction_api_key_registrations=[], + next_page_token="def", ), prediction_apikey_registry_service.ListPredictionApiKeyRegistrationsResponse( prediction_api_key_registrations=[ @@ -1399,7 +1451,7 @@ async def test_list_prediction_api_key_registrations_async_pages(): pages = [] async for page_ in ( await client.list_prediction_api_key_registrations(request={}) - ).pages: + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -1414,7 +1466,8 @@ async def test_list_prediction_api_key_registrations_async_pages(): ) def test_delete_prediction_api_key_registration(request_type, transport: str = "grpc"): client = PredictionApiKeyRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1445,7 +1498,8 @@ def test_delete_prediction_api_key_registration_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PredictionApiKeyRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1467,7 +1521,8 @@ async def test_delete_prediction_api_key_registration_async( request_type=prediction_apikey_registry_service.DeletePredictionApiKeyRegistrationRequest, ): client = PredictionApiKeyRegistryAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1510,7 +1565,7 @@ def test_delete_prediction_api_key_registration_field_headers(): prediction_apikey_registry_service.DeletePredictionApiKeyRegistrationRequest() ) - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1526,7 +1581,10 @@ def test_delete_prediction_api_key_registration_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1541,7 +1599,7 @@ async def test_delete_prediction_api_key_registration_field_headers_async(): prediction_apikey_registry_service.DeletePredictionApiKeyRegistrationRequest() ) - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1557,7 +1615,10 @@ async def test_delete_prediction_api_key_registration_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_delete_prediction_api_key_registration_flattened(): @@ -1573,7 +1634,9 @@ def test_delete_prediction_api_key_registration_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_prediction_api_key_registration(name="name_value",) + client.delete_prediction_api_key_registration( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1649,7 +1712,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = PredictionApiKeyRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -1670,7 +1734,8 @@ def test_credentials_transport_error(): options.api_key = "api_key" with pytest.raises(ValueError): client = PredictionApiKeyRegistryClient( - client_options=options, transport=transport, + client_options=options, + transport=transport, ) # It is an error to provide an api_key and a credential. @@ -1687,7 +1752,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = PredictionApiKeyRegistryClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -1730,13 +1796,27 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = PredictionApiKeyRegistryClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = PredictionApiKeyRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) assert isinstance( - client.transport, transports.PredictionApiKeyRegistryGrpcTransport, + client.transport, + transports.PredictionApiKeyRegistryGrpcTransport, ) @@ -1773,6 +1853,14 @@ def test_prediction_api_key_registry_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_prediction_api_key_registry_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -1784,7 +1872,8 @@ def test_prediction_api_key_registry_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.PredictionApiKeyRegistryTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1921,24 +2010,40 @@ def test_prediction_api_key_registry_grpc_transport_client_cert_source_for_mtls( ) -def test_prediction_api_key_registry_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_prediction_api_key_registry_host_no_port(transport_name): client = PredictionApiKeyRegistryClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="recommendationengine.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "recommendationengine.googleapis.com:443" + assert client.transport._host == ("recommendationengine.googleapis.com:443") -def test_prediction_api_key_registry_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_prediction_api_key_registry_host_with_port(transport_name): client = PredictionApiKeyRegistryClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="recommendationengine.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "recommendationengine.googleapis.com:8000" + assert client.transport._host == ("recommendationengine.googleapis.com:8000") def test_prediction_api_key_registry_grpc_transport_channel(): @@ -1946,7 +2051,8 @@ def test_prediction_api_key_registry_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.PredictionApiKeyRegistryGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1958,7 +2064,8 @@ def test_prediction_api_key_registry_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.PredictionApiKeyRegistryGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2071,7 +2178,10 @@ def test_event_store_path(): catalog = "whelk" event_store = "octopus" expected = "projects/{project}/locations/{location}/catalogs/{catalog}/eventStores/{event_store}".format( - project=project, location=location, catalog=catalog, event_store=event_store, + project=project, + location=location, + catalog=catalog, + event_store=event_store, ) actual = PredictionApiKeyRegistryClient.event_store_path( project, location, catalog, event_store @@ -2153,7 +2263,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "winkle" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = PredictionApiKeyRegistryClient.common_folder_path(folder) assert expected == actual @@ -2171,7 +2283,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "scallop" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = PredictionApiKeyRegistryClient.common_organization_path(organization) assert expected == actual @@ -2189,7 +2303,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "squid" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = PredictionApiKeyRegistryClient.common_project_path(project) assert expected == actual @@ -2209,7 +2325,8 @@ def test_common_location_path(): project = "whelk" location = "octopus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = PredictionApiKeyRegistryClient.common_location_path(project, location) assert expected == actual @@ -2234,7 +2351,8 @@ def test_client_with_default_client_info(): transports.PredictionApiKeyRegistryTransport, "_prep_wrapped_messages" ) as prep: client = PredictionApiKeyRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2243,7 +2361,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = PredictionApiKeyRegistryClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2251,7 +2370,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = PredictionApiKeyRegistryAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/recommendationengine_v1beta1/test_prediction_service.py b/tests/unit/gapic/recommendationengine_v1beta1/test_prediction_service.py index a065960f..3d7c53d4 100644 --- a/tests/unit/gapic/recommendationengine_v1beta1/test_prediction_service.py +++ b/tests/unit/gapic/recommendationengine_v1beta1/test_prediction_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio @@ -97,20 +103,26 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", [PredictionServiceClient, PredictionServiceAsyncClient,] + "client_class,transport_name", + [ + (PredictionServiceClient, "grpc"), + (PredictionServiceAsyncClient, "grpc_asyncio"), + ], ) -def test_prediction_service_client_from_service_account_info(client_class): +def test_prediction_service_client_from_service_account_info( + client_class, transport_name +): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "recommendationengine.googleapis.com:443" + assert client.transport._host == ("recommendationengine.googleapis.com:443") @pytest.mark.parametrize( @@ -139,23 +151,33 @@ def test_prediction_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", [PredictionServiceClient, PredictionServiceAsyncClient,] + "client_class,transport_name", + [ + (PredictionServiceClient, "grpc"), + (PredictionServiceAsyncClient, "grpc_asyncio"), + ], ) -def test_prediction_service_client_from_service_account_file(client_class): +def test_prediction_service_client_from_service_account_file( + client_class, transport_name +): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "recommendationengine.googleapis.com:443" + assert client.transport._host == ("recommendationengine.googleapis.com:443") def test_prediction_service_client_get_transport_class(): @@ -513,7 +535,9 @@ def test_prediction_service_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -653,10 +677,17 @@ def test_prediction_service_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [prediction_service.PredictRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + prediction_service.PredictRequest, + dict, + ], +) def test_predict(request_type, transport: str = "grpc"): client = PredictionServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -691,7 +722,8 @@ def test_predict_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PredictionServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -707,7 +739,8 @@ async def test_predict_async( transport: str = "grpc_asyncio", request_type=prediction_service.PredictRequest ): client = PredictionServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -746,13 +779,15 @@ async def test_predict_async_from_dict(): def test_predict_field_headers(): - client = PredictionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PredictionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = prediction_service.PredictRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.predict), "__call__") as call: @@ -766,7 +801,10 @@ def test_predict_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -779,7 +817,7 @@ async def test_predict_field_headers_async(): # a field header. Set these to a non-empty value. request = prediction_service.PredictRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.predict), "__call__") as call: @@ -795,11 +833,16 @@ async def test_predict_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_predict_flattened(): - client = PredictionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PredictionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.predict), "__call__") as call: @@ -825,7 +868,9 @@ def test_predict_flattened(): def test_predict_flattened_error(): - client = PredictionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PredictionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -888,7 +933,8 @@ async def test_predict_flattened_error_async(): def test_predict_pager(transport_name: str = "grpc"): client = PredictionServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -903,9 +949,14 @@ def test_predict_pager(transport_name: str = "grpc"): ], next_page_token="abc", ), - prediction_service.PredictResponse(results=[], next_page_token="def",), prediction_service.PredictResponse( - results=[prediction_service.PredictResponse.PredictionResult(),], + results=[], + next_page_token="def", + ), + prediction_service.PredictResponse( + results=[ + prediction_service.PredictResponse.PredictionResult(), + ], next_page_token="ghi", ), prediction_service.PredictResponse( @@ -925,7 +976,7 @@ def test_predict_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all( isinstance(i, prediction_service.PredictResponse.PredictionResult) @@ -935,7 +986,8 @@ def test_predict_pager(transport_name: str = "grpc"): def test_predict_pages(transport_name: str = "grpc"): client = PredictionServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -950,9 +1002,14 @@ def test_predict_pages(transport_name: str = "grpc"): ], next_page_token="abc", ), - prediction_service.PredictResponse(results=[], next_page_token="def",), prediction_service.PredictResponse( - results=[prediction_service.PredictResponse.PredictionResult(),], + results=[], + next_page_token="def", + ), + prediction_service.PredictResponse( + results=[ + prediction_service.PredictResponse.PredictionResult(), + ], next_page_token="ghi", ), prediction_service.PredictResponse( @@ -988,9 +1045,14 @@ async def test_predict_async_pager(): ], next_page_token="abc", ), - prediction_service.PredictResponse(results=[], next_page_token="def",), prediction_service.PredictResponse( - results=[prediction_service.PredictResponse.PredictionResult(),], + results=[], + next_page_token="def", + ), + prediction_service.PredictResponse( + results=[ + prediction_service.PredictResponse.PredictionResult(), + ], next_page_token="ghi", ), prediction_service.PredictResponse( @@ -1001,10 +1063,12 @@ async def test_predict_async_pager(): ), RuntimeError, ) - async_pager = await client.predict(request={},) + async_pager = await client.predict( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -1034,9 +1098,14 @@ async def test_predict_async_pages(): ], next_page_token="abc", ), - prediction_service.PredictResponse(results=[], next_page_token="def",), prediction_service.PredictResponse( - results=[prediction_service.PredictResponse.PredictionResult(),], + results=[], + next_page_token="def", + ), + prediction_service.PredictResponse( + results=[ + prediction_service.PredictResponse.PredictionResult(), + ], next_page_token="ghi", ), prediction_service.PredictResponse( @@ -1048,7 +1117,9 @@ async def test_predict_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.predict(request={})).pages: + async for page_ in ( + await client.predict(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -1061,7 +1132,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = PredictionServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -1081,7 +1153,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = PredictionServiceClient(client_options=options, transport=transport,) + client = PredictionServiceClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -1097,7 +1172,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = PredictionServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -1140,10 +1216,28 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = PredictionServiceClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = PredictionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.PredictionServiceGrpcTransport,) + client = PredictionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.PredictionServiceGrpcTransport, + ) def test_prediction_service_base_transport_error(): @@ -1175,6 +1269,14 @@ def test_prediction_service_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_prediction_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -1186,7 +1288,8 @@ def test_prediction_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.PredictionServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1319,24 +1422,40 @@ def test_prediction_service_grpc_transport_client_cert_source_for_mtls(transport ) -def test_prediction_service_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_prediction_service_host_no_port(transport_name): client = PredictionServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="recommendationengine.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "recommendationengine.googleapis.com:443" + assert client.transport._host == ("recommendationengine.googleapis.com:443") -def test_prediction_service_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_prediction_service_host_with_port(transport_name): client = PredictionServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="recommendationengine.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "recommendationengine.googleapis.com:8000" + assert client.transport._host == ("recommendationengine.googleapis.com:8000") def test_prediction_service_grpc_transport_channel(): @@ -1344,7 +1463,8 @@ def test_prediction_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.PredictionServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1356,7 +1476,8 @@ def test_prediction_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.PredictionServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1519,7 +1640,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "squid" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = PredictionServiceClient.common_folder_path(folder) assert expected == actual @@ -1537,7 +1660,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "whelk" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = PredictionServiceClient.common_organization_path(organization) assert expected == actual @@ -1555,7 +1680,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "oyster" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = PredictionServiceClient.common_project_path(project) assert expected == actual @@ -1575,7 +1702,8 @@ def test_common_location_path(): project = "cuttlefish" location = "mussel" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = PredictionServiceClient.common_location_path(project, location) assert expected == actual @@ -1600,7 +1728,8 @@ def test_client_with_default_client_info(): transports.PredictionServiceTransport, "_prep_wrapped_messages" ) as prep: client = PredictionServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1609,7 +1738,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = PredictionServiceClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1617,7 +1747,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = PredictionServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/recommendationengine_v1beta1/test_user_event_service.py b/tests/unit/gapic/recommendationengine_v1beta1/test_user_event_service.py index 699b1afc..526e791e 100644 --- a/tests/unit/gapic/recommendationengine_v1beta1/test_user_event_service.py +++ b/tests/unit/gapic/recommendationengine_v1beta1/test_user_event_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio @@ -105,20 +111,26 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", [UserEventServiceClient, UserEventServiceAsyncClient,] + "client_class,transport_name", + [ + (UserEventServiceClient, "grpc"), + (UserEventServiceAsyncClient, "grpc_asyncio"), + ], ) -def test_user_event_service_client_from_service_account_info(client_class): +def test_user_event_service_client_from_service_account_info( + client_class, transport_name +): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "recommendationengine.googleapis.com:443" + assert client.transport._host == ("recommendationengine.googleapis.com:443") @pytest.mark.parametrize( @@ -147,23 +159,33 @@ def test_user_event_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", [UserEventServiceClient, UserEventServiceAsyncClient,] + "client_class,transport_name", + [ + (UserEventServiceClient, "grpc"), + (UserEventServiceAsyncClient, "grpc_asyncio"), + ], ) -def test_user_event_service_client_from_service_account_file(client_class): +def test_user_event_service_client_from_service_account_file( + client_class, transport_name +): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "recommendationengine.googleapis.com:443" + assert client.transport._host == ("recommendationengine.googleapis.com:443") def test_user_event_service_client_get_transport_class(): @@ -521,7 +543,9 @@ def test_user_event_service_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -662,11 +686,16 @@ def test_user_event_service_client_create_channel_credentials_file( @pytest.mark.parametrize( - "request_type", [user_event_service.WriteUserEventRequest, dict,] + "request_type", + [ + user_event_service.WriteUserEventRequest, + dict, + ], ) def test_write_user_event(request_type, transport: str = "grpc"): client = UserEventServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -697,7 +726,8 @@ def test_write_user_event_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = UserEventServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -714,7 +744,8 @@ async def test_write_user_event_async( request_type=user_event_service.WriteUserEventRequest, ): client = UserEventServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -749,13 +780,15 @@ async def test_write_user_event_async_from_dict(): def test_write_user_event_field_headers(): - client = UserEventServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = UserEventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = user_event_service.WriteUserEventRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.write_user_event), "__call__") as call: @@ -769,7 +802,10 @@ def test_write_user_event_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -782,7 +818,7 @@ async def test_write_user_event_field_headers_async(): # a field header. Set these to a non-empty value. request = user_event_service.WriteUserEventRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.write_user_event), "__call__") as call: @@ -798,11 +834,16 @@ async def test_write_user_event_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_write_user_event_flattened(): - client = UserEventServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = UserEventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.write_user_event), "__call__") as call: @@ -828,7 +869,9 @@ def test_write_user_event_flattened(): def test_write_user_event_flattened_error(): - client = UserEventServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = UserEventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -890,11 +933,16 @@ async def test_write_user_event_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [user_event_service.CollectUserEventRequest, dict,] + "request_type", + [ + user_event_service.CollectUserEventRequest, + dict, + ], ) def test_collect_user_event(request_type, transport: str = "grpc"): client = UserEventServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -907,7 +955,8 @@ def test_collect_user_event(request_type, transport: str = "grpc"): ) as call: # Designate an appropriate return value for the call. call.return_value = httpbody_pb2.HttpBody( - content_type="content_type_value", data=b"data_blob", + content_type="content_type_value", + data=b"data_blob", ) response = client.collect_user_event(request) @@ -926,7 +975,8 @@ def test_collect_user_event_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = UserEventServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -945,7 +995,8 @@ async def test_collect_user_event_async( request_type=user_event_service.CollectUserEventRequest, ): client = UserEventServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -958,7 +1009,10 @@ async def test_collect_user_event_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - httpbody_pb2.HttpBody(content_type="content_type_value", data=b"data_blob",) + httpbody_pb2.HttpBody( + content_type="content_type_value", + data=b"data_blob", + ) ) response = await client.collect_user_event(request) @@ -979,13 +1033,15 @@ async def test_collect_user_event_async_from_dict(): def test_collect_user_event_field_headers(): - client = UserEventServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = UserEventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = user_event_service.CollectUserEventRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1001,7 +1057,10 @@ def test_collect_user_event_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1014,7 +1073,7 @@ async def test_collect_user_event_field_headers_async(): # a field header. Set these to a non-empty value. request = user_event_service.CollectUserEventRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1032,11 +1091,16 @@ async def test_collect_user_event_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_collect_user_event_flattened(): - client = UserEventServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = UserEventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1072,7 +1136,9 @@ def test_collect_user_event_flattened(): def test_collect_user_event_flattened_error(): - client = UserEventServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = UserEventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1148,11 +1214,16 @@ async def test_collect_user_event_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [user_event_service.ListUserEventsRequest, dict,] + "request_type", + [ + user_event_service.ListUserEventsRequest, + dict, + ], ) def test_list_user_events(request_type, transport: str = "grpc"): client = UserEventServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1181,7 +1252,8 @@ def test_list_user_events_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = UserEventServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1198,7 +1270,8 @@ async def test_list_user_events_async( request_type=user_event_service.ListUserEventsRequest, ): client = UserEventServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1231,13 +1304,15 @@ async def test_list_user_events_async_from_dict(): def test_list_user_events_field_headers(): - client = UserEventServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = UserEventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = user_event_service.ListUserEventsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_user_events), "__call__") as call: @@ -1251,7 +1326,10 @@ def test_list_user_events_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1264,7 +1342,7 @@ async def test_list_user_events_field_headers_async(): # a field header. Set these to a non-empty value. request = user_event_service.ListUserEventsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_user_events), "__call__") as call: @@ -1280,11 +1358,16 @@ async def test_list_user_events_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_list_user_events_flattened(): - client = UserEventServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = UserEventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_user_events), "__call__") as call: @@ -1293,7 +1376,8 @@ def test_list_user_events_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_user_events( - parent="parent_value", filter="filter_value", + parent="parent_value", + filter="filter_value", ) # Establish that the underlying call was made with the expected @@ -1309,7 +1393,9 @@ def test_list_user_events_flattened(): def test_list_user_events_flattened_error(): - client = UserEventServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = UserEventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1338,7 +1424,8 @@ async def test_list_user_events_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.list_user_events( - parent="parent_value", filter="filter_value", + parent="parent_value", + filter="filter_value", ) # Establish that the underlying call was made with the expected @@ -1371,7 +1458,8 @@ async def test_list_user_events_flattened_error_async(): def test_list_user_events_pager(transport_name: str = "grpc"): client = UserEventServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1387,13 +1475,20 @@ def test_list_user_events_pager(transport_name: str = "grpc"): next_page_token="abc", ), user_event_service.ListUserEventsResponse( - user_events=[], next_page_token="def", + user_events=[], + next_page_token="def", ), user_event_service.ListUserEventsResponse( - user_events=[user_event.UserEvent(),], next_page_token="ghi", + user_events=[ + user_event.UserEvent(), + ], + next_page_token="ghi", ), user_event_service.ListUserEventsResponse( - user_events=[user_event.UserEvent(), user_event.UserEvent(),], + user_events=[ + user_event.UserEvent(), + user_event.UserEvent(), + ], ), RuntimeError, ) @@ -1406,14 +1501,15 @@ def test_list_user_events_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, user_event.UserEvent) for i in results) def test_list_user_events_pages(transport_name: str = "grpc"): client = UserEventServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1429,13 +1525,20 @@ def test_list_user_events_pages(transport_name: str = "grpc"): next_page_token="abc", ), user_event_service.ListUserEventsResponse( - user_events=[], next_page_token="def", + user_events=[], + next_page_token="def", ), user_event_service.ListUserEventsResponse( - user_events=[user_event.UserEvent(),], next_page_token="ghi", + user_events=[ + user_event.UserEvent(), + ], + next_page_token="ghi", ), user_event_service.ListUserEventsResponse( - user_events=[user_event.UserEvent(), user_event.UserEvent(),], + user_events=[ + user_event.UserEvent(), + user_event.UserEvent(), + ], ), RuntimeError, ) @@ -1465,20 +1568,29 @@ async def test_list_user_events_async_pager(): next_page_token="abc", ), user_event_service.ListUserEventsResponse( - user_events=[], next_page_token="def", + user_events=[], + next_page_token="def", ), user_event_service.ListUserEventsResponse( - user_events=[user_event.UserEvent(),], next_page_token="ghi", + user_events=[ + user_event.UserEvent(), + ], + next_page_token="ghi", ), user_event_service.ListUserEventsResponse( - user_events=[user_event.UserEvent(), user_event.UserEvent(),], + user_events=[ + user_event.UserEvent(), + user_event.UserEvent(), + ], ), RuntimeError, ) - async_pager = await client.list_user_events(request={},) + async_pager = await client.list_user_events( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -1506,29 +1618,43 @@ async def test_list_user_events_async_pages(): next_page_token="abc", ), user_event_service.ListUserEventsResponse( - user_events=[], next_page_token="def", + user_events=[], + next_page_token="def", ), user_event_service.ListUserEventsResponse( - user_events=[user_event.UserEvent(),], next_page_token="ghi", + user_events=[ + user_event.UserEvent(), + ], + next_page_token="ghi", ), user_event_service.ListUserEventsResponse( - user_events=[user_event.UserEvent(), user_event.UserEvent(),], + user_events=[ + user_event.UserEvent(), + user_event.UserEvent(), + ], ), RuntimeError, ) pages = [] - async for page_ in (await client.list_user_events(request={})).pages: + async for page_ in ( + await client.list_user_events(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @pytest.mark.parametrize( - "request_type", [user_event_service.PurgeUserEventsRequest, dict,] + "request_type", + [ + user_event_service.PurgeUserEventsRequest, + dict, + ], ) def test_purge_user_events(request_type, transport: str = "grpc"): client = UserEventServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1556,7 +1682,8 @@ def test_purge_user_events_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = UserEventServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1575,7 +1702,8 @@ async def test_purge_user_events_async( request_type=user_event_service.PurgeUserEventsRequest, ): client = UserEventServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1607,13 +1735,15 @@ async def test_purge_user_events_async_from_dict(): def test_purge_user_events_field_headers(): - client = UserEventServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = UserEventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = user_event_service.PurgeUserEventsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1629,7 +1759,10 @@ def test_purge_user_events_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1642,7 +1775,7 @@ async def test_purge_user_events_field_headers_async(): # a field header. Set these to a non-empty value. request = user_event_service.PurgeUserEventsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1660,11 +1793,16 @@ async def test_purge_user_events_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_purge_user_events_flattened(): - client = UserEventServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = UserEventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1675,7 +1813,9 @@ def test_purge_user_events_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.purge_user_events( - parent="parent_value", filter="filter_value", force=True, + parent="parent_value", + filter="filter_value", + force=True, ) # Establish that the underlying call was made with the expected @@ -1694,7 +1834,9 @@ def test_purge_user_events_flattened(): def test_purge_user_events_flattened_error(): - client = UserEventServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = UserEventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1726,7 +1868,9 @@ async def test_purge_user_events_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.purge_user_events( - parent="parent_value", filter="filter_value", force=True, + parent="parent_value", + filter="filter_value", + force=True, ) # Establish that the underlying call was made with the expected @@ -1761,10 +1905,17 @@ async def test_purge_user_events_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [import_.ImportUserEventsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + import_.ImportUserEventsRequest, + dict, + ], +) def test_import_user_events(request_type, transport: str = "grpc"): client = UserEventServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1792,7 +1943,8 @@ def test_import_user_events_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = UserEventServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1810,7 +1962,8 @@ async def test_import_user_events_async( transport: str = "grpc_asyncio", request_type=import_.ImportUserEventsRequest ): client = UserEventServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1842,13 +1995,15 @@ async def test_import_user_events_async_from_dict(): def test_import_user_events_field_headers(): - client = UserEventServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = UserEventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = import_.ImportUserEventsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1864,7 +2019,10 @@ def test_import_user_events_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1877,7 +2035,7 @@ async def test_import_user_events_field_headers_async(): # a field header. Set these to a non-empty value. request = import_.ImportUserEventsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1895,11 +2053,16 @@ async def test_import_user_events_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_import_user_events_flattened(): - client = UserEventServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = UserEventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1943,7 +2106,9 @@ def test_import_user_events_flattened(): def test_import_user_events_flattened_error(): - client = UserEventServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = UserEventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2041,7 +2206,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = UserEventServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -2061,7 +2227,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = UserEventServiceClient(client_options=options, transport=transport,) + client = UserEventServiceClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -2077,7 +2246,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = UserEventServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -2120,10 +2290,28 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = UserEventServiceClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = UserEventServiceClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.UserEventServiceGrpcTransport,) + client = UserEventServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.UserEventServiceGrpcTransport, + ) def test_user_event_service_base_transport_error(): @@ -2166,6 +2354,14 @@ def test_user_event_service_base_transport(): with pytest.raises(NotImplementedError): transport.operations_client + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_user_event_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -2177,7 +2373,8 @@ def test_user_event_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.UserEventServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -2310,24 +2507,40 @@ def test_user_event_service_grpc_transport_client_cert_source_for_mtls(transport ) -def test_user_event_service_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_user_event_service_host_no_port(transport_name): client = UserEventServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="recommendationengine.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "recommendationengine.googleapis.com:443" + assert client.transport._host == ("recommendationengine.googleapis.com:443") -def test_user_event_service_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_user_event_service_host_with_port(transport_name): client = UserEventServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="recommendationengine.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "recommendationengine.googleapis.com:8000" + assert client.transport._host == ("recommendationengine.googleapis.com:8000") def test_user_event_service_grpc_transport_channel(): @@ -2335,7 +2548,8 @@ def test_user_event_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.UserEventServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2347,7 +2561,8 @@ def test_user_event_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.UserEventServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2456,12 +2671,16 @@ def test_user_event_service_transport_channel_mtls_with_adc(transport_class): def test_user_event_service_grpc_lro_client(): client = UserEventServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsClient,) + assert isinstance( + transport.operations_client, + operations_v1.OperationsClient, + ) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -2469,12 +2688,16 @@ def test_user_event_service_grpc_lro_client(): def test_user_event_service_grpc_lro_async_client(): client = UserEventServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,) + assert isinstance( + transport.operations_client, + operations_v1.OperationsAsyncClient, + ) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -2486,7 +2709,10 @@ def test_event_store_path(): catalog = "whelk" event_store = "octopus" expected = "projects/{project}/locations/{location}/catalogs/{catalog}/eventStores/{event_store}".format( - project=project, location=location, catalog=catalog, event_store=event_store, + project=project, + location=location, + catalog=catalog, + event_store=event_store, ) actual = UserEventServiceClient.event_store_path( project, location, catalog, event_store @@ -2530,7 +2756,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "scallop" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = UserEventServiceClient.common_folder_path(folder) assert expected == actual @@ -2548,7 +2776,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "squid" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = UserEventServiceClient.common_organization_path(organization) assert expected == actual @@ -2566,7 +2796,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "whelk" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = UserEventServiceClient.common_project_path(project) assert expected == actual @@ -2586,7 +2818,8 @@ def test_common_location_path(): project = "oyster" location = "nudibranch" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = UserEventServiceClient.common_location_path(project, location) assert expected == actual @@ -2611,7 +2844,8 @@ def test_client_with_default_client_info(): transports.UserEventServiceTransport, "_prep_wrapped_messages" ) as prep: client = UserEventServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2620,7 +2854,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = UserEventServiceClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2628,7 +2863,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = UserEventServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close"