Skip to content

Commit d596268

Browse files
gcf-owl-bot[bot]ohmayrparthea
authored
feat: [google-cloud-monitoring] Added support for notification prompts in AlertPolicy (#13325)
BEGIN_COMMIT_OVERRIDE feat: Added support for notification prompts in AlertPolicy feat: Added support for PromQL metric validation opt-out in AlertPolicy END_COMMIT_OVERRIDE - [ ] Regenerate this pull request now. fix: Fix typing issue with gRPC metadata when key ends in -bin chore: Update gapic-generator-python to v1.21.0 PiperOrigin-RevId: 705285820 Source-Link: googleapis/googleapis@f9b8b91 Source-Link: googleapis/googleapis-gen@ca1e0a1 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW1vbml0b3JpbmcvLk93bEJvdC55YW1sIiwiaCI6ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ== BEGIN_NESTED_COMMIT feat: [google-cloud-monitoring] Added support for notification prompts in AlertPolicy feat: Added support for PromQL metric validation opt-out in AlertPolicy PiperOrigin-RevId: 702547115 Source-Link: googleapis/googleapis@dedba31 Source-Link: googleapis/googleapis-gen@8413119 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW1vbml0b3JpbmcvLk93bEJvdC55YW1sIiwiaCI6Ijg0MTMxMTk2NzY0YzhiNGY3ZTI0ZDVlNmY0NTAwYmEyYzFjOTM4YTQifQ== END_NESTED_COMMIT --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: ohmayr <omairnaveed@ymail.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parent 19ed3be commit d596268

18 files changed

+128
-107
lines changed

packages/google-cloud-monitoring/google/cloud/monitoring/gapic_version.py

+1-1
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.23.1" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-monitoring/google/cloud/monitoring_v3/gapic_version.py

+1-1
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.23.1" # {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

+3-3
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ async def sample_get_alert_policy():
473473
A description of the conditions under which some aspect of your system is
474474
considered to be "unhealthy" and the ways to notify
475475
people or services about this state. For an overview
476-
of alert policies, see [Introduction to
476+
of alerting policies, see [Introduction to
477477
Alerting](\ https://cloud.google.com/monitoring/alerts/).
478478
479479
"""
@@ -611,7 +611,7 @@ async def sample_create_alert_policy():
611611
A description of the conditions under which some aspect of your system is
612612
considered to be "unhealthy" and the ways to notify
613613
people or services about this state. For an overview
614-
of alert policies, see [Introduction to
614+
of alerting policies, see [Introduction to
615615
Alerting](\ https://cloud.google.com/monitoring/alerts/).
616616
617617
"""
@@ -868,7 +868,7 @@ async def sample_update_alert_policy():
868868
A description of the conditions under which some aspect of your system is
869869
considered to be "unhealthy" and the ways to notify
870870
people or services about this state. For an overview
871-
of alert policies, see [Introduction to
871+
of alerting policies, see [Introduction to
872872
Alerting](\ https://cloud.google.com/monitoring/alerts/).
873873
874874
"""

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ def sample_get_alert_policy():
869869
A description of the conditions under which some aspect of your system is
870870
considered to be "unhealthy" and the ways to notify
871871
people or services about this state. For an overview
872-
of alert policies, see [Introduction to
872+
of alerting policies, see [Introduction to
873873
Alerting](\ https://cloud.google.com/monitoring/alerts/).
874874
875875
"""
@@ -1004,7 +1004,7 @@ def sample_create_alert_policy():
10041004
A description of the conditions under which some aspect of your system is
10051005
considered to be "unhealthy" and the ways to notify
10061006
people or services about this state. For an overview
1007-
of alert policies, see [Introduction to
1007+
of alerting policies, see [Introduction to
10081008
Alerting](\ https://cloud.google.com/monitoring/alerts/).
10091009
10101010
"""
@@ -1255,7 +1255,7 @@ def sample_update_alert_policy():
12551255
A description of the conditions under which some aspect of your system is
12561256
considered to be "unhealthy" and the ways to notify
12571257
people or services about this state. For an overview
1258-
of alert policies, see [Introduction to
1258+
of alerting policies, see [Introduction to
12591259
Alerting](\ https://cloud.google.com/monitoring/alerts/).
12601260
12611261
"""

packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/notification_channel_service/async_client.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ async def sample_update_notification_channel():
10041004
request (Optional[Union[google.cloud.monitoring_v3.types.UpdateNotificationChannelRequest, dict]]):
10051005
The request object. The ``UpdateNotificationChannel`` request.
10061006
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
1007-
The fields to update.
1007+
Optional. The fields to update.
10081008
This corresponds to the ``update_mask`` field
10091009
on the ``request`` instance; if ``request`` is provided, this
10101010
should not be set.
@@ -1149,10 +1149,9 @@ async def sample_delete_notification_channel():
11491149
will be deleted regardless of its use in
11501150
alert policies (the policies will be
11511151
updated to remove the channel). If
1152-
false, channels that are still
1153-
referenced by an existing alerting
1154-
policy will fail to be deleted in a
1155-
delete operation.
1152+
false, this operation will fail if the
1153+
notification channel is referenced by
1154+
existing alerting policies.
11561155
11571156
This corresponds to the ``force`` field
11581157
on the ``request`` instance; if ``request`` is provided, this

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

+4-5
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ def sample_update_notification_channel():
13891389
request (Union[google.cloud.monitoring_v3.types.UpdateNotificationChannelRequest, dict]):
13901390
The request object. The ``UpdateNotificationChannel`` request.
13911391
update_mask (google.protobuf.field_mask_pb2.FieldMask):
1392-
The fields to update.
1392+
Optional. The fields to update.
13931393
This corresponds to the ``update_mask`` field
13941394
on the ``request`` instance; if ``request`` is provided, this
13951395
should not be set.
@@ -1533,10 +1533,9 @@ def sample_delete_notification_channel():
15331533
will be deleted regardless of its use in
15341534
alert policies (the policies will be
15351535
updated to remove the channel). If
1536-
false, channels that are still
1537-
referenced by an existing alerting
1538-
policy will fail to be deleted in a
1539-
delete operation.
1536+
false, this operation will fail if the
1537+
notification channel is referenced by
1538+
existing alerting policies.
15401539
15411540
This corresponds to the ``force`` field
15421541
on the ``request`` instance; if ``request`` is provided, this

packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/snooze_service/async_client.py

-2
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ async def sample_create_snooze():
297297
298298
# Initialize request argument(s)
299299
snooze = monitoring_v3.Snooze()
300-
snooze.name = "name_value"
301300
snooze.display_name = "display_name_value"
302301
303302
request = monitoring_v3.CreateSnoozeRequest(
@@ -671,7 +670,6 @@ async def sample_update_snooze():
671670
672671
# Initialize request argument(s)
673672
snooze = monitoring_v3.Snooze()
674-
snooze.name = "name_value"
675673
snooze.display_name = "display_name_value"
676674
677675
request = monitoring_v3.UpdateSnoozeRequest(

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

-2
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,6 @@ def sample_create_snooze():
694694
695695
# Initialize request argument(s)
696696
snooze = monitoring_v3.Snooze()
697-
snooze.name = "name_value"
698697
snooze.display_name = "display_name_value"
699698
700699
request = monitoring_v3.CreateSnoozeRequest(
@@ -1059,7 +1058,6 @@ def sample_update_snooze():
10591058
10601059
# Initialize request argument(s)
10611060
snooze = monitoring_v3.Snooze()
1062-
snooze.name = "name_value"
10631061
snooze.display_name = "display_name_value"
10641062
10651063
request = monitoring_v3.UpdateSnoozeRequest(

packages/google-cloud-monitoring/google/cloud/monitoring_v3/types/alert.py

+50-23
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
class AlertPolicy(proto.Message):
3737
r"""A description of the conditions under which some aspect of your
3838
system is considered to be "unhealthy" and the ways to notify people
39-
or services about this state. For an overview of alert policies, see
40-
`Introduction to
39+
or services about this state. For an overview of alerting policies,
40+
see `Introduction to
4141
Alerting <https://cloud.google.com/monitoring/alerts/>`__.
4242
4343
Attributes:
4444
name (str):
45-
Required if the policy exists. The resource name for this
46-
policy. The format is:
45+
Identifier. Required if the policy exists. The resource name
46+
for this policy. The format is:
4747
4848
::
4949
@@ -118,10 +118,10 @@ class AlertPolicy(proto.Message):
118118
unless a field projection has been specified
119119
that strips it out.
120120
validity (google.rpc.status_pb2.Status):
121-
Read-only description of how the alert policy
122-
is invalid. This field is only set when the
123-
alert policy is invalid. An invalid alert policy
124-
will not generate incidents.
121+
Read-only description of how the alerting
122+
policy is invalid. This field is only set when
123+
the alerting policy is invalid. An invalid
124+
alerting policy will not generate incidents.
125125
notification_channels (MutableSequence[str]):
126126
Identifies the notification channels to which notifications
127127
should be sent when incidents are opened or closed or when
@@ -146,10 +146,10 @@ class AlertPolicy(proto.Message):
146146
to the alerting policy. If provided in a call to
147147
create or update, this field will be ignored.
148148
alert_strategy (google.cloud.monitoring_v3.types.AlertPolicy.AlertStrategy):
149-
Control over how this alert policy's
149+
Control over how this alerting policy's
150150
notification channels are notified.
151151
severity (google.cloud.monitoring_v3.types.AlertPolicy.Severity):
152-
Optional. The severity of an alert policy
152+
Optional. The severity of an alerting policy
153153
indicates how important incidents generated by
154154
that policy are. The severity level will be
155155
displayed on the Incident detail page and in
@@ -183,8 +183,8 @@ class ConditionCombinerType(proto.Enum):
183183
AND_WITH_MATCHING_RESOURCE = 3
184184

185185
class Severity(proto.Enum):
186-
r"""An enumeration of possible severity level for an Alert
187-
Policy.
186+
r"""An enumeration of possible severity level for an alerting
187+
policy.
188188
189189
Values:
190190
SEVERITY_UNSPECIFIED (0):
@@ -220,7 +220,7 @@ class Documentation(proto.Message):
220220
characters and may not exceed more than 10,240 bytes when
221221
encoded in UTF-8 format, whichever is smaller. This text can
222222
be `templatized by using
223-
variables <https://cloud.google.com/monitoring/alerts/doc-variables>`__.
223+
variables <https://cloud.google.com/monitoring/alerts/doc-variables#doc-vars>`__.
224224
mime_type (str):
225225
The format of the ``content`` field. Presently, only the
226226
value ``"text/markdown"`` is supported. See
@@ -240,7 +240,7 @@ class Documentation(proto.Message):
240240
241241
The contents of the subject line can be `templatized by
242242
using
243-
variables <https://cloud.google.com/monitoring/alerts/doc-variables>`__.
243+
variables <https://cloud.google.com/monitoring/alerts/doc-variables#doc-vars>`__.
244244
If this field is missing or empty, a default subject line
245245
will be generated.
246246
links (MutableSequence[google.cloud.monitoring_v3.types.AlertPolicy.Documentation.Link]):
@@ -712,7 +712,7 @@ class LogMatch(proto.Message):
712712
)
713713

714714
class MonitoringQueryLanguageCondition(proto.Message):
715-
r"""A condition type that allows alert policies to be defined using
715+
r"""A condition type that allows alerting policies to be defined using
716716
`Monitoring Query
717717
Language <https://cloud.google.com/monitoring/mql>`__.
718718
@@ -770,7 +770,7 @@ class MonitoringQueryLanguageCondition(proto.Message):
770770
)
771771

772772
class PrometheusQueryLanguageCondition(proto.Message):
773-
r"""A condition type that allows alert policies to be defined using
773+
r"""A condition type that allows alerting policies to be defined using
774774
`Prometheus Query Language
775775
(PromQL) <https://prometheus.io/docs/prometheus/latest/querying/basics/>`__.
776776
@@ -831,7 +831,7 @@ class PrometheusQueryLanguageCondition(proto.Message):
831831
result. Label names `must be
832832
valid <https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels>`__.
833833
Label values can be `templatized by using
834-
variables <https://cloud.google.com/monitoring/alerts/doc-variables>`__.
834+
variables <https://cloud.google.com/monitoring/alerts/doc-variables#doc-vars>`__.
835835
The only available variable names are the names of the
836836
labels in the PromQL result, including "**name**" and
837837
"value". "labels" may be empty.
@@ -942,21 +942,41 @@ class AlertStrategy(proto.Message):
942942
943943
Attributes:
944944
notification_rate_limit (google.cloud.monitoring_v3.types.AlertPolicy.AlertStrategy.NotificationRateLimit):
945-
Required for alert policies with a ``LogMatch`` condition.
946-
947-
This limit is not implemented for alert policies that are
948-
not log-based.
945+
Required for log-based alerting policies, i.e. policies with
946+
a ``LogMatch`` condition.
947+
948+
This limit is not implemented for alerting policies that do
949+
not have a LogMatch condition.
950+
notification_prompts (MutableSequence[google.cloud.monitoring_v3.types.AlertPolicy.AlertStrategy.NotificationPrompt]):
951+
For log-based alert policies, the notification prompts is
952+
always [OPENED]. For non log-based alert policies, the
953+
notification prompts can be [OPENED] or [OPENED, CLOSED].
949954
auto_close (google.protobuf.duration_pb2.Duration):
950-
If an alert policy that was active has no
955+
If an alerting policy that was active has no
951956
data for this long, any open incidents will
952957
close
953958
notification_channel_strategy (MutableSequence[google.cloud.monitoring_v3.types.AlertPolicy.AlertStrategy.NotificationChannelStrategy]):
954959
Control how notifications will be sent out,
955960
on a per-channel basis.
956961
"""
957962

963+
class NotificationPrompt(proto.Enum):
964+
r"""Control when notifications will be sent out.
965+
966+
Values:
967+
NOTIFICATION_PROMPT_UNSPECIFIED (0):
968+
No strategy specified. Treated as error.
969+
OPENED (1):
970+
Notify when an incident is opened.
971+
CLOSED (3):
972+
Notify when an incident is closed.
973+
"""
974+
NOTIFICATION_PROMPT_UNSPECIFIED = 0
975+
OPENED = 1
976+
CLOSED = 3
977+
958978
class NotificationRateLimit(proto.Message):
959-
r"""Control over the rate of notifications sent to this alert
979+
r"""Control over the rate of notifications sent to this alerting
960980
policy's notification channels.
961981
962982
Attributes:
@@ -1008,6 +1028,13 @@ class NotificationChannelStrategy(proto.Message):
10081028
message="AlertPolicy.AlertStrategy.NotificationRateLimit",
10091029
)
10101030
)
1031+
notification_prompts: MutableSequence[
1032+
"AlertPolicy.AlertStrategy.NotificationPrompt"
1033+
] = proto.RepeatedField(
1034+
proto.ENUM,
1035+
number=2,
1036+
enum="AlertPolicy.AlertStrategy.NotificationPrompt",
1037+
)
10111038
auto_close: duration_pb2.Duration = proto.Field(
10121039
proto.MESSAGE,
10131040
number=3,

packages/google-cloud-monitoring/google/cloud/monitoring_v3/types/alert_service.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -110,27 +110,28 @@ class ListAlertPoliciesRequest(proto.Message):
110110
[GetAlertPolicy][google.monitoring.v3.AlertPolicyService.GetAlertPolicy]
111111
operation, instead.
112112
filter (str):
113-
If provided, this field specifies the criteria that must be
114-
met by alert policies to be included in the response.
113+
Optional. If provided, this field specifies the criteria
114+
that must be met by alert policies to be included in the
115+
response.
115116
116117
For more details, see `sorting and
117118
filtering <https://cloud.google.com/monitoring/api/v3/sorting-and-filtering>`__.
118119
order_by (str):
119-
A comma-separated list of fields by which to sort the
120-
result. Supports the same set of field references as the
120+
Optional. A comma-separated list of fields by which to sort
121+
the result. Supports the same set of field references as the
121122
``filter`` field. Entries can be prefixed with a minus sign
122123
to sort by the field in descending order.
123124
124125
For more details, see `sorting and
125126
filtering <https://cloud.google.com/monitoring/api/v3/sorting-and-filtering>`__.
126127
page_size (int):
127-
The maximum number of results to return in a
128-
single response.
128+
Optional. The maximum number of results to
129+
return in a single response.
129130
page_token (str):
130-
If this field is not empty then it must contain the
131-
``nextPageToken`` value returned by a previous call to this
132-
method. Using this field causes the method to return more
133-
results from the previous method call.
131+
Optional. If this field is not empty then it must contain
132+
the ``nextPageToken`` value returned by a previous call to
133+
this method. Using this field causes the method to return
134+
more results from the previous method call.
134135
"""
135136

136137
name: str = proto.Field(

packages/google-cloud-monitoring/google/cloud/monitoring_v3/types/notification.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ class NotificationChannel(proto.Message):
124124
[NotificationChannelDescriptor.type][google.monitoring.v3.NotificationChannelDescriptor.type]
125125
field.
126126
name (str):
127-
The full REST resource name for this channel. The format is:
127+
Identifier. The full REST resource name for this channel.
128+
The format is:
128129
129130
::
130131

0 commit comments

Comments
 (0)