blob: 6e66eeae446ad030854f93a639f447e78f78ec4c [file] [log] [blame]
Václav Kubernát80aacc02018-08-22 17:41:54 +02001/*
2 * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/
3 * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/
4 *
5 * Written by Václav Kubernát <kubervac@fit.cvut.cz>
6 *
7*/
8
9#pragma once
10
11#include <string>
Václav Kubernát80aacc02018-08-22 17:41:54 +020012#include "datastore_access.hpp"
13
14/*! \class DatastoreAccess
15 * \brief Abstract class for accessing a datastore
16 */
17
Jan Kundrát68d4a2c2018-10-01 17:17:09 +020018namespace sysrepo {
Václav Kubernát80aacc02018-08-22 17:41:54 +020019class Connection;
20class Session;
Václav Kubernátbf9c6112019-11-04 16:03:35 +010021class Yang_Schema;
Jan Kundrát68d4a2c2018-10-01 17:17:09 +020022}
23
Václav Kubernáta6c5fff2018-09-07 15:16:25 +020024class Schema;
25class YangSchema;
Václav Kubernát80aacc02018-08-22 17:41:54 +020026
27class SysrepoAccess : public DatastoreAccess {
28public:
29 ~SysrepoAccess() override;
Václav Kubernát715c85c2020-04-14 01:46:08 +020030 SysrepoAccess(const std::string& appname, const Datastore datastore);
Jan Kundrátb331b552020-01-23 15:25:29 +010031 Tree getItems(const std::string& path) override;
Václav Kubernát80aacc02018-08-22 17:41:54 +020032 void setLeaf(const std::string& path, leaf_data_ value) override;
33 void createPresenceContainer(const std::string& path) override;
34 void deletePresenceContainer(const std::string& path) override;
Václav Kubernátf5f64f02019-03-19 17:15:47 +010035 void createListInstance(const std::string& path) override;
36 void deleteListInstance(const std::string& path) override;
Václav Kubernát5b8a8f32020-05-20 00:57:22 +020037 void createLeafListInstance(const std::string& path) override;
38 void deleteLeafListInstance(const std::string& path) override;
Václav Kubernátbf65dd72020-05-28 02:32:31 +020039 void moveItem(const std::string& source, std::variant<yang::move::Absolute, yang::move::Relative> move) override;
Jan Kundrát6ee84792020-01-24 01:43:36 +010040 Tree executeRpc(const std::string& path, const Tree& input) override;
Jan Kundrát77d9f612019-09-03 16:52:32 +020041
42 std::shared_ptr<Schema> schema() override;
Václav Kubernát80aacc02018-08-22 17:41:54 +020043
Václav Kubernát812ee282018-08-30 17:10:03 +020044 void commitChanges() override;
Václav Kubernát6d791432018-10-25 16:00:35 +020045 void discardChanges() override;
Václav Kubernát7160a132020-04-03 02:11:01 +020046 void copyConfig(const Datastore source, const Datastore destination) override;
Václav Kubernát812ee282018-08-30 17:10:03 +020047
Václav Kubernát80aacc02018-08-22 17:41:54 +020048private:
Václav Kubernátc15fe822020-06-04 11:28:39 +020049 std::vector<ListInstance> listInstances(const std::string& path) override;
Václav Kubernátc58e4aa2019-04-03 18:37:32 +020050 [[noreturn]] void reportErrors();
51
Jan Kundrát77d9f612019-09-03 16:52:32 +020052 std::string fetchSchema(const char* module, const char* revision, const char* submodule);
Václav Kubernátbf9c6112019-11-04 16:03:35 +010053 std::vector<std::shared_ptr<sysrepo::Yang_Schema>> listSchemas();
Jan Kundrát77d9f612019-09-03 16:52:32 +020054
Jan Kundrát68d4a2c2018-10-01 17:17:09 +020055 std::shared_ptr<sysrepo::Connection> m_connection;
56 std::shared_ptr<sysrepo::Session> m_session;
Václav Kubernáta6c5fff2018-09-07 15:16:25 +020057 std::shared_ptr<YangSchema> m_schema;
Václav Kubernát80aacc02018-08-22 17:41:54 +020058};