2323from google .auth .exceptions import MutualTLSChannelError # type: ignore
2424from google .auth .transport import mtls # type: ignore
2525
26+ _MTLS_ENDPOINT_RE = re .compile (
27+ r"(?P<name>[^.]+)(?P<mtls>\.mtls)?(?P<sandbox>\.sandbox)?(?P<googledomain>\.googleapis\.com)?"
28+ )
29+
30+
2631
2732
2833def get_default_mtls_endpoint (api_endpoint : Optional [str ]) -> Optional [str ]:
@@ -38,11 +43,7 @@ def get_default_mtls_endpoint(api_endpoint: Optional[str]) -> Optional[str]:
3843 if not api_endpoint :
3944 return api_endpoint
4045
41- mtls_endpoint_re = re .compile (
42- r"(?P<name>[^.]+)(?P<mtls>\.mtls)?(?P<sandbox>\.sandbox)?(?P<googledomain>\.googleapis\.com)?"
43- )
44-
45- m = mtls_endpoint_re .match (api_endpoint )
46+ m = _MTLS_ENDPOINT_RE .match (api_endpoint )
4647 if m is None :
4748 # Could not parse api_endpoint; return as-is.
4849 return api_endpoint
@@ -89,26 +90,26 @@ def use_client_cert_effective() -> bool:
8990
9091def get_api_endpoint (
9192 api_override : Optional [str ],
92- client_cert_source : Optional [bytes ],
93+ client_cert_source : Optional [Any ],
9394 universe_domain : str ,
9495 use_mtls_endpoint : str ,
9596 default_universe : str ,
9697 default_mtls_endpoint : Optional [str ],
9798 default_endpoint_template : str ,
98- ) -> str :
99+ ) -> Optional [ str ] :
99100 """Return the API endpoint used by the client.
100101
101102 Args:
102103 api_override (Optional[str]): The API endpoint override.
103- client_cert_source (Optional[bytes ]): The client certificate source.
104+ client_cert_source (Optional[Any ]): The client certificate source.
104105 universe_domain (str): The universe domain.
105106 use_mtls_endpoint (str): How to use the mTLS endpoint.
106107 default_universe (str): The default universe.
107108 default_mtls_endpoint (Optional[str]): The default mTLS endpoint.
108109 default_endpoint_template (str): The default endpoint template.
109110
110111 Returns:
111- str: The API endpoint to be used by the client.
112+ Optional[ str] : The API endpoint to be used by the client.
112113 """
113114 if api_override is not None :
114115 api_endpoint = api_override
0 commit comments