![]() |
Kea 2.7.3
|
A translator class for converting a client class list between YANG and JSON. More...
#include <translator_class.h>
Public Member Functions | |
TranslatorClasses (sysrepo::Session session, const std::string &model) | |
Constructor. | |
virtual | ~TranslatorClasses ()=default |
Destructor. | |
isc::data::ElementPtr | getClasses (libyang::DataNode const &data_node) |
Translate client classes from YANG to JSON. | |
isc::data::ElementPtr | getClassesFromAbsoluteXpath (std::string const &xpath) |
Translate client classes from YANG to JSON. | |
void | setClasses (const std::string &xpath, isc::data::ConstElementPtr elem) |
Translate and set client classes from JSON to YANG. | |
![]() | |
TranslatorClass (sysrepo::Session session, const std::string &model) | |
Constructor. | |
virtual | ~TranslatorClass ()=default |
Destructor. | |
isc::data::ElementPtr | getClass (libyang::DataNode const &data_node) |
Translate a client class from YANG to JSON. | |
isc::data::ElementPtr | getClassFromAbsoluteXpath (std::string const &xpath) |
Translate a client class from YANG to JSON. | |
void | setClass (const std::string &xpath, isc::data::ConstElementPtr elem) |
Translate and set client class from JSON to YANG. | |
![]() | |
TranslatorOptionDataList (sysrepo::Session session, const std::string &model) | |
Constructor. | |
virtual | ~TranslatorOptionDataList ()=default |
Destructor. | |
isc::data::ConstElementPtr | getOptionDataList (libyang::DataNode const &data_node) |
Translate option data list from YANG to JSON. | |
isc::data::ConstElementPtr | getOptionDataListFromAbsoluteXpath (std::string const &xpath) |
Translate option data list from YANG to JSON. | |
void | setOptionDataList (const std::string &xpath, isc::data::ConstElementPtr elem) |
Translate and set option data list from JSON to YANG. | |
![]() | |
TranslatorOptionData (sysrepo::Session session, const std::string &model) | |
Constructor. | |
virtual | ~TranslatorOptionData ()=default |
Destructor. | |
isc::data::ElementPtr | getOptionData (libyang::DataNode const &data_node) |
Translate an option data from YANG to JSON. | |
isc::data::ElementPtr | getOptionDataFromAbsoluteXpath (std::string const &xpath) |
Translate an option data from YANG to JSON. | |
void | setOptionData (const std::string &xpath, isc::data::ConstElementPtr elem) |
Translate and set option data from JSON to YANG. | |
![]() | |
Translator (sysrepo::Session session, const std::string &model) | |
Constructor. | |
virtual | ~Translator ()=default |
Destructor. | |
template<typename T > | |
void | checkAndGet (isc::data::ElementPtr const &storage, libyang::DataNode const &data_node, std::string const &xpath, T translate) const |
Calls {translate} for the element found at {xpath} relative to {data_node} and sets the result in {storage} with the {xpath} key. | |
void | checkAndGetAndJsonifyLeaf (isc::data::ElementPtr &storage, libyang::DataNode const &data_node, const std::string &name) const |
Retrieves a child YANG data node identified by name from the given parent YANG container node, converts it from string to JSON and stores it in the specified storage. | |
template<typename T > | |
void | checkAndGetDiverging (isc::data::ElementPtr const &storage, libyang::DataNode const &data_node, std::string const &key, std::string const &xpath, T translate) const |
Calls {translate} for the element found at {xpath} relative to {data_node} and sets the result in {storage} with the {key} key. | |
void | checkAndGetDivergingLeaf (isc::data::ElementPtr &storage, libyang::DataNode const &data_node, std::string const &name, std::string const &yang_name) const |
Retrieves a child YANG data node identified by name from the given parent YANG container node and stores it in the specified storage. | |
void | checkAndGetLeaf (isc::data::ElementPtr &storage, libyang::DataNode const &data_node, std::string const &name) const |
Retrieves a child YANG data node identified by name from the given parent YANG container node and stores it in the specified storage. | |
void | checkAndSetDivergingLeaf (isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name, std::string const &yang_name, libyang::LeafBaseType const type) |
Get an element from given ElementPtr node and set it in sysrepo at given xpath. | |
void | checkAndSetLeaf (isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name, libyang::LeafBaseType const type) |
Get an element from given ElementPtr node and set it in sysrepo at given xpath. | |
void | checkAndSetLeafList (isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name, libyang::LeafBaseType const type) |
Get an element from given ElementPtr node and set it in sysrepo at given xpath as a leaf-list. | |
void | checkAndSetUserContext (isc::data::ConstElementPtr const &from, std::string const &xpath) |
Get an element from given ElementPtr node and set it in sysrepo at given xpath. | |
void | checkAndStringifyAndSetLeaf (isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name) |
Get an element from given ElementPtr node and set it in sysrepo at given xpath. | |
void | deleteItem (const std::string &xpath) |
Delete basic value from YANG. | |
libyang::DataNode | findXPath (std::string const &xpath) const |
Retrieves a YANG data node by xpath. | |
template<typename functor_t > | |
void | forAll (std::string const &xpath, functor_t f) const |
Run a function for a node and all its children. | |
std::optional< libyang::DataNode > | getData (std::string const &xpath) const |
Get a YANG data node found at the given absolute xpath. | |
isc::data::ElementPtr | getItem (libyang::DataNode const &data_node, std::string const &xpath) const |
Translate a basic value from YANG to JSON for a given xpath that is relative to the given source node. | |
isc::data::ElementPtr | getItemFromAbsoluteXpath (std::string const &xpath) const |
Translate a basic value from YANG to JSON for a given absolute xpath. | |
template<typename T > | |
isc::data::ElementPtr | getList (libyang::DataNode const &data_node, std::string const &xpath, T &t, isc::data::ElementPtr(T::*f)(libyang::DataNode const &)) const |
Retrieve a list as ElementPtr from sysrepo from a certain xpath. | |
void | getMandatoryDivergingLeaf (isc::data::ElementPtr &storage, libyang::DataNode const &data_node, std::string const &name, std::string const &yang_name) const |
Retrieves a child YANG data node identified by one name from the given parent YANG container node and stores it in the specified storage under a different name. | |
void | getMandatoryLeaf (isc::data::ElementPtr &storage, libyang::DataNode const &data_node, std::string const &name) const |
Retrieves a child YANG data node identified by name from the given parent YANG container node and stores it in the specified storage. | |
bool | schemaNodeExists (std::string const &xpath) const |
Checks whether a YANG node exists in the schema. | |
void | setItem (const std::string &xpath, isc::data::ConstElementPtr const elem, libyang::LeafBaseType const type) |
Translate and set basic value from JSON to YANG. | |
void | setMandatoryDivergingLeaf (isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name, std::string const &yang_name, libyang::LeafBaseType const type) |
Get an element from given ElementPtr node and set it in sysrepo at given xpath. | |
void | setMandatoryLeaf (isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name, libyang::LeafBaseType const type) |
Get an element from given ElementPtr node and set it in sysrepo at given xpath. | |
![]() | |
TranslatorOptionDefList (sysrepo::Session session, const std::string &model) | |
Constructor. | |
virtual | ~TranslatorOptionDefList ()=default |
Destructor. | |
isc::data::ConstElementPtr | getOptionDefList (libyang::DataNode const &data_node) |
Translate option definition list from YANG to JSON. | |
isc::data::ConstElementPtr | getOptionDefListFromAbsoluteXpath (std::string const &xpath) |
Translate option definition list from YANG to JSON. | |
void | setOptionDefList (const std::string &xpath, isc::data::ConstElementPtr elem) |
Translate and set option definition list from JSON to YANG. | |
![]() | |
TranslatorOptionDef (sysrepo::Session session, const std::string &model) | |
Constructor. | |
virtual | ~TranslatorOptionDef ()=default |
Destructor. | |
isc::data::ElementPtr | getOptionDef (libyang::DataNode const &data_node) |
Translate an option definition from YANG to JSON. | |
isc::data::ElementPtr | getOptionDefFromAbsoluteXpath (std::string const &xpath) |
Translate an option definition from YANG to JSON. | |
void | setOptionDef (const std::string &xpath, isc::data::ConstElementPtr elem) |
Translate and set option definition from JSON to YANG. | |
Protected Member Functions | |
isc::data::ElementPtr | getClassesKea (libyang::DataNode const &data_node) |
getClasses JSON for kea-dhcp[46]. | |
void | setClassesKea (const std::string &xpath, isc::data::ConstElementPtr elem) |
setClasses for kea-dhcp[46]. | |
![]() | |
isc::data::ElementPtr | getClassKea (libyang::DataNode const &data_node) |
getClass JSON for kea-dhcp[46]. | |
void | setClassKea (const std::string &xpath, isc::data::ConstElementPtr elem) |
setClass for kea-dhcp[46]. | |
![]() | |
isc::data::ConstElementPtr | getOptionDataListKea (libyang::DataNode const &data_node) |
getOptionDataList for kea-dhcp[46]. | |
void | setOptionDataListKea (const std::string &xpath, isc::data::ConstElementPtr elem) |
setOptionDataList for kea-dhcp[46]. | |
![]() | |
isc::data::ElementPtr | getOptionDataKea (libyang::DataNode const &data_node) |
getOptionData JSON for kea-dhcp[46]. | |
void | setOptionDataKea (const std::string &xpath, isc::data::ConstElementPtr elem) |
setOptionData for kea-dhcp[46]. | |
![]() | |
isc::data::ConstElementPtr | getOptionDefListKea (libyang::DataNode const &data_node) |
getOptionDefList implementation specific to kea-dhcp[46]-server models. | |
void | setOptionDefListKea (const std::string &xpath, isc::data::ConstElementPtr elem) |
setOptionDefList implementation specific to kea-dhcp[46]-server models. | |
![]() | |
isc::data::ElementPtr | getOptionDefKea (libyang::DataNode const &data_node) |
getOptionDef implementation specific to kea-dhcp[46]-server models. | |
void | setOptionDefKea (const std::string &xpath, isc::data::ConstElementPtr elem) |
setOptionDef implementation specific to kea-dhcp[46]-server models. | |
Additional Inherited Members | |
![]() | |
static isc::data::ElementPtr | translateFromYang (std::optional< libyang::DataNode > data_node) |
Translate basic value from the given YANG data node to JSON element. | |
static std::optional< std::string > | translateToYang (isc::data::ConstElementPtr const &elem, libyang::LeafBaseType const type) |
Translate basic value from JSON to YANG. | |
![]() | |
using | Deserializer |
Maps YANG types to functions that transform a YANG type into an ElementPtr. | |
using | Serializer |
Maps YANG types to functions that transform the string representation of an Element into a string that can be passed into Session::setItem(). | |
![]() | |
static std::string | decode64 (std::string const &input) |
Decode a YANG element of binary type to a string that can be stored in an Element::string JSON. | |
static std::string | encode64 (std::string const &input) |
Encode a string such that it can be stored in a YANG element of binary type. | |
static Deserializer | initializeDeserializer () |
Initializes the deserializer which is used to translate a YANG node to an ElementPtr. | |
static Serializer | initializeSerializer () |
Initializes the serializer which is used to translate the string value of an Element to a string that can be passed into Session::setItem(). | |
![]() | |
std::string | model_ |
The model. | |
sysrepo::Session | session_ |
The sysrepo session. | |
A translator class for converting a client class list between YANG and JSON.
Currently supports only kea-dhcp[46]-server. Ietf-dhcpv6-server does not define client class contents.
Definition at line 139 of file translator_class.h.
isc::yang::TranslatorClasses::TranslatorClasses | ( | sysrepo::Session | session, |
const std::string & | model ) |
Constructor.
session | Sysrepo session. |
model | Model name. |
Definition at line 147 of file translator_class.cc.
|
virtualdefault |
Destructor.
ElementPtr isc::yang::TranslatorClasses::getClasses | ( | libyang::DataNode const & | data_node | ) |
Translate client classes from YANG to JSON.
data_node | the YANG node representing the class |
NetconfError | when sysrepo raises an error. |
Definition at line 157 of file translator_class.cc.
References getClassesKea(), isc_throw, isc::yang::Translator::model_, and isc::Exception::what().
Referenced by getClassesFromAbsoluteXpath(), and isc::yang::TranslatorConfig::getServerKeaDhcpCommon().
ElementPtr isc::yang::TranslatorClasses::getClassesFromAbsoluteXpath | ( | std::string const & | xpath | ) |
Translate client classes from YANG to JSON.
xpath | The xpath of classes. |
NetconfError | when sysrepo raises an error. |
Definition at line 173 of file translator_class.cc.
References isc::yang::Translator::findXPath(), and getClasses().
|
protected |
getClasses JSON for kea-dhcp[46].
data_node | the YANG node representing the classes |
NetconfError | when sysrepo raises an error. |
Definition at line 182 of file translator_class.cc.
References isc::yang::TranslatorClass::getClass().
Referenced by getClasses().
void isc::yang::TranslatorClasses::setClasses | ( | const std::string & | xpath, |
isc::data::ConstElementPtr | elem ) |
Translate and set client classes from JSON to YANG.
xpath | The xpath of classes. |
elem | The JSON element. |
Definition at line 188 of file translator_class.cc.
References isc_throw, isc::yang::Translator::model_, setClassesKea(), and isc::Exception::what().
Referenced by isc::yang::TranslatorConfig::setServerKeaDhcpCommon().
|
protected |
setClasses for kea-dhcp[46].
xpath | The xpath of classes. |
elem | The JSON element. |
BadValue | on client class without name. |
Definition at line 205 of file translator_class.cc.
References isc_throw, and isc::yang::TranslatorClass::setClass().
Referenced by setClasses().