|
27 | 27 | from google.api_core import client_options as client_options_lib |
28 | 28 | from google.api_core import exceptions as core_exceptions |
29 | 29 | from google.api_core import gapic_v1 |
30 | | -from google.iam.credentials_v1._compat import get_universe_domain, get_api_endpoint, get_default_mtls_endpoint, should_use_client_cert |
| 30 | +from google.iam.credentials_v1._compat import get_universe_domain, get_api_endpoint, get_default_mtls_endpoint, should_use_client_cert, read_environment_variables |
31 | 31 | from google.api_core import retry as retries |
32 | 32 | from google.auth import credentials as ga_credentials # type: ignore |
33 | 33 | from google.auth.transport import mtls # type: ignore |
@@ -285,27 +285,6 @@ def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[client_optio |
285 | 285 |
|
286 | 286 | return api_endpoint, client_cert_source |
287 | 287 |
|
288 | | - @staticmethod |
289 | | - def _read_environment_variables(): |
290 | | - """Returns the environment variables used by the client. |
291 | | -
|
292 | | - Returns: |
293 | | - Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE, |
294 | | - GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables. |
295 | | -
|
296 | | - Raises: |
297 | | - ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not |
298 | | - any of ["true", "false"]. |
299 | | - google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT |
300 | | - is not any of ["auto", "never", "always"]. |
301 | | - """ |
302 | | - use_client_cert = should_use_client_cert() |
303 | | - use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower() |
304 | | - universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN") |
305 | | - if use_mtls_endpoint not in ("auto", "never", "always"): |
306 | | - raise MutualTLSChannelError("Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`") |
307 | | - return use_client_cert, use_mtls_endpoint, universe_domain_env |
308 | | - |
309 | 288 | @staticmethod |
310 | 289 | def _get_client_cert_source(provided_cert_source, use_cert_flag): |
311 | 290 | """Return the client cert source to be used by the client. |
@@ -447,7 +426,7 @@ def __init__(self, *, |
447 | 426 |
|
448 | 427 | universe_domain_opt = getattr(self._client_options, 'universe_domain', None) |
449 | 428 |
|
450 | | - self._use_client_cert, self._use_mtls_endpoint, self._universe_domain_env = IAMCredentialsClient._read_environment_variables() |
| 429 | + self._use_client_cert, self._use_mtls_endpoint, self._universe_domain_env = read_environment_variables() |
451 | 430 | self._client_cert_source = IAMCredentialsClient._get_client_cert_source(self._client_options.client_cert_source, self._use_client_cert) |
452 | 431 | self._universe_domain = get_universe_domain(universe_domain_opt, self._universe_domain_env) |
453 | 432 | self._api_endpoint: str = "" # updated below, depending on `transport` |
|
0 commit comments