3535from google .cloud .firestore_v1 import types
3636from google .cloud .firestore_v1 .base_document import DocumentSnapshot
3737from google .cloud .firestore_v1 .field_path import render_field_path
38- from google .cloud .firestore_v1 .services .firestore import client as firestore_client
39- from google .cloud .firestore_v1 .services .firestore .transports import (
40- grpc as firestore_grpc_transport ,
41- )
4238
4339DEFAULT_DATABASE = "(default)"
4440"""str: The default database used in a :class:`~google.cloud.firestore_v1.client.Client`."""
@@ -117,12 +113,10 @@ def __init__(
117113 self ._database = database
118114 self ._emulator_host = os .getenv (_FIRESTORE_EMULATOR_HOST )
119115
120- @property
121- def _firestore_api (self ):
116+ def _firestore_api_helper (self , transport , client_class , client_module ):
122117 """Lazy-loading getter GAPIC Firestore API.
123118 Returns:
124- :class:`~google.cloud.gapic.firestore.v1`.firestore_client.FirestoreClient:
125- <The GAPIC client with the credentials of the current client.
119+ The GAPIC client with the credentials of the current client.
126120 """
127121 if self ._firestore_api_internal is None :
128122 # Use a custom channel.
@@ -131,30 +125,26 @@ def _firestore_api(self):
131125 if self ._emulator_host is not None :
132126 # TODO(microgen): this likely needs to be adapted to use insecure_channel
133127 # on new generated surface.
134- channel = firestore_grpc_transport .FirestoreGrpcTransport .create_channel (
135- host = self ._emulator_host
136- )
128+ channel = transport .create_channel (host = self ._emulator_host )
137129 else :
138- channel = firestore_grpc_transport . FirestoreGrpcTransport .create_channel (
130+ channel = transport .create_channel (
139131 self ._target ,
140132 credentials = self ._credentials ,
141133 options = {"grpc.keepalive_time_ms" : 30000 }.items (),
142134 )
143135
144- self ._transport = firestore_grpc_transport .FirestoreGrpcTransport (
145- host = self ._target , channel = channel
146- )
136+ self ._transport = transport (host = self ._target , channel = channel )
147137
148- self ._firestore_api_internal = firestore_client . FirestoreClient (
138+ self ._firestore_api_internal = client_class (
149139 transport = self ._transport , client_options = self ._client_options
150140 )
151- firestore_client ._client_info = self ._client_info
141+ client_module ._client_info = self ._client_info
152142
153143 return self ._firestore_api_internal
154144
155- @property
156- def _target (self ):
145+ def _target_helper (self , client_class ):
157146 """Return the target (where the API is).
147+ Eg. "firestore.googleapis.com"
158148
159149 Returns:
160150 str: The location of the API.
@@ -164,7 +154,7 @@ def _target(self):
164154 elif self ._client_options and self ._client_options .api_endpoint :
165155 return self ._client_options .api_endpoint
166156 else :
167- return firestore_client . FirestoreClient .DEFAULT_ENDPOINT
157+ return client_class .DEFAULT_ENDPOINT
168158
169159 @property
170160 def _database_string (self ):
0 commit comments