Skip to content

feat: add ACLP list entities method#674

Open
shkaruna wants to merge 4 commits intolinode:devfrom
shkaruna:feat/aclp-list-entities
Open

feat: add ACLP list entities method#674
shkaruna wants to merge 4 commits intolinode:devfrom
shkaruna:feat/aclp-list-entities

Conversation

@shkaruna
Copy link
Copy Markdown
Contributor

@shkaruna shkaruna commented Mar 30, 2026

📝 Description

  1. Update ACLP monitor AlertDefinition struct. Add scope & region fields.
  2. Add entity envelope in AlertDefinition for GET, POST and PUT API responses.
"entities":` { // empty dict for region and account scope alert
"url":"/monitor/services/{service_type}/alert-definitions/{id}/entities",
  "count": integer,
 "has_more_resources": boolean
 }
  1. Add new method to list entities.
    API: GET /monitor/services/{service_type}/alert-definitions/{id}/entities

JIRA: 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:

  1. Run all unit tests:
    python -m pytest test/unit -q

  2. 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

@shkaruna shkaruna force-pushed the feat/aclp-list-entities branch from b632359 to 9e99b43 Compare March 30, 2026 06:32
@shkaruna
Copy link
Copy Markdown
Contributor Author

@satkumar-akamai : Please review

@shkaruna shkaruna force-pushed the feat/aclp-list-entities branch 2 times, most recently from a7817d8 to 5f6f266 Compare April 6, 2026 09:32
@shkaruna shkaruna marked this pull request as ready for review April 7, 2026 06:55
@shkaruna shkaruna requested review from a team as code owners April 7, 2026 06:55
@shkaruna shkaruna requested review from mawilk90 and mgwoj and removed request for a team April 7, 2026 06:55
@mgwoj mgwoj requested a review from Copilot April 7, 2026 10:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 an entities envelope to the AlertDefinition object model (plus new helper JSONObjects/enums).
  • Added MonitorGroup.alert_definition_entities() for GET /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.objects re-exports symbols from linode_api4/objects/monitor.py via from .monitor import *. Removing Alert and Alerts from __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 deprecated Alerts wrapper 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
mgwoj previously approved these changes Apr 7, 2026
Copy link
Copy Markdown
Contributor

@mgwoj mgwoj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two comments from CoPilot which should be addressed.

@shkaruna shkaruna force-pushed the feat/aclp-list-entities branch 2 times, most recently from 299403d to 7651564 Compare April 7, 2026 12:18
@yec-akamai yec-akamai added community-contribution for contributions made by a non-DX author new-feature for new features in the changelog. labels Apr 7, 2026
Copy link
Copy Markdown
Contributor

@yec-akamai yec-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good just some small comments. will run integration test once it's in prod

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@shkaruna shkaruna force-pushed the feat/aclp-list-entities branch from 4d93042 to d590d12 Compare April 8, 2026 08:41
mgwoj
mgwoj previously approved these changes Apr 8, 2026
shkaruna added 2 commits April 8, 2026 22:28
Add entities envelope in AlertDefinition. Add list entities GET API method. Add tests.
@shkaruna shkaruna force-pushed the feat/aclp-list-entities branch from fc8a622 to 5ee602c Compare April 8, 2026 17:00
"entity_ids": Property(mutable=True),
"entity_ids": Property(
mutable=True
), # Deprecated; use entities.url to fetch associated entities
Copy link
Copy Markdown
Contributor

@yec-akamai yec-akamai Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we still use entity_ids as a request body parameter for create and update right? We should keep this field

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I have removed the comment

@shkaruna shkaruna force-pushed the feat/aclp-list-entities branch from 9a109c1 to d671e08 Compare April 9, 2026 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution for contributions made by a non-DX author new-feature for new features in the changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants