Fawkes API  Fawkes Development Version
Service.h
1 
2 /****************************************************************************
3  * BackendInfo -- Schema Service
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 <rapidjson/fwd.h>
18 
19 #include <cstdint>
20 #include <memory>
21 #include <optional>
22 #include <string>
23 #include <vector>
24 
25 /** Service representation for JSON transfer. */
26 class Service
27 
28 {
29 public:
30  /** Constructor. */
31  Service();
32  /** Constructor from JSON.
33  * @param json JSON string to initialize from
34  */
35  Service(const std::string &json);
36  /** Constructor from JSON.
37  * @param v RapidJSON value object to initialize from.
38  */
39  Service(const rapidjson::Value &v);
40 
41  /** Destructor. */
42  virtual ~Service();
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: Service
87 public:
88  /** Get name value.
89  * @return name value
90  */
91  std::optional<std::string>
92  name() const
93  {
94  return name_;
95  }
96 
97  /** Set name value.
98  * @param name new value
99  */
100  void
101  set_name(const std::string &name)
102  {
103  name_ = name;
104  }
105  /** Get url value.
106  * @return url value
107  */
108  std::optional<std::string>
109  url() const
110  {
111  return url_;
112  }
113 
114  /** Set url value.
115  * @param url new value
116  */
117  void
118  set_url(const std::string &url)
119  {
120  url_ = url;
121  }
122 
123 private:
124  std::optional<std::string> name_;
125  std::optional<std::string> url_;
126 };
static std::string api_version()
Get version of implemented API.
Definition: Service.h:48
virtual void to_json_value(rapidjson::Document &d, rapidjson::Value &v) const
Render object to JSON.
Definition: Service.cpp:61
virtual void from_json(const std::string &json)
Retrieve data from JSON string.
Definition: Service.cpp:81
virtual void from_json_value(const rapidjson::Value &v)
Retrieve data from JSON string.
Definition: Service.cpp:90
virtual ~Service()
Destructor.
Definition: Service.cpp:37
void set_url(const std::string &url)
Set url value.
Definition: Service.h:118
virtual void validate(bool subcall=false) const
Validate if all required fields have been set.
Definition: Service.cpp:101
std::optional< std::string > url() const
Get url value.
Definition: Service.h:109
std::optional< std::string > name() const
Get name value.
Definition: Service.h:92
Service()
Constructor.
Definition: Service.cpp:23
virtual std::string to_json(bool pretty=false) const
Render object to JSON.
Definition: Service.cpp:42
Service representation for JSON transfer.
Definition: Service.h:26
void set_name(const std::string &name)
Set name value.
Definition: Service.h:101