5151from google .cloud .spanner_v1 import ExecuteSqlRequest
5252from google .cloud .spanner_v1 import DefaultTransactionOptions
5353from google .cloud .spanner_v1 .types import ClientContext
54- from google .cloud .spanner_v1 ._helpers import _merge_query_options
54+ from google .cloud .spanner_v1 ._helpers import (
55+ _create_experimental_host_transport ,
56+ _merge_query_options ,
57+ )
5558from google .cloud .spanner_v1 ._helpers import _metadata_with_prefix
5659from google .cloud .spanner_v1 ._helpers import _validate_client_context
5760from google .cloud .spanner_v1 .instance import Instance
@@ -233,6 +236,30 @@ class Client(ClientWithProject):
233236
234237 :raises: :class:`ValueError <exceptions.ValueError>` if both ``read_only``
235238 and ``admin`` are :data:`True`
239+
240+ :type use_plain_text: bool
241+ :param use_plain_text: (Optional) Whether to use plain text for the connection.
242+ This is intended only for experimental host spanner endpoints.
243+ If set, this will override the `api_endpoint` in `client_options`.
244+ If not set, the default behavior is to use TLS.
245+
246+ :type ca_certificate: str
247+ :param ca_certificate: (Optional) The path to the CA certificate file used for TLS connection.
248+ This is intended only for experimental host spanner endpoints.
249+ If set, this will override the `api_endpoint` in `client_options`.
250+ This is mandatory if the experimental_host requires a TLS connection.
251+
252+ :type client_certificate: str
253+ :param client_certificate: (Optional) The path to the client certificate file used for mTLS connection.
254+ This is intended only for experimental host spanner endpoints.
255+ If set, this will override the `api_endpoint` in `client_options`.
256+ This is mandatory if the experimental_host requires a mTLS connection.
257+
258+ :type client_key: str
259+ :param client_key: (Optional) The path to the client key file used for mTLS connection.
260+ This is intended only for experimental host spanner endpoints.
261+ If set, this will override the `api_endpoint` in `client_options`.
262+ This is mandatory if the experimental_host requires a mTLS connection.
236263 """
237264
238265 _instance_admin_api = None
@@ -258,6 +285,10 @@ def __init__(
258285 experimental_host = None ,
259286 disable_builtin_metrics = False ,
260287 client_context = None ,
288+ use_plain_text = False ,
289+ ca_certificate = None ,
290+ client_certificate = None ,
291+ client_key = None ,
261292 ):
262293 self ._emulator_host = _get_spanner_emulator_host ()
263294 self ._experimental_host = experimental_host
@@ -272,6 +303,12 @@ def __init__(
272303 if self ._emulator_host :
273304 credentials = AnonymousCredentials ()
274305 elif self ._experimental_host :
306+ # For all experimental host endpoints project is default
307+ project = "default"
308+ self ._use_plain_text = use_plain_text
309+ self ._ca_certificate = ca_certificate
310+ self ._client_certificate = client_certificate
311+ self ._client_key = client_key
275312 credentials = AnonymousCredentials ()
276313 elif isinstance (credentials , AnonymousCredentials ):
277314 self ._emulator_host = self ._client_options .api_endpoint
@@ -369,8 +406,13 @@ def instance_admin_api(self):
369406 transport = transport ,
370407 )
371408 elif self ._experimental_host :
372- transport = InstanceAdminGrpcTransport (
373- channel = grpc .insecure_channel (target = self ._experimental_host )
409+ transport = _create_experimental_host_transport (
410+ InstanceAdminGrpcTransport ,
411+ self ._experimental_host ,
412+ self ._use_plain_text ,
413+ self ._ca_certificate ,
414+ self ._client_certificate ,
415+ self ._client_key ,
374416 )
375417 self ._instance_admin_api = InstanceAdminClient (
376418 client_info = self ._client_info ,
@@ -399,8 +441,13 @@ def database_admin_api(self):
399441 transport = transport ,
400442 )
401443 elif self ._experimental_host :
402- transport = DatabaseAdminGrpcTransport (
403- channel = grpc .insecure_channel (target = self ._experimental_host )
444+ transport = _create_experimental_host_transport (
445+ DatabaseAdminGrpcTransport ,
446+ self ._experimental_host ,
447+ self ._use_plain_text ,
448+ self ._ca_certificate ,
449+ self ._client_certificate ,
450+ self ._client_key ,
404451 )
405452 self ._database_admin_api = DatabaseAdminClient (
406453 client_info = self ._client_info ,
@@ -547,7 +594,6 @@ def instance(
547594 self ._emulator_host ,
548595 labels ,
549596 processing_units ,
550- self ._experimental_host ,
551597 )
552598
553599 def list_instances (self , filter_ = "" , page_size = None ):
0 commit comments