Skip to content

Commit 01aca65

Browse files
1 parent 453b5bd commit 01aca65

File tree

125 files changed

+2163
-99903
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+2163
-99903
lines changed

‎google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/client.py‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# limitations under the License.
1515
#
1616
from collections import OrderedDict
17+
from http import HTTPStatus
18+
import json
1719
import logging as std_logging
1820
import os
1921
import re
@@ -609,6 +611,33 @@ def _validate_universe_domain(self):
609611
# NOTE (b/349488459): universe validation is disabled until further notice.
610612
return True
611613

614+
def _add_cred_info_for_auth_errors(
615+
self, error: core_exceptions.GoogleAPICallError
616+
) -> None:
617+
"""Adds credential info string to error details for 401/403/404 errors.
618+
619+
Args:
620+
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
621+
"""
622+
if error.code not in [
623+
HTTPStatus.UNAUTHORIZED,
624+
HTTPStatus.FORBIDDEN,
625+
HTTPStatus.NOT_FOUND,
626+
]:
627+
return
628+
629+
cred = self._transport._credentials
630+
631+
# get_cred_info is only available in google-auth>=2.35.0
632+
if not hasattr(cred, "get_cred_info"):
633+
return
634+
635+
# ignore the type check since pypy test fails when get_cred_info
636+
# is not available
637+
cred_info = cred.get_cred_info() # type: ignore
638+
if cred_info and hasattr(error._details, "append"):
639+
error._details.append(json.dumps(cred_info))
640+
612641
@property
613642
def api_endpoint(self):
614643
"""Return the API endpoint used by the client instance.

‎google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/rest.py‎

Lines changed: 537 additions & 36 deletions
Large diffs are not rendered by default.

‎google/cloud/bigtable_admin_v2/services/bigtable_table_admin/client.py‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# limitations under the License.
1515
#
1616
from collections import OrderedDict
17+
from http import HTTPStatus
18+
import json
1719
import logging as std_logging
1820
import os
1921
import re
@@ -633,6 +635,33 @@ def _validate_universe_domain(self):
633635
# NOTE (b/349488459): universe validation is disabled until further notice.
634636
return True
635637

638+
def _add_cred_info_for_auth_errors(
639+
self, error: core_exceptions.GoogleAPICallError
640+
) -> None:
641+
"""Adds credential info string to error details for 401/403/404 errors.
642+
643+
Args:
644+
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
645+
"""
646+
if error.code not in [
647+
HTTPStatus.UNAUTHORIZED,
648+
HTTPStatus.FORBIDDEN,
649+
HTTPStatus.NOT_FOUND,
650+
]:
651+
return
652+
653+
cred = self._transport._credentials
654+
655+
# get_cred_info is only available in google-auth>=2.35.0
656+
if not hasattr(cred, "get_cred_info"):
657+
return
658+
659+
# ignore the type check since pypy test fails when get_cred_info
660+
# is not available
661+
cred_info = cred.get_cred_info() # type: ignore
662+
if cred_info and hasattr(error._details, "append"):
663+
error._details.append(json.dumps(cred_info))
664+
636665
@property
637666
def api_endpoint(self):
638667
"""Return the API endpoint used by the client instance.

0 commit comments

Comments
 (0)