yumapro  23.10T-7
YumaPro SDK
Loading...
Searching...
No Matches
HTTP APIs for RESTCONF

HTTP APIs for RESTCONF Protocol Support. More...

Collaboration diagram for HTTP APIs for RESTCONF:

Data Structures

struct  agt_yangapi_context_t
 module context node with cached schema tree and API template for retrieval (root) More...
 
struct  agt_restconf_data_t
 RESTCONF structure for data. More...
 

Functions

const xmlChar * get_launchpoint_name (yangapi_launchpt_t launchpt)
 Get the keyword for the specified launchpt. More...
 
status_t agt_restcmn_parse_fragment (yangapi_cb_t *rcb, xmlChar *uri, uint32 *retlen)
 parse the request URI fragment More...
 
status_t agt_restcmn_parse_query_string (ses_cb_t *scb, rpc_msg_t *msg, yangapi_cb_t *rcb, xmlChar *uri, uint32 *retlen)
 parse the request URI query string More...
 
xmlChar * agt_restcmn_get_param (yangapi_cb_t *rcb, const xmlChar *name, boolean *found)
 Find a query parameter and return its value. More...
 
status_t agt_restcmn_validate_query_string (ses_cb_t *scb, rpc_msg_t *msg, yangapi_cb_t *rcb)
 Validate the parameters in the request URI query string. More...
 
status_t agt_restcmn_parse_path (ses_cb_t *scb, rpc_msg_t *msg, yangapi_cb_t *rcb, val_value_t *root, const xmlChar *path)
 parse the request URI path More...
 
status_t agt_restcmn_get_http_input (ses_cb_t *scb, yangapi_cb_t *rcb, rpc_msg_t *msg, int content_len)
 Get the input from the session input buffers and parse it as the specified target object type. More...
 
status_t agt_restcmn_set_content_encoding (ses_cb_t *scb, yangapi_cb_t *rcb, rpc_msg_t *msg)
 Get the content encoding used. More...
 
boolean agt_restcmn_check_unmodified_return (yangapi_cb_t *rcb)
 Check if the context node(s) will match the filters (if any) More...
 
status_t agt_restcmn_setup_notifications (ses_cb_t *scb, yangapi_cb_t *rcb, rpc_msg_t *msg)
 setup the notification delivery on this GET request More...
 
status_t agt_restcmn_setup_read_params (ses_cb_t *scb, yangapi_cb_t *rcb, rpc_msg_t *msg)
 Setup the message parameters from the yangapi_cb values. More...
 
boolean agt_restcmn_operation_supports_json (obj_template_t *rpcobj)
 Check if the NETCONF operation supports JSON output. More...
 
status_t agt_restcmn_get_operations (ses_cb_t *scb, getcb_mode_t cbmode, const val_value_t *virval, val_value_t *dstval)
 GET1 operation handler for the /operations container. More...
 
int agt_restcmn_get_content_len (yangapi_cb_t *rcb)
 Get the content length for the input request message body. More...
 
status_t agt_restcmn_validate_method (ses_cb_t *scb, yangapi_cb_t *rcb, rpc_msg_t *msg)
 validate that the method is supported for the URI given. More...
 
status_t agt_restcmn_check_metpar_error (ses_cb_t *scb, yangapi_cb_t *rcb, rpc_msg_t *msg, const xmlChar *parmname)
 validate that the URI parameters given are supported for the method More...
 
yangapi_method_t agt_restcmn_get_method (const xmlChar *method)
 Get the HTTP method enum from the string. More...
 
boolean agt_restcmn_method_is_read (yangapi_method_t method)
 Check if this is a read method. More...
 
boolean agt_restcmn_validate_accept_header (ses_cb_t *scb, yangapi_cb_t *rcb, rpc_msg_t *msg, boolean error_recorded, status_t *res)
 Validate the client Accept header. More...
 
xmlns_id_t agt_restcmn_get_nsid (ncx_protocol_t proto)
 Get the XML namespace ID for specific proto. More...
 
void agt_restcmn_free_msg (rpc_msg_t *msg)
 Free an rpc_msg_t. More...
 
void agt_restcmn_print_debug_line (ses_cb_t *scb, yangapi_cb_t *rcb)
 Print the message received debug line. More...
 
boolean agt_restcmn_get_config_parm (yangapi_cb_t *rcb, val_value_t *context_node)
 Get the value of the config parm to use. More...
 
val_value_tagt_restcmn_new_config_wrapper (void)
 Create a <config> wrapper val and return it. More...
 
xmlChar * agt_restcmn_make_uri (ses_cb_t *scb, const xmlChar *target, const xmlChar *edit_target)
 Make a URI string. More...
 
