sysrepo
3.0.0
YANG-based system repository for all-around configuration management.
|
Functions | |
int | sr_apply_changes (sr_session_ctx_t *session, uint32_t timeout_ms) |
Apply changes made in the current session. In case the changes could not be applied successfully for any reason, they remain intact in the session. More... | |
int | sr_copy_config (sr_session_ctx_t *session, const char *module_name, sr_datastore_t src_datastore, uint32_t timeout_ms) |
Replaces a conventional datastore with the contents of another conventional datastore. If the module is specified, limits the operation only to the specified module. If it is not specified, the operation is performed on all modules. More... | |
int | sr_delete_item (sr_session_ctx_t *session, const char *path, const sr_edit_options_t opts) |
Prepare to delete the nodes matching the specified xpath. These changes are applied only after calling sr_apply_changes(). The accepted values are the same as for sr_set_item_str. More... | |
int | sr_discard_changes (sr_session_ctx_t *session) |
Discard prepared changes made in the current session. More... | |
int | sr_discard_items (sr_session_ctx_t *session, const char *xpath) |
Prepare to discard nodes matching the specified xpath (or all if not set) previously set by the session connection. Usable only for SR_DS_OPERATIONAL datastore. These changes are applied only after calling sr_apply_changes(). More... | |
int | sr_discard_oper_changes (sr_conn_ctx_t *conn, sr_session_ctx_t *session, const char *module_name, uint32_t timeout_ms) |
Discard push operational changes of a module for a session. More... | |
int | sr_edit_batch (sr_session_ctx_t *session, const struct lyd_node *edit, const char *default_operation) |
Provide a prepared edit data tree to be applied. These changes are applied only after calling sr_apply_changes(). More... | |
struct lyd_node * | sr_get_changes (sr_session_ctx_t *session) |
Retrieve stored changes (prepared, not yet applied). More... | |
int | sr_get_oper_changes (sr_session_ctx_t *session, const char *module_name, sr_data_t **data) |
Get stored push operational changes of a session. More... | |
int | sr_get_oper_changes_order (sr_session_ctx_t *session, const char *module_name, uint32_t *order) |
Get push operational changes order determining when they are applied relative to other sessions for the module. More... | |
int | sr_has_changes (sr_session_ctx_t *session) |
Learn whether there are any prepared non-applied changes in the session. More... | |
int | sr_move_item (sr_session_ctx_t *session, const char *path, const sr_move_position_t position, const char *list_keys, const char *leaflist_value, const char *origin, const sr_edit_options_t opts) |
Prepare to move/create the instance of an user-ordered list or leaf-list to the specified position. These changes are applied only after calling sr_apply_changes(). More... | |
int | sr_oper_delete_item_str (sr_session_ctx_t *session, const char *path, const char *value, const sr_edit_options_t opts) |
Deprecated, not supported. More... | |
int | sr_replace_config (sr_session_ctx_t *session, const char *module_name, struct lyd_node *src_config, uint32_t timeout_ms) |
Replace a datastore with the contents of a data tree. If the module is specified, limit the operation only to the specified module. If it is not specified, the operation is performed on all modules. More... | |
int | sr_set_item (sr_session_ctx_t *session, const char *path, const sr_val_t *value, const sr_edit_options_t opts) |
Prepare to set (create) the value of a leaf, leaf-list, list, or presence container. These changes are applied only after calling sr_apply_changes(). Data are represented as sr_val_t structures. More... | |
int | sr_set_item_str (sr_session_ctx_t *session, const char *path, const char *value, const char *origin, const sr_edit_options_t opts) |
Prepare to set (create) the value of a leaf, leaf-list, list, or presence container. These changes are applied only after calling sr_apply_changes(). Data are represented as pairs of a path and string value. More... | |
int | sr_set_oper_changes_order (sr_session_ctx_t *session, const char *module_name, uint32_t order) |
Set explicit push operational changes order determining when they are applied relative to other sessions for the module. More... | |
int | sr_validate (sr_session_ctx_t *session, const char *module_name, uint32_t timeout_ms) |
Perform the validation a datastore and any changes made in the current session, but do not apply nor discard them. More... | |
enum | sr_edit_flag_t { SR_EDIT_DEFAULT = 0x0, SR_EDIT_NON_RECURSIVE = 0x1, SR_EDIT_STRICT = 0x2, SR_EDIT_ISOLATE = 0x4 } |
Flags used to override default behavior of data manipulation calls. More... | |
enum | sr_move_position_t { SR_MOVE_BEFORE = 0, SR_MOVE_AFTER = 1, SR_MOVE_FIRST = 2, SR_MOVE_LAST = 3 } |
Options for specifying move direction of sr_move_item call. More... | |
typedef uint32_t | sr_edit_options_t |
Options overriding default behavior of data manipulation calls, it is supposed to be bitwise OR-ed value of any sr_edit_flag_t flags. More... | |
typedef uint32_t sr_edit_options_t |
Options overriding default behavior of data manipulation calls, it is supposed to be bitwise OR-ed value of any sr_edit_flag_t flags.
Definition at line 356 of file sysrepo_types.h.
enum sr_edit_flag_t |
Flags used to override default behavior of data manipulation calls.
Enumerator | |
---|---|
SR_EDIT_DEFAULT |
Default behavior - non-strict. |
SR_EDIT_NON_RECURSIVE |
Non-recursive behavior: by sr_set_item, all preceding nodes (parents) of the identified element must exist. |
SR_EDIT_STRICT |
Strict behavior: by sr_set_item the identified element must not exist (similar to NETCONF create operation), by sr_delete_item the identified element must exist (similar to NETCONF delete operation). |
SR_EDIT_ISOLATE |
Create new operation separately, independent of all the previous operations. Since all the operations are concatenated into one edit tree, it may happen that 2 incompatible operations are set and an error is observed. This flag can in those cases be used. Also, if an error is returned the previous edit is always left untouched. |
Definition at line 339 of file sysrepo_types.h.
enum sr_move_position_t |
Options for specifying move direction of sr_move_item call.
Definition at line 361 of file sysrepo_types.h.
int sr_apply_changes | ( | sr_session_ctx_t * | session, |
uint32_t | timeout_ms | ||
) |
Apply changes made in the current session. In case the changes could not be applied successfully for any reason, they remain intact in the session.
Required WRITE access.
[in] | session | Session (DS-specific) to apply changes of. |
[in] | timeout_ms | Change callback timeout in milliseconds. If 0, default is used. Note that this timeout is measured separately for each callback meaning this whole function call can easily take more time than this timeout if there are changes applied for several subscribers. |
int sr_copy_config | ( | sr_session_ctx_t * | session, |
const char * | module_name, | ||
sr_datastore_t | src_datastore, | ||
uint32_t | timeout_ms | ||
) |
Replaces a conventional datastore with the contents of another conventional datastore. If the module is specified, limits the operation only to the specified module. If it is not specified, the operation is performed on all modules.
Required WRITE access.
[in] | session | Session (DS-specific - target datastore) to use. |
[in] | module_name | Optional module name that limits the copy operation only to this module. |
[in] | src_datastore | Source datastore. |
[in] | timeout_ms | Configuration callback timeout in milliseconds. If 0, default is used. |
int sr_delete_item | ( | sr_session_ctx_t * | session, |
const char * | path, | ||
const sr_edit_options_t | opts | ||
) |
Prepare to delete the nodes matching the specified xpath. These changes are applied only after calling sr_apply_changes(). The accepted values are the same as for sr_set_item_str.
If SR_EDIT_STRICT flag is set the specified node must must exist in the datastore. If the path
includes the list keys/leaf-list value, the specified instance is deleted. If the path
of list/leaf-list does not include keys/value, all instances are deleted but there can be no further changes merged into the list, use SR_EDIT_ISOLATE in such a case.
Not supported for SR_DS_OPERATIONAL, use sr_discard_items() or sr_discard_oper_changes() instead.
[in] | session | Session (DS-specific) to use. |
[in] | path | Path identifier of the data element to be deleted. |
[in] | opts | Options overriding default behavior of this call. |
int sr_discard_changes | ( | sr_session_ctx_t * | session | ) |
int sr_discard_items | ( | sr_session_ctx_t * | session, |
const char * | xpath | ||
) |
Prepare to discard nodes matching the specified xpath (or all if not set) previously set by the session connection. Usable only for SR_DS_OPERATIONAL datastore. These changes are applied only after calling sr_apply_changes().
Creates an opaque node discard-items
in the sysrepo
YANG module namespace with xpath
used as the value. Such a node can be a part of the edit in sr_edit_batch() and will discard nodes like this function does.
[in] | session | Session (DS-specific) to use. |
[in] | xpath | XPath expression filtering the nodes to discard, all if NULL. |
int sr_discard_oper_changes | ( | sr_conn_ctx_t * | conn, |
sr_session_ctx_t * | session, | ||
const char * | module_name, | ||
uint32_t | timeout_ms | ||
) |
Discard push operational changes of a module for a session.
[in] | conn | Unused. |
[in] | session | Session (not DS-specific) to use. |
[in] | module_name | Optional module name that limits the operation only to this module. |
[in] | timeout_ms | Module change callback timeout in millisecond. If 0, default is used. |
int sr_edit_batch | ( | sr_session_ctx_t * | session, |
const struct lyd_node * | edit, | ||
const char * | default_operation | ||
) |
Provide a prepared edit data tree to be applied. These changes are applied only after calling sr_apply_changes().
Only top-level operations merge
and replace
are allowed for SR_DS_OPERATIONAL.
[in] | session | Session (DS-specific) to use. |
[in] | edit | Edit content, similar semantics to NETCONF <edit-config> content. Uses edit and all of its following siblings. |
[in] | default_operation | Default operation for nodes without operation on themselves or any parent. Possible values are merge , replace , or none (see NETCONF RFC). |
struct lyd_node* sr_get_changes | ( | sr_session_ctx_t * | session | ) |
Retrieve stored changes (prepared, not yet applied).
Note: as soon as the changes get applied or discarded, the return value becomes invalid.
[in] | session | Session (DS-specific) to retrieve changes from. |
int sr_get_oper_changes | ( | sr_session_ctx_t * | session, |
const char * | module_name, | ||
sr_data_t ** | data | ||
) |
Get stored push operational changes of a session.
[in] | session | Session (not DS-specific) to use. |
[in] | module_name | Optional module name that limits the operation only to this module. |
[out] | data | SR data with the stored push oper changes. NULL if none found. |
int sr_get_oper_changes_order | ( | sr_session_ctx_t * | session, |
const char * | module_name, | ||
uint32_t * | order | ||
) |
Get push operational changes order determining when they are applied relative to other sessions for the module.
[in] | session | Session (not DS-specific) to use. |
[in] | module_name | Name of the module to use. |
[out] | order | Non-zero push oper data order. 0 if there are no push oper data of the session for the module. |
int sr_has_changes | ( | sr_session_ctx_t * | session | ) |
Learn whether there are any prepared non-applied changes in the session.
[in] | session | Session (DS-specific) to check changes in. |
int sr_move_item | ( | sr_session_ctx_t * | session, |
const char * | path, | ||
const sr_move_position_t | position, | ||
const char * | list_keys, | ||
const char * | leaflist_value, | ||
const char * | origin, | ||
const sr_edit_options_t | opts | ||
) |
Prepare to move/create the instance of an user-ordered list or leaf-list to the specified position. These changes are applied only after calling sr_apply_changes().
Item can be moved to the first or last position or positioned relatively to its sibling.
With default options it recursively creates all missing nodes (containers and lists including their key leaves) in the xpath to the specified node (can be turned off with SR_EDIT_NON_RECURSIVE option). If SR_EDIT_STRICT flag is set, the node must not exist (otherwise an error is returned).
Not supported for SR_DS_OPERATIONAL.
[in] | session | Session (DS-specific) to use |
[in] | path | Path identifier of the data element to be moved. |
[in] | position | Requested move direction. |
[in] | list_keys | Predicate identifying the relative list instance (example input [key1="val1"][key2="val2"]... ). |
[in] | leaflist_value | Value of the relative leaf-list instance (example input val1 ) used to determine relative position, needed only if position argument is SR_MOVE_BEFORE or SR_MOVE_AFTER. |
[in] | origin | Origin of the value, used only for SR_DS_OPERATIONAL edits. Module ietf-origin is assumed if no prefix used. |
[in] | opts | Options overriding default behavior of this call. |
int sr_oper_delete_item_str | ( | sr_session_ctx_t * | session, |
const char * | path, | ||
const char * | value, | ||
const sr_edit_options_t | opts | ||
) |
Deprecated, not supported.
int sr_replace_config | ( | sr_session_ctx_t * | session, |
const char * | module_name, | ||
struct lyd_node * | src_config, | ||
uint32_t | timeout_ms | ||
) |
Replace a datastore with the contents of a data tree. If the module is specified, limit the operation only to the specified module. If it is not specified, the operation is performed on all modules.
Required WRITE access.
[in] | session | Session (DS-specific - target datastore) to use. |
[in] | module_name | If specified, limits the replace operation only to this module. |
[in] | src_config | Source data to replace the datastore in session connection libyang context. Is ALWAYS spent and cannot be further used by the application! |
[in] | timeout_ms | Configuration callback timeout in milliseconds. If 0, default is used. |
int sr_set_item | ( | sr_session_ctx_t * | session, |
const char * | path, | ||
const sr_val_t * | value, | ||
const sr_edit_options_t | opts | ||
) |
Prepare to set (create) the value of a leaf, leaf-list, list, or presence container. These changes are applied only after calling sr_apply_changes(). Data are represented as sr_val_t structures.
With default options it recursively creates all missing nodes (containers and lists including their key leaves) in the xpath to the specified node (can be turned off with SR_EDIT_NON_RECURSIVE option). If SR_EDIT_STRICT flag is set, the node must not exist (otherwise an error is returned). Neither option is allowed for SR_DS_OPERATIONAL.
To create a list use path
with key values included in predicates, value
will be ignored. When creating key-less lists and state leaf-lists, use positional predicates such as [1]
to refer to the instances. Using no predicate means the instance should be created.
The value of a leaf-list can be specified either by predicate in xpath or by value argument. If both are present, value argument is ignored and xpath predicate is used.
Edits preserve their order only if SR_EDIT_ISOLATE is used and in some cases it may affect the result.
[in] | session | Session (DS-specific) to use. |
[in] | path | Path identifier of the data element to be set. |
[in] | value | Value to be set. xpath member of the sr_val_t structure can be NULL. |
[in] | opts | Options overriding default behavior of this call. |
int sr_set_item_str | ( | sr_session_ctx_t * | session, |
const char * | path, | ||
const char * | value, | ||
const char * | origin, | ||
const sr_edit_options_t | opts | ||
) |
Prepare to set (create) the value of a leaf, leaf-list, list, or presence container. These changes are applied only after calling sr_apply_changes(). Data are represented as pairs of a path and string value.
Function provides the same functionality as sr_set_item().
[in] | session | Session (DS-specific) to use. |
[in] | path | Path identifier of the data element to be set. |
[in] | value | String representation of the value to be set. |
[in] | origin | Origin of the value, used only for SR_DS_OPERATIONAL edits. Module 'ietf-origin' is assumed if no prefix used. |
[in] | opts | Options overriding default behavior of this call. |
int sr_set_oper_changes_order | ( | sr_session_ctx_t * | session, |
const char * | module_name, | ||
uint32_t | order | ||
) |
Set explicit push operational changes order determining when they are applied relative to other sessions for the module.
By default the next highest order (lowest priority) is generated for any new session push oper data of a module.
[in] | session | Session (not DS-specific) to use. |
[in] | module_name | Name of the module to change. Set to NULL to change the order for all the modules. |
[in] | order | Non-zero order to set, must be unique. |
int sr_validate | ( | sr_session_ctx_t * | session, |
const char * | module_name, | ||
uint32_t | timeout_ms | ||
) |
Perform the validation a datastore and any changes made in the current session, but do not apply nor discard them.
Provides only YANG validation, apply-changes subscribers will not be notified in this case.
[in] | session | Session (DS-specific) to use. |
[in] | module_name | If specified, limits the validate operation only to this module and its dependencies. |
[in] | timeout_ms | Operational callback timeout in milliseconds. If 0, default is used. |