diff options
author | Ondrej Fabry <ofabry@cisco.com> | 2020-10-02 16:36:32 +0200 |
---|---|---|
committer | Ondrej Fabry <ofabry@cisco.com> | 2020-10-02 16:36:32 +0200 |
commit | c2456559a66107441addb96f673191bde09d6977 (patch) | |
tree | 30020a936849f78f432cf5b6fe0bbb0489e485b6 /binapi/classify | |
parent | f751f3f845ef56bbcdb873d81a1c6edbc5a87853 (diff) |
Check retval value and convert to error in generated RPC client code
Change-Id: I816b4802cb5fc46239f6db0480fa4cf3645fe2f0
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'binapi/classify')
-rw-r--r-- | binapi/classify/classify.ba.go | 4 | ||||
-rw-r--r-- | binapi/classify/classify_rest.ba.go | 258 | ||||
-rw-r--r-- | binapi/classify/classify_rpc.ba.go | 24 |
3 files changed, 14 insertions, 272 deletions
diff --git a/binapi/classify/classify.ba.go b/binapi/classify/classify.ba.go index 16bc4b8..89be260 100644 --- a/binapi/classify/classify.ba.go +++ b/binapi/classify/classify.ba.go @@ -1,7 +1,7 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev -// VPP: 20.05-release +// binapi-generator: v0.4.0 +// VPP: 20.05.1-release // source: /usr/share/vpp/api/core/classify.api.json // Package classify contains generated bindings for API file classify.api. diff --git a/binapi/classify/classify_rest.ba.go b/binapi/classify/classify_rest.ba.go deleted file mode 100644 index f50fefd..0000000 --- a/binapi/classify/classify_rest.ba.go +++ /dev/null @@ -1,258 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. - -package classify - -import ( - "encoding/json" - "io/ioutil" - "net/http" -) - -func RESTHandler(rpc RPCService) http.Handler { - mux := http.NewServeMux() - mux.HandleFunc("/classify_add_del_session", func(w http.ResponseWriter, req *http.Request) { - var request = new(ClassifyAddDelSession) - b, err := ioutil.ReadAll(req.Body) - if err != nil { - http.Error(w, "read body failed", http.StatusBadRequest) - return - } - if err := json.Unmarshal(b, request); err != nil { - http.Error(w, "unmarshal data failed", http.StatusBadRequest) - return - } - reply, err := rpc.ClassifyAddDelSession(req.Context(), request) - if err != nil { - http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) - return - } - rep, err := json.MarshalIndent(reply, "", " ") - if err != nil { - http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) - return - } - w.Write(rep) - }) - mux.HandleFunc("/classify_add_del_table", func(w http.ResponseWriter, req *http.Request) { - var request = new(ClassifyAddDelTable) - b, err := ioutil.ReadAll(req.Body) - if err != nil { - http.Error(w, "read body failed", http.StatusBadRequest) - return - } - if err := json.Unmarshal(b, request); err != nil { - http.Error(w, "unmarshal data failed", http.StatusBadRequest) - return - } - reply, err := rpc.ClassifyAddDelTable(req.Context(), request) - if err != nil { - http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) - return - } - rep, err := json.MarshalIndent(reply, "", " ") - if err != nil { - http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) - return - } - w.Write(rep) - }) - mux.HandleFunc("/classify_set_interface_ip_table", func(w http.ResponseWriter, req *http.Request) { - var request = new(ClassifySetInterfaceIPTable) - b, err := ioutil.ReadAll(req.Body) - if err != nil { - http.Error(w, "read body failed", http.StatusBadRequest) - return - } - if err := json.Unmarshal(b, request); err != nil { - http.Error(w, "unmarshal data failed", http.StatusBadRequest) - return - } - reply, err := rpc.ClassifySetInterfaceIPTable(req.Context(), request) - if err != nil { - http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) - return - } - rep, err := json.MarshalIndent(reply, "", " ") - if err != nil { - http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) - return - } - w.Write(rep) - }) - mux.HandleFunc("/classify_set_interface_l2_tables", func(w http.ResponseWriter, req *http.Request) { - var request = new(ClassifySetInterfaceL2Tables) - b, err := ioutil.ReadAll(req.Body) - if err != nil { - http.Error(w, "read body failed", http.StatusBadRequest) - return - } - if err := json.Unmarshal(b, request); err != nil { - http.Error(w, "unmarshal data failed", http.StatusBadRequest) - return - } - reply, err := rpc.ClassifySetInterfaceL2Tables(req.Context(), request) - if err != nil { - http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) - return - } - rep, err := json.MarshalIndent(reply, "", " ") - if err != nil { - http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) - return - } - w.Write(rep) - }) - mux.HandleFunc("/classify_table_by_interface", func(w http.ResponseWriter, req *http.Request) { - var request = new(ClassifyTableByInterface) - b, err := ioutil.ReadAll(req.Body) - if err != nil { - http.Error(w, "read body failed", http.StatusBadRequest) - return - } - if err := json.Unmarshal(b, request); err != nil { - http.Error(w, "unmarshal data failed", http.StatusBadRequest) - return - } - reply, err := rpc.ClassifyTableByInterface(req.Context(), request) - if err != nil { - http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) - return - } - rep, err := json.MarshalIndent(reply, "", " ") - if err != nil { - http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) - return - } - w.Write(rep) - }) - mux.HandleFunc("/classify_table_ids", func(w http.ResponseWriter, req *http.Request) { - var request = new(ClassifyTableIds) - reply, err := rpc.ClassifyTableIds(req.Context(), request) - if err != nil { - http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) - return - } - rep, err := json.MarshalIndent(reply, "", " ") - if err != nil { - http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) - return - } - w.Write(rep) - }) - mux.HandleFunc("/classify_table_info", func(w http.ResponseWriter, req *http.Request) { - var request = new(ClassifyTableInfo) - b, err := ioutil.ReadAll(req.Body) - if err != nil { - http.Error(w, "read body failed", http.StatusBadRequest) - return - } - if err := json.Unmarshal(b, request); err != nil { - http.Error(w, "unmarshal data failed", http.StatusBadRequest) - return - } - reply, err := rpc.ClassifyTableInfo(req.Context(), request) - if err != nil { - http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) - return - } - rep, err := json.MarshalIndent(reply, "", " ") - if err != nil { - http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) - return - } - w.Write(rep) - }) - mux.HandleFunc("/flow_classify_set_interface", func(w http.ResponseWriter, req *http.Request) { - var request = new(FlowClassifySetInterface) - b, err := ioutil.ReadAll(req.Body) - if err != nil { - http.Error(w, "read body failed", http.StatusBadRequest) - return - } - if err := json.Unmarshal(b, request); err != nil { - http.Error(w, "unmarshal data failed", http.StatusBadRequest) - return - } - reply, err := rpc.FlowClassifySetInterface(req.Context(), request) - if err != nil { - http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) - return - } - rep, err := json.MarshalIndent(reply, "", " ") - if err != nil { - http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) - return - } - w.Write(rep) - }) - mux.HandleFunc("/input_acl_set_interface", func(w http.ResponseWriter, req *http.Request) { - var request = new(InputACLSetInterface) - b, err := ioutil.ReadAll(req.Body) - if err != nil { - http.Error(w, "read body failed", http.StatusBadRequest) - return - } - if err := json.Unmarshal(b, request); err != nil { - http.Error(w, "unmarshal data failed", http.StatusBadRequest) - return - } - reply, err := rpc.InputACLSetInterface(req.Context(), request) - if err != nil { - http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) - return - } - rep, err := json.MarshalIndent(reply, "", " ") - if err != nil { - http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) - return - } - w.Write(rep) - }) - mux.HandleFunc("/output_acl_set_interface", func(w http.ResponseWriter, req *http.Request) { - var request = new(OutputACLSetInterface) - b, err := ioutil.ReadAll(req.Body) - if err != nil { - http.Error(w, "read body failed", http.StatusBadRequest) - return - } - if err := json.Unmarshal(b, request); err != nil { - http.Error(w, "unmarshal data failed", http.StatusBadRequest) - return - } - reply, err := rpc.OutputACLSetInterface(req.Context(), request) - if err != nil { - http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) - return - } - rep, err := json.MarshalIndent(reply, "", " ") - if err != nil { - http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) - return - } - w.Write(rep) - }) - mux.HandleFunc("/policer_classify_set_interface", func(w http.ResponseWriter, req *http.Request) { - var request = new(PolicerClassifySetInterface) - b, err := ioutil.ReadAll(req.Body) - if err != nil { - http.Error(w, "read body failed", http.StatusBadRequest) - return - } - if err := json.Unmarshal(b, request); err != nil { - http.Error(w, "unmarshal data failed", http.StatusBadRequest) - return - } - reply, err := rpc.PolicerClassifySetInterface(req.Context(), request) - if err != nil { - http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) - return - } - rep, err := json.MarshalIndent(reply, "", " ") - if err != nil { - http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) - return - } - w.Write(rep) - }) - return http.HandlerFunc(mux.ServeHTTP) -} diff --git a/binapi/classify/classify_rpc.ba.go b/binapi/classify/classify_rpc.ba.go index de29fa5..5bbb43b 100644 --- a/binapi/classify/classify_rpc.ba.go +++ b/binapi/classify/classify_rpc.ba.go @@ -11,7 +11,7 @@ import ( vpe "git.fd.io/govpp.git/binapi/vpe" ) -// RPCService defines RPC service classify. +// RPCService defines RPC service classify. type RPCService interface { ClassifyAddDelSession(ctx context.Context, in *ClassifyAddDelSession) (*ClassifyAddDelSessionReply, error) ClassifyAddDelTable(ctx context.Context, in *ClassifyAddDelTable) (*ClassifyAddDelTableReply, error) @@ -43,7 +43,7 @@ func (c *serviceClient) ClassifyAddDelSession(ctx context.Context, in *ClassifyA if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ClassifyAddDelTable(ctx context.Context, in *ClassifyAddDelTable) (*ClassifyAddDelTableReply, error) { @@ -52,7 +52,7 @@ func (c *serviceClient) ClassifyAddDelTable(ctx context.Context, in *ClassifyAdd if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ClassifySessionDump(ctx context.Context, in *ClassifySessionDump) (RPCService_ClassifySessionDumpClient, error) { @@ -100,7 +100,7 @@ func (c *serviceClient) ClassifySetInterfaceIPTable(ctx context.Context, in *Cla if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ClassifySetInterfaceL2Tables(ctx context.Context, in *ClassifySetInterfaceL2Tables) (*ClassifySetInterfaceL2TablesReply, error) { @@ -109,7 +109,7 @@ func (c *serviceClient) ClassifySetInterfaceL2Tables(ctx context.Context, in *Cl if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ClassifyTableByInterface(ctx context.Context, in *ClassifyTableByInterface) (*ClassifyTableByInterfaceReply, error) { @@ -118,7 +118,7 @@ func (c *serviceClient) ClassifyTableByInterface(ctx context.Context, in *Classi if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ClassifyTableIds(ctx context.Context, in *ClassifyTableIds) (*ClassifyTableIdsReply, error) { @@ -127,7 +127,7 @@ func (c *serviceClient) ClassifyTableIds(ctx context.Context, in *ClassifyTableI if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) ClassifyTableInfo(ctx context.Context, in *ClassifyTableInfo) (*ClassifyTableInfoReply, error) { @@ -136,7 +136,7 @@ func (c *serviceClient) ClassifyTableInfo(ctx context.Context, in *ClassifyTable if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) FlowClassifyDump(ctx context.Context, in *FlowClassifyDump) (RPCService_FlowClassifyDumpClient, error) { @@ -184,7 +184,7 @@ func (c *serviceClient) FlowClassifySetInterface(ctx context.Context, in *FlowCl if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) InputACLSetInterface(ctx context.Context, in *InputACLSetInterface) (*InputACLSetInterfaceReply, error) { @@ -193,7 +193,7 @@ func (c *serviceClient) InputACLSetInterface(ctx context.Context, in *InputACLSe if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) OutputACLSetInterface(ctx context.Context, in *OutputACLSetInterface) (*OutputACLSetInterfaceReply, error) { @@ -202,7 +202,7 @@ func (c *serviceClient) OutputACLSetInterface(ctx context.Context, in *OutputACL if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) PolicerClassifyDump(ctx context.Context, in *PolicerClassifyDump) (RPCService_PolicerClassifyDumpClient, error) { @@ -250,5 +250,5 @@ func (c *serviceClient) PolicerClassifySetInterface(ctx context.Context, in *Pol if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } |