1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-17 23:28:50 -05:00

REST API device and channel actions: generate swagger code

This commit is contained in:
f4exb 2020-03-10 15:28:57 +01:00
parent 86fd508828
commit c8b9c912a2
6 changed files with 2282 additions and 2162 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +1,21 @@
ChannelActions:
description: Base channel actions. Only the channel actions corresponding to the channel specified in the channelType field is or should be present.
discriminator: channelType
required:
- channelType
- direction
properties:
channelType:
description: Channel type code
type: string
direction:
description: 0 for Rx only, 1 for Tx only or 2 for any number and direction (default 0)
type: integer
originatorDeviceSetIndex:
description: Optional for reverse API. This is the device set index from where the message comes from.
type: integer
originatorChannelIndex:
description: Optional for reverse API. This is the channel index from where the message comes from.
type: integer
FileSourceActions:
$ref: "/doc/swagger/include/FileSource.yaml#/FileSourceActions"
description: Base channel actions. Only the channel actions corresponding to the channel specified in the channelType field is or should be present.
discriminator: channelType
required:
- channelType
- direction
properties:
channelType:
description: Channel type code
type: string
direction:
description: 0 for Rx only, 1 for Tx only or 2 for any number and direction (default 0)
type: integer
originatorDeviceSetIndex:
description: Optional for reverse API. This is the device set index from where the message comes from.
type: integer
originatorChannelIndex:
description: Optional for reverse API. This is the channel index from where the message comes from.
type: integer
FileSourceActions:
$ref: "/doc/swagger/include/FileSource.yaml#/FileSourceActions"

View File

@ -1388,7 +1388,7 @@ paths:
description: post an action on a device
operationId: devicesetDeviceActionsPost
tags:
- Deviceset
- DeviceSet
parameters:
- in: path
name: deviceSetIndex
@ -1647,7 +1647,7 @@ paths:
description: post an action or actions on a channel
operationId: devicesetChannelActionsPost
tags:
- Deviceset
- DeviceSet
parameters:
- in: path
name: deviceSetIndex

File diff suppressed because it is too large Load Diff

View File

