sysrepo  2.2.150
YANG-based system repository for all-around configuration management.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Schema API

Functions

int sr_check_module_ds_access (sr_conn_ctx_t *conn, const char *module_name, int mod_ds, int *read, int *write)
 Check whether the current application has read/write access to a module. More...
 
int sr_disable_module_feature (sr_conn_ctx_t *conn, const char *module_name, const char *feature_name)
 Disable a module feature. More...
 
int sr_enable_module_feature (sr_conn_ctx_t *conn, const char *module_name, const char *feature_name)
 Enable a module feature. More...
 
int sr_get_module_ds_access (sr_conn_ctx_t *conn, const char *module_name, int mod_ds, char **owner, char **group, mode_t *perm)
 Learn about module permissions. More...
 
int sr_get_module_info (sr_conn_ctx_t *conn, sr_data_t **sysrepo_data)
 Get internal sysrepo data tree, which holds detailed information about installed modules. It should not be needed except for some specific use-cases. These data are from the sysrepo module found in modules/sysrepo.yang. More...
 
int sr_get_module_replay_support (sr_conn_ctx_t *conn, const char *module_name, struct timespec *earliest_notif, int *enabled)
 Learn replay support of a module. More...
 
const char * sr_get_repo_path (void)
 Get the common path prefix for all sysrepo files. More...
 
int sr_install_module (sr_conn_ctx_t *conn, const char *schema_path, const char *search_dirs, const char **features)
 Install a new schema (module) into sysrepo. More...
 
int sr_install_module2 (sr_conn_ctx_t *conn, const char *schema_path, const char *search_dirs, const char **features, const sr_module_ds_t *module_ds, const char *owner, const char *group, mode_t perm, const char *data, const char *data_path, LYD_FORMAT format)
 Install a new schema (module) into sysrepo with all the available options. More...
 
int sr_install_modules (sr_conn_ctx_t *conn, const char **schema_paths, const char *search_dirs, const char ***features)
 Install new schemas (modules) into sysrepo in a batch. More...
 
int sr_install_modules2 (sr_conn_ctx_t *conn, const sr_install_mod_t *modules, uint32_t module_count, const char *search_dirs, const char *data, const char *data_path, LYD_FORMAT format)
 Install new schemas (modules) into sysrepo in a batch with all the available options. More...
 
int sr_is_module_internal (const struct lys_module *ly_mod)
 Check whether a module is an internal libyang or sysrepo module. Evaluates to true for all the modules that are installed by default when no modules were explicitly added. More...
 
int sr_remove_module (sr_conn_ctx_t *conn, const char *module_name, int force)
 Remove an installed module from sysrepo. More...
 
int sr_remove_modules (sr_conn_ctx_t *conn, const char **module_names, int force)
 Remove installed modules from sysrepo. More...
 
int sr_set_module_ds_access (sr_conn_ctx_t *conn, const char *module_name, int mod_ds, const char *owner, const char *group, mode_t perm)
 Change module permissions. More...
 
int sr_set_module_replay_support (sr_conn_ctx_t *conn, const char *module_name, int enable)
 Change module replay support. More...
 
int sr_update_module (sr_conn_ctx_t *conn, const char *schema_path, const char *search_dirs)
 Update an installed schema (module) to a new revision. More...
 
int sr_update_modules (sr_conn_ctx_t *conn, const char **schema_paths, const char *search_dirs)
 Update installed schemas (modules) to new revisions in a batch. More...
 

Detailed Description

Function Documentation

int sr_check_module_ds_access ( sr_conn_ctx_t conn,
const char *  module_name,
int  mod_ds,
int *  read,
int *  write 
)

Check whether the current application has read/write access to a module.

Parameters
[in]connConnection to use.
[in]module_nameName of the module to use.
[in]mod_dsAffected datastore, sr_datastore_t value or SR_MOD_DS_NOTIF.
[out]readOptional, set if read access was granted.
[out]writeOptional, set if write access was granted.
Returns
Error code (SR_ERR_OK on success).
int sr_disable_module_feature ( sr_conn_ctx_t conn,
const char *  module_name,
const char *  feature_name 
)

Disable a module feature.

Required WRITE access.

Parameters
[in]connConnection to use.
[in]module_nameName of the module to change.
[in]feature_nameName of the feature to disable.
Returns
Error code (SR_ERR_OK on success).
int sr_enable_module_feature ( sr_conn_ctx_t conn,
const char *  module_name,
const char *  feature_name 
)

Enable a module feature.

Required WRITE access.

Parameters
[in]connConnection to use.
[in]module_nameName of the module to change.
[in]feature_nameName of the feature to enable.
Returns
Error code (SR_ERR_OK on success).
int sr_get_module_ds_access ( sr_conn_ctx_t conn,
const char *  module_name,
int  mod_ds,
char **  owner,
char **  group,
mode_t *  perm 
)

Learn about module permissions.

Parameters
[in]connConnection to use.
[in]module_nameName of the module to use.
[in]mod_dsAffected datastore, sr_datastore_t value or SR_MOD_DS_NOTIF.
[out]ownerOptional, read the owner of the module.
[out]groupOptional, read the group of the module.
[out]permOptional, read the permissions of the module.
Returns
Error code (SR_ERR_OK on success).
int sr_get_module_info ( sr_conn_ctx_t conn,
sr_data_t **  sysrepo_data 
)

Get internal sysrepo data tree, which holds detailed information about installed modules. It should not be needed except for some specific use-cases. These data are from the sysrepo module found in modules/sysrepo.yang.

Parameters
[in]connConnection to use.
[out]sysrepo_dataSysrepo internal data tree.
Returns
Error code (SR_ERR_OK on success).
int sr_get_module_replay_support ( sr_conn_ctx_t conn,
const char *  module_name,
struct timespec *  earliest_notif,
int *  enabled 
)

Learn replay support of a module.

Parameters
[in]connConnection to use.
[in]module_nameName of the module to check.
[out]earliest_notifOptional timestamp of the earliest stored notification, zeroed if none are stored. Can be set even if enabled is false when replay was enabled in the past.
[out]enabledWhether replay support is enabled or disabled.
Returns
Error code (SR_ERR_OK on success).
const char* sr_get_repo_path ( void  )

Get the common path prefix for all sysrepo files.

Note
If a specific path was changed during compilation, it does not use this path prefix.
Returns
Sysrepo repository path.
int sr_install_module ( sr_conn_ctx_t conn,
const char *  schema_path,
const char *  search_dirs,
const char **  features 
)

Install a new schema (module) into sysrepo.

For all datastores and notifications the default plugins are used.

Parameters
[in]connConnection to use.
[in]schema_pathPath to the new schema. Can have either YANG or YIN extension/format.
[in]search_dirsOptional search directories for import schemas, supports the format <dir>[:<dir>]*.
[in]featuresOptional array of enabled features ended with NULL. Feature '*' enables them all.
Returns
Error code (SR_ERR_OK on success).
int sr_install_module2 ( sr_conn_ctx_t conn,
const char *  schema_path,
const char *  search_dirs,
const char **  features,
const sr_module_ds_t module_ds,
const char *  owner,
const char *  group,
mode_t  perm,
const char *  data,
const char *  data_path,
LYD_FORMAT  format 
)

Install a new schema (module) into sysrepo with all the available options.

Any initial data are also used as factory-default datastore data.

Parameters
[in]connConnection to use.
[in]schema_pathPath to the new schema. Can have either YANG or YIN extension/format.
[in]search_dirsOptional search directories for import schemas, supports the format <dir>[:<dir>]*.
[in]featuresOptional array of enabled features ended with NULL, all disabled by default. Feature '*' enables them all.
[in]module_dsOptional datastore implementation plugin names for each datastore, NULL for all defaults. If only SR_DS_RUNNING plugin name is NULL, it is disabled and effectively always mirrors SR_DS_STARTUP.
[in]ownerOptional initial owner of the module data, process user by default.
[in]groupOptional initial group of the module data, process group by default.
[in]permOptional initial permissions of the module data, otherwise system defaults are applied.
[in]dataOptional initial data in format to set, only if data_path is not set.
[in]data_pathOptional path to an initial data file in format to set, only if data is not set.
[in]formatFormat of data or data_path file.
Returns
Error code (SR_ERR_OK on success).
int sr_install_modules ( sr_conn_ctx_t conn,
const char **  schema_paths,
const char *  search_dirs,
const char ***  features 
)

Install new schemas (modules) into sysrepo in a batch.

For all datastores and notifications the default plugins are used.

