File tree Expand file tree Collapse file tree 2 files changed +32
-7
lines changed
Expand file tree Collapse file tree 2 files changed +32
-7
lines changed Original file line number Diff line number Diff line change @@ -58,8 +58,9 @@ pub struct Config {
5858 /// Spylnx Integration
5959 pub spylnx_integration : super :: spylnx_integration:: SplynxIntegration ,
6060
61- /// Netzur Integration
62- pub netzur_integration : super :: netzur_integration:: NetzurIntegration ,
61+ /// Netzur Integration configuration. Optional so older configs without this
62+ /// section still deserialize cleanly.
63+ pub netzur_integration : Option < super :: netzur_integration:: NetzurIntegration > ,
6364
6465 /// UISP Integration
6566 pub uisp_integration : super :: uisp_integration:: UispIntegration ,
@@ -150,7 +151,7 @@ impl Default for Config {
150151 ip_ranges : super :: ip_ranges:: IpRanges :: default ( ) ,
151152 integration_common : super :: integration_common:: IntegrationConfig :: default ( ) ,
152153 spylnx_integration : super :: spylnx_integration:: SplynxIntegration :: default ( ) ,
153- netzur_integration : super :: netzur_integration:: NetzurIntegration :: default ( ) ,
154+ netzur_integration : Some ( super :: netzur_integration:: NetzurIntegration :: default ( ) ) ,
154155 uisp_integration : super :: uisp_integration:: UispIntegration :: default ( ) ,
155156 powercode_integration : super :: powercode_integration:: PowercodeIntegration :: default ( ) ,
156157 sonar_integration : super :: sonar_integration:: SonarIntegration :: default ( ) ,
Original file line number Diff line number Diff line change @@ -595,19 +595,37 @@ fn splynx_strategy() -> PyResult<String> {
595595#[ pyfunction]
596596fn netzur_api_key ( ) -> PyResult < String > {
597597 let config = lqos_config:: load_config ( ) . unwrap ( ) ;
598- Ok ( config. netzur_integration . api_key . clone ( ) )
598+ Ok (
599+ config
600+ . netzur_integration
601+ . as_ref ( )
602+ . map ( |cfg| cfg. api_key . clone ( ) )
603+ . unwrap_or_default ( ) ,
604+ )
599605}
600606
601607#[ pyfunction]
602608fn netzur_api_url ( ) -> PyResult < String > {
603609 let config = lqos_config:: load_config ( ) . unwrap ( ) ;
604- Ok ( config. netzur_integration . api_url . clone ( ) )
610+ Ok (
611+ config
612+ . netzur_integration
613+ . as_ref ( )
614+ . map ( |cfg| cfg. api_url . clone ( ) )
615+ . unwrap_or_default ( ) ,
616+ )
605617}
606618
607619#[ pyfunction]
608620fn netzur_api_timeout ( ) -> PyResult < u64 > {
609621 let config = lqos_config:: load_config ( ) . unwrap ( ) ;
610- Ok ( config. netzur_integration . timeout_secs )
622+ Ok (
623+ config
624+ . netzur_integration
625+ . as_ref ( )
626+ . map ( |cfg| cfg. timeout_secs )
627+ . unwrap_or ( 60 ) ,
628+ )
611629}
612630
613631#[ pyfunction]
@@ -625,7 +643,13 @@ fn automatic_import_splynx() -> PyResult<bool> {
625643#[ pyfunction]
626644fn automatic_import_netzur ( ) -> PyResult < bool > {
627645 let config = lqos_config:: load_config ( ) . unwrap ( ) ;
628- Ok ( config. netzur_integration . enable_netzur )
646+ Ok (
647+ config
648+ . netzur_integration
649+ . as_ref ( )
650+ . map ( |cfg| cfg. enable_netzur )
651+ . unwrap_or ( false ) ,
652+ )
629653}
630654
631655#[ pyfunction]
You can’t perform that action at this time.
0 commit comments