|
14 | 14 | # limitations under the License. |
15 | 15 | # |
16 | 16 | from collections import OrderedDict |
17 | | -from distutils import util |
18 | 17 | import os |
19 | 18 | import re |
20 | 19 | from typing import Dict, Optional, Sequence, Tuple, Type, Union |
21 | 20 | import pkg_resources |
22 | 21 |
|
23 | | -from google.api_core import client_options as client_options_lib # type: ignore |
24 | | -from google.api_core import exceptions as core_exceptions # type: ignore |
25 | | -from google.api_core import gapic_v1 # type: ignore |
26 | | -from google.api_core import retry as retries # type: ignore |
| 22 | +from google.api_core import client_options as client_options_lib |
| 23 | +from google.api_core import exceptions as core_exceptions |
| 24 | +from google.api_core import gapic_v1 |
| 25 | +from google.api_core import retry as retries |
27 | 26 | from google.auth import credentials as ga_credentials # type: ignore |
28 | 27 | from google.auth.transport import mtls # type: ignore |
29 | 28 | from google.auth.transport.grpc import SslCredentials # type: ignore |
30 | 29 | from google.auth.exceptions import MutualTLSChannelError # type: ignore |
31 | 30 | from google.oauth2 import service_account # type: ignore |
32 | 31 |
|
33 | | -OptionalRetry = Union[retries.Retry, object] |
| 32 | +try: |
| 33 | + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] |
| 34 | +except AttributeError: # pragma: NO COVER |
| 35 | + OptionalRetry = Union[retries.Retry, object] # type: ignore |
34 | 36 |
|
35 | 37 | from google.cloud.orchestration.airflow.service_v1.services.image_versions import pagers |
36 | 38 | from google.cloud.orchestration.airflow.service_v1.types import image_versions |
@@ -265,8 +267,15 @@ def __init__( |
265 | 267 | client_options = client_options_lib.ClientOptions() |
266 | 268 |
|
267 | 269 | # Create SSL credentials for mutual TLS if needed. |
268 | | - use_client_cert = bool( |
269 | | - util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) |
| 270 | + if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( |
| 271 | + "true", |
| 272 | + "false", |
| 273 | + ): |
| 274 | + raise ValueError( |
| 275 | + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" |
| 276 | + ) |
| 277 | + use_client_cert = ( |
| 278 | + os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" |
270 | 279 | ) |
271 | 280 |
|
272 | 281 | client_cert_source_func = None |
|
0 commit comments