diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-10-18 14:10:46 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-10-20 10:33:10 +0900 |
commit | 7cb50ce1cfdf959a74dad516ef65a6c6c34aaec8 (patch) | |
tree | 188236c04337a475078ec2e57932c3e47c8c6154 /api | |
parent | 29f9682ecbe0e5bf0a44fdcc2e9f8cec3f6ea31c (diff) |
api/cli: add api to retrieve statements and support showing them via cli
$ gobgp policy statement
$ gobgp policy statement st0
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'api')
-rw-r--r-- | api/gobgp.pb.go | 87 | ||||
-rw-r--r-- | api/gobgp.proto | 2 |
2 files changed, 89 insertions, 0 deletions
diff --git a/api/gobgp.pb.go b/api/gobgp.pb.go index 3b583fe7..d3bdc1e4 100644 --- a/api/gobgp.pb.go +++ b/api/gobgp.pb.go @@ -749,6 +749,8 @@ type GobgpApiClient interface { GetDefinedSet(ctx context.Context, in *DefinedSet, opts ...grpc.CallOption) (*DefinedSet, error) GetDefinedSets(ctx context.Context, in *DefinedSet, opts ...grpc.CallOption) (GobgpApi_GetDefinedSetsClient, error) ModDefinedSet(ctx context.Context, in *ModDefinedSetArguments, opts ...grpc.CallOption) (*Error, error) + GetStatement(ctx context.Context, in *Statement, opts ...grpc.CallOption) (*Statement, error) + GetStatements(ctx context.Context, in *Statement, opts ...grpc.CallOption) (GobgpApi_GetStatementsClient, error) } type gobgpApiClient struct { @@ -1292,6 +1294,47 @@ func (c *gobgpApiClient) ModDefinedSet(ctx context.Context, in *ModDefinedSetArg return out, nil } +func (c *gobgpApiClient) GetStatement(ctx context.Context, in *Statement, opts ...grpc.CallOption) (*Statement, error) { + out := new(Statement) + err := grpc.Invoke(ctx, "/gobgpapi.GobgpApi/GetStatement", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gobgpApiClient) GetStatements(ctx context.Context, in *Statement, opts ...grpc.CallOption) (GobgpApi_GetStatementsClient, error) { + stream, err := grpc.NewClientStream(ctx, &_GobgpApi_serviceDesc.Streams[13], c.cc, "/gobgpapi.GobgpApi/GetStatements", opts...) + if err != nil { + return nil, err + } + x := &gobgpApiGetStatementsClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type GobgpApi_GetStatementsClient interface { + Recv() (*Statement, error) + grpc.ClientStream +} + +type gobgpApiGetStatementsClient struct { + grpc.ClientStream +} + +func (x *gobgpApiGetStatementsClient) Recv() (*Statement, error) { + m := new(Statement) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + // Server API for GobgpApi service type GobgpApiServer interface { @@ -1321,6 +1364,8 @@ type GobgpApiServer interface { GetDefinedSet(context.Context, *DefinedSet) (*DefinedSet, error) GetDefinedSets(*DefinedSet, GobgpApi_GetDefinedSetsServer) error ModDefinedSet(context.Context, *ModDefinedSetArguments) (*Error, error) + GetStatement(context.Context, *Statement) (*Statement, error) + GetStatements(*Statement, GobgpApi_GetStatementsServer) error } func RegisterGobgpApiServer(s *grpc.Server, srv GobgpApiServer) { @@ -1771,6 +1816,39 @@ func _GobgpApi_ModDefinedSet_Handler(srv interface{}, ctx context.Context, dec f return out, nil } +func _GobgpApi_GetStatement_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error) (interface{}, error) { + in := new(Statement) + if err := dec(in); err != nil { + return nil, err + } + out, err := srv.(GobgpApiServer).GetStatement(ctx, in) + if err != nil { + return nil, err + } + return out, nil +} + +func _GobgpApi_GetStatements_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(Statement) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(GobgpApiServer).GetStatements(m, &gobgpApiGetStatementsServer{stream}) +} + +type GobgpApi_GetStatementsServer interface { + Send(*Statement) error + grpc.ServerStream +} + +type gobgpApiGetStatementsServer struct { + grpc.ServerStream +} + +func (x *gobgpApiGetStatementsServer) Send(m *Statement) error { + return x.ServerStream.SendMsg(m) +} + var _GobgpApi_serviceDesc = grpc.ServiceDesc{ ServiceName: "gobgpapi.GobgpApi", HandlerType: (*GobgpApiServer)(nil), @@ -1827,6 +1905,10 @@ var _GobgpApi_serviceDesc = grpc.ServiceDesc{ MethodName: "ModDefinedSet", Handler: _GobgpApi_ModDefinedSet_Handler, }, + { + MethodName: "GetStatement", + Handler: _GobgpApi_GetStatement_Handler, + }, }, Streams: []grpc.StreamDesc{ { @@ -1896,5 +1978,10 @@ var _GobgpApi_serviceDesc = grpc.ServiceDesc{ Handler: _GobgpApi_GetDefinedSets_Handler, ServerStreams: true, }, + { + StreamName: "GetStatements", + Handler: _GobgpApi_GetStatements_Handler, + ServerStreams: true, + }, }, } diff --git a/api/gobgp.proto b/api/gobgp.proto index f6b59356..ad070e60 100644 --- a/api/gobgp.proto +++ b/api/gobgp.proto @@ -46,6 +46,8 @@ service GobgpApi { rpc GetDefinedSet(DefinedSet) returns (DefinedSet) {} rpc GetDefinedSets(DefinedSet) returns (stream DefinedSet) {} rpc ModDefinedSet(ModDefinedSetArguments) returns (Error) {} + rpc GetStatement(Statement) returns (Statement) {} + rpc GetStatements(Statement) returns (stream Statement) {} } message Error { |