diff --git a/.coveragerc b/.coveragerc index dd39c8546c..0d8e6297dc 100644 --- a/.coveragerc +++ b/.coveragerc @@ -17,6 +17,8 @@ # Generated by synthtool. DO NOT EDIT! [run] branch = True +omit = + google/cloud/__init__.py [report] fail_under = 100 @@ -32,4 +34,5 @@ omit = */gapic/*.py */proto/*.py */core/*.py - */site-packages/*.py \ No newline at end of file + */site-packages/*.py + google/cloud/__init__.py diff --git a/.kokoro/samples/python3.6/common.cfg b/.kokoro/samples/python3.6/common.cfg index 4b3c1b8255..b9a59484d3 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-firestore/.kokoro/test-samples.sh" diff --git a/.kokoro/samples/python3.7/common.cfg b/.kokoro/samples/python3.7/common.cfg index 75565787ce..ac1589d36b 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-firestore/.kokoro/test-samples.sh" diff --git a/.kokoro/samples/python3.8/common.cfg b/.kokoro/samples/python3.8/common.cfg index fe06c8d88b..82693f383b 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-firestore/.kokoro/test-samples.sh" diff --git a/google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py b/google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py index 38e6406eb5..c1f3dbe9b4 100644 --- a/google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py +++ b/google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py @@ -28,8 +28,8 @@ from google.auth import credentials # type: ignore from google.oauth2 import service_account # type: ignore -from google.api_core import operation as ga_operation # type: ignore -from google.api_core import operation_async # type: ignore +from google.api_core import operation as ga_operation +from google.api_core import operation_async from google.cloud.firestore_admin_v1.services.firestore_admin import pagers from google.cloud.firestore_admin_v1.types import field from google.cloud.firestore_admin_v1.types import field as gfa_field @@ -274,8 +274,8 @@ async def list_indexes( multiplier=1.3, predicate=retries.if_exception_type( exceptions.DeadlineExceeded, - exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.InternalServerError, ), ), default_timeout=60.0, @@ -362,8 +362,8 @@ async def get_index( multiplier=1.3, predicate=retries.if_exception_type( exceptions.DeadlineExceeded, - exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.InternalServerError, ), ), default_timeout=60.0, @@ -437,8 +437,8 @@ async def delete_index( multiplier=1.3, predicate=retries.if_exception_type( exceptions.DeadlineExceeded, - exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.InternalServerError, ), ), default_timeout=60.0, @@ -520,8 +520,8 @@ async def get_field( multiplier=1.3, predicate=retries.if_exception_type( exceptions.DeadlineExceeded, - exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.InternalServerError, ), ), default_timeout=60.0, @@ -713,8 +713,8 @@ async def list_fields( multiplier=1.3, predicate=retries.if_exception_type( exceptions.DeadlineExceeded, - exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.InternalServerError, ), ), default_timeout=60.0, diff --git a/google/cloud/firestore_admin_v1/services/firestore_admin/client.py b/google/cloud/firestore_admin_v1/services/firestore_admin/client.py index f721cee47d..a2ee377754 100644 --- a/google/cloud/firestore_admin_v1/services/firestore_admin/client.py +++ b/google/cloud/firestore_admin_v1/services/firestore_admin/client.py @@ -19,10 +19,10 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Callable, Dict, Sequence, Tuple, Type, Union import pkg_resources -from google.api_core import client_options as client_options_lib # type: ignore +import google.api_core.client_options as ClientOptions # type: ignore from google.api_core import exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore @@ -32,8 +32,8 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore -from google.api_core import operation as ga_operation # type: ignore -from google.api_core import operation_async # type: ignore +from google.api_core import operation as ga_operation +from google.api_core import operation_async from google.cloud.firestore_admin_v1.services.firestore_admin import pagers from google.cloud.firestore_admin_v1.types import field from google.cloud.firestore_admin_v1.types import field as gfa_field @@ -175,9 +175,9 @@ def parse_index_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, - transport: Union[str, FirestoreAdminTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, + credentials: credentials.Credentials = None, + transport: Union[str, FirestoreAdminTransport] = None, + client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiate the firestore admin client. @@ -191,8 +191,8 @@ def __init__( transport (Union[str, ~.FirestoreAdminTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (client_options_lib.ClientOptions): Custom options for the - client. It won't take effect if a ``transport`` instance is provided. + client_options (ClientOptions): Custom options for the client. It + won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT environment variable can also be used to override the endpoint: @@ -218,9 +218,9 @@ def __init__( creation failed for any reason. """ if isinstance(client_options, dict): - client_options = client_options_lib.from_dict(client_options) + client_options = ClientOptions.from_dict(client_options) if client_options is None: - client_options = client_options_lib.ClientOptions() + client_options = ClientOptions.ClientOptions() # Create SSL credentials for mutual TLS if needed. use_client_cert = bool( @@ -377,7 +377,7 @@ def create_index( response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. - response = ga_operation.from_gapic( + response = operation.from_gapic( response, self._transport.operations_client, gfa_index.Index, @@ -779,7 +779,7 @@ def update_field( response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. - response = ga_operation.from_gapic( + response = operation.from_gapic( response, self._transport.operations_client, gfa_field.Field, @@ -963,7 +963,7 @@ def export_documents( response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. - response = ga_operation.from_gapic( + response = operation.from_gapic( response, self._transport.operations_client, gfa_operation.ExportDocumentsResponse, @@ -1065,7 +1065,7 @@ def import_documents( response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. - response = ga_operation.from_gapic( + response = operation.from_gapic( response, self._transport.operations_client, empty.Empty, diff --git a/google/cloud/firestore_admin_v1/services/firestore_admin/transports/base.py b/google/cloud/firestore_admin_v1/services/firestore_admin/transports/base.py index ac4c4475f5..d668818891 100644 --- a/google/cloud/firestore_admin_v1/services/firestore_admin/transports/base.py +++ b/google/cloud/firestore_admin_v1/services/firestore_admin/transports/base.py @@ -125,8 +125,8 @@ def _prep_wrapped_messages(self, client_info): multiplier=1.3, predicate=retries.if_exception_type( exceptions.DeadlineExceeded, - exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.InternalServerError, ), ), default_timeout=60.0, @@ -140,8 +140,8 @@ def _prep_wrapped_messages(self, client_info): multiplier=1.3, predicate=retries.if_exception_type( exceptions.DeadlineExceeded, - exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.InternalServerError, ), ), default_timeout=60.0, @@ -155,8 +155,8 @@ def _prep_wrapped_messages(self, client_info): multiplier=1.3, predicate=retries.if_exception_type( exceptions.DeadlineExceeded, - exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.InternalServerError, ), ), default_timeout=60.0, @@ -170,8 +170,8 @@ def _prep_wrapped_messages(self, client_info): multiplier=1.3, predicate=retries.if_exception_type( exceptions.DeadlineExceeded, - exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.InternalServerError, ), ), default_timeout=60.0, @@ -188,8 +188,8 @@ def _prep_wrapped_messages(self, client_info): multiplier=1.3, predicate=retries.if_exception_type( exceptions.DeadlineExceeded, - exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.InternalServerError, ), ), default_timeout=60.0, diff --git a/google/cloud/firestore_v1/services/firestore/async_client.py b/google/cloud/firestore_v1/services/firestore/async_client.py index d775a877cf..dd2efb1d01 100644 --- a/google/cloud/firestore_v1/services/firestore/async_client.py +++ b/google/cloud/firestore_v1/services/firestore/async_client.py @@ -154,9 +154,9 @@ async def get_document( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, ), ), default_timeout=60.0, @@ -218,9 +218,9 @@ async def list_documents( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, ), ), default_timeout=60.0, @@ -396,9 +396,9 @@ async def delete_document( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, ), ), default_timeout=60.0, @@ -458,9 +458,9 @@ def batch_get_documents( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, ), ), default_timeout=300.0, @@ -539,9 +539,9 @@ async def begin_transaction( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, ), ), default_timeout=60.0, @@ -710,9 +710,9 @@ async def rollback( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, ), ), default_timeout=60.0, @@ -770,9 +770,9 @@ def run_query( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, ), ), default_timeout=300.0, @@ -947,9 +947,9 @@ def listen( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, ), ), default_timeout=86400.0, @@ -1031,9 +1031,9 @@ async def list_collection_ids( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, ), ), default_timeout=60.0, diff --git a/google/cloud/firestore_v1/services/firestore/client.py b/google/cloud/firestore_v1/services/firestore/client.py index 527ba3c6ad..e6fd7913d3 100644 --- a/google/cloud/firestore_v1/services/firestore/client.py +++ b/google/cloud/firestore_v1/services/firestore/client.py @@ -19,20 +19,10 @@ from distutils import util import os import re -from typing import ( - Callable, - Dict, - Optional, - Iterable, - Iterator, - Sequence, - Tuple, - Type, - Union, -) +from typing import Callable, Dict, Iterable, Iterator, Sequence, Tuple, Type, Union import pkg_resources -from google.api_core import client_options as client_options_lib # type: ignore +import google.api_core.client_options as ClientOptions # type: ignore from google.api_core import exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore @@ -156,9 +146,9 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, - transport: Union[str, FirestoreTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, + credentials: credentials.Credentials = None, + transport: Union[str, FirestoreTransport] = None, + client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiate the firestore client. @@ -172,8 +162,8 @@ def __init__( transport (Union[str, ~.FirestoreTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (client_options_lib.ClientOptions): Custom options for the - client. It won't take effect if a ``transport`` instance is provided. + client_options (ClientOptions): Custom options for the client. It + won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT environment variable can also be used to override the endpoint: @@ -199,9 +189,9 @@ def __init__( creation failed for any reason. """ if isinstance(client_options, dict): - client_options = client_options_lib.from_dict(client_options) + client_options = ClientOptions.from_dict(client_options) if client_options is None: - client_options = client_options_lib.ClientOptions() + client_options = ClientOptions.ClientOptions() # Create SSL credentials for mutual TLS if needed. use_client_cert = bool( diff --git a/google/cloud/firestore_v1/services/firestore/transports/base.py b/google/cloud/firestore_v1/services/firestore/transports/base.py index 12c96dfb31..416bb3f723 100644 --- a/google/cloud/firestore_v1/services/firestore/transports/base.py +++ b/google/cloud/firestore_v1/services/firestore/transports/base.py @@ -117,9 +117,9 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, ), ), default_timeout=60.0, @@ -132,9 +132,9 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, ), ), default_timeout=60.0, @@ -158,9 +158,9 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, ), ), default_timeout=60.0, @@ -173,9 +173,9 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, ), ), default_timeout=300.0, @@ -188,9 +188,9 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, ), ), default_timeout=60.0, @@ -214,9 +214,9 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, ), ), default_timeout=60.0, @@ -229,9 +229,9 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, ), ), default_timeout=300.0, @@ -250,9 +250,9 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, ), ), default_timeout=86400.0, @@ -265,9 +265,9 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.InternalServerError, exceptions.ServiceUnavailable, + exceptions.DeadlineExceeded, ), ), default_timeout=60.0, diff --git a/synth.metadata b/synth.metadata index 61a3eb95b1..a3f9dc1921 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,8 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/python-firestore.git", - "sha": "2021f38bb6f016c13bc43d59730c77b57ae5c352" - + "sha": "8e53a2c3aef160c4090241f5260686aee03323d2" } }, { @@ -20,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "a651c5fb763c69a921aecdd3e1d8dc51dbf20f8d" + "sha": "9b0da5204ab90bcc36f8cd4e5689eff1a54cc3e4" } } ], @@ -45,6 +44,7 @@ } ], "generatedFiles": [ + ".coveragerc", ".flake8", ".github/CONTRIBUTING.md", ".github/ISSUE_TEMPLATE/bug_report.md", diff --git a/tests/unit/gapic/firestore_admin_v1/test_firestore_admin.py b/tests/unit/gapic/firestore_admin_v1/test_firestore_admin.py index 6773457e91..866badfa33 100644 --- a/tests/unit/gapic/firestore_admin_v1/test_firestore_admin.py +++ b/tests/unit/gapic/firestore_admin_v1/test_firestore_admin.py @@ -31,7 +31,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async -from google.api_core import operation_async # type: ignore +from google.api_core import operation_async from google.api_core import operations_v1 from google.auth import credentials from google.auth.exceptions import MutualTLSChannelError