Improve doc & fix import ordering
[govpp.git] / binapi / l2tp / l2tp_rpc.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2
3 package l2tp
4
5 import (
6         "context"
7         "fmt"
8         "io"
9
10         api "git.fd.io/govpp.git/api"
11         vpe "git.fd.io/govpp.git/binapi/vpe"
12 )
13
14 // RPCService defines RPC service  l2tp.
15 type RPCService interface {
16         L2tpv3CreateTunnel(ctx context.Context, in *L2tpv3CreateTunnel) (*L2tpv3CreateTunnelReply, error)
17         L2tpv3InterfaceEnableDisable(ctx context.Context, in *L2tpv3InterfaceEnableDisable) (*L2tpv3InterfaceEnableDisableReply, error)
18         L2tpv3SetLookupKey(ctx context.Context, in *L2tpv3SetLookupKey) (*L2tpv3SetLookupKeyReply, error)
19         L2tpv3SetTunnelCookies(ctx context.Context, in *L2tpv3SetTunnelCookies) (*L2tpv3SetTunnelCookiesReply, error)
20         SwIfL2tpv3TunnelDump(ctx context.Context, in *SwIfL2tpv3TunnelDump) (RPCService_SwIfL2tpv3TunnelDumpClient, error)
21 }
22
23 type serviceClient struct {
24         conn api.Connection
25 }
26
27 func NewServiceClient(conn api.Connection) RPCService {
28         return &serviceClient{conn}
29 }
30
31 func (c *serviceClient) L2tpv3CreateTunnel(ctx context.Context, in *L2tpv3CreateTunnel) (*L2tpv3CreateTunnelReply, error) {
32         out := new(L2tpv3CreateTunnelReply)
33         err := c.conn.Invoke(ctx, in, out)
34         if err != nil {
35                 return nil, err
36         }
37         return out, nil
38 }
39
40 func (c *serviceClient) L2tpv3InterfaceEnableDisable(ctx context.Context, in *L2tpv3InterfaceEnableDisable) (*L2tpv3InterfaceEnableDisableReply, error) {
41         out := new(L2tpv3InterfaceEnableDisableReply)
42         err := c.conn.Invoke(ctx, in, out)
43         if err != nil {
44                 return nil, err
45         }
46         return out, nil
47 }
48
49 func (c *serviceClient) L2tpv3SetLookupKey(ctx context.Context, in *L2tpv3SetLookupKey) (*L2tpv3SetLookupKeyReply, error) {
50         out := new(L2tpv3SetLookupKeyReply)
51         err := c.conn.Invoke(ctx, in, out)
52         if err != nil {
53                 return nil, err
54         }
55         return out, nil
56 }
57
58 func (c *serviceClient) L2tpv3SetTunnelCookies(ctx context.Context, in *L2tpv3SetTunnelCookies) (*L2tpv3SetTunnelCookiesReply, error) {
59         out := new(L2tpv3SetTunnelCookiesReply)
60         err := c.conn.Invoke(ctx, in, out)
61         if err != nil {
62                 return nil, err
63         }
64         return out, nil
65 }
66
67 func (c *serviceClient) SwIfL2tpv3TunnelDump(ctx context.Context, in *SwIfL2tpv3TunnelDump) (RPCService_SwIfL2tpv3TunnelDumpClient, error) {
68         stream, err := c.conn.NewStream(ctx)
69         if err != nil {
70                 return nil, err
71         }
72         x := &serviceClient_SwIfL2tpv3TunnelDumpClient{stream}
73         if err := x.Stream.SendMsg(in); err != nil {
74                 return nil, err
75         }
76         if err = x.Stream.SendMsg(&vpe.ControlPing{}); err != nil {
77                 return nil, err
78         }
79         return x, nil
80 }
81
82 type RPCService_SwIfL2tpv3TunnelDumpClient interface {
83         Recv() (*SwIfL2tpv3TunnelDetails, error)
84         api.Stream
85 }
86
87 type serviceClient_SwIfL2tpv3TunnelDumpClient struct {
88         api.Stream
89 }
90
91 func (c *serviceClient_SwIfL2tpv3TunnelDumpClient) Recv() (*SwIfL2tpv3TunnelDetails, error) {
92         msg, err := c.Stream.RecvMsg()
93         if err != nil {
94                 return nil, err
95         }
96         switch m := msg.(type) {
97         case *SwIfL2tpv3TunnelDetails:
98                 return m, nil
99         case *vpe.ControlPingReply:
100                 return nil, io.EOF
101         default:
102                 return nil, fmt.Errorf("unexpected message: %T %v", m, m)
103         }
104 }