Skip to content

Commit 0e9d669

Browse files
feat: [google-cloud-monitoring] Add REST Interceptors which support reading metadata (#13486)
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 docs: remove extra fenced code block markers feat: add filter field to snooze proto 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: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW1vbml0b3JpbmcvLk93bEJvdC55YW1sIiwiaCI6ImUyOTFjNGRkMWQ2NzBlZGExOTk5OGRlNzZmOTY3ZTE2MDNhNDg5OTMifQ== BEGIN_NESTED_COMMIT docs: [google-cloud-monitoring] remove extra fenced code block markers feat: add filter field to snooze proto PiperOrigin-RevId: 721410619 Source-Link: googleapis/googleapis@4d95834 Source-Link: googleapis/googleapis-gen@6f3fbcb Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW1vbml0b3JpbmcvLk93bEJvdC55YW1sIiwiaCI6IjZmM2ZiY2JiY2QyYTYxZGQ3MmIwMTQ0ZWNkNzA0M2E5OTczZDM5ZTEifQ== END_NESTED_COMMIT --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: ohmayr <[email protected]>
1 parent 8a3376a commit 0e9d669

File tree

21 files changed

+667
-7
lines changed

21 files changed

+667
-7
lines changed

packages/google-cloud-monitoring/google/cloud/monitoring/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.26.0" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-monitoring/google/cloud/monitoring_v3/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.26.0" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/alert_policy_service/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
@@ -515,6 +517,33 @@ def _validate_universe_domain(self):
515517
# NOTE (b/349488459): universe validation is disabled until further notice.
516518
return True
517519

520+
def _add_cred_info_for_auth_errors(
521+
self, error: core_exceptions.GoogleAPICallError
522+
) -> None:
523+
"""Adds credential info string to error details for 401/403/404 errors.
524+
525+
Args:
526+
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
527+
"""
528+
if error.code not in [
529+
HTTPStatus.UNAUTHORIZED,
530+
HTTPStatus.FORBIDDEN,
531+
HTTPStatus.NOT_FOUND,
532+
]:
533+
return
534+
535+
cred = self._transport._credentials
536+
537+
# get_cred_info is only available in google-auth>=2.35.0
538+
if not hasattr(cred, "get_cred_info"):
539+
return
540+
541+
# ignore the type check since pypy test fails when get_cred_info
542+
# is not available
543+
cred_info = cred.get_cred_info() # type: ignore
544+
if cred_info and hasattr(error._details, "append"):
545+
error._details.append(json.dumps(cred_info))
546+
518547
@property
519548
def api_endpoint(self):
520549
"""Return the API endpoint used by the client instance.

packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/group_service/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
@@ -492,6 +494,33 @@ def _validate_universe_domain(self):
492494
# NOTE (b/349488459): universe validation is disabled until further notice.
493495
return True
494496

497+
def _add_cred_info_for_auth_errors(
498+
self, error: core_exceptions.GoogleAPICallError
499+
) -> None:
500+
"""Adds credential info string to error details for 401/403/404 errors.
501+
502+
Args:
503+
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
504+
"""
505+
if error.code not in [
506+
HTTPStatus.UNAUTHORIZED,
507+
HTTPStatus.FORBIDDEN,
508+
HTTPStatus.NOT_FOUND,
509+
]:
510+
return
511+
512+
cred = self._transport._credentials
513+
514+
# get_cred_info is only available in google-auth>=2.35.0
515+
if not hasattr(cred, "get_cred_info"):
516+
return
517+
518+
# ignore the type check since pypy test fails when get_cred_info
519+
# is not available
520+
cred_info = cred.get_cred_info() # type: ignore
521+
if cred_info and hasattr(error._details, "append"):
522+
error._details.append(json.dumps(cred_info))
523+
495524
@property
496525
def api_endpoint(self):
497526
"""Return the API endpoint used by the client instance.

packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/metric_service/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
@@ -527,6 +529,33 @@ def _validate_universe_domain(self):
527529
# NOTE (b/349488459): universe validation is disabled until further notice.
528530
return True
529531

532+
def _add_cred_info_for_auth_errors(
533+
self, error: core_exceptions.GoogleAPICallError
534+
) -> None:
535+
"""Adds credential info string to error details for 401/403/404 errors.
536+
537+
Args:
538+
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
539+
"""
540+
if error.code not in [
541+
HTTPStatus.UNAUTHORIZED,
542+
HTTPStatus.FORBIDDEN,
543+
HTTPStatus.NOT_FOUND,
544+
]:
545+
return
546+
547+
cred = self._transport._credentials
548+
549+
# get_cred_info is only available in google-auth>=2.35.0
550+
if not hasattr(cred, "get_cred_info"):
551+
return
552+
553+
# ignore the type check since pypy test fails when get_cred_info
554+
# is not available
555+
cred_info = cred.get_cred_info() # type: ignore
556+
if cred_info and hasattr(error._details, "append"):
557+
error._details.append(json.dumps(cred_info))
558+
530559
@property
531560
def api_endpoint(self):
532561
"""Return the API endpoint used by the client instance.

packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/notification_channel_service/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
@@ -516,6 +518,33 @@ def _validate_universe_domain(self):
516518
# NOTE (b/349488459): universe validation is disabled until further notice.
517519
return True
518520

521+
def _add_cred_info_for_auth_errors(
522+
self, error: core_exceptions.GoogleAPICallError
523+
) -> None:
524+
"""Adds credential info string to error details for 401/403/404 errors.
525+
526+
Args:
527+
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
528+
"""
529+
if error.code not in [
530+
HTTPStatus.UNAUTHORIZED,
531+
HTTPStatus.FORBIDDEN,
532+
HTTPStatus.NOT_FOUND,
533+
]:
534+
return
535+
536+
cred = self._transport._credentials
537+
538+
# get_cred_info is only available in google-auth>=2.35.0
539+
if not hasattr(cred, "get_cred_info"):
540+
return
541+
542+
# ignore the type check since pypy test fails when get_cred_info
543+
# is not available
544+
cred_info = cred.get_cred_info() # type: ignore
545+
if cred_info and hasattr(error._details, "append"):
546+
error._details.append(json.dumps(cred_info))
547+
519548
@property
520549
def api_endpoint(self):
521550
"""Return the API endpoint used by the client instance.

packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/query_service/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
@@ -463,6 +465,33 @@ def _validate_universe_domain(self):
463465
# NOTE (b/349488459): universe validation is disabled until further notice.
464466
return True
465467

468+
def _add_cred_info_for_auth_errors(
469+
self, error: core_exceptions.GoogleAPICallError
470+
) -> None:
471+
"""Adds credential info string to error details for 401/403/404 errors.
472+
473+
Args:
474+
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
475+
"""
476+
if error.code not in [
477+
HTTPStatus.UNAUTHORIZED,
478+
HTTPStatus.FORBIDDEN,
479+
HTTPStatus.NOT_FOUND,
480+
]:
481+
return
482+
483+
cred = self._transport._credentials
484+
485+
# get_cred_info is only available in google-auth>=2.35.0
486+
if not hasattr(cred, "get_cred_info"):
487+
return
488+
489+
# ignore the type check since pypy test fails when get_cred_info
490+
# is not available
491+
cred_info = cred.get_cred_info() # type: ignore
492+
if cred_info and hasattr(error._details, "append"):
493+
error._details.append(json.dumps(cred_info))
494+
466495
@property
467496
def api_endpoint(self):
468497
"""Return the API endpoint used by the client instance.

packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/service_monitoring_service/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
@@ -512,6 +514,33 @@ def _validate_universe_domain(self):
512514
# NOTE (b/349488459): universe validation is disabled until further notice.
513515
return True
514516

517+
def _add_cred_info_for_auth_errors(
518+
self, error: core_exceptions.GoogleAPICallError
519+
) -> None:
520+
"""Adds credential info string to error details for 401/403/404 errors.
521+
522+
Args:
523+
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
524+
"""
525+
if error.code not in [
526+
HTTPStatus.UNAUTHORIZED,
527+
HTTPStatus.FORBIDDEN,
528+
HTTPStatus.NOT_FOUND,
529+
]:
530+
return
531+
532+
cred = self._transport._credentials
533+
534+
# get_cred_info is only available in google-auth>=2.35.0
535+
if not hasattr(cred, "get_cred_info"):
536+
return
537+
538+
# ignore the type check since pypy test fails when get_cred_info
539+
# is not available
540+
cred_info = cred.get_cred_info() # type: ignore
541+
if cred_info and hasattr(error._details, "append"):
542+
error._details.append(json.dumps(cred_info))
543+
515544
@property
516545
def api_endpoint(self):
517546
"""Return the API endpoint used by the client instance.

packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/snooze_service/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
@@ -504,6 +506,33 @@ def _validate_universe_domain(self):
504506
# NOTE (b/349488459): universe validation is disabled until further notice.
505507
return True
506508

509+
def _add_cred_info_for_auth_errors(
510+
self, error: core_exceptions.GoogleAPICallError
511+
) -> None:
512+
"""Adds credential info string to error details for 401/403/404 errors.
513+
514+
Args:
515+
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
516+
"""
517+
if error.code not in [
518+
HTTPStatus.UNAUTHORIZED,
519+
HTTPStatus.FORBIDDEN,
520+
HTTPStatus.NOT_FOUND,
521+
]:
522+
return
523+
524+
cred = self._transport._credentials
525+
526+
# get_cred_info is only available in google-auth>=2.35.0
527+
if not hasattr(cred, "get_cred_info"):
528+
return
529+
530+
# ignore the type check since pypy test fails when get_cred_info
531+
# is not available
532+
cred_info = cred.get_cred_info() # type: ignore
533+
if cred_info and hasattr(error._details, "append"):
534+
error._details.append(json.dumps(cred_info))
535+
507536
@property
508537
def api_endpoint(self):
509538
"""Return the API endpoint used by the client instance.

packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/uptime_check_service/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
@@ -514,6 +516,33 @@ def _validate_universe_domain(self):
514516
# NOTE (b/349488459): universe validation is disabled until further notice.
515517
return True
516518

519+
def _add_cred_info_for_auth_errors(
520+
self, error: core_exceptions.GoogleAPICallError
521+
) -> None:
522+
"""Adds credential info string to error details for 401/403/404 errors.
523+
524+
Args:
525+
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
526+
"""
527+
if error.code not in [
528+
HTTPStatus.UNAUTHORIZED,
529+
HTTPStatus.FORBIDDEN,
530+
HTTPStatus.NOT_FOUND,
531+
]:
532+
return
533+
534+
cred = self._transport._credentials
535+
536+
# get_cred_info is only available in google-auth>=2.35.0
537+
if not hasattr(cred, "get_cred_info"):
538+
return
539+
540+
# ignore the type check since pypy test fails when get_cred_info
541+
# is not available
542+
cred_info = cred.get_cred_info() # type: ignore
543+
if cred_info and hasattr(error._details, "append"):
544+
error._details.append(json.dumps(cred_info))
545+
517546
@property
518547
def api_endpoint(self):
519548
"""Return the API endpoint used by the client instance.

0 commit comments

Comments
 (0)