sysrepo  1.4.168
YANG datastore
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Getting Data API

Data Structures

union  sr_data_u
 Data of an element (if applicable), properly set according to the type. More...
 
struct  sr_val_s
 Structure that contains value of an data element stored in the sysrepo datastore. More...
 

Typedefs

typedef enum sr_type_e sr_type_t
 Possible types of a data element stored in the sysrepo datastore. More...
 
typedef union sr_data_u sr_data_t
 Data of an element (if applicable), properly set according to the type. More...
 
typedef struct sr_val_s sr_val_t
 Structure that contains value of an data element stored in the sysrepo datastore. More...
 
typedef enum sr_get_oper_flag_e sr_get_oper_flag_t
 Flags used to override default data get behaviour on SR_DS_OPERATIONAL by sr_get_data call. More...
 
typedef uint32_t sr_get_oper_options_t
 Options overriding default get handling by sr_get_data call, it is supposed to be bitwise OR-ed value of any sr_get_oper_flag_t flags. More...
 

Enumerations

enum  sr_type_e {
  SR_UNKNOWN_T, SR_LIST_T, SR_CONTAINER_T, SR_CONTAINER_PRESENCE_T,
  SR_LEAF_EMPTY_T, SR_NOTIFICATION_T, SR_BINARY_T, SR_BITS_T,
  SR_BOOL_T, SR_DECIMAL64_T, SR_ENUM_T, SR_IDENTITYREF_T,
  SR_INSTANCEID_T, SR_INT8_T, SR_INT16_T, SR_INT32_T,
  SR_INT64_T, SR_STRING_T, SR_UINT8_T, SR_UINT16_T,
  SR_UINT32_T, SR_UINT64_T, SR_ANYXML_T, SR_ANYDATA_T
}
 Possible types of a data element stored in the sysrepo datastore. More...
 
enum  sr_get_oper_flag_e {
  SR_OPER_DEFAULT = 0, SR_OPER_NO_STATE = 1, SR_OPER_NO_CONFIG = 2, SR_OPER_NO_SUBS = 4,
  SR_OPER_NO_STORED = 8, SR_OPER_WITH_ORIGIN = 16
}
 Flags used to override default data get behaviour on SR_DS_OPERATIONAL by sr_get_data call. More...
 

Functions

int sr_get_item (sr_session_ctx_t *session, const char *path, uint32_t timeout_ms, sr_val_t **value)
 Retrieve a single data element selected by the provided path. Data are represented as sr_val_t structures. More...
 
int sr_get_items (sr_session_ctx_t *session, const char *xpath, uint32_t timeout_ms, const sr_get_oper_options_t opts, sr_val_t **values, size_t *value_cnt)
 Retrieve an array of data elements selected by the provided XPath. Data are represented as sr_val_t structures. More...
 
int sr_get_subtree (sr_session_ctx_t *session, const char *path, uint32_t timeout_ms, struct lyd_node **subtree)
 Retrieve a single subtree whose root node is selected by the provided path. Data are represented as libyang subtrees. More...
 
int sr_get_data (sr_session_ctx_t *session, const char *xpath, uint32_t max_depth, uint32_t timeout_ms, const sr_get_oper_options_t opts, struct lyd_node **data)
 Retrieve a tree whose root nodes match the provided XPath. Data are represented as libyang subtrees. More...
 
void sr_free_val (sr_val_t *value)
 Free sr_val_t structure and all memory allocated within it. More...
 
void sr_free_values (sr_val_t *values, size_t count)
 Free array of sr_val_t structures (and all memory allocated within of each array element). More...
 

Detailed Description


Data Structure Documentation

union sr_data_u

Data of an element (if applicable), properly set according to the type.

Definition at line 669 of file sysrepo.h.

Data Fields
char * binary_val

Base64-encoded binary data (RFC 7950 sec 9.8)

char * bits_val

A set of bits or flags (RFC 7950 sec 9.7)

bool bool_val

A boolean value (RFC 7950 sec 9.5)

double decimal64_val

64-bit signed decimal number (RFC 7950 sec 9.3) Be careful with this value! It is not always possible and the value can change when converting between a double and YANG decimal64. Because of that you may see some unexpected behavior setting or reading this value. To avoid these problems, use *_tree() API variants instead.

char * enum_val

A string from enumerated strings list (RFC 7950 sec 9.6)

char * identityref_val

A reference to an abstract identity (RFC 7950 sec 9.10)

char * instanceid_val

References a data tree node (RFC 7950 sec 9.13)

int8_t int8_val

8-bit signed integer (RFC 7950 sec 9.2)

int16_t int16_val

16-bit signed integer (RFC 7950 sec 9.2)

int32_t int32_val

32-bit signed integer (RFC 7950 sec 9.2)

int64_t int64_val

64-bit signed integer (RFC 7950 sec 9.2)

char * string_val

