Fawkes API  Fawkes Development Version
Backend Class Reference

Backend representation for JSON transfer. More...

#include <Backend.h>

Public Member Functions

 Backend ()
 Constructor. More...
 
 Backend (const std::string &json)
 Constructor from JSON. More...
 
 Backend (const rapidjson::Value &v)
 Constructor from JSON. More...
 
virtual ~Backend ()
 Destructor. More...
 
virtual std::string to_json (bool pretty=false) const
 Render object to JSON. More...
 
virtual void to_json_value (rapidjson::Document &d, rapidjson::Value &v) const
 Render object to JSON. More...
 
virtual void from_json (const std::string &json)
 Retrieve data from JSON string. More...
 
virtual void from_json_value (const rapidjson::Value &v)
 Retrieve data from JSON string. More...
 
virtual void validate (bool subcall=false) const
 Validate if all required fields have been set. More...
 
std::optional< std::string > kind () const
 Get kind value. More...
 
void set_kind (const std::string &kind)
 Set kind value. More...
 
std::optional< std::string > apiVersion () const
 Get apiVersion value. More...
 
void set_apiVersion (const std::string &apiVersion)
 Set apiVersion value. More...
 
std::optional< std::string > id () const
 Get id value. More...
 
void set_id (const std::string &id)
 Set id value. More...
 
std::optional< std::string > name () const
 Get name value. More...
 
void set_name (const std::string &name)
 Set name value. More...
 
std::optional< std::string > url () const
 Get url value. More...
 
void set_url (const std::string &url)
 Set url value. More...
 
std::vector< std::shared_ptr< Service > > services () const
 Get services value. More...
 
void set_services (const std::vector< std::shared_ptr< Service >> &services)
 Set services value. More...
 
void addto_services (const std::shared_ptr< Service > &&services)
 Add element to services array. More...
 
void addto_services (const std::shared_ptr< Service > &services)
 Add element to services array. More...
 
void addto_services (const Service &&services)
 Add element to services array. More...
 

Static Public Member Functions

static std::string api_version ()
 Get version of implemented API. More...
 

Detailed Description

Backend representation for JSON transfer.

Definition at line 28 of file Backend.h.

Constructor & Destructor Documentation

◆ Backend() [1/3]

Backend::Backend ( )

Constructor.

Definition at line 23 of file Backend.cpp.

◆ Backend() [2/3]

Backend::Backend ( const std::string &  json)

Constructor from JSON.

Parameters
jsonJSON string to initialize from

Definition at line 27 of file Backend.cpp.

References from_json().

◆ Backend() [3/3]

Backend::Backend ( const rapidjson::Value &  v)

Constructor from JSON.

Parameters
vRapidJSON value object to initialize from.

Definition at line 32 of file Backend.cpp.

References from_json_value().

◆ ~Backend()

Backend::~Backend ( )
virtual

Destructor.

Definition at line 37 of file Backend.cpp.

Member Function Documentation

◆ addto_services() [1/3]

void Backend::addto_services ( const Service &&  services)
inline

Add element to services array.

Parameters
servicesnew value

Definition at line 214 of file Backend.h.

References services().

◆ addto_services() [2/3]

void Backend::addto_services ( const std::shared_ptr< Service > &&  services)
inline

Add element to services array.

Parameters
servicesnew value

Definition at line 196 of file Backend.h.

References services().

Referenced by BackendInfoRestApi::init().

◆ addto_services() [3/3]

void Backend::addto_services ( const std::shared_ptr< Service > &  services)
inline

Add element to services array.

The move-semantics version (std::move) should be preferred.

Parameters
servicesnew value

Definition at line 206 of file Backend.h.

References services().

◆ api_version()

static std::string Backend::api_version ( )
inlinestatic

Get version of implemented API.

Returns
string representation of version

Definition at line 50 of file Backend.h.

Referenced by BackendInfoRestApi::init().

◆ apiVersion()

std::optional<std::string> Backend::apiVersion ( ) const
inline

Get apiVersion value.

Returns
apiVersion value

Definition at line 111 of file Backend.h.

