Václav Kubernát | c31bd60 | 2019-03-07 11:44:48 +0100 | [diff] [blame] | 1 | #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 | |
| 10 | struct nc_session; |
| 11 | |
| 12 | namespace libyang { |
| 13 | class Data_Node; |
| 14 | } |
| 15 | |
| 16 | namespace libnetconf { |
| 17 | namespace client { |
| 18 | |
| 19 | class ReportedError : public std::runtime_error { |
| 20 | public: |
| 21 | ReportedError(const std::string& what); |
| 22 | ~ReportedError() override; |
| 23 | }; |
| 24 | |
| 25 | class Session { |
| 26 | public: |
| 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 |
| 46 | protected: |
| 47 | struct nc_session* m_session; |
| 48 | }; |
| 49 | } |
| 50 | } |