Skip to content

ACLP : Webhook alert channels - #732

Draft
mawasthy-lgtm wants to merge 14 commits into
linode:devfrom
mawasthy-lgtm:feat/add-webhook-channel
Draft

mawasthy-lgtm wants to merge 14 commits into
linode:devfrom
mawasthy-lgtm:feat/add-webhook-channel

Conversation

@mawasthy-lgtm

Copy link
Copy Markdown
Contributor

Updating python sdk to include webhook channel management api

What does this PR do and why is this change necessary?

Adds full SDK support for Webhook channel create, verify, delete requests used by tests and examples.

This change is necessary because:

The SDK did not have webhook channel management support added.

✔️ How to Test
Clone the repository
Prepare environment (zsh / macOS)

✔️create & activate venv (recommended)
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

✔️How do I run the relevant unit tests?
cd <PROJECT_DIRECTORY>/linode_api4-python
Unit tests: python -m pytest test/unit -q

Unit test for all monitor: python3 -m pytest test/unit/objects/monitor_test.py -q -s
python3 -m pytest test/unit/groups/monitor_api_test.py -q -s -v

Single unit: python3 -m pytest test/unit/objects/monitor_test.py::MonitorTest -q -s
python3 -m pytest test/unit/groups/monitor_api_test.py::MonitorAlertDefinitionsTest::test_create_verify_delete_webhook_channel -q -s -v

What are the steps to reproduce the issue or verify the changes?
End to end integration testing should suffice

✔️How do I run the relevant integration tests?
Integration tests (E2E):
Note:
#if you have PAT token with write access only to Monitor and read for rest of the services for integration
export SKIP_E2E_FIREWALL=1 # optional: skip firewall autouse fixture
export LINODE_TOKEN="YOUR_REAL_TOKEN" # required for integration
export SKIP_E2E_FIREWALL=1 # optional: skip firewall autouse fixture

python3 -m pytest test/integration/models/monitor/test_monitor.py::test_webhook_channel_crud -q -s

@mawasthy-lgtm
mawasthy-lgtm force-pushed the feat/add-webhook-channel branch from 20fdf94 to 5eea1dc Compare August 14, 2026 08:19
@mawasthy-lgtm
mawasthy-lgtm force-pushed the feat/add-webhook-channel branch from 5eea1dc to 92dbba3 Compare September 30, 2026 04:35
For deleting an alert channel, use the ``delete()`` method directly on the :class:`AlertChannel` object.
"""
if channel_type == "webhook":
self._validate_webhook_details(details)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

line 460-461 - channel_type validation is not required

"""
Verify that a webhook configuration can receive alert notifications.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-verify-webhook

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

return result.get("success", False)

@staticmethod
def _validate_webhook_details(details: ChannelDetails) -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

line 500 - 567 these validations are not required in sdk. Only the API call is enough. APInext code will take care of input validation


:raises ValueError: If the webhook configuration is invalid.
"""
self._validate_webhook_details(ChannelDetails(webhook=webhook))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can replace the implementation with below code. Please check

params = {
        "webhook": webhook.dict if isinstance(webhook, WebhookDetails) else webhook
    }

    return self.client.post(
        "/monitor/alert-channels/verify",
        data=params,
    )

"X-Trace-ID",
)

def test_webhook_channel_validation(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

these test cases can be removed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants