Loading...
Searching...
No Matches
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.
int | sr_disable_module_feature (sr_conn_ctx_t *conn, const char *module_name, const char *feature_name)
| Disable a module feature.
int | sr_enable_module_feature (sr_conn_ctx_t *conn, const char *module_name, const char *feature_name)
| Enable a module feature.
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.
const sr_module_ds_t * | sr_get_module_ds_default (void)
| Get the default datastore plugins.
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.
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.
const char * | sr_get_repo_path (void)
| Get the path (directory) for all persistent sysrepo files.
const char * | sr_get_shm_path (void)
| Get the path (directory) for all volatile sysrepo files, created as SHM files.
const char * | sr_get_shm_prefix (void)
| Get the common SHM file prefix prepended to all SHM files.
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.
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.
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.
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.
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.
int | sr_remove_module (sr_conn_ctx_t *conn, const char *module_name, int force)
| Remove an installed module from sysrepo.
int | sr_remove_modules (sr_conn_ctx_t *conn, const char **module_names, int force)
| Remove installed modules from sysrepo.
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.
int | sr_set_module_replay_support (sr_conn_ctx_t *conn, const char *module_name, int enable)
| Change module replay support.
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.
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.

## Detailed Description

## Function Documentation

## sr_check_module_ds_access()

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] | conn | Connection to use.
  [in] | module_name | Name of the module to use.
  [in] | mod_ds | Affected datastore, sr_datastore_t value or SR_MOD_DS_NOTIF.
  [out] | read | Optional, set if read access was granted.
  [out] | write | Optional, set if write access was granted.

Returns
  Error code (SR_ERR_OK on success).

## sr_disable_module_feature()

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] | conn | Connection to use.
  [in] | module_name | Name of the module to change.
  [in] | feature_name | Name of the feature to disable, "*" for all the features.

Returns
  Error code (SR_ERR_OK on success).

## sr_enable_module_feature()

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] | conn | Connection to use.
  [in] | module_name | Name of the module to change.
  [in] | feature_name | Name of the feature to enable, "*" for all the features.

Returns
  Error code (SR_ERR_OK on success).

## sr_get_module_ds_access()

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] | conn | Connection to use.
  [in] | module_name | Name of the module to use.
  [in] | mod_ds | Affected datastore, sr_datastore_t value or SR_MOD_DS_NOTIF.
  [out] | owner | Optional, read the owner of the module.
  [out] | group | Optional, read the group of the module.
  [out] | perm | Optional, read the permissions of the module.

Returns
  Error code (SR_ERR_OK on success).

## sr_get_module_ds_default()

const sr_module_ds_t * sr_get_module_ds_default | ( | void |  | ) |

Get the default datastore plugins.

New modules without explicitly set DS plugins will use these plugins. Use sr_install_module2 to install a module with a custom set of datastore plugins.

Returns
  Default datastore plugin structure.

## sr_get_module_info()

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] | conn | Connection to use.
  [out] | sysrepo_data | Sysrepo internal data tree.

Returns
  Error code (SR_ERR_OK on success).

## sr_get_module_replay_support()

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] | conn | Connection to use.
  [in] | module_name | Name of the module to check.
  [out] | earliest_notif | Optional 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] | enabled | Whether replay support is enabled or disabled.

Returns
  Error code (SR_ERR_OK on success).

## sr_get_repo_path()

const char * sr_get_repo_path | ( | void |  | ) |

Get the path (directory) for all persistent sysrepo files.

Note
  If a specific path was changed during compilation, it does not use this path prefix.

Returns
  Sysrepo repository path.

## sr_get_shm_path()

const char * sr_get_shm_path | ( | void |  | ) |

Get the path (directory) for all volatile sysrepo files, created as SHM files.

Returns
  Sysrepo SHM path.

## sr_get_shm_prefix()

const char * sr_get_shm_prefix | ( | void |  | ) |

Get the common SHM file prefix prepended to all SHM files.

Returns
  Sysrepo SHM files prefix.

## sr_install_module()

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] | conn | Connection to use.
  [in] | schema_path | Path to the new schema. Can have either YANG or YIN extension/format.
  [in] | search_dirs | Optional search directories for import schemas, supports the format <dir>[:<dir>]*.
  [in] | features | Optional array of enabled features ended with NULL. Feature '*' enables them all.

Returns
  Error code (SR_ERR_OK on success).

## sr_install_module2()

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.

If a libyang import callback is set for `conn` context, it will be used when installing the modules.

Any initial data are used as running, startup, and factory-default datastore data. If not set, the datastore plugin will be used to get the initial data for each datastore, which should generally be empty but may not be for custom DS plugins.

Parameters

  [in] | conn | Connection to use.
  [in] | schema_path | Path to the new schema. Can have either YANG or YIN extension/format.
  [in] | search_dirs | Optional search directories for import schemas, supports the format <dir>[:<dir>]*.
  [in] | features | Optional array of enabled features ended with NULL, all disabled by default. Feature '*' enables them all.
  [in] | module_ds | Optional 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] | owner | Optional initial owner of the module data, process user by default.
  [in] | group | Optional initial group of the module data, process group by default.
  [in] | perm | Optional initial permissions of the module data, otherwise system defaults are applied.
  [in] | data | Optional initial data in `format` to set, only if `data_path` is not set.
  [in] | data_path | Optional path to an initial data file in `format` to set, only if `data` is not set.
  [in] | format | Format of `data` or `data_path` file.

Returns
  Error code (SR_ERR_OK on success).

## sr_install_modules()

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] | conn | Connection to use.
  [in] | schema_paths | Array of paths to the new schemas terminated by NULL. Can have either YANG or YIN extension/format.
  [in] | search_dirs | Optional search directories for import schemas, supports the format <dir>[:<dir>]*.
  [in] | features | Array 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).

## sr_install_modules2()

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.

See sr_install_module2 for details.

Parameters

  [in] | conn | Connection to use.
  [in] | modules | Array of new modules to be installed with all their information.
  [in] | module_count | Count of `modules`.
  [in] | search_dirs | Optional search directories for import schemas, supports the format <dir>[:<dir>]*.
  [in] | data | Optional initial data of all the modules in `format` to set, only if `data_path` is not set.
  [in] | data_path | Optional path to an initial data file of all the modules in `format` to set, only if `data` is not set.
  [in] | format | Format of `data` or `data_path` file.

Returns
  Error code (SR_ERR_OK on success).

## sr_is_module_internal()

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_mod | Module to check.

Returns
  true (0) for an internal module.
  false (non-zero) for other modules.

## sr_remove_module()

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] | conn | Connection to use.
  [in] | module_name | Name of the module to remove.
  [in] | force | If there are other installed modules depending on `module_name`, remove them, too.

Returns
  Error code (SR_ERR_OK on success).

## sr_remove_modules()

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] | conn | Connection to use.
  [in] | module_names | Array of names of modules to remove terminated by NULL.
  [in] | force | If there are other installed modules depending on `module_names`, remove them, too.

Returns
  Error code (SR_ERR_OK on success).

## sr_set_module_ds_access()

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] | conn | Connection to use.
  [in] | module_name | Name of the module to change, NULL for all the modules.
  [in] | mod_ds | Affected datastore, sr_datastore_t value or SR_MOD_DS_NOTIF.
  [in] | owner | Optional, new owner of the module.
  [in] | group | Optional, new group of the module.
  [in] | perm | Optional, new permissions of the module.

Returns
  Error code (SR_ERR_OK on success).

## sr_set_module_replay_support()

int sr_set_module_replay_support | ( | sr_conn_ctx_t * | conn,
|  | const char * | module_name,
|  | int | enable )

Change module replay support.

Parameters

  [in] | conn | Connection to use.
  [in] | module_name | Name of the module to change. NULL to change all the modules.
  [in] | enable | 0 to disable, non-zero to enable.

Returns
  Error code (SR_ERR_OK on success).

## sr_update_module()

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] | conn | Connection to use.
  [in] | schema_path | Path to the updated schema. Can have either YANG or YIN extension/format.
  [in] | search_dirs | Optional search directories for import schemas, supports the format <dir>[:<dir>]*.

Returns
  Error code (SR_ERR_OK on success).

## sr_update_modules()

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] | conn | Connection to use.
  [in] | schema_paths | Array of paths to the new schemas terminated by NULL. Can have either YANG or YIN extension/format.
  [in] | search_dirs | Optional search directories for import schemas, supports the format <dir>[:<dir>]*.

Returns
  Error code (SR_ERR_OK on success).