2020-07-10 14:17:51 +00:00
|
|
|
package container
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/container"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"google.golang.org/grpc/codes"
|
|
|
|
"google.golang.org/grpc/status"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s cnrService) Delete(ctx context.Context, req *container.DeleteRequest) (*container.DeleteResponse, error) {
|
|
|
|
// check healthiness
|
|
|
|
if err := s.healthy.Healthy(); err != nil {
|
|
|
|
return nil, errors.Wrap(err, "try again later")
|
|
|
|
}
|
|
|
|
|
|
|
|
// verify request structure
|
|
|
|
if err := requestVerifyFunc(req); err != nil {
|
|
|
|
return nil, status.Error(codes.InvalidArgument, err.Error())
|
|
|
|
}
|
|
|
|
|
2020-07-24 13:54:03 +00:00
|
|
|
// remove container from storage
|
|
|
|
if err := s.cnrStore.Delete(req.GetCID()); err != nil {
|
2020-07-10 14:17:51 +00:00
|
|
|
return nil, status.Error(
|
|
|
|
codes.Aborted,
|
2020-07-24 13:54:03 +00:00
|
|
|
errors.Wrap(err, "could not remove container from storage").Error(),
|
2020-07-10 14:17:51 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
return new(container.DeleteResponse), nil
|
|
|
|
}
|