8000 feat: [google-cloud-monitoring] Added support for severity in AlertPo… · googleapis/google-cloud-python@4e817f8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4e817f8

Browse files
feat: [google-cloud-monitoring] Added support for severity in AlertPolicy (#12110)
BEGIN_COMMIT_OVERRIDE feat: Added support for severity in AlertPolicy docs: add value range to comment on field forecast_horizon END_COMMIT_OVERRIDE - [ ] Regenerate this pull request now. docs: add value range to comment on field forecast_horizon PiperOrigin-RevId: 589949568 Source-Link: googleapis/googleapis@54bc5b6 Source-Link: googleapis/googleapis-gen@5284b32 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW1vbml0b3JpbmcvLk93bEJvdC55YW1sIiwiaCI6IjUyODRiMzIzODMwYjE1YTc5YjRiZjI3OTliYThkODNiZDEwMTNjNmEifQ== --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: ohmayr <omairnaveed@ymail.com>
1 parent 94e63cb commit 4e817f8

File tree

5 files changed

+55
-4
lines changed

5 files changed

+55
-4
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.17.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.17.0" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

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

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ class AlertPolicy(proto.Message):
148148
alert_strategy (google.cloud.monitoring_v3.types.AlertPolicy.AlertStrategy):
149149
Control over how this alert policy's
150150
notification channels are notified.
151+
severity (google.cloud.monitoring_v3.types.AlertPolicy.Severity):
152+
Optional. The severity of an alert policy
153+
indicates how important incidents generated by
154+
that policy are. The severity level will be
155+
displayed on the Incident detail page and in
156+
notifications.
151157
"""
152158

153159
class ConditionCombinerType(proto.Enum):
@@ -176,6 +182,33 @@ class ConditionCombinerType(proto.Enum):
176182
OR = 2
177183
AND_WITH_MATCHING_RESOURCE = 3
178184

185+
class Severity(proto.Enum):
186+
r"""An enumeration of possible severity level for an Alert
187+
Policy.
188+
189+
Values:
190+
SEVERITY_UNSPECIFIED (0):
191+
No severity is specified. This is the default
192+
value.
193+
CRITICAL (1):
194+
This is the highest severity level. Use this
195+
if the problem could cause significant damage or
196+
downtime.
197+
ERROR (2):
198+
This is the medium severity level. Use this
199+
if the problem could cause minor damage or
200+
downtime.
201+
WARNING (3):
202+
This is the lowest severity level. Use this
203+
if the problem is not causing any damage or
204+
downtime, but could potentially lead to a
205+
problem in the future.
206+
"""
207+
SEVERITY_UNSPECIFIED = 0
208+
CRITICAL = 1
209+
ERROR = 2
210+
WARNING = 3
211+
179212
class Documentation(proto.Message):
180213
r"""A content string and a MIME type that describes the content
181214
string's format.
@@ -474,7 +507,8 @@ class ForecastOptions(proto.Message):
474507
predicted value is found to violate the threshold, and the
475508
violation is observed in all forecasts made for the
476509
configured ``duration``, then the time series is considered
477-
to be failing.
510+
to be failing. The forecast horizon can range from 1 hour to
511+
60 hours.
478512
"""
479513

480514
forecast_horizon: duration_pb2.Duration = proto.Field(
@@ -1008,6 +1042,11 @@ class NotificationChannelStrategy(proto.Message):
10081042
number=21,
10091043
message=AlertStrategy,
10101044
)
1045+
severity: Severity = proto.Field(
1046+
proto.ENUM,
1047+
number=22,
1048+
enum=Severity,
1049+
)
10111050

10121051

10131052
__all__ = tuple(sorted(__protobuf__.manifest))

packages/google-cloud-monitoring/samples/generated_samples/snippet_metadata_google.monitoring.v3.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"language": "PYTHON",
1010
"name": "google-cloud-monitoring",
11-
"version": "2.17.0"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

packages/google-cloud-monitoring/tests/unit/gapic/monitoring_v3/test_alert_policy_service.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,7 @@ def test_get_alert_policy(request_type, transport: str = "grpc"):
11831183
display_name="display_name_value",
11841184
combiner=alert.AlertPolicy.ConditionCombinerType.AND,
11851185
notification_channels=["notification_channels_value"],
1186+
severity=alert.AlertPolicy.Severity.CRITICAL,
11861187
)
11871188
response = client.get_alert_policy(request)
11881189

@@ -1197,6 +1198,7 @@ def test_get_alert_policy(request_type, transport: str = "grpc"):
11971198
assert response.display_name == "display_name_value"
11981199
assert response.combiner == alert.AlertPolicy.ConditionCombinerType.AND
11991200
assert response.notification_channels == ["notification_channels_value"]
1201+
assert response.severity == alert.AlertPolicy.Severity.CRITICAL
12001202

12011203

12021204
def test_get_alert_policy_empty_call():
@@ -1237,6 +1239,7 @@ async def test_get_alert_policy_async(
12371239
display_name="display_name_value",
12381240
combiner=alert.AlertPolicy.ConditionCombinerType.AND,
12391241
notification_channels=["notification_channels_value"],
1242+
severity=alert.AlertPolicy.Severity.CRITICAL,
12401243
)
12411244
)
12421245
response = await client.get_alert_policy(request)
@@ -1252,6 +1255,7 @@ async def test_get_alert_policy_async(
12521255
assert response.display_name == "display_name_value"
12531256
assert response.combiner == alert.AlertPolicy.ConditionCombinerType.AND
12541257
assert response.notification_channels == ["notification_channels_value"]
1258+
assert response.severity == alert.AlertPolicy.Severity.CRITICAL
12551259

12561260

12571261
@pytest.mark.asyncio
@@ -1425,6 +1429,7 @@ def test_create_alert_policy(request_type, transport: str = "grpc"):
14251429
display_name="display_name_value",
14261430
combiner=alert.AlertPolicy.ConditionCombinerType.AND,
14271431
notification_channels=["notification_channels_value"],
1432+
severity=alert.AlertPolicy.Severity.CRITICAL,
14281433
)
14291434
response = client.create_alert_policy(request)
14301435

@@ -1439,6 +1444,7 @@ def test_create_alert_policy(request_type, transport: str = "grpc"):
14391444
assert response.display_name == "display_name_value"
14401445
assert response.combiner == alert.AlertPolicy.ConditionCombinerType.AND
14411446
assert response.notification_channels == ["notification_channels_value"]
1447+
assert response.severity == alert.AlertPolicy.Severity.CRITICAL
14421448

14431449

14441450
def test_create_alert_policy_empty_call():
@@ -1483,6 +1489,7 @@ async def test_create_alert_policy_async(
14831489
display_name="display_name_value",
14841490
combiner=alert.AlertPolicy.ConditionCombinerType.AND,
14851491
notification_channels=["notification_channels_value"],
1492+
severity=alert.AlertPolicy.Severity.CRITICAL,
14861493
)
14871494
)
14881495
response = await client.create_alert_policy(request)
@@ -1498,6 +1505,7 @@ async def test_create_alert_policy_async(
14981505
assert response.display_name == "display_name_value"
14991506
assert response.combiner == alert.AlertPolicy.ConditionCombinerType.AND
15001507
assert response.notification_channels == ["notification_channels_value"]
1508+
assert response.severity == alert.AlertPolicy.Severity.CRITICAL
15011509

15021510

15031511
@pytest.mark.asyncio
@@ -1923,6 +1931,7 @@ def test_update_alert_policy(request_type, transport: str = "grpc"):
19231931
display_name="display_name_value",
19241932
combiner=alert.AlertPolicy.ConditionCombinerType.AND,
19251933
notification_channels=["notification_channels_value"],
1934+
severity=alert.AlertPolicy.Severity.CRITICAL,
19261935
)
19271936
response = client.update_alert_policy(request)
19281937

@@ -1937,6 +1946,7 @@ def test_update_alert_policy(request_type, transport: str = "grpc"):
19371946
assert response.display_name == "display_name_value"
19381947
assert response.combiner == alert.AlertPolicy.ConditionCombinerType.AND
19391948
assert response.notification_channels == ["notification_channels_value"]
1949+
assert response.severity == alert.AlertPolicy.Severity.CRITICAL
19401950

19411951

19421952
def test_update_alert_policy_empty_call():
@@ -1981,6 +1991,7 @@ async def test_update_alert_policy_async(
19811991
display_name="display_name_value",
19821992
combiner=alert.AlertPolicy.ConditionCombinerType.AND,
19831993
notification_channels=["notification_channels_value"],
1994+
severity=alert.AlertPolicy.Severity.CRITICAL,
19841995
)
19851996
)
19861997
response = await client.update_alert_policy(request)
@@ -1996,6 +2007,7 @@ async def test_update_alert_policy_async(
19962007
assert response.display_name == "display_name_value"
19972008
assert response.combiner == alert.AlertPolicy.ConditionCombinerType.AND
19982009
assert response.notification_channels == ["notification_channels_value"]
2010+
assert response.severity == alert.AlertPolicy.Severity.CRITICAL
19992011

20002012

20012013
@pytest.mark.asyncio

0 commit comments

Comments
 (0)
0