Skip to content

Commit 87b5382

Browse files
feat: [Many APIs] Add REST Interceptors which support reading metadata (#13501)
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: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNlY3JldC1tYW5hZ2VyLy5Pd2xCb3QueWFtbCIsImgiOiJlMjkxYzRkZDFkNjcwZWRhMTk5OThkZTc2Zjk2N2UxNjAzYTQ4OTkzIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNlY3VyZXNvdXJjZW1hbmFnZXIvLk93bEJvdC55YW1sIiwiaCI6ImUyOTFjNGRkMWQ2NzBlZGExOTk5OGRlNzZmOTY3ZTE2MDNhNDg5OTMifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNlY3VyaXR5Y2VudGVyLy5Pd2xCb3QueWFtbCIsImgiOiJlMjkxYzRkZDFkNjcwZWRhMTk5OThkZTc2Zjk2N2UxNjAzYTQ4OTkzIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNlY3VyaXR5Y2VudGVybWFuYWdlbWVudC8uT3dsQm90LnlhbWwiLCJoIjoiZTI5MWM0ZGQxZDY3MGVkYTE5OTk4ZGU3NmY5NjdlMTYwM2E0ODk5MyJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNlcnZpY2UtY29udHJvbC8uT3dsQm90LnlhbWwiLCJoIjoiZTI5MWM0ZGQxZDY3MGVkYTE5OTk4ZGU3NmY5NjdlMTYwM2E0ODk5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vZ29vZ2xlLWNsb3VkLXRwdS8uT3dsQm90LnlhbWwiLCJoIjoiZTI5MWM0ZGQxZDY3MGVkYTE5OTk4ZGU3NmY5NjdlMTYwM2E0ODk5MyJ9 --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 17fd214 commit 87b5382

File tree

244 files changed

+23944
-1925
lines changed

Some content is hidden

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

244 files changed

+23944
-1925
lines changed

packages/google-cloud-secret-manager/google/cloud/secretmanager/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__ = "2.22.1" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-secret-manager/google/cloud/secretmanager_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__ = "2.22.1" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/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
@@ -532,6 +534,33 @@ def _validate_universe_domain(self):
532534
# NOTE (b/349488459): universe validation is disabled until further notice.
533535
return True
534536

537+
def _add_cred_info_for_auth_errors(
538+
self, error: core_exceptions.GoogleAPICallError
539+
) -> None:
540+
"""Adds credential info string to error details for 401/403/404 errors.
541+
542+
Args:
543+
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
544+
"""
545+
if error.code not in [
546+
HTTPStatus.UNAUTHORIZED,
547+
HTTPStatus.FORBIDDEN,
548+
HTTPStatus.NOT_FOUND,
549+
]:
550+
return
551+
552+
cred = self._transport._credentials
553+
554+
# get_cred_info is only available in google-auth>=2.35.0
555+
if not hasattr(cred, "get_cred_info"):
556+
return
557+
558+
# ignore the type check since pypy test fails when get_cred_info
559+
# is not available
560+
cred_info = cred.get_cred_info() # type: ignore
561+
if cred_info and hasattr(error._details, "append"):
562+
error._details.append(json.dumps(cred_info))
563+
535564
@property
536565
def api_endpoint(self):
537566
"""Return the API endpoint used by the client instance.
@@ -2541,16 +2570,20 @@ def get_location(
25412570
# Validate the universe domain.
25422571
self._validate_universe_domain()
25432572

2544-
# Send the request.
2545-
response = rpc(
2546-
request,
2547-
retry=retry,
2548-
timeout=timeout,
2549-
metadata=metadata,
2550-
)
2573+
try:
2574+
# Send the request.
2575+
response = rpc(
2576+
request,
2577+
retry=retry,
2578+
timeout=timeout,
2579+
metadata=metadata,
2580+
)
25512581

2552-
# Done; return the response.
2553-
return response
2582+
# Done; return the response.
2583+
return response
2584+
except core_exceptions.GoogleAPICallError as e:
2585+
self._add_cred_info_for_auth_errors(e)
2586+
raise e
25542587

25552588
def list_locations(
25562589
self,
@@ -2596,16 +2629,20 @@ def list_locations(
25962629
# Validate the universe domain.
25972630
self._validate_universe_domain()
25982631

2599-
# Send the request.
2600-
response = rpc(
2601-
request,
2602-
retry=retry,
2603-
timeout=timeout,
2604-
metadata=metadata,
2605-
)
2632+
try:
2633+
# Send the request.
2634+
response = rpc(
2635+
request,
2636+
retry=retry,
2637+
timeout=timeout,
2638+
metadata=metadata,
2639+
)
26062640

2607-
# Done; return the response.
2608-
return response
2641+
# Done; return the response.
2642+
return response
2643+
except core_exceptions.GoogleAPICallError as e:
2644+
self._add_cred_info_for_auth_errors(e)
2645+
raise e
26092646

26102647

26112648
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(

0 commit comments

Comments
 (0)