1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
11 func RESTHandler(rpc RPCService) http.Handler {
12 mux := http.NewServeMux()
13 mux.HandleFunc("/collect_detailed_interface_stats", func(w http.ResponseWriter, req *http.Request) {
14 var request = new(CollectDetailedInterfaceStats)
15 b, err := ioutil.ReadAll(req.Body)
17 http.Error(w, "read body failed", http.StatusBadRequest)
20 if err := json.Unmarshal(b, request); err != nil {
21 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
24 reply, err := rpc.CollectDetailedInterfaceStats(req.Context(), request)
26 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
29 rep, err := json.MarshalIndent(reply, "", " ")
31 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
36 mux.HandleFunc("/create_loopback", func(w http.ResponseWriter, req *http.Request) {
37 var request = new(CreateLoopback)
38 b, err := ioutil.ReadAll(req.Body)
40 http.Error(w, "read body failed", http.StatusBadRequest)
43 if err := json.Unmarshal(b, request); err != nil {
44 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
47 reply, err := rpc.CreateLoopback(req.Context(), request)
49 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
52 rep, err := json.MarshalIndent(reply, "", " ")
54 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
59 mux.HandleFunc("/create_loopback_instance", func(w http.ResponseWriter, req *http.Request) {
60 var request = new(CreateLoopbackInstance)
61 b, err := ioutil.ReadAll(req.Body)
63 http.Error(w, "read body failed", http.StatusBadRequest)
66 if err := json.Unmarshal(b, request); err != nil {
67 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
70 reply, err := rpc.CreateLoopbackInstance(req.Context(), request)
72 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
75 rep, err := json.MarshalIndent(reply, "", " ")
77 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
82 mux.HandleFunc("/create_subif", func(w http.ResponseWriter, req *http.Request) {
83 var request = new(CreateSubif)
84 b, err := ioutil.ReadAll(req.Body)
86 http.Error(w, "read body failed", http.StatusBadRequest)
89 if err := json.Unmarshal(b, request); err != nil {
90 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
93 reply, err := rpc.CreateSubif(req.Context(), request)
95 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
98 rep, err := json.MarshalIndent(reply, "", " ")
100 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
105 mux.HandleFunc("/create_vlan_subif", func(w http.ResponseWriter, req *http.Request) {
106 var request = new(CreateVlanSubif)
107 b, err := ioutil.ReadAll(req.Body)
109 http.Error(w, "read body failed", http.StatusBadRequest)
112 if err := json.Unmarshal(b, request); err != nil {
113 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
116 reply, err := rpc.CreateVlanSubif(req.Context(), request)
118 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
121 rep, err := json.MarshalIndent(reply, "", " ")
123 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
128 mux.HandleFunc("/delete_loopback", func(w http.ResponseWriter, req *http.Request) {
129 var request = new(DeleteLoopback)
130 b, err := ioutil.ReadAll(req.Body)
132 http.Error(w, "read body failed", http.StatusBadRequest)
135 if err := json.Unmarshal(b, request); err != nil {
136 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
139 reply, err := rpc.DeleteLoopback(req.Context(), request)
141 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
144 rep, err := json.MarshalIndent(reply, "", " ")
146 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
151 mux.HandleFunc("/delete_subif", func(w http.ResponseWriter, req *http.Request) {
152 var request = new(DeleteSubif)
153 b, err := ioutil.ReadAll(req.Body)
155 http.Error(w, "read body failed", http.StatusBadRequest)
158 if err := json.Unmarshal(b, request); err != nil {
159 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
162 reply, err := rpc.DeleteSubif(req.Context(), request)
164 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
167 rep, err := json.MarshalIndent(reply, "", " ")
169 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
174 mux.HandleFunc("/hw_interface_set_mtu", func(w http.ResponseWriter, req *http.Request) {
175 var request = new(HwInterfaceSetMtu)
176 b, err := ioutil.ReadAll(req.Body)
178 http.Error(w, "read body failed", http.StatusBadRequest)
181 if err := json.Unmarshal(b, request); err != nil {
182 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
185 reply, err := rpc.HwInterfaceSetMtu(req.Context(), request)
187 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
190 rep, err := json.MarshalIndent(reply, "", " ")
192 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
197 mux.HandleFunc("/interface_name_renumber", func(w http.ResponseWriter, req *http.Request) {
198 var request = new(InterfaceNameRenumber)
199 b, err := ioutil.ReadAll(req.Body)
201 http.Error(w, "read body failed", http.StatusBadRequest)
204 if err := json.Unmarshal(b, request); err != nil {
205 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
208 reply, err := rpc.InterfaceNameRenumber(req.Context(), request)
210 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
213 rep, err := json.MarshalIndent(reply, "", " ")
215 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
220 mux.HandleFunc("/sw_interface_add_del_address", func(w http.ResponseWriter, req *http.Request) {
221 var request = new(SwInterfaceAddDelAddress)
222 b, err := ioutil.ReadAll(req.Body)
224 http.Error(w, "read body failed", http.StatusBadRequest)
227 if err := json.Unmarshal(b, request); err != nil {
228 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
231 reply, err := rpc.SwInterfaceAddDelAddress(req.Context(), request)
233 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
236 rep, err := json.MarshalIndent(reply, "", " ")
238 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
243 mux.HandleFunc("/sw_interface_add_del_mac_address", func(w http.ResponseWriter, req *http.Request) {
244 var request = new(SwInterfaceAddDelMacAddress)
245 b, err := ioutil.ReadAll(req.Body)
247 http.Error(w, "read body failed", http.StatusBadRequest)
250 if err := json.Unmarshal(b, request); err != nil {
251 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
254 reply, err := rpc.SwInterfaceAddDelMacAddress(req.Context(), request)
256 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
259 rep, err := json.MarshalIndent(reply, "", " ")
261 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
266 mux.HandleFunc("/sw_interface_address_replace_begin", func(w http.ResponseWriter, req *http.Request) {
267 var request = new(SwInterfaceAddressReplaceBegin)
268 reply, err := rpc.SwInterfaceAddressReplaceBegin(req.Context(), request)
270 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
273 rep, err := json.MarshalIndent(reply, "", " ")
275 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
280 mux.HandleFunc("/sw_interface_address_replace_end", func(w http.ResponseWriter, req *http.Request) {
281 var request = new(SwInterfaceAddressReplaceEnd)
282 reply, err := rpc.SwInterfaceAddressReplaceEnd(req.Context(), request)
284 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
287 rep, err := json.MarshalIndent(reply, "", " ")
289 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
294 mux.HandleFunc("/sw_interface_clear_stats", func(w http.ResponseWriter, req *http.Request) {
295 var request = new(SwInterfaceClearStats)
296 b, err := ioutil.ReadAll(req.Body)
298 http.Error(w, "read body failed", http.StatusBadRequest)
301 if err := json.Unmarshal(b, request); err != nil {
302 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
305 reply, err := rpc.SwInterfaceClearStats(req.Context(), request)
307 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
310 rep, err := json.MarshalIndent(reply, "", " ")
312 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
317 mux.HandleFunc("/sw_interface_get_mac_address", func(w http.ResponseWriter, req *http.Request) {
318 var request = new(SwInterfaceGetMacAddress)
319 b, err := ioutil.ReadAll(req.Body)
321 http.Error(w, "read body failed", http.StatusBadRequest)
324 if err := json.Unmarshal(b, request); err != nil {
325 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
328 reply, err := rpc.SwInterfaceGetMacAddress(req.Context(), request)
330 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
333 rep, err := json.MarshalIndent(reply, "", " ")
335 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
340 mux.HandleFunc("/sw_interface_get_table", func(w http.ResponseWriter, req *http.Request) {
341 var request = new(SwInterfaceGetTable)
342 b, err := ioutil.ReadAll(req.Body)
344 http.Error(w, "read body failed", http.StatusBadRequest)
347 if err := json.Unmarshal(b, request); err != nil {
348 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
351 reply, err := rpc.SwInterfaceGetTable(req.Context(), request)
353 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
356 rep, err := json.MarshalIndent(reply, "", " ")
358 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
363 mux.HandleFunc("/sw_interface_set_flags", func(w http.ResponseWriter, req *http.Request) {
364 var request = new(SwInterfaceSetFlags)
365 b, err := ioutil.ReadAll(req.Body)
367 http.Error(w, "read body failed", http.StatusBadRequest)
370 if err := json.Unmarshal(b, request); err != nil {
371 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
374 reply, err := rpc.SwInterfaceSetFlags(req.Context(), request)
376 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
379 rep, err := json.MarshalIndent(reply, "", " ")
381 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
386 mux.HandleFunc("/sw_interface_set_ip_directed_broadcast", func(w http.ResponseWriter, req *http.Request) {
387 var request = new(SwInterfaceSetIPDirectedBroadcast)
388 b, err := ioutil.ReadAll(req.Body)
390 http.Error(w, "read body failed", http.StatusBadRequest)
393 if err := json.Unmarshal(b, request); err != nil {
394 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
397 reply, err := rpc.SwInterfaceSetIPDirectedBroadcast(req.Context(), request)
399 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
402 rep, err := json.MarshalIndent(reply, "", " ")
404 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
409 mux.HandleFunc("/sw_interface_set_mac_address", func(w http.ResponseWriter, req *http.Request) {
410 var request = new(SwInterfaceSetMacAddress)
411 b, err := ioutil.ReadAll(req.Body)
413 http.Error(w, "read body failed", http.StatusBadRequest)
416 if err := json.Unmarshal(b, request); err != nil {
417 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
420 reply, err := rpc.SwInterfaceSetMacAddress(req.Context(), request)
422 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
425 rep, err := json.MarshalIndent(reply, "", " ")
427 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
432 mux.HandleFunc("/sw_interface_set_mtu", func(w http.ResponseWriter, req *http.Request) {
433 var request = new(SwInterfaceSetMtu)
434 b, err := ioutil.ReadAll(req.Body)
436 http.Error(w, "read body failed", http.StatusBadRequest)
439 if err := json.Unmarshal(b, request); err != nil {
440 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
443 reply, err := rpc.SwInterfaceSetMtu(req.Context(), request)
445 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
448 rep, err := json.MarshalIndent(reply, "", " ")
450 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
455 mux.HandleFunc("/sw_interface_set_rx_mode", func(w http.ResponseWriter, req *http.Request) {
456 var request = new(SwInterfaceSetRxMode)
457 b, err := ioutil.ReadAll(req.Body)
459 http.Error(w, "read body failed", http.StatusBadRequest)
462 if err := json.Unmarshal(b, request); err != nil {
463 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
466 reply, err := rpc.SwInterfaceSetRxMode(req.Context(), request)
468 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
471 rep, err := json.MarshalIndent(reply, "", " ")
473 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
478 mux.HandleFunc("/sw_interface_set_rx_placement", func(w http.ResponseWriter, req *http.Request) {
479 var request = new(SwInterfaceSetRxPlacement)
480 b, err := ioutil.ReadAll(req.Body)
482 http.Error(w, "read body failed", http.StatusBadRequest)
485 if err := json.Unmarshal(b, request); err != nil {
486 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
489 reply, err := rpc.SwInterfaceSetRxPlacement(req.Context(), request)
491 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
494 rep, err := json.MarshalIndent(reply, "", " ")
496 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
501 mux.HandleFunc("/sw_interface_set_table", func(w http.ResponseWriter, req *http.Request) {
502 var request = new(SwInterfaceSetTable)
503 b, err := ioutil.ReadAll(req.Body)
505 http.Error(w, "read body failed", http.StatusBadRequest)
508 if err := json.Unmarshal(b, request); err != nil {
509 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
512 reply, err := rpc.SwInterfaceSetTable(req.Context(), request)
514 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
517 rep, err := json.MarshalIndent(reply, "", " ")
519 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
524 mux.HandleFunc("/sw_interface_set_unnumbered", func(w http.ResponseWriter, req *http.Request) {
525 var request = new(SwInterfaceSetUnnumbered)
526 b, err := ioutil.ReadAll(req.Body)
528 http.Error(w, "read body failed", http.StatusBadRequest)
531 if err := json.Unmarshal(b, request); err != nil {
532 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
535 reply, err := rpc.SwInterfaceSetUnnumbered(req.Context(), request)
537 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
540 rep, err := json.MarshalIndent(reply, "", " ")
542 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
547 mux.HandleFunc("/sw_interface_tag_add_del", func(w http.ResponseWriter, req *http.Request) {
548 var request = new(SwInterfaceTagAddDel)
549 b, err := ioutil.ReadAll(req.Body)
551 http.Error(w, "read body failed", http.StatusBadRequest)
554 if err := json.Unmarshal(b, request); err != nil {
555 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
558 reply, err := rpc.SwInterfaceTagAddDel(req.Context(), request)
560 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
563 rep, err := json.MarshalIndent(reply, "", " ")
565 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
570 mux.HandleFunc("/want_interface_events", func(w http.ResponseWriter, req *http.Request) {
571 var request = new(WantInterfaceEvents)
572 b, err := ioutil.ReadAll(req.Body)
574 http.Error(w, "read body failed", http.StatusBadRequest)
577 if err := json.Unmarshal(b, request); err != nil {
578 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
581 reply, err := rpc.WantInterfaceEvents(req.Context(), request)
583 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
586 rep, err := json.MarshalIndent(reply, "", " ")
588 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
593 return http.HandlerFunc(mux.ServeHTTP)