Skip to content

Commit e92d527

Browse files
feat: [Many APIs] Add REST Interceptors which support reading metadata (#13497)
BEGIN_COMMIT_OVERRIDE 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 END_COMMIT_OVERRIDE - [ ] Regenerate this pull request now. 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: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRhdGFjYXRhbG9nLWxpbmVhZ2UvLk93bEJvdC55YW1sIiwiaCI6ImUyOTFjNGRkMWQ2NzBlZGExOTk5OGRlNzZmOTY3ZTE2MDNhNDg5OTMifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRhdGFjYXRhbG9nLy5Pd2xCb3QueWFtbCIsImgiOiJlMjkxYzRkZDFkNjcwZWRhMTk5OThkZTc2Zjk2N2UxNjAzYTQ4OTkzIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRhdGFmbG93LWNsaWVudC8uT3dsQm90LnlhbWwiLCJoIjoiZTI5MWM0ZGQxZDY3MGVkYTE5OTk4ZGU3NmY5NjdlMTYwM2E0ODk5MyJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRhdGFmb3JtLy5Pd2xCb3QueWFtbCIsImgiOiJlMjkxYzRkZDFkNjcwZWRhMTk5OThkZTc2Zjk2N2UxNjAzYTQ4OTkzIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRhdGFsYWJlbGluZy8uT3dsQm90LnlhbWwiLCJoIjoiZTI5MWM0ZGQxZDY3MGVkYTE5OTk4ZGU3NmY5NjdlMTYwM2E0ODk5MyJ9 Copy-Tag: eyJwIjoicGFja2F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3dsQm90LnlhbWwiLCJoIjoiZTI5MWM0ZGQxZDY3MGVkYTE5OTk4ZGU3NmY5NjdlMTYwM2E0ODk5MyJ9 --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: ohmayr <[email protected]>
1 parent e22e2bd commit e92d527

File tree

582 files changed

+58948
-7050
lines changed

Some content is hidden

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

582 files changed

+58948
-7050
lines changed

packages/google-cloud-datacatalog-lineage/google/cloud/datacatalog_lineage/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "0.3.11" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-datacatalog-lineage/google/cloud/datacatalog_lineage_v1/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "0.3.11" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-datacatalog-lineage/google/cloud/datacatalog_lineage_v1/services/lineage/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
@@ -545,6 +547,33 @@ def _validate_universe_domain(self):
545547
# NOTE (b/349488459): universe validation is disabled until further notice.
546548
return True
547549

550+
def _add_cred_info_for_auth_errors(
551+
self, error: core_exceptions.GoogleAPICallError
552+
) -> None:
553+
"""Adds credential info string to error details for 401/403/404 errors.
554+
555+
Args:
556+
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
557+
"""
558+
if error.code not in [
559+
HTTPStatus.UNAUTHORIZED,
560+
HTTPStatus.FORBIDDEN,
561+
HTTPStatus.NOT_FOUND,
562+
]:
563+
return
564+
565+
cred = self._transport._credentials
566+
567+
# get_cred_info is only available in google-auth>=2.35.0
568+
if not hasattr(cred, "get_cred_info"):
569+
return
570+
571+
# ignore the type check since pypy test fails when get_cred_info
572+
# is not available
573+
cred_info = cred.get_cred_info() # type: ignore
574+
if cred_info and hasattr(error._details, "append"):
575+
error._details.append(json.dumps(cred_info))
576+
548577
@property
549578
def api_endpoint(self):
550579
"""Return the API endpoint used by the client instance.
@@ -2770,16 +2799,20 @@ def list_operations(
27702799
# Validate the universe domain.
27712800
self._validate_universe_domain()
27722801

2773-
# Send the request.
2774-
response = rpc(
2775-
request,
2776-
retry=retry,
2777-
timeout=timeout,
2778-
metadata=metadata,
2779-
)
2802+
try:
2803+
# Send the request.
2804+
response = rpc(
2805+
request,
2806+
retry=retry,
2807+
timeout=timeout,
2808+
metadata=metadata,
2809+
)
27802810

2781-
# Done; return the response.
2782-
return response
2811+
# Done; return the response.
2812+
return response
2813+
except core_exceptions.GoogleAPICallError as e:
2814+
self._add_cred_info_for_auth_errors(e)
2815+
raise e
27832816

27842817
def get_operation(
27852818
self,
@@ -2825,16 +2858,20 @@ def get_operation(
28252858
# Validate the universe domain.
28262859
self._validate_universe_domain()
28272860

2828-
# Send the request.
2829-
response = rpc(
2830-
request,
2831-
retry=retry,
2832-
timeout=timeout,
2833-
metadata=metadata,
2834-
)
2861+
try:
2862+
# Send the request.
2863+
response = rpc(
2864+
request,
2865+
retry=retry,
2866+
timeout=timeout,
2867+
metadata=metadata,
2868+
)
28352869

2836-
# Done; return the response.
2837-
return response
2870+
# Done; return the response.
2871+
return response
2872+
except core_exceptions.GoogleAPICallError as e:
2873+
self._add_cred_info_for_auth_errors(e)
2874+
raise e
28382875

28392876
def delete_operation(
28402877
self,

0 commit comments

Comments
 (0)