Referenced by set_apiVersion().

◆ from_json()

void Backend::from_json ( const std::string &  json)
virtual

Retrieve data from JSON string.

Parameters
jsonJSON representation suitable for this object. Will allow partial assignment and not validate automaticaly.
See also
validate()

Definition at line 104 of file Backend.cpp.

References from_json_value().

Referenced by Backend().

◆ from_json_value()

void Backend::from_json_value ( const rapidjson::Value &  v)
virtual

Retrieve data from JSON string.

Parameters
vRapidJSON value suitable for this object. Will allow partial assignment and not validate automaticaly.
See also
validate()

Definition at line 113 of file Backend.cpp.

References Service::from_json_value().

Referenced by Backend(), and from_json().

◆ id()

std::optional<std::string> Backend::id ( ) const
inline

Get id value.

Returns
id value

Definition at line 128 of file Backend.h.

Referenced by set_id().

◆ kind()

std::optional<std::string> Backend::kind ( ) const
inline

Get kind value.

Returns
kind value

Definition at line 94 of file Backend.h.

Referenced by set_kind().

◆ name()

std::optional<std::string> Backend::name ( ) const
inline

Get name value.

Returns
name value

Definition at line 145 of file Backend.h.

Referenced by set_name().

◆ services()

std::vector<std::shared_ptr<Service> > Backend::services ( ) const
inline

Get services value.

Returns
services value

Definition at line 179 of file Backend.h.

Referenced by addto_services(), and set_services().

◆ set_apiVersion()

void Backend::set_apiVersion ( const std::string &  apiVersion)
inline

Set apiVersion value.

Parameters
apiVersionnew value

Definition at line 120 of file Backend.h.

References apiVersion().

Referenced by BackendInfoRestApi::init().

◆ set_id()

void Backend::set_id ( const std::string &  id)
inline

Set id value.

Parameters
idnew value

Definition at line 137 of file Backend.h.

References id().

Referenced by BackendInfoRestApi::init().

◆ set_kind()

void Backend::set_kind ( const std::string &  kind)
inline

Set kind value.

Parameters
kindnew value

Definition at line 103 of file Backend.h.

References kind().

Referenced by BackendInfoRestApi::init().

◆ set_name()

void Backend::set_name ( const std::string &  name)
inline

Set name value.

Parameters
namenew value

Definition at line 154 of file Backend.h.

References name().

Referenced by BackendInfoRestApi::init().

◆ set_services()

void Backend::set_services ( const std::vector< std::shared_ptr< Service >> &  services)
inline

Set services value.

Parameters
servicesnew value

Definition at line 188 of file Backend.h.

References services().

◆ set_url()

void Backend::set_url ( const std::string &  url)
inline

Set url value.

Parameters
urlnew value

Definition at line 171 of file Backend.h.

References url().

Referenced by BackendInfoRestApi::init().

◆ to_json()

std::string Backend::to_json ( bool  pretty = false) const
virtual

Render object to JSON.

Parameters
prettytrue to enable pretty printing (readable spacing)
Returns
JSON string

Definition at line 42 of file Backend.cpp.

References to_json_value().

◆ to_json_value()

void Backend::to_json_value ( rapidjson::Document &  d,
rapidjson::Value &  v 
) const
virtual

Render object to JSON.

Parameters
dRapidJSON document to retrieve allocator from
vRapidJSON value to add data to

Definition at line 61 of file Backend.cpp.

Referenced by to_json().

◆ url()

std::optional<std::string> Backend::url ( ) const
inline

Get url value.

Returns
url value

Definition at line 162 of file Backend.h.

Referenced by set_url().

◆ validate()

void Backend::validate ( bool  subcall = false) const
virtual

Validate if all required fields have been set.

Parameters
subcalltrue if this is called from another class, e.g., a sub-class or array holder. Will modify the kind of exception thrown.
Exceptions
std::vector<std::string>thrown if required information is missing and subcall is set to true. Contains a list of missing fields.
std::runtime_errorinformative message describing the missing fields

Definition at line 144 of file Backend.cpp.


The documentation for this class was generated from the following files: