sysrepo
3.0.0
YANG-based system repository for all-around configuration management.
|
Functions | |
struct ly_ctx * | sr_acquire_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. More... | |
int | sr_connect (const sr_conn_options_t opts, sr_conn_ctx_t **conn) |
Connects to the sysrepo datastore. More... | |
int | sr_disconnect (sr_conn_ctx_t *conn) |
Disconnect from the sysrepo datastore. More... | |
uint32_t | sr_get_content_id (sr_conn_ctx_t *conn) |
Get content ID of the current YANG module set. It conforms to the requirements for ietf-yang-library "content-id" node value. More... | |
int | sr_get_error_data (const sr_error_info_err_t *err, uint32_t idx, uint32_t *size, const void **data) |
Get a specific chunk of error data. More... | |
int | sr_get_plugins (sr_conn_ctx_t *conn, const char ***ds_plugins, const char ***ntf_plugins) |
Get loaded plugins of a connection. More... | |
uid_t | sr_get_su_uid (void) |
Get the sysrepo SUPERUSER UID. More... | |
void | sr_release_context (sr_conn_ctx_t *conn) |
Release libyang context obtained from a session/connection. More... | |
struct ly_ctx * | sr_session_acquire_context (sr_session_ctx_t *session) |
Get the libyang context used by a connection. Can be used in an application for working with data and schemas. More... | |
void | sr_session_del_orig_data (sr_session_ctx_t *session) |
Remove all pushed event originator data. More... | |
int | sr_session_dup_error (sr_session_ctx_t *src_session, sr_session_ctx_t *trg_session) |
Copy the first error (if any) from a session to a callback session. More... | |
sr_conn_ctx_t * | sr_session_get_connection (sr_session_ctx_t *session) |
Get the connection the session was created on. More... | |
sr_datastore_t | sr_session_get_ds (sr_session_ctx_t *session) |
Learn the datastore a session operates on. More... | |
int | sr_session_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... | |
uint32_t | sr_session_get_id (sr_session_ctx_t *session) |
Return the assigned session ID of the sysrepo session. More... | |
int | sr_session_get_orig_data (sr_session_ctx_t *session, uint32_t idx, uint32_t *size, const void **data) |
Get a specific chunk of event originator data in a callback. More... | |
const char * | sr_session_get_orig_name (sr_session_ctx_t *session) |
Get event originator name. More... | |
const char * | sr_session_get_user (sr_session_ctx_t *session) |
Get the effective user of a session. More... | |
int | sr_session_notif_buffer (sr_session_ctx_t *session) |
Use notification buffering for the session. More... | |
int | sr_session_push_error_data (sr_session_ctx_t *session, uint32_t size, const void *data) |
Push (add) another chunk of error data for a failed callback communicated back to the originator. Its meaning is specific to the error data format (which must be set prior to calling this function) identifier and can be read from the error structure by the originator using sr_get_error_data(). More... | |
int | sr_session_push_orig_data (sr_session_ctx_t *session, uint32_t size, const void *data) |
Push (add) another chunk of event originator data used for all events sent on this session. Its meaning is specific to the originator name (which must be set prior to calling this function) and can be read from the implicit event session in the callbacks using sr_session_get_orig_data(). More... | |
void | sr_session_release_context (sr_session_ctx_t *session) |
Release libyang context obtained from a session/connection. More... | |
int | sr_session_set_error (sr_session_ctx_t *session, const char *err_format_name, sr_error_t err_code, const char *err_msg_format,...) |
Set an error for a failed callback communicated back to the originator. Does not print the message. More... | |
int | sr_session_set_error_format (sr_session_ctx_t *session, const char *error_format) |
Deprecated, use sr_session_set_error(). More... | |
int | sr_session_set_error_message (sr_session_ctx_t *session, const char *format,...) |
Deprecated, use sr_session_set_error(). More... | |
int | sr_session_set_orig_name (sr_session_ctx_t *session, const char *orig_name) |
Set event originator name used for all events sent on this session. It can then be read from the implicit event session in the callbacks using sr_session_get_orig_name(). This name should be used for interpreting the data set by sr_session_push_orig_data(). 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 than the process owner. 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 the session and releases resources tied to it. 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... | |
int | sr_session_unsubscribe (sr_session_ctx_t *session) |
Unsubscribe all subscriptions created by this session. More... | |
typedef struct sr_conn_ctx_s | sr_conn_ctx_t |
Sysrepo connection. More... | |
typedef struct sr_conn_ctx_s sr_conn_ctx_t |
Sysrepo connection.
Definition at line 89 of file sysrepo_types.h.
struct ly_ctx* sr_acquire_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.
[in] | conn | Connection to use. |
int sr_connect | ( | const sr_conn_options_t | opts, |
sr_conn_ctx_t ** | conn | ||
) |
Connects to the sysrepo datastore.
fork(2)
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 | Connection options. |
[out] | conn | Created connection. |
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 to free. |
uint32_t sr_get_content_id | ( | sr_conn_ctx_t * | conn | ) |
Get content ID of the current YANG module set. It conforms to the requirements for ietf-yang-library "content-id" node value.
[in] | conn | Connection to use. |
int sr_get_error_data | ( | const sr_error_info_err_t * | err, |
uint32_t | idx, | ||
uint32_t * | size, | ||
const void ** | data | ||
) |
Get a specific chunk of error data.
If the error is a well-known one, it is possible to use helper utility functions instead of repeatedly calling this function.
[in] | err | Error structure to use. |
[in] | idx | Index of the error data chunk, starts at 0. |
[out] | size | Optional size of the error data chunk. |
[out] | data | Pointer to an opaque error data chunk. |
int sr_get_plugins | ( | sr_conn_ctx_t * | conn, |
const char *** | ds_plugins, | ||
const char *** | ntf_plugins | ||
) |
Get loaded plugins of a connection.
[in] | conn | Connection to use. |
[out] | ds_plugins | Optional pointer to array of datastore plugins ended by NULL. |
[out] | ntf_plugins | Optional pointer to array of notification plugins ended by NULL. |
uid_t sr_get_su_uid | ( | void | ) |
Get the sysrepo SUPERUSER UID.
void sr_release_context | ( | sr_conn_ctx_t * | conn | ) |
Release libyang context obtained from a session/connection.
[in] | conn | Connection to use. |
struct ly_ctx* sr_session_acquire_context | ( | sr_session_ctx_t * | session | ) |
Get the libyang context used by a connection. Can be used in an application for working with data and schemas.
Similar to and interchangeable with sr_acquire_context().
[in] | session | Session whose connection to use. |
void sr_session_del_orig_data | ( | sr_session_ctx_t * | session | ) |
Remove all pushed event originator data.
[in] | session | Session (not DS-specific) to use. |
int sr_session_dup_error | ( | sr_session_ctx_t * | src_session, |
sr_session_ctx_t * | trg_session | ||
) |
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. |
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_session_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. |
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. |
int sr_session_get_orig_data | ( | sr_session_ctx_t * | session, |
uint32_t | idx, | ||
uint32_t * | size, | ||
const void ** | data | ||
) |
Get a specific chunk of event originator data in a callback.
[in] | session | Implicit session provided in a callback. |
[in] | idx | Index of the data chunk, starts at 0. |
[out] | size | Optional size of the data chunk. |
[out] | data | Pointer to an opaque data chunk. |
const char* sr_session_get_orig_name | ( | sr_session_ctx_t * | session | ) |
Get event originator name.
[in] | session | Implicit session provided in a callback. |
const char* sr_session_get_user | ( | sr_session_ctx_t * | session | ) |
Get the effective user of a session.
[in] | session | Session (not DS-specific) to use. |
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_push_error_data | ( | sr_session_ctx_t * | session, |
uint32_t | size, | ||
const void * | data | ||
) |
Push (add) another chunk of error data for a failed callback communicated back to the originator. Its meaning is specific to the error data format (which must be set prior to calling this function) identifier and can be read from the error structure by the originator using sr_get_error_data().
[in] | session | Implicit session provided in a callback. |
[in] | size | Size of the error data chunk. |
[in] | data | Pointer to an opaque error data chunk. |
int sr_session_push_orig_data | ( | sr_session_ctx_t * | session, |
uint32_t | size, | ||
const void * | data | ||
) |
Push (add) another chunk of event originator data used for all events sent on this session. Its meaning is specific to the originator name (which must be set prior to calling this function) and can be read from the implicit event session in the callbacks using sr_session_get_orig_data().
[in] | session | Session (not DS-specific) to use. |
[in] | size | Size of the data chunk. |
[in] | data | Pointer to an opaque data chunk. |
void sr_session_release_context | ( | sr_session_ctx_t * | session | ) |
Release libyang context obtained from a session/connection.
Similar to and interchangeable with sr_release_context().
[in] | session | Session whose connection to use. |
int sr_session_set_error | ( | sr_session_ctx_t * | session, |
const char * | err_format_name, | ||
sr_error_t | err_code, | ||
const char * | err_msg_format, | ||
... | |||
) |
Set an error for a failed callback communicated back to the originator. Does not print the message.
err_format_name
should be used for interpreting the error data set by sr_session_push_error_data(). There are some well-known error formats defined and those errors can be written/read using helper utility functions.[in] | session | Implicit session provided in a callback. |
[in] | err_format_name | Optional arbitrary error format identifier, set its error data using sr_session_push_error_data(). |
[in] | err_code | Error code of the error. |
[in] | err_msg_format | Error message format. |
[in] | ... | Error message format arguments. |
int sr_session_set_error_format | ( | sr_session_ctx_t * | session, |
const char * | error_format | ||
) |
Deprecated, use sr_session_set_error().
int sr_session_set_error_message | ( | sr_session_ctx_t * | session, |
const char * | format, | ||
... | |||
) |
Deprecated, use sr_session_set_error().
int sr_session_set_orig_name | ( | sr_session_ctx_t * | session, |
const char * | orig_name | ||
) |
Set event originator name used for all events sent on this session. It can then be read from the implicit event session in the callbacks using sr_session_get_orig_name(). This name should be used for interpreting the data set by sr_session_push_orig_data().
The following originator names are well-known:
netopeer2
for the NETCONF serverrousette
for the RESTCONF serversysrepo-cli
for the direct sysrepo mode of the interactive CLI[in] | session | Session (not DS-specific) to use. |
[in] | orig_name | Arbitrary originator name. |
int sr_session_set_user | ( | sr_session_ctx_t * | session, |
const char * | user | ||
) |
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 to use. |
[in] | datastore | Datastore on which to operate, can be later changed using sr_session_switch_ds(). |
[out] | session | Created session. |
int sr_session_stop | ( | sr_session_ctx_t * | session | ) |
Stop the session and releases resources tied to it.
Also releases any locks held and frees subscriptions created (only) by this session.
[in] | session | Session to free. |
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. |
int sr_session_unsubscribe | ( | sr_session_ctx_t * | session | ) |
Unsubscribe all subscriptions created by this session.
[in] | session | Session to use. |