add rest resource documentation

pull/135/head
Simon Stürz 2015-08-13 22:28:04 +02:00 committed by Michael Zanetti
parent c6681ec151
commit deb268d59b
7 changed files with 121 additions and 0 deletions

View File

@ -185,6 +185,7 @@ QVariantMap JsonHandler::statusToReply(Logging::LoggingError status) const
*/
JsonReply::JsonReply(Type type, JsonHandler *handler, const QString &method, const QVariantMap &data):
m_type(type),
m_data(data),

View File

@ -33,6 +33,7 @@ class Logging
Q_FLAGS(LoggingSources)
Q_ENUMS(LoggingLevel)
Q_ENUMS(LoggingEventType)
public:
enum LoggingError {
LoggingErrorNoError,

View File

@ -46,6 +46,7 @@
namespace guhserver {
/*! Constructs a \l DevicesResource with the given \a parent. */
DevicesResource::DevicesResource(QObject *parent) :
RestResource(parent)
{
@ -55,11 +56,20 @@ DevicesResource::DevicesResource(QObject *parent) :
connect(GuhCore::instance(), &GuhCore::pairingFinished, this, &DevicesResource::pairingFinished);
}
/*! Returns the name of the \l{RestResource}. In this case \b devices.
\sa RestResource::name()
*/
QString DevicesResource::name() const
{
return "devices";
}
/*! This method will be used to process the given \a request and the given \a urlTokens. The request
has to be in this namespace. Returns the resulting \l HttpReply.
\sa HttpRequest, HttpReply, RestResource::proccessRequest()
*/
HttpReply *DevicesResource::proccessRequest(const HttpRequest &request, const QStringList &urlTokens)
{
m_device = 0;

View File

@ -18,6 +18,23 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*!
\class guhserver::LogsResource
\brief This subclass of \l{RestResource} processes the REST requests for the \tt Logs namespace.
\ingroup json
\inmodule core
This \l{RestResource} will be created in the \l{RestServer} and used to handle REST requests
for the \tt {Logs} namespace of the API.
\code
http://localhost:3333/api/v1/logs
\endcode
\sa LogEntry, RestResource, RestServer
*/
#include "logsresource.h"
#include "httprequest.h"
#include "loggingcategories.h"
@ -28,16 +45,26 @@
namespace guhserver {
/*! Constructs a \l LogsResource with the given \a parent. */
LogsResource::LogsResource(QObject *parent) :
RestResource(parent)
{
}
/*! Returns the name of the \l{RestResource}. In this case \b logs.
\sa RestResource::name()
*/
QString LogsResource::name() const
{
return "logs";
}
/*! This method will be used to process the given \a request and the given \a urlTokens. The request
has to be in this namespace. Returns the resulting \l HttpReply.
\sa HttpRequest, HttpReply, RestResource::proccessRequest()
*/
HttpReply *LogsResource::proccessRequest(const HttpRequest &request, const QStringList &urlTokens)
{
// check method

View File

@ -18,6 +18,23 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*!
\class guhserver::PluginsResource
\brief This subclass of \l{RestResource} processes the REST requests for the \tt Plugins namespace.
\ingroup json
\inmodule core
This \l{RestResource} will be created in the \l{RestServer} and used to handle REST requests
for the \tt {Plugins} namespace of the API.
\code
http://localhost:3333/api/v1/plugins
\endcode
\sa DevicePlugin, RestResource, RestServer
*/
#include "pluginsresource.h"
#include "httprequest.h"
#include "loggingcategories.h"
@ -27,17 +44,27 @@
namespace guhserver {
/*! Constructs a \l PluginsResource with the given \a parent. */
PluginsResource::PluginsResource(QObject *parent) :
RestResource(parent)
{
}
/*! Returns the name of the \l{RestResource}. In this case \b plugins.
\sa RestResource::name()
*/
QString PluginsResource::name() const
{
return "plugins";
}
/*! This method will be used to process the given \a request and the given \a urlTokens. The request
has to be in this namespace. Returns the resulting \l HttpReply.
\sa HttpRequest, HttpReply, RestResource::proccessRequest()
*/
HttpReply *PluginsResource::proccessRequest(const HttpRequest &request, const QStringList &urlTokens)
{
// get the main resource

View File

@ -18,6 +18,23 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*!
\class guhserver::RulesResource
\brief This subclass of \l{RestResource} processes the REST requests for the \tt Rules namespace.
\ingroup json
\inmodule core
This \l{RestResource} will be created in the \l{RestServer} and used to handle REST requests
for the \tt {Rules} namespace of the API.
\code
http://localhost:3333/api/v1/rules
\endcode
\sa Rule, RestResource, RestServer
*/
#include "rulesresource.h"
#include "httprequest.h"
#include "typeutils.h"
@ -28,16 +45,26 @@
namespace guhserver {
/*! Constructs a \l RulesResource with the given \a parent. */
RulesResource::RulesResource(QObject *parent) :
RestResource(parent)
{
}
/*! Returns the name of the \l{RestResource}. In this case \b rules.
\sa RestResource::name()
*/
QString RulesResource::name() const
{
return "rules";
}
/*! This method will be used to process the given \a request and the given \a urlTokens. The request
has to be in this namespace. Returns the resulting \l HttpReply.
\sa HttpRequest, HttpReply, RestResource::proccessRequest()
*/
HttpReply *RulesResource::proccessRequest(const HttpRequest &request, const QStringList &urlTokens)
{
// /api/v1/rules/{ruleId}/

View File

@ -18,6 +18,24 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*!
\class guhserver::VendorsResource
\brief This subclass of \l{RestResource} processes the REST requests for the \tt Vendors namespace.
\ingroup json
\inmodule core
This \l{RestResource} will be created in the \l{RestServer} and used to handle REST requests
for the \tt {Vendors} namespace of the API.
\code
http://localhost:3333/api/v1/vendors
\endcode
\sa Vendor, RestResource, RestServer
*/
#include "vendorsresource.h"
#include "httprequest.h"
#include "loggingcategories.h"
@ -27,16 +45,26 @@
namespace guhserver {
/*! Constructs a \l VendorsResource with the given \a parent. */
VendorsResource::VendorsResource(QObject *parent) :
RestResource(parent)
{
}
/*! Returns the name of the \l{RestResource}. In this case \b vendors.
\sa RestResource::name()
*/
QString VendorsResource::name() const
{
return "vendors";
}
/*! This method will be used to process the given \a request and the given \a urlTokens. The request
has to be in this namespace. Returns the resulting \l HttpReply.
\sa HttpRequest, HttpReply, RestResource::proccessRequest()
*/
HttpReply *VendorsResource::proccessRequest(const HttpRequest &request, const QStringList &urlTokens)
{
// /api/v1/vendors/{vendorId}/