sysrepo 2.0.53
YANG-based system repository for all-around configuration management.
Loading...
Searching...
No Matches
Getting Data API

Functions

void sr_free_val (sr_val_t *value)
 Free sr_val_t structure and all memory allocated within it.
 
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).
 
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.
 
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.
 
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.
 
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.
 
enum  sr_type_t {
  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_t {
  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...
 
typedef union sr_data_u sr_data_t
 
typedef struct sr_val_s sr_val_t
 
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.
 

Detailed Description

Typedef Documentation

◆ sr_data_t

typedef union sr_data_u sr_data_t

Definition at line 247 of file sysrepo_types.h.

◆ sr_get_oper_options_t

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 294 of file sysrepo_types.h.

◆ sr_val_t

typedef struct sr_val_s sr_val_t

Definition at line 274 of file sysrepo_types.h.

Enumeration Type Documentation

◆ sr_get_oper_flag_t

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 279 of file sysrepo_types.h.

◆ sr_type_t

enum sr_type_t

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 189 of file sysrepo_types.h.

Function Documentation

◆ sr_free_val()

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.

◆ sr_free_values()

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.

◆ sr_get_data()

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).

◆ sr_get_item()

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).

◆ sr_get_items()

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).

◆ sr_get_subtree()

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).