Skip to content

Commit cf8cbb8

Browse files
committed
update creds info logic
1 parent 98ab1f0 commit cf8cbb8

File tree

16 files changed

+56
-64
lines changed

16 files changed

+56
-64
lines changed

gapic/templates/%namespace/%name_%version/%sub/services/%service/async_client.py.j2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,10 @@ class {{ service.async_client_name }}:
254254
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER
255255
# TODO: Make this performant when logging is not enabled
256256

257-
credential_info = None
258257
# TODO: Remove this condition once the minimum version of google-auth is 2.35.0
259-
if hasattr(self.transport._credentials, "get_cred_info"):
260-
credential_info = self.transport._credentials.get_cred_info()
258+
credential_info = getattr(self.transport._credentials, "get_cred_info", None)
259+
if callable(credential_info):
260+
credential_info = credential_info()
261261

262262
_LOGGER.debug(
263263
"Created client `{{ service.meta.address.proto_package_versioned }}.{{ service.async_client_name }}`.",

gapic/templates/%namespace/%name_%version/%sub/services/%service/client.py.j2

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ except AttributeError: # pragma: NO COVER
4141
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
4242

4343
try: # pragma: NO COVER
44-
from google.api_core import client_logging
44+
from google.api_core import client_logging # type: ignore
4545
CLIENT_LOGGING_SUPPORTED = True
4646
except ImportError:
4747
CLIENT_LOGGING_SUPPORTED = False
@@ -612,12 +612,11 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
612612

613613
if "async" not in str(self._transport):
614614
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER
615-
# TODO: Make this performant when logging is not enabled
616615

617-
credential_info = None
618616
# TODO: Remove this condition once the minimum version of google-auth is 2.35.0
619-
if hasattr(self.transport._credentials, "get_cred_info"):
620-
credential_info = self.transport._credentials.get_cred_info()
617+
credential_info = getattr(self.transport._credentials, "get_cred_info", None)
618+
if callable(credential_info):
619+
credential_info = credential_info()
621620

622621
_LOGGER.debug(
623622
"Created client `{{ service.meta.address.proto_package_versioned }}.{{ service.client_name }}`.",

tests/integration/goldens/asset/google/cloud/asset_v1/services/asset_service/async_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,10 @@ def __init__(self, *,
258258
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER
259259
# TODO: Make this performant when logging is not enabled
260260

261-
credential_info = None
262261
# TODO: Remove this condition once the minimum version of google-auth is 2.35.0
263-
if hasattr(self.transport._credentials, "get_cred_info"):
264-
credential_info = self.transport._credentials.get_cred_info()
262+
credential_info = getattr(self.transport._credentials, "get_cred_info", None)
263+
if callable(credential_info):
264+
credential_info = credential_info()
265265

266266
_LOGGER.debug(
267267
"Created client `google.cloud.asset_v1.AssetServiceAsyncClient`.",

tests/integration/goldens/asset/google/cloud/asset_v1/services/asset_service/client.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
3939

4040
try: # pragma: NO COVER
41-
from google.api_core import client_logging
41+
from google.api_core import client_logging # type: ignore
4242
CLIENT_LOGGING_SUPPORTED = True
4343
except ImportError:
4444
CLIENT_LOGGING_SUPPORTED = False
@@ -633,12 +633,11 @@ def __init__(self, *,
633633

634634
if "async" not in str(self._transport):
635635
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER
636-
# TODO: Make this performant when logging is not enabled
637636

638-
credential_info = None
639637
# TODO: Remove this condition once the minimum version of google-auth is 2.35.0
640-
if hasattr(self.transport._credentials, "get_cred_info"):
641-
credential_info = self.transport._credentials.get_cred_info()
638+
credential_info = getattr(self.transport._credentials, "get_cred_info", None)
639+
if callable(credential_info):
640+
credential_info = credential_info()
642641

643642
_LOGGER.debug(
644643
"Created client `google.cloud.asset_v1.AssetServiceClient`.",

tests/integration/goldens/credentials/google/iam/credentials_v1/services/iam_credentials/async_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,10 @@ def __init__(self, *,
249249
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER
250250
# TODO: Make this performant when logging is not enabled
251251

252-
credential_info = None
253252
# TODO: Remove this condition once the minimum version of google-auth is 2.35.0
254-
if hasattr(self.transport._credentials, "get_cred_info"):
255-
credential_info = self.transport._credentials.get_cred_info()
253+
credential_info = getattr(self.transport._credentials, "get_cred_info", None)
254+
if callable(credential_info):
255+
credential_info = credential_info()
256256

257257
_LOGGER.debug(
258258
"Created client `google.iam.credentials_v1.IAMCredentialsAsyncClient`.",

tests/integration/goldens/credentials/google/iam/credentials_v1/services/iam_credentials/client.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
3939

4040
try: # pragma: NO COVER
41-
from google.api_core import client_logging
41+
from google.api_core import client_logging # type: ignore
4242
CLIENT_LOGGING_SUPPORTED = True
4343
except ImportError:
4444
CLIENT_LOGGING_SUPPORTED = False
@@ -570,12 +570,11 @@ def __init__(self, *,
570570

571571
if "async" not in str(self._transport):
572572
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER
573-
# TODO: Make this performant when logging is not enabled
574573

575-
credential_info = None
576574
# TODO: Remove this condition once the minimum version of google-auth is 2.35.0
577-
if hasattr(self.transport._credentials, "get_cred_info"):
578-
credential_info = self.transport._credentials.get_cred_info()
575+
credential_info = getattr(self.transport._credentials, "get_cred_info", None)
576+
if callable(credential_info):
577+
credential_info = credential_info()
579578

580579
_LOGGER.debug(
581580
"Created client `google.iam.credentials_v1.IAMCredentialsClient`.",

tests/integration/goldens/eventarc/google/cloud/eventarc_v1/services/eventarc/async_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,10 @@ def __init__(self, *,
276276
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER
277277
# TODO: Make this performant when logging is not enabled
278278

279-
credential_info = None
280279
# TODO: Remove this condition once the minimum version of google-auth is 2.35.0
281-
if hasattr(self.transport._credentials, "get_cred_info"):
282-
credential_info = self.transport._credentials.get_cred_info()
280+
credential_info = getattr(self.transport._credentials, "get_cred_info", None)
281+
if callable(credential_info):
282+
credential_info = credential_info()
283283

284284
_LOGGER.debug(
285285
"Created client `google.cloud.eventarc_v1.EventarcAsyncClient`.",

tests/integration/goldens/eventarc/google/cloud/eventarc_v1/services/eventarc/client.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
3939

4040
try: # pragma: NO COVER
41-
from google.api_core import client_logging
41+
from google.api_core import client_logging # type: ignore
4242
CLIENT_LOGGING_SUPPORTED = True
4343
except ImportError:
4444
CLIENT_LOGGING_SUPPORTED = False
@@ -678,12 +678,11 @@ def __init__(self, *,
678678

679679
if "async" not in str(self._transport):
680680
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER
681-
# TODO: Make this performant when logging is not enabled
682681

683-
credential_info = None
684682
# TODO: Remove this condition once the minimum version of google-auth is 2.35.0
685-
if hasattr(self.transport._credentials, "get_cred_info"):
686-
credential_info = self.transport._credentials.get_cred_info()
683+
credential_info = getattr(self.transport._credentials, "get_cred_info", None)
684+
if callable(credential_info):
685+
credential_info = credential_info()
687686

688687
_LOGGER.debug(
689688
"Created client `google.cloud.eventarc_v1.EventarcClient`.",

tests/integration/goldens/logging/google/cloud/logging_v2/services/config_service_v2/async_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,10 @@ def __init__(self, *,
253253
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER
254254
# TODO: Make this performant when logging is not enabled
255255

256-
credential_info = None
257256
# TODO: Remove this condition once the minimum version of google-auth is 2.35.0
258-
if hasattr(self.transport._credentials, "get_cred_info"):
259-
credential_info = self.transport._credentials.get_cred_info()
257+
credential_info = getattr(self.transport._credentials, "get_cred_info", None)
258+
if callable(credential_info):
259+
credential_info = credential_info()
260260

261261
_LOGGER.debug(
262262
"Created client `google.logging_v2.ConfigServiceV2AsyncClient`.",

tests/integration/goldens/logging/google/cloud/logging_v2/services/config_service_v2/client.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
3939

4040
try: # pragma: NO COVER
41-
from google.api_core import client_logging
41+
from google.api_core import client_logging # type: ignore
4242
CLIENT_LOGGING_SUPPORTED = True
4343
except ImportError:
4444
CLIENT_LOGGING_SUPPORTED = False
@@ -626,12 +626,11 @@ def __init__(self, *,
626626

627627
if "async" not in str(self._transport):
628628
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER
629-
# TODO: Make this performant when logging is not enabled
630629

631-
credential_info = None
632630
# TODO: Remove this condition once the minimum version of google-auth is 2.35.0
633-
if hasattr(self.transport._credentials, "get_cred_info"):
634-
credential_info = self.transport._credentials.get_cred_info()
631+
credential_info = getattr(self.transport._credentials, "get_cred_info", None)
632+
if callable(credential_info):
633+
credential_info = credential_info()
635634

636635
_LOGGER.debug(
637636
"Created client `google.logging_v2.ConfigServiceV2Client`.",

0 commit comments

Comments
 (0)