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