Parameters
[in]connConnection to use.
[in]schema_pathsArray of paths to the new schemas terminated by NULL. Can have either YANG or YIN extension/format.
[in]search_dirsOptional search directories for import schemas, supports the format <dir>[:<dir>]*.
[in]featuresArray of the same length as schema_paths (minus the last NULL). Each item is an array of enabled features ended with NULL for the schema_paths on the same index. Can be NULL for leaving all the features disabled.
Returns
Error code (SR_ERR_OK on success).
int sr_install_modules2 ( sr_conn_ctx_t conn,
const sr_install_mod_t modules,
uint32_t  module_count,
const char *  search_dirs,
const char *  data,
const char *  data_path,
LYD_FORMAT  format 
)

Install new schemas (modules) into sysrepo in a batch with all the available options.

Any initial data are also used as factory-default datastore data.

Parameters
[in]connConnection to use.
[in]modulesArray of new modules to be installed with all their information.
[in]module_countCount of modules.
[in]search_dirsOptional search directories for import schemas, supports the format <dir>[:<dir>]*.
[in]dataOptional initial data of all the modules in format to set, only if data_path is not set.
[in]data_pathOptional path to an initial data file of all the modules in format to set, only if data is not set.
[in]formatFormat of data or data_path file.
Returns
Error code (SR_ERR_OK on success).
int sr_is_module_internal ( const struct lys_module *  ly_mod)

Check whether a module is an internal libyang or sysrepo module. Evaluates to true for all the modules that are installed by default when no modules were explicitly added.

Parameters
[in]ly_modModule to check.
Returns
true (0) for an internal module.
false (non-zero) for other modules.
int sr_remove_module ( sr_conn_ctx_t conn,
const char *  module_name,
int  force 
)

Remove an installed module from sysrepo.

Required WRITE access.

Parameters
[in]connConnection to use.
[in]module_nameName of the module to remove.
[in]forceIf there are other installed modules depending on module_name, remove them, too.
Returns
Error code (SR_ERR_OK on success).
int sr_remove_modules ( sr_conn_ctx_t conn,
const char **  module_names,
int  force 
)

Remove installed modules from sysrepo.

Required WRITE access.

Parameters
[in]connConnection to use.
[in]module_namesArray of names of modules to remove terminated by NULL.
[in]forceIf there are other installed modules depending on module_names, remove them, too.
Returns
Error code (SR_ERR_OK on success).
int sr_set_module_ds_access ( sr_conn_ctx_t conn,
const char *  module_name,
int  mod_ds,
const char *  owner,
const char *  group,
mode_t  perm 
)

Change module permissions.

Parameters
[in]connConnection to use.
[in]module_nameName of the module to change, NULL for all the modules.
[in]mod_dsAffected datastore, sr_datastore_t value or SR_MOD_DS_NOTIF.
[in]ownerOptional, new owner of the module.
[in]groupOptional, new group of the module.
[in]permOptional, new permissions of the module.
Returns
Error code (SR_ERR_OK on success).
int sr_set_module_replay_support ( sr_conn_ctx_t conn,
const char *  module_name,
int  enable 
)

Change module replay support.

Parameters
[in]connConnection to use.
[in]module_nameName of the module to change. NULL to change all the modules.
[in]enable0 to disable, non-zero to enable.
Returns
Error code (SR_ERR_OK on success).
int sr_update_module ( sr_conn_ctx_t conn,
const char *  schema_path,
const char *  search_dirs 
)

Update an installed schema (module) to a new revision.

Required WRITE access.

Parameters
[in]connConnection to use.
[in]schema_pathPath to the updated schema. Can have either YANG or YIN extension/format.
[in]search_dirsOptional search directories for import schemas, supports the format <dir>[:<dir>]*.
Returns
Error code (SR_ERR_OK on success).
int sr_update_modules ( sr_conn_ctx_t conn,
const char **  schema_paths,
const char *  search_dirs 
)

Update installed schemas (modules) to new revisions in a batch.

Required WRITE access.

Parameters
[in]connConnection to use.
[in]schema_pathsArray of paths to the new schemas terminated by NULL. Can have either YANG or YIN extension/format.
[in]search_dirsOptional search directories for import schemas, supports the format <dir>[:<dir>]*.
Returns
Error code (SR_ERR_OK on success).