@@ -43,18 +43,23 @@ func (h *GetDefaultsHandlerImpl) Handle(params defaults.GetDefaultsSectionParams
4343 t = * params .TransactionID
4444 }
4545
46- configuration , err := h .Client . Configuration ( )
46+ _ , data , err := h .getDefaultsConfiguration ( params , t )
4747 if err != nil {
4848 e := misc .HandleError (err )
4949 return defaults .NewGetDefaultsSectionDefault (int (* e .Code )).WithPayload (e )
5050 }
51+ return defaults .NewGetDefaultsSectionOK ().WithPayload (data )
52+ }
5153
52- _ , data , err := configuration .GetDefaultsConfiguration (t )
54+ func (h * GetDefaultsHandlerImpl ) getDefaultsConfiguration (params defaults.GetDefaultsSectionParams , t string ) (int64 , * models.Defaults , error ) {
55+ configuration , err := h .Client .Configuration ()
5356 if err != nil {
54- e := misc .HandleError (err )
55- return defaults .NewGetDefaultsSectionDefault (int (* e .Code )).WithPayload (e )
57+ return 0 , nil , err
5658 }
57- return defaults .NewGetDefaultsSectionOK ().WithPayload (data )
59+ if params .FullSection != nil && * params .FullSection {
60+ return configuration .GetStructuredDefaultsConfiguration (t )
61+ }
62+ return configuration .GetDefaultsConfiguration (t )
5863}
5964
6065// Handle executing the request and returning a response
@@ -78,13 +83,7 @@ func (h *ReplaceDefaultsHandlerImpl) Handle(params defaults.ReplaceDefaultsSecti
7883 return defaults .NewReplaceDefaultsSectionDefault (int (* e .Code )).WithPayload (e )
7984 }
8085
81- configuration , err := h .Client .Configuration ()
82- if err != nil {
83- e := misc .HandleError (err )
84- return defaults .NewReplaceDefaultsSectionDefault (int (* e .Code )).WithPayload (e )
85- }
86-
87- err = configuration .PushDefaultsConfiguration (params .Data , t , v )
86+ err := h .pushDefaultsConfiguration (params , t , v )
8887 if err != nil {
8988 e := misc .HandleError (err )
9089 return defaults .NewReplaceDefaultsSectionDefault (int (* e .Code )).WithPayload (e )
@@ -105,6 +104,17 @@ func (h *ReplaceDefaultsHandlerImpl) Handle(params defaults.ReplaceDefaultsSecti
105104 return defaults .NewReplaceDefaultsSectionAccepted ().WithPayload (params .Data )
106105}
107106
107+ func (h * ReplaceDefaultsHandlerImpl ) pushDefaultsConfiguration (params defaults.ReplaceDefaultsSectionParams , t string , v int64 ) error {
108+ configuration , err := h .Client .Configuration ()
109+ if err != nil {
110+ return err
111+ }
112+ if params .FullSection != nil && * params .FullSection {
113+ return configuration .PushStructuredDefaultsConfiguration (params .Data , t , v )
114+ }
115+ return configuration .PushDefaultsConfiguration (params .Data , t , v )
116+ }
117+
108118// GetDefaultsHandlerImpl implementation of the GetDefaultsHandler interface
109119type GetDefaultsSectionsHandlerImpl struct {
110120 Client client_native.HAProxyClient
@@ -130,6 +140,17 @@ func (h GetDefaultsSectionsHandlerImpl) Handle(params defaults.GetDefaultsSectio
130140 return defaults .NewGetDefaultsSectionsOK ().WithPayload (fs )
131141}
132142
143+ func (h * GetDefaultsSectionsHandlerImpl ) getDefaultsSections (params defaults.GetDefaultsSectionParams , t string ) (int64 , models.DefaultsSections , error ) {
144+ configuration , err := h .Client .Configuration ()
145+ if err != nil {
146+ return 0 , nil , err
147+ }
148+ if params .FullSection != nil && * params .FullSection {
149+ return configuration .GetStructuredDefaultsSections (t )
150+ }
151+ return configuration .GetDefaultsSections (t )
152+ }
153+
133154type GetDefaultsSectionHandlerImpl struct {
134155 Client client_native.HAProxyClient
135156}
@@ -140,18 +161,23 @@ func (h GetDefaultsSectionHandlerImpl) Handle(params defaults.GetDefaultsSection
140161 t = * params .TransactionID
141162 }
142163
143- configuration , err := h .Client . Configuration ( )
164+ _ , f , err := h .getDefaultsSection ( params , t )
144165 if err != nil {
145166 e := misc .HandleError (err )
146167 return defaults .NewGetDefaultsSectionDefault (int (* e .Code )).WithPayload (e )
147168 }
169+ return defaults .NewGetDefaultsSectionOK ().WithPayload (f )
170+ }
148171
149- _ , f , err := configuration .GetDefaultsSection (params .Name , t )
172+ func (h * GetDefaultsSectionHandlerImpl ) getDefaultsSection (params defaults.GetDefaultsSectionParams , t string ) (int64 , * models.Defaults , error ) {
173+ configuration , err := h .Client .Configuration ()
150174 if err != nil {
151- e := misc .HandleError (err )
152- return defaults .NewGetDefaultsSectionDefault (int (* e .Code )).WithPayload (e )
175+ return 0 , nil , err
153176 }
154- return defaults .NewGetDefaultsSectionOK ().WithPayload (f )
177+ if params .FullSection != nil && * params .FullSection {
178+ return configuration .GetStructuredDefaultsSection (params .Name , t )
179+ }
180+ return configuration .GetDefaultsSection (params .Name , t )
155181}
156182
157183type CreateDefaultsSectionHandlerImpl struct {
@@ -179,13 +205,7 @@ func (h CreateDefaultsSectionHandlerImpl) Handle(params defaults.CreateDefaultsS
179205 return defaults .NewCreateDefaultsSectionDefault (int (* e .Code )).WithPayload (e )
180206 }
181207
182- configuration , err := h .Client .Configuration ()
183- if err != nil {
184- e := misc .HandleError (err )
185- return defaults .NewCreateDefaultsSectionDefault (int (* e .Code )).WithPayload (e )
186- }
187-
188- err = configuration .CreateDefaultsSection (params .Data , t , v )
208+ err := h .createDefaultsSection (params , t , v )
189209 if err != nil {
190210 e := misc .HandleError (err )
191211 return defaults .NewCreateDefaultsSectionDefault (int (* e .Code )).WithPayload (e )
@@ -205,6 +225,17 @@ func (h CreateDefaultsSectionHandlerImpl) Handle(params defaults.CreateDefaultsS
205225 return defaults .NewCreateDefaultsSectionAccepted ().WithPayload (params .Data )
206226}
207227
228+ func (h * CreateDefaultsSectionHandlerImpl ) createDefaultsSection (params defaults.CreateDefaultsSectionParams , t string , v int64 ) error {
229+ configuration , err := h .Client .Configuration ()
230+ if err != nil {
231+ return err
232+ }
233+ if params .FullSection != nil && * params .FullSection {
234+ return configuration .CreateStructuredDefaultsSection (params .Data , t , v )
235+ }
236+ return configuration .CreateDefaultsSection (params .Data , t , v )
237+ }
238+
208239// ReplaceDefaultsHandlerImpl implementation of the ReplaceDefaultsHandler interface
209240type ReplaceDefaultsSectionHandlerImpl struct {
210241 Client client_native.HAProxyClient
@@ -231,13 +262,7 @@ func (h ReplaceDefaultsSectionHandlerImpl) Handle(params defaults.ReplaceDefault
231262 return defaults .NewReplaceDefaultsSectionDefault (int (* e .Code )).WithPayload (e )
232263 }
233264
234- configuration , err := h .Client .Configuration ()
235- if err != nil {
236- e := misc .HandleError (err )
237- return defaults .NewReplaceDefaultsSectionDefault (int (* e .Code )).WithPayload (e )
238- }
239-
240- err = configuration .EditDefaultsSection (params .Name , params .Data , t , v )
265+ err := h .editDefaultsSection (params , t , v )
241266 if err != nil {
242267 e := misc .HandleError (err )
243268 return defaults .NewReplaceDefaultsSectionDefault (int (* e .Code )).WithPayload (e )
@@ -257,6 +282,17 @@ func (h ReplaceDefaultsSectionHandlerImpl) Handle(params defaults.ReplaceDefault
257282 return defaults .NewReplaceDefaultsSectionAccepted ().WithPayload (params .Data )
258283}
259284
285+ func (h * ReplaceDefaultsSectionHandlerImpl ) editDefaultsSection (params defaults.ReplaceDefaultsSectionParams , t string , v int64 ) error {
286+ configuration , err := h .Client .Configuration ()
287+ if err != nil {
288+ return err
289+ }
290+ if params .FullSection != nil && * params .FullSection {
291+ return configuration .EditStructuredDefaultsSection (params .Name , params .Data , t , v )
292+ }
293+ return configuration .EditDefaultsSection (params .Name , params .Data , t , v )
294+ }
295+
260296type DeleteDefaultsSectionHandlerImpl struct {
261297 Client client_native.HAProxyClient
262298 ReloadAgent haproxy.IReloadAgent
0 commit comments