xmlChar * agt_restcmn_decode_url (const xmlChar *url, status_t *res)
 Decode URL encoded string value into string. More...
 
void agt_restcmn_record_obj_error (ses_cb_t *scb, rpc_msg_t *msg, status_t res, obj_template_t *errobj, const xmlChar *badval)
 Record an rpc-error for YANG-API/RESTCONF response translation the error node is an object, not a value node. More...
 
void agt_restcmn_record_error (ses_cb_t *scb, xml_msg_hdr_t *mhdr, status_t res, val_value_t *errnode, const xmlChar *badval)
 Record an rpc-error for YANG-API/RESTCONF response translation. More...
 
void agt_restcmn_record_error_errinfo (ses_cb_t *scb, xml_msg_hdr_t *mhdr, status_t res, val_value_t *errnode, const xmlChar *badval, const ncx_errinfo_t *errinfo)
 Record an rpc-error for YANG-API/RESTCONF response translation. More...
 
void agt_restcmn_obj_error (ses_cb_t *scb, xml_msg_hdr_t *mhdr, status_t res, obj_template_t *errobj, const xmlChar *badval)
 Record an rpc-error for YANG-API/RESTCONF response translation. More...
 
void agt_restcmn_val_error (ses_cb_t *scb, xml_msg_hdr_t *mhdr, status_t res, val_value_t *errval, const xmlChar *badval)
 Record an rpc-error for YANG-API/RESTCONF response translation. More...
 
const xmlChar * agt_restcmn_entry_point (void)
 Get the RESTCONF entry point name. More...
 
void agt_restcmn_setup_launch_point (yangapi_cb_t *rcb)
 check the parseed request URI path set the API launch point data More...
 
status_t agt_rescmn_setup_action_request (ses_cb_t *scb, rpc_msg_t *msg, yangapi_cb_t *rcb)
 Setup the data needed to invoke a YANG action. More...
 
val_value_tget_active_root (yangapi_cb_t *rcb)
 Select the active CFG and return its root val. More...
 

Detailed Description

HTTP APIs for RESTCONF Protocol Support.

Routines common to YANG-API and RESTCONF. YANG-API is obsolete and no longer supported

Function Documentation

◆ agt_rescmn_setup_action_request()

status_t agt_rescmn_setup_action_request ( ses_cb_t scb,
rpc_msg_t msg,
yangapi_cb_t rcb 
)

Setup the data needed to invoke a YANG action.

Parameters
scbRESTCONF session
msgrequest message in progress
rcbrestapi control block to use
Return values
status
Here is the call graph for this function:
Here is the caller graph for this function:

◆ agt_restcmn_check_metpar_error()

status_t agt_restcmn_check_metpar_error ( ses_cb_t scb,
yangapi_cb_t rcb,
rpc_msg_t msg,
const xmlChar *  parmname 
)

validate that the URI parameters given are supported for the method

Errors are recorded by this function. Do not call record_error again if error returned

Parameters
scbsession control block to use
rcbrestapi control block to use
[in,out]msgmessage to use for storing error records
msg hdr errors set as needed
parmnameparameter to check
Returns
status
Here is the caller graph for this function:

◆ agt_restcmn_check_unmodified_return()

boolean agt_restcmn_check_unmodified_return ( yangapi_cb_t rcb)

Check if the context node(s) will match the filters (if any)

Parameters
rcbrestapi control block to use
Returns
TRUE if condition passes or skipped
FALSE if condition fails
Here is the call graph for this function:
Here is the caller graph for this function:

◆ agt_restcmn_decode_url()

xmlChar * agt_restcmn_decode_url ( const xmlChar *  url,
status_t res 
)

Decode URL encoded string value into string.

Parameters
urlURL string
[out]resaddress of return status; *res return status
Returns
malloced string; must free with m__free
Here is the call graph for this function:

◆ agt_restcmn_entry_point()

const xmlChar * agt_restcmn_entry_point ( void  )

Get the RESTCONF entry point name.

Returns
const pointer to entry point name

◆ agt_restcmn_free_msg()

void agt_restcmn_free_msg ( rpc_msg_t msg)

Free an rpc_msg_t.

Free RESTCONF part first.

Parameters
msgrpc_msg_t to delete
Here is the call graph for this function:
Here is the caller graph for this function:

◆ agt_restcmn_get_config_parm()

boolean agt_restcmn_get_config_parm ( yangapi_cb_t rcb,
val_value_t context_node 
)

Get the value of the config parm to use.

Parameters
rcbrestapi control block to use
context_nodeXPath context node to check
Returns
TRUE if config=true || content=config
FALSE if config=false || content=nonconfig
content=all ignores this function (only RESTCONF)
Here is the caller graph for this function:

◆ agt_restcmn_get_content_len()

int agt_restcmn_get_content_len ( yangapi_cb_t rcb)

Get the content length for the input request message body.

Parameters
rcbrestapi control block to use
Returns
content length in bytes; < 0 error
Here is the caller graph for this function:

◆ agt_restcmn_get_http_input()

status_t agt_restcmn_get_http_input ( ses_cb_t scb,
yangapi_cb_t rcb,
rpc_msg_t msg,
int  content_len 
)

Get the input from the session input buffers and parse it as the specified target object type.

Parameters
scbsession to use
rcbrestapi control block to use
[in,out]msgmessage control block in progress
msg->rpc_input value is set representing the parsed content. Only the basic input parsing has been done, not any referential integrity tests or instance tests.
content_lennumber of expected input bytes
Returns
status
Here is the call graph for this function:
Here is the caller graph for this function:

◆ agt_restcmn_get_method()

yangapi_method_t agt_restcmn_get_method ( const xmlChar *  method)

Get the HTTP method enum from the string.

Parameters
methodmethod name string
Returns
method enumeration
Here is the call graph for this function:
Here is the caller graph for this function:

◆ agt_restcmn_get_nsid()

xmlns_id_t agt_restcmn_get_nsid ( ncx_protocol_t  proto)

Get the XML namespace ID for specific proto.

Parameters
protoprotocol to use
Returns
XML namespace ID
Here is the call graph for this function:
Here is the caller graph for this function:

◆ agt_restcmn_get_operations()

status_t agt_restcmn_get_operations ( ses_cb_t scb,
getcb_mode_t  cbmode,
const val_value_t virval,
val_value_t dstval 
)

GET1 operation handler for the /operations container.

Parameters
scbsession that issued the get (may be NULL) can be used for access control purposes
cbmodereason for the callback
virvalplace-holder node in the data model for this virtual value node
[out]dstvalpointer to value output struct
*dstval should be filled in, depending on the callback reason
Returns
status
Here is the call graph for this function:

◆ agt_restcmn_get_param()

xmlChar * agt_restcmn_get_param ( yangapi_cb_t rcb,
const xmlChar *  name,
boolean *  found 
)

Find a query parameter and return its value.

Parameters
rcbrestapi request control block to use
nameparam name to find
[out]foundaddress of return found flag
*found TRUE if parameter found
Returns
back pointer to param value if found, NULL if not found
The value is allowed to be NULL (empty string) so the found flag is needed
Here is the call graph for this function:
Here is the caller graph for this function:

◆ agt_restcmn_make_uri()

xmlChar * agt_restcmn_make_uri ( ses_cb_t scb,
const xmlChar *  target,
const xmlChar *  edit_target 
)

Make a URI string.

Append the DB-API/YANG-PATCH edit target to the datastore entry point

Parameters
scbsession control block to use
targetURI path target string
edit_targetrelative path string to concatenate to target
Returns
malloced string; must free with m__free
Here is the call graph for this function:
Here is the caller graph for this function:

◆ agt_restcmn_method_is_read()

boolean agt_restcmn_method_is_read ( yangapi_method_t  method)

Check if this is a read method.

Parameters
methodenum to check
Returns
TRUE if some sort of read or FALSE if some sort of write
Here is the caller graph for this function:

◆ agt_restcmn_new_config_wrapper()

val_value_t * agt_restcmn_new_config_wrapper ( void  )

Create a <config> wrapper val and return it.

Returns
malloced and initialized val_value_t
must be freed with val_free_value
Here is the call graph for this function:

◆ agt_restcmn_obj_error()

void agt_restcmn_obj_error ( ses_cb_t scb,
xml_msg_hdr_t mhdr,
status_t  res,
obj_template_t errobj,
const xmlChar *  badval 
)

Record an rpc-error for YANG-API/RESTCONF response translation.

Parameters
scbsession control block to use
mhdrmessage header to use
reserror status code
errobjobject node in API schema tree or data schema tree associated with the error
badvalerror-info node to use
Here is the call graph for this function:
Here is the caller graph for this function:

◆ agt_restcmn_operation_supports_json()

boolean agt_restcmn_operation_supports_json ( obj_template_t rpcobj)

Check if the NETCONF operation supports JSON output.

Hack until JSON output fully supported

Parameters
rpcobjRPC template to check
Returns
TRUE if JSON output allowed
FALSE if not supported yet
Here is the call graph for this function:
Here is the caller graph for this function:

