|
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.billing.budgets_v1beta1.services.budget_service import pagers |
36 | 38 | from google.cloud.billing.budgets_v1beta1.types import budget_model |
@@ -284,8 +286,15 @@ def __init__( |
284 | 286 | client_options = client_options_lib.ClientOptions() |
285 | 287 |
|
286 | 288 | # Create SSL credentials for mutual TLS if needed. |
287 | | - use_client_cert = bool( |
288 | | - util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) |
| 289 | + if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( |
| 290 | + "true", |
| 291 | + "false", |
| 292 | + ): |
| 293 | + raise ValueError( |
| 294 | + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" |
| 295 | + ) |
| 296 | + use_client_cert = ( |
| 297 | + os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" |
289 | 298 | ) |
290 | 299 |
|
291 | 300 | client_cert_source_func = None |
|
0 commit comments