blob: bd89e6bff4a0febd93e708cb14e457cce8d250dc [file] [log] [blame]
Václav Kubernátc31bd602019-03-07 11:44:48 +01001#pragma once
2
3#include <libnetconf2/messages_client.h>
4#include <memory>
5#include <optional>
6#include <string>
7#include <string_view>
8#include <vector>
9
10struct nc_session;
11
12namespace libyang {
13class Data_Node;
14}
15
16namespace libnetconf {
17namespace client {
18
19class ReportedError : public std::runtime_error {
20public:
21 ReportedError(const std::string& what);
22 ~ReportedError() override;
23};
24
25class Session {
26public:
27 Session(struct nc_session* session);
28 ~Session();
Václav Kubernátc31bd602019-03-07 11:44:48 +010029 static std::unique_ptr<Session> connectPubkey(const std::string& host, const uint16_t port, const std::string& user, const std::string& pubPath, const std::string& privPath);
30 static std::unique_ptr<Session> connectSocket(const std::string& path);
31 std::vector<std::string_view> capabilities() const;
32 std::shared_ptr<libyang::Data_Node> getConfig(const NC_DATASTORE datastore,
33 const std::optional<const std::string> filter = std::nullopt); // TODO: arguments...
34 std::shared_ptr<libyang::Data_Node> get(const std::string& filter);
35 std::string getSchema(const std::string_view identifier, const std::optional<std::string_view> version);
36 void editConfig(const NC_DATASTORE datastore,
37 const NC_RPC_EDIT_DFLTOP defaultOperation,
38 const NC_RPC_EDIT_TESTOPT testOption,
39 const NC_RPC_EDIT_ERROPT errorOption,
40 const std::string& data);
41 void copyConfigFromString(const NC_DATASTORE target, const std::string& data);
42 void commit();
43 void discard();
44 struct nc_session* session_internal(); // FIXME: remove me
45protected:
46 struct nc_session* m_session;
47};
48}
49}