netconf-client: unify filtering API between <get> and <get-config>
Change-Id: I2762cfbdc8d29b5adde5aee9ba14ea9bad6fef06
diff --git a/src/netconf-client.cpp b/src/netconf-client.cpp
index 8f0e2ec..3ced537 100644
--- a/src/netconf-client.cpp
+++ b/src/netconf-client.cpp
@@ -276,9 +276,9 @@
return res;
}
-std::shared_ptr<libyang::Data_Node> Session::get(const std::string& filter)
+std::shared_ptr<libyang::Data_Node> Session::get(const std::optional<std::string>& filter)
{
- auto rpc = impl::guarded(nc_rpc_get(filter.c_str(), NC_WD_ALL, NC_PARAMTYPE_CONST));
+ auto rpc = impl::guarded(nc_rpc_get(filter ? filter->c_str() : nullptr, NC_WD_ALL, NC_PARAMTYPE_CONST));
if (!rpc) {
throw std::runtime_error("Cannot create get RPC");
}
diff --git a/src/netconf-client.h b/src/netconf-client.h
index b9a1925..6d57e01 100644
--- a/src/netconf-client.h
+++ b/src/netconf-client.h
@@ -35,7 +35,7 @@
std::vector<std::string_view> capabilities() const;
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::string& filter);
+ std::shared_ptr<libyang::Data_Node> get(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,