[#140] object: Support LOCK type

Add `TypeLock` value to `Type` enum. Implement `Lock` type compatible
with corresponding message. Implement `ObjectLocked` and
`IrregularObjectLock` errors in `apistatus` package.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-02-15 08:41:03 +03:00 committed by LeL
parent 07817fb403
commit 2b28f91a89
6 changed files with 170 additions and 17 deletions

View file

@ -3,6 +3,7 @@ package apistatus
import (
"fmt"
"github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-api-go/v2/status"
)
@ -29,6 +30,10 @@ type StatusV2 interface {
//
// Common failures:
// * status.Internal: *ServerInternal.
//
// Object failures:
// * object.StatusLocked: *ObjectLocked;
// * object.StatusLockNonRegularObject: *LockNonRegularObject.
func FromStatusV2(st *status.Status) Status {
var decoder interface {
fromStatusV2(*status.Status)
@ -48,6 +53,13 @@ func FromStatusV2(st *status.Status) Status {
case status.WrongMagicNumber:
decoder = new(WrongMagicNumber)
}
case object.LocalizeFailStatus(&code):
switch code {
case object.StatusLocked:
decoder = new(ObjectLocked)
case object.StatusLockNonRegularObject:
decoder = new(LockNonRegularObject)
}
}
if decoder == nil {