Fawkes API Fawkes Development Version
Plugin.h
1
2/****************************************************************************
3 * Plugin -- Schema Plugin
4 * (auto-generated, do not modify directly)
5 *
6 * Fawkes Plugin REST API.
7 * List, load, and unload plugins.
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/** Plugin representation for JSON transfer. */
26class Plugin
27
28{
29public:
30 /** Constructor. */
31 Plugin();
32 /** Constructor from JSON.
33 * @param json JSON string to initialize from
34 */
35 Plugin(const std::string &json);
36 /** Constructor from JSON.
37 * @param v RapidJSON value object to initialize from.
38 */
39 Plugin(const rapidjson::Value &v);
40
41 /** Destructor. */
42 virtual ~Plugin();
43
44 /** Get version of implemented API.
45 * @return string representation of version
46 */
47 static std::string
49 {
50 return "v1beta1";
51 }
52
53 /** Render object to JSON.
54 * @param pretty true to enable pretty printing (readable spacing)
55 * @return JSON string
56 */
57 virtual std::string to_json(bool pretty = false) const;
58 /** Render object to JSON.
59 * @param d RapidJSON document to retrieve allocator from
60 * @param v RapidJSON value to add data to
61 */
62 virtual void to_json_value(rapidjson::Document &d, rapidjson::Value &v) const;
63 /** Retrieve data from JSON string.
64 * @param json JSON representation suitable for this object.
65 * Will allow partial assignment and not validate automaticaly.
66 * @see validate()
67 */
68 virtual void from_json(const std::string &json);
69 /** Retrieve data from JSON string.
70 * @param v RapidJSON value suitable for this object.
71 * Will allow partial assignment and not validate automaticaly.
72 * @see validate()
73 */
74 virtual void from_json_value(const rapidjson::Value &v);
75
76 /** Validate if all required fields have been set.
77 * @param subcall true if this is called from another class, e.g.,
78 * a sub-class or array holder. Will modify the kind of exception thrown.
79 * @exception std::vector<std::string> thrown if required information is
80 * missing and @p subcall is set to true. Contains a list of missing fields.
81 * @exception std::runtime_error informative message describing the missing
82 * fields
83 */
84 virtual void validate(bool subcall = false) const;
85
86 // Schema: Plugin
87public:
88 /** Get kind value.
89 * @return kind value
90 */
91 std::optional<std::string>
92 kind() const
93 {
94 return kind_;
95 }
96
97 /** Set kind value.
98 * @param kind new value
99 */
100 void
101 set_kind(const std::string &kind)
102 {
103 kind_ = kind;
104 }
105 /** Get apiVersion value.
106 * @return apiVersion value
107 */
108 std::optional<std::string>
110 {
111 return apiVersion_;
112 }
113
114 /** Set apiVersion value.
115 * @param apiVersion new value
116 */
117 void
118 set_apiVersion(const std::string &apiVersion)
119 {
120 apiVersion_ = apiVersion;
121 }
122 /** Get name value.
123 * @return name value
124 */
125 std::optional<std::string>
126 name() const
127 {
128 return name_;
129 }
130
131 /** Set name value.
132 * @param name new value
133 */
134 void
135 set_name(const std::string &name)
136 {
137 name_ = name;
138 }
139 /** Get description value.
140 * @return description value
141 */
142 std::optional<std::string>
144 {
145 return description_;
146 }
147
148 /** Set description value.
149 * @param description new value
150 */
151 void
152 set_description(const std::string &description)
153 {
154 description_ = description;
155 }
156 /** Get is_meta value.
157 * @return is_meta value
158 */
159 std::optional<bool>
160 is_meta() const
161 {
162 return is_meta_;
163 }
164
165 /** Set is_meta value.
166 * @param is_meta new value
167 */
168 void
169 set_is_meta(const bool &is_meta)
170 {
171 is_meta_ = is_meta;
172 }
173 /** Get meta_children value.
174 * @return meta_children value
175 */
176 std::vector<std::string>
178 {
179 return meta_children_;
180 }
181
182 /** Set meta_children value.
183 * @param meta_children new value
184 */
185 void
186 set_meta_children(const std::vector<std::string> &meta_children)
187 {
188 meta_children_ = meta_children;
189 }
190 /** Add element to meta_children array.
191 * @param meta_children new value
192 */
193 void
195 {
196 meta_children_.push_back(std::move(meta_children));
197 }
198
199 /** Add element to meta_children array.
200 * The move-semantics version (std::move) should be preferred.
201 * @param meta_children new value
202 */
203 void
205 {
206 meta_children_.push_back(meta_children);
207 }
208 /** Get is_loaded value.
209 * @return is_loaded value
210 */
211 std::optional<bool>
212 is_loaded() const
213 {
214 return is_loaded_;
215 }
216
217 /** Set is_loaded value.
218 * @param is_loaded new value
219 */
220 void
222 {
223 is_loaded_ = is_loaded;
224 }
225
226private:
227 std::optional<std::string> kind_;
228 std::optional<std::string> apiVersion_;
229 std::optional<std::string> name_;
230 std::optional<std::string> description_;
231 std::optional<bool> is_meta_;
232 std::vector<std::string> meta_children_;
233 std::optional<bool> is_loaded_;
234};
Plugin representation for JSON transfer.
Definition: Plugin.h:28
void set_is_loaded(const bool &is_loaded)
Set is_loaded value.
Definition: Plugin.h:221
std::optional< bool > is_loaded() const
Get is_loaded value.
Definition: Plugin.h:212
std::optional< bool > is_meta() const
Get is_meta value.
Definition: Plugin.h:160
void addto_meta_children(const std::string &&meta_children)
Add element to meta_children array.
Definition: Plugin.h:194
std::optional< std::string > kind() const
Get kind value.
Definition: Plugin.h:92
void addto_meta_children(const std::string &meta_children)
Add element to meta_children array.
Definition: Plugin.h:204
void set_kind(const std::string &kind)
Set kind value.
Definition: Plugin.h:101
virtual void from_json_value(const rapidjson::Value &v)
Retrieve data from JSON string.
Definition: Plugin.cpp:118
virtual void from_json(const std::string &json)
Retrieve data from JSON string.
Definition: Plugin.cpp:109
void set_apiVersion(const std::string &apiVersion)
Set apiVersion value.
Definition: Plugin.h:118
void set_is_meta(const bool &is_meta)
Set is_meta value.
Definition: Plugin.h:169
virtual void validate(bool subcall=false) const
Validate if all required fields have been set.
Definition: Plugin.cpp:150
virtual void to_json_value(rapidjson::Document &d, rapidjson::Value &v) const
Render object to JSON.
Definition: Plugin.cpp:61
Plugin()
Constructor.
Definition: Plugin.cpp:23
void set_name(const std::string &name)
Set name value.
Definition: Plugin.h:135
static std::string api_version()
Get version of implemented API.
Definition: Plugin.h:48
void set_description(const std::string &description)
Set description value.
Definition: Plugin.h:152
std::vector< std::string > meta_children() const
Get meta_children value.
Definition: Plugin.h:177
std::optional< std::string > name() const
Get name value.
Definition: Plugin.h:126
std::optional< std::string > apiVersion() const
Get apiVersion value.
Definition: Plugin.h:109
void set_meta_children(const std::vector< std::string > &meta_children)
Set meta_children value.
Definition: Plugin.h:186
std::optional< std::string > description() const
Get description value.
Definition: Plugin.h:143
virtual ~Plugin()
Destructor.
Definition: Plugin.cpp:37
virtual std::string to_json(bool pretty=false) const
Render object to JSON.
Definition: Plugin.cpp:42