Loading...
Searching...
No Matches
RPC/Action Subscription API

## Functions

int | sr_rpc_send (sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt, uint32_t timeout_ms, sr_val_t **output, size_t *output_cnt)
| Send an RPC/action and wait for the result. Data are represented as sr_val_t structures.
int | sr_rpc_send_tree (sr_session_ctx_t *session, struct lyd_node *input, uint32_t timeout_ms, sr_data_t **output)
| Send an RPC/action and wait for the result. Data are represented as libyang subtrees.
int | sr_rpc_subscribe (sr_session_ctx_t *session, const char *xpath, sr_rpc_cb callback, void *private_data, uint32_t priority, sr_subscr_options_t opts, sr_subscription_ctx_t **subscription)
| Subscribe for the delivery of an RPC/action. Data are represented as sr_val_t structures.
int | sr_rpc_subscribe_tree (sr_session_ctx_t *session, const char *xpath, sr_rpc_tree_cb callback, void *private_data, uint32_t priority, sr_subscr_options_t opts, sr_subscription_ctx_t **subscription)
| Subscribe for the delivery of an RPC/action. Data are represented as libyang subtrees.
typedef int(* | sr_rpc_cb) (sr_session_ctx_t *session, uint32_t sub_id, const char *xpath, const sr_val_t *input, const size_t input_cnt, sr_event_t event, uint32_t operation_id, sr_val_t **output, size_t *output_cnt, void *private_data)
| Callback to be called for the delivery of an RPC/action. Data are represented as sr_val_t structures.
typedef int(* | sr_rpc_tree_cb) (sr_session_ctx_t *session, uint32_t sub_id, const char *op_path, const struct lyd_node *input, sr_event_t event, uint32_t operation_id, struct lyd_node *output, void *private_data)
| Callback to be called for the delivery of an RPC/action. Data are represented as libyang subtrees.

## Detailed Description

## Typedef Documentation

## sr_rpc_cb

typedef int(* sr_rpc_cb) (sr_session_ctx_t *session, uint32_t sub_id, const char *xpath, const sr_val_t *input, const size_t input_cnt, sr_event_t event, uint32_t operation_id, sr_val_t **output, size_t *output_cnt, void *private_data)

Callback to be called for the delivery of an RPC/action. Data are represented as sr_val_t structures.

Note
  Callback must not modify any RPC/action subscriptions, it would result in a deadlock.

Parameters

  [in] | session | Implicit session (do not stop) with information about event originator session IDs.
  [in] | sub_id | Subscription ID.
  [in] | xpath | Full operation xpath identifying the exact RPC/action executed.
  [in] | input | Array of input parameters.
  [in] | input_cnt | Number of input parameters.
  [in] | event | Type of the callback event that has occurred.
  [in] | operation_id | Operation ID of the current operation used for all the callbacks and events.
  [out] | output | Array of output parameters. Should be allocated on heap, will be freed by sysrepo after sending of the RPC response.
  [out] | output_cnt | Number of output parameters.
  [in] | private_data | Private context opaque to sysrepo, as passed to sr_rpc_subscribe call.

Returns
  User error code (SR_ERR_OK on success).

Definition at line 584 of file sysrepo_types.h.

## sr_rpc_tree_cb

typedef int(* sr_rpc_tree_cb) (sr_session_ctx_t *session, uint32_t sub_id, const char *op_path, const struct lyd_node *input, sr_event_t event, uint32_t operation_id, struct lyd_node *output, void *private_data)

Callback to be called for the delivery of an RPC/action. Data are represented as libyang subtrees.

Note
  Callback must not modify any RPC/action subscriptions, it would result in a deadlock.

Parameters

  [in] | session | Implicit session (do not stop) with information about the event originator session IDs.
  [in] | sub_id | Subscription ID.
  [in] | op_path | Simple operation path identifying the RPC/action.
  [in] | input | Data tree of input parameters. Always points to the RPC/action itself, even for nested operations.
  [in] | event | Type of the callback event that has occurred.
  [in] | operation_id | Operation ID of the current operation used for all the callbacks and events.
  [out] | output | Data tree for appending any output parameters, the operation root node is provided..
  [in] | private_data | Private context opaque to sysrepo, as passed to sr_rpc_subscribe_tree call.

