Updated changelog for v0.4.0
[govpp.git] / binapi / acl / acl_rest.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2
3 package acl
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("/acl_add_replace", func(w http.ResponseWriter, req *http.Request) {
14                 var request = new(ACLAddReplace)
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.ACLAddReplace(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("/acl_del", func(w http.ResponseWriter, req *http.Request) {
37                 var request = new(ACLDel)
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.ACLDel(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("/acl_interface_add_del", func(w http.ResponseWriter, req *http.Request) {
60                 var request = new(ACLInterfaceAddDel)
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.ACLInterfaceAddDel(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("/acl_interface_set_acl_list", func(w http.ResponseWriter, req *http.Request) {
83                 var request = new(ACLInterfaceSetACLList)
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.ACLInterfaceSetACLList(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("/acl_interface_set_etype_whitelist", func(w http.ResponseWriter, req *http.Request) {
106                 var request = new(ACLInterfaceSetEtypeWhitelist)
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.ACLInterfaceSetEtypeWhitelist(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("/acl_plugin_control_ping", func(w http.ResponseWriter, req *http.Request) {
129                 var request = new(ACLPluginControlPing)
130                 reply, err := rpc.ACLPluginControlPing(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("/acl_plugin_get_conn_table_max_entries", func(w http.ResponseWriter, req *http.Request) {
143                 var request = new(ACLPluginGetConnTableMaxEntries)
144                 reply, err := rpc.ACLPluginGetConnTableMaxEntries(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("/acl_plugin_get_version", func(w http.ResponseWriter, req *http.Request) {
157                 var request = new(ACLPluginGetVersion)
158                 reply, err := rpc.ACLPluginGetVersion(req.Context(), request)
159                 if err != nil {
160                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
161                         return
162                 }
163                 rep, err := json.MarshalIndent(reply, "", "  ")
164                 if err != nil {
165                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
166                         return
167                 }
168                 w.Write(rep)
169         })
170         mux.HandleFunc("/acl_stats_intf_counters_enable", func(w http.ResponseWriter, req *http.Request) {
171                 var request = new(ACLStatsIntfCountersEnable)
172                 b, err := ioutil.ReadAll(req.Body)
173                 if err != nil {
174                         http.Error(w, "read body failed", http.StatusBadRequest)
175                         return
176                 }
177                 if err := json.Unmarshal(b, request); err != nil {
178                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
179                         return
180                 }
181                 reply, err := rpc.ACLStatsIntfCountersEnable(req.Context(), request)
182                 if err != nil {
183                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
184                         return
185                 }
186                 rep, err := json.MarshalIndent(reply, "", "  ")
187                 if err != nil {
188                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
189                         return
190                 }
191                 w.Write(rep)
192         })
193         mux.HandleFunc("/macip_acl_add", func(w http.ResponseWriter, req *http.Request) {
194                 var request = new(MacipACLAdd)
195                 b, err := ioutil.ReadAll(req.Body)
196                 if err != nil {
197                         http.Error(w, "read body failed", http.StatusBadRequest)
198                         return
199                 }
200                 if err := json.Unmarshal(b, request); err != nil {
201                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
202                         return
203                 }
204                 reply, err := rpc.MacipACLAdd(req.Context(), request)
205                 if err != nil {
206                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
207                         return
208                 }
209                 rep, err := json.MarshalIndent(reply, "", "  ")
210                 if err != nil {
211                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
212                         return
213                 }
214                 w.Write(rep)
215         })
216         mux.HandleFunc("/macip_acl_add_replace", func(w http.ResponseWriter, req *http.Request) {
217                 var request = new(MacipACLAddReplace)
218                 b, err := ioutil.ReadAll(req.Body)
219                 if err != nil {
220                         http.Error(w, "read body failed", http.StatusBadRequest)
221                         return
222                 }
223                 if err := json.Unmarshal(b, request); err != nil {
224                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
225                         return
226                 }
227                 reply, err := rpc.MacipACLAddReplace(req.Context(), request)
228                 if err != nil {
229                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
230                         return
231                 }
232                 rep, err := json.MarshalIndent(reply, "", "  ")
233                 if err != nil {
234                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
235                         return
236                 }
237                 w.Write(rep)
238         })
239         mux.HandleFunc("/macip_acl_del", func(w http.ResponseWriter, req *http.Request) {
240                 var request = new(MacipACLDel)
241                 b, err := ioutil.ReadAll(req.Body)
242                 if err != nil {
243                         http.Error(w, "read body failed", http.StatusBadRequest)
244                         return
245                 }
246                 if err := json.Unmarshal(b, request); err != nil {
247                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
248                         return
249                 }
250                 reply, err := rpc.MacipACLDel(req.Context(), request)
251                 if err != nil {
252                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
253                         return
254                 }
255                 rep, err := json.MarshalIndent(reply, "", "  ")
256                 if err != nil {
257                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
258                         return
259                 }
260                 w.Write(rep)
261         })
262         mux.HandleFunc("/macip_acl_interface_add_del", func(w http.ResponseWriter, req *http.Request) {
263                 var request = new(MacipACLInterfaceAddDel)
264                 b, err := ioutil.ReadAll(req.Body)
265                 if err != nil {
266                         http.Error(w, "read body failed", http.StatusBadRequest)
267                         return
268                 }
269                 if err := json.Unmarshal(b, request); err != nil {
270                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
271                         return
272                 }
273                 reply, err := rpc.MacipACLInterfaceAddDel(req.Context(), request)
274                 if err != nil {
275                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
276                         return
277                 }
278                 rep, err := json.MarshalIndent(reply, "", "  ")
279                 if err != nil {
280                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
281                         return
282                 }
283                 w.Write(rep)
284         })
285         mux.HandleFunc("/macip_acl_interface_get", func(w http.ResponseWriter, req *http.Request) {
286                 var request = new(MacipACLInterfaceGet)
287                 reply, err := rpc.MacipACLInterfaceGet(req.Context(), request)
288                 if err != nil {
289                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
290                         return
291                 }
292                 rep, err := json.MarshalIndent(reply, "", "  ")
293                 if err != nil {
294                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
295                         return
296                 }
297                 w.Write(rep)
298         })
299         return http.HandlerFunc(mux.ServeHTTP)
300 }