Updated changelog for v0.4.0
[govpp.git] / binapi / dhcp / dhcp_rest.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2
3 package dhcp
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("/dhcp6_clients_enable_disable", func(w http.ResponseWriter, req *http.Request) {
14                 var request = new(DHCP6ClientsEnableDisable)
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.DHCP6ClientsEnableDisable(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("/dhcp6_duid_ll_set", func(w http.ResponseWriter, req *http.Request) {
37                 var request = new(DHCP6DuidLlSet)
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.DHCP6DuidLlSet(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("/dhcp6_pd_send_client_message", func(w http.ResponseWriter, req *http.Request) {
60                 var request = new(DHCP6PdSendClientMessage)
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.DHCP6PdSendClientMessage(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("/dhcp6_send_client_message", func(w http.ResponseWriter, req *http.Request) {
83                 var request = new(DHCP6SendClientMessage)
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.DHCP6SendClientMessage(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("/dhcp_client_config", func(w http.ResponseWriter, req *http.Request) {
106                 var request = new(DHCPClientConfig)
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.DHCPClientConfig(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("/dhcp_plugin_control_ping", func(w http.ResponseWriter, req *http.Request) {
129                 var request = new(DHCPPluginControlPing)
130                 reply, err := rpc.DHCPPluginControlPing(req.Context(), request)
131                 if err != nil {
132                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
133                         return
134                 }
135                 rep, err := json.MarshalIndent(reply, "", "  ")
136                 if err != nil {
137                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
138                         return
139                 }
140                 w.Write(rep)
141         })
142         mux.HandleFunc("/dhcp_plugin_get_version", func(w http.ResponseWriter, req *http.Request) {
143                 var request = new(DHCPPluginGetVersion)
144                 reply, err := rpc.DHCPPluginGetVersion(req.Context(), request)
145                 if err != nil {
146                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
147                         return
148                 }
149                 rep, err := json.MarshalIndent(reply, "", "  ")
150                 if err != nil {
151                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
152                         return
153                 }
154                 w.Write(rep)
155         })
156         mux.HandleFunc("/dhcp_proxy_config", func(w http.ResponseWriter, req *http.Request) {
157                 var request = new(DHCPProxyConfig)
158                 b, err := ioutil.ReadAll(req.Body)
159                 if err != nil {
160                         http.Error(w, "read body failed", http.StatusBadRequest)
161                         return
162                 }
163                 if err := json.Unmarshal(b, request); err != nil {
164                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
165                         return
166                 }
167                 reply, err := rpc.DHCPProxyConfig(req.Context(), request)
168                 if err != nil {
169                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
170                         return
171                 }
172                 rep, err := json.MarshalIndent(reply, "", "  ")
173                 if err != nil {
174                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
175                         return
176                 }
177                 w.Write(rep)
178         })
179         mux.HandleFunc("/dhcp_proxy_set_vss", func(w http.ResponseWriter, req *http.Request) {
180                 var request = new(DHCPProxySetVss)
181                 b, err := ioutil.ReadAll(req.Body)
182                 if err != nil {
183                         http.Error(w, "read body failed", http.StatusBadRequest)
184                         return
185                 }
186                 if err := json.Unmarshal(b, request); err != nil {
187                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
188                         return
189                 }
190                 reply, err := rpc.DHCPProxySetVss(req.Context(), request)
191                 if err != nil {
192                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
193                         return
194                 }
195                 rep, err := json.MarshalIndent(reply, "", "  ")
196                 if err != nil {
197                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
198                         return
199                 }
200                 w.Write(rep)
201         })
202         mux.HandleFunc("/want_dhcp6_pd_reply_events", func(w http.ResponseWriter, req *http.Request) {
203                 var request = new(WantDHCP6PdReplyEvents)
204                 b, err := ioutil.ReadAll(req.Body)
205                 if err != nil {
206                         http.Error(w, "read body failed", http.StatusBadRequest)
207                         return
208                 }
209                 if err := json.Unmarshal(b, request); err != nil {
210                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
211                         return
212                 }
213                 reply, err := rpc.WantDHCP6PdReplyEvents(req.Context(), request)
214                 if err != nil {
215                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
216                         return
217                 }
218                 rep, err := json.MarshalIndent(reply, "", "  ")
219                 if err != nil {
220                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
221                         return
222                 }
223                 w.Write(rep)
224         })
225         mux.HandleFunc("/want_dhcp6_reply_events", func(w http.ResponseWriter, req *http.Request) {
226                 var request = new(WantDHCP6ReplyEvents)
227                 b, err := ioutil.ReadAll(req.Body)
228                 if err != nil {
229                         http.Error(w, "read body failed", http.StatusBadRequest)
230                         return
231                 }
232                 if err := json.Unmarshal(b, request); err != nil {
233                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
234                         return
235                 }
236                 reply, err := rpc.WantDHCP6ReplyEvents(req.Context(), request)
237                 if err != nil {
238                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
239                         return
240                 }
241                 rep, err := json.MarshalIndent(reply, "", "  ")
242                 if err != nil {
243                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
244                         return
245                 }
246                 w.Write(rep)
247         })
248         return http.HandlerFunc(mux.ServeHTTP)
249 }