2020-09-30 10:52:14 +00:00
|
|
|
package deletesvc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
objectV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object"
|
|
|
|
deletesvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/delete"
|
2020-09-30 10:52:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Service implements Delete operation of Object service v2.
|
|
|
|
type Service struct {
|
|
|
|
svc *deletesvc.Service
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewService constructs Service instance from provided options.
|
2023-07-06 08:53:18 +00:00
|
|
|
func NewService(svc *deletesvc.Service) *Service {
|
2020-09-30 10:52:14 +00:00
|
|
|
return &Service{
|
2023-07-06 08:53:18 +00:00
|
|
|
svc: svc,
|
2020-09-30 10:52:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete calls internal service.
|
|
|
|
func (s *Service) Delete(ctx context.Context, req *objectV2.DeleteRequest) (*objectV2.DeleteResponse, error) {
|
2020-12-11 08:04:04 +00:00
|
|
|
resp := new(objectV2.DeleteResponse)
|
|
|
|
|
|
|
|
body := new(objectV2.DeleteResponseBody)
|
|
|
|
resp.SetBody(body)
|
|
|
|
|
|
|
|
p, err := s.toPrm(req, body)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = s.svc.Delete(ctx, *p)
|
2020-09-30 10:52:14 +00:00
|
|
|
if err != nil {
|
2020-12-11 08:04:04 +00:00
|
|
|
return nil, err
|
2020-09-30 10:52:14 +00:00
|
|
|
}
|
|
|
|
|
2020-12-11 08:04:04 +00:00
|
|
|
return resp, nil
|
2020-09-30 10:52:14 +00:00
|
|
|
}
|