@ -28,6 +28,65 @@ SWGDeviceSetApi::SWGDeviceSetApi(QString host, QString basePath) {
this->basePath = basePath;
}
void
SWGDeviceSetApi::devicesetChannelActionsPost(qint32 device_set_index, qint32 channel_index, SWGChannelActions& body) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/sdrangel/deviceset/{deviceSetIndex}/channel/{channelIndex}/actions");
QString device_set_indexPathParam("{"); device_set_indexPathParam.append("deviceSetIndex").append("}");
fullPath.replace(device_set_indexPathParam, stringValue(device_set_index));
QString channel_indexPathParam("{"); channel_indexPathParam.append("channelIndex").append("}");
fullPath.replace(channel_indexPathParam, stringValue(channel_index));
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "POST");
QString output = body.asJson();
input.request_body.append(output);
foreach(QString key, this->defaultHeaders.keys()) {
input.headers.insert(key, this->defaultHeaders.value(key));
}
connect(worker,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGDeviceSetApi::devicesetChannelActionsPostCallback);
worker->execute(&input);
}
void
SWGDeviceSetApi::devicesetChannelActionsPostCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length());
}
else {
msg = "Error: " + worker->error_str;
}
QString json(worker->response);
SWGSuccessResponse* output = static_cast<SWGSuccessResponse*>(create(json, QString("SWGSuccessResponse")));
worker->deleteLater();
if (worker->error_type == QNetworkReply::NoError) {
emit devicesetChannelActionsPostSignal(output);
} else {
emit devicesetChannelActionsPostSignalE(output, error_type, error_str);
emit devicesetChannelActionsPostSignalEFull(worker, error_type, error_str);
}
}
void
SWGDeviceSetApi::devicesetChannelDelete(qint32 device_set_index, qint32 channel_index) {
QString fullPath;
@ -425,6 +484,63 @@ SWGDeviceSetApi::devicesetChannelsReportGetCallback(SWGHttpRequestWorker * worke
}
}
void
SWGDeviceSetApi::devicesetDeviceActionsPost(qint32 device_set_index, SWGDeviceActions& body) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/sdrangel/deviceset/{deviceSetIndex}/device/actions");
QString device_set_indexPathParam("{"); device_set_indexPathParam.append("deviceSetIndex").append("}");
fullPath.replace(device_set_indexPathParam, stringValue(device_set_index));
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "POST");
QString output = body.asJson();
input.request_body.append(output);
foreach(QString key, this->defaultHeaders.keys()) {
input.headers.insert(key, this->defaultHeaders.value(key));
}
connect(worker,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGDeviceSetApi::devicesetDeviceActionsPostCallback);
worker->execute(&input);
}
void
SWGDeviceSetApi::devicesetDeviceActionsPostCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length());
}
else {
msg = "Error: " + worker->error_str;
}
QString json(worker->response);
SWGSuccessResponse* output = static_cast<SWGSuccessResponse*>(create(json, QString("SWGSuccessResponse")));
worker->deleteLater();
if (worker->error_type == QNetworkReply::NoError) {
emit devicesetDeviceActionsPostSignal(output);
} else {
emit devicesetDeviceActionsPostSignalE(output, error_type, error_str);
emit devicesetDeviceActionsPostSignalEFull(worker, error_type, error_str);
}
}
void
SWGDeviceSetApi::devicesetDevicePut(qint32 device_set_index, SWGDeviceListItem& body) {
QString fullPath;

View File

@ -15,9 +15,11 @@
#include "SWGHttpRequest.h"
#include "SWGChannelActions.h"
#include "SWGChannelReport.h"
#include "SWGChannelSettings.h"
#include "SWGChannelsDetail.h"
#include "SWGDeviceActions.h"
#include "SWGDeviceListItem.h"
#include "SWGDeviceReport.h"
#include "SWGDeviceSet.h"
@ -42,6 +44,7 @@ public:
QString basePath;
QMap<QString, QString> defaultHeaders;
void devicesetChannelActionsPost(qint32 device_set_index, qint32 channel_index, SWGChannelActions& body);
void devicesetChannelDelete(qint32 device_set_index, qint32 channel_index);
void devicesetChannelPost(qint32 device_set_index, SWGChannelSettings& body);
void devicesetChannelReportGet(qint32 device_set_index, qint32 channel_index);
@ -49,6 +52,7 @@ public:
void devicesetChannelSettingsPatch(qint32 device_set_index, qint32 channel_index, SWGChannelSettings& body);
void devicesetChannelSettingsPut(qint32 device_set_index, qint32 channel_index, SWGChannelSettings& body);
void devicesetChannelsReportGet(qint32 device_set_index);
void devicesetDeviceActionsPost(qint32 device_set_index, SWGDeviceActions& body);
void devicesetDevicePut(qint32 device_set_index, SWGDeviceListItem& body);
void devicesetDeviceReportGet(qint32 device_set_index);
void devicesetDeviceRunDelete(qint32 device_set_index, SWGDeviceSettings& body);
@ -66,6 +70,7 @@ public:
void instanceDeviceSetPost(qint32 direction);
private:
void devicesetChannelActionsPostCallback (SWGHttpRequestWorker * worker);
void devicesetChannelDeleteCallback (SWGHttpRequestWorker * worker);
void devicesetChannelPostCallback (SWGHttpRequestWorker * worker);
void devicesetChannelReportGetCallback (SWGHttpRequestWorker * worker);
@ -73,6 +78,7 @@ private:
void devicesetChannelSettingsPatchCallback (SWGHttpRequestWorker * worker);
void devicesetChannelSettingsPutCallback (SWGHttpRequestWorker * worker);
void devicesetChannelsReportGetCallback (SWGHttpRequestWorker * worker);
void devicesetDeviceActionsPostCallback (SWGHttpRequestWorker * worker);
void devicesetDevicePutCallback (SWGHttpRequestWorker * worker);
void devicesetDeviceReportGetCallback (SWGHttpRequestWorker * worker);
void devicesetDeviceRunDeleteCallback (SWGHttpRequestWorker * worker);
@ -90,6 +96,7 @@ private:
void instanceDeviceSetPostCallback (SWGHttpRequestWorker * worker);
signals:
void devicesetChannelActionsPostSignal(SWGSuccessResponse* summary);
void devicesetChannelDeleteSignal(SWGChannelSettings* summary);
void devicesetChannelPostSignal(SWGSuccessResponse* summary);
void devicesetChannelReportGetSignal(SWGChannelReport* summary);
@ -97,6 +104,7 @@ signals:
void devicesetChannelSettingsPatchSignal(SWGChannelSettings* summary);
void devicesetChannelSettingsPutSignal(SWGChannelSettings* summary);
void devicesetChannelsReportGetSignal(SWGChannelsDetail* summary);
void devicesetDeviceActionsPostSignal(SWGSuccessResponse* summary);
void devicesetDevicePutSignal(SWGDeviceListItem* summary);
void devicesetDeviceReportGetSignal(SWGDeviceReport* summary);
void devicesetDeviceRunDeleteSignal(SWGDeviceState* summary);
@ -113,6 +121,7 @@ signals:
void instanceDeviceSetDeleteSignal(SWGSuccessResponse* summary);
void instanceDeviceSetPostSignal(SWGSuccessResponse* summary);
void devicesetChannelActionsPostSignalE(SWGSuccessResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void devicesetChannelDeleteSignalE(SWGChannelSettings* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void devicesetChannelPostSignalE(SWGSuccessResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void devicesetChannelReportGetSignalE(SWGChannelReport* summary, QNetworkReply::NetworkError error_type, QString& error_str);
@ -120,6 +129,7 @@ signals:
void devicesetChannelSettingsPatchSignalE(SWGChannelSettings* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void devicesetChannelSettingsPutSignalE(SWGChannelSettings* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void devicesetChannelsReportGetSignalE(SWGChannelsDetail* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void devicesetDeviceActionsPostSignalE(SWGSuccessResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void devicesetDevicePutSignalE(SWGDeviceListItem* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void devicesetDeviceReportGetSignalE(SWGDeviceReport* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void devicesetDeviceRunDeleteSignalE(SWGDeviceState* summary, QNetworkReply::NetworkError error_type, QString& error_str);
@ -136,6 +146,7 @@ signals:
void instanceDeviceSetDeleteSignalE(SWGSuccessResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceDeviceSetPostSignalE(SWGSuccessResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void devicesetChannelActionsPostSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void devicesetChannelDeleteSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void devicesetChannelPostSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void devicesetChannelReportGetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
@ -143,6 +154,7 @@ signals:
void devicesetChannelSettingsPatchSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void devicesetChannelSettingsPutSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void devicesetChannelsReportGetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void devicesetDeviceActionsPostSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void devicesetDevicePutSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void devicesetDeviceReportGetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void devicesetDeviceRunDeleteSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);