f12ab0673e1c3e2918857140e11fcc6ada31fbdb
[govpp.git] / binapi / l2 / l2_rest.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2
3 package l2
4
5 import (
6         "encoding/json"
7         "io/ioutil"
8         "net/http"
9 )
10
11 func RESTHandler(rpc RPCService) http.Handler {
12         mux := http.NewServeMux()
13         mux.HandleFunc("/bd_ip_mac_add_del", func(w http.ResponseWriter, req *http.Request) {
14                 var request = new(BdIPMacAddDel)
15                 b, err := ioutil.ReadAll(req.Body)
16                 if err != nil {
17                         http.Error(w, "read body failed", http.StatusBadRequest)
18                         return
19                 }
20                 if err := json.Unmarshal(b, request); err != nil {
21                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
22                         return
23                 }
24                 reply, err := rpc.BdIPMacAddDel(req.Context(), request)
25                 if err != nil {
26                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
27                         return
28                 }
29                 rep, err := json.MarshalIndent(reply, "", "  ")
30                 if err != nil {
31                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
32                         return
33                 }
34                 w.Write(rep)
35         })
36         mux.HandleFunc("/bd_ip_mac_flush", func(w http.ResponseWriter, req *http.Request) {
37                 var request = new(BdIPMacFlush)
38                 b, err := ioutil.ReadAll(req.Body)
39                 if err != nil {
40                         http.Error(w, "read body failed", http.StatusBadRequest)
41                         return
42                 }
43                 if err := json.Unmarshal(b, request); err != nil {
44                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
45                         return
46                 }
47                 reply, err := rpc.BdIPMacFlush(req.Context(), request)
48                 if err != nil {
49                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
50                         return
51                 }
52                 rep, err := json.MarshalIndent(reply, "", "  ")
53                 if err != nil {
54                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
55                         return
56                 }
57                 w.Write(rep)
58         })
59         mux.HandleFunc("/bridge_domain_add_del", func(w http.ResponseWriter, req *http.Request) {
60                 var request = new(BridgeDomainAddDel)
61                 b, err := ioutil.ReadAll(req.Body)
62                 if err != nil {
63                         http.Error(w, "read body failed", http.StatusBadRequest)
64                         return
65                 }
66                 if err := json.Unmarshal(b, request); err != nil {
67                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
68                         return
69                 }
70                 reply, err := rpc.BridgeDomainAddDel(req.Context(), request)
71                 if err != nil {
72                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
73                         return
74                 }
75                 rep, err := json.MarshalIndent(reply, "", "  ")
76                 if err != nil {
77                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
78                         return
79                 }
80                 w.Write(rep)
81         })
82         mux.HandleFunc("/bridge_domain_set_mac_age", func(w http.ResponseWriter, req *http.Request) {
83                 var request = new(BridgeDomainSetMacAge)
84                 b, err := ioutil.ReadAll(req.Body)
85                 if err != nil {
86                         http.Error(w, "read body failed", http.StatusBadRequest)
87                         return
88                 }
89                 if err := json.Unmarshal(b, request); err != nil {
90                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
91                         return
92                 }
93                 reply, err := rpc.BridgeDomainSetMacAge(req.Context(), request)
94                 if err != nil {
95                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
96                         return
97                 }
98                 rep, err := json.MarshalIndent(reply, "", "  ")
99                 if err != nil {
100                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
101                         return
102                 }
103                 w.Write(rep)
104         })
105         mux.HandleFunc("/bridge_flags", func(w http.ResponseWriter, req *http.Request) {
106                 var request = new(BridgeFlags)
107                 b, err := ioutil.ReadAll(req.Body)
108                 if err != nil {
109                         http.Error(w, "read body failed", http.StatusBadRequest)
110                         return
111                 }
112                 if err := json.Unmarshal(b, request); err != nil {
113                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
114                         return
115                 }
116                 reply, err := rpc.BridgeFlags(req.Context(), request)
117                 if err != nil {
118                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
119                         return
120                 }
121                 rep, err := json.MarshalIndent(reply, "", "  ")
122                 if err != nil {
123                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
124                         return
125                 }
126                 w.Write(rep)
127         })
128         mux.HandleFunc("/bvi_create", func(w http.ResponseWriter, req *http.Request) {
129                 var request = new(BviCreate)
130                 b, err := ioutil.ReadAll(req.Body)
131                 if err != nil {
132                         http.Error(w, "read body failed", http.StatusBadRequest)
133                         return
134                 }
135                 if err := json.Unmarshal(b, request); err != nil {
136                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
137                         return
138                 }
139                 reply, err := rpc.BviCreate(req.Context(), request)
140                 if err != nil {
141                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
142                         return
143                 }
144                 rep, err := json.MarshalIndent(reply, "", "  ")
145                 if err != nil {
146                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
147                         return
148                 }
149                 w.Write(rep)
150         })
151         mux.HandleFunc("/bvi_delete", func(w http.ResponseWriter, req *http.Request) {
152                 var request = new(BviDelete)
153                 b, err := ioutil.ReadAll(req.Body)
154                 if err != nil {
155                         http.Error(w, "read body failed", http.StatusBadRequest)
156                         return
157                 }
158                 if err := json.Unmarshal(b, request); err != nil {
159                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
160                         return
161                 }
162                 reply, err := rpc.BviDelete(req.Context(), request)
163                 if err != nil {
164                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
165                         return
166                 }
167                 rep, err := json.MarshalIndent(reply, "", "  ")
168                 if err != nil {
169                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
170                         return
171                 }
172                 w.Write(rep)
173         })
174         mux.HandleFunc("/l2_fib_clear_table", func(w http.ResponseWriter, req *http.Request) {
175                 var request = new(L2FibClearTable)
176                 reply, err := rpc.L2FibClearTable(req.Context(), request)
177                 if err != nil {
178                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
179                         return
180                 }
181                 rep, err := json.MarshalIndent(reply, "", "  ")
182                 if err != nil {
183                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
184                         return
185                 }
186                 w.Write(rep)
187         })
188         mux.HandleFunc("/l2_flags", func(w http.ResponseWriter, req *http.Request) {
189                 var request = new(L2Flags)
190                 b, err := ioutil.ReadAll(req.Body)
191                 if err != nil {
192                         http.Error(w, "read body failed", http.StatusBadRequest)
193                         return
194                 }
195                 if err := json.Unmarshal(b, request); err != nil {
196                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
197                         return
198                 }
199                 reply, err := rpc.L2Flags(req.Context(), request)
200                 if err != nil {
201                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
202                         return
203                 }
204                 rep, err := json.MarshalIndent(reply, "", "  ")
205                 if err != nil {
206                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
207                         return
208                 }
209                 w.Write(rep)
210         })
211         mux.HandleFunc("/l2_interface_efp_filter", func(w http.ResponseWriter, req *http.Request) {
212                 var request = new(L2InterfaceEfpFilter)
213                 b, err := ioutil.ReadAll(req.Body)
214                 if err != nil {
215                         http.Error(w, "read body failed", http.StatusBadRequest)
216                         return
217                 }
218                 if err := json.Unmarshal(b, request); err != nil {
219                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
220                         return
221                 }
222                 reply, err := rpc.L2InterfaceEfpFilter(req.Context(), request)
223                 if err != nil {
224                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
225                         return
226                 }
227                 rep, err := json.MarshalIndent(reply, "", "  ")
228                 if err != nil {
229                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
230                         return
231                 }
232                 w.Write(rep)
233         })
234         mux.HandleFunc("/l2_interface_pbb_tag_rewrite", func(w http.ResponseWriter, req *http.Request) {
235                 var request = new(L2InterfacePbbTagRewrite)
236                 b, err := ioutil.ReadAll(req.Body)
237                 if err != nil {
238                         http.Error(w, "read body failed", http.StatusBadRequest)
239                         return
240                 }
241                 if err := json.Unmarshal(b, request); err != nil {
242                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
243                         return
244                 }
245                 reply, err := rpc.L2InterfacePbbTagRewrite(req.Context(), request)
246                 if err != nil {
247                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
248                         return
249                 }
250                 rep, err := json.MarshalIndent(reply, "", "  ")
251                 if err != nil {
252                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
253                         return
254                 }
255                 w.Write(rep)
256         })
257         mux.HandleFunc("/l2_interface_vlan_tag_rewrite", func(w http.ResponseWriter, req *http.Request) {
258                 var request = new(L2InterfaceVlanTagRewrite)
259                 b, err := ioutil.ReadAll(req.Body)
260                 if err != nil {
261                         http.Error(w, "read body failed", http.StatusBadRequest)
262                         return
263                 }
264                 if err := json.Unmarshal(b, request); err != nil {
265                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
266                         return
267                 }
268                 reply, err := rpc.L2InterfaceVlanTagRewrite(req.Context(), request)
269                 if err != nil {
270                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
271                         return
272                 }
273                 rep, err := json.MarshalIndent(reply, "", "  ")
274                 if err != nil {
275                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
276                         return
277                 }
278                 w.Write(rep)
279         })
280         mux.HandleFunc("/l2_patch_add_del", func(w http.ResponseWriter, req *http.Request) {
281                 var request = new(L2PatchAddDel)
282                 b, err := ioutil.ReadAll(req.Body)
283                 if err != nil {
284                         http.Error(w, "read body failed", http.StatusBadRequest)
285                         return
286                 }
287                 if err := json.Unmarshal(b, request); err != nil {
288                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
289                         return
290                 }
291                 reply, err := rpc.L2PatchAddDel(req.Context(), request)
292                 if err != nil {
293                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
294                         return
295                 }
296                 rep, err := json.MarshalIndent(reply, "", "  ")
297                 if err != nil {
298                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
299                         return
300                 }
301                 w.Write(rep)
302         })
303         mux.HandleFunc("/l2fib_add_del", func(w http.ResponseWriter, req *http.Request) {
304                 var request = new(L2fibAddDel)
305                 b, err := ioutil.ReadAll(req.Body)
306                 if err != nil {
307                         http.Error(w, "read body failed", http.StatusBadRequest)
308                         return
309                 }
310                 if err := json.Unmarshal(b, request); err != nil {
311                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
312                         return
313                 }
314                 reply, err := rpc.L2fibAddDel(req.Context(), request)
315                 if err != nil {
316                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
317                         return
318                 }
319                 rep, err := json.MarshalIndent(reply, "", "  ")
320                 if err != nil {
321                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
322                         return
323                 }
324                 w.Write(rep)
325         })
326         mux.HandleFunc("/l2fib_flush_all", func(w http.ResponseWriter, req *http.Request) {
327                 var request = new(L2fibFlushAll)
328                 reply, err := rpc.L2fibFlushAll(req.Context(), request)
329                 if err != nil {
330                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
331                         return
332                 }
333                 rep, err := json.MarshalIndent(reply, "", "  ")
334                 if err != nil {
335                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
336                         return
337                 }
338                 w.Write(rep)
339         })
340         mux.HandleFunc("/l2fib_flush_bd", func(w http.ResponseWriter, req *http.Request) {
341                 var request = new(L2fibFlushBd)
342                 b, err := ioutil.ReadAll(req.Body)
343                 if err != nil {
344                         http.Error(w, "read body failed", http.StatusBadRequest)
345                         return
346                 }
347                 if err := json.Unmarshal(b, request); err != nil {
348                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
349                         return
350                 }
351                 reply, err := rpc.L2fibFlushBd(req.Context(), request)
352                 if err != nil {
353                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
354                         return
355                 }
356                 rep, err := json.MarshalIndent(reply, "", "  ")
357                 if err != nil {
358                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
359                         return
360                 }
361                 w.Write(rep)
362         })
363         mux.HandleFunc("/l2fib_flush_int", func(w http.ResponseWriter, req *http.Request) {
364                 var request = new(L2fibFlushInt)
365                 b, err := ioutil.ReadAll(req.Body)
366                 if err != nil {
367                         http.Error(w, "read body failed", http.StatusBadRequest)
368                         return
369                 }
370                 if err := json.Unmarshal(b, request); err != nil {
371                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
372                         return
373                 }
374                 reply, err := rpc.L2fibFlushInt(req.Context(), request)
375                 if err != nil {
376                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
377                         return
378                 }
379                 rep, err := json.MarshalIndent(reply, "", "  ")
380                 if err != nil {
381                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
382                         return
383                 }
384                 w.Write(rep)
385         })
386         mux.HandleFunc("/sw_interface_set_l2_bridge", func(w http.ResponseWriter, req *http.Request) {
387                 var request = new(SwInterfaceSetL2Bridge)
388                 b, err := ioutil.ReadAll(req.Body)
389                 if err != nil {
390                         http.Error(w, "read body failed", http.StatusBadRequest)
391                         return
392                 }
393                 if err := json.Unmarshal(b, request); err != nil {
394                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
395                         return
396                 }
397                 reply, err := rpc.SwInterfaceSetL2Bridge(req.Context(), request)
398                 if err != nil {
399                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
400                         return
401                 }
402                 rep, err := json.MarshalIndent(reply, "", "  ")
403                 if err != nil {
404                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
405                         return
406                 }
407                 w.Write(rep)
408         })
409         mux.HandleFunc("/sw_interface_set_l2_xconnect", func(w http.ResponseWriter, req *http.Request) {
410                 var request = new(SwInterfaceSetL2Xconnect)
411                 b, err := ioutil.ReadAll(req.Body)
412                 if err != nil {
413                         http.Error(w, "read body failed", http.StatusBadRequest)
414                         return
415                 }
416                 if err := json.Unmarshal(b, request); err != nil {
417                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
418                         return
419                 }
420                 reply, err := rpc.SwInterfaceSetL2Xconnect(req.Context(), request)
421                 if err != nil {
422                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
423                         return
424                 }
425                 rep, err := json.MarshalIndent(reply, "", "  ")
426                 if err != nil {
427                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
428                         return
429                 }
430                 w.Write(rep)
431         })
432         mux.HandleFunc("/sw_interface_set_vpath", func(w http.ResponseWriter, req *http.Request) {
433                 var request = new(SwInterfaceSetVpath)
434                 b, err := ioutil.ReadAll(req.Body)
435                 if err != nil {
436                         http.Error(w, "read body failed", http.StatusBadRequest)
437                         return
438                 }
439                 if err := json.Unmarshal(b, request); err != nil {
440                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
441                         return
442                 }
443                 reply, err := rpc.SwInterfaceSetVpath(req.Context(), request)
444                 if err != nil {
445                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
446                         return
447                 }
448                 rep, err := json.MarshalIndent(reply, "", "  ")
449                 if err != nil {
450                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
451                         return
452                 }
453                 w.Write(rep)
454         })
455         mux.HandleFunc("/want_l2_arp_term_events", func(w http.ResponseWriter, req *http.Request) {
456                 var request = new(WantL2ArpTermEvents)
457                 b, err := ioutil.ReadAll(req.Body)
458                 if err != nil {
459                         http.Error(w, "read body failed", http.StatusBadRequest)
460                         return
461                 }
462                 if err := json.Unmarshal(b, request); err != nil {
463                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
464                         return
465                 }
466                 reply, err := rpc.WantL2ArpTermEvents(req.Context(), request)
467                 if err != nil {
468                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
469                         return
470                 }
471                 rep, err := json.MarshalIndent(reply, "", "  ")
472                 if err != nil {
473                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
474                         return
475                 }
476                 w.Write(rep)
477         })
478         mux.HandleFunc("/want_l2_macs_events", func(w http.ResponseWriter, req *http.Request) {
479                 var request = new(WantL2MacsEvents)
480                 b, err := ioutil.ReadAll(req.Body)
481                 if err != nil {
482                         http.Error(w, "read body failed", http.StatusBadRequest)
483                         return
484                 }
485                 if err := json.Unmarshal(b, request); err != nil {
486                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
487                         return
488                 }
489                 reply, err := rpc.WantL2MacsEvents(req.Context(), request)
490                 if err != nil {
491                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
492                         return
493                 }
494                 rep, err := json.MarshalIndent(reply, "", "  ")
495                 if err != nil {
496                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
497                         return
498                 }
499                 w.Write(rep)
500         })
501         return http.HandlerFunc(mux.ServeHTTP)
502 }