Conversation
b632359 to
9e99b43
Compare
|
@satkumar-akamai : Please review |
a7817d8 to
5f6f266
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends the Monitor (ACLP) alert definition support by adding scope/regions fields, modeling the entities envelope on alert definition responses, and introducing a new SDK method to list entities associated with an alert definition.
Changes:
- Added
scope,regions, and anentitiesenvelope to theAlertDefinitionobject model (plus new helper JSONObjects/enums). - Added
MonitorGroup.alert_definition_entities()forGET /monitor/services/{service_type}/alert-definitions/{id}/entities. - Updated/added unit + integration tests and fixtures for the new response shapes and entity listing endpoint.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
linode_api4/objects/monitor.py |
Adds new alert-definition-related types (AlertScope, AlertEntities, AlertDefinitionEntity, etc.) and updates AlertDefinition fields to match new API response schema. |
linode_api4/groups/monitor.py |
Adds alert_definition_entities() method and extends create_alert_definition() to accept scope and regions. |
test/unit/groups/monitor_api_test.py |
Adds assertions for new AlertDefinition fields and adds a unit test for listing alert definition entities. |
test/integration/models/monitor/test_monitor.py |
Adds an integration test to list entities for an existing alert definition and validates returned entity fields. |
test/fixtures/monitor_*alert-definitions*.json |
Updates fixtures to include scope, regions, entities, and populated alert_channels. |
test/fixtures/monitor_services_dbaas_alert-definitions_12345_entities.json |
New fixture for the entities listing endpoint response. |
Comments suppressed due to low confidence (1)
linode_api4/objects/monitor.py:23
linode_api4.objectsre-exports symbols fromlinode_api4/objects/monitor.pyviafrom .monitor import *. RemovingAlertandAlertsfrom__all__(and renaming the underlying classes) is a backwards-incompatible change for SDK consumers who import these names. Consider keeping compatibility aliases (e.g.,Alert = AlertDefinitionChannel, and a deprecatedAlertswrapper if still needed) or otherwise preserving the old exports until a major release.
__all__ = [
"AggregateFunction",
"AlertChannel",
"AlertDefinition",
"AlertDefinitionChannel",
"AlertDefinitionEntity",
"AlertEntities",
"AlertScope",
"AlertType",
"MonitorDashboard",
"MonitorMetricsDefinition",
"MonitorService",
"MonitorServiceToken",
"RuleCriteria",
"TriggerConditions",
]
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mgwoj
left a comment
There was a problem hiding this comment.
There are two comments from CoPilot which should be addressed.
299403d to
7651564
Compare
yec-akamai
left a comment
There was a problem hiding this comment.
Overall looks good just some small comments. will run integration test once it's in prod
7651564 to
4d93042
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4d93042 to
d590d12
Compare
Add entities envelope in AlertDefinition. Add list entities GET API method. Add tests.
fc8a622 to
5ee602c
Compare
linode_api4/objects/monitor.py
Outdated
| "entity_ids": Property(mutable=True), | ||
| "entity_ids": Property( | ||
| mutable=True | ||
| ), # Deprecated; use entities.url to fetch associated entities |
There was a problem hiding this comment.
I think we still use entity_ids as a request body parameter for create and update right? We should keep this field
There was a problem hiding this comment.
yes, I have removed the comment
9a109c1 to
d671e08
Compare
…to feat/aclp-list-entities
📝 Description
API:
GET /monitor/services/{service_type}/alert-definitions/{id}/entitiesJIRA: DPS-41869
✔️ How to Test
What are the steps to reproduce the issue or verify the changes?
Not applicable
How do I run the relevant unit/integration tests?
Prerequisites:
Clone the repository
Prepare environment (zsh / macOS)
Create and activate venv:
python3 -m venv .venv
source .venv/bin/activate
install deps
python -m pip install --upgrade pip
Install runtime dependencies:
pip3 install requests polling deprecated
Install dev/test extras
pip3 install -e '.[dev,test]'
test deps
pip3 install pytest mock httpretty pytest-rerunfailures
Unit tests:
Run all unit tests:
python -m pytest test/unit -q
Run Monitor alert definition unit tests:
python -m pytest test/unit/groups/monitor_api_test.py -q -s -v
=============================================================== test session starts ================================================================
platform linux -- Python 3.10.12, pytest-9.0.2, pluggy-1.6.0
rootdir: /home/shkaruna/sdk/linode_api4-python
configfile: pyproject.toml
plugins: anyio-4.12.1, rerunfailures-16.1
collected 4 items
test/unit/groups/monitor_api_test.py ....
================================================================ 4 passed in 0.11s =================================================================
Integration tests:
Verified with Production & devcloud PAT.
python -m pytest test/integration/models/monitor/test_monitor.py::test_alert_definition_entities -q -s
.
1 passed in 9.17s
python -m pytest test/integration/models/monitor/test_monitor.py::test_integration_create_get_update_delete_alert_definition -q -s
.
1 passed in 38.48s