sysrepo
1.4.168
YANG datastore
|
Typedefs | |
typedef enum sr_event_e | sr_event_t |
Type of the event that has occurred (passed to application callbacks). More... | |
typedef enum sr_change_oper_e | sr_change_oper_t |
Type of the operation made on an item, used by changeset retrieval in sr_get_change_next. More... | |
typedef struct sr_change_iter_s | sr_change_iter_t |
Iterator used for retrieval of a changeset using sr_get_changes_iter call. More... | |
typedef int(* | sr_module_change_cb )(sr_session_ctx_t *session, const char *module_name, const char *xpath, sr_event_t event, uint32_t request_id, void *private_data) |
Callback to be called on the event of changing datastore content of the specified module. More... | |
Enumerations | |
enum | sr_event_e { SR_EV_UPDATE, SR_EV_CHANGE, SR_EV_DONE, SR_EV_ABORT, SR_EV_ENABLED, SR_EV_RPC } |
Type of the event that has occurred (passed to application callbacks). More... | |
enum | sr_change_oper_e { SR_OP_CREATED, SR_OP_MODIFIED, SR_OP_DELETED, SR_OP_MOVED } |
Type of the operation made on an item, used by changeset retrieval in sr_get_change_next. More... | |
Functions | |
int | sr_module_change_subscribe (sr_session_ctx_t *session, const char *module_name, const char *xpath, sr_module_change_cb callback, void *private_data, uint32_t priority, sr_subscr_options_t opts, sr_subscription_ctx_t **subscription) |
Subscribe for changes made in the specified module. If there are changes made in several modules, the module order is determined by the order in the changes (it is kept). More... | |
int | sr_get_changes_iter (sr_session_ctx_t *session, const char *xpath, sr_change_iter_t **iter) |
Create an iterator for retrieving the changes (list of newly added / removed / modified nodes) in module-change callbacks. It cannot be used outside the callback. More... | |
int | sr_dup_changes_iter (sr_session_ctx_t *session, const char *xpath, sr_change_iter_t **iter) |
Create an iterator for retrieving the changes (list of newly added / removed / modified nodes) in module-change callbacks. It can be used even outside the callback. More... | |
int | sr_get_change_next (sr_session_ctx_t *session, sr_change_iter_t *iter, sr_change_oper_t *operation, sr_val_t **old_value, sr_val_t **new_value) |
Return the next change from the provided iterator created by sr_get_changes_iter call. Data are represented as sr_val_t structures. More... | |
int | sr_get_change_tree_next (sr_session_ctx_t *session, sr_change_iter_t *iter, sr_change_oper_t *operation, const struct lyd_node **node, const char **prev_value, const char **prev_list, bool *prev_dflt) |
Returns the next change from the provided iterator created by sr_get_changes_iter call. Data are represented as libyang subtrees. More... | |
void | sr_free_change_iter (sr_change_iter_t *iter) |
Frees sr_change_iter_t iterator and all memory allocated within it. More... | |
typedef enum sr_event_e sr_event_t |
Type of the event that has occurred (passed to application callbacks).
typedef enum sr_change_oper_e sr_change_oper_t |
Type of the operation made on an item, used by changeset retrieval in sr_get_change_next.
typedef struct sr_change_iter_s sr_change_iter_t |
Iterator used for retrieval of a changeset using sr_get_changes_iter call.
typedef int(* sr_module_change_cb)(sr_session_ctx_t *session, const char *module_name, const char *xpath, sr_event_t event, uint32_t request_id, void *private_data) |
Callback to be called on the event of changing datastore content of the specified module.
[in] | session | Implicit session (do not stop) with information about the changed data (retrieved by sr_get_changes_iter) and the event originator session IDs. |
[in] | module_name | Name of the module where the change has occurred. |
[in] | xpath | XPath used when subscribing, NULL if the whole module was subscribed to. |
[in] | event | Type of the callback event that has occurred. |
[in] | request_id | Request ID unique for the specific module_name . Connected events for one request (SR_EV_CHANGE and SR_EV_DONE, for example) have the same request ID. |
[in] | private_data | Private context opaque to sysrepo, as passed to sr_module_change_subscribe call. |
enum sr_event_e |
Type of the event that has occurred (passed to application callbacks).
Enumerator | |
---|---|
SR_EV_UPDATE |
Occurs before any other events and the subscriber can update the apply-changes diff. It is performed by calling |
SR_EV_CHANGE |
Occurs just before the changes are committed to the datastore, the subscriber is supposed to verify that the changes are valid and can be applied and prepare all resources required for the changes. The subscriber can still deny the changes in this phase by returning an error from the callback. |
SR_EV_DONE |
Occurs just after the changes have been successfully committed to the datastore, the subscriber can apply the changes now, but it cannot deny the changes in this phase anymore (any returned errors are just logged and ignored). |
SR_EV_ABORT |
Occurs in case that the commit transaction has failed because one of the verifiers has denied the change (returned an error). The subscriber is supposed to return the managed application to the state before the commit. Any returned errors are just logged and ignored. This event is also generated for RPC subscriptions when a later callback has failed and this one has already successfully processed SR_EV_RPC. The callback that failed will never get this event! |
SR_EV_ENABLED |
Occurs for subscriptions with the flag SR_SUBSCR_ENABLED and is normally followed by SR_EV_DONE. It can fail and will also be triggered even when there is no startup configuration (which is different from the SR_EV_CHANGE event). Also note that the callback on this event cannot return SR_ERR_CALLBACK_SHELVE. |
SR_EV_RPC |
Occurs for a standard RPC execution. If a later callback fails, SR_EV_ABORT is generated. |
enum sr_change_oper_e |
Type of the operation made on an item, used by changeset retrieval in sr_get_change_next.
int sr_module_change_subscribe | ( | sr_session_ctx_t * | session, |
const char * | module_name, | ||
const char * | xpath, | ||
sr_module_change_cb | callback, | ||
void * | private_data, | ||
uint32_t | priority, | ||
sr_subscr_options_t | opts, | ||
sr_subscription_ctx_t ** | subscription | ||
) |
Subscribe for changes made in the specified module. If there are changes made in several modules, the module order is determined by the order in the changes (it is kept).
Required WRITE access. If SR_SUBSCR_PASSIVE is set, required READ access.
[in] | session | Session (DS-specific) to use. |
[in] | module_name | Name of the module of interest for change notifications. |
[in] | xpath | Optional XPath further filtering the changes that will be handled by this subscription. |
[in] | callback | Callback to be called when the change in the datastore occurs. |
[in] | private_data | Private context passed to the callback function, opaque to sysrepo. |
[in] | priority | Specifies the order in which the callbacks (within module) will be called. |
[in] | opts | Options overriding default behavior of the subscription, it is supposed to be a bitwise OR-ed value of any sr_subscr_flag_t flags. |
[in,out] | subscription | Subscription context that is supposed to be released by sr_unsubscribe. |
int sr_get_changes_iter | ( | sr_session_ctx_t * | session, |
const char * | xpath, | ||
sr_change_iter_t ** | iter | ||
) |
Create an iterator for retrieving the changes (list of newly added / removed / modified nodes) in module-change callbacks. It cannot be used outside the callback.
[in] | session | Implicit session provided in the callbacks (sr_module_change_cb). Will not work with other sessions. |
[in] | xpath | XPath selecting the changes. Note that you must select all the changes specifically, not just subtrees (to get a full change subtree //. can be appended to the XPath)! Also note that if you use an XPath that selects more changes than subscribed to, you may actually get them because all the changes of a module are available in every callback! |
[out] | iter | Iterator context that can be used to retrieve individual changes using sr_get_change_next calls. Allocated by the function, should be freed with sr_free_change_iter. |
int sr_dup_changes_iter | ( | sr_session_ctx_t * | session, |
const char * | xpath, | ||
sr_change_iter_t ** | iter | ||
) |
Create an iterator for retrieving the changes (list of newly added / removed / modified nodes) in module-change callbacks. It can be used even outside the callback.
[in] | session | Implicit session provided in the callbacks (sr_module_change_cb). Will not work with other sessions. |
[in] | xpath | XPath selecting the changes. Note that you must select all the changes specifically, not just subtrees (to get a full change subtree //. can be appended to the XPath)! Also note that if you use an XPath that selects more changes than subscribed to, you may actually get them because all the changes of a module are available in every callback! |
[out] | iter | Iterator context that can be used to retrieve individual changes using sr_get_change_next calls. Allocated by the function, should be freed with sr_free_change_iter. |
int sr_get_change_next | ( | sr_session_ctx_t * | session, |
sr_change_iter_t * | iter, | ||
sr_change_oper_t * | operation, | ||
sr_val_t ** | old_value, | ||
sr_val_t ** | new_value | ||
) |
Return the next change from the provided iterator created by sr_get_changes_iter call. Data are represented as sr_val_t structures.
[in] | session | Implicit session provided in the callbacks (sr_module_change_cb). Will not work with other sessions. |
[in,out] | iter | Iterator acquired with sr_get_changes_iter call. |
[out] | operation | Type of the operation made on the returned item. |
[out] | old_value | Old value of the item (the value before the change). NULL in case that the item has been just created (operation SR_OP_CREATED). |
[out] | new_value | New (modified) value of the the item. NULL in case that the item has been just deleted (operation SR_OP_DELETED). |
int sr_get_change_tree_next | ( | sr_session_ctx_t * | session, |
sr_change_iter_t * | iter, | ||
sr_change_oper_t * | operation, | ||
const struct lyd_node ** | node, | ||
const char ** | prev_value, | ||
const char ** | prev_list, | ||
bool * | prev_dflt | ||
) |
Returns the next change from the provided iterator created by sr_get_changes_iter call. Data are represented as libyang subtrees.
node
is the created node, for user-ordered lists either prev_value
or prev_list
is always set with meaning similar to SR_OP_MOVED. SR_OP_MODIFIED - node
is the modified node, prev_value
is set to the previous value of the leaf, prev_dflt
is set if the previous leaf value was the default. SR_OP_DELETED - node
is the deleted node. SR_OP_MOVED - node
is the moved (leaf-)list instance, for user-ordered lists either prev_value
(leaf-list) or prev_list
(list) is set to the preceding instance unless the node is the first, when they are set to "" (empty string).[in] | session | Implicit session provided in the callbacks (sr_module_change_cb). Will not work with other sessions. |
[in,out] | iter | Iterator acquired with sr_get_changes_iter call. |
[out] | operation | Type of the operation made on the returned item. |
[out] | node | Affected data node always with all parents, depends on the operation. |
[out] | prev_value | Previous value, depends on the operation. |
[out] | prev_list | Previous list keys predicate ([key1="val1"][key2="val2"]... ), depends on the operation. |
[out] | prev_dflt | Previous value default flag, depends on the operation. |
void sr_free_change_iter | ( | sr_change_iter_t * | iter | ) |
Frees sr_change_iter_t iterator and all memory allocated within it.
[in] | iter | Iterator to be freed. |