blob: 8162b6499a9a9b218792d4ec22ab32e377cedd57 [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();
29 static std::unique_ptr<Session> viaSSH(const std::string& host, const uint16_t port, const std::string& user);
30 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);
31 static std::unique_ptr<Session> connectSocket(const std::string& path);
32 std::vector<std::string_view> capabilities() const;
33 std::shared_ptr<libyang::Data_Node> getConfig(const NC_DATASTORE datastore,
34 const std::optional<const std::string> filter = std::nullopt); // TODO: arguments...
35 std::shared_ptr<libyang::Data_Node> get(const std::string& filter);
36 std::string getSchema(const std::string_view identifier, const std::optional<std::string_view> version);
37 void editConfig(const NC_DATASTORE datastore,
38 const NC_RPC_EDIT_DFLTOP defaultOperation,
39 const NC_RPC_EDIT_TESTOPT testOption,
40 const NC_RPC_EDIT_ERROPT errorOption,
41 const std::string& data);
42 void copyConfigFromString(const NC_DATASTORE target, const std::string& data);
43 void commit();
44 void discard();
45 struct nc_session* session_internal(); // FIXME: remove me
46protected:
47 struct nc_session* m_session;
48};
49}
50}