[#544] layer: Add session token parameter to DeleteBucketParams
Add `DeleteBucketParams.SessionToken` field in order to unify the parameters with `CreateBucketParams` and `PutBucketACLParams`. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
4fe833164e
commit
f596c8be06
3 changed files with 16 additions and 10 deletions
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-s3-gw/api/layer"
|
"github.com/nspcc-dev/neofs-s3-gw/api/layer"
|
||||||
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
||||||
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||||
|
"github.com/nspcc-dev/neofs-sdk-go/session"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
)
|
)
|
||||||
|
@ -271,7 +272,17 @@ func (h *handler) DeleteBucketHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = h.obj.DeleteBucket(r.Context(), &layer.DeleteBucketParams{BktInfo: bktInfo}); err != nil {
|
var sessionToken *session.Container
|
||||||
|
|
||||||
|
boxData, err := layer.GetBoxData(r.Context())
|
||||||
|
if err == nil {
|
||||||
|
sessionToken = boxData.Gate.SessionTokenForDelete()
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = h.obj.DeleteBucket(r.Context(), &layer.DeleteBucketParams{
|
||||||
|
BktInfo: bktInfo,
|
||||||
|
SessionToken: sessionToken,
|
||||||
|
}); err != nil {
|
||||||
h.logAndSendError(w, "couldn't delete bucket", reqInfo, err)
|
h.logAndSendError(w, "couldn't delete bucket", reqInfo, err)
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusNoContent)
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
|
|
@ -180,12 +180,6 @@ func (n *layer) GetContainerEACL(ctx context.Context, idCnr cid.ID) (*eacl.Table
|
||||||
return n.neoFS.ContainerEACL(ctx, idCnr)
|
return n.neoFS.ContainerEACL(ctx, idCnr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *layer) deleteContainer(ctx context.Context, idCnr cid.ID) error {
|
func (n *layer) deleteContainer(ctx context.Context, idCnr cid.ID, sessionToken *session.Container) error {
|
||||||
var sessionToken *session.Container
|
|
||||||
boxData, err := GetBoxData(ctx)
|
|
||||||
if err == nil {
|
|
||||||
sessionToken = boxData.Gate.SessionTokenForDelete()
|
|
||||||
}
|
|
||||||
|
|
||||||
return n.neoFS.DeleteContainer(ctx, idCnr, sessionToken)
|
return n.neoFS.DeleteContainer(ctx, idCnr, sessionToken)
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,8 @@ type (
|
||||||
}
|
}
|
||||||
// DeleteBucketParams stores delete bucket request parameters.
|
// DeleteBucketParams stores delete bucket request parameters.
|
||||||
DeleteBucketParams struct {
|
DeleteBucketParams struct {
|
||||||
BktInfo *data.BucketInfo
|
BktInfo *data.BucketInfo
|
||||||
|
SessionToken *session.Container
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutSystemObjectParams stores putSystemObject parameters.
|
// PutSystemObjectParams stores putSystemObject parameters.
|
||||||
|
@ -658,5 +659,5 @@ func (n *layer) DeleteBucket(ctx context.Context, p *DeleteBucketParams) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
n.bucketCache.Delete(p.BktInfo.Name)
|
n.bucketCache.Delete(p.BktInfo.Name)
|
||||||
return n.deleteContainer(ctx, p.BktInfo.CID)
|
return n.deleteContainer(ctx, p.BktInfo.CID, p.SessionToken)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue