Add <get-data> wrapper
Change-Id: Ie714681c9bd258e30b92884f14dce76bef99df1a
diff --git a/src/netconf-client.cpp b/src/netconf-client.cpp
index f1f7bb1..3f82414 100644
--- a/src/netconf-client.cpp
+++ b/src/netconf-client.cpp
@@ -307,6 +307,28 @@
return impl::do_get(this, std::move(rpc));
}
+const char* datastoreToString(NmdaDatastore datastore)
+{
+ switch (datastore) {
+ case NmdaDatastore::Startup:
+ return "ietf-datastores:startup";
+ case NmdaDatastore::Running:
+ return "ietf-datastores:running";
+ case NmdaDatastore::Operational:
+ return "ietf-datastores:operational";
+ }
+ __builtin_unreachable();
+}
+
+std::shared_ptr<libyang::Data_Node> Session::getData(const NmdaDatastore datastore, const std::optional<std::string>& filter)
+{
+ auto rpc = impl::guarded(nc_rpc_getdata(datastoreToString(datastore), filter ? filter->c_str() : nullptr, nullptr, nullptr, 0, 0, 0, 0, NC_WD_ALL, NC_PARAMTYPE_CONST));
+ if (!rpc) {
+ throw std::runtime_error("Cannot create get RPC");
+ }
+ return impl::do_get(this, std::move(rpc));
+}
+
std::string Session::getSchema(const std::string_view identifier, const std::optional<std::string_view> version)
{
auto rpc = impl::guarded(nc_rpc_getschema(identifier.data(), version ? version.value().data() : nullptr, nullptr, NC_PARAMTYPE_CONST));
diff --git a/src/netconf-client.hpp b/src/netconf-client.hpp
index 6bf4169..0794958 100644
--- a/src/netconf-client.hpp
+++ b/src/netconf-client.hpp
@@ -17,6 +17,11 @@
}
namespace libnetconf {
+enum class NmdaDatastore {
+ Startup,
+ Running,
+ Operational
+};
namespace client {
class ReportedError : public std::runtime_error {
@@ -43,6 +48,7 @@
std::shared_ptr<libyang::Data_Node> getConfig(const NC_DATASTORE datastore,
const std::optional<const std::string> filter = std::nullopt); // TODO: arguments...
std::shared_ptr<libyang::Data_Node> get(const std::optional<std::string>& filter = std::nullopt);
+ std::shared_ptr<libyang::Data_Node> getData(const NmdaDatastore datastore, const std::optional<std::string>& filter = std::nullopt);
std::string getSchema(const std::string_view identifier, const std::optional<std::string_view> version);
void editConfig(const NC_DATASTORE datastore,
const NC_RPC_EDIT_DFLTOP defaultOperation,