NetconfAccess: Use <edit-data> instead of <edit-config>

We're already using <get-data>, so it makes sense to do this. It also
makes it easier to work with datastores, because it uses the NMDA
datastores.

Change-Id: Ie4d5acdf45e1394ea3c0c0398384e855a53b4500
diff --git a/src/netconf-client.cpp b/src/netconf-client.cpp
index 8cf034e..4638bcb 100644
--- a/src/netconf-client.cpp
+++ b/src/netconf-client.cpp
@@ -314,6 +314,8 @@
         return "ietf-datastores:startup";
     case NmdaDatastore::Running:
         return "ietf-datastores:running";
+    case NmdaDatastore::Candidate:
+        return "ietf-datastores:candidate";
     case NmdaDatastore::Operational:
         return "ietf-datastores:operational";
     }
@@ -329,6 +331,15 @@
     return impl::do_get(this, std::move(rpc));
 }
 
+void Session::editData(const NmdaDatastore datastore, const std::string& data)
+{
+    auto rpc = impl::guarded(nc_rpc_editdata(datastoreToString(datastore), NC_RPC_EDIT_DFLTOP_MERGE, data.c_str(), NC_PARAMTYPE_CONST));
+    if (!rpc) {
+        throw std::runtime_error("Cannot create get RPC");
+    }
+    return impl::do_rpc_ok(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 0794958..839c528 100644
--- a/src/netconf-client.hpp
+++ b/src/netconf-client.hpp
@@ -20,6 +20,7 @@
 enum class NmdaDatastore {
     Startup,
     Running,
+    Candidate,
     Operational
 };
 namespace client {
@@ -55,6 +56,7 @@
                     const NC_RPC_EDIT_TESTOPT testOption,
                     const NC_RPC_EDIT_ERROPT errorOption,
                     const std::string& data);
+    void editData(const NmdaDatastore datastore, const std::string& data);
     void copyConfigFromString(const NC_DATASTORE target, const std::string& data);
     std::shared_ptr<libyang::Data_Node> rpc_or_action(const std::string& xmlData);
     void copyConfig(const NC_DATASTORE source, const NC_DATASTORE destination);
diff --git a/src/netconf_access.cpp b/src/netconf_access.cpp
index 4709431..ecd337e 100644
--- a/src/netconf_access.cpp
+++ b/src/netconf_access.cpp
@@ -119,7 +119,7 @@
 void NetconfAccess::doEditFromDataNode(std::shared_ptr<libyang::Data_Node> dataNode)
 {
     auto data = dataNode->print_mem(LYD_XML, 0);
-    m_session->editConfig(NC_DATASTORE_CANDIDATE, NC_RPC_EDIT_DFLTOP_MERGE, NC_RPC_EDIT_TESTOPT_TESTSET, NC_RPC_EDIT_ERROPT_STOP, data);
+    m_session->editData(libnetconf::NmdaDatastore::Candidate, data);
 }
 
 void NetconfAccess::commitChanges()