From c2456559a66107441addb96f673191bde09d6977 Mon Sep 17 00:00:00 2001 From: Ondrej Fabry Date: Fri, 2 Oct 2020 16:36:32 +0200 Subject: Check retval value and convert to error in generated RPC client code Change-Id: I816b4802cb5fc46239f6db0480fa4cf3645fe2f0 Signed-off-by: Ondrej Fabry --- binapi/ikev2/ikev2.ba.go | 4 +- binapi/ikev2/ikev2_rest.ba.go | 419 ------------------------------------------ binapi/ikev2/ikev2_rpc.ba.go | 36 ++-- 3 files changed, 20 insertions(+), 439 deletions(-) delete mode 100644 binapi/ikev2/ikev2_rest.ba.go (limited to 'binapi/ikev2') diff --git a/binapi/ikev2/ikev2.ba.go b/binapi/ikev2/ikev2.ba.go index 5fc68c3..8313ece 100644 --- a/binapi/ikev2/ikev2.ba.go +++ b/binapi/ikev2/ikev2.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/plugins/ikev2.api.json // Package ikev2 contains generated bindings for API file ikev2.api. diff --git a/binapi/ikev2/ikev2_rest.ba.go b/binapi/ikev2/ikev2_rest.ba.go deleted file mode 100644 index 9ffdffa..0000000 --- a/binapi/ikev2/ikev2_rest.ba.go +++ /dev/null @@ -1,419 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. - -package ikev2 - -import ( - "encoding/json" - "io/ioutil" - "net/http" -) - -func RESTHandler(rpc RPCService) http.Handler { - mux := http.NewServeMux() - mux.HandleFunc("/ikev2_initiate_del_child_sa", func(w http.ResponseWriter, req *http.Request) { - var request = new(Ikev2InitiateDelChildSa) - 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.Ikev2InitiateDelChildSa(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("/ikev2_initiate_del_ike_sa", func(w http.ResponseWriter, req *http.Request) { - var request = new(Ikev2InitiateDelIkeSa) - 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.Ikev2InitiateDelIkeSa(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("/ikev2_initiate_rekey_child_sa", func(w http.ResponseWriter, req *http.Request) { - var request = new(Ikev2InitiateRekeyChildSa) - 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.Ikev2InitiateRekeyChildSa(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("/ikev2_initiate_sa_init", func(w http.ResponseWriter, req *http.Request) { - var request = new(Ikev2InitiateSaInit) - 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.Ikev2InitiateSaInit(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("/ikev2_plugin_get_version", func(w http.ResponseWriter, req *http.Request) { - var request = new(Ikev2PluginGetVersion) - reply, err := rpc.Ikev2PluginGetVersion(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("/ikev2_profile_add_del", func(w http.ResponseWriter, req *http.Request) { - var request = new(Ikev2ProfileAddDel) - 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.Ikev2ProfileAddDel(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("/ikev2_profile_set_auth", func(w http.ResponseWriter, req *http.Request) { - var request = new(Ikev2ProfileSetAuth) - 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.Ikev2ProfileSetAuth(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("/ikev2_profile_set_id", func(w http.ResponseWriter, req *http.Request) { - var request = new(Ikev2ProfileSetID) - 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.Ikev2ProfileSetID(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("/ikev2_profile_set_ipsec_udp_port", func(w http.ResponseWriter, req *http.Request) { - var request = new(Ikev2ProfileSetIpsecUDPPort) - 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.Ikev2ProfileSetIpsecUDPPort(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("/ikev2_profile_set_liveness", func(w http.ResponseWriter, req *http.Request) { - var request = new(Ikev2ProfileSetLiveness) - 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.Ikev2ProfileSetLiveness(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("/ikev2_profile_set_ts", func(w http.ResponseWriter, req *http.Request) { - var request = new(Ikev2ProfileSetTs) - 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.Ikev2ProfileSetTs(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("/ikev2_profile_set_udp_encap", func(w http.ResponseWriter, req *http.Request) { - var request = new(Ikev2ProfileSetUDPEncap) - 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.Ikev2ProfileSetUDPEncap(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("/ikev2_set_esp_transforms", func(w http.ResponseWriter, req *http.Request) { - var request = new(Ikev2SetEspTransforms) - 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.Ikev2SetEspTransforms(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("/ikev2_set_ike_transforms", func(w http.ResponseWriter, req *http.Request) { - var request = new(Ikev2SetIkeTransforms) - 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.Ikev2SetIkeTransforms(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("/ikev2_set_local_key", func(w http.ResponseWriter, req *http.Request) { - var request = new(Ikev2SetLocalKey) - 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.Ikev2SetLocalKey(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("/ikev2_set_responder", func(w http.ResponseWriter, req *http.Request) { - var request = new(Ikev2SetResponder) - 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.Ikev2SetResponder(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("/ikev2_set_sa_lifetime", func(w http.ResponseWriter, req *http.Request) { - var request = new(Ikev2SetSaLifetime) - 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.Ikev2SetSaLifetime(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("/ikev2_set_tunnel_interface", func(w http.ResponseWriter, req *http.Request) { - var request = new(Ikev2SetTunnelInterface) - 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.Ikev2SetTunnelInterface(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/ikev2/ikev2_rpc.ba.go b/binapi/ikev2/ikev2_rpc.ba.go index 3491c54..955c440 100644 --- a/binapi/ikev2/ikev2_rpc.ba.go +++ b/binapi/ikev2/ikev2_rpc.ba.go @@ -8,7 +8,7 @@ import ( api "git.fd.io/govpp.git/api" ) -// RPCService defines RPC service ikev2. +// RPCService defines RPC service ikev2. type RPCService interface { Ikev2InitiateDelChildSa(ctx context.Context, in *Ikev2InitiateDelChildSa) (*Ikev2InitiateDelChildSaReply, error) Ikev2InitiateDelIkeSa(ctx context.Context, in *Ikev2InitiateDelIkeSa) (*Ikev2InitiateDelIkeSaReply, error) @@ -44,7 +44,7 @@ func (c *serviceClient) Ikev2InitiateDelChildSa(ctx context.Context, in *Ikev2In if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2InitiateDelIkeSa(ctx context.Context, in *Ikev2InitiateDelIkeSa) (*Ikev2InitiateDelIkeSaReply, error) { @@ -53,7 +53,7 @@ func (c *serviceClient) Ikev2InitiateDelIkeSa(ctx context.Context, in *Ikev2Init if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2InitiateRekeyChildSa(ctx context.Context, in *Ikev2InitiateRekeyChildSa) (*Ikev2InitiateRekeyChildSaReply, error) { @@ -62,7 +62,7 @@ func (c *serviceClient) Ikev2InitiateRekeyChildSa(ctx context.Context, in *Ikev2 if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2InitiateSaInit(ctx context.Context, in *Ikev2InitiateSaInit) (*Ikev2InitiateSaInitReply, error) { @@ -71,7 +71,7 @@ func (c *serviceClient) Ikev2InitiateSaInit(ctx context.Context, in *Ikev2Initia if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2PluginGetVersion(ctx context.Context, in *Ikev2PluginGetVersion) (*Ikev2PluginGetVersionReply, error) { @@ -89,7 +89,7 @@ func (c *serviceClient) Ikev2ProfileAddDel(ctx context.Context, in *Ikev2Profile if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2ProfileSetAuth(ctx context.Context, in *Ikev2ProfileSetAuth) (*Ikev2ProfileSetAuthReply, error) { @@ -98,7 +98,7 @@ func (c *serviceClient) Ikev2ProfileSetAuth(ctx context.Context, in *Ikev2Profil if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2ProfileSetID(ctx context.Context, in *Ikev2ProfileSetID) (*Ikev2ProfileSetIDReply, error) { @@ -107,7 +107,7 @@ func (c *serviceClient) Ikev2ProfileSetID(ctx context.Context, in *Ikev2ProfileS if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2ProfileSetIpsecUDPPort(ctx context.Context, in *Ikev2ProfileSetIpsecUDPPort) (*Ikev2ProfileSetIpsecUDPPortReply, error) { @@ -116,7 +116,7 @@ func (c *serviceClient) Ikev2ProfileSetIpsecUDPPort(ctx context.Context, in *Ike if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2ProfileSetLiveness(ctx context.Context, in *Ikev2ProfileSetLiveness) (*Ikev2ProfileSetLivenessReply, error) { @@ -125,7 +125,7 @@ func (c *serviceClient) Ikev2ProfileSetLiveness(ctx context.Context, in *Ikev2Pr if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2ProfileSetTs(ctx context.Context, in *Ikev2ProfileSetTs) (*Ikev2ProfileSetTsReply, error) { @@ -134,7 +134,7 @@ func (c *serviceClient) Ikev2ProfileSetTs(ctx context.Context, in *Ikev2ProfileS if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2ProfileSetUDPEncap(ctx context.Context, in *Ikev2ProfileSetUDPEncap) (*Ikev2ProfileSetUDPEncapReply, error) { @@ -143,7 +143,7 @@ func (c *serviceClient) Ikev2ProfileSetUDPEncap(ctx context.Context, in *Ikev2Pr if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2SetEspTransforms(ctx context.Context, in *Ikev2SetEspTransforms) (*Ikev2SetEspTransformsReply, error) { @@ -152,7 +152,7 @@ func (c *serviceClient) Ikev2SetEspTransforms(ctx context.Context, in *Ikev2SetE if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2SetIkeTransforms(ctx context.Context, in *Ikev2SetIkeTransforms) (*Ikev2SetIkeTransformsReply, error) { @@ -161,7 +161,7 @@ func (c *serviceClient) Ikev2SetIkeTransforms(ctx context.Context, in *Ikev2SetI if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2SetLocalKey(ctx context.Context, in *Ikev2SetLocalKey) (*Ikev2SetLocalKeyReply, error) { @@ -170,7 +170,7 @@ func (c *serviceClient) Ikev2SetLocalKey(ctx context.Context, in *Ikev2SetLocalK if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2SetResponder(ctx context.Context, in *Ikev2SetResponder) (*Ikev2SetResponderReply, error) { @@ -179,7 +179,7 @@ func (c *serviceClient) Ikev2SetResponder(ctx context.Context, in *Ikev2SetRespo if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2SetSaLifetime(ctx context.Context, in *Ikev2SetSaLifetime) (*Ikev2SetSaLifetimeReply, error) { @@ -188,7 +188,7 @@ func (c *serviceClient) Ikev2SetSaLifetime(ctx context.Context, in *Ikev2SetSaLi if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) Ikev2SetTunnelInterface(ctx context.Context, in *Ikev2SetTunnelInterface) (*Ikev2SetTunnelInterfaceReply, error) { @@ -197,5 +197,5 @@ func (c *serviceClient) Ikev2SetTunnelInterface(ctx context.Context, in *Ikev2Se if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } -- cgit 1.2.3-korg