forked from TrueCloudLab/frostfs-s3-gw
[#196] Add DeleteObjectTagging
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
4a2575fbf3
commit
16da1aba64
6 changed files with 53 additions and 8 deletions
|
@ -47,7 +47,7 @@ func (h *handler) HeadObjectHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
h.logAndSendError(w, "could not fetch object info", reqInfo, err)
|
h.logAndSendError(w, "could not fetch object info", reqInfo, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tagSet, err := h.obj.GetObjectTagging(r.Context(), inf)
|
tagSet, err := h.obj.GetObjectTagging(r.Context(), info)
|
||||||
if err != nil && !errors.IsS3Error(err, errors.ErrNoSuchKey) {
|
if err != nil && !errors.IsS3Error(err, errors.ErrNoSuchKey) {
|
||||||
h.logAndSendError(w, "could not get object tag set", reqInfo, err)
|
h.logAndSendError(w, "could not get object tag set", reqInfo, err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -106,6 +106,28 @@ func checkTagSet(tagSet []Tag) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *handler) DeleteObjectTaggingHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
reqInfo := api.GetReqInfo(r.Context())
|
||||||
|
|
||||||
|
p := &layer.HeadObjectParams{
|
||||||
|
Bucket: reqInfo.BucketName,
|
||||||
|
Object: reqInfo.ObjectName,
|
||||||
|
VersionID: reqInfo.URL.Query().Get("versionId"),
|
||||||
|
}
|
||||||
|
|
||||||
|
objInfo, err := h.obj.GetObjectInfo(r.Context(), p)
|
||||||
|
if err != nil {
|
||||||
|
h.logAndSendError(w, "could not get object info", reqInfo, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = h.obj.DeleteObjectTagging(r.Context(), objInfo); err != nil {
|
||||||
|
h.logAndSendError(w, "could not delete object tagging", reqInfo, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
}
|
||||||
|
|
||||||
func checkTag(tag Tag) error {
|
func checkTag(tag Tag) error {
|
||||||
if len(tag.Key) < 1 || len(tag.Key) > keyTagMaxLength {
|
if len(tag.Key) < 1 || len(tag.Key) > keyTagMaxLength {
|
||||||
return errors.GetAPIError(errors.ErrInvalidTag)
|
return errors.GetAPIError(errors.ErrInvalidTag)
|
||||||
|
|
|
@ -31,10 +31,6 @@ func (h *handler) AbortMultipartUploadHandler(w http.ResponseWriter, r *http.Req
|
||||||
h.logAndSendError(w, "not implemented", api.GetReqInfo(r.Context()), errors.GetAPIError(errors.ErrNotImplemented))
|
h.logAndSendError(w, "not implemented", api.GetReqInfo(r.Context()), errors.GetAPIError(errors.ErrNotImplemented))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *handler) DeleteObjectTaggingHandler(w http.ResponseWriter, r *http.Request) {
|
|
||||||
h.logAndSendError(w, "not implemented", api.GetReqInfo(r.Context()), errors.GetAPIError(errors.ErrNotImplemented))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *handler) SelectObjectContentHandler(w http.ResponseWriter, r *http.Request) {
|
func (h *handler) SelectObjectContentHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
h.logAndSendError(w, "not implemented", api.GetReqInfo(r.Context()), errors.GetAPIError(errors.ErrNotImplemented))
|
h.logAndSendError(w, "not implemented", api.GetReqInfo(r.Context()), errors.GetAPIError(errors.ErrNotImplemented))
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
"github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
||||||
|
@ -174,6 +175,7 @@ type (
|
||||||
ListObjectVersions(ctx context.Context, p *ListObjectVersionsParams) (*ListObjectVersionsInfo, error)
|
ListObjectVersions(ctx context.Context, p *ListObjectVersionsParams) (*ListObjectVersionsInfo, error)
|
||||||
|
|
||||||
DeleteObjects(ctx context.Context, bucket string, objects []*VersionedObject) []error
|
DeleteObjects(ctx context.Context, bucket string, objects []*VersionedObject) []error
|
||||||
|
DeleteObjectTagging(ctx context.Context, p *ObjectInfo) error
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -374,7 +376,7 @@ func (n *layer) PutObject(ctx context.Context, p *PutObjectParams) (*ObjectInfo,
|
||||||
|
|
||||||
// GetObjectTagging from storage.
|
// GetObjectTagging from storage.
|
||||||
func (n *layer) GetObjectTagging(ctx context.Context, oi *ObjectInfo) (map[string]string, error) {
|
func (n *layer) GetObjectTagging(ctx context.Context, oi *ObjectInfo) (map[string]string, error) {
|
||||||
bktInfo := &BucketInfo{
|
bktInfo := &cache.BucketInfo{
|
||||||
Name: oi.Bucket,
|
Name: oi.Bucket,
|
||||||
CID: oi.CID(),
|
CID: oi.CID(),
|
||||||
Owner: oi.Owner,
|
Owner: oi.Owner,
|
||||||
|
@ -413,6 +415,19 @@ func (n *layer) PutObjectTagging(ctx context.Context, p *PutTaggingParams) error
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeleteObjectTagging from storage.
|
||||||
|
func (n *layer) DeleteObjectTagging(ctx context.Context, p *ObjectInfo) error {
|
||||||
|
oid, err := n.objectFindID(ctx, &findParams{cid: p.CID(), attr: objectSystemAttributeName, val: p.TagsObject()})
|
||||||
|
if err != nil {
|
||||||
|
if errors.IsS3Error(err, errors.ErrNoSuchKey) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return n.objectDelete(ctx, p.CID(), oid)
|
||||||
|
}
|
||||||
|
|
||||||
func (n *layer) putSystemObject(ctx context.Context, bktInfo *cache.BucketInfo, objName string, metadata map[string]string, prefix string) (*object.ID, error) {
|
func (n *layer) putSystemObject(ctx context.Context, bktInfo *cache.BucketInfo, objName string, metadata map[string]string, prefix string) (*object.ID, error) {
|
||||||
oldOID, err := n.objectFindID(ctx, &findParams{cid: bktInfo.CID, attr: objectSystemAttributeName, val: objName})
|
oldOID, err := n.objectFindID(ctx, &findParams{cid: bktInfo.CID, attr: objectSystemAttributeName, val: objName})
|
||||||
if err != nil && !errors.IsS3Error(err, errors.ErrNoSuchKey) {
|
if err != nil && !errors.IsS3Error(err, errors.ErrNoSuchKey) {
|
||||||
|
@ -465,7 +480,7 @@ func (n *layer) putSystemObject(ctx context.Context, bktInfo *cache.BucketInfo,
|
||||||
return oid, nil
|
return oid, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *layer) getSystemObject(ctx context.Context, bkt *BucketInfo, objName string) (*ObjectInfo, error) {
|
func (n *layer) getSystemObject(ctx context.Context, bkt *cache.BucketInfo, objName string) (*ObjectInfo, error) {
|
||||||
oid, err := n.objectFindID(ctx, &findParams{cid: bkt.CID, attr: objectSystemAttributeName, val: objName})
|
oid, err := n.objectFindID(ctx, &findParams{cid: bkt.CID, attr: objectSystemAttributeName, val: objName})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -546,6 +561,9 @@ func (n *layer) deleteObject(ctx context.Context, bkt *cache.BucketInfo, obj *Ve
|
||||||
if err = n.objectDelete(ctx, bkt.CID, id); err != nil {
|
if err = n.objectDelete(ctx, bkt.CID, id); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err = n.DeleteObjectTagging(ctx, &ObjectInfo{id: id, bucketID: bkt.CID, Name: obj.Name}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -112,6 +112,15 @@ func (v *objectVersions) getDelHeader() string {
|
||||||
return strings.Join(v.delList, ",")
|
return strings.Join(v.delList, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (v *objectVersions) getVersion(oid *object.ID) *ObjectInfo {
|
||||||
|
for _, version := range v.objects {
|
||||||
|
if version.ID() == oid {
|
||||||
|
return version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (n *layer) PutBucketVersioning(ctx context.Context, p *PutVersioningParams) (*ObjectInfo, error) {
|
func (n *layer) PutBucketVersioning(ctx context.Context, p *PutVersioningParams) (*ObjectInfo, error) {
|
||||||
bucketInfo, err := n.GetBucketInfo(ctx, p.Bucket)
|
bucketInfo, err := n.GetBucketInfo(ctx, p.Bucket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -68,7 +68,7 @@ Should be supported soon.
|
||||||
|
|
||||||
| | Method | Comments |
|
| | Method | Comments |
|
||||||
|----|---------------------|----------|
|
|----|---------------------|----------|
|
||||||
| 🔴 | DeleteObjectTagging | |
|
| 🟢 | DeleteObjectTagging | |
|
||||||
| 🟢 | GetObjectTagging | |
|
| 🟢 | GetObjectTagging | |
|
||||||
| 🟢 | PutObjectTagging | |
|
| 🟢 | PutObjectTagging | |
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue