Skip to content

Commit

Permalink
feat: [google-cloud-monitoring] Added support for severity in AlertPo…
Browse files Browse the repository at this point in the history
…licy (#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>
  • Loading branch information
3 people committed Dec 12, 2023
1 parent 94e63cb commit 4e817f8
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.17.0" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.17.0" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ class AlertPolicy(proto.Message):
alert_strategy (google.cloud.monitoring_v3.types.AlertPolicy.AlertStrategy):
Control over how this alert policy's
notification channels are notified.
severity (google.cloud.monitoring_v3.types.AlertPolicy.Severity):
Optional. The severity of an alert policy
indicates how important incidents generated by
that policy are. The severity level will be
displayed on the Incident detail page and in
notifications.
"""

class ConditionCombinerType(proto.Enum):
Expand Down Expand Up @@ -176,6 +182,33 @@ class ConditionCombinerType(proto.Enum):
OR = 2
AND_WITH_MATCHING_RESOURCE = 3

class Severity(proto.Enum):
r"""An enumeration of possible severity level for an Alert
Policy.
Values:
SEVERITY_UNSPECIFIED (0):
No severity is specified. This is the default
value.
CRITICAL (1):
This is the highest severity level. Use this
if the problem could cause significant damage or
downtime.
ERROR (2):
This is the medium severity level. Use this
if the problem could cause minor damage or
downtime.
WARNING (3):
This is the lowest severity level. Use this
if the problem is not causing any damage or
downtime, but could potentially lead to a
problem in the future.
"""
SEVERITY_UNSPECIFIED = 0
CRITICAL = 1
ERROR = 2
WARNING = 3

class Documentation(proto.Message):
r"""A content string and a MIME type that describes the content
string's format.
Expand Down Expand Up @@ -474,7 +507,8 @@ class ForecastOptions(proto.Message):
predicted value is found to violate the threshold, and the
violation is observed in all forecasts made for the
configured ``duration``, then the time series is considered
to be failing.
to be failing. The forecast horizon can range from 1 hour to
60 hours.
"""

forecast_horizon: duration_pb2.Duration = proto.Field(
Expand Down Expand Up @@ -1008,6 +1042,11 @@ class NotificationChannelStrategy(proto.Message):
number=21,
message=AlertStrategy,
)
severity: Severity = proto.Field(
proto.ENUM,
number=22,
enum=Severity,
)


__all__ = tuple(sorted(__protobuf__.manifest))
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-monitoring",
"version": "2.17.0"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,7 @@ def test_get_alert_policy(request_type, transport: str = "grpc"):
display_name="display_name_value",
combiner=alert.AlertPolicy.ConditionCombinerType.AND,
notification_channels=["notification_channels_value"],
severity=alert.AlertPolicy.Severity.CRITICAL,
)
response = client.get_alert_policy(request)

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


def test_get_alert_policy_empty_call():
Expand Down Expand Up @@ -1237,6 +1239,7 @@ async def test_get_alert_policy_async(
display_name="display_name_value",
combiner=alert.AlertPolicy.ConditionCombinerType.AND,
notification_channels=["notification_channels_value"],
severity=alert.AlertPolicy.Severity.CRITICAL,
)
)
response = await client.get_alert_policy(request)
Expand All @@ -1252,6 +1255,7 @@ async def test_get_alert_policy_async(
assert response.display_name == "display_name_value"
assert response.combiner == alert.AlertPolicy.ConditionCombinerType.AND
assert response.notification_channels == ["notification_channels_value"]
assert response.severity == alert.AlertPolicy.Severity.CRITICAL


@pytest.mark.asyncio
Expand Down Expand Up @@ -1425,6 +1429,7 @@ def test_create_alert_policy(request_type, transport: str = "grpc"):
display_name="display_name_value",
combiner=alert.AlertPolicy.ConditionCombinerType.AND,
notification_channels=["notification_channels_value"],
severity=alert.AlertPolicy.Severity.CRITICAL,
)
response = client.create_alert_policy(request)

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


def test_create_alert_policy_empty_call():
Expand Down Expand Up @@ -1483,6 +1489,7 @@ async def test_create_alert_policy_async(
display_name="display_name_value",
combiner=alert.AlertPolicy.ConditionCombinerType.AND,
notification_channels=["notification_channels_value"],
severity=alert.AlertPolicy.Severity.CRITICAL,
)
)
response = await client.create_alert_policy(request)
Expand All @@ -1498,6 +1505,7 @@ async def test_create_alert_policy_async(
assert response.display_name == "display_name_value"
assert response.combiner == alert.AlertPolicy.ConditionCombinerType.AND
assert response.notification_channels == ["notification_channels_value"]
assert response.severity == alert.AlertPolicy.Severity.CRITICAL


@pytest.mark.asyncio
Expand Down Expand Up @@ -1923,6 +1931,7 @@ def test_update_alert_policy(request_type, transport: str = "grpc"):
display_name="display_name_value",
combiner=alert.AlertPolicy.ConditionCombinerType.AND,
notification_channels=["notification_channels_value"],
severity=alert.AlertPolicy.Severity.CRITICAL,
)
response = client.update_alert_policy(request)

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


def test_update_alert_policy_empty_call():
Expand Down Expand Up @@ -1981,6 +1991,7 @@ async def test_update_alert_policy_async(
display_name="display_name_value",
combiner=alert.AlertPolicy.ConditionCombinerType.AND,
notification_channels=["notification_channels_value"],
severity=alert.AlertPolicy.Severity.CRITICAL,
)
)
response = await client.update_alert_policy(request)
Expand All @@ -1996,6 +2007,7 @@ async def test_update_alert_policy_async(
assert response.display_name == "display_name_value"
assert response.combiner == alert.AlertPolicy.ConditionCombinerType.AND
assert response.notification_channels == ["notification_channels_value"]
assert response.severity == alert.AlertPolicy.Severity.CRITICAL


@pytest.mark.asyncio
Expand Down

0 comments on commit 4e817f8

Please sign in to comment.