Skip to content

Commit 7ecb33c

Browse files
feat: [google-cloud-monitoring] added SqlCondition in AlertPolicy (#13359)
- [ ] Regenerate this pull request now. BEGIN_COMMIT_OVERRIDE feat: Add support for opt-in debug logging fix: Fix typing issue with gRPC metadata when key ends in -bin feat: added PrometheusQueryLanguageCondition.disable_metric_validation feat: deprecated QueryTimeSeries (MQL query endpoint) feat: added TimeSeries.description for input only docs: TimeSeries.unit allows limited updating by CreateTimeSeries docs: ServiceLevelObjective.goal must be <= 0.9999 docs: ServiceAgentAuthentication supports generating an OAuth token feat: added SqlCondition in AlertPolicy END_COMMIT_OVERRIDE For more information about the status of MQL, see the [MQL deprecation notice](https://cloud.google.com/stackdriver/docs/deprecations/mql). PiperOrigin-RevId: 706010293 Source-Link: googleapis/googleapis@f4eff54 Source-Link: googleapis/googleapis-gen@adad43e Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW1vbml0b3JpbmcvLk93bEJvdC55YW1sIiwiaCI6ImFkYWQ0M2ViZTBjOTU5OTE3YTVkOTMzNDhjMjJiOTVkYjYyZTY1YTEifQ== Fixes #13356 --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
1 parent 8e53145 commit 7ecb33c

File tree

49 files changed

+3166
-658
lines changed

Some content is hidden

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

49 files changed

+3166
-658
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.24.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.24.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/async_client.py

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# limitations under the License.
1515
#
1616
from collections import OrderedDict
17+
import logging as std_logging
1718
import re
1819
from typing import (
1920
Callable,
@@ -54,6 +55,15 @@
5455
from .transports.base import DEFAULT_CLIENT_INFO, AlertPolicyServiceTransport
5556
from .transports.grpc_asyncio import AlertPolicyServiceGrpcAsyncIOTransport
5657

58+
try:
59+
from google.api_core import client_logging # type: ignore
60+
61+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
62+
except ImportError: # pragma: NO COVER
63+
CLIENT_LOGGING_SUPPORTED = False
64+
65+
_LOGGER = std_logging.getLogger(__name__)
66+
5767

5868
class AlertPolicyServiceAsyncClient:
5969
"""The AlertPolicyService API is used to manage (list, create, delete,
@@ -280,14 +290,36 @@ def __init__(
280290
client_info=client_info,
281291
)
282292

293+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
294+
std_logging.DEBUG
295+
): # pragma: NO COVER
296+
_LOGGER.debug(
297+
"Created client `google.monitoring_v3.AlertPolicyServiceAsyncClient`.",
298+
extra={
299+
"serviceName": "google.monitoring.v3.AlertPolicyService",
300+
"universeDomain": getattr(
301+
self._client._transport._credentials, "universe_domain", ""
302+
),
303+
"credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}",
304+
"credentialsInfo": getattr(
305+
self.transport._credentials, "get_cred_info", lambda: None
306+
)(),
307+
}
308+
if hasattr(self._client._transport, "_credentials")
309+
else {
310+
"serviceName": "google.monitoring.v3.AlertPolicyService",
311+
"credentialsType": None,
312+
},
313+
)
314+
283315
async def list_alert_policies(
284316
self,
285317
request: Optional[Union[alert_service.ListAlertPoliciesRequest, dict]] = None,
286318
*,
287319
name: Optional[str] = None,
288320
retry: OptionalRetry = gapic_v1.method.DEFAULT,
289321
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
290-
metadata: Sequence[Tuple[str, str]] = (),
322+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
291323
) -> pagers.ListAlertPoliciesAsyncPager:
292324
r"""Lists the existing alerting policies for the
293325
workspace.
@@ -343,8 +375,10 @@ async def sample_list_alert_policies():
343375
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
344376
should be retried.
345377
timeout (float): The timeout for this request.
346-
metadata (Sequence[Tuple[str, str]]): Strings which should be
347-
sent along with the request as metadata.
378+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
379+
sent along with the request as metadata. Normally, each value must be of type `str`,
380+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
381+
be of type `bytes`.
348382
349383
Returns:
350384
google.cloud.monitoring_v3.services.alert_policy_service.pagers.ListAlertPoliciesAsyncPager:
@@ -418,7 +452,7 @@ async def get_alert_policy(
418452
name: Optional[str] = None,
419453
retry: OptionalRetry = gapic_v1.method.DEFAULT,
420454
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
421-
metadata: Sequence[Tuple[str, str]] = (),
455+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
422456
) -> alert.AlertPolicy:
423457
r"""Gets a single alerting policy.
424458
@@ -465,8 +499,10 @@ async def sample_get_alert_policy():
465499
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
466500
should be retried.
467501
timeout (float): The timeout for this request.
468-
metadata (Sequence[Tuple[str, str]]): Strings which should be
469-
sent along with the request as metadata.
502+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
503+
sent along with the request as metadata. Normally, each value must be of type `str`,
504+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
505+
be of type `bytes`.
470506
471507
Returns:
472508
google.cloud.monitoring_v3.types.AlertPolicy:
@@ -531,7 +567,7 @@ async def create_alert_policy(
531567
alert_policy: Optional[alert.AlertPolicy] = None,
532568
retry: OptionalRetry = gapic_v1.method.DEFAULT,
533569
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
534-
metadata: Sequence[Tuple[str, str]] = (),
570+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
535571
) -> alert.AlertPolicy:
536572
r"""Creates a new alerting policy.
537573
@@ -603,8 +639,10 @@ async def sample_create_alert_policy():
603639
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
604640
should be retried.
605641
timeout (float): The timeout for this request.
606-
metadata (Sequence[Tuple[str, str]]): Strings which should be
607-
sent along with the request as metadata.
642+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
643+
sent along with the request as metadata. Normally, each value must be of type `str`,
644+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
645+
be of type `bytes`.
608646
609647
Returns:
610648
google.cloud.monitoring_v3.types.AlertPolicy:
@@ -670,7 +708,7 @@ async def delete_alert_policy(
670708
name: Optional[str] = None,
671709
retry: OptionalRetry = gapic_v1.method.DEFAULT,
672710
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
673-
metadata: Sequence[Tuple[str, str]] = (),
711+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
674712
) -> None:
675713
r"""Deletes an alerting policy.
676714
@@ -721,8 +759,10 @@ async def sample_delete_alert_policy():
721759
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
722760
should be retried.
723761
timeout (float): The timeout for this request.
724-
metadata (Sequence[Tuple[str, str]]): Strings which should be
725-
sent along with the request as metadata.
762+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
763+
sent along with the request as metadata. Normally, each value must be of type `str`,
764+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
765+
be of type `bytes`.
726766
"""
727767
# Create or coerce a protobuf request object.
728768
# - Quick check: If we got a request object, we should *not* have
@@ -775,7 +815,7 @@ async def update_alert_policy(
775815
alert_policy: Optional[alert.AlertPolicy] = None,
776816
retry: OptionalRetry = gapic_v1.method.DEFAULT,
777817
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
778-
metadata: Sequence[Tuple[str, str]] = (),
818+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
779819
) -> alert.AlertPolicy:
780820
r"""Updates an alerting policy. You can either replace the entire
781821
policy with a new one or replace only certain fields in the
@@ -860,8 +900,10 @@ async def sample_update_alert_policy():
860900
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
861901
should be retried.
862902
timeout (float): The timeout for this request.
863-
metadata (Sequence[Tuple[str, str]]): Strings which should be
864-
sent along with the request as metadata.
903+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
904+
sent along with the request as metadata. Normally, each value must be of type `str`,
905+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
906+
be of type `bytes`.
865907
866908
Returns:
867909
google.cloud.monitoring_v3.types.AlertPolicy:

packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/alert_policy_service/client.py

Lines changed: 62 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# limitations under the License.
1515
#
1616
from collections import OrderedDict
17+
import logging as std_logging
1718
import os
1819
import re
1920
from typing import (
@@ -48,6 +49,15 @@
4849
except AttributeError: # pragma: NO COVER
4950
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
5051

52+
try:
53+
from google.api_core import client_logging # type: ignore
54+
55+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
56+
except ImportError: # pragma: NO COVER
57+
CLIENT_LOGGING_SUPPORTED = False
58+
59+
_LOGGER = std_logging.getLogger(__name__)
60+
5161
from google.longrunning import operations_pb2 # type: ignore
5262
from google.protobuf import field_mask_pb2 # type: ignore
5363
from google.protobuf import wrappers_pb2 # type: ignore
@@ -613,6 +623,10 @@ def __init__(
613623
# Initialize the universe domain validation.
614624
self._is_universe_domain_valid = False
615625

626+
if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER
627+
# Setup logging.
628+
client_logging.initialize_logging()
629+
616630
api_key_value = getattr(self._client_options, "api_key", None)
617631
if api_key_value and credentials:
618632
raise ValueError(
@@ -679,14 +693,37 @@ def __init__(
679693
api_audience=self._client_options.api_audience,
680694
)
681695

696+
if "async" not in str(self._transport):
697+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
698+
std_logging.DEBUG
699+
): # pragma: NO COVER
700+
_LOGGER.debug(
701+
"Created client `google.monitoring_v3.AlertPolicyServiceClient`.",
702+
extra={
703+
"serviceName": "google.monitoring.v3.AlertPolicyService",
704+
"universeDomain": getattr(
705+
self._transport._credentials, "universe_domain", ""
706+
),
707+
"credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}",
708+
"credentialsInfo": getattr(
709+
self.transport._credentials, "get_cred_info", lambda: None
710+
)(),
711+
}
712+
if hasattr(self._transport, "_credentials")
713+
else {
714+
"serviceName": "google.monitoring.v3.AlertPolicyService",
715+
"credentialsType": None,
716+
},
717+
)
718+
682719
def list_alert_policies(
683720
self,
684721
request: Optional[Union[alert_service.ListAlertPoliciesRequest, dict]] = None,
685722
*,
686723
name: Optional[str] = None,
687724
retry: OptionalRetry = gapic_v1.method.DEFAULT,
688725
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
689-
metadata: Sequence[Tuple[str, str]] = (),
726+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
690727
) -> pagers.ListAlertPoliciesPager:
691728
r"""Lists the existing alerting policies for the
692729
workspace.
@@ -742,8 +779,10 @@ def sample_list_alert_policies():
742779
retry (google.api_core.retry.Retry): Designation of what errors, if any,
743780
should be retried.
744781
timeout (float): The timeout for this request.
745-
metadata (Sequence[Tuple[str, str]]): Strings which should be
746-
sent along with the request as metadata.
782+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
783+
sent along with the request as metadata. Normally, each value must be of type `str`,
784+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
785+
be of type `bytes`.
747786
748787
Returns:
749788
google.cloud.monitoring_v3.services.alert_policy_service.pagers.ListAlertPoliciesPager:
@@ -814,7 +853,7 @@ def get_alert_policy(
814853
name: Optional[str] = None,
815854
retry: OptionalRetry = gapic_v1.method.DEFAULT,
816855
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
817-
metadata: Sequence[Tuple[str, str]] = (),
856+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
818857
) -> alert.AlertPolicy:
819858
r"""Gets a single alerting policy.
820859
@@ -861,8 +900,10 @@ def sample_get_alert_policy():
861900
retry (google.api_core.retry.Retry): Designation of what errors, if any,
862901
should be retried.
863902
timeout (float): The timeout for this request.
864-
metadata (Sequence[Tuple[str, str]]): Strings which should be
865-
sent along with the request as metadata.
903+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
904+
sent along with the request as metadata. Normally, each value must be of type `str`,
905+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
906+
be of type `bytes`.
866907
867908
Returns:
868909
google.cloud.monitoring_v3.types.AlertPolicy:
@@ -924,7 +965,7 @@ def create_alert_policy(
924965
alert_policy: Optional[alert.AlertPolicy] = None,
925966
retry: OptionalRetry = gapic_v1.method.DEFAULT,
926967
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
927-
metadata: Sequence[Tuple[str, str]] = (),
968+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
928969
) -> alert.AlertPolicy:
929970
r"""Creates a new alerting policy.
930971
@@ -996,8 +1037,10 @@ def sample_create_alert_policy():
9961037
retry (google.api_core.retry.Retry): Designation of what errors, if any,
9971038
should be retried.
9981039
timeout (float): The timeout for this request.
999-
metadata (Sequence[Tuple[str, str]]): Strings which should be
1000-
sent along with the request as metadata.
1040+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1041+
sent along with the request as metadata. Normally, each value must be of type `str`,
1042+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
1043+
be of type `bytes`.
10011044
10021045
Returns:
10031046
google.cloud.monitoring_v3.types.AlertPolicy:
@@ -1060,7 +1103,7 @@ def delete_alert_policy(
10601103
name: Optional[str] = None,
10611104
retry: OptionalRetry = gapic_v1.method.DEFAULT,
10621105
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1063-
metadata: Sequence[Tuple[str, str]] = (),
1106+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
10641107
) -> None:
10651108
r"""Deletes an alerting policy.
10661109
@@ -1111,8 +1154,10 @@ def sample_delete_alert_policy():
11111154
retry (google.api_core.retry.Retry): Designation of what errors, if any,
11121155
should be retried.
11131156
timeout (float): The timeout for this request.
1114-
metadata (Sequence[Tuple[str, str]]): Strings which should be
1115-
sent along with the request as metadata.
1157+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1158+
sent along with the request as metadata. Normally, each value must be of type `str`,
1159+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
1160+
be of type `bytes`.
11161161
"""
11171162
# Create or coerce a protobuf request object.
11181163
# - Quick check: If we got a request object, we should *not* have
@@ -1162,7 +1207,7 @@ def update_alert_policy(
11621207
alert_policy: Optional[alert.AlertPolicy] = None,
11631208
retry: OptionalRetry = gapic_v1.method.DEFAULT,
11641209
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1165-
metadata: Sequence[Tuple[str, str]] = (),
1210+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
11661211
) -> alert.AlertPolicy:
11671212
r"""Updates an alerting policy. You can either replace the entire
11681213
policy with a new one or replace only certain fields in the
@@ -1247,8 +1292,10 @@ def sample_update_alert_policy():
12471292
retry (google.api_core.retry.Retry): Designation of what errors, if any,
12481293
should be retried.
12491294
timeout (float): The timeout for this request.
1250-
metadata (Sequence[Tuple[str, str]]): Strings which should be
1251-
sent along with the request as metadata.
1295+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1296+
sent along with the request as metadata. Normally, each value must be of type `str`,
1297+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
1298+
be of type `bytes`.
12521299
12531300
Returns:
12541301
google.cloud.monitoring_v3.types.AlertPolicy:

packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/alert_policy_service/pagers.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def __init__(
6767
*,
6868
retry: OptionalRetry = gapic_v1.method.DEFAULT,
6969
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
70-
metadata: Sequence[Tuple[str, str]] = ()
70+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
7171
):
7272
"""Instantiate the pager.
7373
@@ -81,8 +81,10 @@ def __init__(
8181
retry (google.api_core.retry.Retry): Designation of what errors,
8282
if any, should be retried.
8383
timeout (float): The timeout for this request.
84-
metadata (Sequence[Tuple[str, str]]): Strings which should be
85-
sent along with the request as metadata.
84+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
85+
sent along with the request as metadata. Normally, each value must be of type `str`,
86+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
87+
be of type `bytes`.
8688
"""
8789
self._method = method
8890
self._request = alert_service.ListAlertPoliciesRequest(request)
@@ -141,7 +143,7 @@ def __init__(
141143
*,
142144
retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,
143145
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
144-
metadata: Sequence[Tuple[str, str]] = ()
146+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
145147
):
146148
"""Instantiates the pager.
147149
@@ -155,8 +157,10 @@ def __init__(
155157
retry (google.api_core.retry.AsyncRetry): Designation of what errors,
156158
if any, should be retried.
157159
timeout (float): The timeout for this request.
158-
metadata (Sequence[Tuple[str, str]]): Strings which should be
159-
sent along with the request as metadata.
160+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
161+
sent along with the request as metadata. Normally, each value must be of type `str`,
162+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
163+
be of type `bytes`.
160164
"""
161165
self._method = method
162166
self._request = alert_service.ListAlertPoliciesRequest(request)

0 commit comments

Comments
 (0)