sysrepo
1.4.168
YANG datastore
|
Data Structures | |
struct | sr_error_info_msg_s |
A single, detailed error message. Used in sr_error_info_s. More... | |
struct | sr_error_info_s |
Detailed sysrepo session error information. More... | |
Typedefs | |
typedef struct sr_conn_ctx_s | sr_conn_ctx_t |
Sysrepo connection. More... | |
typedef struct sr_session_ctx_s | sr_session_ctx_t |
Sysrepo session on a connection. More... | |
typedef enum sr_conn_flag_e | sr_conn_flag_t |
Flags used to override default connection handling by sr_connect call. More... | |
typedef uint32_t | sr_conn_options_t |
Options overriding default connection handling by sr_connect call, it is supposed to be bitwise OR-ed value of any sr_conn_flag_t flags. More... | |
typedef enum sr_datastore_e | sr_datastore_t |
Datastores that sysrepo supports. To change which datastore a session operates on, use sr_session_switch_ds. More... | |
typedef struct sr_error_info_msg_s | sr_error_info_msg_t |
A single, detailed error message. Used in sr_error_info_s. More... | |
typedef struct sr_error_info_s | sr_error_info_t |
Detailed sysrepo session error information. More... | |
typedef int(* | sr_diff_check_cb )(sr_session_ctx_t *session, const struct lyd_node *diff) |
Callback to be called before applying a diff. Set it using sr_set_diff_check_callback. More... | |
Enumerations | |
enum | sr_conn_flag_e { SR_CONN_DEFAULT = 0, SR_CONN_CACHE_RUNNING = 1, SR_CONN_NO_SCHED_CHANGES = 2, SR_CONN_ERR_ON_SCHED_FAIL = 4 } |
Flags used to override default connection handling by sr_connect call. More... | |
enum | sr_datastore_e { SR_DS_STARTUP = 0, SR_DS_RUNNING = 1, SR_DS_CANDIDATE = 2, SR_DS_OPERATIONAL = 3 } |
Datastores that sysrepo supports. To change which datastore a session operates on, use sr_session_switch_ds. More... | |
Functions | |
int | sr_connect (const sr_conn_options_t opts, sr_conn_ctx_t **conn) |
Connects to the sysrepo datastore. If possible (no other connections exist), also apply any scheduled changes. More... | |
int | sr_disconnect (sr_conn_ctx_t *conn) |
Disconnect from the sysrepo datastore. More... | |
int | sr_connection_count (uint32_t *conn_count) |
Learn the current global number of alive connections. More... | |
struct ly_ctx * | sr_get_context (sr_conn_ctx_t *conn) |
Get the libyang context used by a connection. Can be used in an application for working with data and schemas. Do NOT change this context! More... | |
void | sr_set_diff_check_callback (sr_conn_ctx_t *conn, sr_diff_check_cb callback) |
Set callback for checking every diff before it is applied on the datastore. The diff is final (only CRUD operations) but without any implicit changes caused by validation. This callback is primarily meant to allow full NACM (NETCONF Access Control) to be performed by a NETCONF server. More... | |
int | sr_session_start (sr_conn_ctx_t *conn, const sr_datastore_t datastore, sr_session_ctx_t **session) |
Start a new session. More... | |
int | sr_session_stop (sr_session_ctx_t *session) |
Stop current session and releases resources tied to the session. More... | |
int | sr_session_notif_buffer (sr_session_ctx_t *session) |
Use notification buffering for the session. More... | |
int | sr_session_switch_ds (sr_session_ctx_t *session, sr_datastore_t ds) |
Change datastore which the session operates on. All subsequent calls will be issued on the chosen datastore. Previous calls are not affected. More... | |
sr_datastore_t | sr_session_get_ds (sr_session_ctx_t *session) |
Learn the datastore a session operates on. More... | |
int | sr_get_error (sr_session_ctx_t *session, const sr_error_info_t **error_info) |
Retrieve information about the error that has occurred during the last operation executed within provided session. More... | |
int | sr_set_error (sr_session_ctx_t *session, const char *path, const char *format,...) |
Set detailed error information into provided session. Used to notify the client library about errors that occurred in the application code. Does not print the message. More... | |
uint32_t | sr_session_get_id (sr_session_ctx_t *session) |
Return the assigned session ID of the sysrepo session. More... | |
uint32_t | sr_session_get_event_sr_id (sr_session_ctx_t *session) |
Return the session ID of the event originator sysrepo session. Should be used on the implicit session in event callbacks. More... | |
void | sr_session_set_nc_id (sr_session_ctx_t *session, uint32_t nc_sid) |
Set a NETCONF session ID for a sysrepo session. Any application callbacks handling operations initiated by this session will be able to read this ID from the session provided. More... | |
uint32_t | sr_session_get_nc_id (sr_session_ctx_t *session) |
Learn NETCONF session ID set for a sysrepo session. More... | |
uint32_t | sr_session_get_event_nc_id (sr_session_ctx_t *session) |
Learn NETCONF session ID set for the event originator sysrepo session. Should be used on the implicit session in event callbacks. More... | |
int | sr_session_set_user (sr_session_ctx_t *session, const char *user) |
Set the effective user of a session to a different one that the process owner. More... | |
const char * | sr_session_get_user (sr_session_ctx_t *session) |
Get the effective user of a session. More... | |
const char * | sr_session_get_event_user (sr_session_ctx_t *session) |
Get the effective user of the event originator sysrepo session. Should be used on the implicit session in event callbacks. More... | |
sr_conn_ctx_t * | sr_session_get_connection (sr_session_ctx_t *session) |
Get the connection the session was created on. More... | |
struct sr_error_info_msg_s |
A single, detailed error message. Used in sr_error_info_s.
Data Fields | ||
---|---|---|
char * | message |
Error message. |
char * | xpath |
XPath (or rather path) to the node where the error has been discovered. |
struct sr_error_info_s |
Data Fields | ||
---|---|---|
sr_error_t | err_code |
Error code. |
sr_error_info_msg_t * | err |
Array of all generated errors. |
size_t | err_count |
Error message count. |
typedef struct sr_conn_ctx_s sr_conn_ctx_t |
typedef struct sr_session_ctx_s sr_session_ctx_t |
typedef enum sr_conn_flag_e sr_conn_flag_t |
Flags used to override default connection handling by sr_connect call.
typedef uint32_t sr_conn_options_t |
Options overriding default connection handling by sr_connect call, it is supposed to be bitwise OR-ed value of any sr_conn_flag_t flags.
typedef enum sr_datastore_e sr_datastore_t |
Datastores that sysrepo supports. To change which datastore a session operates on, use sr_session_switch_ds.
typedef struct sr_error_info_msg_s sr_error_info_msg_t |
A single, detailed error message. Used in sr_error_info_s.
typedef struct sr_error_info_s sr_error_info_t |
Detailed sysrepo session error information.
typedef int(* sr_diff_check_cb)(sr_session_ctx_t *session, const struct lyd_node *diff) |
Callback to be called before applying a diff. Set it using sr_set_diff_check_callback.
[in] | session | Implicit session (do not stop) with information about the event originator session IDs. |
[in] | diff | Diff to be applied. |
enum sr_conn_flag_e |
Flags used to override default connection handling by sr_connect call.
enum sr_datastore_e |
Datastores that sysrepo supports. To change which datastore a session operates on, use sr_session_switch_ds.
Enumerator | |
---|---|
SR_DS_STARTUP |
Contains configuration data that will be loaded when a device starts. |
SR_DS_RUNNING |
Contains current configuration data. |
SR_DS_CANDIDATE |
Contains prepared configuration data that do not affect actual configuration. |
SR_DS_OPERATIONAL |
Contains currently used configuration (see operational datastore). |
int sr_connect | ( | const sr_conn_options_t | opts, |
sr_conn_ctx_t ** | conn | ||
) |
Connects to the sysrepo datastore. If possible (no other connections exist), also apply any scheduled changes.
fork()
after creating a connection. Sysrepo internally stores the connection ID of every connection. Forking will duplicate the connection and ID resulting in a mismatch.[in] | opts | Options overriding default connection handling by this call. |
[out] | conn | Connection that can be used for subsequent API calls (automatically allocated, it is supposed to be released by the caller using sr_disconnect). |
int sr_disconnect | ( | sr_conn_ctx_t * | conn | ) |
Disconnect from the sysrepo datastore.
Cleans up and frees connection context allocated by sr_connect. All sessions and subscriptions started within the connection will be automatically stopped and cleaned up too.
[in] | conn | Connection acquired with sr_connect call. |
int sr_connection_count | ( | uint32_t * | conn_count | ) |
Learn the current global number of alive connections.
[out] | conn_count | Current number of connections. |
struct ly_ctx* sr_get_context | ( | sr_conn_ctx_t * | conn | ) |
Get the libyang context used by a connection. Can be used in an application for working with data and schemas. Do NOT change this context!
[in] | conn | Connection to use. |
void sr_set_diff_check_callback | ( | sr_conn_ctx_t * | conn, |
sr_diff_check_cb | callback | ||
) |
Set callback for checking every diff before it is applied on the datastore. The diff is final (only CRUD operations) but without any implicit changes caused by validation. This callback is primarily meant to allow full NACM (NETCONF Access Control) to be performed by a NETCONF server.
Required SUPERUSER access.
[in] | conn | Connection, whose all sessions diffs will be passed to this callback. |
[in] | callback | Callback to call for every diff. |
int sr_session_start | ( | sr_conn_ctx_t * | conn, |
const sr_datastore_t | datastore, | ||
sr_session_ctx_t ** | session | ||
) |
Start a new session.
[in] | conn | Connection acquired with sr_connect call. |
[in] | datastore | Datastore on which all sysrepo functions within this session will operate. Later on, datastore can be later changed using sr_session_switch_ds call. Functionality of some sysrepo calls does not depend on datastore. If your session will contain just calls like these, you can pass any valid value (e.g. SR_DS_RUNNING). |
[out] | session | Session context that can be used for subsequent API calls (automatically allocated, can be released by calling sr_session_stop). |
int sr_session_stop | ( | sr_session_ctx_t * | session | ) |
Stop current session and releases resources tied to the session.
Also releases any locks held and frees subscriptions created (only) by this session.
[in] | session | Session context acquired with sr_session_start call. |
int sr_session_notif_buffer | ( | sr_session_ctx_t * | session | ) |
Use notification buffering for the session.
When a notification is sent using this session for a module that supports replay (notification should be stored), the notification function does not wait until it is stored but delegates this work to a special thread and returns.
[in] | session | Session (not DS-specific) whose notifications will be buffered. |
int sr_session_switch_ds | ( | sr_session_ctx_t * | session, |
sr_datastore_t | ds | ||
) |
Change datastore which the session operates on. All subsequent calls will be issued on the chosen datastore. Previous calls are not affected.
[in] | session | Session to modify. |
[in] | ds | New datastore that will be operated on. |
sr_datastore_t sr_session_get_ds | ( | sr_session_ctx_t * | session | ) |
Learn the datastore a session operates on.
[in] | session | Session to use. |
int sr_get_error | ( | sr_session_ctx_t * | session, |
const sr_error_info_t ** | error_info | ||
) |
Retrieve information about the error that has occurred during the last operation executed within provided session.
[in] | session | Session (not DS-specific) to use. |
[out] | error_info | Detailed error information. Be aware that returned pointer may change by the next API call executed within the provided session. Do not free or modify returned values. |
int sr_set_error | ( | sr_session_ctx_t * | session, |
const char * | path, | ||
const char * | format, | ||
... | |||
) |
Set detailed error information into provided session. Used to notify the client library about errors that occurred in the application code. Does not print the message.
[in] | session | Implicit session provided in a callback. |
[in] | path | Optional path of the node where the error has occurred. |
[in] | format | Human-readable format of the error message. |
[in] | ... | Format parameters. |
uint32_t sr_session_get_id | ( | sr_session_ctx_t * | session | ) |
Return the assigned session ID of the sysrepo session.
[in] | session | Session (not DS-specific) to use. |
uint32_t sr_session_get_event_sr_id | ( | sr_session_ctx_t * | session | ) |
Return the session ID of the event originator sysrepo session. Should be used on the implicit session in event callbacks.
[in] | session | Event session (not DS-specific) to use. |
void sr_session_set_nc_id | ( | sr_session_ctx_t * | session, |
uint32_t | nc_sid | ||
) |
Set a NETCONF session ID for a sysrepo session. Any application callbacks handling operations initiated by this session will be able to read this ID from the session provided.
[in] | session | Session (not DS-specific) to change. |
[in] | nc_sid | NETCONF session ID of a NETCONF session running on top of this session. |
uint32_t sr_session_get_nc_id | ( | sr_session_ctx_t * | session | ) |
Learn NETCONF session ID set for a sysrepo session.
[in] | session | Session (not DS-specific) to use. |
uint32_t sr_session_get_event_nc_id | ( | sr_session_ctx_t * | session | ) |
Learn NETCONF session ID set for the event originator sysrepo session. Should be used on the implicit session in event callbacks.
[in] | session | Event session (not DS-specific) to use. |
int sr_session_set_user | ( | sr_session_ctx_t * | session, |
const char * | user | ||
) |
const char* sr_session_get_user | ( | sr_session_ctx_t * | session | ) |
Get the effective user of a session.
Required SUPERUSER access.
[in] | session | Session (not DS-specific) to use. |
const char* sr_session_get_event_user | ( | sr_session_ctx_t * | session | ) |
Get the effective user of the event originator sysrepo session. Should be used on the implicit session in event callbacks.
[in] | session | Event session (not DS-specific) to use. |
sr_conn_ctx_t* sr_session_get_connection | ( | sr_session_ctx_t * | session | ) |
Get the connection the session was created on.
[in] | session | Session (not DS-specific) to use. |