diff --git a/.kokoro/docs/common.cfg b/.kokoro/docs/common.cfg
index b4c987d2..1f4e81f4 100644
--- a/.kokoro/docs/common.cfg
+++ b/.kokoro/docs/common.cfg
@@ -30,7 +30,7 @@ env_vars: {
env_vars: {
key: "V2_STAGING_BUCKET"
- value: "docs-staging-v2-staging"
+ value: "docs-staging-v2"
}
# It will upload the docker image after successful builds.
diff --git a/.kokoro/samples/python3.6/common.cfg b/.kokoro/samples/python3.6/common.cfg
index 3d483d87..bbce0b82 100644
--- a/.kokoro/samples/python3.6/common.cfg
+++ b/.kokoro/samples/python3.6/common.cfg
@@ -13,6 +13,12 @@ env_vars: {
value: "py-3.6"
}
+# Declare build specific Cloud project.
+env_vars: {
+ key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
+ value: "python-docs-samples-tests-py36"
+}
+
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-vision/.kokoro/test-samples.sh"
diff --git a/.kokoro/samples/python3.7/common.cfg b/.kokoro/samples/python3.7/common.cfg
index abd4954b..f01d989d 100644
--- a/.kokoro/samples/python3.7/common.cfg
+++ b/.kokoro/samples/python3.7/common.cfg
@@ -13,6 +13,12 @@ env_vars: {
value: "py-3.7"
}
+# Declare build specific Cloud project.
+env_vars: {
+ key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
+ value: "python-docs-samples-tests-py37"
+}
+
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-vision/.kokoro/test-samples.sh"
diff --git a/.kokoro/samples/python3.8/common.cfg b/.kokoro/samples/python3.8/common.cfg
index f6e94bf7..aedab10e 100644
--- a/.kokoro/samples/python3.8/common.cfg
+++ b/.kokoro/samples/python3.8/common.cfg
@@ -13,6 +13,12 @@ env_vars: {
value: "py-3.8"
}
+# Declare build specific Cloud project.
+env_vars: {
+ key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
+ value: "python-docs-samples-tests-py38"
+}
+
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-vision/.kokoro/test-samples.sh"
diff --git a/.kokoro/test-samples.sh b/.kokoro/test-samples.sh
index 40daa396..b6bc8297 100755
--- a/.kokoro/test-samples.sh
+++ b/.kokoro/test-samples.sh
@@ -28,6 +28,12 @@ if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
git checkout $LATEST_RELEASE
fi
+# Exit early if samples directory doesn't exist
+if [ ! -d "./samples" ]; then
+ echo "No tests run. `./samples` not found"
+ exit 0
+fi
+
# Disable buffering, so that the logs stream through.
export PYTHONUNBUFFERED=1
@@ -101,4 +107,4 @@ cd "$ROOT"
# Workaround for Kokoro permissions issue: delete secrets
rm testing/{test-env.sh,client-secrets.json,service-account.json}
-exit "$RTN"
\ No newline at end of file
+exit "$RTN"
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 00000000..6ad83346
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,17 @@
+# See https://pre-commit.com for more information
+# See https://pre-commit.com/hooks.html for more hooks
+repos:
+- repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v3.3.0
+ hooks:
+ - id: trailing-whitespace
+ - id: end-of-file-fixer
+ - id: check-yaml
+- repo: https://github.com/psf/black
+ rev: 19.10b0
+ hooks:
+ - id: black
+- repo: https://gitlab.com/pycqa/flake8
+ rev: 3.8.4
+ hooks:
+ - id: flake8
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index b3d1f602..039f4368 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -1,44 +1,95 @@
-# Contributor Code of Conduct
+# Code of Conduct
-As contributors and maintainers of this project,
-and in the interest of fostering an open and welcoming community,
-we pledge to respect all people who contribute through reporting issues,
-posting feature requests, updating documentation,
-submitting pull requests or patches, and other activities.
+## Our Pledge
-We are committed to making participation in this project
-a harassment-free experience for everyone,
-regardless of level of experience, gender, gender identity and expression,
-sexual orientation, disability, personal appearance,
-body size, race, ethnicity, age, religion, or nationality.
+In the interest of fostering an open and welcoming environment, we as
+contributors and maintainers pledge to making participation in our project and
+our community a harassment-free experience for everyone, regardless of age, body
+size, disability, ethnicity, gender identity and expression, level of
+experience, education, socio-economic status, nationality, personal appearance,
+race, religion, or sexual identity and orientation.
+
+## Our Standards
+
+Examples of behavior that contributes to creating a positive environment
+include:
+
+* Using welcoming and inclusive language
+* Being respectful of differing viewpoints and experiences
+* Gracefully accepting constructive criticism
+* Focusing on what is best for the community
+* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
-* The use of sexualized language or imagery
-* Personal attacks
-* Trolling or insulting/derogatory comments
-* Public or private harassment
-* Publishing other's private information,
-such as physical or electronic
-addresses, without explicit permission
-* Other unethical or unprofessional conduct.
+* The use of sexualized language or imagery and unwelcome sexual attention or
+ advances
+* Trolling, insulting/derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or electronic
+ address, without explicit permission
+* Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Our Responsibilities
+
+Project maintainers are responsible for clarifying the standards of acceptable
+behavior and are expected to take appropriate and fair corrective action in
+response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject
-comments, commits, code, wiki edits, issues, and other contributions
-that are not aligned to this Code of Conduct.
-By adopting this Code of Conduct,
-project maintainers commit themselves to fairly and consistently
-applying these principles to every aspect of managing this project.
-Project maintainers who do not follow or enforce the Code of Conduct
-may be permanently removed from the project team.
-
-This code of conduct applies both within project spaces and in public spaces
-when an individual is representing the project or its community.
-
-Instances of abusive, harassing, or otherwise unacceptable behavior
-may be reported by opening an issue
-or contacting one or more of the project maintainers.
-
-This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0,
-available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
+comments, commits, code, wiki edits, issues, and other contributions that are
+not aligned to this Code of Conduct, or to ban temporarily or permanently any
+contributor for other behaviors that they deem inappropriate, threatening,
+offensive, or harmful.
+
+## Scope
+
+This Code of Conduct applies both within project spaces and in public spaces
+when an individual is representing the project or its community. Examples of
+representing a project or community include using an official project e-mail
+address, posting via an official social media account, or acting as an appointed
+representative at an online or offline event. Representation of a project may be
+further defined and clarified by project maintainers.
+
+This Code of Conduct also applies outside the project spaces when the Project
+Steward has a reasonable belief that an individual's behavior may have a
+negative impact on the project or its community.
+
+## Conflict Resolution
+
+We do not believe that all conflict is bad; healthy debate and disagreement
+often yield positive results. However, it is never okay to be disrespectful or
+to engage in behavior that violates the project’s code of conduct.
+
+If you see someone violating the code of conduct, you are encouraged to address
+the behavior directly with those involved. Many issues can be resolved quickly
+and easily, and this gives people more control over the outcome of their
+dispute. If you are unable to resolve the matter for any reason, or if the
+behavior is threatening or harassing, report it. We are dedicated to providing
+an environment where participants feel welcome and safe.
+
+
+Reports should be directed to *googleapis-stewards@google.com*, the
+Project Steward(s) for *Google Cloud Client Libraries*. It is the Project Steward’s duty to
+receive and address reported violations of the code of conduct. They will then
+work with a committee consisting of representatives from the Open Source
+Programs Office and the Google Open Source Strategy team. If for any reason you
+are uncomfortable reaching out to the Project Steward, please email
+opensource@google.com.
+
+We will investigate every complaint, but you may not receive a direct response.
+We will use our discretion in determining when and how to follow up on reported
+incidents, which may range from not taking action to permanent expulsion from
+the project and project-sponsored spaces. We will notify the accused of the
+report and provide them an opportunity to discuss it before any action is taken.
+The identity of the reporter will be omitted from the details of the report
+supplied to the accused. In potentially harmful situations, such as ongoing
+harassment or threats to anyone's safety, we may take action without notice.
+
+## Attribution
+
+This Code of Conduct is adapted from the Contributor Covenant, version 1.4,
+available at
+https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
\ No newline at end of file
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index 01292ca5..f5c4b5f2 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -111,6 +111,16 @@ Coding Style
should point to the official ``googleapis`` checkout and the
the branch should be the main branch on that remote (``master``).
+- This repository contains configuration for the
+ `pre-commit `__ tool, which automates checking
+ our linters during a commit. If you have it installed on your ``$PATH``,
+ you can enable enforcing those checks via:
+
+.. code-block:: bash
+
+ $ pre-commit install
+ pre-commit installed at .git/hooks/pre-commit
+
Exceptions to PEP8:
- Many unit tests use a helper method, ``_call_fut`` ("FUT" is short for
diff --git a/docs/conf.py b/docs/conf.py
index 44eaa3ec..63c860f9 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -345,10 +345,11 @@
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
- "python": ("http://python.readthedocs.org/en/latest/", None),
- "google-auth": ("https://google-auth.readthedocs.io/en/stable", None),
+ "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,),
- "grpc": ("https://grpc.io/grpc/python/", None),
+ "grpc": ("https://grpc.github.io/grpc/python/", None),
+ "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None),
}
diff --git a/docs/vision_v1/types.rst b/docs/vision_v1/types.rst
index 8c7b8d86..dbbb594c 100644
--- a/docs/vision_v1/types.rst
+++ b/docs/vision_v1/types.rst
@@ -3,3 +3,4 @@ Types for Google Cloud Vision v1 API
.. automodule:: google.cloud.vision_v1.types
:members:
+ :show-inheritance:
diff --git a/docs/vision_v1p2beta1/types.rst b/docs/vision_v1p2beta1/types.rst
index cdc363d1..898a797f 100644
--- a/docs/vision_v1p2beta1/types.rst
+++ b/docs/vision_v1p2beta1/types.rst
@@ -3,3 +3,4 @@ Types for Google Cloud Vision v1p2beta1 API
.. automodule:: google.cloud.vision_v1p2beta1.types
:members:
+ :show-inheritance:
diff --git a/docs/vision_v1p3beta1/types.rst b/docs/vision_v1p3beta1/types.rst
index b5a9253d..8f60a298 100644
--- a/docs/vision_v1p3beta1/types.rst
+++ b/docs/vision_v1p3beta1/types.rst
@@ -3,3 +3,4 @@ Types for Google Cloud Vision v1p3beta1 API
.. automodule:: google.cloud.vision_v1p3beta1.types
:members:
+ :show-inheritance:
diff --git a/docs/vision_v1p4beta1/types.rst b/docs/vision_v1p4beta1/types.rst
index 1ebaa8bb..214f01b1 100644
--- a/docs/vision_v1p4beta1/types.rst
+++ b/docs/vision_v1p4beta1/types.rst
@@ -3,3 +3,4 @@ Types for Google Cloud Vision v1p4beta1 API
.. automodule:: google.cloud.vision_v1p4beta1.types
:members:
+ :show-inheritance:
diff --git a/google/cloud/vision/__init__.py b/google/cloud/vision/__init__.py
index 3058f7f6..d1fa357a 100644
--- a/google/cloud/vision/__init__.py
+++ b/google/cloud/vision/__init__.py
@@ -67,6 +67,7 @@
from google.cloud.vision_v1.types.image_annotator import OutputConfig
from google.cloud.vision_v1.types.image_annotator import Property
from google.cloud.vision_v1.types.image_annotator import SafeSearchAnnotation
+from google.cloud.vision_v1.types.image_annotator import TextDetectionParams
from google.cloud.vision_v1.types.image_annotator import WebDetectionParams
from google.cloud.vision_v1.types.product_search import ProductSearchParams
from google.cloud.vision_v1.types.product_search import ProductSearchResults
@@ -213,6 +214,7 @@
"SafeSearchAnnotation",
"Symbol",
"TextAnnotation",
+ "TextDetectionParams",
"UpdateProductRequest",
"UpdateProductSetRequest",
"Vertex",
diff --git a/google/cloud/vision_v1/__init__.py b/google/cloud/vision_v1/__init__.py
index fb4ce6e2..df7114a8 100644
--- a/google/cloud/vision_v1/__init__.py
+++ b/google/cloud/vision_v1/__init__.py
@@ -62,6 +62,7 @@
from .types.image_annotator import OutputConfig
from .types.image_annotator import Property
from .types.image_annotator import SafeSearchAnnotation
+from .types.image_annotator import TextDetectionParams
from .types.image_annotator import WebDetectionParams
from .types.product_search import ProductSearchParams
from .types.product_search import ProductSearchResults
@@ -190,6 +191,7 @@ class ImageAnnotatorClient(VisionHelpers, IacImageAnnotatorClient):
"SafeSearchAnnotation",
"Symbol",
"TextAnnotation",
+ "TextDetectionParams",
"UpdateProductRequest",
"UpdateProductSetRequest",
"Vertex",
diff --git a/google/cloud/vision_v1/proto/image_annotator.proto b/google/cloud/vision_v1/proto/image_annotator.proto
index e75ca766..7f13e35c 100644
--- a/google/cloud/vision_v1/proto/image_annotator.proto
+++ b/google/cloud/vision_v1/proto/image_annotator.proto
@@ -664,6 +664,16 @@ message WebDetectionParams {
bool include_geo_results = 2;
}
+// Parameters for text detections. This is used to control TEXT_DETECTION and
+// DOCUMENT_TEXT_DETECTION features.
+message TextDetectionParams {
+
+ // By default, Cloud Vision API only includes confidence score for
+ // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence
+ // score for TEXT_DETECTION as well.
+ bool enable_text_detection_confidence_score = 9;
+}
+
// Image context and/or feature-specific parameters.
message ImageContext {
// Not used.
@@ -687,6 +697,9 @@ message ImageContext {
// Parameters for web detection.
WebDetectionParams web_detection_params = 6;
+
+ // Parameters for text detection and document text detection.
+ TextDetectionParams text_detection_params = 12;
}
// Request for performing Google Cloud Vision API tasks over a user-provided
diff --git a/google/cloud/vision_v1/services/image_annotator/async_client.py b/google/cloud/vision_v1/services/image_annotator/async_client.py
index 32df878c..f441e263 100644
--- a/google/cloud/vision_v1/services/image_annotator/async_client.py
+++ b/google/cloud/vision_v1/services/image_annotator/async_client.py
@@ -49,9 +49,52 @@ class ImageAnnotatorAsyncClient:
DEFAULT_ENDPOINT = ImageAnnotatorClient.DEFAULT_ENDPOINT
DEFAULT_MTLS_ENDPOINT = ImageAnnotatorClient.DEFAULT_MTLS_ENDPOINT
+ product_path = staticmethod(ImageAnnotatorClient.product_path)
+ parse_product_path = staticmethod(ImageAnnotatorClient.parse_product_path)
+ product_set_path = staticmethod(ImageAnnotatorClient.product_set_path)
+ parse_product_set_path = staticmethod(ImageAnnotatorClient.parse_product_set_path)
+
+ common_billing_account_path = staticmethod(
+ ImageAnnotatorClient.common_billing_account_path
+ )
+ parse_common_billing_account_path = staticmethod(
+ ImageAnnotatorClient.parse_common_billing_account_path
+ )
+
+ common_folder_path = staticmethod(ImageAnnotatorClient.common_folder_path)
+ parse_common_folder_path = staticmethod(
+ ImageAnnotatorClient.parse_common_folder_path
+ )
+
+ common_organization_path = staticmethod(
+ ImageAnnotatorClient.common_organization_path
+ )
+ parse_common_organization_path = staticmethod(
+ ImageAnnotatorClient.parse_common_organization_path
+ )
+
+ common_project_path = staticmethod(ImageAnnotatorClient.common_project_path)
+ parse_common_project_path = staticmethod(
+ ImageAnnotatorClient.parse_common_project_path
+ )
+
+ common_location_path = staticmethod(ImageAnnotatorClient.common_location_path)
+ parse_common_location_path = staticmethod(
+ ImageAnnotatorClient.parse_common_location_path
+ )
+
from_service_account_file = ImageAnnotatorClient.from_service_account_file
from_service_account_json = from_service_account_file
+ @property
+ def transport(self) -> ImageAnnotatorTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ ImageAnnotatorTransport: The transport used by the client instance.
+ """
+ return self._client.transport
+
get_transport_class = functools.partial(
type(ImageAnnotatorClient).get_transport_class, type(ImageAnnotatorClient)
)
@@ -142,7 +185,8 @@ async def batch_annotate_images(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([requests]):
+ has_flattened_params = any([requests])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -153,8 +197,8 @@ async def batch_annotate_images(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
@@ -222,7 +266,8 @@ async def batch_annotate_files(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([requests]):
+ has_flattened_params = any([requests])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -233,8 +278,8 @@ async def batch_annotate_files(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
@@ -316,7 +361,8 @@ async def async_batch_annotate_images(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([requests, output_config]):
+ has_flattened_params = any([requests, output_config])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -327,11 +373,12 @@ async def async_batch_annotate_images(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
if output_config is not None:
request.output_config = output_config
+ if requests:
+ request.requests.extend(requests)
+
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
@@ -408,7 +455,8 @@ async def async_batch_annotate_files(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([requests]):
+ has_flattened_params = any([requests])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -419,8 +467,8 @@ async def async_batch_annotate_files(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
diff --git a/google/cloud/vision_v1/services/image_annotator/client.py b/google/cloud/vision_v1/services/image_annotator/client.py
index f3bbe4dc..cd963a34 100644
--- a/google/cloud/vision_v1/services/image_annotator/client.py
+++ b/google/cloud/vision_v1/services/image_annotator/client.py
@@ -135,6 +135,106 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
from_service_account_json = from_service_account_file
+ @property
+ def transport(self) -> ImageAnnotatorTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ ImageAnnotatorTransport: The transport used by the client instance.
+ """
+ return self._transport
+
+ @staticmethod
+ def product_path(project: str, location: str, product: str,) -> str:
+ """Return a fully-qualified product string."""
+ return "projects/{project}/locations/{location}/products/{product}".format(
+ project=project, location=location, product=product,
+ )
+
+ @staticmethod
+ def parse_product_path(path: str) -> Dict[str, str]:
+ """Parse a product path into its component segments."""
+ m = re.match(
+ r"^projects/(?P.+?)/locations/(?P.+?)/products/(?P.+?)$",
+ path,
+ )
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def product_set_path(project: str, location: str, product_set: str,) -> str:
+ """Return a fully-qualified product_set string."""
+ return "projects/{project}/locations/{location}/productSets/{product_set}".format(
+ project=project, location=location, product_set=product_set,
+ )
+
+ @staticmethod
+ def parse_product_set_path(path: str) -> Dict[str, str]:
+ """Parse a product_set path into its component segments."""
+ m = re.match(
+ r"^projects/(?P.+?)/locations/(?P.+?)/productSets/(?P.+?)$",
+ path,
+ )
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_billing_account_path(billing_account: str,) -> str:
+ """Return a fully-qualified billing_account string."""
+ return "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+
+ @staticmethod
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
+ """Parse a billing_account path into its component segments."""
+ m = re.match(r"^billingAccounts/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_folder_path(folder: str,) -> str:
+ """Return a fully-qualified folder string."""
+ return "folders/{folder}".format(folder=folder,)
+
+ @staticmethod
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
+ """Parse a folder path into its component segments."""
+ m = re.match(r"^folders/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_organization_path(organization: str,) -> str:
+ """Return a fully-qualified organization string."""
+ return "organizations/{organization}".format(organization=organization,)
+
+ @staticmethod
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
+ """Parse a organization path into its component segments."""
+ m = re.match(r"^organizations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_project_path(project: str,) -> str:
+ """Return a fully-qualified project string."""
+ return "projects/{project}".format(project=project,)
+
+ @staticmethod
+ def parse_common_project_path(path: str) -> Dict[str, str]:
+ """Parse a project path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_location_path(project: str, location: str,) -> str:
+ """Return a fully-qualified location string."""
+ return "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+
+ @staticmethod
+ def parse_common_location_path(path: str) -> Dict[str, str]:
+ """Parse a location path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
def __init__(
self,
*,
@@ -170,10 +270,10 @@ def __init__(
not provided, the default SSL client certificate will be used if
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
set, no client certificate will be used.
- client_info (google.api_core.gapic_v1.client_info.ClientInfo):
- The client info used to send a user-agent string along with
- API requests. If ``None``, then default info will be used.
- Generally, you only need to set this if you're developing
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
your own client library.
Raises:
@@ -310,8 +410,8 @@ def batch_annotate_images(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
@@ -387,8 +487,8 @@ def batch_annotate_files(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
@@ -478,11 +578,12 @@ def async_batch_annotate_images(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
if output_config is not None:
request.output_config = output_config
+ if requests:
+ request.requests.extend(requests)
+
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[
@@ -569,8 +670,8 @@ def async_batch_annotate_files(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
diff --git a/google/cloud/vision_v1/services/image_annotator/transports/__init__.py b/google/cloud/vision_v1/services/image_annotator/transports/__init__.py
index f2315e0d..e2a0c3ea 100644
--- a/google/cloud/vision_v1/services/image_annotator/transports/__init__.py
+++ b/google/cloud/vision_v1/services/image_annotator/transports/__init__.py
@@ -28,7 +28,6 @@
_transport_registry["grpc"] = ImageAnnotatorGrpcTransport
_transport_registry["grpc_asyncio"] = ImageAnnotatorGrpcAsyncIOTransport
-
__all__ = (
"ImageAnnotatorTransport",
"ImageAnnotatorGrpcTransport",
diff --git a/google/cloud/vision_v1/services/image_annotator/transports/grpc.py b/google/cloud/vision_v1/services/image_annotator/transports/grpc.py
index b939263b..36536880 100644
--- a/google/cloud/vision_v1/services/image_annotator/transports/grpc.py
+++ b/google/cloud/vision_v1/services/image_annotator/transports/grpc.py
@@ -94,10 +94,10 @@ def __init__(
for grpc channel. It is ignored if ``channel`` is provided.
quota_project_id (Optional[str]): An optional project to use for billing
and quota.
- client_info (google.api_core.gapic_v1.client_info.ClientInfo):
- The client info used to send a user-agent string along with
- API requests. If ``None``, then default info will be used.
- Generally, you only need to set this if you're developing
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
your own client library.
Raises:
@@ -106,6 +106,8 @@ def __init__(
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
and ``credentials_file`` are passed.
"""
+ self._ssl_channel_credentials = ssl_channel_credentials
+
if channel:
# Sanity check: Ensure that channel and credentials are not both
# provided.
@@ -113,6 +115,7 @@ def __init__(
# If a channel was explicitly provided, set it.
self._grpc_channel = channel
+ self._ssl_channel_credentials = None
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
@@ -148,7 +151,12 @@ def __init__(
ssl_credentials=ssl_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
+ self._ssl_channel_credentials = ssl_credentials
else:
host = host if ":" in host else host + ":443"
@@ -165,9 +173,14 @@ def __init__(
ssl_credentials=ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
self._stubs = {} # type: Dict[str, Callable]
+ self._operations_client = None
# Run the base constructor.
super().__init__(
@@ -191,7 +204,7 @@ def create_channel(
) -> grpc.Channel:
"""Create and return a gRPC channel object.
Args:
- address (Optionsl[str]): The host for the channel to use.
+ address (Optional[str]): The host for the channel to use.
credentials (Optional[~.Credentials]): The
authorization credentials to attach to requests. These
credentials identify this application to the service. If
@@ -226,12 +239,8 @@ def create_channel(
@property
def grpc_channel(self) -> grpc.Channel:
- """Create the channel designed to connect to this service.
-
- This property caches on the instance; repeated calls return
- the same channel.
+ """Return the channel designed to connect to this service.
"""
- # Return the channel from cache.
return self._grpc_channel
@property
@@ -242,13 +251,11 @@ def operations_client(self) -> operations_v1.OperationsClient:
client.
"""
# Sanity check: Only create a new client if we do not already have one.
- if "operations_client" not in self.__dict__:
- self.__dict__["operations_client"] = operations_v1.OperationsClient(
- self.grpc_channel
- )
+ if self._operations_client is None:
+ self._operations_client = operations_v1.OperationsClient(self.grpc_channel)
# Return the client from cache.
- return self.__dict__["operations_client"]
+ return self._operations_client
@property
def batch_annotate_images(
diff --git a/google/cloud/vision_v1/services/image_annotator/transports/grpc_asyncio.py b/google/cloud/vision_v1/services/image_annotator/transports/grpc_asyncio.py
index c36b70fd..d95951d9 100644
--- a/google/cloud/vision_v1/services/image_annotator/transports/grpc_asyncio.py
+++ b/google/cloud/vision_v1/services/image_annotator/transports/grpc_asyncio.py
@@ -151,6 +151,8 @@ def __init__(
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
and ``credentials_file`` are passed.
"""
+ self._ssl_channel_credentials = ssl_channel_credentials
+
if channel:
# Sanity check: Ensure that channel and credentials are not both
# provided.
@@ -158,6 +160,7 @@ def __init__(
# If a channel was explicitly provided, set it.
self._grpc_channel = channel
+ self._ssl_channel_credentials = None
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
@@ -193,7 +196,12 @@ def __init__(
ssl_credentials=ssl_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
+ self._ssl_channel_credentials = ssl_credentials
else:
host = host if ":" in host else host + ":443"
@@ -210,6 +218,10 @@ def __init__(
ssl_credentials=ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
# Run the base constructor.
@@ -223,6 +235,7 @@ def __init__(
)
self._stubs = {}
+ self._operations_client = None
@property
def grpc_channel(self) -> aio.Channel:
@@ -242,13 +255,13 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient:
client.
"""
# Sanity check: Only create a new client if we do not already have one.
- if "operations_client" not in self.__dict__:
- self.__dict__["operations_client"] = operations_v1.OperationsAsyncClient(
+ if self._operations_client is None:
+ self._operations_client = operations_v1.OperationsAsyncClient(
self.grpc_channel
)
# Return the client from cache.
- return self.__dict__["operations_client"]
+ return self._operations_client
@property
def batch_annotate_images(
diff --git a/google/cloud/vision_v1/services/product_search/async_client.py b/google/cloud/vision_v1/services/product_search/async_client.py
index 0afae177..11b5e016 100644
--- a/google/cloud/vision_v1/services/product_search/async_client.py
+++ b/google/cloud/vision_v1/services/product_search/async_client.py
@@ -78,9 +78,47 @@ class ProductSearchAsyncClient:
ProductSearchClient.parse_reference_image_path
)
+ common_billing_account_path = staticmethod(
+ ProductSearchClient.common_billing_account_path
+ )
+ parse_common_billing_account_path = staticmethod(
+ ProductSearchClient.parse_common_billing_account_path
+ )
+
+ common_folder_path = staticmethod(ProductSearchClient.common_folder_path)
+ parse_common_folder_path = staticmethod(
+ ProductSearchClient.parse_common_folder_path
+ )
+
+ common_organization_path = staticmethod(
+ ProductSearchClient.common_organization_path
+ )
+ parse_common_organization_path = staticmethod(
+ ProductSearchClient.parse_common_organization_path
+ )
+
+ common_project_path = staticmethod(ProductSearchClient.common_project_path)
+ parse_common_project_path = staticmethod(
+ ProductSearchClient.parse_common_project_path
+ )
+
+ common_location_path = staticmethod(ProductSearchClient.common_location_path)
+ parse_common_location_path = staticmethod(
+ ProductSearchClient.parse_common_location_path
+ )
+
from_service_account_file = ProductSearchClient.from_service_account_file
from_service_account_json = from_service_account_file
+ @property
+ def transport(self) -> ProductSearchTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ ProductSearchTransport: The transport used by the client instance.
+ """
+ return self._client.transport
+
get_transport_class = functools.partial(
type(ProductSearchClient).get_transport_class, type(ProductSearchClient)
)
@@ -196,7 +234,8 @@ async def create_product_set(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent, product_set, product_set_id]):
+ has_flattened_params = any([parent, product_set, product_set_id])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -286,7 +325,8 @@ async def list_product_sets(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent]):
+ has_flattened_params = any([parent])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -380,7 +420,8 @@ async def get_product_set(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name]):
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -479,7 +520,8 @@ async def update_product_set(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([product_set, update_mask]):
+ has_flattened_params = any([product_set, update_mask])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -561,7 +603,8 @@ async def delete_product_set(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name]):
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -664,7 +707,8 @@ async def create_product(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent, product, product_id]):
+ has_flattened_params = any([parent, product, product_id])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -754,7 +798,8 @@ async def list_products(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent]):
+ has_flattened_params = any([parent])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -843,7 +888,8 @@ async def get_product(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name]):
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -946,7 +992,8 @@ async def update_product(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([product, update_mask]):
+ has_flattened_params = any([product, update_mask])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1030,7 +1077,8 @@ async def delete_product(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name]):
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1150,7 +1198,8 @@ async def create_reference_image(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent, reference_image, reference_image_id]):
+ has_flattened_params = any([parent, reference_image, reference_image_id])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1235,7 +1284,8 @@ async def delete_reference_image(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name]):
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1324,7 +1374,8 @@ async def list_reference_images(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent]):
+ has_flattened_params = any([parent])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1417,7 +1468,8 @@ async def get_reference_image(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name]):
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1511,7 +1563,8 @@ async def add_product_to_product_set(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name, product]):
+ has_flattened_params = any([name, product])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1598,7 +1651,8 @@ async def remove_product_from_product_set(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name, product]):
+ has_flattened_params = any([name, product])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1691,7 +1745,8 @@ async def list_products_in_product_set(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name]):
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1805,7 +1860,8 @@ async def import_product_sets(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent, input_config]):
+ has_flattened_params = any([parent, input_config])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1935,7 +1991,8 @@ async def purge_products(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent]):
+ has_flattened_params = any([parent])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
diff --git a/google/cloud/vision_v1/services/product_search/client.py b/google/cloud/vision_v1/services/product_search/client.py
index 640f4e46..b79cb3da 100644
--- a/google/cloud/vision_v1/services/product_search/client.py
+++ b/google/cloud/vision_v1/services/product_search/client.py
@@ -153,6 +153,15 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
from_service_account_json = from_service_account_file
+ @property
+ def transport(self) -> ProductSearchTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ ProductSearchTransport: The transport used by the client instance.
+ """
+ return self._transport
+
@staticmethod
def product_path(project: str, location: str, product: str,) -> str:
"""Return a fully-qualified product string."""
@@ -206,6 +215,65 @@ def parse_reference_image_path(path: str) -> Dict[str, str]:
)
return m.groupdict() if m else {}
+ @staticmethod
+ def common_billing_account_path(billing_account: str,) -> str:
+ """Return a fully-qualified billing_account string."""
+ return "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+
+ @staticmethod
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
+ """Parse a billing_account path into its component segments."""
+ m = re.match(r"^billingAccounts/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_folder_path(folder: str,) -> str:
+ """Return a fully-qualified folder string."""
+ return "folders/{folder}".format(folder=folder,)
+
+ @staticmethod
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
+ """Parse a folder path into its component segments."""
+ m = re.match(r"^folders/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_organization_path(organization: str,) -> str:
+ """Return a fully-qualified organization string."""
+ return "organizations/{organization}".format(organization=organization,)
+
+ @staticmethod
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
+ """Parse a organization path into its component segments."""
+ m = re.match(r"^organizations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_project_path(project: str,) -> str:
+ """Return a fully-qualified project string."""
+ return "projects/{project}".format(project=project,)
+
+ @staticmethod
+ def parse_common_project_path(path: str) -> Dict[str, str]:
+ """Parse a project path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_location_path(project: str, location: str,) -> str:
+ """Return a fully-qualified location string."""
+ return "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+
+ @staticmethod
+ def parse_common_location_path(path: str) -> Dict[str, str]:
+ """Parse a location path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
def __init__(
self,
*,
@@ -241,10 +309,10 @@ def __init__(
not provided, the default SSL client certificate will be used if
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
set, no client certificate will be used.
- client_info (google.api_core.gapic_v1.client_info.ClientInfo):
- The client info used to send a user-agent string along with
- API requests. If ``None``, then default info will be used.
- Generally, you only need to set this if you're developing
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
your own client library.
Raises:
diff --git a/google/cloud/vision_v1/services/product_search/transports/__init__.py b/google/cloud/vision_v1/services/product_search/transports/__init__.py
index 2d57de48..8295a6de 100644
--- a/google/cloud/vision_v1/services/product_search/transports/__init__.py
+++ b/google/cloud/vision_v1/services/product_search/transports/__init__.py
@@ -28,7 +28,6 @@
_transport_registry["grpc"] = ProductSearchGrpcTransport
_transport_registry["grpc_asyncio"] = ProductSearchGrpcAsyncIOTransport
-
__all__ = (
"ProductSearchTransport",
"ProductSearchGrpcTransport",
diff --git a/google/cloud/vision_v1/services/product_search/transports/grpc.py b/google/cloud/vision_v1/services/product_search/transports/grpc.py
index 9798f2cd..76d646b7 100644
--- a/google/cloud/vision_v1/services/product_search/transports/grpc.py
+++ b/google/cloud/vision_v1/services/product_search/transports/grpc.py
@@ -109,10 +109,10 @@ def __init__(
for grpc channel. It is ignored if ``channel`` is provided.
quota_project_id (Optional[str]): An optional project to use for billing
and quota.
- client_info (google.api_core.gapic_v1.client_info.ClientInfo):
- The client info used to send a user-agent string along with
- API requests. If ``None``, then default info will be used.
- Generally, you only need to set this if you're developing
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
your own client library.
Raises:
@@ -121,6 +121,8 @@ def __init__(
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
and ``credentials_file`` are passed.
"""
+ self._ssl_channel_credentials = ssl_channel_credentials
+
if channel:
# Sanity check: Ensure that channel and credentials are not both
# provided.
@@ -128,6 +130,7 @@ def __init__(
# If a channel was explicitly provided, set it.
self._grpc_channel = channel
+ self._ssl_channel_credentials = None
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
@@ -163,7 +166,12 @@ def __init__(
ssl_credentials=ssl_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
+ self._ssl_channel_credentials = ssl_credentials
else:
host = host if ":" in host else host + ":443"
@@ -180,9 +188,14 @@ def __init__(
ssl_credentials=ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
self._stubs = {} # type: Dict[str, Callable]
+ self._operations_client = None
# Run the base constructor.
super().__init__(
@@ -206,7 +219,7 @@ def create_channel(
) -> grpc.Channel:
"""Create and return a gRPC channel object.
Args:
- address (Optionsl[str]): The host for the channel to use.
+ address (Optional[str]): The host for the channel to use.
credentials (Optional[~.Credentials]): The
authorization credentials to attach to requests. These
credentials identify this application to the service. If
@@ -241,12 +254,8 @@ def create_channel(
@property
def grpc_channel(self) -> grpc.Channel:
- """Create the channel designed to connect to this service.
-
- This property caches on the instance; repeated calls return
- the same channel.
+ """Return the channel designed to connect to this service.
"""
- # Return the channel from cache.
return self._grpc_channel
@property
@@ -257,13 +266,11 @@ def operations_client(self) -> operations_v1.OperationsClient:
client.
"""
# Sanity check: Only create a new client if we do not already have one.
- if "operations_client" not in self.__dict__:
- self.__dict__["operations_client"] = operations_v1.OperationsClient(
- self.grpc_channel
- )
+ if self._operations_client is None:
+ self._operations_client = operations_v1.OperationsClient(self.grpc_channel)
# Return the client from cache.
- return self.__dict__["operations_client"]
+ return self._operations_client
@property
def create_product_set(
diff --git a/google/cloud/vision_v1/services/product_search/transports/grpc_asyncio.py b/google/cloud/vision_v1/services/product_search/transports/grpc_asyncio.py
index 21143ec9..76a9a2cf 100644
--- a/google/cloud/vision_v1/services/product_search/transports/grpc_asyncio.py
+++ b/google/cloud/vision_v1/services/product_search/transports/grpc_asyncio.py
@@ -166,6 +166,8 @@ def __init__(
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
and ``credentials_file`` are passed.
"""
+ self._ssl_channel_credentials = ssl_channel_credentials
+
if channel:
# Sanity check: Ensure that channel and credentials are not both
# provided.
@@ -173,6 +175,7 @@ def __init__(
# If a channel was explicitly provided, set it.
self._grpc_channel = channel
+ self._ssl_channel_credentials = None
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
@@ -208,7 +211,12 @@ def __init__(
ssl_credentials=ssl_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
+ self._ssl_channel_credentials = ssl_credentials
else:
host = host if ":" in host else host + ":443"
@@ -225,6 +233,10 @@ def __init__(
ssl_credentials=ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
# Run the base constructor.
@@ -238,6 +250,7 @@ def __init__(
)
self._stubs = {}
+ self._operations_client = None
@property
def grpc_channel(self) -> aio.Channel:
@@ -257,13 +270,13 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient:
client.
"""
# Sanity check: Only create a new client if we do not already have one.
- if "operations_client" not in self.__dict__:
- self.__dict__["operations_client"] = operations_v1.OperationsAsyncClient(
+ if self._operations_client is None:
+ self._operations_client = operations_v1.OperationsAsyncClient(
self.grpc_channel
)
# Return the client from cache.
- return self.__dict__["operations_client"]
+ return self._operations_client
@property
def create_product_set(
diff --git a/google/cloud/vision_v1/types/__init__.py b/google/cloud/vision_v1/types/__init__.py
index 98992ae9..4e38e72a 100644
--- a/google/cloud/vision_v1/types/__init__.py
+++ b/google/cloud/vision_v1/types/__init__.py
@@ -85,6 +85,7 @@
CropHintsAnnotation,
CropHintsParams,
WebDetectionParams,
+ TextDetectionParams,
ImageContext,
AnnotateImageRequest,
ImageAnnotationContext,
@@ -106,9 +107,9 @@
GcsSource,
GcsDestination,
OperationMetadata,
+ Likelihood,
)
-
__all__ = (
"Vertex",
"NormalizedVertex",
@@ -171,6 +172,7 @@
"CropHintsAnnotation",
"CropHintsParams",
"WebDetectionParams",
+ "TextDetectionParams",
"ImageContext",
"AnnotateImageRequest",
"ImageAnnotationContext",
@@ -192,4 +194,5 @@
"GcsSource",
"GcsDestination",
"OperationMetadata",
+ "Likelihood",
)
diff --git a/google/cloud/vision_v1/types/geometry.py b/google/cloud/vision_v1/types/geometry.py
index e37f9e07..be6f5602 100644
--- a/google/cloud/vision_v1/types/geometry.py
+++ b/google/cloud/vision_v1/types/geometry.py
@@ -68,10 +68,10 @@ class BoundingPoly(proto.Message):
The bounding polygon normalized vertices.
"""
- vertices = proto.RepeatedField(proto.MESSAGE, number=1, message=Vertex,)
+ vertices = proto.RepeatedField(proto.MESSAGE, number=1, message="Vertex",)
normalized_vertices = proto.RepeatedField(
- proto.MESSAGE, number=2, message=NormalizedVertex,
+ proto.MESSAGE, number=2, message="NormalizedVertex",
)
diff --git a/google/cloud/vision_v1/types/image_annotator.py b/google/cloud/vision_v1/types/image_annotator.py
index c7ae671d..462baf72 100644
--- a/google/cloud/vision_v1/types/image_annotator.py
+++ b/google/cloud/vision_v1/types/image_annotator.py
@@ -49,6 +49,7 @@
"CropHintsAnnotation",
"CropHintsParams",
"WebDetectionParams",
+ "TextDetectionParams",
"ImageContext",
"AnnotateImageRequest",
"ImageAnnotationContext",
@@ -184,7 +185,7 @@ class Image(proto.Message):
content = proto.Field(proto.BYTES, number=1)
- source = proto.Field(proto.MESSAGE, number=2, message=ImageSource,)
+ source = proto.Field(proto.MESSAGE, number=2, message="ImageSource",)
class FaceAnnotation(proto.Message):
@@ -421,9 +422,9 @@ class EntityAnnotation(proto.Message):
bounding_poly = proto.Field(proto.MESSAGE, number=7, message=geometry.BoundingPoly,)
- locations = proto.RepeatedField(proto.MESSAGE, number=8, message=LocationInfo,)
+ locations = proto.RepeatedField(proto.MESSAGE, number=8, message="LocationInfo",)
- properties = proto.RepeatedField(proto.MESSAGE, number=9, message=Property,)
+ properties = proto.RepeatedField(proto.MESSAGE, number=9, message="Property",)
class LocalizedObjectAnnotation(proto.Message):
@@ -572,7 +573,7 @@ class DominantColorsAnnotation(proto.Message):
fraction.
"""
- colors = proto.RepeatedField(proto.MESSAGE, number=1, message=ColorInfo,)
+ colors = proto.RepeatedField(proto.MESSAGE, number=1, message="ColorInfo",)
class ImageProperties(proto.Message):
@@ -585,7 +586,7 @@ class ImageProperties(proto.Message):
"""
dominant_colors = proto.Field(
- proto.MESSAGE, number=1, message=DominantColorsAnnotation,
+ proto.MESSAGE, number=1, message="DominantColorsAnnotation",
)
@@ -621,7 +622,7 @@ class CropHintsAnnotation(proto.Message):
Crop hint results.
"""
- crop_hints = proto.RepeatedField(proto.MESSAGE, number=1, message=CropHint,)
+ crop_hints = proto.RepeatedField(proto.MESSAGE, number=1, message="CropHint",)
class CropHintsParams(proto.Message):
@@ -654,6 +655,20 @@ class WebDetectionParams(proto.Message):
include_geo_results = proto.Field(proto.BOOL, number=2)
+class TextDetectionParams(proto.Message):
+ r"""Parameters for text detections. This is used to control
+ TEXT_DETECTION and DOCUMENT_TEXT_DETECTION features.
+
+ Attributes:
+ enable_text_detection_confidence_score (bool):
+ By default, Cloud Vision API only includes confidence score
+ for DOCUMENT_TEXT_DETECTION result. Set the flag to true to
+ include confidence score for TEXT_DETECTION as well.
+ """
+
+ enable_text_detection_confidence_score = proto.Field(proto.BOOL, number=9)
+
+
class ImageContext(proto.Message):
r"""Image context and/or feature-specific parameters.
@@ -677,20 +692,27 @@ class ImageContext(proto.Message):
Parameters for product search.
web_detection_params (~.image_annotator.WebDetectionParams):
Parameters for web detection.
+ text_detection_params (~.image_annotator.TextDetectionParams):
+ Parameters for text detection and document
+ text detection.
"""
- lat_long_rect = proto.Field(proto.MESSAGE, number=1, message=LatLongRect,)
+ lat_long_rect = proto.Field(proto.MESSAGE, number=1, message="LatLongRect",)
language_hints = proto.RepeatedField(proto.STRING, number=2)
- crop_hints_params = proto.Field(proto.MESSAGE, number=4, message=CropHintsParams,)
+ crop_hints_params = proto.Field(proto.MESSAGE, number=4, message="CropHintsParams",)
product_search_params = proto.Field(
proto.MESSAGE, number=5, message=product_search.ProductSearchParams,
)
web_detection_params = proto.Field(
- proto.MESSAGE, number=6, message=WebDetectionParams,
+ proto.MESSAGE, number=6, message="WebDetectionParams",
+ )
+
+ text_detection_params = proto.Field(
+ proto.MESSAGE, number=12, message="TextDetectionParams",
)
@@ -709,11 +731,11 @@ class AnnotateImageRequest(proto.Message):
image.
"""
- image = proto.Field(proto.MESSAGE, number=1, message=Image,)
+ image = proto.Field(proto.MESSAGE, number=1, message="Image",)
- features = proto.RepeatedField(proto.MESSAGE, number=2, message=Feature,)
+ features = proto.RepeatedField(proto.MESSAGE, number=2, message="Feature",)
- image_context = proto.Field(proto.MESSAGE, number=3, message=ImageContext,)
+ image_context = proto.Field(proto.MESSAGE, number=3, message="ImageContext",)
class ImageAnnotationContext(proto.Message):
@@ -788,27 +810,27 @@ class AnnotateImageResponse(proto.Message):
"""
face_annotations = proto.RepeatedField(
- proto.MESSAGE, number=1, message=FaceAnnotation,
+ proto.MESSAGE, number=1, message="FaceAnnotation",
)
landmark_annotations = proto.RepeatedField(
- proto.MESSAGE, number=2, message=EntityAnnotation,
+ proto.MESSAGE, number=2, message="EntityAnnotation",
)
logo_annotations = proto.RepeatedField(
- proto.MESSAGE, number=3, message=EntityAnnotation,
+ proto.MESSAGE, number=3, message="EntityAnnotation",
)
label_annotations = proto.RepeatedField(
- proto.MESSAGE, number=4, message=EntityAnnotation,
+ proto.MESSAGE, number=4, message="EntityAnnotation",
)
localized_object_annotations = proto.RepeatedField(
- proto.MESSAGE, number=22, message=LocalizedObjectAnnotation,
+ proto.MESSAGE, number=22, message="LocalizedObjectAnnotation",
)
text_annotations = proto.RepeatedField(
- proto.MESSAGE, number=5, message=EntityAnnotation,
+ proto.MESSAGE, number=5, message="EntityAnnotation",
)
full_text_annotation = proto.Field(
@@ -816,15 +838,15 @@ class AnnotateImageResponse(proto.Message):
)
safe_search_annotation = proto.Field(
- proto.MESSAGE, number=6, message=SafeSearchAnnotation,
+ proto.MESSAGE, number=6, message="SafeSearchAnnotation",
)
image_properties_annotation = proto.Field(
- proto.MESSAGE, number=8, message=ImageProperties,
+ proto.MESSAGE, number=8, message="ImageProperties",
)
crop_hints_annotation = proto.Field(
- proto.MESSAGE, number=11, message=CropHintsAnnotation,
+ proto.MESSAGE, number=11, message="CropHintsAnnotation",
)
web_detection = proto.Field(
@@ -837,7 +859,7 @@ class AnnotateImageResponse(proto.Message):
error = proto.Field(proto.MESSAGE, number=9, message=status.Status,)
- context = proto.Field(proto.MESSAGE, number=21, message=ImageAnnotationContext,)
+ context = proto.Field(proto.MESSAGE, number=21, message="ImageAnnotationContext",)
class BatchAnnotateImagesRequest(proto.Message):
@@ -864,7 +886,7 @@ class BatchAnnotateImagesRequest(proto.Message):
"""
requests = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AnnotateImageRequest,
+ proto.MESSAGE, number=1, message="AnnotateImageRequest",
)
parent = proto.Field(proto.STRING, number=4)
@@ -880,7 +902,7 @@ class BatchAnnotateImagesResponse(proto.Message):
"""
responses = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AnnotateImageResponse,
+ proto.MESSAGE, number=1, message="AnnotateImageResponse",
)
@@ -916,9 +938,9 @@ class AnnotateFileRequest(proto.Message):
input_config = proto.Field(proto.MESSAGE, number=1, message="InputConfig",)
- features = proto.RepeatedField(proto.MESSAGE, number=2, message=Feature,)
+ features = proto.RepeatedField(proto.MESSAGE, number=2, message="Feature",)
- image_context = proto.Field(proto.MESSAGE, number=3, message=ImageContext,)
+ image_context = proto.Field(proto.MESSAGE, number=3, message="ImageContext",)
pages = proto.RepeatedField(proto.INT32, number=4)
@@ -946,7 +968,7 @@ class AnnotateFileResponse(proto.Message):
input_config = proto.Field(proto.MESSAGE, number=1, message="InputConfig",)
responses = proto.RepeatedField(
- proto.MESSAGE, number=2, message=AnnotateImageResponse,
+ proto.MESSAGE, number=2, message="AnnotateImageResponse",
)
total_pages = proto.Field(proto.INT32, number=3)
@@ -980,7 +1002,7 @@ class BatchAnnotateFilesRequest(proto.Message):
"""
requests = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AnnotateFileRequest,
+ proto.MESSAGE, number=1, message="AnnotateFileRequest",
)
parent = proto.Field(proto.STRING, number=3)
@@ -998,7 +1020,7 @@ class BatchAnnotateFilesResponse(proto.Message):
"""
responses = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AnnotateFileResponse,
+ proto.MESSAGE, number=1, message="AnnotateFileResponse",
)
@@ -1020,9 +1042,9 @@ class AsyncAnnotateFileRequest(proto.Message):
input_config = proto.Field(proto.MESSAGE, number=1, message="InputConfig",)
- features = proto.RepeatedField(proto.MESSAGE, number=2, message=Feature,)
+ features = proto.RepeatedField(proto.MESSAGE, number=2, message="Feature",)
- image_context = proto.Field(proto.MESSAGE, number=3, message=ImageContext,)
+ image_context = proto.Field(proto.MESSAGE, number=3, message="ImageContext",)
output_config = proto.Field(proto.MESSAGE, number=4, message="OutputConfig",)
@@ -1065,7 +1087,7 @@ class AsyncBatchAnnotateImagesRequest(proto.Message):
"""
requests = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AnnotateImageRequest,
+ proto.MESSAGE, number=1, message="AnnotateImageRequest",
)
output_config = proto.Field(proto.MESSAGE, number=2, message="OutputConfig",)
@@ -1109,7 +1131,7 @@ class AsyncBatchAnnotateFilesRequest(proto.Message):
"""
requests = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AsyncAnnotateFileRequest,
+ proto.MESSAGE, number=1, message="AsyncAnnotateFileRequest",
)
parent = proto.Field(proto.STRING, number=4)
@@ -1126,7 +1148,7 @@ class AsyncBatchAnnotateFilesResponse(proto.Message):
"""
responses = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AsyncAnnotateFileResponse,
+ proto.MESSAGE, number=1, message="AsyncAnnotateFileResponse",
)
diff --git a/google/cloud/vision_v1/types/product_search_service.py b/google/cloud/vision_v1/types/product_search_service.py
index 0c88a647..f06e2eee 100644
--- a/google/cloud/vision_v1/types/product_search_service.py
+++ b/google/cloud/vision_v1/types/product_search_service.py
@@ -238,7 +238,7 @@ class CreateProductRequest(proto.Message):
parent = proto.Field(proto.STRING, number=1)
- product = proto.Field(proto.MESSAGE, number=2, message=Product,)
+ product = proto.Field(proto.MESSAGE, number=2, message="Product",)
product_id = proto.Field(proto.STRING, number=3)
@@ -283,7 +283,7 @@ class ListProductsResponse(proto.Message):
def raw_page(self):
return self
- products = proto.RepeatedField(proto.MESSAGE, number=1, message=Product,)
+ products = proto.RepeatedField(proto.MESSAGE, number=1, message="Product",)
next_page_token = proto.Field(proto.STRING, number=2)
@@ -317,7 +317,7 @@ class UpdateProductRequest(proto.Message):
``product_labels``, ``display_name``, and ``description``.
"""
- product = proto.Field(proto.MESSAGE, number=1, message=Product,)
+ product = proto.Field(proto.MESSAGE, number=1, message="Product",)
update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,)
@@ -357,7 +357,7 @@ class CreateProductSetRequest(proto.Message):
parent = proto.Field(proto.STRING, number=1)
- product_set = proto.Field(proto.MESSAGE, number=2, message=ProductSet,)
+ product_set = proto.Field(proto.MESSAGE, number=2, message="ProductSet",)
product_set_id = proto.Field(proto.STRING, number=3)
@@ -402,7 +402,7 @@ class ListProductSetsResponse(proto.Message):
def raw_page(self):
return self
- product_sets = proto.RepeatedField(proto.MESSAGE, number=1, message=ProductSet,)
+ product_sets = proto.RepeatedField(proto.MESSAGE, number=1, message="ProductSet",)
next_page_token = proto.Field(proto.STRING, number=2)
@@ -435,7 +435,7 @@ class UpdateProductSetRequest(proto.Message):
``display_name``.
"""
- product_set = proto.Field(proto.MESSAGE, number=1, message=ProductSet,)
+ product_set = proto.Field(proto.MESSAGE, number=1, message="ProductSet",)
update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,)
@@ -477,7 +477,7 @@ class CreateReferenceImageRequest(proto.Message):
parent = proto.Field(proto.STRING, number=1)
- reference_image = proto.Field(proto.MESSAGE, number=2, message=ReferenceImage,)
+ reference_image = proto.Field(proto.MESSAGE, number=2, message="ReferenceImage",)
reference_image_id = proto.Field(proto.STRING, number=3)
@@ -529,7 +529,7 @@ def raw_page(self):
return self
reference_images = proto.RepeatedField(
- proto.MESSAGE, number=1, message=ReferenceImage,
+ proto.MESSAGE, number=1, message="ReferenceImage",
)
page_size = proto.Field(proto.INT32, number=2)
@@ -653,7 +653,7 @@ class ListProductsInProductSetResponse(proto.Message):
def raw_page(self):
return self
- products = proto.RepeatedField(proto.MESSAGE, number=1, message=Product,)
+ products = proto.RepeatedField(proto.MESSAGE, number=1, message="Product",)
next_page_token = proto.Field(proto.STRING, number=2)
@@ -753,7 +753,7 @@ class ImportProductSetsInputConfig(proto.Message):
"""
gcs_source = proto.Field(
- proto.MESSAGE, number=1, oneof="source", message=ImportProductSetsGcsSource,
+ proto.MESSAGE, number=1, oneof="source", message="ImportProductSetsGcsSource",
)
@@ -774,7 +774,7 @@ class ImportProductSetsRequest(proto.Message):
parent = proto.Field(proto.STRING, number=1)
input_config = proto.Field(
- proto.MESSAGE, number=2, message=ImportProductSetsInputConfig,
+ proto.MESSAGE, number=2, message="ImportProductSetsInputConfig",
)
@@ -801,7 +801,7 @@ class ImportProductSetsResponse(proto.Message):
"""
reference_images = proto.RepeatedField(
- proto.MESSAGE, number=1, message=ReferenceImage,
+ proto.MESSAGE, number=1, message="ReferenceImage",
)
statuses = proto.RepeatedField(proto.MESSAGE, number=2, message=status.Status,)
@@ -878,7 +878,7 @@ class PurgeProductsRequest(proto.Message):
"""
product_set_purge_config = proto.Field(
- proto.MESSAGE, number=2, oneof="target", message=ProductSetPurgeConfig,
+ proto.MESSAGE, number=2, oneof="target", message="ProductSetPurgeConfig",
)
delete_orphan_products = proto.Field(proto.BOOL, number=3, oneof="target")
diff --git a/google/cloud/vision_v1/types/text_annotation.py b/google/cloud/vision_v1/types/text_annotation.py
index 7d647765..fa3b88ae 100644
--- a/google/cloud/vision_v1/types/text_annotation.py
+++ b/google/cloud/vision_v1/types/text_annotation.py
@@ -129,7 +129,7 @@ class Page(proto.Message):
"""
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
width = proto.Field(proto.INT32, number=2)
@@ -193,7 +193,7 @@ class BlockType(proto.Enum):
BARCODE = 5
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
bounding_box = proto.Field(proto.MESSAGE, number=2, message=geometry.BoundingPoly,)
@@ -233,7 +233,7 @@ class Paragraph(proto.Message):
"""
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
bounding_box = proto.Field(proto.MESSAGE, number=2, message=geometry.BoundingPoly,)
@@ -270,7 +270,7 @@ class Word(proto.Message):
"""
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
bounding_box = proto.Field(proto.MESSAGE, number=2, message=geometry.BoundingPoly,)
@@ -307,7 +307,7 @@ class Symbol(proto.Message):
"""
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
bounding_box = proto.Field(proto.MESSAGE, number=2, message=geometry.BoundingPoly,)
diff --git a/google/cloud/vision_v1p1beta1/__init__.py b/google/cloud/vision_v1p1beta1/__init__.py
index cd412fc8..65a2aaac 100644
--- a/google/cloud/vision_v1p1beta1/__init__.py
+++ b/google/cloud/vision_v1p1beta1/__init__.py
@@ -43,6 +43,7 @@
from .types.image_annotator import LocationInfo
from .types.image_annotator import Property
from .types.image_annotator import SafeSearchAnnotation
+from .types.image_annotator import TextDetectionParams
from .types.image_annotator import WebDetectionParams
from .types.text_annotation import Block
from .types.text_annotation import Page
@@ -88,6 +89,7 @@ class ImageAnnotatorClient(VisionHelpers, IacImageAnnotatorClient):
"SafeSearchAnnotation",
"Symbol",
"TextAnnotation",
+ "TextDetectionParams",
"Vertex",
"WebDetection",
"WebDetectionParams",
diff --git a/google/cloud/vision_v1p1beta1/proto/image_annotator.proto b/google/cloud/vision_v1p1beta1/proto/image_annotator.proto
index 4f5ada70..daf6a2d2 100644
--- a/google/cloud/vision_v1p1beta1/proto/image_annotator.proto
+++ b/google/cloud/vision_v1p1beta1/proto/image_annotator.proto
@@ -490,6 +490,16 @@ message WebDetectionParams {
bool include_geo_results = 2;
}
+// Parameters for text detections. This is used to control TEXT_DETECTION and
+// DOCUMENT_TEXT_DETECTION features.
+message TextDetectionParams {
+
+ // By default, Cloud Vision API only includes confidence score for
+ // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence
+ // score for TEXT_DETECTION as well.
+ bool enable_text_detection_confidence_score = 9;
+}
+
// Image context and/or feature-specific parameters.
message ImageContext {
// lat/long rectangle that specifies the location of the image.
@@ -510,6 +520,9 @@ message ImageContext {
// Parameters for web detection.
WebDetectionParams web_detection_params = 6;
+
+ // Parameters for text detection and document text detection.
+ TextDetectionParams text_detection_params = 12;
}
// Request for performing Google Cloud Vision API tasks over a user-provided
diff --git a/google/cloud/vision_v1p1beta1/services/image_annotator/async_client.py b/google/cloud/vision_v1p1beta1/services/image_annotator/async_client.py
index 0ee7c093..9099dd92 100644
--- a/google/cloud/vision_v1p1beta1/services/image_annotator/async_client.py
+++ b/google/cloud/vision_v1p1beta1/services/image_annotator/async_client.py
@@ -47,9 +47,47 @@ class ImageAnnotatorAsyncClient:
DEFAULT_ENDPOINT = ImageAnnotatorClient.DEFAULT_ENDPOINT
DEFAULT_MTLS_ENDPOINT = ImageAnnotatorClient.DEFAULT_MTLS_ENDPOINT
+ common_billing_account_path = staticmethod(
+ ImageAnnotatorClient.common_billing_account_path
+ )
+ parse_common_billing_account_path = staticmethod(
+ ImageAnnotatorClient.parse_common_billing_account_path
+ )
+
+ common_folder_path = staticmethod(ImageAnnotatorClient.common_folder_path)
+ parse_common_folder_path = staticmethod(
+ ImageAnnotatorClient.parse_common_folder_path
+ )
+
+ common_organization_path = staticmethod(
+ ImageAnnotatorClient.common_organization_path
+ )
+ parse_common_organization_path = staticmethod(
+ ImageAnnotatorClient.parse_common_organization_path
+ )
+
+ common_project_path = staticmethod(ImageAnnotatorClient.common_project_path)
+ parse_common_project_path = staticmethod(
+ ImageAnnotatorClient.parse_common_project_path
+ )
+
+ common_location_path = staticmethod(ImageAnnotatorClient.common_location_path)
+ parse_common_location_path = staticmethod(
+ ImageAnnotatorClient.parse_common_location_path
+ )
+
from_service_account_file = ImageAnnotatorClient.from_service_account_file
from_service_account_json = from_service_account_file
+ @property
+ def transport(self) -> ImageAnnotatorTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ ImageAnnotatorTransport: The transport used by the client instance.
+ """
+ return self._client.transport
+
get_transport_class = functools.partial(
type(ImageAnnotatorClient).get_transport_class, type(ImageAnnotatorClient)
)
@@ -140,7 +178,8 @@ async def batch_annotate_images(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([requests]):
+ has_flattened_params = any([requests])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -151,8 +190,8 @@ async def batch_annotate_images(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
@@ -163,7 +202,7 @@ async def batch_annotate_images(
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
- exceptions.ServiceUnavailable, exceptions.DeadlineExceeded,
+ exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=600.0,
diff --git a/google/cloud/vision_v1p1beta1/services/image_annotator/client.py b/google/cloud/vision_v1p1beta1/services/image_annotator/client.py
index c4b2547c..9b133ea1 100644
--- a/google/cloud/vision_v1p1beta1/services/image_annotator/client.py
+++ b/google/cloud/vision_v1p1beta1/services/image_annotator/client.py
@@ -133,6 +133,74 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
from_service_account_json = from_service_account_file
+ @property
+ def transport(self) -> ImageAnnotatorTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ ImageAnnotatorTransport: The transport used by the client instance.
+ """
+ return self._transport
+
+ @staticmethod
+ def common_billing_account_path(billing_account: str,) -> str:
+ """Return a fully-qualified billing_account string."""
+ return "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+
+ @staticmethod
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
+ """Parse a billing_account path into its component segments."""
+ m = re.match(r"^billingAccounts/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_folder_path(folder: str,) -> str:
+ """Return a fully-qualified folder string."""
+ return "folders/{folder}".format(folder=folder,)
+
+ @staticmethod
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
+ """Parse a folder path into its component segments."""
+ m = re.match(r"^folders/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_organization_path(organization: str,) -> str:
+ """Return a fully-qualified organization string."""
+ return "organizations/{organization}".format(organization=organization,)
+
+ @staticmethod
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
+ """Parse a organization path into its component segments."""
+ m = re.match(r"^organizations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_project_path(project: str,) -> str:
+ """Return a fully-qualified project string."""
+ return "projects/{project}".format(project=project,)
+
+ @staticmethod
+ def parse_common_project_path(path: str) -> Dict[str, str]:
+ """Parse a project path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_location_path(project: str, location: str,) -> str:
+ """Return a fully-qualified location string."""
+ return "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+
+ @staticmethod
+ def parse_common_location_path(path: str) -> Dict[str, str]:
+ """Parse a location path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
def __init__(
self,
*,
@@ -168,10 +236,10 @@ def __init__(
not provided, the default SSL client certificate will be used if
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
set, no client certificate will be used.
- client_info (google.api_core.gapic_v1.client_info.ClientInfo):
- The client info used to send a user-agent string along with
- API requests. If ``None``, then default info will be used.
- Generally, you only need to set this if you're developing
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
your own client library.
Raises:
@@ -308,8 +376,8 @@ def batch_annotate_images(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
diff --git a/google/cloud/vision_v1p1beta1/services/image_annotator/transports/__init__.py b/google/cloud/vision_v1p1beta1/services/image_annotator/transports/__init__.py
index f2315e0d..e2a0c3ea 100644
--- a/google/cloud/vision_v1p1beta1/services/image_annotator/transports/__init__.py
+++ b/google/cloud/vision_v1p1beta1/services/image_annotator/transports/__init__.py
@@ -28,7 +28,6 @@
_transport_registry["grpc"] = ImageAnnotatorGrpcTransport
_transport_registry["grpc_asyncio"] = ImageAnnotatorGrpcAsyncIOTransport
-
__all__ = (
"ImageAnnotatorTransport",
"ImageAnnotatorGrpcTransport",
diff --git a/google/cloud/vision_v1p1beta1/services/image_annotator/transports/base.py b/google/cloud/vision_v1p1beta1/services/image_annotator/transports/base.py
index 9132791e..b9ac57ac 100644
--- a/google/cloud/vision_v1p1beta1/services/image_annotator/transports/base.py
+++ b/google/cloud/vision_v1p1beta1/services/image_annotator/transports/base.py
@@ -114,7 +114,7 @@ def _prep_wrapped_messages(self, client_info):
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
- exceptions.ServiceUnavailable, exceptions.DeadlineExceeded,
+ exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=600.0,
diff --git a/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc.py b/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc.py
index f5047961..8dce4d82 100644
--- a/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc.py
+++ b/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc.py
@@ -92,10 +92,10 @@ def __init__(
for grpc channel. It is ignored if ``channel`` is provided.
quota_project_id (Optional[str]): An optional project to use for billing
and quota.
- client_info (google.api_core.gapic_v1.client_info.ClientInfo):
- The client info used to send a user-agent string along with
- API requests. If ``None``, then default info will be used.
- Generally, you only need to set this if you're developing
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
your own client library.
Raises:
@@ -104,6 +104,8 @@ def __init__(
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
and ``credentials_file`` are passed.
"""
+ self._ssl_channel_credentials = ssl_channel_credentials
+
if channel:
# Sanity check: Ensure that channel and credentials are not both
# provided.
@@ -111,6 +113,7 @@ def __init__(
# If a channel was explicitly provided, set it.
self._grpc_channel = channel
+ self._ssl_channel_credentials = None
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
@@ -146,7 +149,12 @@ def __init__(
ssl_credentials=ssl_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
+ self._ssl_channel_credentials = ssl_credentials
else:
host = host if ":" in host else host + ":443"
@@ -163,6 +171,10 @@ def __init__(
ssl_credentials=ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
self._stubs = {} # type: Dict[str, Callable]
@@ -189,7 +201,7 @@ def create_channel(
) -> grpc.Channel:
"""Create and return a gRPC channel object.
Args:
- address (Optionsl[str]): The host for the channel to use.
+ address (Optional[str]): The host for the channel to use.
credentials (Optional[~.Credentials]): The
authorization credentials to attach to requests. These
credentials identify this application to the service. If
@@ -224,12 +236,8 @@ def create_channel(
@property
def grpc_channel(self) -> grpc.Channel:
- """Create the channel designed to connect to this service.
-
- This property caches on the instance; repeated calls return
- the same channel.
+ """Return the channel designed to connect to this service.
"""
- # Return the channel from cache.
return self._grpc_channel
@property
diff --git a/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc_asyncio.py b/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc_asyncio.py
index a01b6b71..385f11ed 100644
--- a/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc_asyncio.py
+++ b/google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc_asyncio.py
@@ -149,6 +149,8 @@ def __init__(
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
and ``credentials_file`` are passed.
"""
+ self._ssl_channel_credentials = ssl_channel_credentials
+
if channel:
# Sanity check: Ensure that channel and credentials are not both
# provided.
@@ -156,6 +158,7 @@ def __init__(
# If a channel was explicitly provided, set it.
self._grpc_channel = channel
+ self._ssl_channel_credentials = None
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
@@ -191,7 +194,12 @@ def __init__(
ssl_credentials=ssl_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
+ self._ssl_channel_credentials = ssl_credentials
else:
host = host if ":" in host else host + ":443"
@@ -208,6 +216,10 @@ def __init__(
ssl_credentials=ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
# Run the base constructor.
diff --git a/google/cloud/vision_v1p1beta1/types/__init__.py b/google/cloud/vision_v1p1beta1/types/__init__.py
index 3247d09c..e91388a6 100644
--- a/google/cloud/vision_v1p1beta1/types/__init__.py
+++ b/google/cloud/vision_v1p1beta1/types/__init__.py
@@ -46,14 +46,15 @@
CropHintsAnnotation,
CropHintsParams,
WebDetectionParams,
+ TextDetectionParams,
ImageContext,
AnnotateImageRequest,
AnnotateImageResponse,
BatchAnnotateImagesRequest,
BatchAnnotateImagesResponse,
+ Likelihood,
)
-
__all__ = (
"Vertex",
"BoundingPoly",
@@ -81,9 +82,11 @@
"CropHintsAnnotation",
"CropHintsParams",
"WebDetectionParams",
+ "TextDetectionParams",
"ImageContext",
"AnnotateImageRequest",
"AnnotateImageResponse",
"BatchAnnotateImagesRequest",
"BatchAnnotateImagesResponse",
+ "Likelihood",
)
diff --git a/google/cloud/vision_v1p1beta1/types/geometry.py b/google/cloud/vision_v1p1beta1/types/geometry.py
index 6dd62de3..de248804 100644
--- a/google/cloud/vision_v1p1beta1/types/geometry.py
+++ b/google/cloud/vision_v1p1beta1/types/geometry.py
@@ -49,7 +49,7 @@ class BoundingPoly(proto.Message):
The bounding polygon vertices.
"""
- vertices = proto.RepeatedField(proto.MESSAGE, number=1, message=Vertex,)
+ vertices = proto.RepeatedField(proto.MESSAGE, number=1, message="Vertex",)
class Position(proto.Message):
diff --git a/google/cloud/vision_v1p1beta1/types/image_annotator.py b/google/cloud/vision_v1p1beta1/types/image_annotator.py
index 9ad8a626..be04b15f 100644
--- a/google/cloud/vision_v1p1beta1/types/image_annotator.py
+++ b/google/cloud/vision_v1p1beta1/types/image_annotator.py
@@ -46,6 +46,7 @@
"CropHintsAnnotation",
"CropHintsParams",
"WebDetectionParams",
+ "TextDetectionParams",
"ImageContext",
"AnnotateImageRequest",
"AnnotateImageResponse",
@@ -153,7 +154,7 @@ class Image(proto.Message):
content = proto.Field(proto.BYTES, number=1)
- source = proto.Field(proto.MESSAGE, number=2, message=ImageSource,)
+ source = proto.Field(proto.MESSAGE, number=2, message="ImageSource",)
class FaceAnnotation(proto.Message):
@@ -390,9 +391,9 @@ class EntityAnnotation(proto.Message):
bounding_poly = proto.Field(proto.MESSAGE, number=7, message=geometry.BoundingPoly,)
- locations = proto.RepeatedField(proto.MESSAGE, number=8, message=LocationInfo,)
+ locations = proto.RepeatedField(proto.MESSAGE, number=8, message="LocationInfo",)
- properties = proto.RepeatedField(proto.MESSAGE, number=9, message=Property,)
+ properties = proto.RepeatedField(proto.MESSAGE, number=9, message="Property",)
class SafeSearchAnnotation(proto.Message):
@@ -480,7 +481,7 @@ class DominantColorsAnnotation(proto.Message):
fraction.
"""
- colors = proto.RepeatedField(proto.MESSAGE, number=1, message=ColorInfo,)
+ colors = proto.RepeatedField(proto.MESSAGE, number=1, message="ColorInfo",)
class ImageProperties(proto.Message):
@@ -493,7 +494,7 @@ class ImageProperties(proto.Message):
"""
dominant_colors = proto.Field(
- proto.MESSAGE, number=1, message=DominantColorsAnnotation,
+ proto.MESSAGE, number=1, message="DominantColorsAnnotation",
)
@@ -529,7 +530,7 @@ class CropHintsAnnotation(proto.Message):
Crop hint results.
"""
- crop_hints = proto.RepeatedField(proto.MESSAGE, number=1, message=CropHint,)
+ crop_hints = proto.RepeatedField(proto.MESSAGE, number=1, message="CropHint",)
class CropHintsParams(proto.Message):
@@ -562,6 +563,20 @@ class WebDetectionParams(proto.Message):
include_geo_results = proto.Field(proto.BOOL, number=2)
+class TextDetectionParams(proto.Message):
+ r"""Parameters for text detections. This is used to control
+ TEXT_DETECTION and DOCUMENT_TEXT_DETECTION features.
+
+ Attributes:
+ enable_text_detection_confidence_score (bool):
+ By default, Cloud Vision API only includes confidence score
+ for DOCUMENT_TEXT_DETECTION result. Set the flag to true to
+ include confidence score for TEXT_DETECTION as well.
+ """
+
+ enable_text_detection_confidence_score = proto.Field(proto.BOOL, number=9)
+
+
class ImageContext(proto.Message):
r"""Image context and/or feature-specific parameters.
@@ -584,16 +599,23 @@ class ImageContext(proto.Message):
Parameters for crop hints annotation request.
web_detection_params (~.image_annotator.WebDetectionParams):
Parameters for web detection.
+ text_detection_params (~.image_annotator.TextDetectionParams):
+ Parameters for text detection and document
+ text detection.
"""
- lat_long_rect = proto.Field(proto.MESSAGE, number=1, message=LatLongRect,)
+ lat_long_rect = proto.Field(proto.MESSAGE, number=1, message="LatLongRect",)
language_hints = proto.RepeatedField(proto.STRING, number=2)
- crop_hints_params = proto.Field(proto.MESSAGE, number=4, message=CropHintsParams,)
+ crop_hints_params = proto.Field(proto.MESSAGE, number=4, message="CropHintsParams",)
web_detection_params = proto.Field(
- proto.MESSAGE, number=6, message=WebDetectionParams,
+ proto.MESSAGE, number=6, message="WebDetectionParams",
+ )
+
+ text_detection_params = proto.Field(
+ proto.MESSAGE, number=12, message="TextDetectionParams",
)
@@ -611,11 +633,11 @@ class AnnotateImageRequest(proto.Message):
image.
"""
- image = proto.Field(proto.MESSAGE, number=1, message=Image,)
+ image = proto.Field(proto.MESSAGE, number=1, message="Image",)
- features = proto.RepeatedField(proto.MESSAGE, number=2, message=Feature,)
+ features = proto.RepeatedField(proto.MESSAGE, number=2, message="Feature",)
- image_context = proto.Field(proto.MESSAGE, number=3, message=ImageContext,)
+ image_context = proto.Field(proto.MESSAGE, number=3, message="ImageContext",)
class AnnotateImageResponse(proto.Message):
@@ -661,23 +683,23 @@ class AnnotateImageResponse(proto.Message):
"""
face_annotations = proto.RepeatedField(
- proto.MESSAGE, number=1, message=FaceAnnotation,
+ proto.MESSAGE, number=1, message="FaceAnnotation",
)
landmark_annotations = proto.RepeatedField(
- proto.MESSAGE, number=2, message=EntityAnnotation,
+ proto.MESSAGE, number=2, message="EntityAnnotation",
)
logo_annotations = proto.RepeatedField(
- proto.MESSAGE, number=3, message=EntityAnnotation,
+ proto.MESSAGE, number=3, message="EntityAnnotation",
)
label_annotations = proto.RepeatedField(
- proto.MESSAGE, number=4, message=EntityAnnotation,
+ proto.MESSAGE, number=4, message="EntityAnnotation",
)
text_annotations = proto.RepeatedField(
- proto.MESSAGE, number=5, message=EntityAnnotation,
+ proto.MESSAGE, number=5, message="EntityAnnotation",
)
full_text_annotation = proto.Field(
@@ -685,15 +707,15 @@ class AnnotateImageResponse(proto.Message):
)
safe_search_annotation = proto.Field(
- proto.MESSAGE, number=6, message=SafeSearchAnnotation,
+ proto.MESSAGE, number=6, message="SafeSearchAnnotation",
)
image_properties_annotation = proto.Field(
- proto.MESSAGE, number=8, message=ImageProperties,
+ proto.MESSAGE, number=8, message="ImageProperties",
)
crop_hints_annotation = proto.Field(
- proto.MESSAGE, number=11, message=CropHintsAnnotation,
+ proto.MESSAGE, number=11, message="CropHintsAnnotation",
)
web_detection = proto.Field(
@@ -714,7 +736,7 @@ class BatchAnnotateImagesRequest(proto.Message):
"""
requests = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AnnotateImageRequest,
+ proto.MESSAGE, number=1, message="AnnotateImageRequest",
)
@@ -728,7 +750,7 @@ class BatchAnnotateImagesResponse(proto.Message):
"""
responses = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AnnotateImageResponse,
+ proto.MESSAGE, number=1, message="AnnotateImageResponse",
)
diff --git a/google/cloud/vision_v1p1beta1/types/text_annotation.py b/google/cloud/vision_v1p1beta1/types/text_annotation.py
index 36c7b955..8e231b4b 100644
--- a/google/cloud/vision_v1p1beta1/types/text_annotation.py
+++ b/google/cloud/vision_v1p1beta1/types/text_annotation.py
@@ -127,7 +127,7 @@ class Page(proto.Message):
"""
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
width = proto.Field(proto.INT32, number=2)
@@ -178,7 +178,7 @@ class BlockType(proto.Enum):
BARCODE = 5
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
bounding_box = proto.Field(proto.MESSAGE, number=2, message=geometry.BoundingPoly,)
@@ -218,7 +218,7 @@ class Paragraph(proto.Message):
"""
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
bounding_box = proto.Field(proto.MESSAGE, number=2, message=geometry.BoundingPoly,)
@@ -255,7 +255,7 @@ class Word(proto.Message):
"""
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
bounding_box = proto.Field(proto.MESSAGE, number=2, message=geometry.BoundingPoly,)
@@ -292,7 +292,7 @@ class Symbol(proto.Message):
"""
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
bounding_box = proto.Field(proto.MESSAGE, number=2, message=geometry.BoundingPoly,)
diff --git a/google/cloud/vision_v1p2beta1/__init__.py b/google/cloud/vision_v1p2beta1/__init__.py
index 594f7e7a..98b5a243 100644
--- a/google/cloud/vision_v1p2beta1/__init__.py
+++ b/google/cloud/vision_v1p2beta1/__init__.py
@@ -55,6 +55,7 @@
from .types.image_annotator import OutputConfig
from .types.image_annotator import Property
from .types.image_annotator import SafeSearchAnnotation
+from .types.image_annotator import TextDetectionParams
from .types.image_annotator import WebDetectionParams
from .types.text_annotation import Block
from .types.text_annotation import Page
@@ -112,6 +113,7 @@ class ImageAnnotatorClient(VisionHelpers, IacImageAnnotatorClient):
"SafeSearchAnnotation",
"Symbol",
"TextAnnotation",
+ "TextDetectionParams",
"Vertex",
"WebDetection",
"WebDetectionParams",
diff --git a/google/cloud/vision_v1p2beta1/proto/image_annotator.proto b/google/cloud/vision_v1p2beta1/proto/image_annotator.proto
index 87ae9f2c..eaf5abf0 100644
--- a/google/cloud/vision_v1p2beta1/proto/image_annotator.proto
+++ b/google/cloud/vision_v1p2beta1/proto/image_annotator.proto
@@ -521,6 +521,16 @@ message WebDetectionParams {
bool include_geo_results = 2;
}
+// Parameters for text detections. This is used to control TEXT_DETECTION and
+// DOCUMENT_TEXT_DETECTION features.
+message TextDetectionParams {
+
+ // By default, Cloud Vision API only includes confidence score for
+ // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence
+ // score for TEXT_DETECTION as well.
+ bool enable_text_detection_confidence_score = 9;
+}
+
// Image context and/or feature-specific parameters.
message ImageContext {
// Not used.
@@ -541,6 +551,9 @@ message ImageContext {
// Parameters for web detection.
WebDetectionParams web_detection_params = 6;
+
+ // Parameters for text detection and document text detection.
+ TextDetectionParams text_detection_params = 12;
}
// Request for performing Google Cloud Vision API tasks over a user-provided
diff --git a/google/cloud/vision_v1p2beta1/services/image_annotator/async_client.py b/google/cloud/vision_v1p2beta1/services/image_annotator/async_client.py
index 2e9b27a3..e28c5f19 100644
--- a/google/cloud/vision_v1p2beta1/services/image_annotator/async_client.py
+++ b/google/cloud/vision_v1p2beta1/services/image_annotator/async_client.py
@@ -49,9 +49,47 @@ class ImageAnnotatorAsyncClient:
DEFAULT_ENDPOINT = ImageAnnotatorClient.DEFAULT_ENDPOINT
DEFAULT_MTLS_ENDPOINT = ImageAnnotatorClient.DEFAULT_MTLS_ENDPOINT
+ common_billing_account_path = staticmethod(
+ ImageAnnotatorClient.common_billing_account_path
+ )
+ parse_common_billing_account_path = staticmethod(
+ ImageAnnotatorClient.parse_common_billing_account_path
+ )
+
+ common_folder_path = staticmethod(ImageAnnotatorClient.common_folder_path)
+ parse_common_folder_path = staticmethod(
+ ImageAnnotatorClient.parse_common_folder_path
+ )
+
+ common_organization_path = staticmethod(
+ ImageAnnotatorClient.common_organization_path
+ )
+ parse_common_organization_path = staticmethod(
+ ImageAnnotatorClient.parse_common_organization_path
+ )
+
+ common_project_path = staticmethod(ImageAnnotatorClient.common_project_path)
+ parse_common_project_path = staticmethod(
+ ImageAnnotatorClient.parse_common_project_path
+ )
+
+ common_location_path = staticmethod(ImageAnnotatorClient.common_location_path)
+ parse_common_location_path = staticmethod(
+ ImageAnnotatorClient.parse_common_location_path
+ )
+
from_service_account_file = ImageAnnotatorClient.from_service_account_file
from_service_account_json = from_service_account_file
+ @property
+ def transport(self) -> ImageAnnotatorTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ ImageAnnotatorTransport: The transport used by the client instance.
+ """
+ return self._client.transport
+
get_transport_class = functools.partial(
type(ImageAnnotatorClient).get_transport_class, type(ImageAnnotatorClient)
)
@@ -142,7 +180,8 @@ async def batch_annotate_images(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([requests]):
+ has_flattened_params = any([requests])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -153,8 +192,8 @@ async def batch_annotate_images(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
@@ -165,7 +204,7 @@ async def batch_annotate_images(
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
- exceptions.ServiceUnavailable, exceptions.DeadlineExceeded,
+ exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=600.0,
@@ -224,7 +263,8 @@ async def async_batch_annotate_files(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([requests]):
+ has_flattened_params = any([requests])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -235,8 +275,8 @@ async def async_batch_annotate_files(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
@@ -247,7 +287,7 @@ async def async_batch_annotate_files(
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
- exceptions.ServiceUnavailable, exceptions.DeadlineExceeded,
+ exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=600.0,
diff --git a/google/cloud/vision_v1p2beta1/services/image_annotator/client.py b/google/cloud/vision_v1p2beta1/services/image_annotator/client.py
index 66a4e53c..c86c318b 100644
--- a/google/cloud/vision_v1p2beta1/services/image_annotator/client.py
+++ b/google/cloud/vision_v1p2beta1/services/image_annotator/client.py
@@ -135,6 +135,74 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
from_service_account_json = from_service_account_file
+ @property
+ def transport(self) -> ImageAnnotatorTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ ImageAnnotatorTransport: The transport used by the client instance.
+ """
+ return self._transport
+
+ @staticmethod
+ def common_billing_account_path(billing_account: str,) -> str:
+ """Return a fully-qualified billing_account string."""
+ return "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+
+ @staticmethod
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
+ """Parse a billing_account path into its component segments."""
+ m = re.match(r"^billingAccounts/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_folder_path(folder: str,) -> str:
+ """Return a fully-qualified folder string."""
+ return "folders/{folder}".format(folder=folder,)
+
+ @staticmethod
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
+ """Parse a folder path into its component segments."""
+ m = re.match(r"^folders/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_organization_path(organization: str,) -> str:
+ """Return a fully-qualified organization string."""
+ return "organizations/{organization}".format(organization=organization,)
+
+ @staticmethod
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
+ """Parse a organization path into its component segments."""
+ m = re.match(r"^organizations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_project_path(project: str,) -> str:
+ """Return a fully-qualified project string."""
+ return "projects/{project}".format(project=project,)
+
+ @staticmethod
+ def parse_common_project_path(path: str) -> Dict[str, str]:
+ """Parse a project path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_location_path(project: str, location: str,) -> str:
+ """Return a fully-qualified location string."""
+ return "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+
+ @staticmethod
+ def parse_common_location_path(path: str) -> Dict[str, str]:
+ """Parse a location path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
def __init__(
self,
*,
@@ -170,10 +238,10 @@ def __init__(
not provided, the default SSL client certificate will be used if
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
set, no client certificate will be used.
- client_info (google.api_core.gapic_v1.client_info.ClientInfo):
- The client info used to send a user-agent string along with
- API requests. If ``None``, then default info will be used.
- Generally, you only need to set this if you're developing
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
your own client library.
Raises:
@@ -310,8 +378,8 @@ def batch_annotate_images(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
@@ -389,8 +457,8 @@ def async_batch_annotate_files(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
diff --git a/google/cloud/vision_v1p2beta1/services/image_annotator/transports/__init__.py b/google/cloud/vision_v1p2beta1/services/image_annotator/transports/__init__.py
index f2315e0d..e2a0c3ea 100644
--- a/google/cloud/vision_v1p2beta1/services/image_annotator/transports/__init__.py
+++ b/google/cloud/vision_v1p2beta1/services/image_annotator/transports/__init__.py
@@ -28,7 +28,6 @@
_transport_registry["grpc"] = ImageAnnotatorGrpcTransport
_transport_registry["grpc_asyncio"] = ImageAnnotatorGrpcAsyncIOTransport
-
__all__ = (
"ImageAnnotatorTransport",
"ImageAnnotatorGrpcTransport",
diff --git a/google/cloud/vision_v1p2beta1/services/image_annotator/transports/base.py b/google/cloud/vision_v1p2beta1/services/image_annotator/transports/base.py
index f71e6662..dbfe8e1e 100644
--- a/google/cloud/vision_v1p2beta1/services/image_annotator/transports/base.py
+++ b/google/cloud/vision_v1p2beta1/services/image_annotator/transports/base.py
@@ -116,7 +116,7 @@ def _prep_wrapped_messages(self, client_info):
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
- exceptions.ServiceUnavailable, exceptions.DeadlineExceeded,
+ exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=600.0,
@@ -129,7 +129,7 @@ def _prep_wrapped_messages(self, client_info):
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
- exceptions.ServiceUnavailable, exceptions.DeadlineExceeded,
+ exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=600.0,
diff --git a/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc.py b/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc.py
index 6bb99a4d..4795a3d6 100644
--- a/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc.py
+++ b/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc.py
@@ -94,10 +94,10 @@ def __init__(
for grpc channel. It is ignored if ``channel`` is provided.
quota_project_id (Optional[str]): An optional project to use for billing
and quota.
- client_info (google.api_core.gapic_v1.client_info.ClientInfo):
- The client info used to send a user-agent string along with
- API requests. If ``None``, then default info will be used.
- Generally, you only need to set this if you're developing
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
your own client library.
Raises:
@@ -106,6 +106,8 @@ def __init__(
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
and ``credentials_file`` are passed.
"""
+ self._ssl_channel_credentials = ssl_channel_credentials
+
if channel:
# Sanity check: Ensure that channel and credentials are not both
# provided.
@@ -113,6 +115,7 @@ def __init__(
# If a channel was explicitly provided, set it.
self._grpc_channel = channel
+ self._ssl_channel_credentials = None
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
@@ -148,7 +151,12 @@ def __init__(
ssl_credentials=ssl_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
+ self._ssl_channel_credentials = ssl_credentials
else:
host = host if ":" in host else host + ":443"
@@ -165,9 +173,14 @@ def __init__(
ssl_credentials=ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
self._stubs = {} # type: Dict[str, Callable]
+ self._operations_client = None
# Run the base constructor.
super().__init__(
@@ -191,7 +204,7 @@ def create_channel(
) -> grpc.Channel:
"""Create and return a gRPC channel object.
Args:
- address (Optionsl[str]): The host for the channel to use.
+ address (Optional[str]): The host for the channel to use.
credentials (Optional[~.Credentials]): The
authorization credentials to attach to requests. These
credentials identify this application to the service. If
@@ -226,12 +239,8 @@ def create_channel(
@property
def grpc_channel(self) -> grpc.Channel:
- """Create the channel designed to connect to this service.
-
- This property caches on the instance; repeated calls return
- the same channel.
+ """Return the channel designed to connect to this service.
"""
- # Return the channel from cache.
return self._grpc_channel
@property
@@ -242,13 +251,11 @@ def operations_client(self) -> operations_v1.OperationsClient:
client.
"""
# Sanity check: Only create a new client if we do not already have one.
- if "operations_client" not in self.__dict__:
- self.__dict__["operations_client"] = operations_v1.OperationsClient(
- self.grpc_channel
- )
+ if self._operations_client is None:
+ self._operations_client = operations_v1.OperationsClient(self.grpc_channel)
# Return the client from cache.
- return self.__dict__["operations_client"]
+ return self._operations_client
@property
def batch_annotate_images(
diff --git a/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc_asyncio.py b/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc_asyncio.py
index ea82d15b..aba72790 100644
--- a/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc_asyncio.py
+++ b/google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc_asyncio.py
@@ -151,6 +151,8 @@ def __init__(
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
and ``credentials_file`` are passed.
"""
+ self._ssl_channel_credentials = ssl_channel_credentials
+
if channel:
# Sanity check: Ensure that channel and credentials are not both
# provided.
@@ -158,6 +160,7 @@ def __init__(
# If a channel was explicitly provided, set it.
self._grpc_channel = channel
+ self._ssl_channel_credentials = None
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
@@ -193,7 +196,12 @@ def __init__(
ssl_credentials=ssl_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
+ self._ssl_channel_credentials = ssl_credentials
else:
host = host if ":" in host else host + ":443"
@@ -210,6 +218,10 @@ def __init__(
ssl_credentials=ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
# Run the base constructor.
@@ -223,6 +235,7 @@ def __init__(
)
self._stubs = {}
+ self._operations_client = None
@property
def grpc_channel(self) -> aio.Channel:
@@ -242,13 +255,13 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient:
client.
"""
# Sanity check: Only create a new client if we do not already have one.
- if "operations_client" not in self.__dict__:
- self.__dict__["operations_client"] = operations_v1.OperationsAsyncClient(
+ if self._operations_client is None:
+ self._operations_client = operations_v1.OperationsAsyncClient(
self.grpc_channel
)
# Return the client from cache.
- return self.__dict__["operations_client"]
+ return self._operations_client
@property
def batch_annotate_images(
diff --git a/google/cloud/vision_v1p2beta1/types/__init__.py b/google/cloud/vision_v1p2beta1/types/__init__.py
index c58236aa..db10dffd 100644
--- a/google/cloud/vision_v1p2beta1/types/__init__.py
+++ b/google/cloud/vision_v1p2beta1/types/__init__.py
@@ -47,6 +47,7 @@
CropHintsAnnotation,
CropHintsParams,
WebDetectionParams,
+ TextDetectionParams,
ImageContext,
AnnotateImageRequest,
ImageAnnotationContext,
@@ -63,9 +64,9 @@
GcsSource,
GcsDestination,
OperationMetadata,
+ Likelihood,
)
-
__all__ = (
"Vertex",
"NormalizedVertex",
@@ -94,6 +95,7 @@
"CropHintsAnnotation",
"CropHintsParams",
"WebDetectionParams",
+ "TextDetectionParams",
"ImageContext",
"AnnotateImageRequest",
"ImageAnnotationContext",
@@ -110,4 +112,5 @@
"GcsSource",
"GcsDestination",
"OperationMetadata",
+ "Likelihood",
)
diff --git a/google/cloud/vision_v1p2beta1/types/geometry.py b/google/cloud/vision_v1p2beta1/types/geometry.py
index ce17fcf1..482f5ec2 100644
--- a/google/cloud/vision_v1p2beta1/types/geometry.py
+++ b/google/cloud/vision_v1p2beta1/types/geometry.py
@@ -68,10 +68,10 @@ class BoundingPoly(proto.Message):
The bounding polygon normalized vertices.
"""
- vertices = proto.RepeatedField(proto.MESSAGE, number=1, message=Vertex,)
+ vertices = proto.RepeatedField(proto.MESSAGE, number=1, message="Vertex",)
normalized_vertices = proto.RepeatedField(
- proto.MESSAGE, number=2, message=NormalizedVertex,
+ proto.MESSAGE, number=2, message="NormalizedVertex",
)
diff --git a/google/cloud/vision_v1p2beta1/types/image_annotator.py b/google/cloud/vision_v1p2beta1/types/image_annotator.py
index a1f2ad65..0f3bee9c 100644
--- a/google/cloud/vision_v1p2beta1/types/image_annotator.py
+++ b/google/cloud/vision_v1p2beta1/types/image_annotator.py
@@ -47,6 +47,7 @@
"CropHintsAnnotation",
"CropHintsParams",
"WebDetectionParams",
+ "TextDetectionParams",
"ImageContext",
"AnnotateImageRequest",
"ImageAnnotationContext",
@@ -175,7 +176,7 @@ class Image(proto.Message):
content = proto.Field(proto.BYTES, number=1)
- source = proto.Field(proto.MESSAGE, number=2, message=ImageSource,)
+ source = proto.Field(proto.MESSAGE, number=2, message="ImageSource",)
class FaceAnnotation(proto.Message):
@@ -413,9 +414,9 @@ class EntityAnnotation(proto.Message):
bounding_poly = proto.Field(proto.MESSAGE, number=7, message=geometry.BoundingPoly,)
- locations = proto.RepeatedField(proto.MESSAGE, number=8, message=LocationInfo,)
+ locations = proto.RepeatedField(proto.MESSAGE, number=8, message="LocationInfo",)
- properties = proto.RepeatedField(proto.MESSAGE, number=9, message=Property,)
+ properties = proto.RepeatedField(proto.MESSAGE, number=9, message="Property",)
class SafeSearchAnnotation(proto.Message):
@@ -503,7 +504,7 @@ class DominantColorsAnnotation(proto.Message):
fraction.
"""
- colors = proto.RepeatedField(proto.MESSAGE, number=1, message=ColorInfo,)
+ colors = proto.RepeatedField(proto.MESSAGE, number=1, message="ColorInfo",)
class ImageProperties(proto.Message):
@@ -516,7 +517,7 @@ class ImageProperties(proto.Message):
"""
dominant_colors = proto.Field(
- proto.MESSAGE, number=1, message=DominantColorsAnnotation,
+ proto.MESSAGE, number=1, message="DominantColorsAnnotation",
)
@@ -552,7 +553,7 @@ class CropHintsAnnotation(proto.Message):
Crop hint results.
"""
- crop_hints = proto.RepeatedField(proto.MESSAGE, number=1, message=CropHint,)
+ crop_hints = proto.RepeatedField(proto.MESSAGE, number=1, message="CropHint",)
class CropHintsParams(proto.Message):
@@ -585,6 +586,20 @@ class WebDetectionParams(proto.Message):
include_geo_results = proto.Field(proto.BOOL, number=2)
+class TextDetectionParams(proto.Message):
+ r"""Parameters for text detections. This is used to control
+ TEXT_DETECTION and DOCUMENT_TEXT_DETECTION features.
+
+ Attributes:
+ enable_text_detection_confidence_score (bool):
+ By default, Cloud Vision API only includes confidence score
+ for DOCUMENT_TEXT_DETECTION result. Set the flag to true to
+ include confidence score for TEXT_DETECTION as well.
+ """
+
+ enable_text_detection_confidence_score = proto.Field(proto.BOOL, number=9)
+
+
class ImageContext(proto.Message):
r"""Image context and/or feature-specific parameters.
@@ -606,16 +621,23 @@ class ImageContext(proto.Message):
Parameters for crop hints annotation request.
web_detection_params (~.image_annotator.WebDetectionParams):
Parameters for web detection.
+ text_detection_params (~.image_annotator.TextDetectionParams):
+ Parameters for text detection and document
+ text detection.
"""
- lat_long_rect = proto.Field(proto.MESSAGE, number=1, message=LatLongRect,)
+ lat_long_rect = proto.Field(proto.MESSAGE, number=1, message="LatLongRect",)
language_hints = proto.RepeatedField(proto.STRING, number=2)
- crop_hints_params = proto.Field(proto.MESSAGE, number=4, message=CropHintsParams,)
+ crop_hints_params = proto.Field(proto.MESSAGE, number=4, message="CropHintsParams",)
web_detection_params = proto.Field(
- proto.MESSAGE, number=6, message=WebDetectionParams,
+ proto.MESSAGE, number=6, message="WebDetectionParams",
+ )
+
+ text_detection_params = proto.Field(
+ proto.MESSAGE, number=12, message="TextDetectionParams",
)
@@ -633,11 +655,11 @@ class AnnotateImageRequest(proto.Message):
image.
"""
- image = proto.Field(proto.MESSAGE, number=1, message=Image,)
+ image = proto.Field(proto.MESSAGE, number=1, message="Image",)
- features = proto.RepeatedField(proto.MESSAGE, number=2, message=Feature,)
+ features = proto.RepeatedField(proto.MESSAGE, number=2, message="Feature",)
- image_context = proto.Field(proto.MESSAGE, number=3, message=ImageContext,)
+ image_context = proto.Field(proto.MESSAGE, number=3, message="ImageContext",)
class ImageAnnotationContext(proto.Message):
@@ -705,23 +727,23 @@ class AnnotateImageResponse(proto.Message):
"""
face_annotations = proto.RepeatedField(
- proto.MESSAGE, number=1, message=FaceAnnotation,
+ proto.MESSAGE, number=1, message="FaceAnnotation",
)
landmark_annotations = proto.RepeatedField(
- proto.MESSAGE, number=2, message=EntityAnnotation,
+ proto.MESSAGE, number=2, message="EntityAnnotation",
)
logo_annotations = proto.RepeatedField(
- proto.MESSAGE, number=3, message=EntityAnnotation,
+ proto.MESSAGE, number=3, message="EntityAnnotation",
)
label_annotations = proto.RepeatedField(
- proto.MESSAGE, number=4, message=EntityAnnotation,
+ proto.MESSAGE, number=4, message="EntityAnnotation",
)
text_annotations = proto.RepeatedField(
- proto.MESSAGE, number=5, message=EntityAnnotation,
+ proto.MESSAGE, number=5, message="EntityAnnotation",
)
full_text_annotation = proto.Field(
@@ -729,15 +751,15 @@ class AnnotateImageResponse(proto.Message):
)
safe_search_annotation = proto.Field(
- proto.MESSAGE, number=6, message=SafeSearchAnnotation,
+ proto.MESSAGE, number=6, message="SafeSearchAnnotation",
)
image_properties_annotation = proto.Field(
- proto.MESSAGE, number=8, message=ImageProperties,
+ proto.MESSAGE, number=8, message="ImageProperties",
)
crop_hints_annotation = proto.Field(
- proto.MESSAGE, number=11, message=CropHintsAnnotation,
+ proto.MESSAGE, number=11, message="CropHintsAnnotation",
)
web_detection = proto.Field(
@@ -746,7 +768,7 @@ class AnnotateImageResponse(proto.Message):
error = proto.Field(proto.MESSAGE, number=9, message=status.Status,)
- context = proto.Field(proto.MESSAGE, number=21, message=ImageAnnotationContext,)
+ context = proto.Field(proto.MESSAGE, number=21, message="ImageAnnotationContext",)
class AnnotateFileResponse(proto.Message):
@@ -766,7 +788,7 @@ class AnnotateFileResponse(proto.Message):
input_config = proto.Field(proto.MESSAGE, number=1, message="InputConfig",)
responses = proto.RepeatedField(
- proto.MESSAGE, number=2, message=AnnotateImageResponse,
+ proto.MESSAGE, number=2, message="AnnotateImageResponse",
)
@@ -781,7 +803,7 @@ class BatchAnnotateImagesRequest(proto.Message):
"""
requests = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AnnotateImageRequest,
+ proto.MESSAGE, number=1, message="AnnotateImageRequest",
)
@@ -795,7 +817,7 @@ class BatchAnnotateImagesResponse(proto.Message):
"""
responses = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AnnotateImageResponse,
+ proto.MESSAGE, number=1, message="AnnotateImageResponse",
)
@@ -817,9 +839,9 @@ class AsyncAnnotateFileRequest(proto.Message):
input_config = proto.Field(proto.MESSAGE, number=1, message="InputConfig",)
- features = proto.RepeatedField(proto.MESSAGE, number=2, message=Feature,)
+ features = proto.RepeatedField(proto.MESSAGE, number=2, message="Feature",)
- image_context = proto.Field(proto.MESSAGE, number=3, message=ImageContext,)
+ image_context = proto.Field(proto.MESSAGE, number=3, message="ImageContext",)
output_config = proto.Field(proto.MESSAGE, number=4, message="OutputConfig",)
@@ -847,7 +869,7 @@ class AsyncBatchAnnotateFilesRequest(proto.Message):
"""
requests = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AsyncAnnotateFileRequest,
+ proto.MESSAGE, number=1, message="AsyncAnnotateFileRequest",
)
@@ -862,7 +884,7 @@ class AsyncBatchAnnotateFilesResponse(proto.Message):
"""
responses = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AsyncAnnotateFileResponse,
+ proto.MESSAGE, number=1, message="AsyncAnnotateFileResponse",
)
diff --git a/google/cloud/vision_v1p2beta1/types/text_annotation.py b/google/cloud/vision_v1p2beta1/types/text_annotation.py
index d7ca587b..c7c6de3d 100644
--- a/google/cloud/vision_v1p2beta1/types/text_annotation.py
+++ b/google/cloud/vision_v1p2beta1/types/text_annotation.py
@@ -129,7 +129,7 @@ class Page(proto.Message):
"""
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
width = proto.Field(proto.INT32, number=2)
@@ -193,7 +193,7 @@ class BlockType(proto.Enum):
BARCODE = 5
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
bounding_box = proto.Field(proto.MESSAGE, number=2, message=geometry.BoundingPoly,)
@@ -233,7 +233,7 @@ class Paragraph(proto.Message):
"""
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
bounding_box = proto.Field(proto.MESSAGE, number=2, message=geometry.BoundingPoly,)
@@ -270,7 +270,7 @@ class Word(proto.Message):
"""
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
bounding_box = proto.Field(proto.MESSAGE, number=2, message=geometry.BoundingPoly,)
@@ -307,7 +307,7 @@ class Symbol(proto.Message):
"""
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
bounding_box = proto.Field(proto.MESSAGE, number=2, message=geometry.BoundingPoly,)
diff --git a/google/cloud/vision_v1p3beta1/__init__.py b/google/cloud/vision_v1p3beta1/__init__.py
index c7ed337d..c00754cf 100644
--- a/google/cloud/vision_v1p3beta1/__init__.py
+++ b/google/cloud/vision_v1p3beta1/__init__.py
@@ -58,6 +58,7 @@
from .types.image_annotator import OutputConfig
from .types.image_annotator import Property
from .types.image_annotator import SafeSearchAnnotation
+from .types.image_annotator import TextDetectionParams
from .types.image_annotator import WebDetectionParams
from .types.product_search import ProductSearchCategory
from .types.product_search import ProductSearchParams
@@ -142,6 +143,7 @@ class ImageAnnotatorClient(VisionHelpers, IacImageAnnotatorClient):
"GetReferenceImageRequest",
"Image",
"ImageAnnotationContext",
+ "ImageAnnotatorClient",
"ImageContext",
"ImageProperties",
"ImageSource",
@@ -171,7 +173,6 @@ class ImageAnnotatorClient(VisionHelpers, IacImageAnnotatorClient):
"Position",
"Product",
"ProductSearchCategory",
- "ProductSearchClient",
"ProductSearchParams",
"ProductSearchResults",
"ProductSearchResultsView",
@@ -182,11 +183,12 @@ class ImageAnnotatorClient(VisionHelpers, IacImageAnnotatorClient):
"SafeSearchAnnotation",
"Symbol",
"TextAnnotation",
+ "TextDetectionParams",
"UpdateProductRequest",
"UpdateProductSetRequest",
"Vertex",
"WebDetection",
"WebDetectionParams",
"Word",
- "ImageAnnotatorClient",
+ "ProductSearchClient",
)
diff --git a/google/cloud/vision_v1p3beta1/proto/image_annotator.proto b/google/cloud/vision_v1p3beta1/proto/image_annotator.proto
index b63aa2b2..c865ff53 100644
--- a/google/cloud/vision_v1p3beta1/proto/image_annotator.proto
+++ b/google/cloud/vision_v1p3beta1/proto/image_annotator.proto
@@ -549,6 +549,16 @@ message WebDetectionParams {
bool include_geo_results = 2;
}
+// Parameters for text detections. This is used to control TEXT_DETECTION and
+// DOCUMENT_TEXT_DETECTION features.
+message TextDetectionParams {
+
+ // By default, Cloud Vision API only includes confidence score for
+ // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence
+ // score for TEXT_DETECTION as well.
+ bool enable_text_detection_confidence_score = 9;
+}
+
// Image context and/or feature-specific parameters.
message ImageContext {
// Not used.
@@ -572,6 +582,9 @@ message ImageContext {
// Parameters for web detection.
WebDetectionParams web_detection_params = 6;
+
+ // Parameters for text detection and document text detection.
+ TextDetectionParams text_detection_params = 12;
}
// Request for performing Google Cloud Vision API tasks over a user-provided
diff --git a/google/cloud/vision_v1p3beta1/services/image_annotator/async_client.py b/google/cloud/vision_v1p3beta1/services/image_annotator/async_client.py
index 64d06d59..c9e14583 100644
--- a/google/cloud/vision_v1p3beta1/services/image_annotator/async_client.py
+++ b/google/cloud/vision_v1p3beta1/services/image_annotator/async_client.py
@@ -49,9 +49,52 @@ class ImageAnnotatorAsyncClient:
DEFAULT_ENDPOINT = ImageAnnotatorClient.DEFAULT_ENDPOINT
DEFAULT_MTLS_ENDPOINT = ImageAnnotatorClient.DEFAULT_MTLS_ENDPOINT
+ product_path = staticmethod(ImageAnnotatorClient.product_path)
+ parse_product_path = staticmethod(ImageAnnotatorClient.parse_product_path)
+ product_set_path = staticmethod(ImageAnnotatorClient.product_set_path)
+ parse_product_set_path = staticmethod(ImageAnnotatorClient.parse_product_set_path)
+
+ common_billing_account_path = staticmethod(
+ ImageAnnotatorClient.common_billing_account_path
+ )
+ parse_common_billing_account_path = staticmethod(
+ ImageAnnotatorClient.parse_common_billing_account_path
+ )
+
+ common_folder_path = staticmethod(ImageAnnotatorClient.common_folder_path)
+ parse_common_folder_path = staticmethod(
+ ImageAnnotatorClient.parse_common_folder_path
+ )
+
+ common_organization_path = staticmethod(
+ ImageAnnotatorClient.common_organization_path
+ )
+ parse_common_organization_path = staticmethod(
+ ImageAnnotatorClient.parse_common_organization_path
+ )
+
+ common_project_path = staticmethod(ImageAnnotatorClient.common_project_path)
+ parse_common_project_path = staticmethod(
+ ImageAnnotatorClient.parse_common_project_path
+ )
+
+ common_location_path = staticmethod(ImageAnnotatorClient.common_location_path)
+ parse_common_location_path = staticmethod(
+ ImageAnnotatorClient.parse_common_location_path
+ )
+
from_service_account_file = ImageAnnotatorClient.from_service_account_file
from_service_account_json = from_service_account_file
+ @property
+ def transport(self) -> ImageAnnotatorTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ ImageAnnotatorTransport: The transport used by the client instance.
+ """
+ return self._client.transport
+
get_transport_class = functools.partial(
type(ImageAnnotatorClient).get_transport_class, type(ImageAnnotatorClient)
)
@@ -142,7 +185,8 @@ async def batch_annotate_images(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([requests]):
+ has_flattened_params = any([requests])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -153,8 +197,8 @@ async def batch_annotate_images(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
@@ -224,7 +268,8 @@ async def async_batch_annotate_files(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([requests]):
+ has_flattened_params = any([requests])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -235,8 +280,8 @@ async def async_batch_annotate_files(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
diff --git a/google/cloud/vision_v1p3beta1/services/image_annotator/client.py b/google/cloud/vision_v1p3beta1/services/image_annotator/client.py
index a7fc7e0c..6792a030 100644
--- a/google/cloud/vision_v1p3beta1/services/image_annotator/client.py
+++ b/google/cloud/vision_v1p3beta1/services/image_annotator/client.py
@@ -135,6 +135,106 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
from_service_account_json = from_service_account_file
+ @property
+ def transport(self) -> ImageAnnotatorTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ ImageAnnotatorTransport: The transport used by the client instance.
+ """
+ return self._transport
+
+ @staticmethod
+ def product_path(project: str, location: str, product: str,) -> str:
+ """Return a fully-qualified product string."""
+ return "projects/{project}/locations/{location}/products/{product}".format(
+ project=project, location=location, product=product,
+ )
+
+ @staticmethod
+ def parse_product_path(path: str) -> Dict[str, str]:
+ """Parse a product path into its component segments."""
+ m = re.match(
+ r"^projects/(?P.+?)/locations/(?P.+?)/products/(?P.+?)$",
+ path,
+ )
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def product_set_path(project: str, location: str, product_set: str,) -> str:
+ """Return a fully-qualified product_set string."""
+ return "projects/{project}/locations/{location}/productSets/{product_set}".format(
+ project=project, location=location, product_set=product_set,
+ )
+
+ @staticmethod
+ def parse_product_set_path(path: str) -> Dict[str, str]:
+ """Parse a product_set path into its component segments."""
+ m = re.match(
+ r"^projects/(?P.+?)/locations/(?P.+?)/productSets/(?P.+?)$",
+ path,
+ )
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_billing_account_path(billing_account: str,) -> str:
+ """Return a fully-qualified billing_account string."""
+ return "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+
+ @staticmethod
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
+ """Parse a billing_account path into its component segments."""
+ m = re.match(r"^billingAccounts/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_folder_path(folder: str,) -> str:
+ """Return a fully-qualified folder string."""
+ return "folders/{folder}".format(folder=folder,)
+
+ @staticmethod
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
+ """Parse a folder path into its component segments."""
+ m = re.match(r"^folders/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_organization_path(organization: str,) -> str:
+ """Return a fully-qualified organization string."""
+ return "organizations/{organization}".format(organization=organization,)
+
+ @staticmethod
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
+ """Parse a organization path into its component segments."""
+ m = re.match(r"^organizations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_project_path(project: str,) -> str:
+ """Return a fully-qualified project string."""
+ return "projects/{project}".format(project=project,)
+
+ @staticmethod
+ def parse_common_project_path(path: str) -> Dict[str, str]:
+ """Parse a project path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_location_path(project: str, location: str,) -> str:
+ """Return a fully-qualified location string."""
+ return "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+
+ @staticmethod
+ def parse_common_location_path(path: str) -> Dict[str, str]:
+ """Parse a location path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
def __init__(
self,
*,
@@ -170,10 +270,10 @@ def __init__(
not provided, the default SSL client certificate will be used if
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
set, no client certificate will be used.
- client_info (google.api_core.gapic_v1.client_info.ClientInfo):
- The client info used to send a user-agent string along with
- API requests. If ``None``, then default info will be used.
- Generally, you only need to set this if you're developing
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
your own client library.
Raises:
@@ -310,8 +410,8 @@ def batch_annotate_images(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
@@ -389,8 +489,8 @@ def async_batch_annotate_files(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
diff --git a/google/cloud/vision_v1p3beta1/services/image_annotator/transports/__init__.py b/google/cloud/vision_v1p3beta1/services/image_annotator/transports/__init__.py
index f2315e0d..e2a0c3ea 100644
--- a/google/cloud/vision_v1p3beta1/services/image_annotator/transports/__init__.py
+++ b/google/cloud/vision_v1p3beta1/services/image_annotator/transports/__init__.py
@@ -28,7 +28,6 @@
_transport_registry["grpc"] = ImageAnnotatorGrpcTransport
_transport_registry["grpc_asyncio"] = ImageAnnotatorGrpcAsyncIOTransport
-
__all__ = (
"ImageAnnotatorTransport",
"ImageAnnotatorGrpcTransport",
diff --git a/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc.py b/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc.py
index 398731df..7edc9581 100644
--- a/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc.py
+++ b/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc.py
@@ -94,10 +94,10 @@ def __init__(
for grpc channel. It is ignored if ``channel`` is provided.
quota_project_id (Optional[str]): An optional project to use for billing
and quota.
- client_info (google.api_core.gapic_v1.client_info.ClientInfo):
- The client info used to send a user-agent string along with
- API requests. If ``None``, then default info will be used.
- Generally, you only need to set this if you're developing
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
your own client library.
Raises:
@@ -106,6 +106,8 @@ def __init__(
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
and ``credentials_file`` are passed.
"""
+ self._ssl_channel_credentials = ssl_channel_credentials
+
if channel:
# Sanity check: Ensure that channel and credentials are not both
# provided.
@@ -113,6 +115,7 @@ def __init__(
# If a channel was explicitly provided, set it.
self._grpc_channel = channel
+ self._ssl_channel_credentials = None
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
@@ -148,7 +151,12 @@ def __init__(
ssl_credentials=ssl_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
+ self._ssl_channel_credentials = ssl_credentials
else:
host = host if ":" in host else host + ":443"
@@ -165,9 +173,14 @@ def __init__(
ssl_credentials=ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
self._stubs = {} # type: Dict[str, Callable]
+ self._operations_client = None
# Run the base constructor.
super().__init__(
@@ -191,7 +204,7 @@ def create_channel(
) -> grpc.Channel:
"""Create and return a gRPC channel object.
Args:
- address (Optionsl[str]): The host for the channel to use.
+ address (Optional[str]): The host for the channel to use.
credentials (Optional[~.Credentials]): The
authorization credentials to attach to requests. These
credentials identify this application to the service. If
@@ -226,12 +239,8 @@ def create_channel(
@property
def grpc_channel(self) -> grpc.Channel:
- """Create the channel designed to connect to this service.
-
- This property caches on the instance; repeated calls return
- the same channel.
+ """Return the channel designed to connect to this service.
"""
- # Return the channel from cache.
return self._grpc_channel
@property
@@ -242,13 +251,11 @@ def operations_client(self) -> operations_v1.OperationsClient:
client.
"""
# Sanity check: Only create a new client if we do not already have one.
- if "operations_client" not in self.__dict__:
- self.__dict__["operations_client"] = operations_v1.OperationsClient(
- self.grpc_channel
- )
+ if self._operations_client is None:
+ self._operations_client = operations_v1.OperationsClient(self.grpc_channel)
# Return the client from cache.
- return self.__dict__["operations_client"]
+ return self._operations_client
@property
def batch_annotate_images(
diff --git a/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc_asyncio.py b/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc_asyncio.py
index 111165e8..c496e829 100644
--- a/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc_asyncio.py
+++ b/google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc_asyncio.py
@@ -151,6 +151,8 @@ def __init__(
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
and ``credentials_file`` are passed.
"""
+ self._ssl_channel_credentials = ssl_channel_credentials
+
if channel:
# Sanity check: Ensure that channel and credentials are not both
# provided.
@@ -158,6 +160,7 @@ def __init__(
# If a channel was explicitly provided, set it.
self._grpc_channel = channel
+ self._ssl_channel_credentials = None
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
@@ -193,7 +196,12 @@ def __init__(
ssl_credentials=ssl_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
+ self._ssl_channel_credentials = ssl_credentials
else:
host = host if ":" in host else host + ":443"
@@ -210,6 +218,10 @@ def __init__(
ssl_credentials=ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
# Run the base constructor.
@@ -223,6 +235,7 @@ def __init__(
)
self._stubs = {}
+ self._operations_client = None
@property
def grpc_channel(self) -> aio.Channel:
@@ -242,13 +255,13 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient:
client.
"""
# Sanity check: Only create a new client if we do not already have one.
- if "operations_client" not in self.__dict__:
- self.__dict__["operations_client"] = operations_v1.OperationsAsyncClient(
+ if self._operations_client is None:
+ self._operations_client = operations_v1.OperationsAsyncClient(
self.grpc_channel
)
# Return the client from cache.
- return self.__dict__["operations_client"]
+ return self._operations_client
@property
def batch_annotate_images(
diff --git a/google/cloud/vision_v1p3beta1/services/product_search/async_client.py b/google/cloud/vision_v1p3beta1/services/product_search/async_client.py
index 1537b605..60c3a3cd 100644
--- a/google/cloud/vision_v1p3beta1/services/product_search/async_client.py
+++ b/google/cloud/vision_v1p3beta1/services/product_search/async_client.py
@@ -79,9 +79,47 @@ class ProductSearchAsyncClient:
ProductSearchClient.parse_reference_image_path
)
+ common_billing_account_path = staticmethod(
+ ProductSearchClient.common_billing_account_path
+ )
+ parse_common_billing_account_path = staticmethod(
+ ProductSearchClient.parse_common_billing_account_path
+ )
+
+ common_folder_path = staticmethod(ProductSearchClient.common_folder_path)
+ parse_common_folder_path = staticmethod(
+ ProductSearchClient.parse_common_folder_path
+ )
+
+ common_organization_path = staticmethod(
+ ProductSearchClient.common_organization_path
+ )
+ parse_common_organization_path = staticmethod(
+ ProductSearchClient.parse_common_organization_path
+ )
+
+ common_project_path = staticmethod(ProductSearchClient.common_project_path)
+ parse_common_project_path = staticmethod(
+ ProductSearchClient.parse_common_project_path
+ )
+
+ common_location_path = staticmethod(ProductSearchClient.common_location_path)
+ parse_common_location_path = staticmethod(
+ ProductSearchClient.parse_common_location_path
+ )
+
from_service_account_file = ProductSearchClient.from_service_account_file
from_service_account_json = from_service_account_file
+ @property
+ def transport(self) -> ProductSearchTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ ProductSearchTransport: The transport used by the client instance.
+ """
+ return self._client.transport
+
get_transport_class = functools.partial(
type(ProductSearchClient).get_transport_class, type(ProductSearchClient)
)
@@ -197,7 +235,8 @@ async def create_product_set(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent, product_set, product_set_id]):
+ has_flattened_params = any([parent, product_set, product_set_id])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -287,7 +326,8 @@ async def list_product_sets(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent]):
+ has_flattened_params = any([parent])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -381,7 +421,8 @@ async def get_product_set(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name]):
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -480,7 +521,8 @@ async def update_product_set(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([product_set, update_mask]):
+ has_flattened_params = any([product_set, update_mask])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -565,7 +607,8 @@ async def delete_product_set(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name]):
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -668,7 +711,8 @@ async def create_product(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent, product, product_id]):
+ has_flattened_params = any([parent, product, product_id])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -758,7 +802,8 @@ async def list_products(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent]):
+ has_flattened_params = any([parent])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -847,7 +892,8 @@ async def get_product(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name]):
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -950,7 +996,8 @@ async def update_product(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([product, update_mask]):
+ has_flattened_params = any([product, update_mask])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1035,7 +1082,8 @@ async def delete_product(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name]):
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1155,7 +1203,8 @@ async def create_reference_image(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent, reference_image, reference_image_id]):
+ has_flattened_params = any([parent, reference_image, reference_image_id])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1245,7 +1294,8 @@ async def delete_reference_image(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name]):
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1334,7 +1384,8 @@ async def list_reference_images(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent]):
+ has_flattened_params = any([parent])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1427,7 +1478,8 @@ async def get_reference_image(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name]):
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1521,7 +1573,8 @@ async def add_product_to_product_set(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name, product]):
+ has_flattened_params = any([name, product])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1611,7 +1664,8 @@ async def remove_product_from_product_set(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name, product]):
+ has_flattened_params = any([name, product])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1702,7 +1756,8 @@ async def list_products_in_product_set(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name]):
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1816,7 +1871,8 @@ async def import_product_sets(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent, input_config]):
+ has_flattened_params = any([parent, input_config])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
diff --git a/google/cloud/vision_v1p3beta1/services/product_search/client.py b/google/cloud/vision_v1p3beta1/services/product_search/client.py
index 87e4dceb..804985ed 100644
--- a/google/cloud/vision_v1p3beta1/services/product_search/client.py
+++ b/google/cloud/vision_v1p3beta1/services/product_search/client.py
@@ -154,6 +154,15 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
from_service_account_json = from_service_account_file
+ @property
+ def transport(self) -> ProductSearchTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ ProductSearchTransport: The transport used by the client instance.
+ """
+ return self._transport
+
@staticmethod
def product_path(project: str, location: str, product: str,) -> str:
"""Return a fully-qualified product string."""
@@ -207,6 +216,65 @@ def parse_reference_image_path(path: str) -> Dict[str, str]:
)
return m.groupdict() if m else {}
+ @staticmethod
+ def common_billing_account_path(billing_account: str,) -> str:
+ """Return a fully-qualified billing_account string."""
+ return "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+
+ @staticmethod
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
+ """Parse a billing_account path into its component segments."""
+ m = re.match(r"^billingAccounts/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_folder_path(folder: str,) -> str:
+ """Return a fully-qualified folder string."""
+ return "folders/{folder}".format(folder=folder,)
+
+ @staticmethod
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
+ """Parse a folder path into its component segments."""
+ m = re.match(r"^folders/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_organization_path(organization: str,) -> str:
+ """Return a fully-qualified organization string."""
+ return "organizations/{organization}".format(organization=organization,)
+
+ @staticmethod
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
+ """Parse a organization path into its component segments."""
+ m = re.match(r"^organizations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_project_path(project: str,) -> str:
+ """Return a fully-qualified project string."""
+ return "projects/{project}".format(project=project,)
+
+ @staticmethod
+ def parse_common_project_path(path: str) -> Dict[str, str]:
+ """Parse a project path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_location_path(project: str, location: str,) -> str:
+ """Return a fully-qualified location string."""
+ return "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+
+ @staticmethod
+ def parse_common_location_path(path: str) -> Dict[str, str]:
+ """Parse a location path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
def __init__(
self,
*,
@@ -242,10 +310,10 @@ def __init__(
not provided, the default SSL client certificate will be used if
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
set, no client certificate will be used.
- client_info (google.api_core.gapic_v1.client_info.ClientInfo):
- The client info used to send a user-agent string along with
- API requests. If ``None``, then default info will be used.
- Generally, you only need to set this if you're developing
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
your own client library.
Raises:
diff --git a/google/cloud/vision_v1p3beta1/services/product_search/transports/__init__.py b/google/cloud/vision_v1p3beta1/services/product_search/transports/__init__.py
index 2d57de48..8295a6de 100644
--- a/google/cloud/vision_v1p3beta1/services/product_search/transports/__init__.py
+++ b/google/cloud/vision_v1p3beta1/services/product_search/transports/__init__.py
@@ -28,7 +28,6 @@
_transport_registry["grpc"] = ProductSearchGrpcTransport
_transport_registry["grpc_asyncio"] = ProductSearchGrpcAsyncIOTransport
-
__all__ = (
"ProductSearchTransport",
"ProductSearchGrpcTransport",
diff --git a/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc.py b/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc.py
index 61f94bb4..d48af7d8 100644
--- a/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc.py
+++ b/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc.py
@@ -111,10 +111,10 @@ def __init__(
for grpc channel. It is ignored if ``channel`` is provided.
quota_project_id (Optional[str]): An optional project to use for billing
and quota.
- client_info (google.api_core.gapic_v1.client_info.ClientInfo):
- The client info used to send a user-agent string along with
- API requests. If ``None``, then default info will be used.
- Generally, you only need to set this if you're developing
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
your own client library.
Raises:
@@ -123,6 +123,8 @@ def __init__(
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
and ``credentials_file`` are passed.
"""
+ self._ssl_channel_credentials = ssl_channel_credentials
+
if channel:
# Sanity check: Ensure that channel and credentials are not both
# provided.
@@ -130,6 +132,7 @@ def __init__(
# If a channel was explicitly provided, set it.
self._grpc_channel = channel
+ self._ssl_channel_credentials = None
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
@@ -165,7 +168,12 @@ def __init__(
ssl_credentials=ssl_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
+ self._ssl_channel_credentials = ssl_credentials
else:
host = host if ":" in host else host + ":443"
@@ -182,9 +190,14 @@ def __init__(
ssl_credentials=ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
self._stubs = {} # type: Dict[str, Callable]
+ self._operations_client = None
# Run the base constructor.
super().__init__(
@@ -208,7 +221,7 @@ def create_channel(
) -> grpc.Channel:
"""Create and return a gRPC channel object.
Args:
- address (Optionsl[str]): The host for the channel to use.
+ address (Optional[str]): The host for the channel to use.
credentials (Optional[~.Credentials]): The
authorization credentials to attach to requests. These
credentials identify this application to the service. If
@@ -243,12 +256,8 @@ def create_channel(
@property
def grpc_channel(self) -> grpc.Channel:
- """Create the channel designed to connect to this service.
-
- This property caches on the instance; repeated calls return
- the same channel.
+ """Return the channel designed to connect to this service.
"""
- # Return the channel from cache.
return self._grpc_channel
@property
@@ -259,13 +268,11 @@ def operations_client(self) -> operations_v1.OperationsClient:
client.
"""
# Sanity check: Only create a new client if we do not already have one.
- if "operations_client" not in self.__dict__:
- self.__dict__["operations_client"] = operations_v1.OperationsClient(
- self.grpc_channel
- )
+ if self._operations_client is None:
+ self._operations_client = operations_v1.OperationsClient(self.grpc_channel)
# Return the client from cache.
- return self.__dict__["operations_client"]
+ return self._operations_client
@property
def create_product_set(
diff --git a/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc_asyncio.py b/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc_asyncio.py
index 0cbbc97b..68078018 100644
--- a/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc_asyncio.py
+++ b/google/cloud/vision_v1p3beta1/services/product_search/transports/grpc_asyncio.py
@@ -168,6 +168,8 @@ def __init__(
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
and ``credentials_file`` are passed.
"""
+ self._ssl_channel_credentials = ssl_channel_credentials
+
if channel:
# Sanity check: Ensure that channel and credentials are not both
# provided.
@@ -175,6 +177,7 @@ def __init__(
# If a channel was explicitly provided, set it.
self._grpc_channel = channel
+ self._ssl_channel_credentials = None
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
@@ -210,7 +213,12 @@ def __init__(
ssl_credentials=ssl_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
+ self._ssl_channel_credentials = ssl_credentials
else:
host = host if ":" in host else host + ":443"
@@ -227,6 +235,10 @@ def __init__(
ssl_credentials=ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
# Run the base constructor.
@@ -240,6 +252,7 @@ def __init__(
)
self._stubs = {}
+ self._operations_client = None
@property
def grpc_channel(self) -> aio.Channel:
@@ -259,13 +272,13 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient:
client.
"""
# Sanity check: Only create a new client if we do not already have one.
- if "operations_client" not in self.__dict__:
- self.__dict__["operations_client"] = operations_v1.OperationsAsyncClient(
+ if self._operations_client is None:
+ self._operations_client = operations_v1.OperationsAsyncClient(
self.grpc_channel
)
# Return the client from cache.
- return self.__dict__["operations_client"]
+ return self._operations_client
@property
def create_product_set(
diff --git a/google/cloud/vision_v1p3beta1/types/__init__.py b/google/cloud/vision_v1p3beta1/types/__init__.py
index 4b9cbb17..2378e089 100644
--- a/google/cloud/vision_v1p3beta1/types/__init__.py
+++ b/google/cloud/vision_v1p3beta1/types/__init__.py
@@ -56,6 +56,8 @@
from .product_search import (
ProductSearchParams,
ProductSearchResults,
+ ProductSearchCategory,
+ ProductSearchResultsView,
)
from .text_annotation import (
TextAnnotation,
@@ -84,6 +86,7 @@
CropHintsAnnotation,
CropHintsParams,
WebDetectionParams,
+ TextDetectionParams,
ImageContext,
AnnotateImageRequest,
ImageAnnotationContext,
@@ -100,9 +103,9 @@
GcsSource,
GcsDestination,
OperationMetadata,
+ Likelihood,
)
-
__all__ = (
"Vertex",
"NormalizedVertex",
@@ -140,6 +143,8 @@
"BatchOperationMetadata",
"ProductSearchParams",
"ProductSearchResults",
+ "ProductSearchCategory",
+ "ProductSearchResultsView",
"TextAnnotation",
"Page",
"Block",
@@ -164,6 +169,7 @@
"CropHintsAnnotation",
"CropHintsParams",
"WebDetectionParams",
+ "TextDetectionParams",
"ImageContext",
"AnnotateImageRequest",
"ImageAnnotationContext",
@@ -180,4 +186,5 @@
"GcsSource",
"GcsDestination",
"OperationMetadata",
+ "Likelihood",
)
diff --git a/google/cloud/vision_v1p3beta1/types/geometry.py b/google/cloud/vision_v1p3beta1/types/geometry.py
index f5b2b8fc..e6107175 100644
--- a/google/cloud/vision_v1p3beta1/types/geometry.py
+++ b/google/cloud/vision_v1p3beta1/types/geometry.py
@@ -74,10 +74,10 @@ class BoundingPoly(proto.Message):
The bounding polygon normalized vertices.
"""
- vertices = proto.RepeatedField(proto.MESSAGE, number=1, message=Vertex,)
+ vertices = proto.RepeatedField(proto.MESSAGE, number=1, message="Vertex",)
normalized_vertices = proto.RepeatedField(
- proto.MESSAGE, number=2, message=NormalizedVertex,
+ proto.MESSAGE, number=2, message="NormalizedVertex",
)
@@ -89,7 +89,7 @@ class NormalizedBoundingPoly(proto.Message):
Normalized vertices of the bounding polygon.
"""
- vertices = proto.RepeatedField(proto.MESSAGE, number=1, message=NormalizedVertex,)
+ vertices = proto.RepeatedField(proto.MESSAGE, number=1, message="NormalizedVertex",)
class Position(proto.Message):
diff --git a/google/cloud/vision_v1p3beta1/types/image_annotator.py b/google/cloud/vision_v1p3beta1/types/image_annotator.py
index b801ff74..7c5f1d41 100644
--- a/google/cloud/vision_v1p3beta1/types/image_annotator.py
+++ b/google/cloud/vision_v1p3beta1/types/image_annotator.py
@@ -49,6 +49,7 @@
"CropHintsAnnotation",
"CropHintsParams",
"WebDetectionParams",
+ "TextDetectionParams",
"ImageContext",
"AnnotateImageRequest",
"ImageAnnotationContext",
@@ -179,7 +180,7 @@ class Image(proto.Message):
content = proto.Field(proto.BYTES, number=1)
- source = proto.Field(proto.MESSAGE, number=2, message=ImageSource,)
+ source = proto.Field(proto.MESSAGE, number=2, message="ImageSource",)
class FaceAnnotation(proto.Message):
@@ -417,9 +418,9 @@ class EntityAnnotation(proto.Message):
bounding_poly = proto.Field(proto.MESSAGE, number=7, message=geometry.BoundingPoly,)
- locations = proto.RepeatedField(proto.MESSAGE, number=8, message=LocationInfo,)
+ locations = proto.RepeatedField(proto.MESSAGE, number=8, message="LocationInfo",)
- properties = proto.RepeatedField(proto.MESSAGE, number=9, message=Property,)
+ properties = proto.RepeatedField(proto.MESSAGE, number=9, message="Property",)
class LocalizedObjectAnnotation(proto.Message):
@@ -538,7 +539,7 @@ class DominantColorsAnnotation(proto.Message):
fraction.
"""
- colors = proto.RepeatedField(proto.MESSAGE, number=1, message=ColorInfo,)
+ colors = proto.RepeatedField(proto.MESSAGE, number=1, message="ColorInfo",)
class ImageProperties(proto.Message):
@@ -551,7 +552,7 @@ class ImageProperties(proto.Message):
"""
dominant_colors = proto.Field(
- proto.MESSAGE, number=1, message=DominantColorsAnnotation,
+ proto.MESSAGE, number=1, message="DominantColorsAnnotation",
)
@@ -587,7 +588,7 @@ class CropHintsAnnotation(proto.Message):
Crop hint results.
"""
- crop_hints = proto.RepeatedField(proto.MESSAGE, number=1, message=CropHint,)
+ crop_hints = proto.RepeatedField(proto.MESSAGE, number=1, message="CropHint",)
class CropHintsParams(proto.Message):
@@ -620,6 +621,20 @@ class WebDetectionParams(proto.Message):
include_geo_results = proto.Field(proto.BOOL, number=2)
+class TextDetectionParams(proto.Message):
+ r"""Parameters for text detections. This is used to control
+ TEXT_DETECTION and DOCUMENT_TEXT_DETECTION features.
+
+ Attributes:
+ enable_text_detection_confidence_score (bool):
+ By default, Cloud Vision API only includes confidence score
+ for DOCUMENT_TEXT_DETECTION result. Set the flag to true to
+ include confidence score for TEXT_DETECTION as well.
+ """
+
+ enable_text_detection_confidence_score = proto.Field(proto.BOOL, number=9)
+
+
class ImageContext(proto.Message):
r"""Image context and/or feature-specific parameters.
@@ -643,20 +658,27 @@ class ImageContext(proto.Message):
Parameters for product search.
web_detection_params (~.image_annotator.WebDetectionParams):
Parameters for web detection.
+ text_detection_params (~.image_annotator.TextDetectionParams):
+ Parameters for text detection and document
+ text detection.
"""
- lat_long_rect = proto.Field(proto.MESSAGE, number=1, message=LatLongRect,)
+ lat_long_rect = proto.Field(proto.MESSAGE, number=1, message="LatLongRect",)
language_hints = proto.RepeatedField(proto.STRING, number=2)
- crop_hints_params = proto.Field(proto.MESSAGE, number=4, message=CropHintsParams,)
+ crop_hints_params = proto.Field(proto.MESSAGE, number=4, message="CropHintsParams",)
product_search_params = proto.Field(
proto.MESSAGE, number=5, message=product_search.ProductSearchParams,
)
web_detection_params = proto.Field(
- proto.MESSAGE, number=6, message=WebDetectionParams,
+ proto.MESSAGE, number=6, message="WebDetectionParams",
+ )
+
+ text_detection_params = proto.Field(
+ proto.MESSAGE, number=12, message="TextDetectionParams",
)
@@ -674,11 +696,11 @@ class AnnotateImageRequest(proto.Message):
image.
"""
- image = proto.Field(proto.MESSAGE, number=1, message=Image,)
+ image = proto.Field(proto.MESSAGE, number=1, message="Image",)
- features = proto.RepeatedField(proto.MESSAGE, number=2, message=Feature,)
+ features = proto.RepeatedField(proto.MESSAGE, number=2, message="Feature",)
- image_context = proto.Field(proto.MESSAGE, number=3, message=ImageContext,)
+ image_context = proto.Field(proto.MESSAGE, number=3, message="ImageContext",)
class ImageAnnotationContext(proto.Message):
@@ -753,27 +775,27 @@ class AnnotateImageResponse(proto.Message):
"""
face_annotations = proto.RepeatedField(
- proto.MESSAGE, number=1, message=FaceAnnotation,
+ proto.MESSAGE, number=1, message="FaceAnnotation",
)
landmark_annotations = proto.RepeatedField(
- proto.MESSAGE, number=2, message=EntityAnnotation,
+ proto.MESSAGE, number=2, message="EntityAnnotation",
)
logo_annotations = proto.RepeatedField(
- proto.MESSAGE, number=3, message=EntityAnnotation,
+ proto.MESSAGE, number=3, message="EntityAnnotation",
)
label_annotations = proto.RepeatedField(
- proto.MESSAGE, number=4, message=EntityAnnotation,
+ proto.MESSAGE, number=4, message="EntityAnnotation",
)
localized_object_annotations = proto.RepeatedField(
- proto.MESSAGE, number=22, message=LocalizedObjectAnnotation,
+ proto.MESSAGE, number=22, message="LocalizedObjectAnnotation",
)
text_annotations = proto.RepeatedField(
- proto.MESSAGE, number=5, message=EntityAnnotation,
+ proto.MESSAGE, number=5, message="EntityAnnotation",
)
full_text_annotation = proto.Field(
@@ -781,15 +803,15 @@ class AnnotateImageResponse(proto.Message):
)
safe_search_annotation = proto.Field(
- proto.MESSAGE, number=6, message=SafeSearchAnnotation,
+ proto.MESSAGE, number=6, message="SafeSearchAnnotation",
)
image_properties_annotation = proto.Field(
- proto.MESSAGE, number=8, message=ImageProperties,
+ proto.MESSAGE, number=8, message="ImageProperties",
)
crop_hints_annotation = proto.Field(
- proto.MESSAGE, number=11, message=CropHintsAnnotation,
+ proto.MESSAGE, number=11, message="CropHintsAnnotation",
)
web_detection = proto.Field(
@@ -802,7 +824,7 @@ class AnnotateImageResponse(proto.Message):
error = proto.Field(proto.MESSAGE, number=9, message=status.Status,)
- context = proto.Field(proto.MESSAGE, number=21, message=ImageAnnotationContext,)
+ context = proto.Field(proto.MESSAGE, number=21, message="ImageAnnotationContext",)
class AnnotateFileResponse(proto.Message):
@@ -822,7 +844,7 @@ class AnnotateFileResponse(proto.Message):
input_config = proto.Field(proto.MESSAGE, number=1, message="InputConfig",)
responses = proto.RepeatedField(
- proto.MESSAGE, number=2, message=AnnotateImageResponse,
+ proto.MESSAGE, number=2, message="AnnotateImageResponse",
)
@@ -837,7 +859,7 @@ class BatchAnnotateImagesRequest(proto.Message):
"""
requests = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AnnotateImageRequest,
+ proto.MESSAGE, number=1, message="AnnotateImageRequest",
)
@@ -851,7 +873,7 @@ class BatchAnnotateImagesResponse(proto.Message):
"""
responses = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AnnotateImageResponse,
+ proto.MESSAGE, number=1, message="AnnotateImageResponse",
)
@@ -873,9 +895,9 @@ class AsyncAnnotateFileRequest(proto.Message):
input_config = proto.Field(proto.MESSAGE, number=1, message="InputConfig",)
- features = proto.RepeatedField(proto.MESSAGE, number=2, message=Feature,)
+ features = proto.RepeatedField(proto.MESSAGE, number=2, message="Feature",)
- image_context = proto.Field(proto.MESSAGE, number=3, message=ImageContext,)
+ image_context = proto.Field(proto.MESSAGE, number=3, message="ImageContext",)
output_config = proto.Field(proto.MESSAGE, number=4, message="OutputConfig",)
@@ -903,7 +925,7 @@ class AsyncBatchAnnotateFilesRequest(proto.Message):
"""
requests = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AsyncAnnotateFileRequest,
+ proto.MESSAGE, number=1, message="AsyncAnnotateFileRequest",
)
@@ -918,7 +940,7 @@ class AsyncBatchAnnotateFilesResponse(proto.Message):
"""
responses = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AsyncAnnotateFileResponse,
+ proto.MESSAGE, number=1, message="AsyncAnnotateFileResponse",
)
diff --git a/google/cloud/vision_v1p3beta1/types/product_search_service.py b/google/cloud/vision_v1p3beta1/types/product_search_service.py
index 0be4fa6c..1f13e1ba 100644
--- a/google/cloud/vision_v1p3beta1/types/product_search_service.py
+++ b/google/cloud/vision_v1p3beta1/types/product_search_service.py
@@ -230,7 +230,7 @@ class CreateProductRequest(proto.Message):
parent = proto.Field(proto.STRING, number=1)
- product = proto.Field(proto.MESSAGE, number=2, message=Product,)
+ product = proto.Field(proto.MESSAGE, number=2, message="Product",)
product_id = proto.Field(proto.STRING, number=3)
@@ -275,7 +275,7 @@ class ListProductsResponse(proto.Message):
def raw_page(self):
return self
- products = proto.RepeatedField(proto.MESSAGE, number=1, message=Product,)
+ products = proto.RepeatedField(proto.MESSAGE, number=1, message="Product",)
next_page_token = proto.Field(proto.STRING, number=2)
@@ -309,7 +309,7 @@ class UpdateProductRequest(proto.Message):
``product_labels``, ``display_name``, and ``description``.
"""
- product = proto.Field(proto.MESSAGE, number=1, message=Product,)
+ product = proto.Field(proto.MESSAGE, number=1, message="Product",)
update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,)
@@ -349,7 +349,7 @@ class CreateProductSetRequest(proto.Message):
parent = proto.Field(proto.STRING, number=1)
- product_set = proto.Field(proto.MESSAGE, number=2, message=ProductSet,)
+ product_set = proto.Field(proto.MESSAGE, number=2, message="ProductSet",)
product_set_id = proto.Field(proto.STRING, number=3)
@@ -394,7 +394,7 @@ class ListProductSetsResponse(proto.Message):
def raw_page(self):
return self
- product_sets = proto.RepeatedField(proto.MESSAGE, number=1, message=ProductSet,)
+ product_sets = proto.RepeatedField(proto.MESSAGE, number=1, message="ProductSet",)
next_page_token = proto.Field(proto.STRING, number=2)
@@ -427,7 +427,7 @@ class UpdateProductSetRequest(proto.Message):
``display_name``.
"""
- product_set = proto.Field(proto.MESSAGE, number=1, message=ProductSet,)
+ product_set = proto.Field(proto.MESSAGE, number=1, message="ProductSet",)
update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,)
@@ -469,7 +469,7 @@ class CreateReferenceImageRequest(proto.Message):
parent = proto.Field(proto.STRING, number=1)
- reference_image = proto.Field(proto.MESSAGE, number=2, message=ReferenceImage,)
+ reference_image = proto.Field(proto.MESSAGE, number=2, message="ReferenceImage",)
reference_image_id = proto.Field(proto.STRING, number=3)
@@ -521,7 +521,7 @@ def raw_page(self):
return self
reference_images = proto.RepeatedField(
- proto.MESSAGE, number=1, message=ReferenceImage,
+ proto.MESSAGE, number=1, message="ReferenceImage",
)
page_size = proto.Field(proto.INT32, number=2)
@@ -645,7 +645,7 @@ class ListProductsInProductSetResponse(proto.Message):
def raw_page(self):
return self
- products = proto.RepeatedField(proto.MESSAGE, number=1, message=Product,)
+ products = proto.RepeatedField(proto.MESSAGE, number=1, message="Product",)
next_page_token = proto.Field(proto.STRING, number=2)
@@ -732,7 +732,7 @@ class ImportProductSetsInputConfig(proto.Message):
"""
gcs_source = proto.Field(
- proto.MESSAGE, number=1, oneof="source", message=ImportProductSetsGcsSource,
+ proto.MESSAGE, number=1, oneof="source", message="ImportProductSetsGcsSource",
)
@@ -753,7 +753,7 @@ class ImportProductSetsRequest(proto.Message):
parent = proto.Field(proto.STRING, number=1)
input_config = proto.Field(
- proto.MESSAGE, number=2, message=ImportProductSetsInputConfig,
+ proto.MESSAGE, number=2, message="ImportProductSetsInputConfig",
)
@@ -780,7 +780,7 @@ class ImportProductSetsResponse(proto.Message):
"""
reference_images = proto.RepeatedField(
- proto.MESSAGE, number=1, message=ReferenceImage,
+ proto.MESSAGE, number=1, message="ReferenceImage",
)
statuses = proto.RepeatedField(proto.MESSAGE, number=2, message=status.Status,)
diff --git a/google/cloud/vision_v1p3beta1/types/text_annotation.py b/google/cloud/vision_v1p3beta1/types/text_annotation.py
index 1c3c212e..e1252879 100644
--- a/google/cloud/vision_v1p3beta1/types/text_annotation.py
+++ b/google/cloud/vision_v1p3beta1/types/text_annotation.py
@@ -129,7 +129,7 @@ class Page(proto.Message):
"""
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
width = proto.Field(proto.INT32, number=2)
@@ -193,7 +193,7 @@ class BlockType(proto.Enum):
BARCODE = 5
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
bounding_box = proto.Field(proto.MESSAGE, number=2, message=geometry.BoundingPoly,)
@@ -233,7 +233,7 @@ class Paragraph(proto.Message):
"""
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
bounding_box = proto.Field(proto.MESSAGE, number=2, message=geometry.BoundingPoly,)
@@ -270,7 +270,7 @@ class Word(proto.Message):
"""
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
bounding_box = proto.Field(proto.MESSAGE, number=2, message=geometry.BoundingPoly,)
@@ -307,7 +307,7 @@ class Symbol(proto.Message):
"""
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
bounding_box = proto.Field(proto.MESSAGE, number=2, message=geometry.BoundingPoly,)
diff --git a/google/cloud/vision_v1p4beta1/__init__.py b/google/cloud/vision_v1p4beta1/__init__.py
index ff3c3fb5..c2b932ed 100644
--- a/google/cloud/vision_v1p4beta1/__init__.py
+++ b/google/cloud/vision_v1p4beta1/__init__.py
@@ -65,6 +65,7 @@
from .types.image_annotator import OutputConfig
from .types.image_annotator import Property
from .types.image_annotator import SafeSearchAnnotation
+from .types.image_annotator import TextDetectionParams
from .types.image_annotator import WebDetectionParams
from .types.product_search import ProductSearchParams
from .types.product_search import ProductSearchResults
@@ -196,6 +197,7 @@ class ImageAnnotatorClient(VisionHelpers, IacImageAnnotatorClient):
"SafeSearchAnnotation",
"Symbol",
"TextAnnotation",
+ "TextDetectionParams",
"UpdateProductRequest",
"UpdateProductSetRequest",
"Vertex",
diff --git a/google/cloud/vision_v1p4beta1/proto/image_annotator.proto b/google/cloud/vision_v1p4beta1/proto/image_annotator.proto
index 9c18cccd..07217f39 100644
--- a/google/cloud/vision_v1p4beta1/proto/image_annotator.proto
+++ b/google/cloud/vision_v1p4beta1/proto/image_annotator.proto
@@ -620,6 +620,16 @@ message WebDetectionParams {
bool include_geo_results = 2;
}
+// Parameters for text detections. This is used to control TEXT_DETECTION and
+// DOCUMENT_TEXT_DETECTION features.
+message TextDetectionParams {
+
+ // By default, Cloud Vision API only includes confidence score for
+ // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence
+ // score for TEXT_DETECTION as well.
+ bool enable_text_detection_confidence_score = 9;
+}
+
// Image context and/or feature-specific parameters.
message ImageContext {
// Not used.
@@ -646,6 +656,9 @@ message ImageContext {
// Parameters for web detection.
WebDetectionParams web_detection_params = 6;
+
+ // Parameters for text detection and document text detection.
+ TextDetectionParams text_detection_params = 12;
}
// Request for performing Google Cloud Vision API tasks over a user-provided
diff --git a/google/cloud/vision_v1p4beta1/services/image_annotator/async_client.py b/google/cloud/vision_v1p4beta1/services/image_annotator/async_client.py
index 182132c9..581f63bd 100644
--- a/google/cloud/vision_v1p4beta1/services/image_annotator/async_client.py
+++ b/google/cloud/vision_v1p4beta1/services/image_annotator/async_client.py
@@ -49,9 +49,52 @@ class ImageAnnotatorAsyncClient:
DEFAULT_ENDPOINT = ImageAnnotatorClient.DEFAULT_ENDPOINT
DEFAULT_MTLS_ENDPOINT = ImageAnnotatorClient.DEFAULT_MTLS_ENDPOINT
+ product_path = staticmethod(ImageAnnotatorClient.product_path)
+ parse_product_path = staticmethod(ImageAnnotatorClient.parse_product_path)
+ product_set_path = staticmethod(ImageAnnotatorClient.product_set_path)
+ parse_product_set_path = staticmethod(ImageAnnotatorClient.parse_product_set_path)
+
+ common_billing_account_path = staticmethod(
+ ImageAnnotatorClient.common_billing_account_path
+ )
+ parse_common_billing_account_path = staticmethod(
+ ImageAnnotatorClient.parse_common_billing_account_path
+ )
+
+ common_folder_path = staticmethod(ImageAnnotatorClient.common_folder_path)
+ parse_common_folder_path = staticmethod(
+ ImageAnnotatorClient.parse_common_folder_path
+ )
+
+ common_organization_path = staticmethod(
+ ImageAnnotatorClient.common_organization_path
+ )
+ parse_common_organization_path = staticmethod(
+ ImageAnnotatorClient.parse_common_organization_path
+ )
+
+ common_project_path = staticmethod(ImageAnnotatorClient.common_project_path)
+ parse_common_project_path = staticmethod(
+ ImageAnnotatorClient.parse_common_project_path
+ )
+
+ common_location_path = staticmethod(ImageAnnotatorClient.common_location_path)
+ parse_common_location_path = staticmethod(
+ ImageAnnotatorClient.parse_common_location_path
+ )
+
from_service_account_file = ImageAnnotatorClient.from_service_account_file
from_service_account_json = from_service_account_file
+ @property
+ def transport(self) -> ImageAnnotatorTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ ImageAnnotatorTransport: The transport used by the client instance.
+ """
+ return self._client.transport
+
get_transport_class = functools.partial(
type(ImageAnnotatorClient).get_transport_class, type(ImageAnnotatorClient)
)
@@ -142,7 +185,8 @@ async def batch_annotate_images(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([requests]):
+ has_flattened_params = any([requests])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -153,8 +197,8 @@ async def batch_annotate_images(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
@@ -220,7 +264,8 @@ async def batch_annotate_files(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([requests]):
+ has_flattened_params = any([requests])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -231,8 +276,8 @@ async def batch_annotate_files(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
@@ -312,7 +357,8 @@ async def async_batch_annotate_images(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([requests, output_config]):
+ has_flattened_params = any([requests, output_config])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -323,11 +369,12 @@ async def async_batch_annotate_images(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
if output_config is not None:
request.output_config = output_config
+ if requests:
+ request.requests.extend(requests)
+
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
@@ -402,7 +449,8 @@ async def async_batch_annotate_files(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([requests]):
+ has_flattened_params = any([requests])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -413,8 +461,8 @@ async def async_batch_annotate_files(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
diff --git a/google/cloud/vision_v1p4beta1/services/image_annotator/client.py b/google/cloud/vision_v1p4beta1/services/image_annotator/client.py
index 2abb95a9..160e68ef 100644
--- a/google/cloud/vision_v1p4beta1/services/image_annotator/client.py
+++ b/google/cloud/vision_v1p4beta1/services/image_annotator/client.py
@@ -135,6 +135,106 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
from_service_account_json = from_service_account_file
+ @property
+ def transport(self) -> ImageAnnotatorTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ ImageAnnotatorTransport: The transport used by the client instance.
+ """
+ return self._transport
+
+ @staticmethod
+ def product_path(project: str, location: str, product: str,) -> str:
+ """Return a fully-qualified product string."""
+ return "projects/{project}/locations/{location}/products/{product}".format(
+ project=project, location=location, product=product,
+ )
+
+ @staticmethod
+ def parse_product_path(path: str) -> Dict[str, str]:
+ """Parse a product path into its component segments."""
+ m = re.match(
+ r"^projects/(?P.+?)/locations/(?P.+?)/products/(?P.+?)$",
+ path,
+ )
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def product_set_path(project: str, location: str, product_set: str,) -> str:
+ """Return a fully-qualified product_set string."""
+ return "projects/{project}/locations/{location}/productSets/{product_set}".format(
+ project=project, location=location, product_set=product_set,
+ )
+
+ @staticmethod
+ def parse_product_set_path(path: str) -> Dict[str, str]:
+ """Parse a product_set path into its component segments."""
+ m = re.match(
+ r"^projects/(?P.+?)/locations/(?P.+?)/productSets/(?P.+?)$",
+ path,
+ )
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_billing_account_path(billing_account: str,) -> str:
+ """Return a fully-qualified billing_account string."""
+ return "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+
+ @staticmethod
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
+ """Parse a billing_account path into its component segments."""
+ m = re.match(r"^billingAccounts/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_folder_path(folder: str,) -> str:
+ """Return a fully-qualified folder string."""
+ return "folders/{folder}".format(folder=folder,)
+
+ @staticmethod
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
+ """Parse a folder path into its component segments."""
+ m = re.match(r"^folders/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_organization_path(organization: str,) -> str:
+ """Return a fully-qualified organization string."""
+ return "organizations/{organization}".format(organization=organization,)
+
+ @staticmethod
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
+ """Parse a organization path into its component segments."""
+ m = re.match(r"^organizations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_project_path(project: str,) -> str:
+ """Return a fully-qualified project string."""
+ return "projects/{project}".format(project=project,)
+
+ @staticmethod
+ def parse_common_project_path(path: str) -> Dict[str, str]:
+ """Parse a project path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_location_path(project: str, location: str,) -> str:
+ """Return a fully-qualified location string."""
+ return "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+
+ @staticmethod
+ def parse_common_location_path(path: str) -> Dict[str, str]:
+ """Parse a location path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
def __init__(
self,
*,
@@ -170,10 +270,10 @@ def __init__(
not provided, the default SSL client certificate will be used if
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
set, no client certificate will be used.
- client_info (google.api_core.gapic_v1.client_info.ClientInfo):
- The client info used to send a user-agent string along with
- API requests. If ``None``, then default info will be used.
- Generally, you only need to set this if you're developing
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
your own client library.
Raises:
@@ -310,8 +410,8 @@ def batch_annotate_images(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
@@ -387,8 +487,8 @@ def batch_annotate_files(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
@@ -478,11 +578,12 @@ def async_batch_annotate_images(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
if output_config is not None:
request.output_config = output_config
+ if requests:
+ request.requests.extend(requests)
+
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[
@@ -569,8 +670,8 @@ def async_batch_annotate_files(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
- if requests is not None:
- request.requests = requests
+ if requests:
+ request.requests.extend(requests)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
diff --git a/google/cloud/vision_v1p4beta1/services/image_annotator/transports/__init__.py b/google/cloud/vision_v1p4beta1/services/image_annotator/transports/__init__.py
index f2315e0d..e2a0c3ea 100644
--- a/google/cloud/vision_v1p4beta1/services/image_annotator/transports/__init__.py
+++ b/google/cloud/vision_v1p4beta1/services/image_annotator/transports/__init__.py
@@ -28,7 +28,6 @@
_transport_registry["grpc"] = ImageAnnotatorGrpcTransport
_transport_registry["grpc_asyncio"] = ImageAnnotatorGrpcAsyncIOTransport
-
__all__ = (
"ImageAnnotatorTransport",
"ImageAnnotatorGrpcTransport",
diff --git a/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc.py b/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc.py
index 3e41f0d3..01609395 100644
--- a/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc.py
+++ b/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc.py
@@ -94,10 +94,10 @@ def __init__(
for grpc channel. It is ignored if ``channel`` is provided.
quota_project_id (Optional[str]): An optional project to use for billing
and quota.
- client_info (google.api_core.gapic_v1.client_info.ClientInfo):
- The client info used to send a user-agent string along with
- API requests. If ``None``, then default info will be used.
- Generally, you only need to set this if you're developing
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
your own client library.
Raises:
@@ -106,6 +106,8 @@ def __init__(
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
and ``credentials_file`` are passed.
"""
+ self._ssl_channel_credentials = ssl_channel_credentials
+
if channel:
# Sanity check: Ensure that channel and credentials are not both
# provided.
@@ -113,6 +115,7 @@ def __init__(
# If a channel was explicitly provided, set it.
self._grpc_channel = channel
+ self._ssl_channel_credentials = None
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
@@ -148,7 +151,12 @@ def __init__(
ssl_credentials=ssl_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
+ self._ssl_channel_credentials = ssl_credentials
else:
host = host if ":" in host else host + ":443"
@@ -165,9 +173,14 @@ def __init__(
ssl_credentials=ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
self._stubs = {} # type: Dict[str, Callable]
+ self._operations_client = None
# Run the base constructor.
super().__init__(
@@ -191,7 +204,7 @@ def create_channel(
) -> grpc.Channel:
"""Create and return a gRPC channel object.
Args:
- address (Optionsl[str]): The host for the channel to use.
+ address (Optional[str]): The host for the channel to use.
credentials (Optional[~.Credentials]): The
authorization credentials to attach to requests. These
credentials identify this application to the service. If
@@ -226,12 +239,8 @@ def create_channel(
@property
def grpc_channel(self) -> grpc.Channel:
- """Create the channel designed to connect to this service.
-
- This property caches on the instance; repeated calls return
- the same channel.
+ """Return the channel designed to connect to this service.
"""
- # Return the channel from cache.
return self._grpc_channel
@property
@@ -242,13 +251,11 @@ def operations_client(self) -> operations_v1.OperationsClient:
client.
"""
# Sanity check: Only create a new client if we do not already have one.
- if "operations_client" not in self.__dict__:
- self.__dict__["operations_client"] = operations_v1.OperationsClient(
- self.grpc_channel
- )
+ if self._operations_client is None:
+ self._operations_client = operations_v1.OperationsClient(self.grpc_channel)
# Return the client from cache.
- return self.__dict__["operations_client"]
+ return self._operations_client
@property
def batch_annotate_images(
diff --git a/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc_asyncio.py b/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc_asyncio.py
index d1f5775c..1386542d 100644
--- a/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc_asyncio.py
+++ b/google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc_asyncio.py
@@ -151,6 +151,8 @@ def __init__(
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
and ``credentials_file`` are passed.
"""
+ self._ssl_channel_credentials = ssl_channel_credentials
+
if channel:
# Sanity check: Ensure that channel and credentials are not both
# provided.
@@ -158,6 +160,7 @@ def __init__(
# If a channel was explicitly provided, set it.
self._grpc_channel = channel
+ self._ssl_channel_credentials = None
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
@@ -193,7 +196,12 @@ def __init__(
ssl_credentials=ssl_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
+ self._ssl_channel_credentials = ssl_credentials
else:
host = host if ":" in host else host + ":443"
@@ -210,6 +218,10 @@ def __init__(
ssl_credentials=ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
# Run the base constructor.
@@ -223,6 +235,7 @@ def __init__(
)
self._stubs = {}
+ self._operations_client = None
@property
def grpc_channel(self) -> aio.Channel:
@@ -242,13 +255,13 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient:
client.
"""
# Sanity check: Only create a new client if we do not already have one.
- if "operations_client" not in self.__dict__:
- self.__dict__["operations_client"] = operations_v1.OperationsAsyncClient(
+ if self._operations_client is None:
+ self._operations_client = operations_v1.OperationsAsyncClient(
self.grpc_channel
)
# Return the client from cache.
- return self.__dict__["operations_client"]
+ return self._operations_client
@property
def batch_annotate_images(
diff --git a/google/cloud/vision_v1p4beta1/services/product_search/async_client.py b/google/cloud/vision_v1p4beta1/services/product_search/async_client.py
index f00e5814..1c50dd67 100644
--- a/google/cloud/vision_v1p4beta1/services/product_search/async_client.py
+++ b/google/cloud/vision_v1p4beta1/services/product_search/async_client.py
@@ -80,9 +80,47 @@ class ProductSearchAsyncClient:
ProductSearchClient.parse_reference_image_path
)
+ common_billing_account_path = staticmethod(
+ ProductSearchClient.common_billing_account_path
+ )
+ parse_common_billing_account_path = staticmethod(
+ ProductSearchClient.parse_common_billing_account_path
+ )
+
+ common_folder_path = staticmethod(ProductSearchClient.common_folder_path)
+ parse_common_folder_path = staticmethod(
+ ProductSearchClient.parse_common_folder_path
+ )
+
+ common_organization_path = staticmethod(
+ ProductSearchClient.common_organization_path
+ )
+ parse_common_organization_path = staticmethod(
+ ProductSearchClient.parse_common_organization_path
+ )
+
+ common_project_path = staticmethod(ProductSearchClient.common_project_path)
+ parse_common_project_path = staticmethod(
+ ProductSearchClient.parse_common_project_path
+ )
+
+ common_location_path = staticmethod(ProductSearchClient.common_location_path)
+ parse_common_location_path = staticmethod(
+ ProductSearchClient.parse_common_location_path
+ )
+
from_service_account_file = ProductSearchClient.from_service_account_file
from_service_account_json = from_service_account_file
+ @property
+ def transport(self) -> ProductSearchTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ ProductSearchTransport: The transport used by the client instance.
+ """
+ return self._client.transport
+
get_transport_class = functools.partial(
type(ProductSearchClient).get_transport_class, type(ProductSearchClient)
)
@@ -198,7 +236,8 @@ async def create_product_set(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent, product_set, product_set_id]):
+ has_flattened_params = any([parent, product_set, product_set_id])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -288,7 +327,8 @@ async def list_product_sets(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent]):
+ has_flattened_params = any([parent])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -382,7 +422,8 @@ async def get_product_set(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name]):
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -481,7 +522,8 @@ async def update_product_set(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([product_set, update_mask]):
+ has_flattened_params = any([product_set, update_mask])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -561,7 +603,8 @@ async def delete_product_set(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name]):
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -664,7 +707,8 @@ async def create_product(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent, product, product_id]):
+ has_flattened_params = any([parent, product, product_id])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -754,7 +798,8 @@ async def list_products(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent]):
+ has_flattened_params = any([parent])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -843,7 +888,8 @@ async def get_product(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name]):
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -946,7 +992,8 @@ async def update_product(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([product, update_mask]):
+ has_flattened_params = any([product, update_mask])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1028,7 +1075,8 @@ async def delete_product(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name]):
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1148,7 +1196,8 @@ async def create_reference_image(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent, reference_image, reference_image_id]):
+ has_flattened_params = any([parent, reference_image, reference_image_id])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1233,7 +1282,8 @@ async def delete_reference_image(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name]):
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1322,7 +1372,8 @@ async def list_reference_images(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent]):
+ has_flattened_params = any([parent])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1415,7 +1466,8 @@ async def get_reference_image(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name]):
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1509,7 +1561,8 @@ async def add_product_to_product_set(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name, product]):
+ has_flattened_params = any([name, product])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1594,7 +1647,8 @@ async def remove_product_from_product_set(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name, product]):
+ has_flattened_params = any([name, product])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1685,7 +1739,8 @@ async def list_products_in_product_set(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([name]):
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1799,7 +1854,8 @@ async def import_product_sets(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent, input_config]):
+ has_flattened_params = any([parent, input_config])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
@@ -1929,7 +1985,8 @@ async def purge_products(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
- if request is not None and any([parent]):
+ has_flattened_params = any([parent])
+ if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
diff --git a/google/cloud/vision_v1p4beta1/services/product_search/client.py b/google/cloud/vision_v1p4beta1/services/product_search/client.py
index 42410736..dc704e28 100644
--- a/google/cloud/vision_v1p4beta1/services/product_search/client.py
+++ b/google/cloud/vision_v1p4beta1/services/product_search/client.py
@@ -155,6 +155,15 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
from_service_account_json = from_service_account_file
+ @property
+ def transport(self) -> ProductSearchTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ ProductSearchTransport: The transport used by the client instance.
+ """
+ return self._transport
+
@staticmethod
def product_path(project: str, location: str, product: str,) -> str:
"""Return a fully-qualified product string."""
@@ -208,6 +217,65 @@ def parse_reference_image_path(path: str) -> Dict[str, str]:
)
return m.groupdict() if m else {}
+ @staticmethod
+ def common_billing_account_path(billing_account: str,) -> str:
+ """Return a fully-qualified billing_account string."""
+ return "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+
+ @staticmethod
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
+ """Parse a billing_account path into its component segments."""
+ m = re.match(r"^billingAccounts/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_folder_path(folder: str,) -> str:
+ """Return a fully-qualified folder string."""
+ return "folders/{folder}".format(folder=folder,)
+
+ @staticmethod
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
+ """Parse a folder path into its component segments."""
+ m = re.match(r"^folders/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_organization_path(organization: str,) -> str:
+ """Return a fully-qualified organization string."""
+ return "organizations/{organization}".format(organization=organization,)
+
+ @staticmethod
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
+ """Parse a organization path into its component segments."""
+ m = re.match(r"^organizations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_project_path(project: str,) -> str:
+ """Return a fully-qualified project string."""
+ return "projects/{project}".format(project=project,)
+
+ @staticmethod
+ def parse_common_project_path(path: str) -> Dict[str, str]:
+ """Parse a project path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_location_path(project: str, location: str,) -> str:
+ """Return a fully-qualified location string."""
+ return "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+
+ @staticmethod
+ def parse_common_location_path(path: str) -> Dict[str, str]:
+ """Parse a location path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
def __init__(
self,
*,
@@ -243,10 +311,10 @@ def __init__(
not provided, the default SSL client certificate will be used if
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
set, no client certificate will be used.
- client_info (google.api_core.gapic_v1.client_info.ClientInfo):
- The client info used to send a user-agent string along with
- API requests. If ``None``, then default info will be used.
- Generally, you only need to set this if you're developing
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
your own client library.
Raises:
diff --git a/google/cloud/vision_v1p4beta1/services/product_search/transports/__init__.py b/google/cloud/vision_v1p4beta1/services/product_search/transports/__init__.py
index 2d57de48..8295a6de 100644
--- a/google/cloud/vision_v1p4beta1/services/product_search/transports/__init__.py
+++ b/google/cloud/vision_v1p4beta1/services/product_search/transports/__init__.py
@@ -28,7 +28,6 @@
_transport_registry["grpc"] = ProductSearchGrpcTransport
_transport_registry["grpc_asyncio"] = ProductSearchGrpcAsyncIOTransport
-
__all__ = (
"ProductSearchTransport",
"ProductSearchGrpcTransport",
diff --git a/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc.py b/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc.py
index 5f060e60..3e8ea680 100644
--- a/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc.py
+++ b/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc.py
@@ -111,10 +111,10 @@ def __init__(
for grpc channel. It is ignored if ``channel`` is provided.
quota_project_id (Optional[str]): An optional project to use for billing
and quota.
- client_info (google.api_core.gapic_v1.client_info.ClientInfo):
- The client info used to send a user-agent string along with
- API requests. If ``None``, then default info will be used.
- Generally, you only need to set this if you're developing
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
your own client library.
Raises:
@@ -123,6 +123,8 @@ def __init__(
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
and ``credentials_file`` are passed.
"""
+ self._ssl_channel_credentials = ssl_channel_credentials
+
if channel:
# Sanity check: Ensure that channel and credentials are not both
# provided.
@@ -130,6 +132,7 @@ def __init__(
# If a channel was explicitly provided, set it.
self._grpc_channel = channel
+ self._ssl_channel_credentials = None
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
@@ -165,7 +168,12 @@ def __init__(
ssl_credentials=ssl_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
+ self._ssl_channel_credentials = ssl_credentials
else:
host = host if ":" in host else host + ":443"
@@ -182,9 +190,14 @@ def __init__(
ssl_credentials=ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
self._stubs = {} # type: Dict[str, Callable]
+ self._operations_client = None
# Run the base constructor.
super().__init__(
@@ -208,7 +221,7 @@ def create_channel(
) -> grpc.Channel:
"""Create and return a gRPC channel object.
Args:
- address (Optionsl[str]): The host for the channel to use.
+ address (Optional[str]): The host for the channel to use.
credentials (Optional[~.Credentials]): The
authorization credentials to attach to requests. These
credentials identify this application to the service. If
@@ -243,12 +256,8 @@ def create_channel(
@property
def grpc_channel(self) -> grpc.Channel:
- """Create the channel designed to connect to this service.
-
- This property caches on the instance; repeated calls return
- the same channel.
+ """Return the channel designed to connect to this service.
"""
- # Return the channel from cache.
return self._grpc_channel
@property
@@ -259,13 +268,11 @@ def operations_client(self) -> operations_v1.OperationsClient:
client.
"""
# Sanity check: Only create a new client if we do not already have one.
- if "operations_client" not in self.__dict__:
- self.__dict__["operations_client"] = operations_v1.OperationsClient(
- self.grpc_channel
- )
+ if self._operations_client is None:
+ self._operations_client = operations_v1.OperationsClient(self.grpc_channel)
# Return the client from cache.
- return self.__dict__["operations_client"]
+ return self._operations_client
@property
def create_product_set(
diff --git a/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc_asyncio.py b/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc_asyncio.py
index d52e9a69..6a0af863 100644
--- a/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc_asyncio.py
+++ b/google/cloud/vision_v1p4beta1/services/product_search/transports/grpc_asyncio.py
@@ -168,6 +168,8 @@ def __init__(
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
and ``credentials_file`` are passed.
"""
+ self._ssl_channel_credentials = ssl_channel_credentials
+
if channel:
# Sanity check: Ensure that channel and credentials are not both
# provided.
@@ -175,6 +177,7 @@ def __init__(
# If a channel was explicitly provided, set it.
self._grpc_channel = channel
+ self._ssl_channel_credentials = None
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
@@ -210,7 +213,12 @@ def __init__(
ssl_credentials=ssl_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
+ self._ssl_channel_credentials = ssl_credentials
else:
host = host if ":" in host else host + ":443"
@@ -227,6 +235,10 @@ def __init__(
ssl_credentials=ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
# Run the base constructor.
@@ -240,6 +252,7 @@ def __init__(
)
self._stubs = {}
+ self._operations_client = None
@property
def grpc_channel(self) -> aio.Channel:
@@ -259,13 +272,13 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient:
client.
"""
# Sanity check: Only create a new client if we do not already have one.
- if "operations_client" not in self.__dict__:
- self.__dict__["operations_client"] = operations_v1.OperationsAsyncClient(
+ if self._operations_client is None:
+ self._operations_client = operations_v1.OperationsAsyncClient(
self.grpc_channel
)
# Return the client from cache.
- return self.__dict__["operations_client"]
+ return self._operations_client
@property
def create_product_set(
diff --git a/google/cloud/vision_v1p4beta1/types/__init__.py b/google/cloud/vision_v1p4beta1/types/__init__.py
index 8addc27c..d1f39653 100644
--- a/google/cloud/vision_v1p4beta1/types/__init__.py
+++ b/google/cloud/vision_v1p4beta1/types/__init__.py
@@ -90,6 +90,7 @@
CropHintsAnnotation,
CropHintsParams,
WebDetectionParams,
+ TextDetectionParams,
ImageContext,
AnnotateImageRequest,
ImageAnnotationContext,
@@ -111,9 +112,9 @@
GcsSource,
GcsDestination,
OperationMetadata,
+ Likelihood,
)
-
__all__ = (
"Vertex",
"NormalizedVertex",
@@ -179,6 +180,7 @@
"CropHintsAnnotation",
"CropHintsParams",
"WebDetectionParams",
+ "TextDetectionParams",
"ImageContext",
"AnnotateImageRequest",
"ImageAnnotationContext",
@@ -200,4 +202,5 @@
"GcsSource",
"GcsDestination",
"OperationMetadata",
+ "Likelihood",
)
diff --git a/google/cloud/vision_v1p4beta1/types/face.py b/google/cloud/vision_v1p4beta1/types/face.py
index 68b34cc0..34ca9aa9 100644
--- a/google/cloud/vision_v1p4beta1/types/face.py
+++ b/google/cloud/vision_v1p4beta1/types/face.py
@@ -71,7 +71,7 @@ class FaceRecognitionResult(proto.Message):
Recognition confidence. Range [0, 1].
"""
- celebrity = proto.Field(proto.MESSAGE, number=1, message=Celebrity,)
+ celebrity = proto.Field(proto.MESSAGE, number=1, message="Celebrity",)
confidence = proto.Field(proto.FLOAT, number=2)
diff --git a/google/cloud/vision_v1p4beta1/types/geometry.py b/google/cloud/vision_v1p4beta1/types/geometry.py
index 03a2a726..60c32e6e 100644
--- a/google/cloud/vision_v1p4beta1/types/geometry.py
+++ b/google/cloud/vision_v1p4beta1/types/geometry.py
@@ -68,10 +68,10 @@ class BoundingPoly(proto.Message):
The bounding polygon normalized vertices.
"""
- vertices = proto.RepeatedField(proto.MESSAGE, number=1, message=Vertex,)
+ vertices = proto.RepeatedField(proto.MESSAGE, number=1, message="Vertex",)
normalized_vertices = proto.RepeatedField(
- proto.MESSAGE, number=2, message=NormalizedVertex,
+ proto.MESSAGE, number=2, message="NormalizedVertex",
)
diff --git a/google/cloud/vision_v1p4beta1/types/image_annotator.py b/google/cloud/vision_v1p4beta1/types/image_annotator.py
index 6f6c1cf6..98788127 100644
--- a/google/cloud/vision_v1p4beta1/types/image_annotator.py
+++ b/google/cloud/vision_v1p4beta1/types/image_annotator.py
@@ -50,6 +50,7 @@
"CropHintsAnnotation",
"CropHintsParams",
"WebDetectionParams",
+ "TextDetectionParams",
"ImageContext",
"AnnotateImageRequest",
"ImageAnnotationContext",
@@ -185,7 +186,7 @@ class Image(proto.Message):
content = proto.Field(proto.BYTES, number=1)
- source = proto.Field(proto.MESSAGE, number=2, message=ImageSource,)
+ source = proto.Field(proto.MESSAGE, number=2, message="ImageSource",)
class FaceAnnotation(proto.Message):
@@ -435,9 +436,9 @@ class EntityAnnotation(proto.Message):
bounding_poly = proto.Field(proto.MESSAGE, number=7, message=geometry.BoundingPoly,)
- locations = proto.RepeatedField(proto.MESSAGE, number=8, message=LocationInfo,)
+ locations = proto.RepeatedField(proto.MESSAGE, number=8, message="LocationInfo",)
- properties = proto.RepeatedField(proto.MESSAGE, number=9, message=Property,)
+ properties = proto.RepeatedField(proto.MESSAGE, number=9, message="Property",)
class LocalizedObjectAnnotation(proto.Message):
@@ -556,7 +557,7 @@ class DominantColorsAnnotation(proto.Message):
fraction.
"""
- colors = proto.RepeatedField(proto.MESSAGE, number=1, message=ColorInfo,)
+ colors = proto.RepeatedField(proto.MESSAGE, number=1, message="ColorInfo",)
class ImageProperties(proto.Message):
@@ -569,7 +570,7 @@ class ImageProperties(proto.Message):
"""
dominant_colors = proto.Field(
- proto.MESSAGE, number=1, message=DominantColorsAnnotation,
+ proto.MESSAGE, number=1, message="DominantColorsAnnotation",
)
@@ -605,7 +606,7 @@ class CropHintsAnnotation(proto.Message):
Crop hint results.
"""
- crop_hints = proto.RepeatedField(proto.MESSAGE, number=1, message=CropHint,)
+ crop_hints = proto.RepeatedField(proto.MESSAGE, number=1, message="CropHint",)
class CropHintsParams(proto.Message):
@@ -638,6 +639,20 @@ class WebDetectionParams(proto.Message):
include_geo_results = proto.Field(proto.BOOL, number=2)
+class TextDetectionParams(proto.Message):
+ r"""Parameters for text detections. This is used to control
+ TEXT_DETECTION and DOCUMENT_TEXT_DETECTION features.
+
+ Attributes:
+ enable_text_detection_confidence_score (bool):
+ By default, Cloud Vision API only includes confidence score
+ for DOCUMENT_TEXT_DETECTION result. Set the flag to true to
+ include confidence score for TEXT_DETECTION as well.
+ """
+
+ enable_text_detection_confidence_score = proto.Field(proto.BOOL, number=9)
+
+
class ImageContext(proto.Message):
r"""Image context and/or feature-specific parameters.
@@ -663,13 +678,16 @@ class ImageContext(proto.Message):
Parameters for product search.
web_detection_params (~.image_annotator.WebDetectionParams):
Parameters for web detection.
+ text_detection_params (~.image_annotator.TextDetectionParams):
+ Parameters for text detection and document
+ text detection.
"""
- lat_long_rect = proto.Field(proto.MESSAGE, number=1, message=LatLongRect,)
+ lat_long_rect = proto.Field(proto.MESSAGE, number=1, message="LatLongRect",)
language_hints = proto.RepeatedField(proto.STRING, number=2)
- crop_hints_params = proto.Field(proto.MESSAGE, number=4, message=CropHintsParams,)
+ crop_hints_params = proto.Field(proto.MESSAGE, number=4, message="CropHintsParams",)
face_recognition_params = proto.Field(
proto.MESSAGE, number=10, message=face.FaceRecognitionParams,
@@ -680,7 +698,11 @@ class ImageContext(proto.Message):
)
web_detection_params = proto.Field(
- proto.MESSAGE, number=6, message=WebDetectionParams,
+ proto.MESSAGE, number=6, message="WebDetectionParams",
+ )
+
+ text_detection_params = proto.Field(
+ proto.MESSAGE, number=12, message="TextDetectionParams",
)
@@ -699,11 +721,11 @@ class AnnotateImageRequest(proto.Message):
image.
"""
- image = proto.Field(proto.MESSAGE, number=1, message=Image,)
+ image = proto.Field(proto.MESSAGE, number=1, message="Image",)
- features = proto.RepeatedField(proto.MESSAGE, number=2, message=Feature,)
+ features = proto.RepeatedField(proto.MESSAGE, number=2, message="Feature",)
- image_context = proto.Field(proto.MESSAGE, number=3, message=ImageContext,)
+ image_context = proto.Field(proto.MESSAGE, number=3, message="ImageContext",)
class ImageAnnotationContext(proto.Message):
@@ -778,27 +800,27 @@ class AnnotateImageResponse(proto.Message):
"""
face_annotations = proto.RepeatedField(
- proto.MESSAGE, number=1, message=FaceAnnotation,
+ proto.MESSAGE, number=1, message="FaceAnnotation",
)
landmark_annotations = proto.RepeatedField(
- proto.MESSAGE, number=2, message=EntityAnnotation,
+ proto.MESSAGE, number=2, message="EntityAnnotation",
)
logo_annotations = proto.RepeatedField(
- proto.MESSAGE, number=3, message=EntityAnnotation,
+ proto.MESSAGE, number=3, message="EntityAnnotation",
)
label_annotations = proto.RepeatedField(
- proto.MESSAGE, number=4, message=EntityAnnotation,
+ proto.MESSAGE, number=4, message="EntityAnnotation",
)
localized_object_annotations = proto.RepeatedField(
- proto.MESSAGE, number=22, message=LocalizedObjectAnnotation,
+ proto.MESSAGE, number=22, message="LocalizedObjectAnnotation",
)
text_annotations = proto.RepeatedField(
- proto.MESSAGE, number=5, message=EntityAnnotation,
+ proto.MESSAGE, number=5, message="EntityAnnotation",
)
full_text_annotation = proto.Field(
@@ -806,15 +828,15 @@ class AnnotateImageResponse(proto.Message):
)
safe_search_annotation = proto.Field(
- proto.MESSAGE, number=6, message=SafeSearchAnnotation,
+ proto.MESSAGE, number=6, message="SafeSearchAnnotation",
)
image_properties_annotation = proto.Field(
- proto.MESSAGE, number=8, message=ImageProperties,
+ proto.MESSAGE, number=8, message="ImageProperties",
)
crop_hints_annotation = proto.Field(
- proto.MESSAGE, number=11, message=CropHintsAnnotation,
+ proto.MESSAGE, number=11, message="CropHintsAnnotation",
)
web_detection = proto.Field(
@@ -827,7 +849,7 @@ class AnnotateImageResponse(proto.Message):
error = proto.Field(proto.MESSAGE, number=9, message=status.Status,)
- context = proto.Field(proto.MESSAGE, number=21, message=ImageAnnotationContext,)
+ context = proto.Field(proto.MESSAGE, number=21, message="ImageAnnotationContext",)
class BatchAnnotateImagesRequest(proto.Message):
@@ -841,7 +863,7 @@ class BatchAnnotateImagesRequest(proto.Message):
"""
requests = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AnnotateImageRequest,
+ proto.MESSAGE, number=1, message="AnnotateImageRequest",
)
@@ -855,7 +877,7 @@ class BatchAnnotateImagesResponse(proto.Message):
"""
responses = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AnnotateImageResponse,
+ proto.MESSAGE, number=1, message="AnnotateImageResponse",
)
@@ -891,9 +913,9 @@ class AnnotateFileRequest(proto.Message):
input_config = proto.Field(proto.MESSAGE, number=1, message="InputConfig",)
- features = proto.RepeatedField(proto.MESSAGE, number=2, message=Feature,)
+ features = proto.RepeatedField(proto.MESSAGE, number=2, message="Feature",)
- image_context = proto.Field(proto.MESSAGE, number=3, message=ImageContext,)
+ image_context = proto.Field(proto.MESSAGE, number=3, message="ImageContext",)
pages = proto.RepeatedField(proto.INT32, number=4)
@@ -921,7 +943,7 @@ class AnnotateFileResponse(proto.Message):
input_config = proto.Field(proto.MESSAGE, number=1, message="InputConfig",)
responses = proto.RepeatedField(
- proto.MESSAGE, number=2, message=AnnotateImageResponse,
+ proto.MESSAGE, number=2, message="AnnotateImageResponse",
)
total_pages = proto.Field(proto.INT32, number=3)
@@ -942,7 +964,7 @@ class BatchAnnotateFilesRequest(proto.Message):
"""
requests = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AnnotateFileRequest,
+ proto.MESSAGE, number=1, message="AnnotateFileRequest",
)
@@ -958,7 +980,7 @@ class BatchAnnotateFilesResponse(proto.Message):
"""
responses = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AnnotateFileResponse,
+ proto.MESSAGE, number=1, message="AnnotateFileResponse",
)
@@ -980,9 +1002,9 @@ class AsyncAnnotateFileRequest(proto.Message):
input_config = proto.Field(proto.MESSAGE, number=1, message="InputConfig",)
- features = proto.RepeatedField(proto.MESSAGE, number=2, message=Feature,)
+ features = proto.RepeatedField(proto.MESSAGE, number=2, message="Feature",)
- image_context = proto.Field(proto.MESSAGE, number=3, message=ImageContext,)
+ image_context = proto.Field(proto.MESSAGE, number=3, message="ImageContext",)
output_config = proto.Field(proto.MESSAGE, number=4, message="OutputConfig",)
@@ -1012,7 +1034,7 @@ class AsyncBatchAnnotateImagesRequest(proto.Message):
"""
requests = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AnnotateImageRequest,
+ proto.MESSAGE, number=1, message="AnnotateImageRequest",
)
output_config = proto.Field(proto.MESSAGE, number=2, message="OutputConfig",)
@@ -1041,7 +1063,7 @@ class AsyncBatchAnnotateFilesRequest(proto.Message):
"""
requests = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AsyncAnnotateFileRequest,
+ proto.MESSAGE, number=1, message="AsyncAnnotateFileRequest",
)
@@ -1056,7 +1078,7 @@ class AsyncBatchAnnotateFilesResponse(proto.Message):
"""
responses = proto.RepeatedField(
- proto.MESSAGE, number=1, message=AsyncAnnotateFileResponse,
+ proto.MESSAGE, number=1, message="AsyncAnnotateFileResponse",
)
diff --git a/google/cloud/vision_v1p4beta1/types/product_search_service.py b/google/cloud/vision_v1p4beta1/types/product_search_service.py
index 66a480f5..598c868d 100644
--- a/google/cloud/vision_v1p4beta1/types/product_search_service.py
+++ b/google/cloud/vision_v1p4beta1/types/product_search_service.py
@@ -238,7 +238,7 @@ class CreateProductRequest(proto.Message):
parent = proto.Field(proto.STRING, number=1)
- product = proto.Field(proto.MESSAGE, number=2, message=Product,)
+ product = proto.Field(proto.MESSAGE, number=2, message="Product",)
product_id = proto.Field(proto.STRING, number=3)
@@ -283,7 +283,7 @@ class ListProductsResponse(proto.Message):
def raw_page(self):
return self
- products = proto.RepeatedField(proto.MESSAGE, number=1, message=Product,)
+ products = proto.RepeatedField(proto.MESSAGE, number=1, message="Product",)
next_page_token = proto.Field(proto.STRING, number=2)
@@ -317,7 +317,7 @@ class UpdateProductRequest(proto.Message):
``product_labels``, ``display_name``, and ``description``.
"""
- product = proto.Field(proto.MESSAGE, number=1, message=Product,)
+ product = proto.Field(proto.MESSAGE, number=1, message="Product",)
update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,)
@@ -357,7 +357,7 @@ class CreateProductSetRequest(proto.Message):
parent = proto.Field(proto.STRING, number=1)
- product_set = proto.Field(proto.MESSAGE, number=2, message=ProductSet,)
+ product_set = proto.Field(proto.MESSAGE, number=2, message="ProductSet",)
product_set_id = proto.Field(proto.STRING, number=3)
@@ -402,7 +402,7 @@ class ListProductSetsResponse(proto.Message):
def raw_page(self):
return self
- product_sets = proto.RepeatedField(proto.MESSAGE, number=1, message=ProductSet,)
+ product_sets = proto.RepeatedField(proto.MESSAGE, number=1, message="ProductSet",)
next_page_token = proto.Field(proto.STRING, number=2)
@@ -435,7 +435,7 @@ class UpdateProductSetRequest(proto.Message):
``display_name``.
"""
- product_set = proto.Field(proto.MESSAGE, number=1, message=ProductSet,)
+ product_set = proto.Field(proto.MESSAGE, number=1, message="ProductSet",)
update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,)
@@ -477,7 +477,7 @@ class CreateReferenceImageRequest(proto.Message):
parent = proto.Field(proto.STRING, number=1)
- reference_image = proto.Field(proto.MESSAGE, number=2, message=ReferenceImage,)
+ reference_image = proto.Field(proto.MESSAGE, number=2, message="ReferenceImage",)
reference_image_id = proto.Field(proto.STRING, number=3)
@@ -529,7 +529,7 @@ def raw_page(self):
return self
reference_images = proto.RepeatedField(
- proto.MESSAGE, number=1, message=ReferenceImage,
+ proto.MESSAGE, number=1, message="ReferenceImage",
)
page_size = proto.Field(proto.INT32, number=2)
@@ -653,7 +653,7 @@ class ListProductsInProductSetResponse(proto.Message):
def raw_page(self):
return self
- products = proto.RepeatedField(proto.MESSAGE, number=1, message=Product,)
+ products = proto.RepeatedField(proto.MESSAGE, number=1, message="Product",)
next_page_token = proto.Field(proto.STRING, number=2)
@@ -753,7 +753,7 @@ class ImportProductSetsInputConfig(proto.Message):
"""
gcs_source = proto.Field(
- proto.MESSAGE, number=1, oneof="source", message=ImportProductSetsGcsSource,
+ proto.MESSAGE, number=1, oneof="source", message="ImportProductSetsGcsSource",
)
@@ -774,7 +774,7 @@ class ImportProductSetsRequest(proto.Message):
parent = proto.Field(proto.STRING, number=1)
input_config = proto.Field(
- proto.MESSAGE, number=2, message=ImportProductSetsInputConfig,
+ proto.MESSAGE, number=2, message="ImportProductSetsInputConfig",
)
@@ -801,7 +801,7 @@ class ImportProductSetsResponse(proto.Message):
"""
reference_images = proto.RepeatedField(
- proto.MESSAGE, number=1, message=ReferenceImage,
+ proto.MESSAGE, number=1, message="ReferenceImage",
)
statuses = proto.RepeatedField(proto.MESSAGE, number=2, message=status.Status,)
@@ -878,7 +878,7 @@ class PurgeProductsRequest(proto.Message):
"""
product_set_purge_config = proto.Field(
- proto.MESSAGE, number=2, oneof="target", message=ProductSetPurgeConfig,
+ proto.MESSAGE, number=2, oneof="target", message="ProductSetPurgeConfig",
)
delete_orphan_products = proto.Field(proto.BOOL, number=3, oneof="target")
diff --git a/google/cloud/vision_v1p4beta1/types/text_annotation.py b/google/cloud/vision_v1p4beta1/types/text_annotation.py
index f20e9a1a..25c4f0c9 100644
--- a/google/cloud/vision_v1p4beta1/types/text_annotation.py
+++ b/google/cloud/vision_v1p4beta1/types/text_annotation.py
@@ -129,7 +129,7 @@ class Page(proto.Message):
"""
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
width = proto.Field(proto.INT32, number=2)
@@ -193,7 +193,7 @@ class BlockType(proto.Enum):
BARCODE = 5
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
bounding_box = proto.Field(proto.MESSAGE, number=2, message=geometry.BoundingPoly,)
@@ -233,7 +233,7 @@ class Paragraph(proto.Message):
"""
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
bounding_box = proto.Field(proto.MESSAGE, number=2, message=geometry.BoundingPoly,)
@@ -270,7 +270,7 @@ class Word(proto.Message):
"""
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
bounding_box = proto.Field(proto.MESSAGE, number=2, message=geometry.BoundingPoly,)
@@ -307,7 +307,7 @@ class Symbol(proto.Message):
"""
property = proto.Field(
- proto.MESSAGE, number=1, message=TextAnnotation.TextProperty,
+ proto.MESSAGE, number=1, message="TextAnnotation.TextProperty",
)
bounding_box = proto.Field(proto.MESSAGE, number=2, message=geometry.BoundingPoly,)
diff --git a/noxfile.py b/noxfile.py
index c23dbf75..ed64181e 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -28,7 +28,7 @@
DEFAULT_PYTHON_VERSION = "3.8"
SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"]
-UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8"]
+UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"]
@nox.session(python=DEFAULT_PYTHON_VERSION)
@@ -72,16 +72,17 @@ def default(session):
# Install all test dependencies, then install this package in-place.
session.install("asyncmock", "pytest-asyncio")
- session.install("mock", "pytest", "pytest-cov")
+ session.install(
+ "mock", "pytest", "pytest-cov",
+ )
session.install("-e", ".")
# Run py.test against the unit tests.
session.run(
"py.test",
"--quiet",
- "--cov=google.cloud.vision",
- "--cov=google.cloud",
- "--cov=tests.unit",
+ "--cov=google/cloud",
+ "--cov=tests/unit",
"--cov-append",
"--cov-config=.coveragerc",
"--cov-report=",
diff --git a/samples/snippets/crop_hints/noxfile.py b/samples/snippets/crop_hints/noxfile.py
index ba55d7ce..bca0522e 100644
--- a/samples/snippets/crop_hints/noxfile.py
+++ b/samples/snippets/crop_hints/noxfile.py
@@ -17,6 +17,7 @@
import os
from pathlib import Path
import sys
+from typing import Callable, Dict, List, Optional
import nox
@@ -39,6 +40,10 @@
# You can opt out from the test for specific Python versions.
'ignored_versions': ["2.7"],
+ # Old samples are opted out of enforcing Python type hints
+ # All new samples should feature them
+ 'enforce_type_hints': False,
+
# An envvar key for determining the project id to use. Change it
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
# build specific Cloud project. You can also use your own string
@@ -64,7 +69,7 @@
TEST_CONFIG.update(TEST_CONFIG_OVERRIDE)
-def get_pytest_env_vars():
+def get_pytest_env_vars() -> Dict[str, str]:
"""Returns a dict for pytest invocation."""
ret = {}
@@ -93,7 +98,7 @@ def get_pytest_env_vars():
#
-def _determine_local_import_names(start_dir):
+def _determine_local_import_names(start_dir: str) -> List[str]:
"""Determines all import names that should be considered "local".
This is used when running the linter to insure that import order is
@@ -131,8 +136,11 @@ def _determine_local_import_names(start_dir):
@nox.session
-def lint(session):
- session.install("flake8", "flake8-import-order")
+def lint(session: nox.sessions.Session) -> None:
+ if not TEST_CONFIG['enforce_type_hints']:
+ session.install("flake8", "flake8-import-order")
+ else:
+ session.install("flake8", "flake8-import-order", "flake8-annotations")
local_names = _determine_local_import_names(".")
args = FLAKE8_COMMON_ARGS + [
@@ -141,8 +149,18 @@ def lint(session):
"."
]
session.run("flake8", *args)
+#
+# Black
+#
+@nox.session
+def blacken(session: nox.sessions.Session) -> None:
+ session.install("black")
+ python_files = [path for path in os.listdir(".") if path.endswith(".py")]
+
+ session.run("black", *python_files)
+
#
# Sample Tests
#
@@ -151,7 +169,7 @@ def lint(session):
PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"]
-def _session_tests(session, post_install=None):
+def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None:
"""Runs py.test for a particular project."""
if os.path.exists("requirements.txt"):
session.install("-r", "requirements.txt")
@@ -177,7 +195,7 @@ def _session_tests(session, post_install=None):
@nox.session(python=ALL_VERSIONS)
-def py(session):
+def py(session: nox.sessions.Session) -> None:
"""Runs py.test for a sample using the specified version of Python."""
if session.python in TESTED_VERSIONS:
_session_tests(session)
@@ -192,7 +210,7 @@ def py(session):
#
-def _get_repo_root():
+def _get_repo_root() -> Optional[str]:
""" Returns the root folder of the project. """
# Get root of this repository. Assume we don't have directories nested deeper than 10 items.
p = Path(os.getcwd())
@@ -201,6 +219,11 @@ def _get_repo_root():
break
if Path(p / ".git").exists():
return str(p)
+ # .git is not available in repos cloned via Cloud Build
+ # setup.py is always in the library's root, so use that instead
+ # https://github.com/googleapis/synthtool/issues/792
+ if Path(p / "setup.py").exists():
+ return str(p)
p = p.parent
raise Exception("Unable to detect repository root.")
@@ -210,7 +233,7 @@ def _get_repo_root():
@nox.session
@nox.parametrize("path", GENERATED_READMES)
-def readmegen(session, path):
+def readmegen(session: nox.sessions.Session, path: str) -> None:
"""(Re-)generates the readme for a sample."""
session.install("jinja2", "pyyaml")
dir_ = os.path.dirname(path)
diff --git a/samples/snippets/detect/noxfile.py b/samples/snippets/detect/noxfile.py
index ba55d7ce..bca0522e 100644
--- a/samples/snippets/detect/noxfile.py
+++ b/samples/snippets/detect/noxfile.py
@@ -17,6 +17,7 @@
import os
from pathlib import Path
import sys
+from typing import Callable, Dict, List, Optional
import nox
@@ -39,6 +40,10 @@
# You can opt out from the test for specific Python versions.
'ignored_versions': ["2.7"],
+ # Old samples are opted out of enforcing Python type hints
+ # All new samples should feature them
+ 'enforce_type_hints': False,
+
# An envvar key for determining the project id to use. Change it
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
# build specific Cloud project. You can also use your own string
@@ -64,7 +69,7 @@
TEST_CONFIG.update(TEST_CONFIG_OVERRIDE)
-def get_pytest_env_vars():
+def get_pytest_env_vars() -> Dict[str, str]:
"""Returns a dict for pytest invocation."""
ret = {}
@@ -93,7 +98,7 @@ def get_pytest_env_vars():
#
-def _determine_local_import_names(start_dir):
+def _determine_local_import_names(start_dir: str) -> List[str]:
"""Determines all import names that should be considered "local".
This is used when running the linter to insure that import order is
@@ -131,8 +136,11 @@ def _determine_local_import_names(start_dir):
@nox.session
-def lint(session):
- session.install("flake8", "flake8-import-order")
+def lint(session: nox.sessions.Session) -> None:
+ if not TEST_CONFIG['enforce_type_hints']:
+ session.install("flake8", "flake8-import-order")
+ else:
+ session.install("flake8", "flake8-import-order", "flake8-annotations")
local_names = _determine_local_import_names(".")
args = FLAKE8_COMMON_ARGS + [
@@ -141,8 +149,18 @@ def lint(session):
"."
]
session.run("flake8", *args)
+#
+# Black
+#
+@nox.session
+def blacken(session: nox.sessions.Session) -> None:
+ session.install("black")
+ python_files = [path for path in os.listdir(".") if path.endswith(".py")]
+
+ session.run("black", *python_files)
+
#
# Sample Tests
#
@@ -151,7 +169,7 @@ def lint(session):
PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"]
-def _session_tests(session, post_install=None):
+def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None:
"""Runs py.test for a particular project."""
if os.path.exists("requirements.txt"):
session.install("-r", "requirements.txt")
@@ -177,7 +195,7 @@ def _session_tests(session, post_install=None):
@nox.session(python=ALL_VERSIONS)
-def py(session):
+def py(session: nox.sessions.Session) -> None:
"""Runs py.test for a sample using the specified version of Python."""
if session.python in TESTED_VERSIONS:
_session_tests(session)
@@ -192,7 +210,7 @@ def py(session):
#
-def _get_repo_root():
+def _get_repo_root() -> Optional[str]:
""" Returns the root folder of the project. """
# Get root of this repository. Assume we don't have directories nested deeper than 10 items.
p = Path(os.getcwd())
@@ -201,6 +219,11 @@ def _get_repo_root():
break
if Path(p / ".git").exists():
return str(p)
+ # .git is not available in repos cloned via Cloud Build
+ # setup.py is always in the library's root, so use that instead
+ # https://github.com/googleapis/synthtool/issues/792
+ if Path(p / "setup.py").exists():
+ return str(p)
p = p.parent
raise Exception("Unable to detect repository root.")
@@ -210,7 +233,7 @@ def _get_repo_root():
@nox.session
@nox.parametrize("path", GENERATED_READMES)
-def readmegen(session, path):
+def readmegen(session: nox.sessions.Session, path: str) -> None:
"""(Re-)generates the readme for a sample."""
session.install("jinja2", "pyyaml")
dir_ = os.path.dirname(path)
diff --git a/samples/snippets/document_text/noxfile.py b/samples/snippets/document_text/noxfile.py
index ba55d7ce..bca0522e 100644
--- a/samples/snippets/document_text/noxfile.py
+++ b/samples/snippets/document_text/noxfile.py
@@ -17,6 +17,7 @@
import os
from pathlib import Path
import sys
+from typing import Callable, Dict, List, Optional
import nox
@@ -39,6 +40,10 @@
# You can opt out from the test for specific Python versions.
'ignored_versions': ["2.7"],
+ # Old samples are opted out of enforcing Python type hints
+ # All new samples should feature them
+ 'enforce_type_hints': False,
+
# An envvar key for determining the project id to use. Change it
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
# build specific Cloud project. You can also use your own string
@@ -64,7 +69,7 @@
TEST_CONFIG.update(TEST_CONFIG_OVERRIDE)
-def get_pytest_env_vars():
+def get_pytest_env_vars() -> Dict[str, str]:
"""Returns a dict for pytest invocation."""
ret = {}
@@ -93,7 +98,7 @@ def get_pytest_env_vars():
#
-def _determine_local_import_names(start_dir):
+def _determine_local_import_names(start_dir: str) -> List[str]:
"""Determines all import names that should be considered "local".
This is used when running the linter to insure that import order is
@@ -131,8 +136,11 @@ def _determine_local_import_names(start_dir):
@nox.session
-def lint(session):
- session.install("flake8", "flake8-import-order")
+def lint(session: nox.sessions.Session) -> None:
+ if not TEST_CONFIG['enforce_type_hints']:
+ session.install("flake8", "flake8-import-order")
+ else:
+ session.install("flake8", "flake8-import-order", "flake8-annotations")
local_names = _determine_local_import_names(".")
args = FLAKE8_COMMON_ARGS + [
@@ -141,8 +149,18 @@ def lint(session):
"."
]
session.run("flake8", *args)
+#
+# Black
+#
+@nox.session
+def blacken(session: nox.sessions.Session) -> None:
+ session.install("black")
+ python_files = [path for path in os.listdir(".") if path.endswith(".py")]
+
+ session.run("black", *python_files)
+
#
# Sample Tests
#
@@ -151,7 +169,7 @@ def lint(session):
PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"]
-def _session_tests(session, post_install=None):
+def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None:
"""Runs py.test for a particular project."""
if os.path.exists("requirements.txt"):
session.install("-r", "requirements.txt")
@@ -177,7 +195,7 @@ def _session_tests(session, post_install=None):
@nox.session(python=ALL_VERSIONS)
-def py(session):
+def py(session: nox.sessions.Session) -> None:
"""Runs py.test for a sample using the specified version of Python."""
if session.python in TESTED_VERSIONS:
_session_tests(session)
@@ -192,7 +210,7 @@ def py(session):
#
-def _get_repo_root():
+def _get_repo_root() -> Optional[str]:
""" Returns the root folder of the project. """
# Get root of this repository. Assume we don't have directories nested deeper than 10 items.
p = Path(os.getcwd())
@@ -201,6 +219,11 @@ def _get_repo_root():
break
if Path(p / ".git").exists():
return str(p)
+ # .git is not available in repos cloned via Cloud Build
+ # setup.py is always in the library's root, so use that instead
+ # https://github.com/googleapis/synthtool/issues/792
+ if Path(p / "setup.py").exists():
+ return str(p)
p = p.parent
raise Exception("Unable to detect repository root.")
@@ -210,7 +233,7 @@ def _get_repo_root():
@nox.session
@nox.parametrize("path", GENERATED_READMES)
-def readmegen(session, path):
+def readmegen(session: nox.sessions.Session, path: str) -> None:
"""(Re-)generates the readme for a sample."""
session.install("jinja2", "pyyaml")
dir_ = os.path.dirname(path)
diff --git a/samples/snippets/face_detection/noxfile.py b/samples/snippets/face_detection/noxfile.py
index ba55d7ce..bca0522e 100644
--- a/samples/snippets/face_detection/noxfile.py
+++ b/samples/snippets/face_detection/noxfile.py
@@ -17,6 +17,7 @@
import os
from pathlib import Path
import sys
+from typing import Callable, Dict, List, Optional
import nox
@@ -39,6 +40,10 @@
# You can opt out from the test for specific Python versions.
'ignored_versions': ["2.7"],
+ # Old samples are opted out of enforcing Python type hints
+ # All new samples should feature them
+ 'enforce_type_hints': False,
+
# An envvar key for determining the project id to use. Change it
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
# build specific Cloud project. You can also use your own string
@@ -64,7 +69,7 @@
TEST_CONFIG.update(TEST_CONFIG_OVERRIDE)
-def get_pytest_env_vars():
+def get_pytest_env_vars() -> Dict[str, str]:
"""Returns a dict for pytest invocation."""
ret = {}
@@ -93,7 +98,7 @@ def get_pytest_env_vars():
#
-def _determine_local_import_names(start_dir):
+def _determine_local_import_names(start_dir: str) -> List[str]:
"""Determines all import names that should be considered "local".
This is used when running the linter to insure that import order is
@@ -131,8 +136,11 @@ def _determine_local_import_names(start_dir):
@nox.session
-def lint(session):
- session.install("flake8", "flake8-import-order")
+def lint(session: nox.sessions.Session) -> None:
+ if not TEST_CONFIG['enforce_type_hints']:
+ session.install("flake8", "flake8-import-order")
+ else:
+ session.install("flake8", "flake8-import-order", "flake8-annotations")
local_names = _determine_local_import_names(".")
args = FLAKE8_COMMON_ARGS + [
@@ -141,8 +149,18 @@ def lint(session):
"."
]
session.run("flake8", *args)
+#
+# Black
+#
+@nox.session
+def blacken(session: nox.sessions.Session) -> None:
+ session.install("black")
+ python_files = [path for path in os.listdir(".") if path.endswith(".py")]
+
+ session.run("black", *python_files)
+
#
# Sample Tests
#
@@ -151,7 +169,7 @@ def lint(session):
PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"]
-def _session_tests(session, post_install=None):
+def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None:
"""Runs py.test for a particular project."""
if os.path.exists("requirements.txt"):
session.install("-r", "requirements.txt")
@@ -177,7 +195,7 @@ def _session_tests(session, post_install=None):
@nox.session(python=ALL_VERSIONS)
-def py(session):
+def py(session: nox.sessions.Session) -> None:
"""Runs py.test for a sample using the specified version of Python."""
if session.python in TESTED_VERSIONS:
_session_tests(session)
@@ -192,7 +210,7 @@ def py(session):
#
-def _get_repo_root():
+def _get_repo_root() -> Optional[str]:
""" Returns the root folder of the project. """
# Get root of this repository. Assume we don't have directories nested deeper than 10 items.
p = Path(os.getcwd())
@@ -201,6 +219,11 @@ def _get_repo_root():
break
if Path(p / ".git").exists():
return str(p)
+ # .git is not available in repos cloned via Cloud Build
+ # setup.py is always in the library's root, so use that instead
+ # https://github.com/googleapis/synthtool/issues/792
+ if Path(p / "setup.py").exists():
+ return str(p)
p = p.parent
raise Exception("Unable to detect repository root.")
@@ -210,7 +233,7 @@ def _get_repo_root():
@nox.session
@nox.parametrize("path", GENERATED_READMES)
-def readmegen(session, path):
+def readmegen(session: nox.sessions.Session, path: str) -> None:
"""(Re-)generates the readme for a sample."""
session.install("jinja2", "pyyaml")
dir_ = os.path.dirname(path)
diff --git a/samples/snippets/product_search/noxfile.py b/samples/snippets/product_search/noxfile.py
index ba55d7ce..bca0522e 100644
--- a/samples/snippets/product_search/noxfile.py
+++ b/samples/snippets/product_search/noxfile.py
@@ -17,6 +17,7 @@
import os
from pathlib import Path
import sys
+from typing import Callable, Dict, List, Optional
import nox
@@ -39,6 +40,10 @@
# You can opt out from the test for specific Python versions.
'ignored_versions': ["2.7"],
+ # Old samples are opted out of enforcing Python type hints
+ # All new samples should feature them
+ 'enforce_type_hints': False,
+
# An envvar key for determining the project id to use. Change it
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
# build specific Cloud project. You can also use your own string
@@ -64,7 +69,7 @@
TEST_CONFIG.update(TEST_CONFIG_OVERRIDE)
-def get_pytest_env_vars():
+def get_pytest_env_vars() -> Dict[str, str]:
"""Returns a dict for pytest invocation."""
ret = {}
@@ -93,7 +98,7 @@ def get_pytest_env_vars():
#
-def _determine_local_import_names(start_dir):
+def _determine_local_import_names(start_dir: str) -> List[str]:
"""Determines all import names that should be considered "local".
This is used when running the linter to insure that import order is
@@ -131,8 +136,11 @@ def _determine_local_import_names(start_dir):
@nox.session
-def lint(session):
- session.install("flake8", "flake8-import-order")
+def lint(session: nox.sessions.Session) -> None:
+ if not TEST_CONFIG['enforce_type_hints']:
+ session.install("flake8", "flake8-import-order")
+ else:
+ session.install("flake8", "flake8-import-order", "flake8-annotations")
local_names = _determine_local_import_names(".")
args = FLAKE8_COMMON_ARGS + [
@@ -141,8 +149,18 @@ def lint(session):
"."
]
session.run("flake8", *args)
+#
+# Black
+#
+@nox.session
+def blacken(session: nox.sessions.Session) -> None:
+ session.install("black")
+ python_files = [path for path in os.listdir(".") if path.endswith(".py")]
+
+ session.run("black", *python_files)
+
#
# Sample Tests
#
@@ -151,7 +169,7 @@ def lint(session):
PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"]
-def _session_tests(session, post_install=None):
+def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None:
"""Runs py.test for a particular project."""
if os.path.exists("requirements.txt"):
session.install("-r", "requirements.txt")
@@ -177,7 +195,7 @@ def _session_tests(session, post_install=None):
@nox.session(python=ALL_VERSIONS)
-def py(session):
+def py(session: nox.sessions.Session) -> None:
"""Runs py.test for a sample using the specified version of Python."""
if session.python in TESTED_VERSIONS:
_session_tests(session)
@@ -192,7 +210,7 @@ def py(session):
#
-def _get_repo_root():
+def _get_repo_root() -> Optional[str]:
""" Returns the root folder of the project. """
# Get root of this repository. Assume we don't have directories nested deeper than 10 items.
p = Path(os.getcwd())
@@ -201,6 +219,11 @@ def _get_repo_root():
break
if Path(p / ".git").exists():
return str(p)
+ # .git is not available in repos cloned via Cloud Build
+ # setup.py is always in the library's root, so use that instead
+ # https://github.com/googleapis/synthtool/issues/792
+ if Path(p / "setup.py").exists():
+ return str(p)
p = p.parent
raise Exception("Unable to detect repository root.")
@@ -210,7 +233,7 @@ def _get_repo_root():
@nox.session
@nox.parametrize("path", GENERATED_READMES)
-def readmegen(session, path):
+def readmegen(session: nox.sessions.Session, path: str) -> None:
"""(Re-)generates the readme for a sample."""
session.install("jinja2", "pyyaml")
dir_ = os.path.dirname(path)
diff --git a/samples/snippets/quickstart/noxfile.py b/samples/snippets/quickstart/noxfile.py
index ba55d7ce..bca0522e 100644
--- a/samples/snippets/quickstart/noxfile.py
+++ b/samples/snippets/quickstart/noxfile.py
@@ -17,6 +17,7 @@
import os
from pathlib import Path
import sys
+from typing import Callable, Dict, List, Optional
import nox
@@ -39,6 +40,10 @@
# You can opt out from the test for specific Python versions.
'ignored_versions': ["2.7"],
+ # Old samples are opted out of enforcing Python type hints
+ # All new samples should feature them
+ 'enforce_type_hints': False,
+
# An envvar key for determining the project id to use. Change it
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
# build specific Cloud project. You can also use your own string
@@ -64,7 +69,7 @@
TEST_CONFIG.update(TEST_CONFIG_OVERRIDE)
-def get_pytest_env_vars():
+def get_pytest_env_vars() -> Dict[str, str]:
"""Returns a dict for pytest invocation."""
ret = {}
@@ -93,7 +98,7 @@ def get_pytest_env_vars():
#
-def _determine_local_import_names(start_dir):
+def _determine_local_import_names(start_dir: str) -> List[str]:
"""Determines all import names that should be considered "local".
This is used when running the linter to insure that import order is
@@ -131,8 +136,11 @@ def _determine_local_import_names(start_dir):
@nox.session
-def lint(session):
- session.install("flake8", "flake8-import-order")
+def lint(session: nox.sessions.Session) -> None:
+ if not TEST_CONFIG['enforce_type_hints']:
+ session.install("flake8", "flake8-import-order")
+ else:
+ session.install("flake8", "flake8-import-order", "flake8-annotations")
local_names = _determine_local_import_names(".")
args = FLAKE8_COMMON_ARGS + [
@@ -141,8 +149,18 @@ def lint(session):
"."
]
session.run("flake8", *args)
+#
+# Black
+#
+@nox.session
+def blacken(session: nox.sessions.Session) -> None:
+ session.install("black")
+ python_files = [path for path in os.listdir(".") if path.endswith(".py")]
+
+ session.run("black", *python_files)
+
#
# Sample Tests
#
@@ -151,7 +169,7 @@ def lint(session):
PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"]
-def _session_tests(session, post_install=None):
+def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None:
"""Runs py.test for a particular project."""
if os.path.exists("requirements.txt"):
session.install("-r", "requirements.txt")
@@ -177,7 +195,7 @@ def _session_tests(session, post_install=None):
@nox.session(python=ALL_VERSIONS)
-def py(session):
+def py(session: nox.sessions.Session) -> None:
"""Runs py.test for a sample using the specified version of Python."""
if session.python in TESTED_VERSIONS:
_session_tests(session)
@@ -192,7 +210,7 @@ def py(session):
#
-def _get_repo_root():
+def _get_repo_root() -> Optional[str]:
""" Returns the root folder of the project. """
# Get root of this repository. Assume we don't have directories nested deeper than 10 items.
p = Path(os.getcwd())
@@ -201,6 +219,11 @@ def _get_repo_root():
break
if Path(p / ".git").exists():
return str(p)
+ # .git is not available in repos cloned via Cloud Build
+ # setup.py is always in the library's root, so use that instead
+ # https://github.com/googleapis/synthtool/issues/792
+ if Path(p / "setup.py").exists():
+ return str(p)
p = p.parent
raise Exception("Unable to detect repository root.")
@@ -210,7 +233,7 @@ def _get_repo_root():
@nox.session
@nox.parametrize("path", GENERATED_READMES)
-def readmegen(session, path):
+def readmegen(session: nox.sessions.Session, path: str) -> None:
"""(Re-)generates the readme for a sample."""
session.install("jinja2", "pyyaml")
dir_ = os.path.dirname(path)
diff --git a/samples/snippets/web/noxfile.py b/samples/snippets/web/noxfile.py
index ba55d7ce..bca0522e 100644
--- a/samples/snippets/web/noxfile.py
+++ b/samples/snippets/web/noxfile.py
@@ -17,6 +17,7 @@
import os
from pathlib import Path
import sys
+from typing import Callable, Dict, List, Optional
import nox
@@ -39,6 +40,10 @@
# You can opt out from the test for specific Python versions.
'ignored_versions': ["2.7"],
+ # Old samples are opted out of enforcing Python type hints
+ # All new samples should feature them
+ 'enforce_type_hints': False,
+
# An envvar key for determining the project id to use. Change it
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
# build specific Cloud project. You can also use your own string
@@ -64,7 +69,7 @@
TEST_CONFIG.update(TEST_CONFIG_OVERRIDE)
-def get_pytest_env_vars():
+def get_pytest_env_vars() -> Dict[str, str]:
"""Returns a dict for pytest invocation."""
ret = {}
@@ -93,7 +98,7 @@ def get_pytest_env_vars():
#
-def _determine_local_import_names(start_dir):
+def _determine_local_import_names(start_dir: str) -> List[str]:
"""Determines all import names that should be considered "local".
This is used when running the linter to insure that import order is
@@ -131,8 +136,11 @@ def _determine_local_import_names(start_dir):
@nox.session
-def lint(session):
- session.install("flake8", "flake8-import-order")
+def lint(session: nox.sessions.Session) -> None:
+ if not TEST_CONFIG['enforce_type_hints']:
+ session.install("flake8", "flake8-import-order")
+ else:
+ session.install("flake8", "flake8-import-order", "flake8-annotations")
local_names = _determine_local_import_names(".")
args = FLAKE8_COMMON_ARGS + [
@@ -141,8 +149,18 @@ def lint(session):
"."
]
session.run("flake8", *args)
+#
+# Black
+#
+@nox.session
+def blacken(session: nox.sessions.Session) -> None:
+ session.install("black")
+ python_files = [path for path in os.listdir(".") if path.endswith(".py")]
+
+ session.run("black", *python_files)
+
#
# Sample Tests
#
@@ -151,7 +169,7 @@ def lint(session):
PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"]
-def _session_tests(session, post_install=None):
+def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None:
"""Runs py.test for a particular project."""
if os.path.exists("requirements.txt"):
session.install("-r", "requirements.txt")
@@ -177,7 +195,7 @@ def _session_tests(session, post_install=None):
@nox.session(python=ALL_VERSIONS)
-def py(session):
+def py(session: nox.sessions.Session) -> None:
"""Runs py.test for a sample using the specified version of Python."""
if session.python in TESTED_VERSIONS:
_session_tests(session)
@@ -192,7 +210,7 @@ def py(session):
#
-def _get_repo_root():
+def _get_repo_root() -> Optional[str]:
""" Returns the root folder of the project. """
# Get root of this repository. Assume we don't have directories nested deeper than 10 items.
p = Path(os.getcwd())
@@ -201,6 +219,11 @@ def _get_repo_root():
break
if Path(p / ".git").exists():
return str(p)
+ # .git is not available in repos cloned via Cloud Build
+ # setup.py is always in the library's root, so use that instead
+ # https://github.com/googleapis/synthtool/issues/792
+ if Path(p / "setup.py").exists():
+ return str(p)
p = p.parent
raise Exception("Unable to detect repository root.")
@@ -210,7 +233,7 @@ def _get_repo_root():
@nox.session
@nox.parametrize("path", GENERATED_READMES)
-def readmegen(session, path):
+def readmegen(session: nox.sessions.Session, path: str) -> None:
"""(Re-)generates the readme for a sample."""
session.install("jinja2", "pyyaml")
dir_ = os.path.dirname(path)
diff --git a/synth.metadata b/synth.metadata
index 65ac2388..a3164259 100644
--- a/synth.metadata
+++ b/synth.metadata
@@ -4,21 +4,29 @@
"git": {
"name": ".",
"remote": "https://github.com/googleapis/python-vision.git",
- "sha": "a712e4055590022d6fdd748f07d9de773587eefe"
+ "sha": "c42a4e135a034a64c66522a56e1edc2eeda32ad4"
+ }
+ },
+ {
+ "git": {
+ "name": "googleapis",
+ "remote": "https://github.com/googleapis/googleapis.git",
+ "sha": "dd372aa22ded7a8ba6f0e03a80e06358a3fa0907",
+ "internalRef": "347055288"
}
},
{
"git": {
"name": "synthtool",
"remote": "https://github.com/googleapis/synthtool.git",
- "sha": "916c10e8581804df2b48a0f0457d848f3faa582e"
+ "sha": "18c5dbdb4ac8cf75d4d8174e7b4558f48e76f8a1"
}
},
{
"git": {
"name": "synthtool",
"remote": "https://github.com/googleapis/synthtool.git",
- "sha": "916c10e8581804df2b48a0f0457d848f3faa582e"
+ "sha": "18c5dbdb4ac8cf75d4d8174e7b4558f48e76f8a1"
}
}
],
@@ -68,5 +76,236 @@
"generator": "bazel"
}
}
+ ],
+ "generatedFiles": [
+ ".flake8",
+ ".github/CONTRIBUTING.md",
+ ".github/ISSUE_TEMPLATE/bug_report.md",
+ ".github/ISSUE_TEMPLATE/feature_request.md",
+ ".github/ISSUE_TEMPLATE/support_request.md",
+ ".github/PULL_REQUEST_TEMPLATE.md",
+ ".github/release-please.yml",
+ ".github/snippet-bot.yml",
+ ".gitignore",
+ ".kokoro/build.sh",
+ ".kokoro/continuous/common.cfg",
+ ".kokoro/continuous/continuous.cfg",
+ ".kokoro/docker/docs/Dockerfile",
+ ".kokoro/docker/docs/fetch_gpg_keys.sh",
+ ".kokoro/docs/common.cfg",
+ ".kokoro/docs/docs-presubmit.cfg",
+ ".kokoro/docs/docs.cfg",
+ ".kokoro/populate-secrets.sh",
+ ".kokoro/presubmit/common.cfg",
+ ".kokoro/presubmit/presubmit.cfg",
+ ".kokoro/publish-docs.sh",
+ ".kokoro/release.sh",
+ ".kokoro/release/common.cfg",
+ ".kokoro/release/release.cfg",
+ ".kokoro/samples/lint/common.cfg",
+ ".kokoro/samples/lint/continuous.cfg",
+ ".kokoro/samples/lint/periodic.cfg",
+ ".kokoro/samples/lint/presubmit.cfg",
+ ".kokoro/samples/python3.6/common.cfg",
+ ".kokoro/samples/python3.6/continuous.cfg",
+ ".kokoro/samples/python3.6/periodic.cfg",
+ ".kokoro/samples/python3.6/presubmit.cfg",
+ ".kokoro/samples/python3.7/common.cfg",
+ ".kokoro/samples/python3.7/continuous.cfg",
+ ".kokoro/samples/python3.7/periodic.cfg",
+ ".kokoro/samples/python3.7/presubmit.cfg",
+ ".kokoro/samples/python3.8/common.cfg",
+ ".kokoro/samples/python3.8/continuous.cfg",
+ ".kokoro/samples/python3.8/periodic.cfg",
+ ".kokoro/samples/python3.8/presubmit.cfg",
+ ".kokoro/test-samples.sh",
+ ".kokoro/trampoline.sh",
+ ".kokoro/trampoline_v2.sh",
+ ".pre-commit-config.yaml",
+ ".trampolinerc",
+ "CODE_OF_CONDUCT.md",
+ "CONTRIBUTING.rst",
+ "LICENSE",
+ "MANIFEST.in",
+ "docs/_static/custom.css",
+ "docs/_templates/layout.html",
+ "docs/conf.py",
+ "docs/multiprocessing.rst",
+ "docs/vision_v1/services.rst",
+ "docs/vision_v1/types.rst",
+ "docs/vision_v1p2beta1/services.rst",
+ "docs/vision_v1p2beta1/types.rst",
+ "docs/vision_v1p3beta1/services.rst",
+ "docs/vision_v1p3beta1/types.rst",
+ "docs/vision_v1p4beta1/services.rst",
+ "docs/vision_v1p4beta1/types.rst",
+ "google/cloud/vision/__init__.py",
+ "google/cloud/vision/py.typed",
+ "google/cloud/vision_v1/__init__.py",
+ "google/cloud/vision_v1/proto/geometry.proto",
+ "google/cloud/vision_v1/proto/image_annotator.proto",
+ "google/cloud/vision_v1/proto/product_search.proto",
+ "google/cloud/vision_v1/proto/product_search_service.proto",
+ "google/cloud/vision_v1/proto/text_annotation.proto",
+ "google/cloud/vision_v1/proto/web_detection.proto",
+ "google/cloud/vision_v1/py.typed",
+ "google/cloud/vision_v1/services/__init__.py",
+ "google/cloud/vision_v1/services/image_annotator/__init__.py",
+ "google/cloud/vision_v1/services/image_annotator/async_client.py",
+ "google/cloud/vision_v1/services/image_annotator/client.py",
+ "google/cloud/vision_v1/services/image_annotator/transports/__init__.py",
+ "google/cloud/vision_v1/services/image_annotator/transports/base.py",
+ "google/cloud/vision_v1/services/image_annotator/transports/grpc.py",
+ "google/cloud/vision_v1/services/image_annotator/transports/grpc_asyncio.py",
+ "google/cloud/vision_v1/services/product_search/__init__.py",
+ "google/cloud/vision_v1/services/product_search/async_client.py",
+ "google/cloud/vision_v1/services/product_search/client.py",
+ "google/cloud/vision_v1/services/product_search/pagers.py",
+ "google/cloud/vision_v1/services/product_search/transports/__init__.py",
+ "google/cloud/vision_v1/services/product_search/transports/base.py",
+ "google/cloud/vision_v1/services/product_search/transports/grpc.py",
+ "google/cloud/vision_v1/services/product_search/transports/grpc_asyncio.py",
+ "google/cloud/vision_v1/types/__init__.py",
+ "google/cloud/vision_v1/types/geometry.py",
+ "google/cloud/vision_v1/types/image_annotator.py",
+ "google/cloud/vision_v1/types/product_search.py",
+ "google/cloud/vision_v1/types/product_search_service.py",
+ "google/cloud/vision_v1/types/text_annotation.py",
+ "google/cloud/vision_v1/types/web_detection.py",
+ "google/cloud/vision_v1p1beta1/__init__.py",
+ "google/cloud/vision_v1p1beta1/proto/geometry.proto",
+ "google/cloud/vision_v1p1beta1/proto/image_annotator.proto",
+ "google/cloud/vision_v1p1beta1/proto/text_annotation.proto",
+ "google/cloud/vision_v1p1beta1/proto/web_detection.proto",
+ "google/cloud/vision_v1p1beta1/py.typed",
+ "google/cloud/vision_v1p1beta1/services/__init__.py",
+ "google/cloud/vision_v1p1beta1/services/image_annotator/__init__.py",
+ "google/cloud/vision_v1p1beta1/services/image_annotator/async_client.py",
+ "google/cloud/vision_v1p1beta1/services/image_annotator/client.py",
+ "google/cloud/vision_v1p1beta1/services/image_annotator/transports/__init__.py",
+ "google/cloud/vision_v1p1beta1/services/image_annotator/transports/base.py",
+ "google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc.py",
+ "google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc_asyncio.py",
+ "google/cloud/vision_v1p1beta1/types/__init__.py",
+ "google/cloud/vision_v1p1beta1/types/geometry.py",
+ "google/cloud/vision_v1p1beta1/types/image_annotator.py",
+ "google/cloud/vision_v1p1beta1/types/text_annotation.py",
+ "google/cloud/vision_v1p1beta1/types/web_detection.py",
+ "google/cloud/vision_v1p2beta1/__init__.py",
+ "google/cloud/vision_v1p2beta1/proto/geometry.proto",
+ "google/cloud/vision_v1p2beta1/proto/image_annotator.proto",
+ "google/cloud/vision_v1p2beta1/proto/text_annotation.proto",
+ "google/cloud/vision_v1p2beta1/proto/web_detection.proto",
+ "google/cloud/vision_v1p2beta1/py.typed",
+ "google/cloud/vision_v1p2beta1/services/__init__.py",
+ "google/cloud/vision_v1p2beta1/services/image_annotator/__init__.py",
+ "google/cloud/vision_v1p2beta1/services/image_annotator/async_client.py",
+ "google/cloud/vision_v1p2beta1/services/image_annotator/client.py",
+ "google/cloud/vision_v1p2beta1/services/image_annotator/transports/__init__.py",
+ "google/cloud/vision_v1p2beta1/services/image_annotator/transports/base.py",
+ "google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc.py",
+ "google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc_asyncio.py",
+ "google/cloud/vision_v1p2beta1/types/__init__.py",
+ "google/cloud/vision_v1p2beta1/types/geometry.py",
+ "google/cloud/vision_v1p2beta1/types/image_annotator.py",
+ "google/cloud/vision_v1p2beta1/types/text_annotation.py",
+ "google/cloud/vision_v1p2beta1/types/web_detection.py",
+ "google/cloud/vision_v1p3beta1/__init__.py",
+ "google/cloud/vision_v1p3beta1/proto/geometry.proto",
+ "google/cloud/vision_v1p3beta1/proto/image_annotator.proto",
+ "google/cloud/vision_v1p3beta1/proto/product_search.proto",
+ "google/cloud/vision_v1p3beta1/proto/product_search_service.proto",
+ "google/cloud/vision_v1p3beta1/proto/text_annotation.proto",
+ "google/cloud/vision_v1p3beta1/proto/web_detection.proto",
+ "google/cloud/vision_v1p3beta1/py.typed",
+ "google/cloud/vision_v1p3beta1/services/__init__.py",
+ "google/cloud/vision_v1p3beta1/services/image_annotator/__init__.py",
+ "google/cloud/vision_v1p3beta1/services/image_annotator/async_client.py",
+ "google/cloud/vision_v1p3beta1/services/image_annotator/client.py",
+ "google/cloud/vision_v1p3beta1/services/image_annotator/transports/__init__.py",
+ "google/cloud/vision_v1p3beta1/services/image_annotator/transports/base.py",
+ "google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc.py",
+ "google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc_asyncio.py",
+ "google/cloud/vision_v1p3beta1/services/product_search/__init__.py",
+ "google/cloud/vision_v1p3beta1/services/product_search/async_client.py",
+ "google/cloud/vision_v1p3beta1/services/product_search/client.py",
+ "google/cloud/vision_v1p3beta1/services/product_search/pagers.py",
+ "google/cloud/vision_v1p3beta1/services/product_search/transports/__init__.py",
+ "google/cloud/vision_v1p3beta1/services/product_search/transports/base.py",
+ "google/cloud/vision_v1p3beta1/services/product_search/transports/grpc.py",
+ "google/cloud/vision_v1p3beta1/services/product_search/transports/grpc_asyncio.py",
+ "google/cloud/vision_v1p3beta1/types/__init__.py",
+ "google/cloud/vision_v1p3beta1/types/geometry.py",
+ "google/cloud/vision_v1p3beta1/types/image_annotator.py",
+ "google/cloud/vision_v1p3beta1/types/product_search.py",
+ "google/cloud/vision_v1p3beta1/types/product_search_service.py",
+ "google/cloud/vision_v1p3beta1/types/text_annotation.py",
+ "google/cloud/vision_v1p3beta1/types/web_detection.py",
+ "google/cloud/vision_v1p4beta1/__init__.py",
+ "google/cloud/vision_v1p4beta1/proto/face.proto",
+ "google/cloud/vision_v1p4beta1/proto/geometry.proto",
+ "google/cloud/vision_v1p4beta1/proto/image_annotator.proto",
+ "google/cloud/vision_v1p4beta1/proto/product_search.proto",
+ "google/cloud/vision_v1p4beta1/proto/product_search_service.proto",
+ "google/cloud/vision_v1p4beta1/proto/text_annotation.proto",
+ "google/cloud/vision_v1p4beta1/proto/web_detection.proto",
+ "google/cloud/vision_v1p4beta1/py.typed",
+ "google/cloud/vision_v1p4beta1/services/__init__.py",
+ "google/cloud/vision_v1p4beta1/services/image_annotator/__init__.py",
+ "google/cloud/vision_v1p4beta1/services/image_annotator/async_client.py",
+ "google/cloud/vision_v1p4beta1/services/image_annotator/client.py",
+ "google/cloud/vision_v1p4beta1/services/image_annotator/transports/__init__.py",
+ "google/cloud/vision_v1p4beta1/services/image_annotator/transports/base.py",
+ "google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc.py",
+ "google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc_asyncio.py",
+ "google/cloud/vision_v1p4beta1/services/product_search/__init__.py",
+ "google/cloud/vision_v1p4beta1/services/product_search/async_client.py",
+ "google/cloud/vision_v1p4beta1/services/product_search/client.py",
+ "google/cloud/vision_v1p4beta1/services/product_search/pagers.py",
+ "google/cloud/vision_v1p4beta1/services/product_search/transports/__init__.py",
+ "google/cloud/vision_v1p4beta1/services/product_search/transports/base.py",
+ "google/cloud/vision_v1p4beta1/services/product_search/transports/grpc.py",
+ "google/cloud/vision_v1p4beta1/services/product_search/transports/grpc_asyncio.py",
+ "google/cloud/vision_v1p4beta1/types/__init__.py",
+ "google/cloud/vision_v1p4beta1/types/face.py",
+ "google/cloud/vision_v1p4beta1/types/geometry.py",
+ "google/cloud/vision_v1p4beta1/types/image_annotator.py",
+ "google/cloud/vision_v1p4beta1/types/product_search.py",
+ "google/cloud/vision_v1p4beta1/types/product_search_service.py",
+ "google/cloud/vision_v1p4beta1/types/text_annotation.py",
+ "google/cloud/vision_v1p4beta1/types/web_detection.py",
+ "noxfile.py",
+ "renovate.json",
+ "samples/AUTHORING_GUIDE.md",
+ "samples/CONTRIBUTING.md",
+ "samples/snippets/crop_hints/noxfile.py",
+ "samples/snippets/detect/noxfile.py",
+ "samples/snippets/document_text/noxfile.py",
+ "samples/snippets/face_detection/noxfile.py",
+ "samples/snippets/product_search/noxfile.py",
+ "samples/snippets/quickstart/noxfile.py",
+ "samples/snippets/web/noxfile.py",
+ "scripts/decrypt-secrets.sh",
+ "scripts/readme-gen/readme_gen.py",
+ "scripts/readme-gen/templates/README.tmpl.rst",
+ "scripts/readme-gen/templates/auth.tmpl.rst",
+ "scripts/readme-gen/templates/auth_api_key.tmpl.rst",
+ "scripts/readme-gen/templates/install_deps.tmpl.rst",
+ "scripts/readme-gen/templates/install_portaudio.tmpl.rst",
+ "setup.cfg",
+ "testing/.gitignore",
+ "tests/unit/gapic/vision_v1/__init__.py",
+ "tests/unit/gapic/vision_v1/test_image_annotator.py",
+ "tests/unit/gapic/vision_v1/test_product_search.py",
+ "tests/unit/gapic/vision_v1p1beta1/__init__.py",
+ "tests/unit/gapic/vision_v1p1beta1/test_image_annotator.py",
+ "tests/unit/gapic/vision_v1p2beta1/__init__.py",
+ "tests/unit/gapic/vision_v1p2beta1/test_image_annotator.py",
+ "tests/unit/gapic/vision_v1p3beta1/__init__.py",
+ "tests/unit/gapic/vision_v1p3beta1/test_image_annotator.py",
+ "tests/unit/gapic/vision_v1p3beta1/test_product_search.py",
+ "tests/unit/gapic/vision_v1p4beta1/__init__.py",
+ "tests/unit/gapic/vision_v1p4beta1/test_image_annotator.py",
+ "tests/unit/gapic/vision_v1p4beta1/test_product_search.py"
]
}
\ No newline at end of file
diff --git a/tests/unit/gapic/vision_v1/test_image_annotator.py b/tests/unit/gapic/vision_v1/test_image_annotator.py
index 908a6726..7e39be07 100644
--- a/tests/unit/gapic/vision_v1/test_image_annotator.py
+++ b/tests/unit/gapic/vision_v1/test_image_annotator.py
@@ -100,12 +100,12 @@ def test_image_annotator_client_from_service_account_file(client_class):
) as factory:
factory.return_value = creds
client = client_class.from_service_account_file("dummy/file/path.json")
- assert client._transport._credentials == creds
+ assert client.transport._credentials == creds
client = client_class.from_service_account_json("dummy/file/path.json")
- assert client._transport._credentials == creds
+ assert client.transport._credentials == creds
- assert client._transport._host == "vision.googleapis.com:443"
+ assert client.transport._host == "vision.googleapis.com:443"
def test_image_annotator_client_get_transport_class():
@@ -456,7 +456,7 @@ def test_batch_annotate_images(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.batch_annotate_images), "__call__"
+ type(client.transport.batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = image_annotator.BatchAnnotateImagesResponse()
@@ -470,6 +470,7 @@ def test_batch_annotate_images(
assert args[0] == image_annotator.BatchAnnotateImagesRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, image_annotator.BatchAnnotateImagesResponse)
@@ -478,18 +479,21 @@ def test_batch_annotate_images_from_dict():
@pytest.mark.asyncio
-async def test_batch_annotate_images_async(transport: str = "grpc_asyncio"):
+async def test_batch_annotate_images_async(
+ transport: str = "grpc_asyncio",
+ request_type=image_annotator.BatchAnnotateImagesRequest,
+):
client = ImageAnnotatorAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = image_annotator.BatchAnnotateImagesRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.batch_annotate_images), "__call__"
+ type(client.transport.batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -502,18 +506,23 @@ async def test_batch_annotate_images_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == image_annotator.BatchAnnotateImagesRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, image_annotator.BatchAnnotateImagesResponse)
+@pytest.mark.asyncio
+async def test_batch_annotate_images_async_from_dict():
+ await test_batch_annotate_images_async(request_type=dict)
+
+
def test_batch_annotate_images_flattened():
client = ImageAnnotatorClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.batch_annotate_images), "__call__"
+ type(client.transport.batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = image_annotator.BatchAnnotateImagesResponse()
@@ -562,7 +571,7 @@ async def test_batch_annotate_images_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.batch_annotate_images), "__call__"
+ type(client.transport.batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = image_annotator.BatchAnnotateImagesResponse()
@@ -622,7 +631,7 @@ def test_batch_annotate_files(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.batch_annotate_files), "__call__"
+ type(client.transport.batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = image_annotator.BatchAnnotateFilesResponse()
@@ -636,6 +645,7 @@ def test_batch_annotate_files(
assert args[0] == image_annotator.BatchAnnotateFilesRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, image_annotator.BatchAnnotateFilesResponse)
@@ -644,18 +654,21 @@ def test_batch_annotate_files_from_dict():
@pytest.mark.asyncio
-async def test_batch_annotate_files_async(transport: str = "grpc_asyncio"):
+async def test_batch_annotate_files_async(
+ transport: str = "grpc_asyncio",
+ request_type=image_annotator.BatchAnnotateFilesRequest,
+):
client = ImageAnnotatorAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = image_annotator.BatchAnnotateFilesRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.batch_annotate_files), "__call__"
+ type(client.transport.batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -668,18 +681,23 @@ async def test_batch_annotate_files_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == image_annotator.BatchAnnotateFilesRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, image_annotator.BatchAnnotateFilesResponse)
+@pytest.mark.asyncio
+async def test_batch_annotate_files_async_from_dict():
+ await test_batch_annotate_files_async(request_type=dict)
+
+
def test_batch_annotate_files_flattened():
client = ImageAnnotatorClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.batch_annotate_files), "__call__"
+ type(client.transport.batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = image_annotator.BatchAnnotateFilesResponse()
@@ -734,7 +752,7 @@ async def test_batch_annotate_files_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.batch_annotate_files), "__call__"
+ type(client.transport.batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = image_annotator.BatchAnnotateFilesResponse()
@@ -801,7 +819,7 @@ def test_async_batch_annotate_images(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.async_batch_annotate_images), "__call__"
+ type(client.transport.async_batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/spam")
@@ -823,18 +841,21 @@ def test_async_batch_annotate_images_from_dict():
@pytest.mark.asyncio
-async def test_async_batch_annotate_images_async(transport: str = "grpc_asyncio"):
+async def test_async_batch_annotate_images_async(
+ transport: str = "grpc_asyncio",
+ request_type=image_annotator.AsyncBatchAnnotateImagesRequest,
+):
client = ImageAnnotatorAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = image_annotator.AsyncBatchAnnotateImagesRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.async_batch_annotate_images), "__call__"
+ type(client.transport.async_batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -847,18 +868,23 @@ async def test_async_batch_annotate_images_async(transport: str = "grpc_asyncio"
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == image_annotator.AsyncBatchAnnotateImagesRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, future.Future)
+@pytest.mark.asyncio
+async def test_async_batch_annotate_images_async_from_dict():
+ await test_async_batch_annotate_images_async(request_type=dict)
+
+
def test_async_batch_annotate_images_flattened():
client = ImageAnnotatorClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.async_batch_annotate_images), "__call__"
+ type(client.transport.async_batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -917,7 +943,7 @@ async def test_async_batch_annotate_images_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.async_batch_annotate_images), "__call__"
+ type(client.transport.async_batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -987,7 +1013,7 @@ def test_async_batch_annotate_files(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.async_batch_annotate_files), "__call__"
+ type(client.transport.async_batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/spam")
@@ -1009,18 +1035,21 @@ def test_async_batch_annotate_files_from_dict():
@pytest.mark.asyncio
-async def test_async_batch_annotate_files_async(transport: str = "grpc_asyncio"):
+async def test_async_batch_annotate_files_async(
+ transport: str = "grpc_asyncio",
+ request_type=image_annotator.AsyncBatchAnnotateFilesRequest,
+):
client = ImageAnnotatorAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = image_annotator.AsyncBatchAnnotateFilesRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.async_batch_annotate_files), "__call__"
+ type(client.transport.async_batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -1033,18 +1062,23 @@ async def test_async_batch_annotate_files_async(transport: str = "grpc_asyncio")
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == image_annotator.AsyncBatchAnnotateFilesRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, future.Future)
+@pytest.mark.asyncio
+async def test_async_batch_annotate_files_async_from_dict():
+ await test_async_batch_annotate_files_async(request_type=dict)
+
+
def test_async_batch_annotate_files_flattened():
client = ImageAnnotatorClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.async_batch_annotate_files), "__call__"
+ type(client.transport.async_batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -1099,7 +1133,7 @@ async def test_async_batch_annotate_files_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.async_batch_annotate_files), "__call__"
+ type(client.transport.async_batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -1188,7 +1222,7 @@ def test_transport_instance():
credentials=credentials.AnonymousCredentials(),
)
client = ImageAnnotatorClient(transport=transport)
- assert client._transport is transport
+ assert client.transport is transport
def test_transport_get_channel():
@@ -1224,7 +1258,7 @@ def test_transport_adc(transport_class):
def test_transport_grpc_default():
# A client should use the gRPC transport by default.
client = ImageAnnotatorClient(credentials=credentials.AnonymousCredentials(),)
- assert isinstance(client._transport, transports.ImageAnnotatorGrpcTransport,)
+ assert isinstance(client.transport, transports.ImageAnnotatorGrpcTransport,)
def test_image_annotator_base_transport_error():
@@ -1335,7 +1369,7 @@ def test_image_annotator_host_no_port():
api_endpoint="vision.googleapis.com"
),
)
- assert client._transport._host == "vision.googleapis.com:443"
+ assert client.transport._host == "vision.googleapis.com:443"
def test_image_annotator_host_with_port():
@@ -1345,7 +1379,7 @@ def test_image_annotator_host_with_port():
api_endpoint="vision.googleapis.com:8000"
),
)
- assert client._transport._host == "vision.googleapis.com:8000"
+ assert client.transport._host == "vision.googleapis.com:8000"
def test_image_annotator_grpc_transport_channel():
@@ -1357,6 +1391,7 @@ def test_image_annotator_grpc_transport_channel():
)
assert transport.grpc_channel == channel
assert transport._host == "squid.clam.whelk:443"
+ assert transport._ssl_channel_credentials == None
def test_image_annotator_grpc_asyncio_transport_channel():
@@ -1368,6 +1403,7 @@ def test_image_annotator_grpc_asyncio_transport_channel():
)
assert transport.grpc_channel == channel
assert transport._host == "squid.clam.whelk:443"
+ assert transport._ssl_channel_credentials == None
@pytest.mark.parametrize(
@@ -1416,8 +1452,13 @@ def test_image_annotator_transport_channel_mtls_with_client_cert_source(
),
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
assert transport.grpc_channel == mock_grpc_channel
+ assert transport._ssl_channel_credentials == mock_ssl_cred
@pytest.mark.parametrize(
@@ -1459,6 +1500,10 @@ def test_image_annotator_transport_channel_mtls_with_adc(transport_class):
),
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
assert transport.grpc_channel == mock_grpc_channel
@@ -1467,7 +1512,7 @@ def test_image_annotator_grpc_lro_client():
client = ImageAnnotatorClient(
credentials=credentials.AnonymousCredentials(), transport="grpc",
)
- transport = client._transport
+ transport = client.transport
# Ensure that we have a api-core operations client.
assert isinstance(transport.operations_client, operations_v1.OperationsClient,)
@@ -1480,7 +1525,7 @@ def test_image_annotator_grpc_lro_async_client():
client = ImageAnnotatorAsyncClient(
credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio",
)
- transport = client._client._transport
+ transport = client.transport
# Ensure that we have a api-core operations client.
assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,)
@@ -1489,6 +1534,157 @@ def test_image_annotator_grpc_lro_async_client():
assert transport.operations_client is transport.operations_client
+def test_product_path():
+ project = "squid"
+ location = "clam"
+ product = "whelk"
+
+ expected = "projects/{project}/locations/{location}/products/{product}".format(
+ project=project, location=location, product=product,
+ )
+ actual = ImageAnnotatorClient.product_path(project, location, product)
+ assert expected == actual
+
+
+def test_parse_product_path():
+ expected = {
+ "project": "octopus",
+ "location": "oyster",
+ "product": "nudibranch",
+ }
+ path = ImageAnnotatorClient.product_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_product_path(path)
+ assert expected == actual
+
+
+def test_product_set_path():
+ project = "cuttlefish"
+ location = "mussel"
+ product_set = "winkle"
+
+ expected = "projects/{project}/locations/{location}/productSets/{product_set}".format(
+ project=project, location=location, product_set=product_set,
+ )
+ actual = ImageAnnotatorClient.product_set_path(project, location, product_set)
+ assert expected == actual
+
+
+def test_parse_product_set_path():
+ expected = {
+ "project": "nautilus",
+ "location": "scallop",
+ "product_set": "abalone",
+ }
+ path = ImageAnnotatorClient.product_set_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_product_set_path(path)
+ assert expected == actual
+
+
+def test_common_billing_account_path():
+ billing_account = "squid"
+
+ expected = "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+ actual = ImageAnnotatorClient.common_billing_account_path(billing_account)
+ assert expected == actual
+
+
+def test_parse_common_billing_account_path():
+ expected = {
+ "billing_account": "clam",
+ }
+ path = ImageAnnotatorClient.common_billing_account_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_billing_account_path(path)
+ assert expected == actual
+
+
+def test_common_folder_path():
+ folder = "whelk"
+
+ expected = "folders/{folder}".format(folder=folder,)
+ actual = ImageAnnotatorClient.common_folder_path(folder)
+ assert expected == actual
+
+
+def test_parse_common_folder_path():
+ expected = {
+ "folder": "octopus",
+ }
+ path = ImageAnnotatorClient.common_folder_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_folder_path(path)
+ assert expected == actual
+
+
+def test_common_organization_path():
+ organization = "oyster"
+
+ expected = "organizations/{organization}".format(organization=organization,)
+ actual = ImageAnnotatorClient.common_organization_path(organization)
+ assert expected == actual
+
+
+def test_parse_common_organization_path():
+ expected = {
+ "organization": "nudibranch",
+ }
+ path = ImageAnnotatorClient.common_organization_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_organization_path(path)
+ assert expected == actual
+
+
+def test_common_project_path():
+ project = "cuttlefish"
+
+ expected = "projects/{project}".format(project=project,)
+ actual = ImageAnnotatorClient.common_project_path(project)
+ assert expected == actual
+
+
+def test_parse_common_project_path():
+ expected = {
+ "project": "mussel",
+ }
+ path = ImageAnnotatorClient.common_project_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_project_path(path)
+ assert expected == actual
+
+
+def test_common_location_path():
+ project = "winkle"
+ location = "nautilus"
+
+ expected = "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+ actual = ImageAnnotatorClient.common_location_path(project, location)
+ assert expected == actual
+
+
+def test_parse_common_location_path():
+ expected = {
+ "project": "scallop",
+ "location": "abalone",
+ }
+ path = ImageAnnotatorClient.common_location_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_location_path(path)
+ assert expected == actual
+
+
def test_client_withDEFAULT_CLIENT_INFO():
client_info = gapic_v1.client_info.ClientInfo()
diff --git a/tests/unit/gapic/vision_v1/test_product_search.py b/tests/unit/gapic/vision_v1/test_product_search.py
index 2d15b41f..52c594c3 100644
--- a/tests/unit/gapic/vision_v1/test_product_search.py
+++ b/tests/unit/gapic/vision_v1/test_product_search.py
@@ -103,12 +103,12 @@ def test_product_search_client_from_service_account_file(client_class):
) as factory:
factory.return_value = creds
client = client_class.from_service_account_file("dummy/file/path.json")
- assert client._transport._credentials == creds
+ assert client.transport._credentials == creds
client = client_class.from_service_account_json("dummy/file/path.json")
- assert client._transport._credentials == creds
+ assert client.transport._credentials == creds
- assert client._transport._host == "vision.googleapis.com:443"
+ assert client.transport._host == "vision.googleapis.com:443"
def test_product_search_client_get_transport_class():
@@ -459,7 +459,7 @@ def test_create_product_set(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.create_product_set), "__call__"
+ type(client.transport.create_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet(
@@ -475,6 +475,7 @@ def test_create_product_set(
assert args[0] == product_search_service.CreateProductSetRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.ProductSet)
assert response.name == "name_value"
@@ -487,18 +488,21 @@ def test_create_product_set_from_dict():
@pytest.mark.asyncio
-async def test_create_product_set_async(transport: str = "grpc_asyncio"):
+async def test_create_product_set_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.CreateProductSetRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.CreateProductSetRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.create_product_set), "__call__"
+ type(client.transport.create_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -513,7 +517,7 @@ async def test_create_product_set_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.CreateProductSetRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.ProductSet)
@@ -523,6 +527,11 @@ async def test_create_product_set_async(transport: str = "grpc_asyncio"):
assert response.display_name == "display_name_value"
+@pytest.mark.asyncio
+async def test_create_product_set_async_from_dict():
+ await test_create_product_set_async(request_type=dict)
+
+
def test_create_product_set_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -533,7 +542,7 @@ def test_create_product_set_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.create_product_set), "__call__"
+ type(client.transport.create_product_set), "__call__"
) as call:
call.return_value = product_search_service.ProductSet()
@@ -560,7 +569,7 @@ async def test_create_product_set_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.create_product_set), "__call__"
+ type(client.transport.create_product_set), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ProductSet()
@@ -583,7 +592,7 @@ def test_create_product_set_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.create_product_set), "__call__"
+ type(client.transport.create_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet()
@@ -630,7 +639,7 @@ async def test_create_product_set_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.create_product_set), "__call__"
+ type(client.transport.create_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet()
@@ -688,7 +697,7 @@ def test_list_product_sets(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductSetsResponse(
@@ -704,6 +713,7 @@ def test_list_product_sets(
assert args[0] == product_search_service.ListProductSetsRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, pagers.ListProductSetsPager)
assert response.next_page_token == "next_page_token_value"
@@ -714,18 +724,21 @@ def test_list_product_sets_from_dict():
@pytest.mark.asyncio
-async def test_list_product_sets_async(transport: str = "grpc_asyncio"):
+async def test_list_product_sets_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.ListProductSetsRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.ListProductSetsRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -740,7 +753,7 @@ async def test_list_product_sets_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.ListProductSetsRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, pagers.ListProductSetsAsyncPager)
@@ -748,6 +761,11 @@ async def test_list_product_sets_async(transport: str = "grpc_asyncio"):
assert response.next_page_token == "next_page_token_value"
+@pytest.mark.asyncio
+async def test_list_product_sets_async_from_dict():
+ await test_list_product_sets_async(request_type=dict)
+
+
def test_list_product_sets_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -758,7 +776,7 @@ def test_list_product_sets_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
call.return_value = product_search_service.ListProductSetsResponse()
@@ -785,7 +803,7 @@ async def test_list_product_sets_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ListProductSetsResponse()
@@ -808,7 +826,7 @@ def test_list_product_sets_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductSetsResponse()
@@ -842,7 +860,7 @@ async def test_list_product_sets_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductSetsResponse()
@@ -879,7 +897,7 @@ def test_list_product_sets_pager():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -925,7 +943,7 @@ def test_list_product_sets_pages():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -963,7 +981,7 @@ async def test_list_product_sets_async_pager():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_product_sets),
+ type(client.transport.list_product_sets),
"__call__",
new_callable=mock.AsyncMock,
) as call:
@@ -1008,7 +1026,7 @@ async def test_list_product_sets_async_pages():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_product_sets),
+ type(client.transport.list_product_sets),
"__call__",
new_callable=mock.AsyncMock,
) as call:
@@ -1056,7 +1074,7 @@ def test_get_product_set(
request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.get_product_set), "__call__") as call:
+ with mock.patch.object(type(client.transport.get_product_set), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet(
name="name_value", display_name="display_name_value",
@@ -1071,6 +1089,7 @@ def test_get_product_set(
assert args[0] == product_search_service.GetProductSetRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.ProductSet)
assert response.name == "name_value"
@@ -1083,19 +1102,20 @@ def test_get_product_set_from_dict():
@pytest.mark.asyncio
-async def test_get_product_set_async(transport: str = "grpc_asyncio"):
+async def test_get_product_set_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.GetProductSetRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.GetProductSetRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.get_product_set), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.get_product_set), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ProductSet(
@@ -1109,7 +1129,7 @@ async def test_get_product_set_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.GetProductSetRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.ProductSet)
@@ -1119,6 +1139,11 @@ async def test_get_product_set_async(transport: str = "grpc_asyncio"):
assert response.display_name == "display_name_value"
+@pytest.mark.asyncio
+async def test_get_product_set_async_from_dict():
+ await test_get_product_set_async(request_type=dict)
+
+
def test_get_product_set_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -1128,7 +1153,7 @@ def test_get_product_set_field_headers():
request.name = "name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.get_product_set), "__call__") as call:
+ with mock.patch.object(type(client.transport.get_product_set), "__call__") as call:
call.return_value = product_search_service.ProductSet()
client.get_product_set(request)
@@ -1153,9 +1178,7 @@ async def test_get_product_set_field_headers_async():
request.name = "name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.get_product_set), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.get_product_set), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ProductSet()
)
@@ -1176,7 +1199,7 @@ def test_get_product_set_flattened():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.get_product_set), "__call__") as call:
+ with mock.patch.object(type(client.transport.get_product_set), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet()
@@ -1208,9 +1231,7 @@ async def test_get_product_set_flattened_async():
client = ProductSearchAsyncClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.get_product_set), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.get_product_set), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet()
@@ -1254,7 +1275,7 @@ def test_update_product_set(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.update_product_set), "__call__"
+ type(client.transport.update_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet(
@@ -1270,6 +1291,7 @@ def test_update_product_set(
assert args[0] == product_search_service.UpdateProductSetRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.ProductSet)
assert response.name == "name_value"
@@ -1282,18 +1304,21 @@ def test_update_product_set_from_dict():
@pytest.mark.asyncio
-async def test_update_product_set_async(transport: str = "grpc_asyncio"):
+async def test_update_product_set_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.UpdateProductSetRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.UpdateProductSetRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.update_product_set), "__call__"
+ type(client.transport.update_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -1308,7 +1333,7 @@ async def test_update_product_set_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.UpdateProductSetRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.ProductSet)
@@ -1318,6 +1343,11 @@ async def test_update_product_set_async(transport: str = "grpc_asyncio"):
assert response.display_name == "display_name_value"
+@pytest.mark.asyncio
+async def test_update_product_set_async_from_dict():
+ await test_update_product_set_async(request_type=dict)
+
+
def test_update_product_set_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -1328,7 +1358,7 @@ def test_update_product_set_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.update_product_set), "__call__"
+ type(client.transport.update_product_set), "__call__"
) as call:
call.return_value = product_search_service.ProductSet()
@@ -1357,7 +1387,7 @@ async def test_update_product_set_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.update_product_set), "__call__"
+ type(client.transport.update_product_set), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ProductSet()
@@ -1382,7 +1412,7 @@ def test_update_product_set_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.update_product_set), "__call__"
+ type(client.transport.update_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet()
@@ -1425,7 +1455,7 @@ async def test_update_product_set_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.update_product_set), "__call__"
+ type(client.transport.update_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet()
@@ -1479,7 +1509,7 @@ def test_delete_product_set(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.delete_product_set), "__call__"
+ type(client.transport.delete_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -1501,18 +1531,21 @@ def test_delete_product_set_from_dict():
@pytest.mark.asyncio
-async def test_delete_product_set_async(transport: str = "grpc_asyncio"):
+async def test_delete_product_set_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.DeleteProductSetRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.DeleteProductSetRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.delete_product_set), "__call__"
+ type(client.transport.delete_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -1523,12 +1556,17 @@ async def test_delete_product_set_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.DeleteProductSetRequest()
# Establish that the response is the type that we expect.
assert response is None
+@pytest.mark.asyncio
+async def test_delete_product_set_async_from_dict():
+ await test_delete_product_set_async(request_type=dict)
+
+
def test_delete_product_set_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -1539,7 +1577,7 @@ def test_delete_product_set_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.delete_product_set), "__call__"
+ type(client.transport.delete_product_set), "__call__"
) as call:
call.return_value = None
@@ -1566,7 +1604,7 @@ async def test_delete_product_set_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.delete_product_set), "__call__"
+ type(client.transport.delete_product_set), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -1587,7 +1625,7 @@ def test_delete_product_set_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.delete_product_set), "__call__"
+ type(client.transport.delete_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -1621,7 +1659,7 @@ async def test_delete_product_set_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.delete_product_set), "__call__"
+ type(client.transport.delete_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -1663,7 +1701,7 @@ def test_create_product(
request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.create_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.create_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product(
name="name_value",
@@ -1681,6 +1719,7 @@ def test_create_product(
assert args[0] == product_search_service.CreateProductRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.Product)
assert response.name == "name_value"
@@ -1697,19 +1736,20 @@ def test_create_product_from_dict():
@pytest.mark.asyncio
-async def test_create_product_async(transport: str = "grpc_asyncio"):
+async def test_create_product_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.CreateProductRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.CreateProductRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.create_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.create_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.Product(
@@ -1726,7 +1766,7 @@ async def test_create_product_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.CreateProductRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.Product)
@@ -1740,6 +1780,11 @@ async def test_create_product_async(transport: str = "grpc_asyncio"):
assert response.product_category == "product_category_value"
+@pytest.mark.asyncio
+async def test_create_product_async_from_dict():
+ await test_create_product_async(request_type=dict)
+
+
def test_create_product_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -1749,7 +1794,7 @@ def test_create_product_field_headers():
request.parent = "parent/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.create_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.create_product), "__call__") as call:
call.return_value = product_search_service.Product()
client.create_product(request)
@@ -1774,9 +1819,7 @@ async def test_create_product_field_headers_async():
request.parent = "parent/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.create_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.create_product), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.Product()
)
@@ -1797,7 +1840,7 @@ def test_create_product_flattened():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.create_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.create_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product()
@@ -1840,9 +1883,7 @@ async def test_create_product_flattened_async():
client = ProductSearchAsyncClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.create_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.create_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product()
@@ -1896,7 +1937,7 @@ def test_list_products(
request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.list_products), "__call__") as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductsResponse(
next_page_token="next_page_token_value",
@@ -1911,6 +1952,7 @@ def test_list_products(
assert args[0] == product_search_service.ListProductsRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, pagers.ListProductsPager)
assert response.next_page_token == "next_page_token_value"
@@ -1921,19 +1963,20 @@ def test_list_products_from_dict():
@pytest.mark.asyncio
-async def test_list_products_async(transport: str = "grpc_asyncio"):
+async def test_list_products_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.ListProductsRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.ListProductsRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.list_products), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ListProductsResponse(
@@ -1947,7 +1990,7 @@ async def test_list_products_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.ListProductsRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, pagers.ListProductsAsyncPager)
@@ -1955,6 +1998,11 @@ async def test_list_products_async(transport: str = "grpc_asyncio"):
assert response.next_page_token == "next_page_token_value"
+@pytest.mark.asyncio
+async def test_list_products_async_from_dict():
+ await test_list_products_async(request_type=dict)
+
+
def test_list_products_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -1964,7 +2012,7 @@ def test_list_products_field_headers():
request.parent = "parent/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.list_products), "__call__") as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
call.return_value = product_search_service.ListProductsResponse()
client.list_products(request)
@@ -1989,9 +2037,7 @@ async def test_list_products_field_headers_async():
request.parent = "parent/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.list_products), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ListProductsResponse()
)
@@ -2012,7 +2058,7 @@ def test_list_products_flattened():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.list_products), "__call__") as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductsResponse()
@@ -2044,9 +2090,7 @@ async def test_list_products_flattened_async():
client = ProductSearchAsyncClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.list_products), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductsResponse()
@@ -2081,7 +2125,7 @@ def test_list_products_pager():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials,)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.list_products), "__call__") as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
# Set the response to a series of pages.
call.side_effect = (
product_search_service.ListProductsResponse(
@@ -2124,7 +2168,7 @@ def test_list_products_pages():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials,)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.list_products), "__call__") as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
# Set the response to a series of pages.
call.side_effect = (
product_search_service.ListProductsResponse(
@@ -2160,9 +2204,7 @@ async def test_list_products_async_pager():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_products),
- "__call__",
- new_callable=mock.AsyncMock,
+ type(client.transport.list_products), "__call__", new_callable=mock.AsyncMock
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -2204,9 +2246,7 @@ async def test_list_products_async_pages():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_products),
- "__call__",
- new_callable=mock.AsyncMock,
+ type(client.transport.list_products), "__call__", new_callable=mock.AsyncMock
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -2251,7 +2291,7 @@ def test_get_product(
request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.get_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.get_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product(
name="name_value",
@@ -2269,6 +2309,7 @@ def test_get_product(
assert args[0] == product_search_service.GetProductRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.Product)
assert response.name == "name_value"
@@ -2285,19 +2326,20 @@ def test_get_product_from_dict():
@pytest.mark.asyncio
-async def test_get_product_async(transport: str = "grpc_asyncio"):
+async def test_get_product_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.GetProductRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.GetProductRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.get_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.get_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.Product(
@@ -2314,7 +2356,7 @@ async def test_get_product_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.GetProductRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.Product)
@@ -2328,6 +2370,11 @@ async def test_get_product_async(transport: str = "grpc_asyncio"):
assert response.product_category == "product_category_value"
+@pytest.mark.asyncio
+async def test_get_product_async_from_dict():
+ await test_get_product_async(request_type=dict)
+
+
def test_get_product_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -2337,7 +2384,7 @@ def test_get_product_field_headers():
request.name = "name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.get_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.get_product), "__call__") as call:
call.return_value = product_search_service.Product()
client.get_product(request)
@@ -2362,9 +2409,7 @@ async def test_get_product_field_headers_async():
request.name = "name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.get_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.get_product), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.Product()
)
@@ -2385,7 +2430,7 @@ def test_get_product_flattened():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.get_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.get_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product()
@@ -2417,9 +2462,7 @@ async def test_get_product_flattened_async():
client = ProductSearchAsyncClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.get_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.get_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product()
@@ -2462,7 +2505,7 @@ def test_update_product(
request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.update_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.update_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product(
name="name_value",
@@ -2480,6 +2523,7 @@ def test_update_product(
assert args[0] == product_search_service.UpdateProductRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.Product)
assert response.name == "name_value"
@@ -2496,19 +2540,20 @@ def test_update_product_from_dict():
@pytest.mark.asyncio
-async def test_update_product_async(transport: str = "grpc_asyncio"):
+async def test_update_product_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.UpdateProductRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.UpdateProductRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.update_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.update_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.Product(
@@ -2525,7 +2570,7 @@ async def test_update_product_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.UpdateProductRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.Product)
@@ -2539,6 +2584,11 @@ async def test_update_product_async(transport: str = "grpc_asyncio"):
assert response.product_category == "product_category_value"
+@pytest.mark.asyncio
+async def test_update_product_async_from_dict():
+ await test_update_product_async(request_type=dict)
+
+
def test_update_product_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -2548,7 +2598,7 @@ def test_update_product_field_headers():
request.product.name = "product.name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.update_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.update_product), "__call__") as call:
call.return_value = product_search_service.Product()
client.update_product(request)
@@ -2575,9 +2625,7 @@ async def test_update_product_field_headers_async():
request.product.name = "product.name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.update_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.update_product), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.Product()
)
@@ -2600,7 +2648,7 @@ def test_update_product_flattened():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.update_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.update_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product()
@@ -2639,9 +2687,7 @@ async def test_update_product_flattened_async():
client = ProductSearchAsyncClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.update_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.update_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product()
@@ -2691,7 +2737,7 @@ def test_delete_product(
request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.delete_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.delete_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -2712,19 +2758,20 @@ def test_delete_product_from_dict():
@pytest.mark.asyncio
-async def test_delete_product_async(transport: str = "grpc_asyncio"):
+async def test_delete_product_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.DeleteProductRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.DeleteProductRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.delete_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.delete_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -2734,12 +2781,17 @@ async def test_delete_product_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.DeleteProductRequest()
# Establish that the response is the type that we expect.
assert response is None
+@pytest.mark.asyncio
+async def test_delete_product_async_from_dict():
+ await test_delete_product_async(request_type=dict)
+
+
def test_delete_product_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -2749,7 +2801,7 @@ def test_delete_product_field_headers():
request.name = "name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.delete_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.delete_product), "__call__") as call:
call.return_value = None
client.delete_product(request)
@@ -2774,9 +2826,7 @@ async def test_delete_product_field_headers_async():
request.name = "name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.delete_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.delete_product), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
await client.delete_product(request)
@@ -2795,7 +2845,7 @@ def test_delete_product_flattened():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.delete_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.delete_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -2827,9 +2877,7 @@ async def test_delete_product_flattened_async():
client = ProductSearchAsyncClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.delete_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.delete_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -2872,7 +2920,7 @@ def test_create_reference_image(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.create_reference_image), "__call__"
+ type(client.transport.create_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ReferenceImage(
@@ -2888,6 +2936,7 @@ def test_create_reference_image(
assert args[0] == product_search_service.CreateReferenceImageRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.ReferenceImage)
assert response.name == "name_value"
@@ -2900,18 +2949,21 @@ def test_create_reference_image_from_dict():
@pytest.mark.asyncio
-async def test_create_reference_image_async(transport: str = "grpc_asyncio"):
+async def test_create_reference_image_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.CreateReferenceImageRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.CreateReferenceImageRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.create_reference_image), "__call__"
+ type(client.transport.create_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -2924,7 +2976,7 @@ async def test_create_reference_image_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.CreateReferenceImageRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.ReferenceImage)
@@ -2934,6 +2986,11 @@ async def test_create_reference_image_async(transport: str = "grpc_asyncio"):
assert response.uri == "uri_value"
+@pytest.mark.asyncio
+async def test_create_reference_image_async_from_dict():
+ await test_create_reference_image_async(request_type=dict)
+
+
def test_create_reference_image_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -2944,7 +3001,7 @@ def test_create_reference_image_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.create_reference_image), "__call__"
+ type(client.transport.create_reference_image), "__call__"
) as call:
call.return_value = product_search_service.ReferenceImage()
@@ -2971,7 +3028,7 @@ async def test_create_reference_image_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.create_reference_image), "__call__"
+ type(client.transport.create_reference_image), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ReferenceImage()
@@ -2994,7 +3051,7 @@ def test_create_reference_image_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.create_reference_image), "__call__"
+ type(client.transport.create_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ReferenceImage()
@@ -3041,7 +3098,7 @@ async def test_create_reference_image_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.create_reference_image), "__call__"
+ type(client.transport.create_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ReferenceImage()
@@ -3100,7 +3157,7 @@ def test_delete_reference_image(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.delete_reference_image), "__call__"
+ type(client.transport.delete_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -3122,18 +3179,21 @@ def test_delete_reference_image_from_dict():
@pytest.mark.asyncio
-async def test_delete_reference_image_async(transport: str = "grpc_asyncio"):
+async def test_delete_reference_image_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.DeleteReferenceImageRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.DeleteReferenceImageRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.delete_reference_image), "__call__"
+ type(client.transport.delete_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -3144,12 +3204,17 @@ async def test_delete_reference_image_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.DeleteReferenceImageRequest()
# Establish that the response is the type that we expect.
assert response is None
+@pytest.mark.asyncio
+async def test_delete_reference_image_async_from_dict():
+ await test_delete_reference_image_async(request_type=dict)
+
+
def test_delete_reference_image_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -3160,7 +3225,7 @@ def test_delete_reference_image_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.delete_reference_image), "__call__"
+ type(client.transport.delete_reference_image), "__call__"
) as call:
call.return_value = None
@@ -3187,7 +3252,7 @@ async def test_delete_reference_image_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.delete_reference_image), "__call__"
+ type(client.transport.delete_reference_image), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -3208,7 +3273,7 @@ def test_delete_reference_image_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.delete_reference_image), "__call__"
+ type(client.transport.delete_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -3242,7 +3307,7 @@ async def test_delete_reference_image_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.delete_reference_image), "__call__"
+ type(client.transport.delete_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -3286,7 +3351,7 @@ def test_list_reference_images(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListReferenceImagesResponse(
@@ -3302,6 +3367,7 @@ def test_list_reference_images(
assert args[0] == product_search_service.ListReferenceImagesRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, pagers.ListReferenceImagesPager)
assert response.page_size == 951
@@ -3314,18 +3380,21 @@ def test_list_reference_images_from_dict():
@pytest.mark.asyncio
-async def test_list_reference_images_async(transport: str = "grpc_asyncio"):
+async def test_list_reference_images_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.ListReferenceImagesRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.ListReferenceImagesRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -3340,7 +3409,7 @@ async def test_list_reference_images_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.ListReferenceImagesRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, pagers.ListReferenceImagesAsyncPager)
@@ -3350,6 +3419,11 @@ async def test_list_reference_images_async(transport: str = "grpc_asyncio"):
assert response.next_page_token == "next_page_token_value"
+@pytest.mark.asyncio
+async def test_list_reference_images_async_from_dict():
+ await test_list_reference_images_async(request_type=dict)
+
+
def test_list_reference_images_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -3360,7 +3434,7 @@ def test_list_reference_images_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
call.return_value = product_search_service.ListReferenceImagesResponse()
@@ -3387,7 +3461,7 @@ async def test_list_reference_images_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ListReferenceImagesResponse()
@@ -3410,7 +3484,7 @@ def test_list_reference_images_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListReferenceImagesResponse()
@@ -3444,7 +3518,7 @@ async def test_list_reference_images_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListReferenceImagesResponse()
@@ -3481,7 +3555,7 @@ def test_list_reference_images_pager():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -3529,7 +3603,7 @@ def test_list_reference_images_pages():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -3567,7 +3641,7 @@ async def test_list_reference_images_async_pager():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_reference_images),
+ type(client.transport.list_reference_images),
"__call__",
new_callable=mock.AsyncMock,
) as call:
@@ -3614,7 +3688,7 @@ async def test_list_reference_images_async_pages():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_reference_images),
+ type(client.transport.list_reference_images),
"__call__",
new_callable=mock.AsyncMock,
) as call:
@@ -3664,7 +3738,7 @@ def test_get_reference_image(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.get_reference_image), "__call__"
+ type(client.transport.get_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ReferenceImage(
@@ -3680,6 +3754,7 @@ def test_get_reference_image(
assert args[0] == product_search_service.GetReferenceImageRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.ReferenceImage)
assert response.name == "name_value"
@@ -3692,18 +3767,21 @@ def test_get_reference_image_from_dict():
@pytest.mark.asyncio
-async def test_get_reference_image_async(transport: str = "grpc_asyncio"):
+async def test_get_reference_image_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.GetReferenceImageRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.GetReferenceImageRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.get_reference_image), "__call__"
+ type(client.transport.get_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -3716,7 +3794,7 @@ async def test_get_reference_image_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.GetReferenceImageRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.ReferenceImage)
@@ -3726,6 +3804,11 @@ async def test_get_reference_image_async(transport: str = "grpc_asyncio"):
assert response.uri == "uri_value"
+@pytest.mark.asyncio
+async def test_get_reference_image_async_from_dict():
+ await test_get_reference_image_async(request_type=dict)
+
+
def test_get_reference_image_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -3736,7 +3819,7 @@ def test_get_reference_image_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.get_reference_image), "__call__"
+ type(client.transport.get_reference_image), "__call__"
) as call:
call.return_value = product_search_service.ReferenceImage()
@@ -3763,7 +3846,7 @@ async def test_get_reference_image_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.get_reference_image), "__call__"
+ type(client.transport.get_reference_image), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ReferenceImage()
@@ -3786,7 +3869,7 @@ def test_get_reference_image_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.get_reference_image), "__call__"
+ type(client.transport.get_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ReferenceImage()
@@ -3820,7 +3903,7 @@ async def test_get_reference_image_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.get_reference_image), "__call__"
+ type(client.transport.get_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ReferenceImage()
@@ -3866,7 +3949,7 @@ def test_add_product_to_product_set(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.add_product_to_product_set), "__call__"
+ type(client.transport.add_product_to_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -3888,18 +3971,21 @@ def test_add_product_to_product_set_from_dict():
@pytest.mark.asyncio
-async def test_add_product_to_product_set_async(transport: str = "grpc_asyncio"):
+async def test_add_product_to_product_set_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.AddProductToProductSetRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.AddProductToProductSetRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.add_product_to_product_set), "__call__"
+ type(client.transport.add_product_to_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -3910,12 +3996,17 @@ async def test_add_product_to_product_set_async(transport: str = "grpc_asyncio")
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.AddProductToProductSetRequest()
# Establish that the response is the type that we expect.
assert response is None
+@pytest.mark.asyncio
+async def test_add_product_to_product_set_async_from_dict():
+ await test_add_product_to_product_set_async(request_type=dict)
+
+
def test_add_product_to_product_set_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -3926,7 +4017,7 @@ def test_add_product_to_product_set_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.add_product_to_product_set), "__call__"
+ type(client.transport.add_product_to_product_set), "__call__"
) as call:
call.return_value = None
@@ -3953,7 +4044,7 @@ async def test_add_product_to_product_set_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.add_product_to_product_set), "__call__"
+ type(client.transport.add_product_to_product_set), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -3974,7 +4065,7 @@ def test_add_product_to_product_set_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.add_product_to_product_set), "__call__"
+ type(client.transport.add_product_to_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -4014,7 +4105,7 @@ async def test_add_product_to_product_set_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.add_product_to_product_set), "__call__"
+ type(client.transport.add_product_to_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -4064,7 +4155,7 @@ def test_remove_product_from_product_set(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.remove_product_from_product_set), "__call__"
+ type(client.transport.remove_product_from_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -4086,18 +4177,21 @@ def test_remove_product_from_product_set_from_dict():
@pytest.mark.asyncio
-async def test_remove_product_from_product_set_async(transport: str = "grpc_asyncio"):
+async def test_remove_product_from_product_set_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.RemoveProductFromProductSetRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.RemoveProductFromProductSetRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.remove_product_from_product_set), "__call__"
+ type(client.transport.remove_product_from_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -4108,12 +4202,17 @@ async def test_remove_product_from_product_set_async(transport: str = "grpc_asyn
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.RemoveProductFromProductSetRequest()
# Establish that the response is the type that we expect.
assert response is None
+@pytest.mark.asyncio
+async def test_remove_product_from_product_set_async_from_dict():
+ await test_remove_product_from_product_set_async(request_type=dict)
+
+
def test_remove_product_from_product_set_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -4124,7 +4223,7 @@ def test_remove_product_from_product_set_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.remove_product_from_product_set), "__call__"
+ type(client.transport.remove_product_from_product_set), "__call__"
) as call:
call.return_value = None
@@ -4151,7 +4250,7 @@ async def test_remove_product_from_product_set_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.remove_product_from_product_set), "__call__"
+ type(client.transport.remove_product_from_product_set), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -4172,7 +4271,7 @@ def test_remove_product_from_product_set_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.remove_product_from_product_set), "__call__"
+ type(client.transport.remove_product_from_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -4212,7 +4311,7 @@ async def test_remove_product_from_product_set_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.remove_product_from_product_set), "__call__"
+ type(client.transport.remove_product_from_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -4262,7 +4361,7 @@ def test_list_products_in_product_set(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductsInProductSetResponse(
@@ -4278,6 +4377,7 @@ def test_list_products_in_product_set(
assert args[0] == product_search_service.ListProductsInProductSetRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, pagers.ListProductsInProductSetPager)
assert response.next_page_token == "next_page_token_value"
@@ -4288,18 +4388,21 @@ def test_list_products_in_product_set_from_dict():
@pytest.mark.asyncio
-async def test_list_products_in_product_set_async(transport: str = "grpc_asyncio"):
+async def test_list_products_in_product_set_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.ListProductsInProductSetRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.ListProductsInProductSetRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -4314,7 +4417,7 @@ async def test_list_products_in_product_set_async(transport: str = "grpc_asyncio
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.ListProductsInProductSetRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, pagers.ListProductsInProductSetAsyncPager)
@@ -4322,6 +4425,11 @@ async def test_list_products_in_product_set_async(transport: str = "grpc_asyncio
assert response.next_page_token == "next_page_token_value"
+@pytest.mark.asyncio
+async def test_list_products_in_product_set_async_from_dict():
+ await test_list_products_in_product_set_async(request_type=dict)
+
+
def test_list_products_in_product_set_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -4332,7 +4440,7 @@ def test_list_products_in_product_set_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
call.return_value = product_search_service.ListProductsInProductSetResponse()
@@ -4359,7 +4467,7 @@ async def test_list_products_in_product_set_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ListProductsInProductSetResponse()
@@ -4382,7 +4490,7 @@ def test_list_products_in_product_set_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductsInProductSetResponse()
@@ -4416,7 +4524,7 @@ async def test_list_products_in_product_set_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductsInProductSetResponse()
@@ -4453,7 +4561,7 @@ def test_list_products_in_product_set_pager():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -4498,7 +4606,7 @@ def test_list_products_in_product_set_pages():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -4535,7 +4643,7 @@ async def test_list_products_in_product_set_async_pager():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_products_in_product_set),
+ type(client.transport.list_products_in_product_set),
"__call__",
new_callable=mock.AsyncMock,
) as call:
@@ -4579,7 +4687,7 @@ async def test_list_products_in_product_set_async_pages():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_products_in_product_set),
+ type(client.transport.list_products_in_product_set),
"__call__",
new_callable=mock.AsyncMock,
) as call:
@@ -4630,7 +4738,7 @@ def test_import_product_sets(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.import_product_sets), "__call__"
+ type(client.transport.import_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/spam")
@@ -4652,18 +4760,21 @@ def test_import_product_sets_from_dict():
@pytest.mark.asyncio
-async def test_import_product_sets_async(transport: str = "grpc_asyncio"):
+async def test_import_product_sets_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.ImportProductSetsRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.ImportProductSetsRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.import_product_sets), "__call__"
+ type(client.transport.import_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -4676,12 +4787,17 @@ async def test_import_product_sets_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.ImportProductSetsRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, future.Future)
+@pytest.mark.asyncio
+async def test_import_product_sets_async_from_dict():
+ await test_import_product_sets_async(request_type=dict)
+
+
def test_import_product_sets_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -4692,7 +4808,7 @@ def test_import_product_sets_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.import_product_sets), "__call__"
+ type(client.transport.import_product_sets), "__call__"
) as call:
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -4719,7 +4835,7 @@ async def test_import_product_sets_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.import_product_sets), "__call__"
+ type(client.transport.import_product_sets), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
operations_pb2.Operation(name="operations/op")
@@ -4742,7 +4858,7 @@ def test_import_product_sets_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.import_product_sets), "__call__"
+ type(client.transport.import_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -4797,7 +4913,7 @@ async def test_import_product_sets_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.import_product_sets), "__call__"
+ type(client.transport.import_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -4862,7 +4978,7 @@ def test_purge_products(
request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.purge_products), "__call__") as call:
+ with mock.patch.object(type(client.transport.purge_products), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/spam")
@@ -4883,19 +4999,20 @@ def test_purge_products_from_dict():
@pytest.mark.asyncio
-async def test_purge_products_async(transport: str = "grpc_asyncio"):
+async def test_purge_products_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.PurgeProductsRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.PurgeProductsRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.purge_products), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.purge_products), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
operations_pb2.Operation(name="operations/spam")
@@ -4907,12 +5024,17 @@ async def test_purge_products_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.PurgeProductsRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, future.Future)
+@pytest.mark.asyncio
+async def test_purge_products_async_from_dict():
+ await test_purge_products_async(request_type=dict)
+
+
def test_purge_products_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -4922,7 +5044,7 @@ def test_purge_products_field_headers():
request.parent = "parent/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.purge_products), "__call__") as call:
+ with mock.patch.object(type(client.transport.purge_products), "__call__") as call:
call.return_value = operations_pb2.Operation(name="operations/op")
client.purge_products(request)
@@ -4947,9 +5069,7 @@ async def test_purge_products_field_headers_async():
request.parent = "parent/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.purge_products), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.purge_products), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
operations_pb2.Operation(name="operations/op")
)
@@ -4970,7 +5090,7 @@ def test_purge_products_flattened():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.purge_products), "__call__") as call:
+ with mock.patch.object(type(client.transport.purge_products), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -5002,9 +5122,7 @@ async def test_purge_products_flattened_async():
client = ProductSearchAsyncClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.purge_products), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.purge_products), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -5071,7 +5189,7 @@ def test_transport_instance():
credentials=credentials.AnonymousCredentials(),
)
client = ProductSearchClient(transport=transport)
- assert client._transport is transport
+ assert client.transport is transport
def test_transport_get_channel():
@@ -5107,7 +5225,7 @@ def test_transport_adc(transport_class):
def test_transport_grpc_default():
# A client should use the gRPC transport by default.
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
- assert isinstance(client._transport, transports.ProductSearchGrpcTransport,)
+ assert isinstance(client.transport, transports.ProductSearchGrpcTransport,)
def test_product_search_base_transport_error():
@@ -5233,7 +5351,7 @@ def test_product_search_host_no_port():
api_endpoint="vision.googleapis.com"
),
)
- assert client._transport._host == "vision.googleapis.com:443"
+ assert client.transport._host == "vision.googleapis.com:443"
def test_product_search_host_with_port():
@@ -5243,7 +5361,7 @@ def test_product_search_host_with_port():
api_endpoint="vision.googleapis.com:8000"
),
)
- assert client._transport._host == "vision.googleapis.com:8000"
+ assert client.transport._host == "vision.googleapis.com:8000"
def test_product_search_grpc_transport_channel():
@@ -5255,6 +5373,7 @@ def test_product_search_grpc_transport_channel():
)
assert transport.grpc_channel == channel
assert transport._host == "squid.clam.whelk:443"
+ assert transport._ssl_channel_credentials == None
def test_product_search_grpc_asyncio_transport_channel():
@@ -5266,6 +5385,7 @@ def test_product_search_grpc_asyncio_transport_channel():
)
assert transport.grpc_channel == channel
assert transport._host == "squid.clam.whelk:443"
+ assert transport._ssl_channel_credentials == None
@pytest.mark.parametrize(
@@ -5312,8 +5432,13 @@ def test_product_search_transport_channel_mtls_with_client_cert_source(transport
),
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
assert transport.grpc_channel == mock_grpc_channel
+ assert transport._ssl_channel_credentials == mock_ssl_cred
@pytest.mark.parametrize(
@@ -5355,6 +5480,10 @@ def test_product_search_transport_channel_mtls_with_adc(transport_class):
),
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
assert transport.grpc_channel == mock_grpc_channel
@@ -5363,7 +5492,7 @@ def test_product_search_grpc_lro_client():
client = ProductSearchClient(
credentials=credentials.AnonymousCredentials(), transport="grpc",
)
- transport = client._transport
+ transport = client.transport
# Ensure that we have a api-core operations client.
assert isinstance(transport.operations_client, operations_v1.OperationsClient,)
@@ -5376,7 +5505,7 @@ def test_product_search_grpc_lro_async_client():
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio",
)
- transport = client._client._transport
+ transport = client.transport
# Ensure that we have a api-core operations client.
assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,)
@@ -5411,9 +5540,9 @@ def test_parse_product_path():
def test_product_set_path():
- project = "squid"
- location = "clam"
- product_set = "whelk"
+ project = "cuttlefish"
+ location = "mussel"
+ product_set = "winkle"
expected = "projects/{project}/locations/{location}/productSets/{product_set}".format(
project=project, location=location, product_set=product_set,
@@ -5424,9 +5553,9 @@ def test_product_set_path():
def test_parse_product_set_path():
expected = {
- "project": "octopus",
- "location": "oyster",
- "product_set": "nudibranch",
+ "project": "nautilus",
+ "location": "scallop",
+ "product_set": "abalone",
}
path = ProductSearchClient.product_set_path(**expected)
@@ -5467,6 +5596,107 @@ def test_parse_reference_image_path():
assert expected == actual
+def test_common_billing_account_path():
+ billing_account = "winkle"
+
+ expected = "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+ actual = ProductSearchClient.common_billing_account_path(billing_account)
+ assert expected == actual
+
+
+def test_parse_common_billing_account_path():
+ expected = {
+ "billing_account": "nautilus",
+ }
+ path = ProductSearchClient.common_billing_account_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ProductSearchClient.parse_common_billing_account_path(path)
+ assert expected == actual
+
+
+def test_common_folder_path():
+ folder = "scallop"
+
+ expected = "folders/{folder}".format(folder=folder,)
+ actual = ProductSearchClient.common_folder_path(folder)
+ assert expected == actual
+
+
+def test_parse_common_folder_path():
+ expected = {
+ "folder": "abalone",
+ }
+ path = ProductSearchClient.common_folder_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ProductSearchClient.parse_common_folder_path(path)
+ assert expected == actual
+
+
+def test_common_organization_path():
+ organization = "squid"
+
+ expected = "organizations/{organization}".format(organization=organization,)
+ actual = ProductSearchClient.common_organization_path(organization)
+ assert expected == actual
+
+
+def test_parse_common_organization_path():
+ expected = {
+ "organization": "clam",
+ }
+ path = ProductSearchClient.common_organization_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ProductSearchClient.parse_common_organization_path(path)
+ assert expected == actual
+
+
+def test_common_project_path():
+ project = "whelk"
+
+ expected = "projects/{project}".format(project=project,)
+ actual = ProductSearchClient.common_project_path(project)
+ assert expected == actual
+
+
+def test_parse_common_project_path():
+ expected = {
+ "project": "octopus",
+ }
+ path = ProductSearchClient.common_project_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ProductSearchClient.parse_common_project_path(path)
+ assert expected == actual
+
+
+def test_common_location_path():
+ project = "oyster"
+ location = "nudibranch"
+
+ expected = "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+ actual = ProductSearchClient.common_location_path(project, location)
+ assert expected == actual
+
+
+def test_parse_common_location_path():
+ expected = {
+ "project": "cuttlefish",
+ "location": "mussel",
+ }
+ path = ProductSearchClient.common_location_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ProductSearchClient.parse_common_location_path(path)
+ assert expected == actual
+
+
def test_client_withDEFAULT_CLIENT_INFO():
client_info = gapic_v1.client_info.ClientInfo()
diff --git a/tests/unit/gapic/vision_v1p1beta1/test_image_annotator.py b/tests/unit/gapic/vision_v1p1beta1/test_image_annotator.py
index 18280372..4ee68cf4 100644
--- a/tests/unit/gapic/vision_v1p1beta1/test_image_annotator.py
+++ b/tests/unit/gapic/vision_v1p1beta1/test_image_annotator.py
@@ -96,12 +96,12 @@ def test_image_annotator_client_from_service_account_file(client_class):
) as factory:
factory.return_value = creds
client = client_class.from_service_account_file("dummy/file/path.json")
- assert client._transport._credentials == creds
+ assert client.transport._credentials == creds
client = client_class.from_service_account_json("dummy/file/path.json")
- assert client._transport._credentials == creds
+ assert client.transport._credentials == creds
- assert client._transport._host == "vision.googleapis.com:443"
+ assert client.transport._host == "vision.googleapis.com:443"
def test_image_annotator_client_get_transport_class():
@@ -452,7 +452,7 @@ def test_batch_annotate_images(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.batch_annotate_images), "__call__"
+ type(client.transport.batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = image_annotator.BatchAnnotateImagesResponse()
@@ -466,6 +466,7 @@ def test_batch_annotate_images(
assert args[0] == image_annotator.BatchAnnotateImagesRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, image_annotator.BatchAnnotateImagesResponse)
@@ -474,18 +475,21 @@ def test_batch_annotate_images_from_dict():
@pytest.mark.asyncio
-async def test_batch_annotate_images_async(transport: str = "grpc_asyncio"):
+async def test_batch_annotate_images_async(
+ transport: str = "grpc_asyncio",
+ request_type=image_annotator.BatchAnnotateImagesRequest,
+):
client = ImageAnnotatorAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = image_annotator.BatchAnnotateImagesRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.batch_annotate_images), "__call__"
+ type(client.transport.batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -498,18 +502,23 @@ async def test_batch_annotate_images_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == image_annotator.BatchAnnotateImagesRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, image_annotator.BatchAnnotateImagesResponse)
+@pytest.mark.asyncio
+async def test_batch_annotate_images_async_from_dict():
+ await test_batch_annotate_images_async(request_type=dict)
+
+
def test_batch_annotate_images_flattened():
client = ImageAnnotatorClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.batch_annotate_images), "__call__"
+ type(client.transport.batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = image_annotator.BatchAnnotateImagesResponse()
@@ -558,7 +567,7 @@ async def test_batch_annotate_images_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.batch_annotate_images), "__call__"
+ type(client.transport.batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = image_annotator.BatchAnnotateImagesResponse()
@@ -641,7 +650,7 @@ def test_transport_instance():
credentials=credentials.AnonymousCredentials(),
)
client = ImageAnnotatorClient(transport=transport)
- assert client._transport is transport
+ assert client.transport is transport
def test_transport_get_channel():
@@ -677,7 +686,7 @@ def test_transport_adc(transport_class):
def test_transport_grpc_default():
# A client should use the gRPC transport by default.
client = ImageAnnotatorClient(credentials=credentials.AnonymousCredentials(),)
- assert isinstance(client._transport, transports.ImageAnnotatorGrpcTransport,)
+ assert isinstance(client.transport, transports.ImageAnnotatorGrpcTransport,)
def test_image_annotator_base_transport_error():
@@ -778,7 +787,7 @@ def test_image_annotator_host_no_port():
api_endpoint="vision.googleapis.com"
),
)
- assert client._transport._host == "vision.googleapis.com:443"
+ assert client.transport._host == "vision.googleapis.com:443"
def test_image_annotator_host_with_port():
@@ -788,7 +797,7 @@ def test_image_annotator_host_with_port():
api_endpoint="vision.googleapis.com:8000"
),
)
- assert client._transport._host == "vision.googleapis.com:8000"
+ assert client.transport._host == "vision.googleapis.com:8000"
def test_image_annotator_grpc_transport_channel():
@@ -800,6 +809,7 @@ def test_image_annotator_grpc_transport_channel():
)
assert transport.grpc_channel == channel
assert transport._host == "squid.clam.whelk:443"
+ assert transport._ssl_channel_credentials == None
def test_image_annotator_grpc_asyncio_transport_channel():
@@ -811,6 +821,7 @@ def test_image_annotator_grpc_asyncio_transport_channel():
)
assert transport.grpc_channel == channel
assert transport._host == "squid.clam.whelk:443"
+ assert transport._ssl_channel_credentials == None
@pytest.mark.parametrize(
@@ -859,8 +870,13 @@ def test_image_annotator_transport_channel_mtls_with_client_cert_source(
),
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
assert transport.grpc_channel == mock_grpc_channel
+ assert transport._ssl_channel_credentials == mock_ssl_cred
@pytest.mark.parametrize(
@@ -902,10 +918,115 @@ def test_image_annotator_transport_channel_mtls_with_adc(transport_class):
),
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
assert transport.grpc_channel == mock_grpc_channel
+def test_common_billing_account_path():
+ billing_account = "squid"
+
+ expected = "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+ actual = ImageAnnotatorClient.common_billing_account_path(billing_account)
+ assert expected == actual
+
+
+def test_parse_common_billing_account_path():
+ expected = {
+ "billing_account": "clam",
+ }
+ path = ImageAnnotatorClient.common_billing_account_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_billing_account_path(path)
+ assert expected == actual
+
+
+def test_common_folder_path():
+ folder = "whelk"
+
+ expected = "folders/{folder}".format(folder=folder,)
+ actual = ImageAnnotatorClient.common_folder_path(folder)
+ assert expected == actual
+
+
+def test_parse_common_folder_path():
+ expected = {
+ "folder": "octopus",
+ }
+ path = ImageAnnotatorClient.common_folder_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_folder_path(path)
+ assert expected == actual
+
+
+def test_common_organization_path():
+ organization = "oyster"
+
+ expected = "organizations/{organization}".format(organization=organization,)
+ actual = ImageAnnotatorClient.common_organization_path(organization)
+ assert expected == actual
+
+
+def test_parse_common_organization_path():
+ expected = {
+ "organization": "nudibranch",
+ }
+ path = ImageAnnotatorClient.common_organization_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_organization_path(path)
+ assert expected == actual
+
+
+def test_common_project_path():
+ project = "cuttlefish"
+
+ expected = "projects/{project}".format(project=project,)
+ actual = ImageAnnotatorClient.common_project_path(project)
+ assert expected == actual
+
+
+def test_parse_common_project_path():
+ expected = {
+ "project": "mussel",
+ }
+ path = ImageAnnotatorClient.common_project_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_project_path(path)
+ assert expected == actual
+
+
+def test_common_location_path():
+ project = "winkle"
+ location = "nautilus"
+
+ expected = "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+ actual = ImageAnnotatorClient.common_location_path(project, location)
+ assert expected == actual
+
+
+def test_parse_common_location_path():
+ expected = {
+ "project": "scallop",
+ "location": "abalone",
+ }
+ path = ImageAnnotatorClient.common_location_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_location_path(path)
+ assert expected == actual
+
+
def test_client_withDEFAULT_CLIENT_INFO():
client_info = gapic_v1.client_info.ClientInfo()
diff --git a/tests/unit/gapic/vision_v1p2beta1/test_image_annotator.py b/tests/unit/gapic/vision_v1p2beta1/test_image_annotator.py
index 10d5cc81..3527d957 100644
--- a/tests/unit/gapic/vision_v1p2beta1/test_image_annotator.py
+++ b/tests/unit/gapic/vision_v1p2beta1/test_image_annotator.py
@@ -100,12 +100,12 @@ def test_image_annotator_client_from_service_account_file(client_class):
) as factory:
factory.return_value = creds
client = client_class.from_service_account_file("dummy/file/path.json")
- assert client._transport._credentials == creds
+ assert client.transport._credentials == creds
client = client_class.from_service_account_json("dummy/file/path.json")
- assert client._transport._credentials == creds
+ assert client.transport._credentials == creds
- assert client._transport._host == "vision.googleapis.com:443"
+ assert client.transport._host == "vision.googleapis.com:443"
def test_image_annotator_client_get_transport_class():
@@ -456,7 +456,7 @@ def test_batch_annotate_images(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.batch_annotate_images), "__call__"
+ type(client.transport.batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = image_annotator.BatchAnnotateImagesResponse()
@@ -470,6 +470,7 @@ def test_batch_annotate_images(
assert args[0] == image_annotator.BatchAnnotateImagesRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, image_annotator.BatchAnnotateImagesResponse)
@@ -478,18 +479,21 @@ def test_batch_annotate_images_from_dict():
@pytest.mark.asyncio
-async def test_batch_annotate_images_async(transport: str = "grpc_asyncio"):
+async def test_batch_annotate_images_async(
+ transport: str = "grpc_asyncio",
+ request_type=image_annotator.BatchAnnotateImagesRequest,
+):
client = ImageAnnotatorAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = image_annotator.BatchAnnotateImagesRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.batch_annotate_images), "__call__"
+ type(client.transport.batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -502,18 +506,23 @@ async def test_batch_annotate_images_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == image_annotator.BatchAnnotateImagesRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, image_annotator.BatchAnnotateImagesResponse)
+@pytest.mark.asyncio
+async def test_batch_annotate_images_async_from_dict():
+ await test_batch_annotate_images_async(request_type=dict)
+
+
def test_batch_annotate_images_flattened():
client = ImageAnnotatorClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.batch_annotate_images), "__call__"
+ type(client.transport.batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = image_annotator.BatchAnnotateImagesResponse()
@@ -562,7 +571,7 @@ async def test_batch_annotate_images_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.batch_annotate_images), "__call__"
+ type(client.transport.batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = image_annotator.BatchAnnotateImagesResponse()
@@ -622,7 +631,7 @@ def test_async_batch_annotate_files(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.async_batch_annotate_files), "__call__"
+ type(client.transport.async_batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/spam")
@@ -644,18 +653,21 @@ def test_async_batch_annotate_files_from_dict():
@pytest.mark.asyncio
-async def test_async_batch_annotate_files_async(transport: str = "grpc_asyncio"):
+async def test_async_batch_annotate_files_async(
+ transport: str = "grpc_asyncio",
+ request_type=image_annotator.AsyncBatchAnnotateFilesRequest,
+):
client = ImageAnnotatorAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = image_annotator.AsyncBatchAnnotateFilesRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.async_batch_annotate_files), "__call__"
+ type(client.transport.async_batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -668,18 +680,23 @@ async def test_async_batch_annotate_files_async(transport: str = "grpc_asyncio")
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == image_annotator.AsyncBatchAnnotateFilesRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, future.Future)
+@pytest.mark.asyncio
+async def test_async_batch_annotate_files_async_from_dict():
+ await test_async_batch_annotate_files_async(request_type=dict)
+
+
def test_async_batch_annotate_files_flattened():
client = ImageAnnotatorClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.async_batch_annotate_files), "__call__"
+ type(client.transport.async_batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -734,7 +751,7 @@ async def test_async_batch_annotate_files_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.async_batch_annotate_files), "__call__"
+ type(client.transport.async_batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -823,7 +840,7 @@ def test_transport_instance():
credentials=credentials.AnonymousCredentials(),
)
client = ImageAnnotatorClient(transport=transport)
- assert client._transport is transport
+ assert client.transport is transport
def test_transport_get_channel():
@@ -859,7 +876,7 @@ def test_transport_adc(transport_class):
def test_transport_grpc_default():
# A client should use the gRPC transport by default.
client = ImageAnnotatorClient(credentials=credentials.AnonymousCredentials(),)
- assert isinstance(client._transport, transports.ImageAnnotatorGrpcTransport,)
+ assert isinstance(client.transport, transports.ImageAnnotatorGrpcTransport,)
def test_image_annotator_base_transport_error():
@@ -968,7 +985,7 @@ def test_image_annotator_host_no_port():
api_endpoint="vision.googleapis.com"
),
)
- assert client._transport._host == "vision.googleapis.com:443"
+ assert client.transport._host == "vision.googleapis.com:443"
def test_image_annotator_host_with_port():
@@ -978,7 +995,7 @@ def test_image_annotator_host_with_port():
api_endpoint="vision.googleapis.com:8000"
),
)
- assert client._transport._host == "vision.googleapis.com:8000"
+ assert client.transport._host == "vision.googleapis.com:8000"
def test_image_annotator_grpc_transport_channel():
@@ -990,6 +1007,7 @@ def test_image_annotator_grpc_transport_channel():
)
assert transport.grpc_channel == channel
assert transport._host == "squid.clam.whelk:443"
+ assert transport._ssl_channel_credentials == None
def test_image_annotator_grpc_asyncio_transport_channel():
@@ -1001,6 +1019,7 @@ def test_image_annotator_grpc_asyncio_transport_channel():
)
assert transport.grpc_channel == channel
assert transport._host == "squid.clam.whelk:443"
+ assert transport._ssl_channel_credentials == None
@pytest.mark.parametrize(
@@ -1049,8 +1068,13 @@ def test_image_annotator_transport_channel_mtls_with_client_cert_source(
),
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
assert transport.grpc_channel == mock_grpc_channel
+ assert transport._ssl_channel_credentials == mock_ssl_cred
@pytest.mark.parametrize(
@@ -1092,6 +1116,10 @@ def test_image_annotator_transport_channel_mtls_with_adc(transport_class):
),
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
assert transport.grpc_channel == mock_grpc_channel
@@ -1100,7 +1128,7 @@ def test_image_annotator_grpc_lro_client():
client = ImageAnnotatorClient(
credentials=credentials.AnonymousCredentials(), transport="grpc",
)
- transport = client._transport
+ transport = client.transport
# Ensure that we have a api-core operations client.
assert isinstance(transport.operations_client, operations_v1.OperationsClient,)
@@ -1113,7 +1141,7 @@ def test_image_annotator_grpc_lro_async_client():
client = ImageAnnotatorAsyncClient(
credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio",
)
- transport = client._client._transport
+ transport = client.transport
# Ensure that we have a api-core operations client.
assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,)
@@ -1122,6 +1150,107 @@ def test_image_annotator_grpc_lro_async_client():
assert transport.operations_client is transport.operations_client
+def test_common_billing_account_path():
+ billing_account = "squid"
+
+ expected = "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+ actual = ImageAnnotatorClient.common_billing_account_path(billing_account)
+ assert expected == actual
+
+
+def test_parse_common_billing_account_path():
+ expected = {
+ "billing_account": "clam",
+ }
+ path = ImageAnnotatorClient.common_billing_account_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_billing_account_path(path)
+ assert expected == actual
+
+
+def test_common_folder_path():
+ folder = "whelk"
+
+ expected = "folders/{folder}".format(folder=folder,)
+ actual = ImageAnnotatorClient.common_folder_path(folder)
+ assert expected == actual
+
+
+def test_parse_common_folder_path():
+ expected = {
+ "folder": "octopus",
+ }
+ path = ImageAnnotatorClient.common_folder_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_folder_path(path)
+ assert expected == actual
+
+
+def test_common_organization_path():
+ organization = "oyster"
+
+ expected = "organizations/{organization}".format(organization=organization,)
+ actual = ImageAnnotatorClient.common_organization_path(organization)
+ assert expected == actual
+
+
+def test_parse_common_organization_path():
+ expected = {
+ "organization": "nudibranch",
+ }
+ path = ImageAnnotatorClient.common_organization_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_organization_path(path)
+ assert expected == actual
+
+
+def test_common_project_path():
+ project = "cuttlefish"
+
+ expected = "projects/{project}".format(project=project,)
+ actual = ImageAnnotatorClient.common_project_path(project)
+ assert expected == actual
+
+
+def test_parse_common_project_path():
+ expected = {
+ "project": "mussel",
+ }
+ path = ImageAnnotatorClient.common_project_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_project_path(path)
+ assert expected == actual
+
+
+def test_common_location_path():
+ project = "winkle"
+ location = "nautilus"
+
+ expected = "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+ actual = ImageAnnotatorClient.common_location_path(project, location)
+ assert expected == actual
+
+
+def test_parse_common_location_path():
+ expected = {
+ "project": "scallop",
+ "location": "abalone",
+ }
+ path = ImageAnnotatorClient.common_location_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_location_path(path)
+ assert expected == actual
+
+
def test_client_withDEFAULT_CLIENT_INFO():
client_info = gapic_v1.client_info.ClientInfo()
diff --git a/tests/unit/gapic/vision_v1p3beta1/test_image_annotator.py b/tests/unit/gapic/vision_v1p3beta1/test_image_annotator.py
index ce7942fe..a2afe4ad 100644
--- a/tests/unit/gapic/vision_v1p3beta1/test_image_annotator.py
+++ b/tests/unit/gapic/vision_v1p3beta1/test_image_annotator.py
@@ -102,12 +102,12 @@ def test_image_annotator_client_from_service_account_file(client_class):
) as factory:
factory.return_value = creds
client = client_class.from_service_account_file("dummy/file/path.json")
- assert client._transport._credentials == creds
+ assert client.transport._credentials == creds
client = client_class.from_service_account_json("dummy/file/path.json")
- assert client._transport._credentials == creds
+ assert client.transport._credentials == creds
- assert client._transport._host == "vision.googleapis.com:443"
+ assert client.transport._host == "vision.googleapis.com:443"
def test_image_annotator_client_get_transport_class():
@@ -458,7 +458,7 @@ def test_batch_annotate_images(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.batch_annotate_images), "__call__"
+ type(client.transport.batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = image_annotator.BatchAnnotateImagesResponse()
@@ -472,6 +472,7 @@ def test_batch_annotate_images(
assert args[0] == image_annotator.BatchAnnotateImagesRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, image_annotator.BatchAnnotateImagesResponse)
@@ -480,18 +481,21 @@ def test_batch_annotate_images_from_dict():
@pytest.mark.asyncio
-async def test_batch_annotate_images_async(transport: str = "grpc_asyncio"):
+async def test_batch_annotate_images_async(
+ transport: str = "grpc_asyncio",
+ request_type=image_annotator.BatchAnnotateImagesRequest,
+):
client = ImageAnnotatorAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = image_annotator.BatchAnnotateImagesRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.batch_annotate_images), "__call__"
+ type(client.transport.batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -504,18 +508,23 @@ async def test_batch_annotate_images_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == image_annotator.BatchAnnotateImagesRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, image_annotator.BatchAnnotateImagesResponse)
+@pytest.mark.asyncio
+async def test_batch_annotate_images_async_from_dict():
+ await test_batch_annotate_images_async(request_type=dict)
+
+
def test_batch_annotate_images_flattened():
client = ImageAnnotatorClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.batch_annotate_images), "__call__"
+ type(client.transport.batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = image_annotator.BatchAnnotateImagesResponse()
@@ -564,7 +573,7 @@ async def test_batch_annotate_images_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.batch_annotate_images), "__call__"
+ type(client.transport.batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = image_annotator.BatchAnnotateImagesResponse()
@@ -624,7 +633,7 @@ def test_async_batch_annotate_files(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.async_batch_annotate_files), "__call__"
+ type(client.transport.async_batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/spam")
@@ -646,18 +655,21 @@ def test_async_batch_annotate_files_from_dict():
@pytest.mark.asyncio
-async def test_async_batch_annotate_files_async(transport: str = "grpc_asyncio"):
+async def test_async_batch_annotate_files_async(
+ transport: str = "grpc_asyncio",
+ request_type=image_annotator.AsyncBatchAnnotateFilesRequest,
+):
client = ImageAnnotatorAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = image_annotator.AsyncBatchAnnotateFilesRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.async_batch_annotate_files), "__call__"
+ type(client.transport.async_batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -670,18 +682,23 @@ async def test_async_batch_annotate_files_async(transport: str = "grpc_asyncio")
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == image_annotator.AsyncBatchAnnotateFilesRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, future.Future)
+@pytest.mark.asyncio
+async def test_async_batch_annotate_files_async_from_dict():
+ await test_async_batch_annotate_files_async(request_type=dict)
+
+
def test_async_batch_annotate_files_flattened():
client = ImageAnnotatorClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.async_batch_annotate_files), "__call__"
+ type(client.transport.async_batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -736,7 +753,7 @@ async def test_async_batch_annotate_files_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.async_batch_annotate_files), "__call__"
+ type(client.transport.async_batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -825,7 +842,7 @@ def test_transport_instance():
credentials=credentials.AnonymousCredentials(),
)
client = ImageAnnotatorClient(transport=transport)
- assert client._transport is transport
+ assert client.transport is transport
def test_transport_get_channel():
@@ -861,7 +878,7 @@ def test_transport_adc(transport_class):
def test_transport_grpc_default():
# A client should use the gRPC transport by default.
client = ImageAnnotatorClient(credentials=credentials.AnonymousCredentials(),)
- assert isinstance(client._transport, transports.ImageAnnotatorGrpcTransport,)
+ assert isinstance(client.transport, transports.ImageAnnotatorGrpcTransport,)
def test_image_annotator_base_transport_error():
@@ -970,7 +987,7 @@ def test_image_annotator_host_no_port():
api_endpoint="vision.googleapis.com"
),
)
- assert client._transport._host == "vision.googleapis.com:443"
+ assert client.transport._host == "vision.googleapis.com:443"
def test_image_annotator_host_with_port():
@@ -980,7 +997,7 @@ def test_image_annotator_host_with_port():
api_endpoint="vision.googleapis.com:8000"
),
)
- assert client._transport._host == "vision.googleapis.com:8000"
+ assert client.transport._host == "vision.googleapis.com:8000"
def test_image_annotator_grpc_transport_channel():
@@ -992,6 +1009,7 @@ def test_image_annotator_grpc_transport_channel():
)
assert transport.grpc_channel == channel
assert transport._host == "squid.clam.whelk:443"
+ assert transport._ssl_channel_credentials == None
def test_image_annotator_grpc_asyncio_transport_channel():
@@ -1003,6 +1021,7 @@ def test_image_annotator_grpc_asyncio_transport_channel():
)
assert transport.grpc_channel == channel
assert transport._host == "squid.clam.whelk:443"
+ assert transport._ssl_channel_credentials == None
@pytest.mark.parametrize(
@@ -1051,8 +1070,13 @@ def test_image_annotator_transport_channel_mtls_with_client_cert_source(
),
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
assert transport.grpc_channel == mock_grpc_channel
+ assert transport._ssl_channel_credentials == mock_ssl_cred
@pytest.mark.parametrize(
@@ -1094,6 +1118,10 @@ def test_image_annotator_transport_channel_mtls_with_adc(transport_class):
),
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
assert transport.grpc_channel == mock_grpc_channel
@@ -1102,7 +1130,7 @@ def test_image_annotator_grpc_lro_client():
client = ImageAnnotatorClient(
credentials=credentials.AnonymousCredentials(), transport="grpc",
)
- transport = client._transport
+ transport = client.transport
# Ensure that we have a api-core operations client.
assert isinstance(transport.operations_client, operations_v1.OperationsClient,)
@@ -1115,7 +1143,7 @@ def test_image_annotator_grpc_lro_async_client():
client = ImageAnnotatorAsyncClient(
credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio",
)
- transport = client._client._transport
+ transport = client.transport
# Ensure that we have a api-core operations client.
assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,)
@@ -1124,6 +1152,157 @@ def test_image_annotator_grpc_lro_async_client():
assert transport.operations_client is transport.operations_client
+def test_product_path():
+ project = "squid"
+ location = "clam"
+ product = "whelk"
+
+ expected = "projects/{project}/locations/{location}/products/{product}".format(
+ project=project, location=location, product=product,
+ )
+ actual = ImageAnnotatorClient.product_path(project, location, product)
+ assert expected == actual
+
+
+def test_parse_product_path():
+ expected = {
+ "project": "octopus",
+ "location": "oyster",
+ "product": "nudibranch",
+ }
+ path = ImageAnnotatorClient.product_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_product_path(path)
+ assert expected == actual
+
+
+def test_product_set_path():
+ project = "cuttlefish"
+ location = "mussel"
+ product_set = "winkle"
+
+ expected = "projects/{project}/locations/{location}/productSets/{product_set}".format(
+ project=project, location=location, product_set=product_set,
+ )
+ actual = ImageAnnotatorClient.product_set_path(project, location, product_set)
+ assert expected == actual
+
+
+def test_parse_product_set_path():
+ expected = {
+ "project": "nautilus",
+ "location": "scallop",
+ "product_set": "abalone",
+ }
+ path = ImageAnnotatorClient.product_set_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_product_set_path(path)
+ assert expected == actual
+
+
+def test_common_billing_account_path():
+ billing_account = "squid"
+
+ expected = "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+ actual = ImageAnnotatorClient.common_billing_account_path(billing_account)
+ assert expected == actual
+
+
+def test_parse_common_billing_account_path():
+ expected = {
+ "billing_account": "clam",
+ }
+ path = ImageAnnotatorClient.common_billing_account_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_billing_account_path(path)
+ assert expected == actual
+
+
+def test_common_folder_path():
+ folder = "whelk"
+
+ expected = "folders/{folder}".format(folder=folder,)
+ actual = ImageAnnotatorClient.common_folder_path(folder)
+ assert expected == actual
+
+
+def test_parse_common_folder_path():
+ expected = {
+ "folder": "octopus",
+ }
+ path = ImageAnnotatorClient.common_folder_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_folder_path(path)
+ assert expected == actual
+
+
+def test_common_organization_path():
+ organization = "oyster"
+
+ expected = "organizations/{organization}".format(organization=organization,)
+ actual = ImageAnnotatorClient.common_organization_path(organization)
+ assert expected == actual
+
+
+def test_parse_common_organization_path():
+ expected = {
+ "organization": "nudibranch",
+ }
+ path = ImageAnnotatorClient.common_organization_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_organization_path(path)
+ assert expected == actual
+
+
+def test_common_project_path():
+ project = "cuttlefish"
+
+ expected = "projects/{project}".format(project=project,)
+ actual = ImageAnnotatorClient.common_project_path(project)
+ assert expected == actual
+
+
+def test_parse_common_project_path():
+ expected = {
+ "project": "mussel",
+ }
+ path = ImageAnnotatorClient.common_project_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_project_path(path)
+ assert expected == actual
+
+
+def test_common_location_path():
+ project = "winkle"
+ location = "nautilus"
+
+ expected = "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+ actual = ImageAnnotatorClient.common_location_path(project, location)
+ assert expected == actual
+
+
+def test_parse_common_location_path():
+ expected = {
+ "project": "scallop",
+ "location": "abalone",
+ }
+ path = ImageAnnotatorClient.common_location_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_location_path(path)
+ assert expected == actual
+
+
def test_client_withDEFAULT_CLIENT_INFO():
client_info = gapic_v1.client_info.ClientInfo()
diff --git a/tests/unit/gapic/vision_v1p3beta1/test_product_search.py b/tests/unit/gapic/vision_v1p3beta1/test_product_search.py
index 5e2e7d9d..af66ff8b 100644
--- a/tests/unit/gapic/vision_v1p3beta1/test_product_search.py
+++ b/tests/unit/gapic/vision_v1p3beta1/test_product_search.py
@@ -105,12 +105,12 @@ def test_product_search_client_from_service_account_file(client_class):
) as factory:
factory.return_value = creds
client = client_class.from_service_account_file("dummy/file/path.json")
- assert client._transport._credentials == creds
+ assert client.transport._credentials == creds
client = client_class.from_service_account_json("dummy/file/path.json")
- assert client._transport._credentials == creds
+ assert client.transport._credentials == creds
- assert client._transport._host == "vision.googleapis.com:443"
+ assert client.transport._host == "vision.googleapis.com:443"
def test_product_search_client_get_transport_class():
@@ -461,7 +461,7 @@ def test_create_product_set(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.create_product_set), "__call__"
+ type(client.transport.create_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet(
@@ -477,6 +477,7 @@ def test_create_product_set(
assert args[0] == product_search_service.CreateProductSetRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.ProductSet)
assert response.name == "name_value"
@@ -489,18 +490,21 @@ def test_create_product_set_from_dict():
@pytest.mark.asyncio
-async def test_create_product_set_async(transport: str = "grpc_asyncio"):
+async def test_create_product_set_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.CreateProductSetRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.CreateProductSetRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.create_product_set), "__call__"
+ type(client.transport.create_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -515,7 +519,7 @@ async def test_create_product_set_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.CreateProductSetRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.ProductSet)
@@ -525,6 +529,11 @@ async def test_create_product_set_async(transport: str = "grpc_asyncio"):
assert response.display_name == "display_name_value"
+@pytest.mark.asyncio
+async def test_create_product_set_async_from_dict():
+ await test_create_product_set_async(request_type=dict)
+
+
def test_create_product_set_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -535,7 +544,7 @@ def test_create_product_set_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.create_product_set), "__call__"
+ type(client.transport.create_product_set), "__call__"
) as call:
call.return_value = product_search_service.ProductSet()
@@ -562,7 +571,7 @@ async def test_create_product_set_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.create_product_set), "__call__"
+ type(client.transport.create_product_set), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ProductSet()
@@ -585,7 +594,7 @@ def test_create_product_set_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.create_product_set), "__call__"
+ type(client.transport.create_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet()
@@ -632,7 +641,7 @@ async def test_create_product_set_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.create_product_set), "__call__"
+ type(client.transport.create_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet()
@@ -690,7 +699,7 @@ def test_list_product_sets(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductSetsResponse(
@@ -706,6 +715,7 @@ def test_list_product_sets(
assert args[0] == product_search_service.ListProductSetsRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, pagers.ListProductSetsPager)
assert response.next_page_token == "next_page_token_value"
@@ -716,18 +726,21 @@ def test_list_product_sets_from_dict():
@pytest.mark.asyncio
-async def test_list_product_sets_async(transport: str = "grpc_asyncio"):
+async def test_list_product_sets_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.ListProductSetsRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.ListProductSetsRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -742,7 +755,7 @@ async def test_list_product_sets_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.ListProductSetsRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, pagers.ListProductSetsAsyncPager)
@@ -750,6 +763,11 @@ async def test_list_product_sets_async(transport: str = "grpc_asyncio"):
assert response.next_page_token == "next_page_token_value"
+@pytest.mark.asyncio
+async def test_list_product_sets_async_from_dict():
+ await test_list_product_sets_async(request_type=dict)
+
+
def test_list_product_sets_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -760,7 +778,7 @@ def test_list_product_sets_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
call.return_value = product_search_service.ListProductSetsResponse()
@@ -787,7 +805,7 @@ async def test_list_product_sets_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ListProductSetsResponse()
@@ -810,7 +828,7 @@ def test_list_product_sets_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductSetsResponse()
@@ -844,7 +862,7 @@ async def test_list_product_sets_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductSetsResponse()
@@ -881,7 +899,7 @@ def test_list_product_sets_pager():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -927,7 +945,7 @@ def test_list_product_sets_pages():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -965,7 +983,7 @@ async def test_list_product_sets_async_pager():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_product_sets),
+ type(client.transport.list_product_sets),
"__call__",
new_callable=mock.AsyncMock,
) as call:
@@ -1010,7 +1028,7 @@ async def test_list_product_sets_async_pages():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_product_sets),
+ type(client.transport.list_product_sets),
"__call__",
new_callable=mock.AsyncMock,
) as call:
@@ -1058,7 +1076,7 @@ def test_get_product_set(
request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.get_product_set), "__call__") as call:
+ with mock.patch.object(type(client.transport.get_product_set), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet(
name="name_value", display_name="display_name_value",
@@ -1073,6 +1091,7 @@ def test_get_product_set(
assert args[0] == product_search_service.GetProductSetRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.ProductSet)
assert response.name == "name_value"
@@ -1085,19 +1104,20 @@ def test_get_product_set_from_dict():
@pytest.mark.asyncio
-async def test_get_product_set_async(transport: str = "grpc_asyncio"):
+async def test_get_product_set_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.GetProductSetRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.GetProductSetRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.get_product_set), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.get_product_set), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ProductSet(
@@ -1111,7 +1131,7 @@ async def test_get_product_set_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.GetProductSetRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.ProductSet)
@@ -1121,6 +1141,11 @@ async def test_get_product_set_async(transport: str = "grpc_asyncio"):
assert response.display_name == "display_name_value"
+@pytest.mark.asyncio
+async def test_get_product_set_async_from_dict():
+ await test_get_product_set_async(request_type=dict)
+
+
def test_get_product_set_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -1130,7 +1155,7 @@ def test_get_product_set_field_headers():
request.name = "name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.get_product_set), "__call__") as call:
+ with mock.patch.object(type(client.transport.get_product_set), "__call__") as call:
call.return_value = product_search_service.ProductSet()
client.get_product_set(request)
@@ -1155,9 +1180,7 @@ async def test_get_product_set_field_headers_async():
request.name = "name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.get_product_set), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.get_product_set), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ProductSet()
)
@@ -1178,7 +1201,7 @@ def test_get_product_set_flattened():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.get_product_set), "__call__") as call:
+ with mock.patch.object(type(client.transport.get_product_set), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet()
@@ -1210,9 +1233,7 @@ async def test_get_product_set_flattened_async():
client = ProductSearchAsyncClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.get_product_set), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.get_product_set), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet()
@@ -1256,7 +1277,7 @@ def test_update_product_set(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.update_product_set), "__call__"
+ type(client.transport.update_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet(
@@ -1272,6 +1293,7 @@ def test_update_product_set(
assert args[0] == product_search_service.UpdateProductSetRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.ProductSet)
assert response.name == "name_value"
@@ -1284,18 +1306,21 @@ def test_update_product_set_from_dict():
@pytest.mark.asyncio
-async def test_update_product_set_async(transport: str = "grpc_asyncio"):
+async def test_update_product_set_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.UpdateProductSetRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.UpdateProductSetRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.update_product_set), "__call__"
+ type(client.transport.update_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -1310,7 +1335,7 @@ async def test_update_product_set_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.UpdateProductSetRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.ProductSet)
@@ -1320,6 +1345,11 @@ async def test_update_product_set_async(transport: str = "grpc_asyncio"):
assert response.display_name == "display_name_value"
+@pytest.mark.asyncio
+async def test_update_product_set_async_from_dict():
+ await test_update_product_set_async(request_type=dict)
+
+
def test_update_product_set_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -1330,7 +1360,7 @@ def test_update_product_set_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.update_product_set), "__call__"
+ type(client.transport.update_product_set), "__call__"
) as call:
call.return_value = product_search_service.ProductSet()
@@ -1359,7 +1389,7 @@ async def test_update_product_set_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.update_product_set), "__call__"
+ type(client.transport.update_product_set), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ProductSet()
@@ -1384,7 +1414,7 @@ def test_update_product_set_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.update_product_set), "__call__"
+ type(client.transport.update_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet()
@@ -1427,7 +1457,7 @@ async def test_update_product_set_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.update_product_set), "__call__"
+ type(client.transport.update_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet()
@@ -1481,7 +1511,7 @@ def test_delete_product_set(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.delete_product_set), "__call__"
+ type(client.transport.delete_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -1503,18 +1533,21 @@ def test_delete_product_set_from_dict():
@pytest.mark.asyncio
-async def test_delete_product_set_async(transport: str = "grpc_asyncio"):
+async def test_delete_product_set_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.DeleteProductSetRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.DeleteProductSetRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.delete_product_set), "__call__"
+ type(client.transport.delete_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -1525,12 +1558,17 @@ async def test_delete_product_set_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.DeleteProductSetRequest()
# Establish that the response is the type that we expect.
assert response is None
+@pytest.mark.asyncio
+async def test_delete_product_set_async_from_dict():
+ await test_delete_product_set_async(request_type=dict)
+
+
def test_delete_product_set_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -1541,7 +1579,7 @@ def test_delete_product_set_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.delete_product_set), "__call__"
+ type(client.transport.delete_product_set), "__call__"
) as call:
call.return_value = None
@@ -1568,7 +1606,7 @@ async def test_delete_product_set_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.delete_product_set), "__call__"
+ type(client.transport.delete_product_set), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -1589,7 +1627,7 @@ def test_delete_product_set_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.delete_product_set), "__call__"
+ type(client.transport.delete_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -1623,7 +1661,7 @@ async def test_delete_product_set_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.delete_product_set), "__call__"
+ type(client.transport.delete_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -1665,7 +1703,7 @@ def test_create_product(
request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.create_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.create_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product(
name="name_value",
@@ -1683,6 +1721,7 @@ def test_create_product(
assert args[0] == product_search_service.CreateProductRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.Product)
assert response.name == "name_value"
@@ -1699,19 +1738,20 @@ def test_create_product_from_dict():
@pytest.mark.asyncio
-async def test_create_product_async(transport: str = "grpc_asyncio"):
+async def test_create_product_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.CreateProductRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.CreateProductRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.create_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.create_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.Product(
@@ -1728,7 +1768,7 @@ async def test_create_product_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.CreateProductRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.Product)
@@ -1742,6 +1782,11 @@ async def test_create_product_async(transport: str = "grpc_asyncio"):
assert response.product_category == "product_category_value"
+@pytest.mark.asyncio
+async def test_create_product_async_from_dict():
+ await test_create_product_async(request_type=dict)
+
+
def test_create_product_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -1751,7 +1796,7 @@ def test_create_product_field_headers():
request.parent = "parent/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.create_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.create_product), "__call__") as call:
call.return_value = product_search_service.Product()
client.create_product(request)
@@ -1776,9 +1821,7 @@ async def test_create_product_field_headers_async():
request.parent = "parent/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.create_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.create_product), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.Product()
)
@@ -1799,7 +1842,7 @@ def test_create_product_flattened():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.create_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.create_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product()
@@ -1842,9 +1885,7 @@ async def test_create_product_flattened_async():
client = ProductSearchAsyncClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.create_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.create_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product()
@@ -1898,7 +1939,7 @@ def test_list_products(
request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.list_products), "__call__") as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductsResponse(
next_page_token="next_page_token_value",
@@ -1913,6 +1954,7 @@ def test_list_products(
assert args[0] == product_search_service.ListProductsRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, pagers.ListProductsPager)
assert response.next_page_token == "next_page_token_value"
@@ -1923,19 +1965,20 @@ def test_list_products_from_dict():
@pytest.mark.asyncio
-async def test_list_products_async(transport: str = "grpc_asyncio"):
+async def test_list_products_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.ListProductsRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.ListProductsRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.list_products), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ListProductsResponse(
@@ -1949,7 +1992,7 @@ async def test_list_products_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.ListProductsRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, pagers.ListProductsAsyncPager)
@@ -1957,6 +2000,11 @@ async def test_list_products_async(transport: str = "grpc_asyncio"):
assert response.next_page_token == "next_page_token_value"
+@pytest.mark.asyncio
+async def test_list_products_async_from_dict():
+ await test_list_products_async(request_type=dict)
+
+
def test_list_products_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -1966,7 +2014,7 @@ def test_list_products_field_headers():
request.parent = "parent/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.list_products), "__call__") as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
call.return_value = product_search_service.ListProductsResponse()
client.list_products(request)
@@ -1991,9 +2039,7 @@ async def test_list_products_field_headers_async():
request.parent = "parent/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.list_products), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ListProductsResponse()
)
@@ -2014,7 +2060,7 @@ def test_list_products_flattened():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.list_products), "__call__") as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductsResponse()
@@ -2046,9 +2092,7 @@ async def test_list_products_flattened_async():
client = ProductSearchAsyncClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.list_products), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductsResponse()
@@ -2083,7 +2127,7 @@ def test_list_products_pager():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials,)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.list_products), "__call__") as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
# Set the response to a series of pages.
call.side_effect = (
product_search_service.ListProductsResponse(
@@ -2126,7 +2170,7 @@ def test_list_products_pages():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials,)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.list_products), "__call__") as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
# Set the response to a series of pages.
call.side_effect = (
product_search_service.ListProductsResponse(
@@ -2162,9 +2206,7 @@ async def test_list_products_async_pager():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_products),
- "__call__",
- new_callable=mock.AsyncMock,
+ type(client.transport.list_products), "__call__", new_callable=mock.AsyncMock
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -2206,9 +2248,7 @@ async def test_list_products_async_pages():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_products),
- "__call__",
- new_callable=mock.AsyncMock,
+ type(client.transport.list_products), "__call__", new_callable=mock.AsyncMock
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -2253,7 +2293,7 @@ def test_get_product(
request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.get_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.get_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product(
name="name_value",
@@ -2271,6 +2311,7 @@ def test_get_product(
assert args[0] == product_search_service.GetProductRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.Product)
assert response.name == "name_value"
@@ -2287,19 +2328,20 @@ def test_get_product_from_dict():
@pytest.mark.asyncio
-async def test_get_product_async(transport: str = "grpc_asyncio"):
+async def test_get_product_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.GetProductRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.GetProductRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.get_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.get_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.Product(
@@ -2316,7 +2358,7 @@ async def test_get_product_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.GetProductRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.Product)
@@ -2330,6 +2372,11 @@ async def test_get_product_async(transport: str = "grpc_asyncio"):
assert response.product_category == "product_category_value"
+@pytest.mark.asyncio
+async def test_get_product_async_from_dict():
+ await test_get_product_async(request_type=dict)
+
+
def test_get_product_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -2339,7 +2386,7 @@ def test_get_product_field_headers():
request.name = "name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.get_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.get_product), "__call__") as call:
call.return_value = product_search_service.Product()
client.get_product(request)
@@ -2364,9 +2411,7 @@ async def test_get_product_field_headers_async():
request.name = "name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.get_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.get_product), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.Product()
)
@@ -2387,7 +2432,7 @@ def test_get_product_flattened():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.get_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.get_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product()
@@ -2419,9 +2464,7 @@ async def test_get_product_flattened_async():
client = ProductSearchAsyncClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.get_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.get_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product()
@@ -2464,7 +2507,7 @@ def test_update_product(
request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.update_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.update_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product(
name="name_value",
@@ -2482,6 +2525,7 @@ def test_update_product(
assert args[0] == product_search_service.UpdateProductRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.Product)
assert response.name == "name_value"
@@ -2498,19 +2542,20 @@ def test_update_product_from_dict():
@pytest.mark.asyncio
-async def test_update_product_async(transport: str = "grpc_asyncio"):
+async def test_update_product_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.UpdateProductRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.UpdateProductRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.update_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.update_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.Product(
@@ -2527,7 +2572,7 @@ async def test_update_product_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.UpdateProductRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.Product)
@@ -2541,6 +2586,11 @@ async def test_update_product_async(transport: str = "grpc_asyncio"):
assert response.product_category == "product_category_value"
+@pytest.mark.asyncio
+async def test_update_product_async_from_dict():
+ await test_update_product_async(request_type=dict)
+
+
def test_update_product_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -2550,7 +2600,7 @@ def test_update_product_field_headers():
request.product.name = "product.name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.update_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.update_product), "__call__") as call:
call.return_value = product_search_service.Product()
client.update_product(request)
@@ -2577,9 +2627,7 @@ async def test_update_product_field_headers_async():
request.product.name = "product.name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.update_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.update_product), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.Product()
)
@@ -2602,7 +2650,7 @@ def test_update_product_flattened():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.update_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.update_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product()
@@ -2641,9 +2689,7 @@ async def test_update_product_flattened_async():
client = ProductSearchAsyncClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.update_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.update_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product()
@@ -2693,7 +2739,7 @@ def test_delete_product(
request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.delete_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.delete_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -2714,19 +2760,20 @@ def test_delete_product_from_dict():
@pytest.mark.asyncio
-async def test_delete_product_async(transport: str = "grpc_asyncio"):
+async def test_delete_product_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.DeleteProductRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.DeleteProductRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.delete_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.delete_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -2736,12 +2783,17 @@ async def test_delete_product_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.DeleteProductRequest()
# Establish that the response is the type that we expect.
assert response is None
+@pytest.mark.asyncio
+async def test_delete_product_async_from_dict():
+ await test_delete_product_async(request_type=dict)
+
+
def test_delete_product_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -2751,7 +2803,7 @@ def test_delete_product_field_headers():
request.name = "name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.delete_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.delete_product), "__call__") as call:
call.return_value = None
client.delete_product(request)
@@ -2776,9 +2828,7 @@ async def test_delete_product_field_headers_async():
request.name = "name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.delete_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.delete_product), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
await client.delete_product(request)
@@ -2797,7 +2847,7 @@ def test_delete_product_flattened():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.delete_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.delete_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -2829,9 +2879,7 @@ async def test_delete_product_flattened_async():
client = ProductSearchAsyncClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.delete_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.delete_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -2874,7 +2922,7 @@ def test_create_reference_image(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.create_reference_image), "__call__"
+ type(client.transport.create_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ReferenceImage(
@@ -2890,6 +2938,7 @@ def test_create_reference_image(
assert args[0] == product_search_service.CreateReferenceImageRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.ReferenceImage)
assert response.name == "name_value"
@@ -2902,18 +2951,21 @@ def test_create_reference_image_from_dict():
@pytest.mark.asyncio
-async def test_create_reference_image_async(transport: str = "grpc_asyncio"):
+async def test_create_reference_image_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.CreateReferenceImageRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.CreateReferenceImageRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.create_reference_image), "__call__"
+ type(client.transport.create_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -2926,7 +2978,7 @@ async def test_create_reference_image_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.CreateReferenceImageRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.ReferenceImage)
@@ -2936,6 +2988,11 @@ async def test_create_reference_image_async(transport: str = "grpc_asyncio"):
assert response.uri == "uri_value"
+@pytest.mark.asyncio
+async def test_create_reference_image_async_from_dict():
+ await test_create_reference_image_async(request_type=dict)
+
+
def test_create_reference_image_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -2946,7 +3003,7 @@ def test_create_reference_image_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.create_reference_image), "__call__"
+ type(client.transport.create_reference_image), "__call__"
) as call:
call.return_value = product_search_service.ReferenceImage()
@@ -2973,7 +3030,7 @@ async def test_create_reference_image_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.create_reference_image), "__call__"
+ type(client.transport.create_reference_image), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ReferenceImage()
@@ -2996,7 +3053,7 @@ def test_create_reference_image_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.create_reference_image), "__call__"
+ type(client.transport.create_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ReferenceImage()
@@ -3043,7 +3100,7 @@ async def test_create_reference_image_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.create_reference_image), "__call__"
+ type(client.transport.create_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ReferenceImage()
@@ -3102,7 +3159,7 @@ def test_delete_reference_image(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.delete_reference_image), "__call__"
+ type(client.transport.delete_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -3124,18 +3181,21 @@ def test_delete_reference_image_from_dict():
@pytest.mark.asyncio
-async def test_delete_reference_image_async(transport: str = "grpc_asyncio"):
+async def test_delete_reference_image_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.DeleteReferenceImageRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.DeleteReferenceImageRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.delete_reference_image), "__call__"
+ type(client.transport.delete_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -3146,12 +3206,17 @@ async def test_delete_reference_image_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.DeleteReferenceImageRequest()
# Establish that the response is the type that we expect.
assert response is None
+@pytest.mark.asyncio
+async def test_delete_reference_image_async_from_dict():
+ await test_delete_reference_image_async(request_type=dict)
+
+
def test_delete_reference_image_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -3162,7 +3227,7 @@ def test_delete_reference_image_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.delete_reference_image), "__call__"
+ type(client.transport.delete_reference_image), "__call__"
) as call:
call.return_value = None
@@ -3189,7 +3254,7 @@ async def test_delete_reference_image_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.delete_reference_image), "__call__"
+ type(client.transport.delete_reference_image), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -3210,7 +3275,7 @@ def test_delete_reference_image_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.delete_reference_image), "__call__"
+ type(client.transport.delete_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -3244,7 +3309,7 @@ async def test_delete_reference_image_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.delete_reference_image), "__call__"
+ type(client.transport.delete_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -3288,7 +3353,7 @@ def test_list_reference_images(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListReferenceImagesResponse(
@@ -3304,6 +3369,7 @@ def test_list_reference_images(
assert args[0] == product_search_service.ListReferenceImagesRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, pagers.ListReferenceImagesPager)
assert response.page_size == 951
@@ -3316,18 +3382,21 @@ def test_list_reference_images_from_dict():
@pytest.mark.asyncio
-async def test_list_reference_images_async(transport: str = "grpc_asyncio"):
+async def test_list_reference_images_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.ListReferenceImagesRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.ListReferenceImagesRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -3342,7 +3411,7 @@ async def test_list_reference_images_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.ListReferenceImagesRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, pagers.ListReferenceImagesAsyncPager)
@@ -3352,6 +3421,11 @@ async def test_list_reference_images_async(transport: str = "grpc_asyncio"):
assert response.next_page_token == "next_page_token_value"
+@pytest.mark.asyncio
+async def test_list_reference_images_async_from_dict():
+ await test_list_reference_images_async(request_type=dict)
+
+
def test_list_reference_images_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -3362,7 +3436,7 @@ def test_list_reference_images_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
call.return_value = product_search_service.ListReferenceImagesResponse()
@@ -3389,7 +3463,7 @@ async def test_list_reference_images_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ListReferenceImagesResponse()
@@ -3412,7 +3486,7 @@ def test_list_reference_images_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListReferenceImagesResponse()
@@ -3446,7 +3520,7 @@ async def test_list_reference_images_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListReferenceImagesResponse()
@@ -3483,7 +3557,7 @@ def test_list_reference_images_pager():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -3531,7 +3605,7 @@ def test_list_reference_images_pages():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -3569,7 +3643,7 @@ async def test_list_reference_images_async_pager():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_reference_images),
+ type(client.transport.list_reference_images),
"__call__",
new_callable=mock.AsyncMock,
) as call:
@@ -3616,7 +3690,7 @@ async def test_list_reference_images_async_pages():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_reference_images),
+ type(client.transport.list_reference_images),
"__call__",
new_callable=mock.AsyncMock,
) as call:
@@ -3666,7 +3740,7 @@ def test_get_reference_image(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.get_reference_image), "__call__"
+ type(client.transport.get_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ReferenceImage(
@@ -3682,6 +3756,7 @@ def test_get_reference_image(
assert args[0] == product_search_service.GetReferenceImageRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.ReferenceImage)
assert response.name == "name_value"
@@ -3694,18 +3769,21 @@ def test_get_reference_image_from_dict():
@pytest.mark.asyncio
-async def test_get_reference_image_async(transport: str = "grpc_asyncio"):
+async def test_get_reference_image_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.GetReferenceImageRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.GetReferenceImageRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.get_reference_image), "__call__"
+ type(client.transport.get_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -3718,7 +3796,7 @@ async def test_get_reference_image_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.GetReferenceImageRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.ReferenceImage)
@@ -3728,6 +3806,11 @@ async def test_get_reference_image_async(transport: str = "grpc_asyncio"):
assert response.uri == "uri_value"
+@pytest.mark.asyncio
+async def test_get_reference_image_async_from_dict():
+ await test_get_reference_image_async(request_type=dict)
+
+
def test_get_reference_image_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -3738,7 +3821,7 @@ def test_get_reference_image_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.get_reference_image), "__call__"
+ type(client.transport.get_reference_image), "__call__"
) as call:
call.return_value = product_search_service.ReferenceImage()
@@ -3765,7 +3848,7 @@ async def test_get_reference_image_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.get_reference_image), "__call__"
+ type(client.transport.get_reference_image), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ReferenceImage()
@@ -3788,7 +3871,7 @@ def test_get_reference_image_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.get_reference_image), "__call__"
+ type(client.transport.get_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ReferenceImage()
@@ -3822,7 +3905,7 @@ async def test_get_reference_image_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.get_reference_image), "__call__"
+ type(client.transport.get_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ReferenceImage()
@@ -3868,7 +3951,7 @@ def test_add_product_to_product_set(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.add_product_to_product_set), "__call__"
+ type(client.transport.add_product_to_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -3890,18 +3973,21 @@ def test_add_product_to_product_set_from_dict():
@pytest.mark.asyncio
-async def test_add_product_to_product_set_async(transport: str = "grpc_asyncio"):
+async def test_add_product_to_product_set_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.AddProductToProductSetRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.AddProductToProductSetRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.add_product_to_product_set), "__call__"
+ type(client.transport.add_product_to_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -3912,12 +3998,17 @@ async def test_add_product_to_product_set_async(transport: str = "grpc_asyncio")
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.AddProductToProductSetRequest()
# Establish that the response is the type that we expect.
assert response is None
+@pytest.mark.asyncio
+async def test_add_product_to_product_set_async_from_dict():
+ await test_add_product_to_product_set_async(request_type=dict)
+
+
def test_add_product_to_product_set_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -3928,7 +4019,7 @@ def test_add_product_to_product_set_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.add_product_to_product_set), "__call__"
+ type(client.transport.add_product_to_product_set), "__call__"
) as call:
call.return_value = None
@@ -3955,7 +4046,7 @@ async def test_add_product_to_product_set_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.add_product_to_product_set), "__call__"
+ type(client.transport.add_product_to_product_set), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -3976,7 +4067,7 @@ def test_add_product_to_product_set_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.add_product_to_product_set), "__call__"
+ type(client.transport.add_product_to_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -4016,7 +4107,7 @@ async def test_add_product_to_product_set_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.add_product_to_product_set), "__call__"
+ type(client.transport.add_product_to_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -4066,7 +4157,7 @@ def test_remove_product_from_product_set(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.remove_product_from_product_set), "__call__"
+ type(client.transport.remove_product_from_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -4088,18 +4179,21 @@ def test_remove_product_from_product_set_from_dict():
@pytest.mark.asyncio
-async def test_remove_product_from_product_set_async(transport: str = "grpc_asyncio"):
+async def test_remove_product_from_product_set_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.RemoveProductFromProductSetRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.RemoveProductFromProductSetRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.remove_product_from_product_set), "__call__"
+ type(client.transport.remove_product_from_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -4110,12 +4204,17 @@ async def test_remove_product_from_product_set_async(transport: str = "grpc_asyn
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.RemoveProductFromProductSetRequest()
# Establish that the response is the type that we expect.
assert response is None
+@pytest.mark.asyncio
+async def test_remove_product_from_product_set_async_from_dict():
+ await test_remove_product_from_product_set_async(request_type=dict)
+
+
def test_remove_product_from_product_set_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -4126,7 +4225,7 @@ def test_remove_product_from_product_set_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.remove_product_from_product_set), "__call__"
+ type(client.transport.remove_product_from_product_set), "__call__"
) as call:
call.return_value = None
@@ -4153,7 +4252,7 @@ async def test_remove_product_from_product_set_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.remove_product_from_product_set), "__call__"
+ type(client.transport.remove_product_from_product_set), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -4174,7 +4273,7 @@ def test_remove_product_from_product_set_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.remove_product_from_product_set), "__call__"
+ type(client.transport.remove_product_from_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -4214,7 +4313,7 @@ async def test_remove_product_from_product_set_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.remove_product_from_product_set), "__call__"
+ type(client.transport.remove_product_from_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -4264,7 +4363,7 @@ def test_list_products_in_product_set(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductsInProductSetResponse(
@@ -4280,6 +4379,7 @@ def test_list_products_in_product_set(
assert args[0] == product_search_service.ListProductsInProductSetRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, pagers.ListProductsInProductSetPager)
assert response.next_page_token == "next_page_token_value"
@@ -4290,18 +4390,21 @@ def test_list_products_in_product_set_from_dict():
@pytest.mark.asyncio
-async def test_list_products_in_product_set_async(transport: str = "grpc_asyncio"):
+async def test_list_products_in_product_set_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.ListProductsInProductSetRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.ListProductsInProductSetRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -4316,7 +4419,7 @@ async def test_list_products_in_product_set_async(transport: str = "grpc_asyncio
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.ListProductsInProductSetRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, pagers.ListProductsInProductSetAsyncPager)
@@ -4324,6 +4427,11 @@ async def test_list_products_in_product_set_async(transport: str = "grpc_asyncio
assert response.next_page_token == "next_page_token_value"
+@pytest.mark.asyncio
+async def test_list_products_in_product_set_async_from_dict():
+ await test_list_products_in_product_set_async(request_type=dict)
+
+
def test_list_products_in_product_set_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -4334,7 +4442,7 @@ def test_list_products_in_product_set_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
call.return_value = product_search_service.ListProductsInProductSetResponse()
@@ -4361,7 +4469,7 @@ async def test_list_products_in_product_set_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ListProductsInProductSetResponse()
@@ -4384,7 +4492,7 @@ def test_list_products_in_product_set_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductsInProductSetResponse()
@@ -4418,7 +4526,7 @@ async def test_list_products_in_product_set_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductsInProductSetResponse()
@@ -4455,7 +4563,7 @@ def test_list_products_in_product_set_pager():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -4500,7 +4608,7 @@ def test_list_products_in_product_set_pages():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -4537,7 +4645,7 @@ async def test_list_products_in_product_set_async_pager():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_products_in_product_set),
+ type(client.transport.list_products_in_product_set),
"__call__",
new_callable=mock.AsyncMock,
) as call:
@@ -4581,7 +4689,7 @@ async def test_list_products_in_product_set_async_pages():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_products_in_product_set),
+ type(client.transport.list_products_in_product_set),
"__call__",
new_callable=mock.AsyncMock,
) as call:
@@ -4632,7 +4740,7 @@ def test_import_product_sets(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.import_product_sets), "__call__"
+ type(client.transport.import_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/spam")
@@ -4654,18 +4762,21 @@ def test_import_product_sets_from_dict():
@pytest.mark.asyncio
-async def test_import_product_sets_async(transport: str = "grpc_asyncio"):
+async def test_import_product_sets_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.ImportProductSetsRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.ImportProductSetsRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.import_product_sets), "__call__"
+ type(client.transport.import_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -4678,12 +4789,17 @@ async def test_import_product_sets_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.ImportProductSetsRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, future.Future)
+@pytest.mark.asyncio
+async def test_import_product_sets_async_from_dict():
+ await test_import_product_sets_async(request_type=dict)
+
+
def test_import_product_sets_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -4694,7 +4810,7 @@ def test_import_product_sets_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.import_product_sets), "__call__"
+ type(client.transport.import_product_sets), "__call__"
) as call:
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -4721,7 +4837,7 @@ async def test_import_product_sets_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.import_product_sets), "__call__"
+ type(client.transport.import_product_sets), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
operations_pb2.Operation(name="operations/op")
@@ -4744,7 +4860,7 @@ def test_import_product_sets_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.import_product_sets), "__call__"
+ type(client.transport.import_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -4799,7 +4915,7 @@ async def test_import_product_sets_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.import_product_sets), "__call__"
+ type(client.transport.import_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -4888,7 +5004,7 @@ def test_transport_instance():
credentials=credentials.AnonymousCredentials(),
)
client = ProductSearchClient(transport=transport)
- assert client._transport is transport
+ assert client.transport is transport
def test_transport_get_channel():
@@ -4924,7 +5040,7 @@ def test_transport_adc(transport_class):
def test_transport_grpc_default():
# A client should use the gRPC transport by default.
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
- assert isinstance(client._transport, transports.ProductSearchGrpcTransport,)
+ assert isinstance(client.transport, transports.ProductSearchGrpcTransport,)
def test_product_search_base_transport_error():
@@ -5049,7 +5165,7 @@ def test_product_search_host_no_port():
api_endpoint="vision.googleapis.com"
),
)
- assert client._transport._host == "vision.googleapis.com:443"
+ assert client.transport._host == "vision.googleapis.com:443"
def test_product_search_host_with_port():
@@ -5059,7 +5175,7 @@ def test_product_search_host_with_port():
api_endpoint="vision.googleapis.com:8000"
),
)
- assert client._transport._host == "vision.googleapis.com:8000"
+ assert client.transport._host == "vision.googleapis.com:8000"
def test_product_search_grpc_transport_channel():
@@ -5071,6 +5187,7 @@ def test_product_search_grpc_transport_channel():
)
assert transport.grpc_channel == channel
assert transport._host == "squid.clam.whelk:443"
+ assert transport._ssl_channel_credentials == None
def test_product_search_grpc_asyncio_transport_channel():
@@ -5082,6 +5199,7 @@ def test_product_search_grpc_asyncio_transport_channel():
)
assert transport.grpc_channel == channel
assert transport._host == "squid.clam.whelk:443"
+ assert transport._ssl_channel_credentials == None
@pytest.mark.parametrize(
@@ -5128,8 +5246,13 @@ def test_product_search_transport_channel_mtls_with_client_cert_source(transport
),
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
assert transport.grpc_channel == mock_grpc_channel
+ assert transport._ssl_channel_credentials == mock_ssl_cred
@pytest.mark.parametrize(
@@ -5171,6 +5294,10 @@ def test_product_search_transport_channel_mtls_with_adc(transport_class):
),
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
assert transport.grpc_channel == mock_grpc_channel
@@ -5179,7 +5306,7 @@ def test_product_search_grpc_lro_client():
client = ProductSearchClient(
credentials=credentials.AnonymousCredentials(), transport="grpc",
)
- transport = client._transport
+ transport = client.transport
# Ensure that we have a api-core operations client.
assert isinstance(transport.operations_client, operations_v1.OperationsClient,)
@@ -5192,7 +5319,7 @@ def test_product_search_grpc_lro_async_client():
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio",
)
- transport = client._client._transport
+ transport = client.transport
# Ensure that we have a api-core operations client.
assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,)
@@ -5227,9 +5354,9 @@ def test_parse_product_path():
def test_product_set_path():
- project = "squid"
- location = "clam"
- product_set = "whelk"
+ project = "cuttlefish"
+ location = "mussel"
+ product_set = "winkle"
expected = "projects/{project}/locations/{location}/productSets/{product_set}".format(
project=project, location=location, product_set=product_set,
@@ -5240,9 +5367,9 @@ def test_product_set_path():
def test_parse_product_set_path():
expected = {
- "project": "octopus",
- "location": "oyster",
- "product_set": "nudibranch",
+ "project": "nautilus",
+ "location": "scallop",
+ "product_set": "abalone",
}
path = ProductSearchClient.product_set_path(**expected)
@@ -5283,6 +5410,107 @@ def test_parse_reference_image_path():
assert expected == actual
+def test_common_billing_account_path():
+ billing_account = "winkle"
+
+ expected = "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+ actual = ProductSearchClient.common_billing_account_path(billing_account)
+ assert expected == actual
+
+
+def test_parse_common_billing_account_path():
+ expected = {
+ "billing_account": "nautilus",
+ }
+ path = ProductSearchClient.common_billing_account_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ProductSearchClient.parse_common_billing_account_path(path)
+ assert expected == actual
+
+
+def test_common_folder_path():
+ folder = "scallop"
+
+ expected = "folders/{folder}".format(folder=folder,)
+ actual = ProductSearchClient.common_folder_path(folder)
+ assert expected == actual
+
+
+def test_parse_common_folder_path():
+ expected = {
+ "folder": "abalone",
+ }
+ path = ProductSearchClient.common_folder_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ProductSearchClient.parse_common_folder_path(path)
+ assert expected == actual
+
+
+def test_common_organization_path():
+ organization = "squid"
+
+ expected = "organizations/{organization}".format(organization=organization,)
+ actual = ProductSearchClient.common_organization_path(organization)
+ assert expected == actual
+
+
+def test_parse_common_organization_path():
+ expected = {
+ "organization": "clam",
+ }
+ path = ProductSearchClient.common_organization_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ProductSearchClient.parse_common_organization_path(path)
+ assert expected == actual
+
+
+def test_common_project_path():
+ project = "whelk"
+
+ expected = "projects/{project}".format(project=project,)
+ actual = ProductSearchClient.common_project_path(project)
+ assert expected == actual
+
+
+def test_parse_common_project_path():
+ expected = {
+ "project": "octopus",
+ }
+ path = ProductSearchClient.common_project_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ProductSearchClient.parse_common_project_path(path)
+ assert expected == actual
+
+
+def test_common_location_path():
+ project = "oyster"
+ location = "nudibranch"
+
+ expected = "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+ actual = ProductSearchClient.common_location_path(project, location)
+ assert expected == actual
+
+
+def test_parse_common_location_path():
+ expected = {
+ "project": "cuttlefish",
+ "location": "mussel",
+ }
+ path = ProductSearchClient.common_location_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ProductSearchClient.parse_common_location_path(path)
+ assert expected == actual
+
+
def test_client_withDEFAULT_CLIENT_INFO():
client_info = gapic_v1.client_info.ClientInfo()
diff --git a/tests/unit/gapic/vision_v1p4beta1/test_image_annotator.py b/tests/unit/gapic/vision_v1p4beta1/test_image_annotator.py
index 3fe919f8..2a8d5072 100644
--- a/tests/unit/gapic/vision_v1p4beta1/test_image_annotator.py
+++ b/tests/unit/gapic/vision_v1p4beta1/test_image_annotator.py
@@ -103,12 +103,12 @@ def test_image_annotator_client_from_service_account_file(client_class):
) as factory:
factory.return_value = creds
client = client_class.from_service_account_file("dummy/file/path.json")
- assert client._transport._credentials == creds
+ assert client.transport._credentials == creds
client = client_class.from_service_account_json("dummy/file/path.json")
- assert client._transport._credentials == creds
+ assert client.transport._credentials == creds
- assert client._transport._host == "vision.googleapis.com:443"
+ assert client.transport._host == "vision.googleapis.com:443"
def test_image_annotator_client_get_transport_class():
@@ -459,7 +459,7 @@ def test_batch_annotate_images(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.batch_annotate_images), "__call__"
+ type(client.transport.batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = image_annotator.BatchAnnotateImagesResponse()
@@ -473,6 +473,7 @@ def test_batch_annotate_images(
assert args[0] == image_annotator.BatchAnnotateImagesRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, image_annotator.BatchAnnotateImagesResponse)
@@ -481,18 +482,21 @@ def test_batch_annotate_images_from_dict():
@pytest.mark.asyncio
-async def test_batch_annotate_images_async(transport: str = "grpc_asyncio"):
+async def test_batch_annotate_images_async(
+ transport: str = "grpc_asyncio",
+ request_type=image_annotator.BatchAnnotateImagesRequest,
+):
client = ImageAnnotatorAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = image_annotator.BatchAnnotateImagesRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.batch_annotate_images), "__call__"
+ type(client.transport.batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -505,18 +509,23 @@ async def test_batch_annotate_images_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == image_annotator.BatchAnnotateImagesRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, image_annotator.BatchAnnotateImagesResponse)
+@pytest.mark.asyncio
+async def test_batch_annotate_images_async_from_dict():
+ await test_batch_annotate_images_async(request_type=dict)
+
+
def test_batch_annotate_images_flattened():
client = ImageAnnotatorClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.batch_annotate_images), "__call__"
+ type(client.transport.batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = image_annotator.BatchAnnotateImagesResponse()
@@ -565,7 +574,7 @@ async def test_batch_annotate_images_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.batch_annotate_images), "__call__"
+ type(client.transport.batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = image_annotator.BatchAnnotateImagesResponse()
@@ -625,7 +634,7 @@ def test_batch_annotate_files(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.batch_annotate_files), "__call__"
+ type(client.transport.batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = image_annotator.BatchAnnotateFilesResponse()
@@ -639,6 +648,7 @@ def test_batch_annotate_files(
assert args[0] == image_annotator.BatchAnnotateFilesRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, image_annotator.BatchAnnotateFilesResponse)
@@ -647,18 +657,21 @@ def test_batch_annotate_files_from_dict():
@pytest.mark.asyncio
-async def test_batch_annotate_files_async(transport: str = "grpc_asyncio"):
+async def test_batch_annotate_files_async(
+ transport: str = "grpc_asyncio",
+ request_type=image_annotator.BatchAnnotateFilesRequest,
+):
client = ImageAnnotatorAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = image_annotator.BatchAnnotateFilesRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.batch_annotate_files), "__call__"
+ type(client.transport.batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -671,18 +684,23 @@ async def test_batch_annotate_files_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == image_annotator.BatchAnnotateFilesRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, image_annotator.BatchAnnotateFilesResponse)
+@pytest.mark.asyncio
+async def test_batch_annotate_files_async_from_dict():
+ await test_batch_annotate_files_async(request_type=dict)
+
+
def test_batch_annotate_files_flattened():
client = ImageAnnotatorClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.batch_annotate_files), "__call__"
+ type(client.transport.batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = image_annotator.BatchAnnotateFilesResponse()
@@ -737,7 +755,7 @@ async def test_batch_annotate_files_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.batch_annotate_files), "__call__"
+ type(client.transport.batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = image_annotator.BatchAnnotateFilesResponse()
@@ -804,7 +822,7 @@ def test_async_batch_annotate_images(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.async_batch_annotate_images), "__call__"
+ type(client.transport.async_batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/spam")
@@ -826,18 +844,21 @@ def test_async_batch_annotate_images_from_dict():
@pytest.mark.asyncio
-async def test_async_batch_annotate_images_async(transport: str = "grpc_asyncio"):
+async def test_async_batch_annotate_images_async(
+ transport: str = "grpc_asyncio",
+ request_type=image_annotator.AsyncBatchAnnotateImagesRequest,
+):
client = ImageAnnotatorAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = image_annotator.AsyncBatchAnnotateImagesRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.async_batch_annotate_images), "__call__"
+ type(client.transport.async_batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -850,18 +871,23 @@ async def test_async_batch_annotate_images_async(transport: str = "grpc_asyncio"
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == image_annotator.AsyncBatchAnnotateImagesRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, future.Future)
+@pytest.mark.asyncio
+async def test_async_batch_annotate_images_async_from_dict():
+ await test_async_batch_annotate_images_async(request_type=dict)
+
+
def test_async_batch_annotate_images_flattened():
client = ImageAnnotatorClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.async_batch_annotate_images), "__call__"
+ type(client.transport.async_batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -920,7 +946,7 @@ async def test_async_batch_annotate_images_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.async_batch_annotate_images), "__call__"
+ type(client.transport.async_batch_annotate_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -990,7 +1016,7 @@ def test_async_batch_annotate_files(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.async_batch_annotate_files), "__call__"
+ type(client.transport.async_batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/spam")
@@ -1012,18 +1038,21 @@ def test_async_batch_annotate_files_from_dict():
@pytest.mark.asyncio
-async def test_async_batch_annotate_files_async(transport: str = "grpc_asyncio"):
+async def test_async_batch_annotate_files_async(
+ transport: str = "grpc_asyncio",
+ request_type=image_annotator.AsyncBatchAnnotateFilesRequest,
+):
client = ImageAnnotatorAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = image_annotator.AsyncBatchAnnotateFilesRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.async_batch_annotate_files), "__call__"
+ type(client.transport.async_batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -1036,18 +1065,23 @@ async def test_async_batch_annotate_files_async(transport: str = "grpc_asyncio")
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == image_annotator.AsyncBatchAnnotateFilesRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, future.Future)
+@pytest.mark.asyncio
+async def test_async_batch_annotate_files_async_from_dict():
+ await test_async_batch_annotate_files_async(request_type=dict)
+
+
def test_async_batch_annotate_files_flattened():
client = ImageAnnotatorClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.async_batch_annotate_files), "__call__"
+ type(client.transport.async_batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -1102,7 +1136,7 @@ async def test_async_batch_annotate_files_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.async_batch_annotate_files), "__call__"
+ type(client.transport.async_batch_annotate_files), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -1191,7 +1225,7 @@ def test_transport_instance():
credentials=credentials.AnonymousCredentials(),
)
client = ImageAnnotatorClient(transport=transport)
- assert client._transport is transport
+ assert client.transport is transport
def test_transport_get_channel():
@@ -1227,7 +1261,7 @@ def test_transport_adc(transport_class):
def test_transport_grpc_default():
# A client should use the gRPC transport by default.
client = ImageAnnotatorClient(credentials=credentials.AnonymousCredentials(),)
- assert isinstance(client._transport, transports.ImageAnnotatorGrpcTransport,)
+ assert isinstance(client.transport, transports.ImageAnnotatorGrpcTransport,)
def test_image_annotator_base_transport_error():
@@ -1338,7 +1372,7 @@ def test_image_annotator_host_no_port():
api_endpoint="vision.googleapis.com"
),
)
- assert client._transport._host == "vision.googleapis.com:443"
+ assert client.transport._host == "vision.googleapis.com:443"
def test_image_annotator_host_with_port():
@@ -1348,7 +1382,7 @@ def test_image_annotator_host_with_port():
api_endpoint="vision.googleapis.com:8000"
),
)
- assert client._transport._host == "vision.googleapis.com:8000"
+ assert client.transport._host == "vision.googleapis.com:8000"
def test_image_annotator_grpc_transport_channel():
@@ -1360,6 +1394,7 @@ def test_image_annotator_grpc_transport_channel():
)
assert transport.grpc_channel == channel
assert transport._host == "squid.clam.whelk:443"
+ assert transport._ssl_channel_credentials == None
def test_image_annotator_grpc_asyncio_transport_channel():
@@ -1371,6 +1406,7 @@ def test_image_annotator_grpc_asyncio_transport_channel():
)
assert transport.grpc_channel == channel
assert transport._host == "squid.clam.whelk:443"
+ assert transport._ssl_channel_credentials == None
@pytest.mark.parametrize(
@@ -1419,8 +1455,13 @@ def test_image_annotator_transport_channel_mtls_with_client_cert_source(
),
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
assert transport.grpc_channel == mock_grpc_channel
+ assert transport._ssl_channel_credentials == mock_ssl_cred
@pytest.mark.parametrize(
@@ -1462,6 +1503,10 @@ def test_image_annotator_transport_channel_mtls_with_adc(transport_class):
),
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
assert transport.grpc_channel == mock_grpc_channel
@@ -1470,7 +1515,7 @@ def test_image_annotator_grpc_lro_client():
client = ImageAnnotatorClient(
credentials=credentials.AnonymousCredentials(), transport="grpc",
)
- transport = client._transport
+ transport = client.transport
# Ensure that we have a api-core operations client.
assert isinstance(transport.operations_client, operations_v1.OperationsClient,)
@@ -1483,7 +1528,7 @@ def test_image_annotator_grpc_lro_async_client():
client = ImageAnnotatorAsyncClient(
credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio",
)
- transport = client._client._transport
+ transport = client.transport
# Ensure that we have a api-core operations client.
assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,)
@@ -1492,6 +1537,157 @@ def test_image_annotator_grpc_lro_async_client():
assert transport.operations_client is transport.operations_client
+def test_product_path():
+ project = "squid"
+ location = "clam"
+ product = "whelk"
+
+ expected = "projects/{project}/locations/{location}/products/{product}".format(
+ project=project, location=location, product=product,
+ )
+ actual = ImageAnnotatorClient.product_path(project, location, product)
+ assert expected == actual
+
+
+def test_parse_product_path():
+ expected = {
+ "project": "octopus",
+ "location": "oyster",
+ "product": "nudibranch",
+ }
+ path = ImageAnnotatorClient.product_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_product_path(path)
+ assert expected == actual
+
+
+def test_product_set_path():
+ project = "cuttlefish"
+ location = "mussel"
+ product_set = "winkle"
+
+ expected = "projects/{project}/locations/{location}/productSets/{product_set}".format(
+ project=project, location=location, product_set=product_set,
+ )
+ actual = ImageAnnotatorClient.product_set_path(project, location, product_set)
+ assert expected == actual
+
+
+def test_parse_product_set_path():
+ expected = {
+ "project": "nautilus",
+ "location": "scallop",
+ "product_set": "abalone",
+ }
+ path = ImageAnnotatorClient.product_set_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_product_set_path(path)
+ assert expected == actual
+
+
+def test_common_billing_account_path():
+ billing_account = "squid"
+
+ expected = "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+ actual = ImageAnnotatorClient.common_billing_account_path(billing_account)
+ assert expected == actual
+
+
+def test_parse_common_billing_account_path():
+ expected = {
+ "billing_account": "clam",
+ }
+ path = ImageAnnotatorClient.common_billing_account_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_billing_account_path(path)
+ assert expected == actual
+
+
+def test_common_folder_path():
+ folder = "whelk"
+
+ expected = "folders/{folder}".format(folder=folder,)
+ actual = ImageAnnotatorClient.common_folder_path(folder)
+ assert expected == actual
+
+
+def test_parse_common_folder_path():
+ expected = {
+ "folder": "octopus",
+ }
+ path = ImageAnnotatorClient.common_folder_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_folder_path(path)
+ assert expected == actual
+
+
+def test_common_organization_path():
+ organization = "oyster"
+
+ expected = "organizations/{organization}".format(organization=organization,)
+ actual = ImageAnnotatorClient.common_organization_path(organization)
+ assert expected == actual
+
+
+def test_parse_common_organization_path():
+ expected = {
+ "organization": "nudibranch",
+ }
+ path = ImageAnnotatorClient.common_organization_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_organization_path(path)
+ assert expected == actual
+
+
+def test_common_project_path():
+ project = "cuttlefish"
+
+ expected = "projects/{project}".format(project=project,)
+ actual = ImageAnnotatorClient.common_project_path(project)
+ assert expected == actual
+
+
+def test_parse_common_project_path():
+ expected = {
+ "project": "mussel",
+ }
+ path = ImageAnnotatorClient.common_project_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_project_path(path)
+ assert expected == actual
+
+
+def test_common_location_path():
+ project = "winkle"
+ location = "nautilus"
+
+ expected = "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+ actual = ImageAnnotatorClient.common_location_path(project, location)
+ assert expected == actual
+
+
+def test_parse_common_location_path():
+ expected = {
+ "project": "scallop",
+ "location": "abalone",
+ }
+ path = ImageAnnotatorClient.common_location_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ImageAnnotatorClient.parse_common_location_path(path)
+ assert expected == actual
+
+
def test_client_withDEFAULT_CLIENT_INFO():
client_info = gapic_v1.client_info.ClientInfo()
diff --git a/tests/unit/gapic/vision_v1p4beta1/test_product_search.py b/tests/unit/gapic/vision_v1p4beta1/test_product_search.py
index 99f91b47..0ad20e9a 100644
--- a/tests/unit/gapic/vision_v1p4beta1/test_product_search.py
+++ b/tests/unit/gapic/vision_v1p4beta1/test_product_search.py
@@ -105,12 +105,12 @@ def test_product_search_client_from_service_account_file(client_class):
) as factory:
factory.return_value = creds
client = client_class.from_service_account_file("dummy/file/path.json")
- assert client._transport._credentials == creds
+ assert client.transport._credentials == creds
client = client_class.from_service_account_json("dummy/file/path.json")
- assert client._transport._credentials == creds
+ assert client.transport._credentials == creds
- assert client._transport._host == "vision.googleapis.com:443"
+ assert client.transport._host == "vision.googleapis.com:443"
def test_product_search_client_get_transport_class():
@@ -461,7 +461,7 @@ def test_create_product_set(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.create_product_set), "__call__"
+ type(client.transport.create_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet(
@@ -477,6 +477,7 @@ def test_create_product_set(
assert args[0] == product_search_service.CreateProductSetRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.ProductSet)
assert response.name == "name_value"
@@ -489,18 +490,21 @@ def test_create_product_set_from_dict():
@pytest.mark.asyncio
-async def test_create_product_set_async(transport: str = "grpc_asyncio"):
+async def test_create_product_set_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.CreateProductSetRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.CreateProductSetRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.create_product_set), "__call__"
+ type(client.transport.create_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -515,7 +519,7 @@ async def test_create_product_set_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.CreateProductSetRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.ProductSet)
@@ -525,6 +529,11 @@ async def test_create_product_set_async(transport: str = "grpc_asyncio"):
assert response.display_name == "display_name_value"
+@pytest.mark.asyncio
+async def test_create_product_set_async_from_dict():
+ await test_create_product_set_async(request_type=dict)
+
+
def test_create_product_set_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -535,7 +544,7 @@ def test_create_product_set_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.create_product_set), "__call__"
+ type(client.transport.create_product_set), "__call__"
) as call:
call.return_value = product_search_service.ProductSet()
@@ -562,7 +571,7 @@ async def test_create_product_set_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.create_product_set), "__call__"
+ type(client.transport.create_product_set), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ProductSet()
@@ -585,7 +594,7 @@ def test_create_product_set_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.create_product_set), "__call__"
+ type(client.transport.create_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet()
@@ -632,7 +641,7 @@ async def test_create_product_set_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.create_product_set), "__call__"
+ type(client.transport.create_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet()
@@ -690,7 +699,7 @@ def test_list_product_sets(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductSetsResponse(
@@ -706,6 +715,7 @@ def test_list_product_sets(
assert args[0] == product_search_service.ListProductSetsRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, pagers.ListProductSetsPager)
assert response.next_page_token == "next_page_token_value"
@@ -716,18 +726,21 @@ def test_list_product_sets_from_dict():
@pytest.mark.asyncio
-async def test_list_product_sets_async(transport: str = "grpc_asyncio"):
+async def test_list_product_sets_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.ListProductSetsRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.ListProductSetsRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -742,7 +755,7 @@ async def test_list_product_sets_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.ListProductSetsRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, pagers.ListProductSetsAsyncPager)
@@ -750,6 +763,11 @@ async def test_list_product_sets_async(transport: str = "grpc_asyncio"):
assert response.next_page_token == "next_page_token_value"
+@pytest.mark.asyncio
+async def test_list_product_sets_async_from_dict():
+ await test_list_product_sets_async(request_type=dict)
+
+
def test_list_product_sets_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -760,7 +778,7 @@ def test_list_product_sets_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
call.return_value = product_search_service.ListProductSetsResponse()
@@ -787,7 +805,7 @@ async def test_list_product_sets_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ListProductSetsResponse()
@@ -810,7 +828,7 @@ def test_list_product_sets_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductSetsResponse()
@@ -844,7 +862,7 @@ async def test_list_product_sets_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductSetsResponse()
@@ -881,7 +899,7 @@ def test_list_product_sets_pager():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -927,7 +945,7 @@ def test_list_product_sets_pages():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_product_sets), "__call__"
+ type(client.transport.list_product_sets), "__call__"
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -965,7 +983,7 @@ async def test_list_product_sets_async_pager():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_product_sets),
+ type(client.transport.list_product_sets),
"__call__",
new_callable=mock.AsyncMock,
) as call:
@@ -1010,7 +1028,7 @@ async def test_list_product_sets_async_pages():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_product_sets),
+ type(client.transport.list_product_sets),
"__call__",
new_callable=mock.AsyncMock,
) as call:
@@ -1058,7 +1076,7 @@ def test_get_product_set(
request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.get_product_set), "__call__") as call:
+ with mock.patch.object(type(client.transport.get_product_set), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet(
name="name_value", display_name="display_name_value",
@@ -1073,6 +1091,7 @@ def test_get_product_set(
assert args[0] == product_search_service.GetProductSetRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.ProductSet)
assert response.name == "name_value"
@@ -1085,19 +1104,20 @@ def test_get_product_set_from_dict():
@pytest.mark.asyncio
-async def test_get_product_set_async(transport: str = "grpc_asyncio"):
+async def test_get_product_set_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.GetProductSetRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.GetProductSetRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.get_product_set), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.get_product_set), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ProductSet(
@@ -1111,7 +1131,7 @@ async def test_get_product_set_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.GetProductSetRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.ProductSet)
@@ -1121,6 +1141,11 @@ async def test_get_product_set_async(transport: str = "grpc_asyncio"):
assert response.display_name == "display_name_value"
+@pytest.mark.asyncio
+async def test_get_product_set_async_from_dict():
+ await test_get_product_set_async(request_type=dict)
+
+
def test_get_product_set_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -1130,7 +1155,7 @@ def test_get_product_set_field_headers():
request.name = "name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.get_product_set), "__call__") as call:
+ with mock.patch.object(type(client.transport.get_product_set), "__call__") as call:
call.return_value = product_search_service.ProductSet()
client.get_product_set(request)
@@ -1155,9 +1180,7 @@ async def test_get_product_set_field_headers_async():
request.name = "name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.get_product_set), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.get_product_set), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ProductSet()
)
@@ -1178,7 +1201,7 @@ def test_get_product_set_flattened():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.get_product_set), "__call__") as call:
+ with mock.patch.object(type(client.transport.get_product_set), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet()
@@ -1210,9 +1233,7 @@ async def test_get_product_set_flattened_async():
client = ProductSearchAsyncClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.get_product_set), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.get_product_set), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet()
@@ -1256,7 +1277,7 @@ def test_update_product_set(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.update_product_set), "__call__"
+ type(client.transport.update_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet(
@@ -1272,6 +1293,7 @@ def test_update_product_set(
assert args[0] == product_search_service.UpdateProductSetRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.ProductSet)
assert response.name == "name_value"
@@ -1284,18 +1306,21 @@ def test_update_product_set_from_dict():
@pytest.mark.asyncio
-async def test_update_product_set_async(transport: str = "grpc_asyncio"):
+async def test_update_product_set_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.UpdateProductSetRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.UpdateProductSetRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.update_product_set), "__call__"
+ type(client.transport.update_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -1310,7 +1335,7 @@ async def test_update_product_set_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.UpdateProductSetRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.ProductSet)
@@ -1320,6 +1345,11 @@ async def test_update_product_set_async(transport: str = "grpc_asyncio"):
assert response.display_name == "display_name_value"
+@pytest.mark.asyncio
+async def test_update_product_set_async_from_dict():
+ await test_update_product_set_async(request_type=dict)
+
+
def test_update_product_set_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -1330,7 +1360,7 @@ def test_update_product_set_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.update_product_set), "__call__"
+ type(client.transport.update_product_set), "__call__"
) as call:
call.return_value = product_search_service.ProductSet()
@@ -1359,7 +1389,7 @@ async def test_update_product_set_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.update_product_set), "__call__"
+ type(client.transport.update_product_set), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ProductSet()
@@ -1384,7 +1414,7 @@ def test_update_product_set_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.update_product_set), "__call__"
+ type(client.transport.update_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet()
@@ -1427,7 +1457,7 @@ async def test_update_product_set_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.update_product_set), "__call__"
+ type(client.transport.update_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ProductSet()
@@ -1481,7 +1511,7 @@ def test_delete_product_set(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.delete_product_set), "__call__"
+ type(client.transport.delete_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -1503,18 +1533,21 @@ def test_delete_product_set_from_dict():
@pytest.mark.asyncio
-async def test_delete_product_set_async(transport: str = "grpc_asyncio"):
+async def test_delete_product_set_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.DeleteProductSetRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.DeleteProductSetRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.delete_product_set), "__call__"
+ type(client.transport.delete_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -1525,12 +1558,17 @@ async def test_delete_product_set_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.DeleteProductSetRequest()
# Establish that the response is the type that we expect.
assert response is None
+@pytest.mark.asyncio
+async def test_delete_product_set_async_from_dict():
+ await test_delete_product_set_async(request_type=dict)
+
+
def test_delete_product_set_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -1541,7 +1579,7 @@ def test_delete_product_set_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.delete_product_set), "__call__"
+ type(client.transport.delete_product_set), "__call__"
) as call:
call.return_value = None
@@ -1568,7 +1606,7 @@ async def test_delete_product_set_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.delete_product_set), "__call__"
+ type(client.transport.delete_product_set), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -1589,7 +1627,7 @@ def test_delete_product_set_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.delete_product_set), "__call__"
+ type(client.transport.delete_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -1623,7 +1661,7 @@ async def test_delete_product_set_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.delete_product_set), "__call__"
+ type(client.transport.delete_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -1665,7 +1703,7 @@ def test_create_product(
request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.create_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.create_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product(
name="name_value",
@@ -1683,6 +1721,7 @@ def test_create_product(
assert args[0] == product_search_service.CreateProductRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.Product)
assert response.name == "name_value"
@@ -1699,19 +1738,20 @@ def test_create_product_from_dict():
@pytest.mark.asyncio
-async def test_create_product_async(transport: str = "grpc_asyncio"):
+async def test_create_product_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.CreateProductRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.CreateProductRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.create_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.create_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.Product(
@@ -1728,7 +1768,7 @@ async def test_create_product_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.CreateProductRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.Product)
@@ -1742,6 +1782,11 @@ async def test_create_product_async(transport: str = "grpc_asyncio"):
assert response.product_category == "product_category_value"
+@pytest.mark.asyncio
+async def test_create_product_async_from_dict():
+ await test_create_product_async(request_type=dict)
+
+
def test_create_product_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -1751,7 +1796,7 @@ def test_create_product_field_headers():
request.parent = "parent/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.create_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.create_product), "__call__") as call:
call.return_value = product_search_service.Product()
client.create_product(request)
@@ -1776,9 +1821,7 @@ async def test_create_product_field_headers_async():
request.parent = "parent/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.create_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.create_product), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.Product()
)
@@ -1799,7 +1842,7 @@ def test_create_product_flattened():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.create_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.create_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product()
@@ -1842,9 +1885,7 @@ async def test_create_product_flattened_async():
client = ProductSearchAsyncClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.create_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.create_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product()
@@ -1898,7 +1939,7 @@ def test_list_products(
request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.list_products), "__call__") as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductsResponse(
next_page_token="next_page_token_value",
@@ -1913,6 +1954,7 @@ def test_list_products(
assert args[0] == product_search_service.ListProductsRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, pagers.ListProductsPager)
assert response.next_page_token == "next_page_token_value"
@@ -1923,19 +1965,20 @@ def test_list_products_from_dict():
@pytest.mark.asyncio
-async def test_list_products_async(transport: str = "grpc_asyncio"):
+async def test_list_products_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.ListProductsRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.ListProductsRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.list_products), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ListProductsResponse(
@@ -1949,7 +1992,7 @@ async def test_list_products_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.ListProductsRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, pagers.ListProductsAsyncPager)
@@ -1957,6 +2000,11 @@ async def test_list_products_async(transport: str = "grpc_asyncio"):
assert response.next_page_token == "next_page_token_value"
+@pytest.mark.asyncio
+async def test_list_products_async_from_dict():
+ await test_list_products_async(request_type=dict)
+
+
def test_list_products_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -1966,7 +2014,7 @@ def test_list_products_field_headers():
request.parent = "parent/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.list_products), "__call__") as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
call.return_value = product_search_service.ListProductsResponse()
client.list_products(request)
@@ -1991,9 +2039,7 @@ async def test_list_products_field_headers_async():
request.parent = "parent/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.list_products), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ListProductsResponse()
)
@@ -2014,7 +2060,7 @@ def test_list_products_flattened():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.list_products), "__call__") as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductsResponse()
@@ -2046,9 +2092,7 @@ async def test_list_products_flattened_async():
client = ProductSearchAsyncClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.list_products), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductsResponse()
@@ -2083,7 +2127,7 @@ def test_list_products_pager():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials,)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.list_products), "__call__") as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
# Set the response to a series of pages.
call.side_effect = (
product_search_service.ListProductsResponse(
@@ -2126,7 +2170,7 @@ def test_list_products_pages():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials,)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.list_products), "__call__") as call:
+ with mock.patch.object(type(client.transport.list_products), "__call__") as call:
# Set the response to a series of pages.
call.side_effect = (
product_search_service.ListProductsResponse(
@@ -2162,9 +2206,7 @@ async def test_list_products_async_pager():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_products),
- "__call__",
- new_callable=mock.AsyncMock,
+ type(client.transport.list_products), "__call__", new_callable=mock.AsyncMock
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -2206,9 +2248,7 @@ async def test_list_products_async_pages():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_products),
- "__call__",
- new_callable=mock.AsyncMock,
+ type(client.transport.list_products), "__call__", new_callable=mock.AsyncMock
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -2253,7 +2293,7 @@ def test_get_product(
request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.get_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.get_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product(
name="name_value",
@@ -2271,6 +2311,7 @@ def test_get_product(
assert args[0] == product_search_service.GetProductRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.Product)
assert response.name == "name_value"
@@ -2287,19 +2328,20 @@ def test_get_product_from_dict():
@pytest.mark.asyncio
-async def test_get_product_async(transport: str = "grpc_asyncio"):
+async def test_get_product_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.GetProductRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.GetProductRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.get_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.get_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.Product(
@@ -2316,7 +2358,7 @@ async def test_get_product_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.GetProductRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.Product)
@@ -2330,6 +2372,11 @@ async def test_get_product_async(transport: str = "grpc_asyncio"):
assert response.product_category == "product_category_value"
+@pytest.mark.asyncio
+async def test_get_product_async_from_dict():
+ await test_get_product_async(request_type=dict)
+
+
def test_get_product_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -2339,7 +2386,7 @@ def test_get_product_field_headers():
request.name = "name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.get_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.get_product), "__call__") as call:
call.return_value = product_search_service.Product()
client.get_product(request)
@@ -2364,9 +2411,7 @@ async def test_get_product_field_headers_async():
request.name = "name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.get_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.get_product), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.Product()
)
@@ -2387,7 +2432,7 @@ def test_get_product_flattened():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.get_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.get_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product()
@@ -2419,9 +2464,7 @@ async def test_get_product_flattened_async():
client = ProductSearchAsyncClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.get_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.get_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product()
@@ -2464,7 +2507,7 @@ def test_update_product(
request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.update_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.update_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product(
name="name_value",
@@ -2482,6 +2525,7 @@ def test_update_product(
assert args[0] == product_search_service.UpdateProductRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.Product)
assert response.name == "name_value"
@@ -2498,19 +2542,20 @@ def test_update_product_from_dict():
@pytest.mark.asyncio
-async def test_update_product_async(transport: str = "grpc_asyncio"):
+async def test_update_product_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.UpdateProductRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.UpdateProductRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.update_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.update_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.Product(
@@ -2527,7 +2572,7 @@ async def test_update_product_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.UpdateProductRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.Product)
@@ -2541,6 +2586,11 @@ async def test_update_product_async(transport: str = "grpc_asyncio"):
assert response.product_category == "product_category_value"
+@pytest.mark.asyncio
+async def test_update_product_async_from_dict():
+ await test_update_product_async(request_type=dict)
+
+
def test_update_product_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -2550,7 +2600,7 @@ def test_update_product_field_headers():
request.product.name = "product.name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.update_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.update_product), "__call__") as call:
call.return_value = product_search_service.Product()
client.update_product(request)
@@ -2577,9 +2627,7 @@ async def test_update_product_field_headers_async():
request.product.name = "product.name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.update_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.update_product), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.Product()
)
@@ -2602,7 +2650,7 @@ def test_update_product_flattened():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.update_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.update_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product()
@@ -2641,9 +2689,7 @@ async def test_update_product_flattened_async():
client = ProductSearchAsyncClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.update_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.update_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.Product()
@@ -2693,7 +2739,7 @@ def test_delete_product(
request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.delete_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.delete_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -2714,19 +2760,20 @@ def test_delete_product_from_dict():
@pytest.mark.asyncio
-async def test_delete_product_async(transport: str = "grpc_asyncio"):
+async def test_delete_product_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.DeleteProductRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.DeleteProductRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.delete_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.delete_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -2736,12 +2783,17 @@ async def test_delete_product_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.DeleteProductRequest()
# Establish that the response is the type that we expect.
assert response is None
+@pytest.mark.asyncio
+async def test_delete_product_async_from_dict():
+ await test_delete_product_async(request_type=dict)
+
+
def test_delete_product_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -2751,7 +2803,7 @@ def test_delete_product_field_headers():
request.name = "name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.delete_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.delete_product), "__call__") as call:
call.return_value = None
client.delete_product(request)
@@ -2776,9 +2828,7 @@ async def test_delete_product_field_headers_async():
request.name = "name/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.delete_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.delete_product), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
await client.delete_product(request)
@@ -2797,7 +2847,7 @@ def test_delete_product_flattened():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.delete_product), "__call__") as call:
+ with mock.patch.object(type(client.transport.delete_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -2829,9 +2879,7 @@ async def test_delete_product_flattened_async():
client = ProductSearchAsyncClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.delete_product), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.delete_product), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -2874,7 +2922,7 @@ def test_create_reference_image(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.create_reference_image), "__call__"
+ type(client.transport.create_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ReferenceImage(
@@ -2890,6 +2938,7 @@ def test_create_reference_image(
assert args[0] == product_search_service.CreateReferenceImageRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.ReferenceImage)
assert response.name == "name_value"
@@ -2902,18 +2951,21 @@ def test_create_reference_image_from_dict():
@pytest.mark.asyncio
-async def test_create_reference_image_async(transport: str = "grpc_asyncio"):
+async def test_create_reference_image_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.CreateReferenceImageRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.CreateReferenceImageRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.create_reference_image), "__call__"
+ type(client.transport.create_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -2926,7 +2978,7 @@ async def test_create_reference_image_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.CreateReferenceImageRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.ReferenceImage)
@@ -2936,6 +2988,11 @@ async def test_create_reference_image_async(transport: str = "grpc_asyncio"):
assert response.uri == "uri_value"
+@pytest.mark.asyncio
+async def test_create_reference_image_async_from_dict():
+ await test_create_reference_image_async(request_type=dict)
+
+
def test_create_reference_image_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -2946,7 +3003,7 @@ def test_create_reference_image_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.create_reference_image), "__call__"
+ type(client.transport.create_reference_image), "__call__"
) as call:
call.return_value = product_search_service.ReferenceImage()
@@ -2973,7 +3030,7 @@ async def test_create_reference_image_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.create_reference_image), "__call__"
+ type(client.transport.create_reference_image), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ReferenceImage()
@@ -2996,7 +3053,7 @@ def test_create_reference_image_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.create_reference_image), "__call__"
+ type(client.transport.create_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ReferenceImage()
@@ -3043,7 +3100,7 @@ async def test_create_reference_image_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.create_reference_image), "__call__"
+ type(client.transport.create_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ReferenceImage()
@@ -3102,7 +3159,7 @@ def test_delete_reference_image(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.delete_reference_image), "__call__"
+ type(client.transport.delete_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -3124,18 +3181,21 @@ def test_delete_reference_image_from_dict():
@pytest.mark.asyncio
-async def test_delete_reference_image_async(transport: str = "grpc_asyncio"):
+async def test_delete_reference_image_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.DeleteReferenceImageRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.DeleteReferenceImageRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.delete_reference_image), "__call__"
+ type(client.transport.delete_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -3146,12 +3206,17 @@ async def test_delete_reference_image_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.DeleteReferenceImageRequest()
# Establish that the response is the type that we expect.
assert response is None
+@pytest.mark.asyncio
+async def test_delete_reference_image_async_from_dict():
+ await test_delete_reference_image_async(request_type=dict)
+
+
def test_delete_reference_image_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -3162,7 +3227,7 @@ def test_delete_reference_image_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.delete_reference_image), "__call__"
+ type(client.transport.delete_reference_image), "__call__"
) as call:
call.return_value = None
@@ -3189,7 +3254,7 @@ async def test_delete_reference_image_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.delete_reference_image), "__call__"
+ type(client.transport.delete_reference_image), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -3210,7 +3275,7 @@ def test_delete_reference_image_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.delete_reference_image), "__call__"
+ type(client.transport.delete_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -3244,7 +3309,7 @@ async def test_delete_reference_image_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.delete_reference_image), "__call__"
+ type(client.transport.delete_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -3288,7 +3353,7 @@ def test_list_reference_images(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListReferenceImagesResponse(
@@ -3304,6 +3369,7 @@ def test_list_reference_images(
assert args[0] == product_search_service.ListReferenceImagesRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, pagers.ListReferenceImagesPager)
assert response.page_size == 951
@@ -3316,18 +3382,21 @@ def test_list_reference_images_from_dict():
@pytest.mark.asyncio
-async def test_list_reference_images_async(transport: str = "grpc_asyncio"):
+async def test_list_reference_images_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.ListReferenceImagesRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.ListReferenceImagesRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -3342,7 +3411,7 @@ async def test_list_reference_images_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.ListReferenceImagesRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, pagers.ListReferenceImagesAsyncPager)
@@ -3352,6 +3421,11 @@ async def test_list_reference_images_async(transport: str = "grpc_asyncio"):
assert response.next_page_token == "next_page_token_value"
+@pytest.mark.asyncio
+async def test_list_reference_images_async_from_dict():
+ await test_list_reference_images_async(request_type=dict)
+
+
def test_list_reference_images_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -3362,7 +3436,7 @@ def test_list_reference_images_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
call.return_value = product_search_service.ListReferenceImagesResponse()
@@ -3389,7 +3463,7 @@ async def test_list_reference_images_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ListReferenceImagesResponse()
@@ -3412,7 +3486,7 @@ def test_list_reference_images_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListReferenceImagesResponse()
@@ -3446,7 +3520,7 @@ async def test_list_reference_images_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListReferenceImagesResponse()
@@ -3483,7 +3557,7 @@ def test_list_reference_images_pager():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -3531,7 +3605,7 @@ def test_list_reference_images_pages():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_reference_images), "__call__"
+ type(client.transport.list_reference_images), "__call__"
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -3569,7 +3643,7 @@ async def test_list_reference_images_async_pager():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_reference_images),
+ type(client.transport.list_reference_images),
"__call__",
new_callable=mock.AsyncMock,
) as call:
@@ -3616,7 +3690,7 @@ async def test_list_reference_images_async_pages():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_reference_images),
+ type(client.transport.list_reference_images),
"__call__",
new_callable=mock.AsyncMock,
) as call:
@@ -3666,7 +3740,7 @@ def test_get_reference_image(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.get_reference_image), "__call__"
+ type(client.transport.get_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ReferenceImage(
@@ -3682,6 +3756,7 @@ def test_get_reference_image(
assert args[0] == product_search_service.GetReferenceImageRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, product_search_service.ReferenceImage)
assert response.name == "name_value"
@@ -3694,18 +3769,21 @@ def test_get_reference_image_from_dict():
@pytest.mark.asyncio
-async def test_get_reference_image_async(transport: str = "grpc_asyncio"):
+async def test_get_reference_image_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.GetReferenceImageRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.GetReferenceImageRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.get_reference_image), "__call__"
+ type(client.transport.get_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -3718,7 +3796,7 @@ async def test_get_reference_image_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.GetReferenceImageRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, product_search_service.ReferenceImage)
@@ -3728,6 +3806,11 @@ async def test_get_reference_image_async(transport: str = "grpc_asyncio"):
assert response.uri == "uri_value"
+@pytest.mark.asyncio
+async def test_get_reference_image_async_from_dict():
+ await test_get_reference_image_async(request_type=dict)
+
+
def test_get_reference_image_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -3738,7 +3821,7 @@ def test_get_reference_image_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.get_reference_image), "__call__"
+ type(client.transport.get_reference_image), "__call__"
) as call:
call.return_value = product_search_service.ReferenceImage()
@@ -3765,7 +3848,7 @@ async def test_get_reference_image_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.get_reference_image), "__call__"
+ type(client.transport.get_reference_image), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ReferenceImage()
@@ -3788,7 +3871,7 @@ def test_get_reference_image_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.get_reference_image), "__call__"
+ type(client.transport.get_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ReferenceImage()
@@ -3822,7 +3905,7 @@ async def test_get_reference_image_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.get_reference_image), "__call__"
+ type(client.transport.get_reference_image), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ReferenceImage()
@@ -3868,7 +3951,7 @@ def test_add_product_to_product_set(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.add_product_to_product_set), "__call__"
+ type(client.transport.add_product_to_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -3890,18 +3973,21 @@ def test_add_product_to_product_set_from_dict():
@pytest.mark.asyncio
-async def test_add_product_to_product_set_async(transport: str = "grpc_asyncio"):
+async def test_add_product_to_product_set_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.AddProductToProductSetRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.AddProductToProductSetRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.add_product_to_product_set), "__call__"
+ type(client.transport.add_product_to_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -3912,12 +3998,17 @@ async def test_add_product_to_product_set_async(transport: str = "grpc_asyncio")
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.AddProductToProductSetRequest()
# Establish that the response is the type that we expect.
assert response is None
+@pytest.mark.asyncio
+async def test_add_product_to_product_set_async_from_dict():
+ await test_add_product_to_product_set_async(request_type=dict)
+
+
def test_add_product_to_product_set_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -3928,7 +4019,7 @@ def test_add_product_to_product_set_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.add_product_to_product_set), "__call__"
+ type(client.transport.add_product_to_product_set), "__call__"
) as call:
call.return_value = None
@@ -3955,7 +4046,7 @@ async def test_add_product_to_product_set_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.add_product_to_product_set), "__call__"
+ type(client.transport.add_product_to_product_set), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -3976,7 +4067,7 @@ def test_add_product_to_product_set_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.add_product_to_product_set), "__call__"
+ type(client.transport.add_product_to_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -4016,7 +4107,7 @@ async def test_add_product_to_product_set_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.add_product_to_product_set), "__call__"
+ type(client.transport.add_product_to_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -4066,7 +4157,7 @@ def test_remove_product_from_product_set(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.remove_product_from_product_set), "__call__"
+ type(client.transport.remove_product_from_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -4088,18 +4179,21 @@ def test_remove_product_from_product_set_from_dict():
@pytest.mark.asyncio
-async def test_remove_product_from_product_set_async(transport: str = "grpc_asyncio"):
+async def test_remove_product_from_product_set_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.RemoveProductFromProductSetRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.RemoveProductFromProductSetRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.remove_product_from_product_set), "__call__"
+ type(client.transport.remove_product_from_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -4110,12 +4204,17 @@ async def test_remove_product_from_product_set_async(transport: str = "grpc_asyn
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.RemoveProductFromProductSetRequest()
# Establish that the response is the type that we expect.
assert response is None
+@pytest.mark.asyncio
+async def test_remove_product_from_product_set_async_from_dict():
+ await test_remove_product_from_product_set_async(request_type=dict)
+
+
def test_remove_product_from_product_set_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -4126,7 +4225,7 @@ def test_remove_product_from_product_set_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.remove_product_from_product_set), "__call__"
+ type(client.transport.remove_product_from_product_set), "__call__"
) as call:
call.return_value = None
@@ -4153,7 +4252,7 @@ async def test_remove_product_from_product_set_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.remove_product_from_product_set), "__call__"
+ type(client.transport.remove_product_from_product_set), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
@@ -4174,7 +4273,7 @@ def test_remove_product_from_product_set_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.remove_product_from_product_set), "__call__"
+ type(client.transport.remove_product_from_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -4214,7 +4313,7 @@ async def test_remove_product_from_product_set_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.remove_product_from_product_set), "__call__"
+ type(client.transport.remove_product_from_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
@@ -4264,7 +4363,7 @@ def test_list_products_in_product_set(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductsInProductSetResponse(
@@ -4280,6 +4379,7 @@ def test_list_products_in_product_set(
assert args[0] == product_search_service.ListProductsInProductSetRequest()
# Establish that the response is the type that we expect.
+
assert isinstance(response, pagers.ListProductsInProductSetPager)
assert response.next_page_token == "next_page_token_value"
@@ -4290,18 +4390,21 @@ def test_list_products_in_product_set_from_dict():
@pytest.mark.asyncio
-async def test_list_products_in_product_set_async(transport: str = "grpc_asyncio"):
+async def test_list_products_in_product_set_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.ListProductsInProductSetRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.ListProductsInProductSetRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -4316,7 +4419,7 @@ async def test_list_products_in_product_set_async(transport: str = "grpc_asyncio
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.ListProductsInProductSetRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, pagers.ListProductsInProductSetAsyncPager)
@@ -4324,6 +4427,11 @@ async def test_list_products_in_product_set_async(transport: str = "grpc_asyncio
assert response.next_page_token == "next_page_token_value"
+@pytest.mark.asyncio
+async def test_list_products_in_product_set_async_from_dict():
+ await test_list_products_in_product_set_async(request_type=dict)
+
+
def test_list_products_in_product_set_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -4334,7 +4442,7 @@ def test_list_products_in_product_set_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
call.return_value = product_search_service.ListProductsInProductSetResponse()
@@ -4361,7 +4469,7 @@ async def test_list_products_in_product_set_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
product_search_service.ListProductsInProductSetResponse()
@@ -4384,7 +4492,7 @@ def test_list_products_in_product_set_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductsInProductSetResponse()
@@ -4418,7 +4526,7 @@ async def test_list_products_in_product_set_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = product_search_service.ListProductsInProductSetResponse()
@@ -4455,7 +4563,7 @@ def test_list_products_in_product_set_pager():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -4500,7 +4608,7 @@ def test_list_products_in_product_set_pages():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.list_products_in_product_set), "__call__"
+ type(client.transport.list_products_in_product_set), "__call__"
) as call:
# Set the response to a series of pages.
call.side_effect = (
@@ -4537,7 +4645,7 @@ async def test_list_products_in_product_set_async_pager():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_products_in_product_set),
+ type(client.transport.list_products_in_product_set),
"__call__",
new_callable=mock.AsyncMock,
) as call:
@@ -4581,7 +4689,7 @@ async def test_list_products_in_product_set_async_pages():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.list_products_in_product_set),
+ type(client.transport.list_products_in_product_set),
"__call__",
new_callable=mock.AsyncMock,
) as call:
@@ -4632,7 +4740,7 @@ def test_import_product_sets(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.import_product_sets), "__call__"
+ type(client.transport.import_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/spam")
@@ -4654,18 +4762,21 @@ def test_import_product_sets_from_dict():
@pytest.mark.asyncio
-async def test_import_product_sets_async(transport: str = "grpc_asyncio"):
+async def test_import_product_sets_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.ImportProductSetsRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.ImportProductSetsRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.import_product_sets), "__call__"
+ type(client.transport.import_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
@@ -4678,12 +4789,17 @@ async def test_import_product_sets_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.ImportProductSetsRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, future.Future)
+@pytest.mark.asyncio
+async def test_import_product_sets_async_from_dict():
+ await test_import_product_sets_async(request_type=dict)
+
+
def test_import_product_sets_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -4694,7 +4810,7 @@ def test_import_product_sets_field_headers():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.import_product_sets), "__call__"
+ type(client.transport.import_product_sets), "__call__"
) as call:
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -4721,7 +4837,7 @@ async def test_import_product_sets_field_headers_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.import_product_sets), "__call__"
+ type(client.transport.import_product_sets), "__call__"
) as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
operations_pb2.Operation(name="operations/op")
@@ -4744,7 +4860,7 @@ def test_import_product_sets_flattened():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._transport.import_product_sets), "__call__"
+ type(client.transport.import_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -4799,7 +4915,7 @@ async def test_import_product_sets_flattened_async():
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
- type(client._client._transport.import_product_sets), "__call__"
+ type(client.transport.import_product_sets), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -4864,7 +4980,7 @@ def test_purge_products(
request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.purge_products), "__call__") as call:
+ with mock.patch.object(type(client.transport.purge_products), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/spam")
@@ -4885,19 +5001,20 @@ def test_purge_products_from_dict():
@pytest.mark.asyncio
-async def test_purge_products_async(transport: str = "grpc_asyncio"):
+async def test_purge_products_async(
+ transport: str = "grpc_asyncio",
+ request_type=product_search_service.PurgeProductsRequest,
+):
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
- request = product_search_service.PurgeProductsRequest()
+ request = request_type()
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.purge_products), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.purge_products), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
operations_pb2.Operation(name="operations/spam")
@@ -4909,12 +5026,17 @@ async def test_purge_products_async(transport: str = "grpc_asyncio"):
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
- assert args[0] == request
+ assert args[0] == product_search_service.PurgeProductsRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, future.Future)
+@pytest.mark.asyncio
+async def test_purge_products_async_from_dict():
+ await test_purge_products_async(request_type=dict)
+
+
def test_purge_products_field_headers():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
@@ -4924,7 +5046,7 @@ def test_purge_products_field_headers():
request.parent = "parent/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.purge_products), "__call__") as call:
+ with mock.patch.object(type(client.transport.purge_products), "__call__") as call:
call.return_value = operations_pb2.Operation(name="operations/op")
client.purge_products(request)
@@ -4949,9 +5071,7 @@ async def test_purge_products_field_headers_async():
request.parent = "parent/value"
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.purge_products), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.purge_products), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
operations_pb2.Operation(name="operations/op")
)
@@ -4972,7 +5092,7 @@ def test_purge_products_flattened():
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client._transport.purge_products), "__call__") as call:
+ with mock.patch.object(type(client.transport.purge_products), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -5004,9 +5124,7 @@ async def test_purge_products_flattened_async():
client = ProductSearchAsyncClient(credentials=credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client._client._transport.purge_products), "__call__"
- ) as call:
+ with mock.patch.object(type(client.transport.purge_products), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = operations_pb2.Operation(name="operations/op")
@@ -5073,7 +5191,7 @@ def test_transport_instance():
credentials=credentials.AnonymousCredentials(),
)
client = ProductSearchClient(transport=transport)
- assert client._transport is transport
+ assert client.transport is transport
def test_transport_get_channel():
@@ -5109,7 +5227,7 @@ def test_transport_adc(transport_class):
def test_transport_grpc_default():
# A client should use the gRPC transport by default.
client = ProductSearchClient(credentials=credentials.AnonymousCredentials(),)
- assert isinstance(client._transport, transports.ProductSearchGrpcTransport,)
+ assert isinstance(client.transport, transports.ProductSearchGrpcTransport,)
def test_product_search_base_transport_error():
@@ -5235,7 +5353,7 @@ def test_product_search_host_no_port():
api_endpoint="vision.googleapis.com"
),
)
- assert client._transport._host == "vision.googleapis.com:443"
+ assert client.transport._host == "vision.googleapis.com:443"
def test_product_search_host_with_port():
@@ -5245,7 +5363,7 @@ def test_product_search_host_with_port():
api_endpoint="vision.googleapis.com:8000"
),
)
- assert client._transport._host == "vision.googleapis.com:8000"
+ assert client.transport._host == "vision.googleapis.com:8000"
def test_product_search_grpc_transport_channel():
@@ -5257,6 +5375,7 @@ def test_product_search_grpc_transport_channel():
)
assert transport.grpc_channel == channel
assert transport._host == "squid.clam.whelk:443"
+ assert transport._ssl_channel_credentials == None
def test_product_search_grpc_asyncio_transport_channel():
@@ -5268,6 +5387,7 @@ def test_product_search_grpc_asyncio_transport_channel():
)
assert transport.grpc_channel == channel
assert transport._host == "squid.clam.whelk:443"
+ assert transport._ssl_channel_credentials == None
@pytest.mark.parametrize(
@@ -5314,8 +5434,13 @@ def test_product_search_transport_channel_mtls_with_client_cert_source(transport
),
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
assert transport.grpc_channel == mock_grpc_channel
+ assert transport._ssl_channel_credentials == mock_ssl_cred
@pytest.mark.parametrize(
@@ -5357,6 +5482,10 @@ def test_product_search_transport_channel_mtls_with_adc(transport_class):
),
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
)
assert transport.grpc_channel == mock_grpc_channel
@@ -5365,7 +5494,7 @@ def test_product_search_grpc_lro_client():
client = ProductSearchClient(
credentials=credentials.AnonymousCredentials(), transport="grpc",
)
- transport = client._transport
+ transport = client.transport
# Ensure that we have a api-core operations client.
assert isinstance(transport.operations_client, operations_v1.OperationsClient,)
@@ -5378,7 +5507,7 @@ def test_product_search_grpc_lro_async_client():
client = ProductSearchAsyncClient(
credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio",
)
- transport = client._client._transport
+ transport = client.transport
# Ensure that we have a api-core operations client.
assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,)
@@ -5413,9 +5542,9 @@ def test_parse_product_path():
def test_product_set_path():
- project = "squid"
- location = "clam"
- product_set = "whelk"
+ project = "cuttlefish"
+ location = "mussel"
+ product_set = "winkle"
expected = "projects/{project}/locations/{location}/productSets/{product_set}".format(
project=project, location=location, product_set=product_set,
@@ -5426,9 +5555,9 @@ def test_product_set_path():
def test_parse_product_set_path():
expected = {
- "project": "octopus",
- "location": "oyster",
- "product_set": "nudibranch",
+ "project": "nautilus",
+ "location": "scallop",
+ "product_set": "abalone",
}
path = ProductSearchClient.product_set_path(**expected)
@@ -5469,6 +5598,107 @@ def test_parse_reference_image_path():
assert expected == actual
+def test_common_billing_account_path():
+ billing_account = "winkle"
+
+ expected = "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+ actual = ProductSearchClient.common_billing_account_path(billing_account)
+ assert expected == actual
+
+
+def test_parse_common_billing_account_path():
+ expected = {
+ "billing_account": "nautilus",
+ }
+ path = ProductSearchClient.common_billing_account_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ProductSearchClient.parse_common_billing_account_path(path)
+ assert expected == actual
+
+
+def test_common_folder_path():
+ folder = "scallop"
+
+ expected = "folders/{folder}".format(folder=folder,)
+ actual = ProductSearchClient.common_folder_path(folder)
+ assert expected == actual
+
+
+def test_parse_common_folder_path():
+ expected = {
+ "folder": "abalone",
+ }
+ path = ProductSearchClient.common_folder_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ProductSearchClient.parse_common_folder_path(path)
+ assert expected == actual
+
+
+def test_common_organization_path():
+ organization = "squid"
+
+ expected = "organizations/{organization}".format(organization=organization,)
+ actual = ProductSearchClient.common_organization_path(organization)
+ assert expected == actual
+
+
+def test_parse_common_organization_path():
+ expected = {
+ "organization": "clam",
+ }
+ path = ProductSearchClient.common_organization_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ProductSearchClient.parse_common_organization_path(path)
+ assert expected == actual
+
+
+def test_common_project_path():
+ project = "whelk"
+
+ expected = "projects/{project}".format(project=project,)
+ actual = ProductSearchClient.common_project_path(project)
+ assert expected == actual
+
+
+def test_parse_common_project_path():
+ expected = {
+ "project": "octopus",
+ }
+ path = ProductSearchClient.common_project_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ProductSearchClient.parse_common_project_path(path)
+ assert expected == actual
+
+
+def test_common_location_path():
+ project = "oyster"
+ location = "nudibranch"
+
+ expected = "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+ actual = ProductSearchClient.common_location_path(project, location)
+ assert expected == actual
+
+
+def test_parse_common_location_path():
+ expected = {
+ "project": "cuttlefish",
+ "location": "mussel",
+ }
+ path = ProductSearchClient.common_location_path(**expected)
+
+ # Check that the path construction is reversible.
+ actual = ProductSearchClient.parse_common_location_path(path)
+ assert expected == actual
+
+
def test_client_withDEFAULT_CLIENT_INFO():
client_info = gapic_v1.client_info.ClientInfo()