yumapro
24.10-1
YumaPro SDK
|
HTTP APIs for RESTCONF Protocol Support. More...
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... | |
yangapi_param_t * | agt_restcmn_get_first_param (yangapi_cb_t *rcb) |
Get the first query parameter entry from the parameter queue. More... | |
yangapi_param_t * | agt_restcmn_get_next_param (yangapi_param_t *param) |
Get the next query parameter entry from the parameter queue. 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_t * | agt_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_t * | agt_restcmn_get_active_root (yangapi_cb_t *rcb) |
Select the active CFG and return its root val. More... | |
HTTP APIs for RESTCONF Protocol Support.
Routines common to YANG-API and RESTCONF. YANG-API is obsolete and no longer supported
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.
scb | RESTCONF session |
msg | request message in progress |
rcb | restapi control block to use |
status |
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
scb | session control block to use | |
rcb | restapi control block to use | |
[in,out] | msg | message to use for storing error records msg hdr errors set as needed |
parmname | parameter to check |
boolean agt_restcmn_check_unmodified_return | ( | yangapi_cb_t * | rcb | ) |
Check if the context node(s) will match the filters (if any)
rcb | restapi control block to use |
xmlChar * agt_restcmn_decode_url | ( | const xmlChar * | url, |
status_t * | res | ||
) |
Decode URL encoded string value into string.
url | URL string | |
[out] | res | address of return status; *res return status |
const xmlChar * agt_restcmn_entry_point | ( | void | ) |
Get the RESTCONF entry point name.
void agt_restcmn_free_msg | ( | rpc_msg_t * | msg | ) |
val_value_t * agt_restcmn_get_active_root | ( | yangapi_cb_t * | rcb | ) |
Select the active CFG and return its root val.
rcb | restapi control block to use |
val_value | of the active root value |
boolean agt_restcmn_get_config_parm | ( | yangapi_cb_t * | rcb, |
val_value_t * | context_node | ||
) |
Get the value of the config parm to use.
rcb | restapi control block to use |
context_node | XPath context node to check |
int agt_restcmn_get_content_len | ( | yangapi_cb_t * | rcb | ) |
Get the content length for the input request message body.
rcb | restapi control block to use |
yangapi_param_t * agt_restcmn_get_first_param | ( | yangapi_cb_t * | rcb | ) |
Get the first query parameter entry from the parameter queue.
rcb | restapi request control block to use |
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.
scb | session to use | |
rcb | restapi control block to use | |
[in,out] | msg | message 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_len | number of expected input bytes |
yangapi_method_t agt_restcmn_get_method | ( | const xmlChar * | method | ) |
Get the HTTP method enum from the string.
method | method name string |
yangapi_param_t * agt_restcmn_get_next_param | ( | yangapi_param_t * | param | ) |
Get the next query parameter entry from the parameter queue.
param | current yangapi_param_t entry |
xmlns_id_t agt_restcmn_get_nsid | ( | ncx_protocol_t | proto | ) |
Get the XML namespace ID for specific proto.
proto | protocol to use |
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.
scb | session that issued the get (may be NULL) can be used for access control purposes | |
cbmode | reason for the callback | |
virval | place-holder node in the data model for this virtual value node | |
[out] | dstval | pointer to value output struct *dstval should be filled in, depending on the callback reason |
xmlChar * agt_restcmn_get_param | ( | yangapi_cb_t * | rcb, |
const xmlChar * | name, | ||
boolean * | found | ||
) |
Find a query parameter and return its value.
rcb | restapi request control block to use | |
name | param name to find | |
[out] | found | address of return found flag *found TRUE if parameter found |
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
scb | session control block to use |
target | URI path target string |
edit_target | relative path string to concatenate to target |
boolean agt_restcmn_method_is_read | ( | yangapi_method_t | method | ) |
Check if this is a read method.
method | enum to check |
val_value_t * agt_restcmn_new_config_wrapper | ( | void | ) |
Create a <config> wrapper val and return it.
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.
scb | session control block to use |
mhdr | message header to use |
res | error status code |
errobj | object node in API schema tree or data schema tree associated with the error |
badval | error-info node to use |
boolean agt_restcmn_operation_supports_json | ( | obj_template_t * | rpcobj | ) |
Check if the NETCONF operation supports JSON output.
Hack until JSON output fully supported
rpcobj | RPC template to check |
status_t agt_restcmn_parse_fragment | ( | yangapi_cb_t * | rcb, |
xmlChar * | uri, | ||
uint32 * | retlen | ||
) |
parse the request URI fragment
rcb | restapi control block to use | |
uri | request URI string to use | |
[out] | retlen | address of return byte count parsed *retlen byte count of uri parsed |
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
scb | session control block to use | |
msg | message to record errors | |
[in,out] | rcb | restapi control block to use
|
root | context to use for parse root | |
path | YANG-API or RESTCONF path string to use |
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
scb | session control block to use | |
msg | message to use to record errors | |
rcb | restapi control block to use | |
uri | request URI string to use | |
[out] | retlen | address of return byte count parsed *retlen byte count of uri parsed |
void agt_restcmn_print_debug_line | ( | ses_cb_t * | scb, |
yangapi_cb_t * | rcb | ||
) |
Print the message received debug line.
scb | session control block to use |
rcb | restapi control block to use |
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.
scb | session control block to use |
mhdr | xml_msg_hdr_t to use |
res | error status code |
errnode | node in API tree or data tree associated with the error |
badval | error-info string to use |
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
scb | session control block to use |
mhdr | xml_msg_hdr_t to use |
res | error status code |
errnode | node in API tree or data tree associated with the error |
badval | error-info string to use |
errinfo | ncx_errinfo_t struct to use |
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.
scb | session control block to use |
msg | rpc_msg_t to use |
res | error status code |
errobj | object node in API schema tree or data schema tree associated with the error |
badval | error-info node to use |
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
scb | session control block to use |
rcb | restapi control block to use |
msg | message control block in progress |
void agt_restcmn_setup_launch_point | ( | yangapi_cb_t * | rcb | ) |
check the parseed request URI path set the API launch point data
[in,out] | rcb | restapi control block to use
|
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
scb | session control block to use |
rcb | restapi control block to use |
msg | message to record errors |
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!
scb | session control block to use | |
[in,out] | rcb | restapi control block to use rcb->skip_read may be set |
[in,out] | msg | message to record errors msg->mhdr fields set as needed |
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.
scb | session control block to use |
mhdr | message header to use |
res | error status code |
errval | value node in API schema tree or data schema tree associated with the error |
badval | error-info node to use |
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
scb | session to use | |
[in,out] | rcb | restapi control block to use
|
msg | message control block in progress | |
error_recorded | if 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] | res | address of return status; *res return status |
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
scb | session control block to use |
rcb | restapi control block to use |
msg | msg to use for storing error records |
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
scb | session control block to use | |
msg | msg to use for recording errors | |
[in,out] | rcb | restapi request control block to use rcb->query_* fields will be filled in |
const xmlChar * get_launchpoint_name | ( | yangapi_launchpt_t | launchpt | ) |
Get the keyword for the specified launchpt.
launchpt | launchpt ID |