Human-readable string (RFC 7950 sec 9.4)

uint8_t uint8_val

8-bit unsigned integer (RFC 7950 sec 9.2)

uint16_t uint16_val

16-bit unsigned integer (RFC 7950 sec 9.2)

uint32_t uint32_val

32-bit unsigned integer (RFC 7950 sec 9.2)

uint64_t uint64_val

64-bit unsigned integer (RFC 7950 sec 9.2)

char * anyxml_val

Unknown chunk of XML (RFC 7950 sec 7.10)

char * anydata_val

Unknown set of nodes, encoded in XML (RFC 7950 sec 7.10)

struct sr_val_s

Structure that contains value of an data element stored in the sysrepo datastore.

Definition at line 696 of file sysrepo.h.

Data Fields
char * xpath

XPath (or rather path) identifier of the data element.

sr_type_t type

Type of an element.

bool dflt

Flag for node with default value (applicable only for leaves). It is set to TRUE only if the value was implicitly set by the datastore as per module schema. Explicitly set/modified data element (through the sysrepo API) always has this flag unset regardless of the entered value.

char * origin

Origin of the value.

sr_data_t data

Data of an element (if applicable), properly set according to the type.

Typedef Documentation

typedef enum sr_type_e sr_type_t

Possible types of a data element stored in the sysrepo datastore.

typedef union sr_data_u sr_data_t

Data of an element (if applicable), properly set according to the type.

typedef struct sr_val_s sr_val_t

Structure that contains value of an data element stored in the sysrepo datastore.

Flags used to override default data get behaviour on SR_DS_OPERATIONAL by sr_get_data call.

typedef uint32_t sr_get_oper_options_t

Options overriding default get handling by sr_get_data call, it is supposed to be bitwise OR-ed value of any sr_get_oper_flag_t flags.

Definition at line 737 of file sysrepo.h.

Enumeration Type Documentation

enum sr_type_e

Possible types of a data element stored in the sysrepo datastore.

Enumerator
SR_UNKNOWN_T 

Element unknown to sysrepo (unsupported element).

SR_LIST_T 

List instance. (RFC 7950 sec 7.8)

SR_CONTAINER_T 

Non-presence container. (RFC 7950 sec 7.5)

SR_CONTAINER_PRESENCE_T 

Presence container. (RFC 7950 sec 7.5.1)

SR_LEAF_EMPTY_T 

A leaf that does not hold any value (RFC 7950 sec 9.11)

SR_NOTIFICATION_T 

Notification instance (RFC 7095 sec 7.16)

SR_BINARY_T 

Base64-encoded binary data (RFC 7950 sec 9.8)

SR_BITS_T 

A set of bits or flags (RFC 7950 sec 9.7)

SR_BOOL_T 

A boolean value (RFC 7950 sec 9.5)

SR_DECIMAL64_T 

64-bit signed decimal number (RFC 7950 sec 9.3)

SR_ENUM_T 

A string from enumerated strings list (RFC 7950 sec 9.6)

SR_IDENTITYREF_T 

A reference to an abstract identity (RFC 7950 sec 9.10)

SR_INSTANCEID_T 

References a data tree node (RFC 7950 sec 9.13)

SR_INT8_T 

8-bit signed integer (RFC 7950 sec 9.2)

SR_INT16_T 

16-bit signed integer (RFC 7950 sec 9.2)

SR_INT32_T 

32-bit signed integer (RFC 7950 sec 9.2)

SR_INT64_T 

64-bit signed integer (RFC 7950 sec 9.2)

SR_STRING_T 

Human-readable string (RFC 7950 sec 9.4)

SR_UINT8_T 

8-bit unsigned integer (RFC 7950 sec 9.2)

SR_UINT16_T 

16-bit unsigned integer (RFC 7950 sec 9.2)

SR_UINT32_T 

32-bit unsigned integer (RFC 7950 sec 9.2)

SR_UINT64_T 

64-bit unsigned integer (RFC 7950 sec 9.2)

SR_ANYXML_T 

Unknown chunk of XML (RFC 7950 sec 7.10)

SR_ANYDATA_T 

Unknown set of nodes, encoded in XML (RFC 7950 sec 7.10)

Definition at line 635 of file sysrepo.h.

Flags used to override default data get behaviour on SR_DS_OPERATIONAL by sr_get_data call.

Enumerator
SR_OPER_DEFAULT 

No special behaviour.

SR_OPER_NO_STATE 

Return only configuration data.

SR_OPER_NO_CONFIG 

Return only state data. If there are some state subtrees with configuration parents, these are also returned (with keys if lists).

SR_OPER_NO_SUBS 

Return only stored operational data (push), do not call subscriber callbacks (pull).

SR_OPER_NO_STORED 

Do not merge with stored operational data (push).

SR_OPER_WITH_ORIGIN 

Return data with their origin attributes. Nodes without one inherit the origin from parents.

