Skip to content

Commit 8854f6c

Browse files
samuel-gauthierrjarry
authored andcommitted
session: implement discard_items
This can be used to discard all the changes made by a session in the operational datastore. Signed-off-by: Samuel Gauthier <[email protected]>
1 parent 2e026a5 commit 8854f6c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cffi/cdefs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ void sr_release_data(sr_data_t *);
188188
int sr_rpc_send_tree(sr_session_ctx_t *, struct lyd_node *, uint32_t, sr_data_t **);
189189

190190
int sr_set_item_str(sr_session_ctx_t *, const char *, const char *, const char *, const sr_edit_options_t);
191+
int sr_discard_items(sr_session_ctx_t *, const char *);
191192
int sr_delete_item(sr_session_ctx_t *, const char *, const sr_edit_options_t);
192193
int sr_oper_delete_item_str(sr_session_ctx_t *, const char *, const char *, const sr_edit_options_t);
193194
int sr_edit_batch(sr_session_ctx_t *, const struct lyd_node *, const char *);

sysrepo/session.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,18 @@ def set_item(self, xpath: str, value: Any = None) -> None:
11591159
lib.sr_set_item_str, self.cdata, str2c(xpath), str2c(value), ffi.NULL, 0
11601160
)
11611161

1162+
def discard_items(self, xpath: str) -> None:
1163+
"""
1164+
Prepare to discard nodes matching the specified xpath (or all if not
1165+
set) previously set by the session connection. Usable only for the
1166+
operational datastore . These changes are applied only after calling
1167+
apply_changes().
1168+
1169+
:arg xpath:
1170+
Path identifier of the data element to be deleted.
1171+
"""
1172+
check_call(lib.sr_discard_items, self.cdata, str2c(xpath))
1173+
11621174
def delete_item(self, xpath: str) -> None:
11631175
"""
11641176
Prepare to delete the nodes matching the specified xpath. These changes

0 commit comments

Comments
 (0)