Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Clixon Python API Changelog

## Unreleased

### Features
* Transaction notification subscriptions now use an xpath filter
`select="controller-transaction"` so that progress notifications on the
unified `controller-transaction` stream are filtered out.
* This requires a clixon-controller where transaction progress and completion
share the `controller-transaction` stream.
* `rpc_subscription_create()` takes a new optional `select` argument.

## 1.9.0
6 October 2026

Expand Down
4 changes: 3 additions & 1 deletion clixon/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ def enable_transaction_notify(sock: socket, pp: bool) -> None:

"""

rpc = rpc_subscription_create("controller-transaction")
rpc = rpc_subscription_create(
"controller-transaction", select="controller-transaction"
)
send(sock, rpc, pp)
data = read(sock, pp)

Expand Down
3 changes: 2 additions & 1 deletion clixon/clixon.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@ def __enable_transaction_notify(self) -> None:
"""

enable_transaction_notify = rpc_subscription_create(
"controller-transaction", user=self.__user
"controller-transaction", user=self.__user,
select="controller-transaction"
)

send(self.__socket, enable_transaction_notify, pp)
Expand Down
10 changes: 8 additions & 2 deletions clixon/netconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,19 @@ def rpc_header_get(


def rpc_subscription_create(
stream: Optional[str] = "services-commit", user: Optional[str] = None
stream: Optional[str] = "services-commit",
user: Optional[str] = None,
select: Optional[str] = "",
) -> Element:
"""
Create a RPC subscription element.

:param stream: Stream name
:type stream: str
:param user: Username
:type user: str
:param select: XPath filter select, "" matches all notifications
:type select: str
:return: RPC element
:rtype: Element

Expand All @@ -335,7 +341,7 @@ def rpc_subscription_create(
root.rpc.create("create-subscription", attributes=attributes)
root.rpc.create_subscription.create("stream")
root.rpc.create_subscription.stream.cdata = stream
root.rpc.create_subscription.create("filter", {"type": "xpath", "select": ""})
root.rpc.create_subscription.create("filter", {"type": "xpath", "select": select})

return root

Expand Down
14 changes: 14 additions & 0 deletions tests/test_netconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ def test_rpc_subscription_create_user():
assert root.dumps() == xmlstr


def test_rpc_subscription_create_select():
"""
Test the rpc_subscription_create function with an xpath select filter.
"""

xmlstr = f"""<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" cl:username="{user}" xmlns:cl="http://clicon.org/lib" message-id="42"><create-subscription xmlns="urn:ietf:params:xml:ns:netmod:notification"><stream>controller-transaction</stream><filter type="xpath" select="controller-transaction"/></create-subscription></rpc>"""

root = netconf.rpc_subscription_create(
"controller-transaction", select="controller-transaction"
)

assert root.dumps() == xmlstr


def test_rpc_header_get():
"""
Test the rpc_header_get function.
Expand Down
Loading