API: added PUT, PATCH, POST /sdrangel/featureset/{featureSetIndex}​/preset

This commit is contained in:
f4exb 2021-09-05 22:12:26 +02:00
parent e1c3726a27
commit b0c35d22b8
14 changed files with 4127 additions and 2 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2040,6 +2040,121 @@ paths:
"501":
$ref: "#/responses/Response_501"
/sdrangel/featureset/{featureSetIndex}/preset:
x-swagger-router-controller: featureset
patch:
description: Load a preset in a feature set
operationId: featuresetPresetPatch
tags:
- FeatureSet
consumes:
- application/json
parameters:
- in: path
name: featureSetIndex
type: integer
required: true
description: Index of feature set in the feature set list
- name: body
in: body
description: Load preset settings to the feature set
required: true
schema:
$ref: "#/definitions/FeaturePresetIdentifier"
responses:
"202":
description: On successful sending of the message the selected preset identification is returned
schema:
$ref: "#/definitions/FeaturePresetIdentifier"
"400":
description: Invalid JSON request
schema:
$ref: "#/definitions/ErrorResponse"
"404":
description: No preset or feature set found
schema:
$ref: "#/definitions/ErrorResponse"
"500":
$ref: "#/responses/Response_500"
"501":
$ref: "#/responses/Response_501"
put:
description: Update an existing preset with feature set settings.
operationId: featuresetPresetPut
tags:
- FeatureSet
consumes:
- application/json
parameters:
- in: path
name: featureSetIndex
type: integer
required: true
description: Index of feature set in the feature set list
- name: body
in: body
description: save feature set settings to the preset
required: true
schema:
$ref: "#/definitions/FeaturePresetIdentifier"
responses:
"202":
description: On successful sending of the message the selected preset identification is returned
schema:
$ref: "#/definitions/FeaturePresetIdentifier"
"400":
description: Invalid JSON request
schema:
$ref: "#/definitions/ErrorResponse"
"404":
description: No preset or feature set found
schema:
$ref: "#/definitions/ErrorResponse"
"500":
$ref: "#/responses/Response_500"
"501":
$ref: "#/responses/Response_501"
post:
description: Create a new preset from a feature set settings.
operationId: featuresetPresetPost
tags:
- FeatureSet
consumes:
- application/json
parameters:
- in: path
name: featureSetIndex
type: integer
required: true
description: Index of feature set in the feature set list
- name: body
in: body
description: save feature set settings on a new preset
required: true
schema:
$ref: "#/definitions/FeaturePresetIdentifier"
responses:
"202":
description: On successful sending of the message the created preset identification is returned
schema:
$ref: "#/definitions/PresetIdentifier"
"400":
description: Invalid JSON request
schema:
$ref: "#/definitions/ErrorResponse"
"404":
description: Feature set not found
schema:
$ref: "#/definitions/ErrorResponse"
"409":
description: Preset already exists
schema:
$ref: "#/definitions/ErrorResponse"
"500":
$ref: "#/responses/Response_500"
"501":
$ref: "#/responses/Response_501"
/sdrangel/featureset/{featureSetIndex}/feature/{featureIndex}:
x-swagger-router-controller: featureset
delete:

View File

