Fawkes API  Fawkes Development Version
Service Class Reference

Service representation for JSON transfer. More...

#include <Service.h>

Public Member Functions

 Service ()
 Constructor. More...
 
 Service (const std::string &json)
 Constructor from JSON. More...
 
 Service (const rapidjson::Value &v)
 Constructor from JSON. More...
 
virtual ~Service ()
 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 > 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...
 

Static Public Member Functions

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

Detailed Description

Service representation for JSON transfer.

Definition at line 25 of file Service.h.

Constructor & Destructor Documentation

◆ Service() [1/3]

Service::Service ( )

Constructor.

Definition at line 22 of file Service.cpp.

◆ Service() [2/3]

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

Constructor from JSON.

Parameters
jsonJSON string to initialize from

Definition at line 26 of file Service.cpp.

References from_json().

◆ Service() [3/3]

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

Constructor from JSON.

Parameters
vRapidJSON value object to initialize from.

Definition at line 31 of file Service.cpp.

References from_json_value().

◆ ~Service()

Service::~Service ( )
virtual

Destructor.

Definition at line 36 of file Service.cpp.

Member Function Documentation

◆ api_version()

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

Get version of implemented API.

Returns
string representation of version

Definition at line 47 of file Service.h.

◆ from_json()

void Service::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 80 of file Service.cpp.

References from_json_value().

Referenced by Service().

◆ from_json_value()

void Service::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 89 of file Service.cpp.

Referenced by from_json(), Backend::from_json_value(), and Service().

◆ name()

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

Get name value.

Returns
name value

Definition at line 91 of file Service.h.

Referenced by set_name().

◆ set_name()

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

Set name value.

Parameters
namenew value

Definition at line 100 of file Service.h.

References name().

Referenced by BackendInfoRestApi::init().

◆ set_url()

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

Set url value.

Parameters
urlnew value

Definition at line 117 of file Service.h.

References url().

◆ to_json()

std::string Service::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 41 of file Service.cpp.

References to_json_value().

◆ to_json_value()

void Service::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 60 of file Service.cpp.

Referenced by to_json().

◆ url()

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

Get url value.

Returns
url value

Definition at line 108 of file Service.h.

Referenced by set_url().

◆ validate()

void Service::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 100 of file Service.cpp.


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