2024-04-24 17:23:15 +00:00
|
|
|
package apemanager
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
apemanager_svc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/apemanager"
|
2024-11-07 14:32:10 +00:00
|
|
|
apemanager_v2 "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/apemanager"
|
|
|
|
apemanager_grpc "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/apemanager/grpc"
|
2024-04-24 17:23:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Server struct {
|
|
|
|
srv apemanager_svc.Server
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ apemanager_grpc.APEManagerServiceServer = (*Server)(nil)
|
|
|
|
|
|
|
|
func New(c apemanager_svc.Server) *Server {
|
|
|
|
return &Server{
|
|
|
|
srv: c,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) AddChain(ctx context.Context, req *apemanager_grpc.AddChainRequest) (*apemanager_grpc.AddChainResponse, error) {
|
|
|
|
v2req := new(apemanager_v2.AddChainRequest)
|
|
|
|
if err := v2req.FromGRPCMessage(req); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := s.srv.AddChain(ctx, v2req)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return resp.ToGRPCMessage().(*apemanager_grpc.AddChainResponse), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) RemoveChain(ctx context.Context, req *apemanager_grpc.RemoveChainRequest) (*apemanager_grpc.RemoveChainResponse, error) {
|
|
|
|
v2req := new(apemanager_v2.RemoveChainRequest)
|
|
|
|
if err := v2req.FromGRPCMessage(req); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := s.srv.RemoveChain(ctx, v2req)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return resp.ToGRPCMessage().(*apemanager_grpc.RemoveChainResponse), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) ListChains(ctx context.Context, req *apemanager_grpc.ListChainsRequest) (*apemanager_grpc.ListChainsResponse, error) {
|
|
|
|
v2req := new(apemanager_v2.ListChainsRequest)
|
|
|
|
if err := v2req.FromGRPCMessage(req); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := s.srv.ListChains(ctx, v2req)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return resp.ToGRPCMessage().(*apemanager_grpc.ListChainsResponse), nil
|
|
|
|
}
|