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/gbp | |
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/gbp')
-rw-r--r-- | binapi/gbp/gbp.ba.go | 4 | ||||
-rw-r--r-- | binapi/gbp/gbp_rest.ba.go | 336 | ||||
-rw-r--r-- | binapi/gbp/gbp_rpc.ba.go | 30 |
3 files changed, 17 insertions, 353 deletions
diff --git a/binapi/gbp/gbp.ba.go b/binapi/gbp/gbp.ba.go index 066371a..efa1bbc 100644 --- a/binapi/gbp/gbp.ba.go +++ b/binapi/gbp/gbp.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/gbp.api.json // Package gbp contains generated bindings for API file gbp.api. diff --git a/binapi/gbp/gbp_rest.ba.go b/binapi/gbp/gbp_rest.ba.go deleted file mode 100644 index 9999a07..0000000 --- a/binapi/gbp/gbp_rest.ba.go +++ /dev/null @@ -1,336 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. - -package gbp - -import ( - "encoding/json" - "io/ioutil" - "net/http" -) - -func RESTHandler(rpc RPCService) http.Handler { - mux := http.NewServeMux() - mux.HandleFunc("/gbp_bridge_domain_add", func(w http.ResponseWriter, req *http.Request) { - var request = new(GbpBridgeDomainAdd) - 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.GbpBridgeDomainAdd(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("/gbp_bridge_domain_del", func(w http.ResponseWriter, req *http.Request) { - var request = new(GbpBridgeDomainDel) - 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.GbpBridgeDomainDel(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("/gbp_contract_add_del", func(w http.ResponseWriter, req *http.Request) { - var request = new(GbpContractAddDel) - 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.GbpContractAddDel(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("/gbp_endpoint_add", func(w http.ResponseWriter, req *http.Request) { - var request = new(GbpEndpointAdd) - 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.GbpEndpointAdd(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("/gbp_endpoint_del", func(w http.ResponseWriter, req *http.Request) { - var request = new(GbpEndpointDel) - 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.GbpEndpointDel(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("/gbp_endpoint_group_add", func(w http.ResponseWriter, req *http.Request) { - var request = new(GbpEndpointGroupAdd) - 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.GbpEndpointGroupAdd(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("/gbp_endpoint_group_del", func(w http.ResponseWriter, req *http.Request) { - var request = new(GbpEndpointGroupDel) - 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.GbpEndpointGroupDel(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("/gbp_ext_itf_add_del", func(w http.ResponseWriter, req *http.Request) { - var request = new(GbpExtItfAddDel) - 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.GbpExtItfAddDel(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("/gbp_recirc_add_del", func(w http.ResponseWriter, req *http.Request) { - var request = new(GbpRecircAddDel) - 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.GbpRecircAddDel(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("/gbp_route_domain_add", func(w http.ResponseWriter, req *http.Request) { - var request = new(GbpRouteDomainAdd) - 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.GbpRouteDomainAdd(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("/gbp_route_domain_del", func(w http.ResponseWriter, req *http.Request) { - var request = new(GbpRouteDomainDel) - 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.GbpRouteDomainDel(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("/gbp_subnet_add_del", func(w http.ResponseWriter, req *http.Request) { - var request = new(GbpSubnetAddDel) - 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.GbpSubnetAddDel(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("/gbp_vxlan_tunnel_add", func(w http.ResponseWriter, req *http.Request) { - var request = new(GbpVxlanTunnelAdd) - 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.GbpVxlanTunnelAdd(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("/gbp_vxlan_tunnel_del", func(w http.ResponseWriter, req *http.Request) { - var request = new(GbpVxlanTunnelDel) - 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.GbpVxlanTunnelDel(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/gbp/gbp_rpc.ba.go b/binapi/gbp/gbp_rpc.ba.go index 635394e..4b45ea7 100644 --- a/binapi/gbp/gbp_rpc.ba.go +++ b/binapi/gbp/gbp_rpc.ba.go @@ -11,7 +11,7 @@ import ( vpe "git.fd.io/govpp.git/binapi/vpe" ) -// RPCService defines RPC service gbp. +// RPCService defines RPC service gbp. type RPCService interface { GbpBridgeDomainAdd(ctx context.Context, in *GbpBridgeDomainAdd) (*GbpBridgeDomainAddReply, error) GbpBridgeDomainDel(ctx context.Context, in *GbpBridgeDomainDel) (*GbpBridgeDomainDelReply, error) @@ -52,7 +52,7 @@ func (c *serviceClient) GbpBridgeDomainAdd(ctx context.Context, in *GbpBridgeDom if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpBridgeDomainDel(ctx context.Context, in *GbpBridgeDomainDel) (*GbpBridgeDomainDelReply, error) { @@ -61,7 +61,7 @@ func (c *serviceClient) GbpBridgeDomainDel(ctx context.Context, in *GbpBridgeDom if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpBridgeDomainDump(ctx context.Context, in *GbpBridgeDomainDump) (RPCService_GbpBridgeDomainDumpClient, error) { @@ -109,7 +109,7 @@ func (c *serviceClient) GbpContractAddDel(ctx context.Context, in *GbpContractAd if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpContractDump(ctx context.Context, in *GbpContractDump) (RPCService_GbpContractDumpClient, error) { @@ -157,7 +157,7 @@ func (c *serviceClient) GbpEndpointAdd(ctx context.Context, in *GbpEndpointAdd) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpEndpointDel(ctx context.Context, in *GbpEndpointDel) (*GbpEndpointDelReply, error) { @@ -166,7 +166,7 @@ func (c *serviceClient) GbpEndpointDel(ctx context.Context, in *GbpEndpointDel) if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpEndpointDump(ctx context.Context, in *GbpEndpointDump) (RPCService_GbpEndpointDumpClient, error) { @@ -214,7 +214,7 @@ func (c *serviceClient) GbpEndpointGroupAdd(ctx context.Context, in *GbpEndpoint if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpEndpointGroupDel(ctx context.Context, in *GbpEndpointGroupDel) (*GbpEndpointGroupDelReply, error) { @@ -223,7 +223,7 @@ func (c *serviceClient) GbpEndpointGroupDel(ctx context.Context, in *GbpEndpoint if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpEndpointGroupDump(ctx context.Context, in *GbpEndpointGroupDump) (RPCService_GbpEndpointGroupDumpClient, error) { @@ -271,7 +271,7 @@ func (c *serviceClient) GbpExtItfAddDel(ctx context.Context, in *GbpExtItfAddDel if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpExtItfDump(ctx context.Context, in *GbpExtItfDump) (RPCService_GbpExtItfDumpClient, error) { @@ -319,7 +319,7 @@ func (c *serviceClient) GbpRecircAddDel(ctx context.Context, in *GbpRecircAddDel if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpRecircDump(ctx context.Context, in *GbpRecircDump) (RPCService_GbpRecircDumpClient, error) { @@ -367,7 +367,7 @@ func (c *serviceClient) GbpRouteDomainAdd(ctx context.Context, in *GbpRouteDomai if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpRouteDomainDel(ctx context.Context, in *GbpRouteDomainDel) (*GbpRouteDomainDelReply, error) { @@ -376,7 +376,7 @@ func (c *serviceClient) GbpRouteDomainDel(ctx context.Context, in *GbpRouteDomai if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpRouteDomainDump(ctx context.Context, in *GbpRouteDomainDump) (RPCService_GbpRouteDomainDumpClient, error) { @@ -424,7 +424,7 @@ func (c *serviceClient) GbpSubnetAddDel(ctx context.Context, in *GbpSubnetAddDel if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpSubnetDump(ctx context.Context, in *GbpSubnetDump) (RPCService_GbpSubnetDumpClient, error) { @@ -472,7 +472,7 @@ func (c *serviceClient) GbpVxlanTunnelAdd(ctx context.Context, in *GbpVxlanTunne if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpVxlanTunnelDel(ctx context.Context, in *GbpVxlanTunnelDel) (*GbpVxlanTunnelDelReply, error) { @@ -481,7 +481,7 @@ func (c *serviceClient) GbpVxlanTunnelDel(ctx context.Context, in *GbpVxlanTunne if err != nil { return nil, err } - return out, nil + return out, api.RetvalToVPPApiError(out.Retval) } func (c *serviceClient) GbpVxlanTunnelDump(ctx context.Context, in *GbpVxlanTunnelDump) (RPCService_GbpVxlanTunnelDumpClient, error) { |