From f80d16451bbfdb5499185a22522eaa0e0f234fac Mon Sep 17 00:00:00 2001 From: f4exb Date: Mon, 5 Aug 2019 18:29:09 +0200 Subject: [PATCH] REST API: config: PUT (1): swagger implementation. Various small fixes --- plugins/samplemimo/testmi/testmi.cpp | 2 +- .../bladerf1output/bladerf1output.cpp | 2 +- .../bladerf2output/bladerf2output.cpp | 2 +- plugins/samplesink/xtrxoutput/xtrxoutput.cpp | 2 +- .../plutosdrinput/plutosdrinput.cpp | 2 +- .../samplesource/remoteinput/remoteinput.cpp | 2 +- sdrbase/device/deviceutils.cpp | 2 + sdrbase/resources/webapi/doc/html2/index.html | 514 +++++++++++++++--- .../resources/webapi/doc/swagger/swagger.yaml | 27 +- swagger/sdrangel/api/swagger/swagger.yaml | 27 +- swagger/sdrangel/code/html2/index.html | 514 +++++++++++++++--- .../code/qt5/client/SWGInstanceApi.cpp | 67 ++- .../sdrangel/code/qt5/client/SWGInstanceApi.h | 15 +- 13 files changed, 1033 insertions(+), 145 deletions(-) diff --git a/plugins/samplemimo/testmi/testmi.cpp b/plugins/samplemimo/testmi/testmi.cpp index 82cdebaf5..8a6fb176a 100644 --- a/plugins/samplemimo/testmi/testmi.cpp +++ b/plugins/samplemimo/testmi/testmi.cpp @@ -585,7 +585,7 @@ int TestMI::webapiSettingsPutPatch( return 200; } -void webapiUpdateDeviceSettings( +void TestMI::webapiUpdateDeviceSettings( TestMISettings& settings, const QStringList& deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings& response) diff --git a/plugins/samplesink/bladerf1output/bladerf1output.cpp b/plugins/samplesink/bladerf1output/bladerf1output.cpp index e63e74a6c..daf9588b1 100644 --- a/plugins/samplesink/bladerf1output/bladerf1output.cpp +++ b/plugins/samplesink/bladerf1output/bladerf1output.cpp @@ -605,7 +605,7 @@ int Bladerf1Output::webapiSettingsPutPatch( return 200; } -void webapiUpdateDeviceSettings( +void Bladerf1Output::webapiUpdateDeviceSettings( BladeRF1OutputSettings& settings, const QStringList& deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings& response) diff --git a/plugins/samplesink/bladerf2output/bladerf2output.cpp b/plugins/samplesink/bladerf2output/bladerf2output.cpp index 86ad0135d..f3a7bca80 100644 --- a/plugins/samplesink/bladerf2output/bladerf2output.cpp +++ b/plugins/samplesink/bladerf2output/bladerf2output.cpp @@ -981,7 +981,7 @@ int BladeRF2Output::webapiSettingsPutPatch( return 200; } -void webapiUpdateDeviceSettings( +void BladeRF2Output::webapiUpdateDeviceSettings( BladeRF2OutputSettings& settings, const QStringList& deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings& response) diff --git a/plugins/samplesink/xtrxoutput/xtrxoutput.cpp b/plugins/samplesink/xtrxoutput/xtrxoutput.cpp index 61d4ad6c9..e16ca1fa3 100644 --- a/plugins/samplesink/xtrxoutput/xtrxoutput.cpp +++ b/plugins/samplesink/xtrxoutput/xtrxoutput.cpp @@ -1200,7 +1200,7 @@ int XTRXOutput::webapiSettingsPutPatch( return 200; } -void webapiUpdateDeviceSettings( +void XTRXOutput::webapiUpdateDeviceSettings( XTRXOutputSettings& settings, const QStringList& deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings& response) diff --git a/plugins/samplesource/plutosdrinput/plutosdrinput.cpp b/plugins/samplesource/plutosdrinput/plutosdrinput.cpp index c78f5861a..4585e9974 100644 --- a/plugins/samplesource/plutosdrinput/plutosdrinput.cpp +++ b/plugins/samplesource/plutosdrinput/plutosdrinput.cpp @@ -810,7 +810,7 @@ int PlutoSDRInput::webapiSettingsPutPatch( return 200; } -void webapiUpdateDeviceSettings( +void PlutoSDRInput::webapiUpdateDeviceSettings( PlutoSDRInputSettings& settings, const QStringList& deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings& response) diff --git a/plugins/samplesource/remoteinput/remoteinput.cpp b/plugins/samplesource/remoteinput/remoteinput.cpp index 7ef740442..383f662b8 100644 --- a/plugins/samplesource/remoteinput/remoteinput.cpp +++ b/plugins/samplesource/remoteinput/remoteinput.cpp @@ -348,7 +348,7 @@ int RemoteInput::webapiSettingsPutPatch( return 200; } -void webapiUpdateDeviceSettings( +void RemoteInput::webapiUpdateDeviceSettings( RemoteInputSettings& settings, const QStringList& deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings& response) diff --git a/sdrbase/device/deviceutils.cpp b/sdrbase/device/deviceutils.cpp index 62d5e58d2..397190d50 100644 --- a/sdrbase/device/deviceutils.cpp +++ b/sdrbase/device/deviceutils.cpp @@ -26,6 +26,8 @@ QString DeviceUtils::getRegisteredDeviceURI(const QString& xDeviceURI) { if (xDeviceURI == "sdrangel.samplesource.bladerf") { return "sdrangel.samplesource.bladerf1input"; + } else if (xDeviceURI == "sdrangel.samplesource.filesource") { + return "sdrangel.samplesource.fileinput"; } else { return xDeviceURI; } diff --git a/sdrbase/resources/webapi/doc/html2/index.html b/sdrbase/resources/webapi/doc/html2/index.html index a38ae5efe..b6a7805f7 100644 --- a/sdrbase/resources/webapi/doc/html2/index.html +++ b/sdrbase/resources/webapi/doc/html2/index.html @@ -6514,8 +6514,11 @@ margin-bottom: 20px;
  • instanceChannels
  • -
  • - instanceConfig +
  • + instanceConfigGet +
  • +
  • + instanceConfigPut
  • instanceDelete @@ -20474,16 +20477,16 @@ except ApiException as e:
    -
    -
    +
    +
    -

    instanceConfig

    +

    instanceConfigGet

    -

    Get the Preferences, Presets and Commands of the MainSettings saved by Qt

    +

    Get the Preferences, Presets and Commands of the MainSettings saved by Qt. Supports config backup.


    /sdrangel/config
    @@ -20491,24 +20494,24 @@ except ApiException as e:

    Usage and SDK Samples

    -
    +
    curl -X GET "http://localhost/sdrangel/config"
    -
    +
    import SWGSDRangel.*;
     import SWGSDRangel.auth.*;
     import SWGSDRangel.model.*;
    @@ -20523,17 +20526,17 @@ public class InstanceApiExample {
             
             InstanceApi apiInstance = new InstanceApi();
             try {
    -            InstanceConfigResponse result = apiInstance.instanceConfig();
    +            InstanceConfigResponse result = apiInstance.instanceConfigGet();
                 System.out.println(result);
             } catch (ApiException e) {
    -            System.err.println("Exception when calling InstanceApi#instanceConfig");
    +            System.err.println("Exception when calling InstanceApi#instanceConfigGet");
                 e.printStackTrace();
             }
         }
     }
    -
    +
    import SWGSDRangel.api.InstanceApi;
     
     public class InstanceApiExample {
    @@ -20541,24 +20544,24 @@ public class InstanceApiExample {
         public static void main(String[] args) {
             InstanceApi apiInstance = new InstanceApi();
             try {
    -            InstanceConfigResponse result = apiInstance.instanceConfig();
    +            InstanceConfigResponse result = apiInstance.instanceConfigGet();
                 System.out.println(result);
             } catch (ApiException e) {
    -            System.err.println("Exception when calling InstanceApi#instanceConfig");
    +            System.err.println("Exception when calling InstanceApi#instanceConfigGet");
                 e.printStackTrace();
             }
         }
     }
    -
    +
    
     InstanceApi *apiInstance = [[InstanceApi alloc] init];
     
    -[apiInstance instanceConfigWithCompletionHandler: 
    +[apiInstance instanceConfigGetWithCompletionHandler: 
                   ^(InstanceConfigResponse output, NSError* error) {
                                 if (output) {
                                     NSLog(@"%@", output);
    @@ -20570,7 +20573,7 @@ InstanceApi *apiInstance = [[InstanceApi alloc] init];
     
    -
    +
    var SdRangel = require('sd_rangel');
     
     var api = new SdRangel.InstanceApi()
    @@ -20582,14 +20585,14 @@ var callback = function(error, data, response) {
         console.log('API called successfully. Returned data: ' + data);
       }
     };
    -api.instanceConfig(callback);
    +api.instanceConfigGet(callback);
     
    - -
    +
    using System;
     using System.Diagnostics;
     using SWGSDRangel.Api;
    @@ -20598,7 +20601,7 @@ using SWGSDRangel.Model;
     
     namespace Example
     {
    -    public class instanceConfigExample
    +    public class instanceConfigGetExample
         {
             public void main()
             {
    @@ -20607,12 +20610,12 @@ namespace Example
     
                 try
                 {
    -                InstanceConfigResponse result = apiInstance.instanceConfig();
    +                InstanceConfigResponse result = apiInstance.instanceConfigGet();
                     Debug.WriteLine(result);
                 }
                 catch (Exception e)
                 {
    -                Debug.Print("Exception when calling InstanceApi.instanceConfig: " + e.Message );
    +                Debug.Print("Exception when calling InstanceApi.instanceConfigGet: " + e.Message );
                 }
             }
         }
    @@ -20620,22 +20623,22 @@ namespace Example
     
    -
    +
    <?php
     require_once(__DIR__ . '/vendor/autoload.php');
     
     $api_instance = new Swagger\Client\Api\InstanceApi();
     
     try {
    -    $result = $api_instance->instanceConfig();
    +    $result = $api_instance->instanceConfigGet();
         print_r($result);
     } catch (Exception $e) {
    -    echo 'Exception when calling InstanceApi->instanceConfig: ', $e->getMessage(), PHP_EOL;
    +    echo 'Exception when calling InstanceApi->instanceConfigGet: ', $e->getMessage(), PHP_EOL;
     }
     ?>
    -
    +
    use Data::Dumper;
     use SWGSDRangel::Configuration;
     use SWGSDRangel::InstanceApi;
    @@ -20643,15 +20646,15 @@ use SWGSDRangel::InstanceApi;
     my $api_instance = SWGSDRangel::InstanceApi->new();
     
     eval { 
    -    my $result = $api_instance->instanceConfig();
    +    my $result = $api_instance->instanceConfigGet();
         print Dumper($result);
     };
     if ($@) {
    -    warn "Exception when calling InstanceApi->instanceConfig: $@\n";
    +    warn "Exception when calling InstanceApi->instanceConfigGet: $@\n";
     }
    -
    +
    from __future__ import print_statement
     import time
     import swagger_sdrangel
    @@ -20662,10 +20665,10 @@ from pprint import pprint
     api_instance = swagger_sdrangel.InstanceApi()
     
     try: 
    -    api_response = api_instance.instance_config()
    +    api_response = api_instance.instance_config_get()
         pprint(api_response)
     except ApiException as e:
    -    print("Exception when calling InstanceApi->instanceConfig: %s\n" % e)
    + print("Exception when calling InstanceApi->instanceConfigGet: %s\n" % e)
    @@ -20681,14 +20684,14 @@ except ApiException as e:
    -
    -
    +
    +
    - +
    @@ -20724,14 +20727,14 @@ except ApiException as e:
    -
    -
    +
    +
    - +
    @@ -20767,14 +20770,14 @@ except ApiException as e:
    -
    -
    +
    +
    - + +
    +
    + +
    +
    +
    +
    +
    +
    +

    instanceConfigPut

    +

    +
    +
    +
    +

    +

    Replace the Preferences, Presets and Commands of the MainSettings object with the contents of the payload. Supports config restore.

    +

    +
    +
    /sdrangel/config
    +

    +

    Usage and SDK Samples

    +

    + + +
    +
    +
    curl -X PUT "http://localhost/sdrangel/config"
    +
    +
    +
    import SWGSDRangel.*;
    +import SWGSDRangel.auth.*;
    +import SWGSDRangel.model.*;
    +import SWGSDRangel.api.InstanceApi;
    +
    +import java.io.File;
    +import java.util.*;
    +
    +public class InstanceApiExample {
    +
    +    public static void main(String[] args) {
    +        
    +        InstanceApi apiInstance = new InstanceApi();
    +        InstanceConfigResponse body = ; // InstanceConfigResponse | Config information
    +        try {
    +            SuccessResponse result = apiInstance.instanceConfigPut(body);
    +            System.out.println(result);
    +        } catch (ApiException e) {
    +            System.err.println("Exception when calling InstanceApi#instanceConfigPut");
    +            e.printStackTrace();
    +        }
    +    }
    +}
    +
    + +
    +
    import SWGSDRangel.api.InstanceApi;
    +
    +public class InstanceApiExample {
    +
    +    public static void main(String[] args) {
    +        InstanceApi apiInstance = new InstanceApi();
    +        InstanceConfigResponse body = ; // InstanceConfigResponse | Config information
    +        try {
    +            SuccessResponse result = apiInstance.instanceConfigPut(body);
    +            System.out.println(result);
    +        } catch (ApiException e) {
    +            System.err.println("Exception when calling InstanceApi#instanceConfigPut");
    +            e.printStackTrace();
    +        }
    +    }
    +}
    +
    + +
    +
    InstanceConfigResponse *body = ; // Config information
    +
    +InstanceApi *apiInstance = [[InstanceApi alloc] init];
    +
    +[apiInstance instanceConfigPutWith:body
    +              completionHandler: ^(SuccessResponse output, NSError* error) {
    +                            if (output) {
    +                                NSLog(@"%@", output);
    +                            }
    +                            if (error) {
    +                                NSLog(@"Error: %@", error);
    +                            }
    +                        }];
    +
    +
    + +
    +
    var SdRangel = require('sd_rangel');
    +
    +var api = new SdRangel.InstanceApi()
    +
    +var body = ; // {InstanceConfigResponse} Config information
    +
    +
    +var callback = function(error, data, response) {
    +  if (error) {
    +    console.error(error);
    +  } else {
    +    console.log('API called successfully. Returned data: ' + data);
    +  }
    +};
    +api.instanceConfigPut(body, callback);
    +
    +
    + + +
    +
    using System;
    +using System.Diagnostics;
    +using SWGSDRangel.Api;
    +using SWGSDRangel.Client;
    +using SWGSDRangel.Model;
    +
    +namespace Example
    +{
    +    public class instanceConfigPutExample
    +    {
    +        public void main()
    +        {
    +            
    +            var apiInstance = new InstanceApi();
    +            var body = new InstanceConfigResponse(); // InstanceConfigResponse | Config information
    +
    +            try
    +            {
    +                SuccessResponse result = apiInstance.instanceConfigPut(body);
    +                Debug.WriteLine(result);
    +            }
    +            catch (Exception e)
    +            {
    +                Debug.Print("Exception when calling InstanceApi.instanceConfigPut: " + e.Message );
    +            }
    +        }
    +    }
    +}
    +
    +
    + +
    +
    <?php
    +require_once(__DIR__ . '/vendor/autoload.php');
    +
    +$api_instance = new Swagger\Client\Api\InstanceApi();
    +$body = ; // InstanceConfigResponse | Config information
    +
    +try {
    +    $result = $api_instance->instanceConfigPut($body);
    +    print_r($result);
    +} catch (Exception $e) {
    +    echo 'Exception when calling InstanceApi->instanceConfigPut: ', $e->getMessage(), PHP_EOL;
    +}
    +?>
    +
    + +
    +
    use Data::Dumper;
    +use SWGSDRangel::Configuration;
    +use SWGSDRangel::InstanceApi;
    +
    +my $api_instance = SWGSDRangel::InstanceApi->new();
    +my $body = SWGSDRangel::Object::InstanceConfigResponse->new(); # InstanceConfigResponse | Config information
    +
    +eval { 
    +    my $result = $api_instance->instanceConfigPut(body => $body);
    +    print Dumper($result);
    +};
    +if ($@) {
    +    warn "Exception when calling InstanceApi->instanceConfigPut: $@\n";
    +}
    +
    + +
    +
    from __future__ import print_statement
    +import time
    +import swagger_sdrangel
    +from swagger_sdrangel.rest import ApiException
    +from pprint import pprint
    +
    +# create an instance of the API class
    +api_instance = swagger_sdrangel.InstanceApi()
    +body =  # InstanceConfigResponse | Config information
    +
    +try: 
    +    api_response = api_instance.instance_config_put(body)
    +    pprint(api_response)
    +except ApiException as e:
    +    print("Exception when calling InstanceApi->instanceConfigPut: %s\n" % e)
    +
    +
    + +

    Parameters

    + + + +
    Body parameters
    + + + + + + + + + +
    NameDescription
    body * + + + +
    +
    + + + +

    Responses

    +

    Status: 200 - Success

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 500 - Error

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 501 - Function not implemented

    + + + +
    +
    +
    + +
    +
    @@ -26955,7 +27345,7 @@ except ApiException as e:
    - Generated 2019-08-05T03:02:48.921+02:00 + Generated 2019-08-05T18:13:15.915+02:00
    diff --git a/sdrbase/resources/webapi/doc/swagger/swagger.yaml b/sdrbase/resources/webapi/doc/swagger/swagger.yaml index 9b170c5e5..850c75c42 100644 --- a/sdrbase/resources/webapi/doc/swagger/swagger.yaml +++ b/sdrbase/resources/webapi/doc/swagger/swagger.yaml @@ -78,8 +78,8 @@ paths: /sdrangel/config: x-swagger-router-controller: instance get: - description: Get the Preferences, Presets and Commands of the MainSettings saved by Qt - operationId: instanceConfig + description: Get the Preferences, Presets and Commands of the MainSettings saved by Qt. Supports config backup. + operationId: instanceConfigGet tags: - Instance responses: @@ -92,6 +92,29 @@ paths: $ref: "#/responses/Response_500" "501": $ref: "#/responses/Response_501" + put: + description: Replace the Preferences, Presets and Commands of the MainSettings object with the contents of the payload. Supports config restore. + operationId: instanceConfigPut + tags: + - Instance + consumes: + - application/json + parameters: + - name: body + in: body + description: Config information + required: true + schema: + $ref: "#/definitions/InstanceConfigResponse" + responses: + "200": + description: Success + schema: + $ref: "#/definitions/SuccessResponse" + "500": + $ref: "#/responses/Response_500" + "501": + $ref: "#/responses/Response_501" /sdrangel/devices: x-swagger-router-controller: instance diff --git a/swagger/sdrangel/api/swagger/swagger.yaml b/swagger/sdrangel/api/swagger/swagger.yaml index e34f9d7d6..38744f583 100644 --- a/swagger/sdrangel/api/swagger/swagger.yaml +++ b/swagger/sdrangel/api/swagger/swagger.yaml @@ -78,8 +78,8 @@ paths: /sdrangel/config: x-swagger-router-controller: instance get: - description: Get the Preferences, Presets and Commands of the MainSettings saved by Qt - operationId: instanceConfig + description: Get the Preferences, Presets and Commands of the MainSettings saved by Qt. Supports config backup. + operationId: instanceConfigGet tags: - Instance responses: @@ -92,6 +92,29 @@ paths: $ref: "#/responses/Response_500" "501": $ref: "#/responses/Response_501" + put: + description: Replace the Preferences, Presets and Commands of the MainSettings object with the contents of the payload. Supports config restore. + operationId: instanceConfigPut + tags: + - Instance + consumes: + - application/json + parameters: + - name: body + in: body + description: Config information + required: true + schema: + $ref: "#/definitions/InstanceConfigResponse" + responses: + "200": + description: Success + schema: + $ref: "#/definitions/SuccessResponse" + "500": + $ref: "#/responses/Response_500" + "501": + $ref: "#/responses/Response_501" /sdrangel/devices: x-swagger-router-controller: instance diff --git a/swagger/sdrangel/code/html2/index.html b/swagger/sdrangel/code/html2/index.html index a38ae5efe..b6a7805f7 100644 --- a/swagger/sdrangel/code/html2/index.html +++ b/swagger/sdrangel/code/html2/index.html @@ -6514,8 +6514,11 @@ margin-bottom: 20px;
  • instanceChannels
  • -
  • - instanceConfig +
  • + instanceConfigGet +
  • +
  • + instanceConfigPut
  • instanceDelete @@ -20474,16 +20477,16 @@ except ApiException as e:
    -
    -
    +
    +
    -

    instanceConfig

    +

    instanceConfigGet

    -

    Get the Preferences, Presets and Commands of the MainSettings saved by Qt

    +

    Get the Preferences, Presets and Commands of the MainSettings saved by Qt. Supports config backup.


    /sdrangel/config
    @@ -20491,24 +20494,24 @@ except ApiException as e:

    Usage and SDK Samples

    -
    +
    curl -X GET "http://localhost/sdrangel/config"
    -
    +
    import SWGSDRangel.*;
     import SWGSDRangel.auth.*;
     import SWGSDRangel.model.*;
    @@ -20523,17 +20526,17 @@ public class InstanceApiExample {
             
             InstanceApi apiInstance = new InstanceApi();
             try {
    -            InstanceConfigResponse result = apiInstance.instanceConfig();
    +            InstanceConfigResponse result = apiInstance.instanceConfigGet();
                 System.out.println(result);
             } catch (ApiException e) {
    -            System.err.println("Exception when calling InstanceApi#instanceConfig");
    +            System.err.println("Exception when calling InstanceApi#instanceConfigGet");
                 e.printStackTrace();
             }
         }
     }
    -
    +
    import SWGSDRangel.api.InstanceApi;
     
     public class InstanceApiExample {
    @@ -20541,24 +20544,24 @@ public class InstanceApiExample {
         public static void main(String[] args) {
             InstanceApi apiInstance = new InstanceApi();
             try {
    -            InstanceConfigResponse result = apiInstance.instanceConfig();
    +            InstanceConfigResponse result = apiInstance.instanceConfigGet();
                 System.out.println(result);
             } catch (ApiException e) {
    -            System.err.println("Exception when calling InstanceApi#instanceConfig");
    +            System.err.println("Exception when calling InstanceApi#instanceConfigGet");
                 e.printStackTrace();
             }
         }
     }
    -
    +
    
     InstanceApi *apiInstance = [[InstanceApi alloc] init];
     
    -[apiInstance instanceConfigWithCompletionHandler: 
    +[apiInstance instanceConfigGetWithCompletionHandler: 
                   ^(InstanceConfigResponse output, NSError* error) {
                                 if (output) {
                                     NSLog(@"%@", output);
    @@ -20570,7 +20573,7 @@ InstanceApi *apiInstance = [[InstanceApi alloc] init];
     
    -
    +
    var SdRangel = require('sd_rangel');
     
     var api = new SdRangel.InstanceApi()
    @@ -20582,14 +20585,14 @@ var callback = function(error, data, response) {
         console.log('API called successfully. Returned data: ' + data);
       }
     };
    -api.instanceConfig(callback);
    +api.instanceConfigGet(callback);
     
    - -
    +
    using System;
     using System.Diagnostics;
     using SWGSDRangel.Api;
    @@ -20598,7 +20601,7 @@ using SWGSDRangel.Model;
     
     namespace Example
     {
    -    public class instanceConfigExample
    +    public class instanceConfigGetExample
         {
             public void main()
             {
    @@ -20607,12 +20610,12 @@ namespace Example
     
                 try
                 {
    -                InstanceConfigResponse result = apiInstance.instanceConfig();
    +                InstanceConfigResponse result = apiInstance.instanceConfigGet();
                     Debug.WriteLine(result);
                 }
                 catch (Exception e)
                 {
    -                Debug.Print("Exception when calling InstanceApi.instanceConfig: " + e.Message );
    +                Debug.Print("Exception when calling InstanceApi.instanceConfigGet: " + e.Message );
                 }
             }
         }
    @@ -20620,22 +20623,22 @@ namespace Example
     
    -
    +
    <?php
     require_once(__DIR__ . '/vendor/autoload.php');
     
     $api_instance = new Swagger\Client\Api\InstanceApi();
     
     try {
    -    $result = $api_instance->instanceConfig();
    +    $result = $api_instance->instanceConfigGet();
         print_r($result);
     } catch (Exception $e) {
    -    echo 'Exception when calling InstanceApi->instanceConfig: ', $e->getMessage(), PHP_EOL;
    +    echo 'Exception when calling InstanceApi->instanceConfigGet: ', $e->getMessage(), PHP_EOL;
     }
     ?>
    -
    +
    use Data::Dumper;
     use SWGSDRangel::Configuration;
     use SWGSDRangel::InstanceApi;
    @@ -20643,15 +20646,15 @@ use SWGSDRangel::InstanceApi;
     my $api_instance = SWGSDRangel::InstanceApi->new();
     
     eval { 
    -    my $result = $api_instance->instanceConfig();
    +    my $result = $api_instance->instanceConfigGet();
         print Dumper($result);
     };
     if ($@) {
    -    warn "Exception when calling InstanceApi->instanceConfig: $@\n";
    +    warn "Exception when calling InstanceApi->instanceConfigGet: $@\n";
     }
    -
    +
    from __future__ import print_statement
     import time
     import swagger_sdrangel
    @@ -20662,10 +20665,10 @@ from pprint import pprint
     api_instance = swagger_sdrangel.InstanceApi()
     
     try: 
    -    api_response = api_instance.instance_config()
    +    api_response = api_instance.instance_config_get()
         pprint(api_response)
     except ApiException as e:
    -    print("Exception when calling InstanceApi->instanceConfig: %s\n" % e)
    + print("Exception when calling InstanceApi->instanceConfigGet: %s\n" % e)
    @@ -20681,14 +20684,14 @@ except ApiException as e:
    -
    -
    +
    +
    - +
    @@ -20724,14 +20727,14 @@ except ApiException as e:
    -
    -
    +
    +
    - +
    @@ -20767,14 +20770,14 @@ except ApiException as e:
    -
    -
    +
    +
    - + +
    +
    + +
    +
    +
    +
    +
    +
    +

    instanceConfigPut

    +

    +
    +
    +
    +

    +

    Replace the Preferences, Presets and Commands of the MainSettings object with the contents of the payload. Supports config restore.

    +

    +
    +
    /sdrangel/config
    +

    +

    Usage and SDK Samples

    +

    + + +
    +
    +
    curl -X PUT "http://localhost/sdrangel/config"
    +
    +
    +
    import SWGSDRangel.*;
    +import SWGSDRangel.auth.*;
    +import SWGSDRangel.model.*;
    +import SWGSDRangel.api.InstanceApi;
    +
    +import java.io.File;
    +import java.util.*;
    +
    +public class InstanceApiExample {
    +
    +    public static void main(String[] args) {
    +        
    +        InstanceApi apiInstance = new InstanceApi();
    +        InstanceConfigResponse body = ; // InstanceConfigResponse | Config information
    +        try {
    +            SuccessResponse result = apiInstance.instanceConfigPut(body);
    +            System.out.println(result);
    +        } catch (ApiException e) {
    +            System.err.println("Exception when calling InstanceApi#instanceConfigPut");
    +            e.printStackTrace();
    +        }
    +    }
    +}
    +
    + +
    +
    import SWGSDRangel.api.InstanceApi;
    +
    +public class InstanceApiExample {
    +
    +    public static void main(String[] args) {
    +        InstanceApi apiInstance = new InstanceApi();
    +        InstanceConfigResponse body = ; // InstanceConfigResponse | Config information
    +        try {
    +            SuccessResponse result = apiInstance.instanceConfigPut(body);
    +            System.out.println(result);
    +        } catch (ApiException e) {
    +            System.err.println("Exception when calling InstanceApi#instanceConfigPut");
    +            e.printStackTrace();
    +        }
    +    }
    +}
    +
    + +
    +
    InstanceConfigResponse *body = ; // Config information
    +
    +InstanceApi *apiInstance = [[InstanceApi alloc] init];
    +
    +[apiInstance instanceConfigPutWith:body
    +              completionHandler: ^(SuccessResponse output, NSError* error) {
    +                            if (output) {
    +                                NSLog(@"%@", output);
    +                            }
    +                            if (error) {
    +                                NSLog(@"Error: %@", error);
    +                            }
    +                        }];
    +
    +
    + +
    +
    var SdRangel = require('sd_rangel');
    +
    +var api = new SdRangel.InstanceApi()
    +
    +var body = ; // {InstanceConfigResponse} Config information
    +
    +
    +var callback = function(error, data, response) {
    +  if (error) {
    +    console.error(error);
    +  } else {
    +    console.log('API called successfully. Returned data: ' + data);
    +  }
    +};
    +api.instanceConfigPut(body, callback);
    +
    +
    + + +
    +
    using System;
    +using System.Diagnostics;
    +using SWGSDRangel.Api;
    +using SWGSDRangel.Client;
    +using SWGSDRangel.Model;
    +
    +namespace Example
    +{
    +    public class instanceConfigPutExample
    +    {
    +        public void main()
    +        {
    +            
    +            var apiInstance = new InstanceApi();
    +            var body = new InstanceConfigResponse(); // InstanceConfigResponse | Config information
    +
    +            try
    +            {
    +                SuccessResponse result = apiInstance.instanceConfigPut(body);
    +                Debug.WriteLine(result);
    +            }
    +            catch (Exception e)
    +            {
    +                Debug.Print("Exception when calling InstanceApi.instanceConfigPut: " + e.Message );
    +            }
    +        }
    +    }
    +}
    +
    +
    + +
    +
    <?php
    +require_once(__DIR__ . '/vendor/autoload.php');
    +
    +$api_instance = new Swagger\Client\Api\InstanceApi();
    +$body = ; // InstanceConfigResponse | Config information
    +
    +try {
    +    $result = $api_instance->instanceConfigPut($body);
    +    print_r($result);
    +} catch (Exception $e) {
    +    echo 'Exception when calling InstanceApi->instanceConfigPut: ', $e->getMessage(), PHP_EOL;
    +}
    +?>
    +
    + +
    +
    use Data::Dumper;
    +use SWGSDRangel::Configuration;
    +use SWGSDRangel::InstanceApi;
    +
    +my $api_instance = SWGSDRangel::InstanceApi->new();
    +my $body = SWGSDRangel::Object::InstanceConfigResponse->new(); # InstanceConfigResponse | Config information
    +
    +eval { 
    +    my $result = $api_instance->instanceConfigPut(body => $body);
    +    print Dumper($result);
    +};
    +if ($@) {
    +    warn "Exception when calling InstanceApi->instanceConfigPut: $@\n";
    +}
    +
    + +
    +
    from __future__ import print_statement
    +import time
    +import swagger_sdrangel
    +from swagger_sdrangel.rest import ApiException
    +from pprint import pprint
    +
    +# create an instance of the API class
    +api_instance = swagger_sdrangel.InstanceApi()
    +body =  # InstanceConfigResponse | Config information
    +
    +try: 
    +    api_response = api_instance.instance_config_put(body)
    +    pprint(api_response)
    +except ApiException as e:
    +    print("Exception when calling InstanceApi->instanceConfigPut: %s\n" % e)
    +
    +
    + +

    Parameters

    + + + +
    Body parameters
    + + + + + + + + + +
    NameDescription
    body * + + + +
    +
    + + + +

    Responses

    +

    Status: 200 - Success

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 500 - Error

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 501 - Function not implemented

    + + + +
    +
    +
    + +
    +
    @@ -26955,7 +27345,7 @@ except ApiException as e:
    - Generated 2019-08-05T03:02:48.921+02:00 + Generated 2019-08-05T18:13:15.915+02:00
    diff --git a/swagger/sdrangel/code/qt5/client/SWGInstanceApi.cpp b/swagger/sdrangel/code/qt5/client/SWGInstanceApi.cpp index ba39da967..35a38c355 100644 --- a/swagger/sdrangel/code/qt5/client/SWGInstanceApi.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGInstanceApi.cpp @@ -731,7 +731,7 @@ SWGInstanceApi::instanceChannelsCallback(SWGHttpRequestWorker * worker) { } void -SWGInstanceApi::instanceConfig() { +SWGInstanceApi::instanceConfigGet() { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/sdrangel/config"); @@ -751,13 +751,13 @@ SWGInstanceApi::instanceConfig() { connect(worker, &SWGHttpRequestWorker::on_execution_finished, this, - &SWGInstanceApi::instanceConfigCallback); + &SWGInstanceApi::instanceConfigGetCallback); worker->execute(&input); } void -SWGInstanceApi::instanceConfigCallback(SWGHttpRequestWorker * worker) { +SWGInstanceApi::instanceConfigGetCallback(SWGHttpRequestWorker * worker) { QString msg; QString error_str = worker->error_str; QNetworkReply::NetworkError error_type = worker->error_type; @@ -775,10 +775,65 @@ SWGInstanceApi::instanceConfigCallback(SWGHttpRequestWorker * worker) { worker->deleteLater(); if (worker->error_type == QNetworkReply::NoError) { - emit instanceConfigSignal(output); + emit instanceConfigGetSignal(output); } else { - emit instanceConfigSignalE(output, error_type, error_str); - emit instanceConfigSignalEFull(worker, error_type, error_str); + emit instanceConfigGetSignalE(output, error_type, error_str); + emit instanceConfigGetSignalEFull(worker, error_type, error_str); + } +} + +void +SWGInstanceApi::instanceConfigPut(SWGInstanceConfigResponse& body) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/sdrangel/config"); + + + + 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, + &SWGInstanceApi::instanceConfigPutCallback); + + worker->execute(&input); +} + +void +SWGInstanceApi::instanceConfigPutCallback(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(create(json, QString("SWGSuccessResponse"))); + worker->deleteLater(); + + if (worker->error_type == QNetworkReply::NoError) { + emit instanceConfigPutSignal(output); + } else { + emit instanceConfigPutSignalE(output, error_type, error_str); + emit instanceConfigPutSignalEFull(worker, error_type, error_str); } } diff --git a/swagger/sdrangel/code/qt5/client/SWGInstanceApi.h b/swagger/sdrangel/code/qt5/client/SWGInstanceApi.h index 65bc260b5..df9385c38 100644 --- a/swagger/sdrangel/code/qt5/client/SWGInstanceApi.h +++ b/swagger/sdrangel/code/qt5/client/SWGInstanceApi.h @@ -64,7 +64,8 @@ public: void instanceAudioOutputDelete(SWGAudioOutputDevice& body); void instanceAudioOutputPatch(SWGAudioOutputDevice& body); void instanceChannels(qint32 direction); - void instanceConfig(); + void instanceConfigGet(); + void instanceConfigPut(SWGInstanceConfigResponse& body); void instanceDelete(); void instanceDeviceSetsGet(); void instanceDevices(qint32 direction); @@ -95,7 +96,8 @@ private: void instanceAudioOutputDeleteCallback (SWGHttpRequestWorker * worker); void instanceAudioOutputPatchCallback (SWGHttpRequestWorker * worker); void instanceChannelsCallback (SWGHttpRequestWorker * worker); - void instanceConfigCallback (SWGHttpRequestWorker * worker); + void instanceConfigGetCallback (SWGHttpRequestWorker * worker); + void instanceConfigPutCallback (SWGHttpRequestWorker * worker); void instanceDeleteCallback (SWGHttpRequestWorker * worker); void instanceDeviceSetsGetCallback (SWGHttpRequestWorker * worker); void instanceDevicesCallback (SWGHttpRequestWorker * worker); @@ -126,7 +128,8 @@ signals: void instanceAudioOutputDeleteSignal(SWGAudioOutputDevice* summary); void instanceAudioOutputPatchSignal(SWGAudioOutputDevice* summary); void instanceChannelsSignal(SWGInstanceChannelsResponse* summary); - void instanceConfigSignal(SWGInstanceConfigResponse* summary); + void instanceConfigGetSignal(SWGInstanceConfigResponse* summary); + void instanceConfigPutSignal(SWGSuccessResponse* summary); void instanceDeleteSignal(SWGInstanceSummaryResponse* summary); void instanceDeviceSetsGetSignal(SWGDeviceSetList* summary); void instanceDevicesSignal(SWGInstanceDevicesResponse* summary); @@ -156,7 +159,8 @@ signals: void instanceAudioOutputDeleteSignalE(SWGAudioOutputDevice* summary, QNetworkReply::NetworkError error_type, QString& error_str); void instanceAudioOutputPatchSignalE(SWGAudioOutputDevice* summary, QNetworkReply::NetworkError error_type, QString& error_str); void instanceChannelsSignalE(SWGInstanceChannelsResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str); - void instanceConfigSignalE(SWGInstanceConfigResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str); + void instanceConfigGetSignalE(SWGInstanceConfigResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str); + void instanceConfigPutSignalE(SWGSuccessResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str); void instanceDeleteSignalE(SWGInstanceSummaryResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str); void instanceDeviceSetsGetSignalE(SWGDeviceSetList* summary, QNetworkReply::NetworkError error_type, QString& error_str); void instanceDevicesSignalE(SWGInstanceDevicesResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str); @@ -186,7 +190,8 @@ signals: void instanceAudioOutputDeleteSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void instanceAudioOutputPatchSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void instanceChannelsSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); - void instanceConfigSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); + void instanceConfigGetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); + void instanceConfigPutSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void instanceDeleteSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void instanceDeviceSetsGetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void instanceDevicesSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);