@ -75,6 +75,7 @@
#include "SWGFeaturePresetGroup.h"
#include "SWGFeaturePresetItem.h"
#include "SWGFeaturePresetIdentifier.h"
#include "SWGFeaturePresetTransfer.h"
#include "SWGFeatureSetList.h"
#include "SWGFeatureSettings.h"
#include "SWGFeatureReport.h"
@ -3165,6 +3166,109 @@ int WebAPIAdapter::featuresetFeatureRunDelete(
}
}
int WebAPIAdapter::featuresetPresetPatch(
int featureSetIndex,
SWGSDRangel::SWGFeaturePresetIdentifier& query,
SWGSDRangel::SWGErrorResponse& error)
{
int nbFeatureSets = m_mainCore->m_featureSets.size();
if (featureSetIndex >= nbFeatureSets)
{
error.init();
*error.getMessage() = QString("There is no feature set at index %1. Number of device sets is %2").arg(featureSetIndex).arg(nbFeatureSets);
return 404;
}
const FeatureSetPreset *selectedPreset = m_mainCore->m_settings.getFeatureSetPreset(
*query.getGroupName(),
*query.getDescription());
if (selectedPreset == 0)
{
error.init();
*error.getMessage() = QString("There is no preset [%1, %2]")
.arg(*query.getGroupName())
.arg(*query.getDescription());
return 404;
}
MainCore::MsgLoadFeatureSetPreset *msg = MainCore::MsgLoadFeatureSetPreset::create(selectedPreset, featureSetIndex);
m_mainCore->m_mainMessageQueue->push(msg);
return 202;
}
int WebAPIAdapter::featuresetPresetPut(
int featureSetIndex,
SWGSDRangel::SWGFeaturePresetIdentifier& query,
SWGSDRangel::SWGErrorResponse& error)
{
int nbFeatureSets = m_mainCore->m_featureSets.size();
if (featureSetIndex >= nbFeatureSets)
{
error.init();
*error.getMessage() = QString("There is no feature set at index %1. Number of feature sets is %2").arg(featureSetIndex).arg(nbFeatureSets);
return 404;
}
const FeatureSetPreset *selectedPreset = m_mainCore->m_settings.getFeatureSetPreset(
*query.getGroupName(),
*query.getDescription());
if (selectedPreset == 0)
{
error.init();
*error.getMessage() = QString("There is no preset [%1, %2]")
.arg(*query.getGroupName())
.arg(*query.getDescription());
return 404;
}
MainCore::MsgSaveFeatureSetPreset *msg = MainCore::MsgSaveFeatureSetPreset::create(const_cast<FeatureSetPreset*>(selectedPreset), featureSetIndex, false);
m_mainCore->m_mainMessageQueue->push(msg);
return 202;
}
int WebAPIAdapter::featuresetPresetPost(
int featureSetIndex,
SWGSDRangel::SWGFeaturePresetIdentifier& query,
SWGSDRangel::SWGErrorResponse& error)
{
int nbFeatureSets = m_mainCore->m_featureSets.size();
if (featureSetIndex >= nbFeatureSets)
{
error.init();
*error.getMessage() = QString("There is no feature set at index %1. Number of feature sets is %2").arg(featureSetIndex).arg(nbFeatureSets);
return 404;
}
const FeatureSetPreset *selectedPreset = m_mainCore->m_settings.getFeatureSetPreset(
*query.getGroupName(),
*query.getDescription());
if (selectedPreset == 0) // save on a new preset
{
selectedPreset = m_mainCore->m_settings.newFeatureSetPreset(*query.getGroupName(), *query.getDescription());
}
else
{
error.init();
*error.getMessage() = QString("Preset already exists [%1, %2]")
.arg(*query.getGroupName())
.arg(*query.getDescription());
return 409;
}
MainCore::MsgSaveFeatureSetPreset *msg = MainCore::MsgSaveFeatureSetPreset::create(const_cast<FeatureSetPreset*>(selectedPreset), featureSetIndex, true);
m_mainCore->m_mainMessageQueue->push(msg);
return 202;
}
int WebAPIAdapter::featuresetFeatureSettingsGet(
int featureSetIndex,
int featureIndex,

View File

@ -408,6 +408,21 @@ public:
SWGSDRangel::SWGDeviceState& response,
SWGSDRangel::SWGErrorResponse& error);
virtual int featuresetPresetPatch(
int featureSetIndex,
SWGSDRangel::SWGFeaturePresetIdentifier& query,
SWGSDRangel::SWGErrorResponse& error);
virtual int featuresetPresetPut(
int featureSetIndex,
SWGSDRangel::SWGFeaturePresetIdentifier& query,
SWGSDRangel::SWGErrorResponse& error);
virtual int featuresetPresetPost(
int featureSetIndex,
SWGSDRangel::SWGFeaturePresetIdentifier& query,
SWGSDRangel::SWGErrorResponse& error);
virtual int featuresetFeatureSettingsGet(
int featureSetIndex,
int featureIndex,

View File

@ -66,6 +66,7 @@ std::regex WebAPIAdapterInterface::devicesetChannelActionsURLRe("^/sdrangel/devi
std::regex WebAPIAdapterInterface::featuresetURLRe("^/sdrangel/featureset/([0-9]{1,2})$");
std::regex WebAPIAdapterInterface::featuresetFeatureURLRe("^/sdrangel/featureset/([0-9]{1,2})/feature$");
std::regex WebAPIAdapterInterface::featuresetPresetURLRe("^/sdrangel/featureset/([0-9]{1,2})/preset");
std::regex WebAPIAdapterInterface::featuresetFeatureIndexURLRe("^/sdrangel/featureset/([0-9]{1,2})/feature/([0-9]{1,2})$");
std::regex WebAPIAdapterInterface::featuresetFeatureRunURLRe("^/sdrangel/featureset/([0-9]{1,2})/feature/([0-9]{1,2})/run$");
std::regex WebAPIAdapterInterface::featuresetFeatureSettingsURLRe("^/sdrangel/featureset/([0-9]{1,2})/feature/([0-9]{1,2})/settings$");

View File

@ -65,6 +65,7 @@ namespace SWGSDRangel
class SWGSuccessResponse;
class SWGFeaturePresets;
class SWGFeaturePresetIdentifier;
class SWGFeaturePresetTransfer;
class SWGFeatureSetList;
class SWGFeatureSet;
class SWGFeatureSettings;
@ -1318,6 +1319,54 @@ public:
return 501;
}
/**
* Handler of /sdrangel/featureset/{featuresetIndex}/preset (PATCH) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
* returns the Http status code (default 501: not implemented)
*/
virtual int featuresetPresetPatch(
int featureSetIndex,
SWGSDRangel::SWGFeaturePresetIdentifier& query,
SWGSDRangel::SWGErrorResponse& error)
{
(void) featureSetIndex;
(void) query;
error.init();
*error.getMessage() = QString("Function not implemented");
return 501;
}
/**
* Handler of /sdrangel/featureset/{featuresetIndex}/preset (PUT) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
* returns the Http status code (default 501: not implemented)
*/
virtual int featuresetPresetPut(
int featureSetIndex,
SWGSDRangel::SWGFeaturePresetIdentifier& query,
SWGSDRangel::SWGErrorResponse& error)
{
(void) featureSetIndex;
(void) query;
error.init();
*error.getMessage() = QString("Function not implemented");
return 501;
}
/**
* Handler of /sdrangel/featureset/{featuresetIndex}/preset (POST) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
* returns the Http status code (default 501: not implemented)
*/
virtual int featuresetPresetPost(
int featureSetIndex,
SWGSDRangel::SWGFeaturePresetIdentifier& query,
SWGSDRangel::SWGErrorResponse& error)
{
(void) featureSetIndex;
(void) query;
error.init();
*error.getMessage() = QString("Function not implemented");
return 501;
}
/**
* Handler of /sdrangel/featureset/{featuresetIndex}/feature/{featureIndex}/settings (GET)
* returns the Http status code (default 501: not implemented)
@ -1443,6 +1492,7 @@ public:
static std::regex devicesetChannelsReportURLRe;
static std::regex featuresetURLRe;
static std::regex featuresetFeatureURLRe;
static std::regex featuresetPresetURLRe;
static std::regex featuresetFeatureIndexURLRe;
static std::regex featuresetFeatureRunURLRe;
static std::regex featuresetFeatureSettingsURLRe;

View File

@ -55,6 +55,7 @@
#include "SWGErrorResponse.h"
#include "SWGFeaturePresets.h"
#include "SWGFeaturePresetIdentifier.h"
#include "SWGFeaturePresetTransfer.h"
#include "SWGFeatureSetList.h"
#include "SWGFeatureSettings.h"
#include "SWGFeatureReport.h"
@ -206,6 +207,8 @@ void WebAPIRequestMapper::service(qtwebapp::HttpRequest& request, qtwebapp::Http
featuresetService(std::string(desc_match[1]), request, response);
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::featuresetFeatureURLRe)) {
featuresetFeatureService(std::string(desc_match[1]), request, response);
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::featuresetPresetURLRe)) {
featuresetPresetService(std::string(desc_match[1]), request, response);
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::featuresetFeatureIndexURLRe)) {
featuresetFeatureIndexService(std::string(desc_match[1]), std::string(desc_match[2]), request, response);
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::featuresetFeatureRunURLRe)) {
@ -2687,6 +2690,147 @@ void WebAPIRequestMapper::featuresetFeatureService(
}
}
void WebAPIRequestMapper::featuresetPresetService(
const std::string& featureSetIndexStr,
qtwebapp::HttpRequest& request,
qtwebapp::HttpResponse& response)
{
SWGSDRangel::SWGErrorResponse errorResponse;
response.setHeader("Content-Type", "application/json");
response.setHeader("Access-Control-Allow-Origin", "*");
try
{
int featureSetIndex = boost::lexical_cast<int>(featureSetIndexStr);
if (request.getMethod() == "PATCH")
{
SWGSDRangel::SWGFeaturePresetIdentifier query;
QString jsonStr = request.getBody();
QJsonObject jsonObject;
if (parseJsonBody(jsonStr, jsonObject, response))
{
query.fromJson(jsonStr);
if (validateFeaturePresetIdentifer(query))
{
int status = m_adapter->featuresetPresetPatch(featureSetIndex, query, errorResponse);
response.setStatus(status);
if (status/100 == 2) {
response.write(query.asJson().toUtf8());
} else {
response.write(errorResponse.asJson().toUtf8());
}
}
else
{
response.setStatus(400,"Invalid JSON request");
errorResponse.init();
*errorResponse.getMessage() = "Invalid JSON request";
response.write(errorResponse.asJson().toUtf8());
}
}
else
{
response.setStatus(400,"Invalid JSON format");
errorResponse.init();
*errorResponse.getMessage() = "Invalid JSON format";
response.write(errorResponse.asJson().toUtf8());
}
}
else if (request.getMethod() == "PUT")
{
SWGSDRangel::SWGFeaturePresetIdentifier query;
QString jsonStr = request.getBody();
QJsonObject jsonObject;
if (parseJsonBody(jsonStr, jsonObject, response))
{
query.fromJson(jsonStr);
if (validateFeaturePresetIdentifer(query))
{
int status = m_adapter->featuresetPresetPut(featureSetIndex, query, errorResponse);
response.setStatus(status);
if (status/100 == 2) {
response.write(query.asJson().toUtf8());
} else {
response.write(errorResponse.asJson().toUtf8());
}
}
else
{
response.setStatus(400,"Invalid JSON request");
errorResponse.init();
*errorResponse.getMessage() = "Invalid JSON request";
response.write(errorResponse.asJson().toUtf8());
}
}
else
{
response.setStatus(400,"Invalid JSON format");
errorResponse.init();
*errorResponse.getMessage() = "Invalid JSON format";
response.write(errorResponse.asJson().toUtf8());
}
}
else if (request.getMethod() == "POST")
{
SWGSDRangel::SWGFeaturePresetIdentifier query;
QString jsonStr = request.getBody();
QJsonObject jsonObject;
if (parseJsonBody(jsonStr, jsonObject, response))
{
query.fromJson(jsonStr);
if (validateFeaturePresetIdentifer(query))
{
int status = m_adapter->featuresetPresetPost(featureSetIndex, query, errorResponse);
response.setStatus(status);
if (status/100 == 2) {
response.write(query.asJson().toUtf8());
} else {
response.write(errorResponse.asJson().toUtf8());
}
}
else
{
response.setStatus(400,"Invalid JSON request");
errorResponse.init();
*errorResponse.getMessage() = "Invalid JSON request";
response.write(errorResponse.asJson().toUtf8());
}
}
else
{
response.setStatus(400,"Invalid JSON format");
errorResponse.init();
*errorResponse.getMessage() = "Invalid JSON format";
response.write(errorResponse.asJson().toUtf8());
}
}
else
{
response.setStatus(405,"Invalid HTTP method");
errorResponse.init();
*errorResponse.getMessage() = "Invalid HTTP method";
response.write(errorResponse.asJson().toUtf8());
}
}
catch (const boost::bad_lexical_cast &e)
{
errorResponse.init();
*errorResponse.getMessage() = "Wrong integer conversion on index";
response.setStatus(400,"Invalid data");
response.write(errorResponse.asJson().toUtf8());
}
}
void WebAPIRequestMapper::featuresetFeatureIndexService(
const std::string& featureSetIndexStr,
const std::string& featureIndexStr,
@ -3068,6 +3212,17 @@ bool WebAPIRequestMapper::validatePresetIdentifer(SWGSDRangel::SWGPresetIdentifi
return (presetIdentifier.getGroupName() && presetIdentifier.getName() && presetIdentifier.getType());
}
bool WebAPIRequestMapper::validateFeaturePresetTransfer(SWGSDRangel::SWGFeaturePresetTransfer& presetTransfer)
{
SWGSDRangel::SWGFeaturePresetIdentifier *presetIdentifier = presetTransfer.getPreset();
if (presetIdentifier == 0) {
return false;
}
return validateFeaturePresetIdentifer(*presetIdentifier);
}
bool WebAPIRequestMapper::validateFeaturePresetIdentifer(SWGSDRangel::SWGFeaturePresetIdentifier& presetIdentifier)
{
return (presetIdentifier.getGroupName() && presetIdentifier.getDescription());

View File

@ -102,6 +102,7 @@ private:
void featuresetService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void featuresetFeatureService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void featuresetPresetService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void featuresetFeatureIndexService(const std::string& featureSetIndexStr, const std::string& featureIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void featuresetFeatureRunService(const std::string& featureSetIndexStr, const std::string& featureIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void featuresetFeatureSettingsService(const std::string& featureSetIndexStr, const std::string& featureIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
@ -117,6 +118,7 @@ private:
bool validateDeviceActions(SWGSDRangel::SWGDeviceActions& deviceActions, QJsonObject& jsonObject, QStringList& deviceActionsKeys);
bool validateChannelSettings(SWGSDRangel::SWGChannelSettings& channelSettings, QJsonObject& jsonObject, QStringList& channelSettingsKeys);
bool validateChannelActions(SWGSDRangel::SWGChannelActions& channelActions, QJsonObject& jsonObject, QStringList& channelActionsKeys);
bool validateFeaturePresetTransfer(SWGSDRangel::SWGFeaturePresetTransfer& presetTransfer);
bool validateFeaturePresetIdentifer(SWGSDRangel::SWGFeaturePresetIdentifier& presetIdentifier);
bool validateFeatureSettings(SWGSDRangel::SWGFeatureSettings& featureSettings, QJsonObject& jsonObject, QStringList& featureSettingsKeys);
bool validateFeatureActions(SWGSDRangel::SWGFeatureActions& featureActions, QJsonObject& jsonObject, QStringList& featureActionsKeys);

View File

@ -2040,6 +2040,121 @@ paths:
"501":
$ref: "#/responses/Response_501"
/sdrangel/featureset/{featureSetIndex}/preset:
x-swagger-router-controller: featureset
patch:
description: Load a preset in a feature set
operationId: featuresetPresetPatch
tags:
- FeatureSet
consumes:
- application/json
parameters:
- in: path
name: featureSetIndex
type: integer
required: true
description: Index of feature set in the feature set list
- name: body
in: body
description: Load preset settings to the feature set
required: true
schema:
$ref: "#/definitions/FeaturePresetIdentifier"
responses:
"202":
description: On successful sending of the message the selected preset identification is returned
schema:
$ref: "#/definitions/FeaturePresetIdentifier"
"400":
description: Invalid JSON request
schema:
$ref: "#/definitions/ErrorResponse"
"404":
description: No preset or feature set found
schema:
$ref: "#/definitions/ErrorResponse"
"500":
$ref: "#/responses/Response_500"
"501":
$ref: "#/responses/Response_501"
put:
description: Update an existing preset with feature set settings.
operationId: featuresetPresetPut
tags:
- FeatureSet
consumes:
- application/json
parameters:
- in: path
name: featureSetIndex
type: integer
required: true
description: Index of feature set in the feature set list
- name: body
in: body
description: save feature set settings to the preset
required: true
schema:
$ref: "#/definitions/FeaturePresetIdentifier"
responses:
"202":
description: On successful sending of the message the selected preset identification is returned
schema:
$ref: "#/definitions/FeaturePresetIdentifier"
"400":
description: Invalid JSON request
schema:
$ref: "#/definitions/ErrorResponse"
"404":
description: No preset or feature set found
schema:
$ref: "#/definitions/ErrorResponse"
"500":
$ref: "#/responses/Response_500"
"501":
$ref: "#/responses/Response_501"
post:
description: Create a new preset from a feature set settings.
operationId: featuresetPresetPost
tags:
- FeatureSet
consumes:
- application/json
parameters:
- in: path
name: featureSetIndex
type: integer
required: true
description: Index of feature set in the feature set list
- name: body
in: body
description: save feature set settings on a new preset
required: true
schema:
$ref: "#/definitions/FeaturePresetIdentifier"
responses:
"202":
description: On successful sending of the message the created preset identification is returned
schema:
$ref: "#/definitions/PresetIdentifier"
"400":
description: Invalid JSON request
schema:
$ref: "#/definitions/ErrorResponse"
"404":
description: Feature set not found
schema:
$ref: "#/definitions/ErrorResponse"
"409":
description: Preset already exists
schema:
$ref: "#/definitions/ErrorResponse"
"500":
$ref: "#/responses/Response_500"
"501":
$ref: "#/responses/Response_501"
/sdrangel/featureset/{featureSetIndex}/feature/{featureIndex}:
x-swagger-router-controller: featureset
delete:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,133 @@
/**
* SDRangel
* This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time ---
*
* OpenAPI spec version: 6.0.0
* Contact: f4exb06@gmail.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
#include "SWGFeaturePresetTransfer.h"
#include "SWGHelpers.h"
#include <QJsonDocument>
#include <QJsonArray>
#include <QObject>
#include <QDebug>
namespace SWGSDRangel {
SWGFeaturePresetTransfer::SWGFeaturePresetTransfer(QString* json) {
init();
this->fromJson(*json);
}
SWGFeaturePresetTransfer::SWGFeaturePresetTransfer() {
feature_set_index = 0;
m_feature_set_index_isSet = false;
preset = nullptr;
m_preset_isSet = false;
}
SWGFeaturePresetTransfer::~SWGFeaturePresetTransfer() {
this->cleanup();
}
void
SWGFeaturePresetTransfer::init() {
feature_set_index = 0;
m_feature_set_index_isSet = false;
preset = new SWGFeaturePresetIdentifier();
m_preset_isSet = false;
}
void
SWGFeaturePresetTransfer::cleanup() {
if(preset != nullptr) {
delete preset;
}
}
SWGFeaturePresetTransfer*
SWGFeaturePresetTransfer::fromJson(QString &json) {
QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object();
this->fromJsonObject(jsonObject);
return this;
}
void
SWGFeaturePresetTransfer::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&feature_set_index, pJson["featureSetIndex"], "qint32", "");
::SWGSDRangel::setValue(&preset, pJson["preset"], "SWGFeaturePresetIdentifier", "SWGFeaturePresetIdentifier");
}
QString
SWGFeaturePresetTransfer::asJson ()
{
QJsonObject* obj = this->asJsonObject();
QJsonDocument doc(*obj);
QByteArray bytes = doc.toJson();
delete obj;
return QString(bytes);
}
QJsonObject*
SWGFeaturePresetTransfer::asJsonObject() {
QJsonObject* obj = new QJsonObject();
if(m_feature_set_index_isSet){
obj->insert("featureSetIndex", QJsonValue(feature_set_index));
}
if((preset != nullptr) && (preset->isSet())){
toJsonValue(QString("preset"), preset, obj, QString("SWGFeaturePresetIdentifier"));
}
return obj;
}
qint32
SWGFeaturePresetTransfer::getFeatureSetIndex() {
return feature_set_index;
}
void
SWGFeaturePresetTransfer::setFeatureSetIndex(qint32 feature_set_index) {
this->feature_set_index = feature_set_index;
this->m_feature_set_index_isSet = true;
}
SWGFeaturePresetIdentifier*
SWGFeaturePresetTransfer::getPreset() {
return preset;
}
void
SWGFeaturePresetTransfer::setPreset(SWGFeaturePresetIdentifier* preset) {
this->preset = preset;
this->m_preset_isSet = true;
}
bool
SWGFeaturePresetTransfer::isSet(){
bool isObjectUpdated = false;
do{
if(m_feature_set_index_isSet){
isObjectUpdated = true; break;
}
if(preset && preset->isSet()){
isObjectUpdated = true; break;
}
}while(false);
return isObjectUpdated;
}
}

View File

@ -0,0 +1,65 @@
/**
* SDRangel
* This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time ---
*
* OpenAPI spec version: 6.0.0
* Contact: f4exb06@gmail.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
/*
* SWGFeaturePresetTransfer.h
*
* Preset transfer to or from a feature set
*/
#ifndef SWGFeaturePresetTransfer_H_
#define SWGFeaturePresetTransfer_H_
#include <QJsonObject>
#include "SWGFeaturePresetIdentifier.h"
#include "SWGObject.h"
#include "export.h"
namespace SWGSDRangel {
class SWG_API SWGFeaturePresetTransfer: public SWGObject {
public:
SWGFeaturePresetTransfer();
SWGFeaturePresetTransfer(QString* json);
virtual ~SWGFeaturePresetTransfer();
void init();
void cleanup();
virtual QString asJson () override;
virtual QJsonObject* asJsonObject() override;
virtual void fromJsonObject(QJsonObject &json) override;
virtual SWGFeaturePresetTransfer* fromJson(QString &jsonString) override;
qint32 getFeatureSetIndex();
void setFeatureSetIndex(qint32 feature_set_index);
SWGFeaturePresetIdentifier* getPreset();
void setPreset(SWGFeaturePresetIdentifier* preset);
virtual bool isSet() override;
private:
qint32 feature_set_index;
bool m_feature_set_index_isSet;
SWGFeaturePresetIdentifier* preset;
bool m_preset_isSet;
};
}
#endif /* SWGFeaturePresetTransfer_H_ */

View File

@ -652,6 +652,177 @@ SWGFeatureSetApi::featuresetGetCallback(SWGHttpRequestWorker * worker) {
}
}
void
SWGFeatureSetApi::featuresetPresetPatch(qint32 feature_set_index, SWGFeaturePresetIdentifier& body) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/sdrangel/featureset/{featureSetIndex}/preset");
QString feature_set_indexPathParam("{"); feature_set_indexPathParam.append("featureSetIndex").append("}");
fullPath.replace(feature_set_indexPathParam, stringValue(feature_set_index));
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "PATCH");
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,
&SWGFeatureSetApi::featuresetPresetPatchCallback);
worker->execute(&input);
}
void
SWGFeatureSetApi::featuresetPresetPatchCallback(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);
SWGFeaturePresetIdentifier* output = static_cast<SWGFeaturePresetIdentifier*>(create(json, QString("SWGFeaturePresetIdentifier")));
worker->deleteLater();
if (worker->error_type == QNetworkReply::NoError) {
emit featuresetPresetPatchSignal(output);
} else {
emit featuresetPresetPatchSignalE(output, error_type, error_str);
emit featuresetPresetPatchSignalEFull(worker, error_type, error_str);
}
}
void
SWGFeatureSetApi::featuresetPresetPost(qint32 feature_set_index, SWGFeaturePresetIdentifier& body) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/sdrangel/featureset/{featureSetIndex}/preset");
QString feature_set_indexPathParam("{"); feature_set_indexPathParam.append("featureSetIndex").append("}");
fullPath.replace(feature_set_indexPathParam, stringValue(feature_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,
&SWGFeatureSetApi::featuresetPresetPostCallback);
worker->execute(&input);
}
void
SWGFeatureSetApi::featuresetPresetPostCallback(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);
SWGPresetIdentifier* output = static_cast<SWGPresetIdentifier*>(create(json, QString("SWGPresetIdentifier")));
worker->deleteLater();
if (worker->error_type == QNetworkReply::NoError) {
emit featuresetPresetPostSignal(output);
} else {
emit featuresetPresetPostSignalE(output, error_type, error_str);
emit featuresetPresetPostSignalEFull(worker, error_type, error_str);
}
}
void
SWGFeatureSetApi::featuresetPresetPut(qint32 feature_set_index, SWGFeaturePresetIdentifier& body) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/sdrangel/featureset/{featureSetIndex}/preset");
QString feature_set_indexPathParam("{"); feature_set_indexPathParam.append("featureSetIndex").append("}");
fullPath.replace(feature_set_indexPathParam, stringValue(feature_set_index));
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "PUT");
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,
&SWGFeatureSetApi::featuresetPresetPutCallback);
worker->execute(&input);
}
void
SWGFeatureSetApi::featuresetPresetPutCallback(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);
SWGFeaturePresetIdentifier* output = static_cast<SWGFeaturePresetIdentifier*>(create(json, QString("SWGFeaturePresetIdentifier")));
worker->deleteLater();
if (worker->error_type == QNetworkReply::NoError) {
emit featuresetPresetPutSignal(output);
} else {
emit featuresetPresetPutSignalE(output, error_type, error_str);
emit featuresetPresetPutSignalEFull(worker, error_type, error_str);
}
}
void
SWGFeatureSetApi::instanceFeatureSetDelete() {
QString fullPath;

View File

@ -18,9 +18,11 @@
#include "SWGDeviceState.h"
#include "SWGErrorResponse.h"
#include "SWGFeatureActions.h"
#include "SWGFeaturePresetIdentifier.h"
#include "SWGFeatureReport.h"
#include "SWGFeatureSet.h"
#include "SWGFeatureSettings.h"
#include "SWGPresetIdentifier.h"
#include "SWGSuccessResponse.h"
#include <QObject>
@ -50,6 +52,9 @@ public:
void featuresetFeatureSettingsGet(qint32 feature_set_index, qint32 feature_index);
void featuresetFeatureSettingsPatch(qint32 feature_set_index, qint32 feature_index, SWGFeatureSettings& body);
void featuresetGet(qint32 feature_set_index);
void featuresetPresetPatch(qint32 feature_set_index, SWGFeaturePresetIdentifier& body);
void featuresetPresetPost(qint32 feature_set_index, SWGFeaturePresetIdentifier& body);
void featuresetPresetPut(qint32 feature_set_index, SWGFeaturePresetIdentifier& body);
void instanceFeatureSetDelete();
void instanceFeatureSetPost();
@ -65,6 +70,9 @@ private:
void featuresetFeatureSettingsGetCallback (SWGHttpRequestWorker * worker);
void featuresetFeatureSettingsPatchCallback (SWGHttpRequestWorker * worker);
void featuresetGetCallback (SWGHttpRequestWorker * worker);
void featuresetPresetPatchCallback (SWGHttpRequestWorker * worker);
void featuresetPresetPostCallback (SWGHttpRequestWorker * worker);
void featuresetPresetPutCallback (SWGHttpRequestWorker * worker);
void instanceFeatureSetDeleteCallback (SWGHttpRequestWorker * worker);
void instanceFeatureSetPostCallback (SWGHttpRequestWorker * worker);
@ -80,6 +88,9 @@ signals:
void featuresetFeatureSettingsGetSignal(SWGFeatureSettings* summary);
void featuresetFeatureSettingsPatchSignal(SWGFeatureSettings* summary);
void featuresetGetSignal(SWGFeatureSet* summary);
void featuresetPresetPatchSignal(SWGFeaturePresetIdentifier* summary);
void featuresetPresetPostSignal(SWGPresetIdentifier* summary);
void featuresetPresetPutSignal(SWGFeaturePresetIdentifier* summary);
void instanceFeatureSetDeleteSignal(SWGSuccessResponse* summary);
void instanceFeatureSetPostSignal(SWGSuccessResponse* summary);
@ -94,6 +105,9 @@ signals:
void featuresetFeatureSettingsGetSignalE(SWGFeatureSettings* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void featuresetFeatureSettingsPatchSignalE(SWGFeatureSettings* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void featuresetGetSignalE(SWGFeatureSet* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void featuresetPresetPatchSignalE(SWGFeaturePresetIdentifier* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void featuresetPresetPostSignalE(SWGPresetIdentifier* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void featuresetPresetPutSignalE(SWGFeaturePresetIdentifier* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceFeatureSetDeleteSignalE(SWGSuccessResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceFeatureSetPostSignalE(SWGSuccessResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str);
@ -108,6 +122,9 @@ signals:
void featuresetFeatureSettingsGetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void featuresetFeatureSettingsPatchSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void featuresetGetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void featuresetPresetPatchSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void featuresetPresetPostSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void featuresetPresetPutSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceFeatureSetDeleteSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceFeatureSetPostSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);