Skip to content

Commit 4e971ee

Browse files
chore: pull up gapic updates (#1016)
* feat: Add REST Interceptors which support reading metadata feat: Add support for reading selective GAPIC generation methods from service YAML chore: Update gapic-generator-python to v1.22.0 PiperOrigin-RevId: 724026024 Source-Link: googleapis/googleapis@ad99638 Source-Link: googleapis/googleapis-gen@e291c4d Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTI5MWM0ZGQxZDY3MGVkYTE5OTk4ZGU3NmY5NjdlMTYwM2E0ODk5MyJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: expose the Firestore.executePipeline API to the preview branch docs: minor documentation updates to `StructuredQuery` docs: minor documentation changes for `distance_threshold` PiperOrigin-RevId: 731306872 Source-Link: googleapis/googleapis@b6d5ae8 Source-Link: googleapis/googleapis-gen@4cb9048 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGNiOTA0ODg3MWJmNTkwNmIzOTBlOGVhM2Q3YjlmMWVmNmFjMTlkNiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Daniel Sanche <[email protected]>
1 parent a268c8f commit 4e971ee

File tree

7 files changed

+1383
-104
lines changed

7 files changed

+1383
-104
lines changed

packages/google-cloud-firestore/google/cloud/firestore_admin_v1/services/firestore_admin/client.py

Lines changed: 55 additions & 18 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
@@ -679,6 +681,33 @@ def _validate_universe_domain(self):
679681
# NOTE (b/349488459): universe validation is disabled until further notice.
680682
return True
681683

684+
def _add_cred_info_for_auth_errors(
685+
self, error: core_exceptions.GoogleAPICallError
686+
) -> None:
687+
"""Adds credential info string to error details for 401/403/404 errors.
688+
689+
Args:
690+
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
691+
"""
692+
if error.code not in [
693+
HTTPStatus.UNAUTHORIZED,
694+
HTTPStatus.FORBIDDEN,
695+
HTTPStatus.NOT_FOUND,
696+
]:
697+
return
698+
699+
cred = self._transport._credentials
700+
701+
# get_cred_info is only available in google-auth>=2.35.0
702+
if not hasattr(cred, "get_cred_info"):
703+
return
704+
705+
# ignore the type check since pypy test fails when get_cred_info
706+
# is not available
707+
cred_info = cred.get_cred_info() # type: ignore
708+
if cred_info and hasattr(error._details, "append"):
709+
error._details.append(json.dumps(cred_info))
710+
682711
@property
683712
def api_endpoint(self):
684713
"""Return the API endpoint used by the client instance.
@@ -3761,16 +3790,20 @@ def list_operations(
37613790
# Validate the universe domain.
37623791
self._validate_universe_domain()
37633792

3764-
# Send the request.
3765-
response = rpc(
3766-
request,
3767-
retry=retry,
3768-
timeout=timeout,
3769-
metadata=metadata,
3770-
)
3793+
try:
3794+
# Send the request.
3795+
response = rpc(
3796+
request,
3797+
retry=retry,
3798+
timeout=timeout,
3799+
metadata=metadata,
3800+
)
37713801

3772-
# Done; return the response.
3773-
return response
3802+
# Done; return the response.
3803+
return response
3804+
except core_exceptions.GoogleAPICallError as e:
3805+
self._add_cred_info_for_auth_errors(e)
3806+
raise e
37743807

37753808
def get_operation(
37763809
self,
@@ -3816,16 +3849,20 @@ def get_operation(
38163849
# Validate the universe domain.
38173850
self._validate_universe_domain()
38183851

3819-
# Send the request.
3820-
response = rpc(
3821-
request,
3822-
retry=retry,
3823-
timeout=timeout,
3824-
metadata=metadata,
3825-
)
3852+
try:
3853+
# Send the request.
3854+
response = rpc(
3855+
request,
3856+
retry=retry,
3857+
timeout=timeout,
3858+
metadata=metadata,
3859+
)
38263860

3827-
# Done; return the response.
3828-
return response
3861+
# Done; return the response.
3862+
return response
3863+
except core_exceptions.GoogleAPICallError as e:
3864+
self._add_cred_info_for_auth_errors(e)
3865+
raise e
38293866

38303867
def delete_operation(
38313868
self,

0 commit comments

Comments
 (0)