Fawkes API Fawkes Development Version
ConfigTree.h
1
2/****************************************************************************
3 * Configuration -- Schema ConfigTree
4 * (auto-generated, do not modify directly)
5 *
6 * Fawkes Configuration REST API.
7 * Retrieve information from the configuration.
8 *
9 * API Contact: Tim Niemueller <niemueller@kbsg.rwth-aachen.de>
10 * API Version: v1beta1
11 * API License: Apache 2.0
12 ****************************************************************************/
13
14#pragma once
15
16#define RAPIDJSON_HAS_STDSTRING 1
17#include <rapidjson/fwd.h>
18
19#include <cstdint>
20#include <memory>
21#include <optional>
22#include <string>
23#include <vector>
24
25/** ConfigTree representation for JSON transfer. */
27
28{
29public:
30 /** Constructor. */
31 ConfigTree();
32 /** Constructor from JSON.
33 * @param json JSON string to initialize from
34 */
35 ConfigTree(const std::string &json);
36 /** Constructor from JSON.
37 * @param v RapidJSON value object to initialize from.
38 */
39 ConfigTree(const rapidjson::Value &v);
40
41 /** Get version of implemented API.
42 * @return string representation of version
43 */
44 static std::string
46 {
47 return "v1beta1";
48 }
49
50 /** Render object to JSON.
51 * @param pretty true to enable pretty printing (readable spacing)
52 * @return JSON string
53 */
54 virtual std::string to_json(bool pretty = false) const;
55 /** Render object to JSON.
56 * @param d RapidJSON document to retrieve allocator from
57 * @param v RapidJSON value to add data to
58 */
59 virtual void to_json_value(rapidjson::Document &d, rapidjson::Value &v) const;
60 /** Retrieve data from JSON string.
61 * @param json JSON representation suitable for this object.
62 * Will allow partial assignment and not validate automaticaly.
63 * @see validate()
64 */
65 virtual void from_json(const std::string &json);
66 /** Retrieve data from JSON string.
67 * @param v RapidJSON value suitable for this object.
68 * Will allow partial assignment and not validate automaticaly.
69 * @see validate()
70 */
71 virtual void from_json_value(const rapidjson::Value &v);
72
73 /** Validate if all required fields have been set.
74 * @param subcall true if this is called from another class, e.g.,
75 * a sub-class or array holder. Will modify the kind of exception thrown.
76 * @exception std::vector<std::string> thrown if required information is
77 * missing and @p subcall is set to true. Contains a list of missing fields.
78 * @exception std::runtime_error informative message describing the missing
79 * fields
80 */
81 virtual void validate(bool subcall = false) const;
82
83 // Schema: ConfigTree
84public:
85 /** Get kind value.
86 * @return kind value
87 */
88 std::optional<std::string>
89 kind() const
90 {
91 return kind_;
92 }
93
94 /** Set kind value.
95 * @param kind new value
96 */
97 void
98 set_kind(const std::string &kind)
99 {
100 kind_ = kind;
101 }
102 /** Get apiVersion value.
103 * @return apiVersion value
104 */
105 std::optional<std::string>
107 {
108 return apiVersion_;
109 }
110
111 /** Set apiVersion value.
112 * @param apiVersion new value
113 */
114 void
115 set_apiVersion(const std::string &apiVersion)
116 {
117 apiVersion_ = apiVersion;
118 }
119 /** Get config value.
120 * @return config value
121 */
122 std::shared_ptr<rapidjson::Document>
123 config() const
124 {
125 return config_;
126 }
127
128 /** Set config value.
129 * @param config new value
130 */
131 void
132 set_config(const std::shared_ptr<rapidjson::Document> &config)
133 {
134 config_ = config;
135 }
136
137private:
138 std::optional<std::string> kind_;
139 std::optional<std::string> apiVersion_;
140 std::shared_ptr<rapidjson::Document> config_;
141};
ConfigTree representation for JSON transfer.
Definition: ConfigTree.h:28
virtual void from_json_value(const rapidjson::Value &v)
Retrieve data from JSON string.
Definition: ConfigTree.cpp:89
ConfigTree()
Constructor.
Definition: ConfigTree.cpp:23
std::optional< std::string > apiVersion() const
Get apiVersion value.
Definition: ConfigTree.h:106
virtual void validate(bool subcall=false) const
Validate if all required fields have been set.
Definition: ConfigTree.cpp:104
static std::string api_version()
Get version of implemented API.
Definition: ConfigTree.h:45
void set_apiVersion(const std::string &apiVersion)
Set apiVersion value.
Definition: ConfigTree.h:115
void set_kind(const std::string &kind)
Set kind value.
Definition: ConfigTree.h:98
std::shared_ptr< rapidjson::Document > config() const
Get config value.
Definition: ConfigTree.h:123
std::optional< std::string > kind() const
Get kind value.
Definition: ConfigTree.h:89
void set_config(const std::shared_ptr< rapidjson::Document > &config)
Set config value.
Definition: ConfigTree.h:132
virtual std::string to_json(bool pretty=false) const
Render object to JSON.
Definition: ConfigTree.cpp:38
virtual void from_json(const std::string &json)
Retrieve data from JSON string.
Definition: ConfigTree.cpp:80
virtual void to_json_value(rapidjson::Document &d, rapidjson::Value &v) const
Render object to JSON.
Definition: ConfigTree.cpp:57