Returns
  User error code (SR_ERR_OK on success).

Definition at line 603 of file sysrepo_types.h.

## Function Documentation

## sr_rpc_send()

int sr_rpc_send | ( | sr_session_ctx_t * | session,
|  | const char * | path,
|  | const sr_val_t * | input,
|  | const size_t | input_cnt,
|  | uint32_t | timeout_ms,
|  | sr_val_t ** | output,
|  | size_t * | output_cnt )

Send an RPC/action and wait for the result. Data are represented as sr_val_t structures.

Required READ access.

Note
  RPC/action must be valid in (is validated against) the operational datastore context.

Parameters

  [in] | session | Session (not DS-specific) to use.
  [in] | path | Path identifying the RPC/action.
  [in] | input | Array of input parameters (array of all nodes that hold some data in RPC/action input subtree - same as sr_get_items would return).
  [in] | input_cnt | Number of input parameters.
  [in] | timeout_ms | RPC/action callback timeout in milliseconds. If 0, default is used.
  [out] | output | Array of output parameters (all nodes that hold some data in RPC/action output subtree). Will be allocated by sysrepo and should be freed by caller using sr_free_values.
  [out] | output_cnt | Number of output parameters.

Returns
  Error code (SR_ERR_OK on success).

## sr_rpc_send_tree()

int sr_rpc_send_tree | ( | sr_session_ctx_t * | session,
|  | struct lyd_node * | input,
|  | uint32_t | timeout_ms,
|  | sr_data_t ** | output )

Send an RPC/action and wait for the result. Data are represented as libyang subtrees.

Required READ access.

Note
  RPC/action must be valid in (is validated against) the operational datastore context.

Parameters

  [in] | session | Session (not DS-specific) to use.
  [in,out] | input | Input data tree in `session` connection libyang context, is validated.
  [in] | timeout_ms | RPC/action callback timeout in milliseconds. If 0, default is used.
  [out] | output | SR data with the output data tree, NULL if no output nodes were generated.

Returns
  Error code (SR_ERR_OK on success).

## sr_rpc_subscribe()

int sr_rpc_subscribe | ( | sr_session_ctx_t * | session,
|  | const char * | xpath,
|  | sr_rpc_cb | callback,
|  | void * | private_data,
|  | uint32_t | priority,
|  | sr_subscr_options_t | opts,
|  | sr_subscription_ctx_t ** | subscription )

Subscribe for the delivery of an RPC/action. Data are represented as sr_val_t structures.

Required WRITE access.

Parameters

  [in] | session | Session (not DS-specific) to use.
  [in] | xpath | XPath identifying the RPC/action. Any predicates are allowed.
  [in] | callback | Callback to be called.
  [in] | private_data | Private context passed to the callback function, opaque to sysrepo.
  [in] | priority | Specifies the order in which the callbacks (within RPC/action) will be called, higher first.
  [in] | opts | Options overriding default behavior of the subscription, it is supposed to be a bitwise OR-ed value of any sr_subscr_flag_t flags.
  [in,out] | subscription | Subscription context, zeroed for first subscription, freed by sr_unsubscribe.

Returns
  Error code (SR_ERR_OK on success).

## sr_rpc_subscribe_tree()

int sr_rpc_subscribe_tree | ( | sr_session_ctx_t * | session,
|  | const char * | xpath,
|  | sr_rpc_tree_cb | callback,
|  | void * | private_data,
|  | uint32_t | priority,
|  | sr_subscr_options_t | opts,
|  | sr_subscription_ctx_t ** | subscription )

Subscribe for the delivery of an RPC/action. Data are represented as libyang subtrees.

Required WRITE access.

Parameters

  [in] | session | Session (not DS-specific) to use.
  [in] | xpath | XPath identifying the RPC/action. Any predicates are allowed.
  [in] | callback | Callback to be called.
  [in] | private_data | Private context passed to the callback function, opaque to sysrepo.
  [in] | priority | Specifies the order in which the callbacks (within RPC/action) will be called, higher first.
  [in] | opts | Options overriding default behavior of the subscription, it is supposed to be a bitwise OR-ed value of any sr_subscr_flag_t flags.
  [in,out] | subscription | Subscription context, zeroed for first subscription, freed by sr_unsubscribe.

Returns
  Error code (SR_ERR_OK on success).