|
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, Iterable, Iterator, 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.apigeeconnect_v1.types import tether
|
36 | 38 | from google.protobuf import duration_pb2 # type: ignore
|
@@ -269,8 +271,15 @@ def __init__(
|
269 | 271 | client_options = client_options_lib.ClientOptions()
|
270 | 272 |
|
271 | 273 | # Create SSL credentials for mutual TLS if needed.
|
272 |
| - use_client_cert = bool( |
273 |
| - util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) |
| 274 | + if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( |
| 275 | + "true", |
| 276 | + "false", |
| 277 | + ): |
| 278 | + raise ValueError( |
| 279 | + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" |
| 280 | + ) |
| 281 | + use_client_cert = ( |
| 282 | + os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" |
274 | 283 | )
|
275 | 284 |
|
276 | 285 | client_cert_source_func = None
|
|
0 commit comments