Definition at line 722 of file sysrepo.h.

Function Documentation

int sr_get_item ( sr_session_ctx_t session,
const char *  path,
uint32_t  timeout_ms,
sr_val_t **  value 
)

Retrieve a single data element selected by the provided path. Data are represented as sr_val_t structures.

If the path identifies an empty leaf, a list or a container, the value has no data filled in and its type is set properly (SR_LEAF_EMPTY_T / SR_LIST_T / SR_CONTAINER_T / SR_CONTAINER_PRESENCE_T).

Required READ access, but if the access check fails, the module data are simply ignored without an error.

See Also
Use sr_get_items for retrieving larger chunks of data from the datastore. Since it retrieves the data from datastore in larger chunks, it can work much more efficiently than multiple sr_get_item calls.
Parameters
[in]sessionSession (DS-specific) to use.
[in]pathPath of the data element to be retrieved.
[in]timeout_msOperational callback timeout in milliseconds. If 0, default is used.
[out]valueRequested node, allocated dynamically (free using sr_free_val).
Returns
Error code (SR_ERR_OK on success, SR_ERR_INVAL_ARG if multiple nodes match the path, SR_ERR_NOT_FOUND if no nodes match the path).
int sr_get_items ( sr_session_ctx_t session,
const char *  xpath,
uint32_t  timeout_ms,
const sr_get_oper_options_t  opts,
sr_val_t **  values,
size_t *  value_cnt 
)

Retrieve an array of data elements selected by the provided XPath. Data are represented as sr_val_t structures.

All data elements are transferred within one message from the datastore, which is more efficient that calling multiple sr_get_item calls.

Required READ access, but if the access check fails, the module data are simply ignored without an error.

Parameters
[in]sessionSession (DS-specific) to use.
[in]xpathXPath of the data elements to be retrieved.
[in]timeout_msOperational callback timeout in milliseconds. If 0, default is used.
[in]optsOptions overriding default get behaviour.
[out]valuesArray of requested nodes, if any, allocated dynamically (free using sr_free_values).
[out]value_cntNumber of returned elements in the values array.
Returns
Error code (SR_ERR_OK on success).
int sr_get_subtree ( sr_session_ctx_t session,
const char *  path,
uint32_t  timeout_ms,
struct lyd_node **  subtree 
)

Retrieve a single subtree whose root node is selected by the provided path. Data are represented as libyang subtrees.

The functions returns values and all associated information stored under the root node and all its descendants. While the same data can be obtained using sr_get_items in combination with the expressive power of XPath addressing, the recursive nature of the output data type also preserves the hierarchical relationships between data elements.

Required READ access, but if the access check fails, the module data are simply ignored without an error.

Parameters
[in]sessionSession (DS-specific) to use.
[in]pathPath selecting the root node of the subtree to be retrieved.
[in]timeout_msOperational callback timeout in milliseconds. If 0, default is used.
[out]subtreeRequested subtree, allocated dynamically. NULL if none found.
Returns
Error code (SR_ERR_OK on success, SR_ERR_INVAL_ARG if multiple nodes match the path).
int sr_get_data ( sr_session_ctx_t session,
const char *  xpath,
uint32_t  max_depth,
uint32_t  timeout_ms,
const sr_get_oper_options_t  opts,
struct lyd_node **  data 
)

Retrieve a tree whose root nodes match the provided XPath. Data are represented as libyang subtrees.

Top-level trees are always returned so if an inner node is selected, all of its descendants and its direct parents (lists also with keys) are returned.

If the subtree selection process results in too many node overlaps, the cost of the operation may be unnecessarily big. As an example, a common XPath expression //. is normally used to select all nodes in a data tree, but for this operation it would result in an excessive duplication of data nodes. Since all the descendants of each matched node are returned implicitly, // in the XPath should never be used (i.e. /* is the correct XPath for all the nodes).

Required READ access, but if the access check fails, the module data are simply ignored without an error.

Parameters
[in]sessionSession (DS-specific) to use.
[in]xpathXPath selecting root nodes of subtrees to be retrieved.
[in]max_depthMaximum depth of the selected subtrees. 0 is unlimited, 1 will not return any descendant nodes. If a list should be returned, its keys are always returned as well.
[in]timeout_msOperational callback timeout in milliseconds. If 0, default is used.
[in]optsOptions overriding default get behaviour.
[out]dataConnected top-level trees with all the requested data, allocated dynamically. NULL if none found.
Returns
Error code (SR_ERR_OK on success).
void sr_free_val ( sr_val_t value)

Free sr_val_t structure and all memory allocated within it.

Parameters
[in]valueValue to be freed.
void sr_free_values ( sr_val_t values,
size_t  count 
)

Free array of sr_val_t structures (and all memory allocated within of each array element).

Parameters
[in]valuesArray of values to be freed.
[in]countNumber of elements stored in the array.