024d6f54e42fab4f4a2f22c410b7631aa8199b5b
[govpp.git] / binapi / lisp / lisp_rest.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2
3 package lisp
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("/lisp_add_del_adjacency", func(w http.ResponseWriter, req *http.Request) {
14                 var request = new(LispAddDelAdjacency)
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.LispAddDelAdjacency(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("/lisp_add_del_local_eid", func(w http.ResponseWriter, req *http.Request) {
37                 var request = new(LispAddDelLocalEid)
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.LispAddDelLocalEid(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("/lisp_add_del_locator", func(w http.ResponseWriter, req *http.Request) {
60                 var request = new(LispAddDelLocator)
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.LispAddDelLocator(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("/lisp_add_del_locator_set", func(w http.ResponseWriter, req *http.Request) {
83                 var request = new(LispAddDelLocatorSet)
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.LispAddDelLocatorSet(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("/lisp_add_del_map_request_itr_rlocs", func(w http.ResponseWriter, req *http.Request) {
106                 var request = new(LispAddDelMapRequestItrRlocs)
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.LispAddDelMapRequestItrRlocs(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("/lisp_add_del_map_resolver", func(w http.ResponseWriter, req *http.Request) {
129                 var request = new(LispAddDelMapResolver)
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.LispAddDelMapResolver(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("/lisp_add_del_map_server", func(w http.ResponseWriter, req *http.Request) {
152                 var request = new(LispAddDelMapServer)
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.LispAddDelMapServer(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("/lisp_add_del_remote_mapping", func(w http.ResponseWriter, req *http.Request) {
175                 var request = new(LispAddDelRemoteMapping)
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.LispAddDelRemoteMapping(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("/lisp_adjacencies_get", func(w http.ResponseWriter, req *http.Request) {
198                 var request = new(LispAdjacenciesGet)
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.LispAdjacenciesGet(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("/lisp_eid_table_add_del_map", func(w http.ResponseWriter, req *http.Request) {
221                 var request = new(LispEidTableAddDelMap)
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.LispEidTableAddDelMap(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("/lisp_enable_disable", func(w http.ResponseWriter, req *http.Request) {
244                 var request = new(LispEnableDisable)
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.LispEnableDisable(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("/lisp_get_map_request_itr_rlocs", func(w http.ResponseWriter, req *http.Request) {
267                 var request = new(LispGetMapRequestItrRlocs)
268                 reply, err := rpc.LispGetMapRequestItrRlocs(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("/lisp_map_register_enable_disable", func(w http.ResponseWriter, req *http.Request) {
281                 var request = new(LispMapRegisterEnableDisable)
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.LispMapRegisterEnableDisable(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("/lisp_map_request_mode", func(w http.ResponseWriter, req *http.Request) {
304                 var request = new(LispMapRequestMode)
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.LispMapRequestMode(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("/lisp_pitr_set_locator_set", func(w http.ResponseWriter, req *http.Request) {
327                 var request = new(LispPitrSetLocatorSet)
328                 b, err := ioutil.ReadAll(req.Body)
329                 if err != nil {
330                         http.Error(w, "read body failed", http.StatusBadRequest)
331                         return
332                 }
333                 if err := json.Unmarshal(b, request); err != nil {
334                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
335                         return
336                 }
337                 reply, err := rpc.LispPitrSetLocatorSet(req.Context(), request)
338                 if err != nil {
339                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
340                         return
341                 }
342                 rep, err := json.MarshalIndent(reply, "", "  ")
343                 if err != nil {
344                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
345                         return
346                 }
347                 w.Write(rep)
348         })
349         mux.HandleFunc("/lisp_rloc_probe_enable_disable", func(w http.ResponseWriter, req *http.Request) {
350                 var request = new(LispRlocProbeEnableDisable)
351                 b, err := ioutil.ReadAll(req.Body)
352                 if err != nil {
353                         http.Error(w, "read body failed", http.StatusBadRequest)
354                         return
355                 }
356                 if err := json.Unmarshal(b, request); err != nil {
357                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
358                         return
359                 }
360                 reply, err := rpc.LispRlocProbeEnableDisable(req.Context(), request)
361                 if err != nil {
362                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
363                         return
364                 }
365                 rep, err := json.MarshalIndent(reply, "", "  ")
366                 if err != nil {
367                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
368                         return
369                 }
370                 w.Write(rep)
371         })
372         mux.HandleFunc("/lisp_use_petr", func(w http.ResponseWriter, req *http.Request) {
373                 var request = new(LispUsePetr)
374                 b, err := ioutil.ReadAll(req.Body)
375                 if err != nil {
376                         http.Error(w, "read body failed", http.StatusBadRequest)
377                         return
378                 }
379                 if err := json.Unmarshal(b, request); err != nil {
380                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
381                         return
382                 }
383                 reply, err := rpc.LispUsePetr(req.Context(), request)
384                 if err != nil {
385                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
386                         return
387                 }
388                 rep, err := json.MarshalIndent(reply, "", "  ")
389                 if err != nil {
390                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
391                         return
392                 }
393                 w.Write(rep)
394         })
395         mux.HandleFunc("/show_lisp_map_register_state", func(w http.ResponseWriter, req *http.Request) {
396                 var request = new(ShowLispMapRegisterState)
397                 reply, err := rpc.ShowLispMapRegisterState(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("/show_lisp_map_request_mode", func(w http.ResponseWriter, req *http.Request) {
410                 var request = new(ShowLispMapRequestMode)
411                 reply, err := rpc.ShowLispMapRequestMode(req.Context(), request)
412                 if err != nil {
413                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
414                         return
415                 }
416                 rep, err := json.MarshalIndent(reply, "", "  ")
417                 if err != nil {
418                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
419                         return
420                 }
421                 w.Write(rep)
422         })
423         mux.HandleFunc("/show_lisp_pitr", func(w http.ResponseWriter, req *http.Request) {
424                 var request = new(ShowLispPitr)
425                 reply, err := rpc.ShowLispPitr(req.Context(), request)
426                 if err != nil {
427                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
428                         return
429                 }
430                 rep, err := json.MarshalIndent(reply, "", "  ")
431                 if err != nil {
432                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
433                         return
434                 }
435                 w.Write(rep)
436         })
437         mux.HandleFunc("/show_lisp_rloc_probe_state", func(w http.ResponseWriter, req *http.Request) {
438                 var request = new(ShowLispRlocProbeState)
439                 reply, err := rpc.ShowLispRlocProbeState(req.Context(), request)
440                 if err != nil {
441                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
442                         return
443                 }
444                 rep, err := json.MarshalIndent(reply, "", "  ")
445                 if err != nil {
446                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
447                         return
448                 }
449                 w.Write(rep)
450         })
451         mux.HandleFunc("/show_lisp_status", func(w http.ResponseWriter, req *http.Request) {
452                 var request = new(ShowLispStatus)
453                 reply, err := rpc.ShowLispStatus(req.Context(), request)
454                 if err != nil {
455                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
456                         return
457                 }
458                 rep, err := json.MarshalIndent(reply, "", "  ")
459                 if err != nil {
460                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
461                         return
462                 }
463                 w.Write(rep)
464         })
465         mux.HandleFunc("/show_lisp_use_petr", func(w http.ResponseWriter, req *http.Request) {
466                 var request = new(ShowLispUsePetr)
467                 reply, err := rpc.ShowLispUsePetr(req.Context(), request)
468                 if err != nil {
469                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
470                         return
471                 }
472                 rep, err := json.MarshalIndent(reply, "", "  ")
473                 if err != nil {
474                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
475                         return
476                 }
477                 w.Write(rep)
478         })
479         return http.HandlerFunc(mux.ServeHTTP)
480 }