◆ agt_restcmn_parse_fragment()

status_t agt_restcmn_parse_fragment ( yangapi_cb_t rcb,
xmlChar *  uri,
uint32 *  retlen 
)

parse the request URI fragment

Parameters
rcbrestapi control block to use
urirequest URI string to use
[out]retlenaddress of return byte count parsed
*retlen byte count of uri parsed
Returns
status
Here is the call graph for this function:

◆ agt_restcmn_parse_path()

status_t agt_restcmn_parse_path ( ses_cb_t scb,
rpc_msg_t msg,
yangapi_cb_t rcb,
val_value_t root,
const xmlChar *  path 
)

parse the request URI path

fill in rcb->request_tree and set request_launch if needed fill in request_target_obj if the target does not exist, such as a new transaction

Parameters
scbsession control block to use
msgmessage to record errors
[in,out]rcbrestapi control block to use
  • rcb->request_launch set if the path uses a root or rpc-root
  • rcb->request_top_data set if the path uses a root and includes at least 1 top-level YANG data node
  • rcb->request_terminal set the the path leaves the data tree to specify a new node, which will be set in request_target_obj
  • rcb->request_target set (back-ptr, do not free)
  • rcb->request_target_obj set (back-ptr, do not free)
rootcontext to use for parse root
pathYANG-API or RESTCONF path string to use
Returns
status
Here is the call graph for this function:

◆ agt_restcmn_parse_query_string()

status_t agt_restcmn_parse_query_string ( ses_cb_t scb,
rpc_msg_t msg,
yangapi_cb_t rcb,
xmlChar *  uri,
uint32 *  retlen 
)

parse the request URI query string

Parameters
scbsession control block to use
msgmessage to use to record errors
rcbrestapi control block to use
urirequest URI string to use
[out]retlenaddress of return byte count parsed
*retlen byte count of uri parsed
Returns
status
Here is the call graph for this function:

◆ agt_restcmn_print_debug_line()

void agt_restcmn_print_debug_line ( ses_cb_t scb,
yangapi_cb_t rcb 
)

Print the message received debug line.

Parameters
scbsession control block to use
rcbrestapi control block to use
Here is the call graph for this function:
Here is the caller graph for this function:

◆ agt_restcmn_record_error()

void agt_restcmn_record_error ( ses_cb_t scb,
xml_msg_hdr_t mhdr,
status_t  res,
val_value_t errnode,
const xmlChar *  badval 
)

Record an rpc-error for YANG-API/RESTCONF response translation.

Parameters
scbsession control block to use
mhdrxml_msg_hdr_t to use
reserror status code
errnodenode in API tree or data tree associated with the error
badvalerror-info string to use
Here is the call graph for this function:
Here is the caller graph for this function:

◆ agt_restcmn_record_error_errinfo()

void agt_restcmn_record_error_errinfo ( ses_cb_t scb,
xml_msg_hdr_t mhdr,
status_t  res,
val_value_t errnode,
const xmlChar *  badval,
const ncx_errinfo_t errinfo 
)

Record an rpc-error for YANG-API/RESTCONF response translation.

Add errinfo struct if present

Parameters
scbsession control block to use
mhdrxml_msg_hdr_t to use
reserror status code
errnodenode in API tree or data tree associated with the error
badvalerror-info string to use
errinfoncx_errinfo_t struct to use
Here is the call graph for this function:
Here is the caller graph for this function:

◆ agt_restcmn_record_obj_error()

void agt_restcmn_record_obj_error ( ses_cb_t scb,
rpc_msg_t msg,
status_t  res,
obj_template_t errobj,
const xmlChar *  badval 
)

Record an rpc-error for YANG-API/RESTCONF response translation the error node is an object, not a value node.

Parameters
scbsession control block to use
msgrpc_msg_t to use
reserror status code
errobjobject node in API schema tree or data schema tree associated with the error
badvalerror-info node to use
Here is the call graph for this function:
Here is the caller graph for this function:

◆ agt_restcmn_set_content_encoding()

status_t agt_restcmn_set_content_encoding ( ses_cb_t scb,
yangapi_cb_t rcb,
rpc_msg_t msg 
)

Get the content encoding used.

IN Encoding validation for RESTCONF/YANG-API is the same and based on Content-Type header value

OUT encoding is set here for YANG-API only RESTCONF utilize Accept-header entries for the OUT encoding

All errors will be generated in this function if any

Parameters
scbsession control block to use
rcbrestapi control block to use
msgmessage control block in progress
Returns
status
Here is the call graph for this function:
Here is the caller graph for this function:

◆ agt_restcmn_setup_launch_point()

void agt_restcmn_setup_launch_point ( yangapi_cb_t rcb)

check the parseed request URI path set the API launch point data

Parameters
[in,out]rcbrestapi control block to use
  • rcb->request_launch set
  • rcb->request_launchpt set
Here is the call graph for this function:

◆ agt_restcmn_setup_notifications()

status_t agt_restcmn_setup_notifications ( ses_cb_t scb,
yangapi_cb_t rcb,
rpc_msg_t msg 
)

setup the notification delivery on this GET request

TEMP: harndwired to NETCONF stream; no parameters supported

Parameters
scbsession control block to use
rcbrestapi control block to use
msgmessage to record errors
Returns
status
Here is the call graph for this function:
Here is the caller graph for this function:

◆ agt_restcmn_setup_read_params()

status_t agt_restcmn_setup_read_params ( ses_cb_t scb,
yangapi_cb_t rcb,
rpc_msg_t msg 
)

Setup the message parameters from the yangapi_cb values.

Records errors! Do not duplicate!

Parameters
scbsession control block to use
[in,out]rcbrestapi control block to use
rcb->skip_read may be set
[in,out]msgmessage to record errors
msg->mhdr fields set as needed
Returns
status
Here is the call graph for this function:
Here is the caller graph for this function:

◆ agt_restcmn_val_error()

void agt_restcmn_val_error ( ses_cb_t scb,
xml_msg_hdr_t mhdr,
status_t  res,
val_value_t errval,
const xmlChar *  badval 
)

Record an rpc-error for YANG-API/RESTCONF response translation.

Parameters
scbsession control block to use
mhdrmessage header to use
reserror status code
errvalvalue node in API schema tree or data schema tree associated with the error
badvalerror-info node to use
Here is the call graph for this function:

◆ agt_restcmn_validate_accept_header()

boolean agt_restcmn_validate_accept_header ( ses_cb_t scb,
yangapi_cb_t rcb,
rpc_msg_t msg,
boolean  error_recorded,
status_t res 
)

Validate the client Accept header.

If no Accept header field is present, then it is assumed that the client accepts all media types. The default values for the format will be set by dispath() fn Media types validation will be skiiped.

If an Accept header field is present, and if the server cannot send a response which is acceptable according to the combined Accept field value, then the server SHOULD send a 406 (not acceptable) response. RFC2616::section-14.1

If Errors media type has valid format, this format will be used for OUT Encoding if any error occur during validation or later/before.

All errors will be generated in this function

Parameters
scbsession to use
[in,out]rcbrestapi control block to use
  • rcb->accept_format is set based on +format entry in the header
  • rcb->accept_submedia is set if submedia is present in the header entry
msgmessage control block in progress
error_recordedif TRUE, try to find app/yang.error media type in the header. If it's present, set the format of outgoing error messages to that value, and skip any other validations
if FALSE, no any errors previously recorded, full validatations
[out]resaddress of return status; *res return status
Returns
TRUE if accept header is valid and accepted
FALSE, if the haeder is invalid
Here is the call graph for this function:
Here is the caller graph for this function:

◆ agt_restcmn_validate_method()

status_t agt_restcmn_validate_method ( ses_cb_t scb,
yangapi_cb_t rcb,
rpc_msg_t msg 
)

validate that the method is supported for the URI given.

validate that the query parameters given are allowed for this operation.

Errors are recorded by this function. Do not call record_error again if error returned

Parameters
scbsession control block to use
rcbrestapi control block to use
msgmsg to use for storing error records
Returns
status
Here is the call graph for this function:
Here is the caller graph for this function:

◆ agt_restcmn_validate_query_string()

status_t agt_restcmn_validate_query_string ( ses_cb_t scb,
rpc_msg_t msg,
yangapi_cb_t rcb 
)

Validate the parameters in the request URI query string.

Errors are recorded by this function

Parameters
scbsession control block to use
msgmsg to use for recording errors
[in,out]rcbrestapi request control block to use
rcb->query_* fields will be filled in
Returns
status
Here is the call graph for this function:

◆ get_active_root()

val_value_t * get_active_root ( yangapi_cb_t rcb)

Select the active CFG and return its root val.

Parameters
rcbrestapi control block to use
Return values
val_valueof the active root value
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_launchpoint_name()

const xmlChar * get_launchpoint_name ( yangapi_launchpt_t  launchpt)

Get the keyword for the specified launchpt.

Parameters
launchptlaunchpt ID
Returns
string for the launchpt, or "none" or "illegal"