From deb268d59b133a5ce725c7fa342858642f0aa263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Thu, 13 Aug 2015 22:28:04 +0200 Subject: [PATCH] add rest resource documentation --- server/jsonrpc/jsonhandler.cpp | 1 + server/logging/logging.h | 1 + server/rest/devicesresource.cpp | 10 ++++++++++ server/rest/logsresource.cpp | 27 +++++++++++++++++++++++++++ server/rest/pluginsresource.cpp | 27 +++++++++++++++++++++++++++ server/rest/rulesresource.cpp | 27 +++++++++++++++++++++++++++ server/rest/vendorsresource.cpp | 28 ++++++++++++++++++++++++++++ 7 files changed, 121 insertions(+) diff --git a/server/jsonrpc/jsonhandler.cpp b/server/jsonrpc/jsonhandler.cpp index fa9121c9..257c4e59 100644 --- a/server/jsonrpc/jsonhandler.cpp +++ b/server/jsonrpc/jsonhandler.cpp @@ -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), diff --git a/server/logging/logging.h b/server/logging/logging.h index 500e9b67..70c65df4 100644 --- a/server/logging/logging.h +++ b/server/logging/logging.h @@ -33,6 +33,7 @@ class Logging Q_FLAGS(LoggingSources) Q_ENUMS(LoggingLevel) Q_ENUMS(LoggingEventType) + public: enum LoggingError { LoggingErrorNoError, diff --git a/server/rest/devicesresource.cpp b/server/rest/devicesresource.cpp index d4d0cae2..f49c0955 100644 --- a/server/rest/devicesresource.cpp +++ b/server/rest/devicesresource.cpp @@ -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; diff --git a/server/rest/logsresource.cpp b/server/rest/logsresource.cpp index 1ccf7e01..ebc20903 100644 --- a/server/rest/logsresource.cpp +++ b/server/rest/logsresource.cpp @@ -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 diff --git a/server/rest/pluginsresource.cpp b/server/rest/pluginsresource.cpp index 500b56ae..512caf8e 100644 --- a/server/rest/pluginsresource.cpp +++ b/server/rest/pluginsresource.cpp @@ -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 diff --git a/server/rest/rulesresource.cpp b/server/rest/rulesresource.cpp index 864d448b..fea16fbf 100644 --- a/server/rest/rulesresource.cpp +++ b/server/rest/rulesresource.cpp @@ -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}/ diff --git a/server/rest/vendorsresource.cpp b/server/rest/vendorsresource.cpp index ed355b28..d5a22843 100644 --- a/server/rest/vendorsresource.cpp +++ b/server/rest/vendorsresource.cpp @@ -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}/