Updated changelog for v0.4.0
[govpp.git] / binapi / ip / ip_rest.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2
3 package ip
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("/ioam_disable", func(w http.ResponseWriter, req *http.Request) {
14                 var request = new(IoamDisable)
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.IoamDisable(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("/ioam_enable", func(w http.ResponseWriter, req *http.Request) {
37                 var request = new(IoamEnable)
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.IoamEnable(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("/ip_container_proxy_add_del", func(w http.ResponseWriter, req *http.Request) {
60                 var request = new(IPContainerProxyAddDel)
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.IPContainerProxyAddDel(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("/ip_mroute_add_del", func(w http.ResponseWriter, req *http.Request) {
83                 var request = new(IPMrouteAddDel)
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.IPMrouteAddDel(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("/ip_punt_police", func(w http.ResponseWriter, req *http.Request) {
106                 var request = new(IPPuntPolice)
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.IPPuntPolice(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("/ip_punt_redirect", func(w http.ResponseWriter, req *http.Request) {
129                 var request = new(IPPuntRedirect)
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.IPPuntRedirect(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("/ip_reassembly_enable_disable", func(w http.ResponseWriter, req *http.Request) {
152                 var request = new(IPReassemblyEnableDisable)
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.IPReassemblyEnableDisable(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("/ip_reassembly_get", func(w http.ResponseWriter, req *http.Request) {
175                 var request = new(IPReassemblyGet)
176                 b, err := ioutil.ReadAll(req.Body)
177                 if err != nil {
178                         http.Error(w, "read body failed", http.StatusBadRequest)
179                         return
180                 }
181                 if err := json.Unmarshal(b, request); err != nil {
182                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
183                         return
184                 }
185                 reply, err := rpc.IPReassemblyGet(req.Context(), request)
186                 if err != nil {
187                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
188                         return
189                 }
190                 rep, err := json.MarshalIndent(reply, "", "  ")
191                 if err != nil {
192                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
193                         return
194                 }
195                 w.Write(rep)
196         })
197         mux.HandleFunc("/ip_reassembly_set", func(w http.ResponseWriter, req *http.Request) {
198                 var request = new(IPReassemblySet)
199                 b, err := ioutil.ReadAll(req.Body)
200                 if err != nil {
201                         http.Error(w, "read body failed", http.StatusBadRequest)
202                         return
203                 }
204                 if err := json.Unmarshal(b, request); err != nil {
205                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
206                         return
207                 }
208                 reply, err := rpc.IPReassemblySet(req.Context(), request)
209                 if err != nil {
210                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
211                         return
212                 }
213                 rep, err := json.MarshalIndent(reply, "", "  ")
214                 if err != nil {
215                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
216                         return
217                 }
218                 w.Write(rep)
219         })
220         mux.HandleFunc("/ip_route_add_del", func(w http.ResponseWriter, req *http.Request) {
221                 var request = new(IPRouteAddDel)
222                 b, err := ioutil.ReadAll(req.Body)
223                 if err != nil {
224                         http.Error(w, "read body failed", http.StatusBadRequest)
225                         return
226                 }
227                 if err := json.Unmarshal(b, request); err != nil {
228                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
229                         return
230                 }
231                 reply, err := rpc.IPRouteAddDel(req.Context(), request)
232                 if err != nil {
233                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
234                         return
235                 }
236                 rep, err := json.MarshalIndent(reply, "", "  ")
237                 if err != nil {
238                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
239                         return
240                 }
241                 w.Write(rep)
242         })
243         mux.HandleFunc("/ip_route_lookup", func(w http.ResponseWriter, req *http.Request) {
244                 var request = new(IPRouteLookup)
245                 b, err := ioutil.ReadAll(req.Body)
246                 if err != nil {
247                         http.Error(w, "read body failed", http.StatusBadRequest)
248                         return
249                 }
250                 if err := json.Unmarshal(b, request); err != nil {
251                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
252                         return
253                 }
254                 reply, err := rpc.IPRouteLookup(req.Context(), request)
255                 if err != nil {
256                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
257                         return
258                 }
259                 rep, err := json.MarshalIndent(reply, "", "  ")
260                 if err != nil {
261                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
262                         return
263                 }
264                 w.Write(rep)
265         })
266         mux.HandleFunc("/ip_source_and_port_range_check_add_del", func(w http.ResponseWriter, req *http.Request) {
267                 var request = new(IPSourceAndPortRangeCheckAddDel)
268                 b, err := ioutil.ReadAll(req.Body)
269                 if err != nil {
270                         http.Error(w, "read body failed", http.StatusBadRequest)
271                         return
272                 }
273                 if err := json.Unmarshal(b, request); err != nil {
274                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
275                         return
276                 }
277                 reply, err := rpc.IPSourceAndPortRangeCheckAddDel(req.Context(), request)
278                 if err != nil {
279                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
280                         return
281                 }
282                 rep, err := json.MarshalIndent(reply, "", "  ")
283                 if err != nil {
284                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
285                         return
286                 }
287                 w.Write(rep)
288         })
289         mux.HandleFunc("/ip_source_and_port_range_check_interface_add_del", func(w http.ResponseWriter, req *http.Request) {
290                 var request = new(IPSourceAndPortRangeCheckInterfaceAddDel)
291                 b, err := ioutil.ReadAll(req.Body)
292                 if err != nil {
293                         http.Error(w, "read body failed", http.StatusBadRequest)
294                         return
295                 }
296                 if err := json.Unmarshal(b, request); err != nil {
297                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
298                         return
299                 }
300                 reply, err := rpc.IPSourceAndPortRangeCheckInterfaceAddDel(req.Context(), request)
301                 if err != nil {
302                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
303                         return
304                 }
305                 rep, err := json.MarshalIndent(reply, "", "  ")
306                 if err != nil {
307                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
308                         return
309                 }
310                 w.Write(rep)
311         })
312         mux.HandleFunc("/ip_table_add_del", func(w http.ResponseWriter, req *http.Request) {
313                 var request = new(IPTableAddDel)
314                 b, err := ioutil.ReadAll(req.Body)
315                 if err != nil {
316                         http.Error(w, "read body failed", http.StatusBadRequest)
317                         return
318                 }
319                 if err := json.Unmarshal(b, request); err != nil {
320                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
321                         return
322                 }
323                 reply, err := rpc.IPTableAddDel(req.Context(), request)
324                 if err != nil {
325                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
326                         return
327                 }
328                 rep, err := json.MarshalIndent(reply, "", "  ")
329                 if err != nil {
330                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
331                         return
332                 }
333                 w.Write(rep)
334         })
335         mux.HandleFunc("/ip_table_flush", func(w http.ResponseWriter, req *http.Request) {
336                 var request = new(IPTableFlush)
337                 b, err := ioutil.ReadAll(req.Body)
338                 if err != nil {
339                         http.Error(w, "read body failed", http.StatusBadRequest)
340                         return
341                 }
342                 if err := json.Unmarshal(b, request); err != nil {
343                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
344                         return
345                 }
346                 reply, err := rpc.IPTableFlush(req.Context(), request)
347                 if err != nil {
348                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
349                         return
350                 }
351                 rep, err := json.MarshalIndent(reply, "", "  ")
352                 if err != nil {
353                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
354                         return
355                 }
356                 w.Write(rep)
357         })
358         mux.HandleFunc("/ip_table_replace_begin", func(w http.ResponseWriter, req *http.Request) {
359                 var request = new(IPTableReplaceBegin)
360                 b, err := ioutil.ReadAll(req.Body)
361                 if err != nil {
362                         http.Error(w, "read body failed", http.StatusBadRequest)
363                         return
364                 }
365                 if err := json.Unmarshal(b, request); err != nil {
366                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
367                         return
368                 }
369                 reply, err := rpc.IPTableReplaceBegin(req.Context(), request)
370                 if err != nil {
371                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
372                         return
373                 }
374                 rep, err := json.MarshalIndent(reply, "", "  ")
375                 if err != nil {
376                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
377                         return
378                 }
379                 w.Write(rep)
380         })
381         mux.HandleFunc("/ip_table_replace_end", func(w http.ResponseWriter, req *http.Request) {
382                 var request = new(IPTableReplaceEnd)
383                 b, err := ioutil.ReadAll(req.Body)
384                 if err != nil {
385                         http.Error(w, "read body failed", http.StatusBadRequest)
386                         return
387                 }
388                 if err := json.Unmarshal(b, request); err != nil {
389                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
390                         return
391                 }
392                 reply, err := rpc.IPTableReplaceEnd(req.Context(), request)
393                 if err != nil {
394                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
395                         return
396                 }
397                 rep, err := json.MarshalIndent(reply, "", "  ")
398                 if err != nil {
399                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
400                         return
401                 }
402                 w.Write(rep)
403         })
404         mux.HandleFunc("/set_ip_flow_hash", func(w http.ResponseWriter, req *http.Request) {
405                 var request = new(SetIPFlowHash)
406                 b, err := ioutil.ReadAll(req.Body)
407                 if err != nil {
408                         http.Error(w, "read body failed", http.StatusBadRequest)
409                         return
410                 }
411                 if err := json.Unmarshal(b, request); err != nil {
412                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
413                         return
414                 }
415                 reply, err := rpc.SetIPFlowHash(req.Context(), request)
416                 if err != nil {
417                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
418                         return
419                 }
420                 rep, err := json.MarshalIndent(reply, "", "  ")
421                 if err != nil {
422                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
423                         return
424                 }
425                 w.Write(rep)
426         })
427         mux.HandleFunc("/sw_interface_ip6_enable_disable", func(w http.ResponseWriter, req *http.Request) {
428                 var request = new(SwInterfaceIP6EnableDisable)
429                 b, err := ioutil.ReadAll(req.Body)
430                 if err != nil {
431                         http.Error(w, "read body failed", http.StatusBadRequest)
432                         return
433                 }
434                 if err := json.Unmarshal(b, request); err != nil {
435                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
436                         return
437                 }
438                 reply, err := rpc.SwInterfaceIP6EnableDisable(req.Context(), request)
439                 if err != nil {
440                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
441                         return
442                 }
443                 rep, err := json.MarshalIndent(reply, "", "  ")
444                 if err != nil {
445                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
446                         return
447                 }
448                 w.Write(rep)
449         })
450         mux.HandleFunc("/sw_interface_ip6_set_link_local_address", func(w http.ResponseWriter, req *http.Request) {
451                 var request = new(SwInterfaceIP6SetLinkLocalAddress)
452                 b, err := ioutil.ReadAll(req.Body)
453                 if err != nil {
454                         http.Error(w, "read body failed", http.StatusBadRequest)
455                         return
456                 }
457                 if err := json.Unmarshal(b, request); err != nil {
458                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
459                         return
460                 }
461                 reply, err := rpc.SwInterfaceIP6SetLinkLocalAddress(req.Context(), request)
462                 if err != nil {
463                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
464                         return
465                 }
466                 rep, err := json.MarshalIndent(reply, "", "  ")
467                 if err != nil {
468                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
469                         return
470                 }
471                 w.Write(rep)
472         })
473         return http.HandlerFunc(mux.ServeHTTP)
474 }