Skip to content

Adding create channel api changes to python SDK#709

Draft
mawasthy-lgtm wants to merge 3 commits into
linode:devfrom
mawasthy-lgtm:feat/add-create-alert-channel
Draft

Adding create channel api changes to python SDK#709
mawasthy-lgtm wants to merge 3 commits into
linode:devfrom
mawasthy-lgtm:feat/add-create-alert-channel

Conversation

@mawasthy-lgtm

@mawasthy-lgtm mawasthy-lgtm commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

📝 Description

Updating python sdk to include create channel management api

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

Adds full SDK support for Creating a new channel (post request) used by tests and examples.
Ensures create channel fields are parsed and exposed as per the latest API response.

This change is necessary because:

The SDK did not have channel management api 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_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_integration_create_get_delete_alert_channel -q -s

Comment on lines +350 to +365
Example usage::

def streams(self, *filters) -> PaginatedList:
"""
List available logs streams.
from linode_api4.objects.monitor import ChannelDetails, EmailDetails

Returns a paginated collection of :class:`LogsStream` objects which
describe logs streams. By default, this method returns all available
streams; you can supply optional filter expressions to restrict
the results, for example::
client = LinodeClient(TOKEN)

# Get all streams with status ``provisioning``
provisioning_streams = client.monitor.streams(LogsStream.status == "provisioning")
new_channel = client.monitor.channel_create(
label="Email channel for api change",
channel_type="email",
details=ChannelDetails(
email=EmailDetails(
recipient_type="user",
usernames=["username-test"],
)
),
)

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.

This example usage may not be required

)

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-streams
API Documentation: https://techdocs.akamai.com/linode-api/reference/post-alert-channel

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.

:type label: str
:param channel_type: The type of notification channel (e.g. ``"email"``).
:type channel_type: str
:param details: Notification-type-specific configuration. Use

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.

Even here usage may not be required


API Documentation: https://techdocs.akamai.com/linode-api/reference/get-notification-channels
API Documentation:
List/Get: https://techdocs.akamai.com/linode-api/reference/get-alert-channels

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.

GET: https://techdocs.akamai.com/linode-api/reference/get-notification-channel

This class will be used for response contract. Single response object.

"id": Property(identifier=True),
"label": Property(),
"label": Property(mutable=True),
"type": Property(),

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.

We can define enum Type for user & system values

details=ChannelDetails(
email=EmailDetails(
recipient_type="user",
usernames=["mawasthy_tenant02_admin"],

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.

Instead of using actual usernames we can use API to list users and use the usernames from the response of it.

https://techdocs.akamai.com/linode-api/reference/get-users

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