[#197] sdk/object: Rename getters of Attribute and Object types
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
67bcf6eb4d
commit
5f5e5ac5dd
7 changed files with 82 additions and 82 deletions
|
@ -180,8 +180,8 @@ func (c *Client) putObjectV2(ctx context.Context, p *PutObjectParams, opts ...Ca
|
|||
req.SetBody(body)
|
||||
|
||||
v2Addr := new(v2refs.Address)
|
||||
v2Addr.SetObjectID(p.obj.GetID().ToV2())
|
||||
v2Addr.SetContainerID(p.obj.GetContainerID().ToV2())
|
||||
v2Addr.SetObjectID(p.obj.ID().ToV2())
|
||||
v2Addr.SetContainerID(p.obj.ContainerID().ToV2())
|
||||
|
||||
// set meta header
|
||||
meta := v2MetaHeaderFromOpts(callOpts)
|
||||
|
|
|
@ -19,8 +19,8 @@ func NewAttribute() *Attribute {
|
|||
return NewAttributeFromV2(new(object.Attribute))
|
||||
}
|
||||
|
||||
// GetKey returns key to the object attribute.
|
||||
func (a *Attribute) GetKey() string {
|
||||
// Key returns key to the object attribute.
|
||||
func (a *Attribute) Key() string {
|
||||
return (*object.Attribute)(a).GetKey()
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,8 @@ func (a *Attribute) SetKey(v string) {
|
|||
(*object.Attribute)(a).SetKey(v)
|
||||
}
|
||||
|
||||
// GetValue return value of the object attribute.
|
||||
func (a *Attribute) GetValue() string {
|
||||
// Value return value of the object attribute.
|
||||
func (a *Attribute) Value() string {
|
||||
return (*object.Attribute)(a).GetValue()
|
||||
}
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ func TestAttribute(t *testing.T) {
|
|||
a.SetKey(key)
|
||||
a.SetValue(val)
|
||||
|
||||
require.Equal(t, key, a.GetKey())
|
||||
require.Equal(t, val, a.GetValue())
|
||||
require.Equal(t, key, a.Key())
|
||||
require.Equal(t, val, a.Value())
|
||||
|
||||
aV2 := a.ToV2()
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ func CalculatePayloadChecksum(payload []byte) *pkg.Checksum {
|
|||
// object payload and writes it to the object.
|
||||
func CalculateAndSetPayloadChecksum(obj *RawObject) {
|
||||
obj.SetPayloadChecksum(
|
||||
CalculatePayloadChecksum(obj.GetPayload()),
|
||||
CalculatePayloadChecksum(obj.Payload()),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,8 @@ func CalculateAndSetPayloadChecksum(obj *RawObject) {
|
|||
// corresponds to its payload.
|
||||
func VerifyPayloadChecksum(obj *Object) error {
|
||||
if !pkg.EqualChecksums(
|
||||
obj.GetPayloadChecksum(),
|
||||
CalculatePayloadChecksum(obj.GetPayload()),
|
||||
obj.PayloadChecksum(),
|
||||
CalculatePayloadChecksum(obj.Payload()),
|
||||
) {
|
||||
return errors.New("payload checksum mismatch")
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ func VerifyID(obj *Object) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if !id.Equal(obj.GetID()) {
|
||||
if !id.Equal(obj.ID()) {
|
||||
return errors.New("incorrect object identifier")
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ func CalculateIDSignature(key *ecdsa.PrivateKey, id *ID) (*pkg.Signature, error)
|
|||
}
|
||||
|
||||
func CalculateAndSetSignature(key *ecdsa.PrivateKey, obj *RawObject) error {
|
||||
sig, err := CalculateIDSignature(key, obj.GetID())
|
||||
sig, err := CalculateIDSignature(key, obj.ID())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -114,10 +114,10 @@ func CalculateAndSetSignature(key *ecdsa.PrivateKey, obj *RawObject) error {
|
|||
func VerifyIDSignature(obj *Object) error {
|
||||
return signature.VerifyDataWithSource(
|
||||
signatureV2.StableMarshalerWrapper{
|
||||
SM: obj.GetID().ToV2(),
|
||||
SM: obj.ID().ToV2(),
|
||||
},
|
||||
func() ([]byte, []byte) {
|
||||
sig := obj.GetSignature()
|
||||
sig := obj.Signature()
|
||||
|
||||
return sig.Key(), sig.Sign()
|
||||
},
|
||||
|
|
|
@ -35,34 +35,34 @@ func TestVerificationFields(t *testing.T) {
|
|||
},
|
||||
{
|
||||
corrupt: func() {
|
||||
obj.SetPayloadSize(obj.GetPayloadSize() + 1)
|
||||
obj.SetPayloadSize(obj.PayloadSize() + 1)
|
||||
},
|
||||
restore: func() {
|
||||
obj.SetPayloadSize(obj.GetPayloadSize() - 1)
|
||||
obj.SetPayloadSize(obj.PayloadSize() - 1)
|
||||
},
|
||||
},
|
||||
{
|
||||
corrupt: func() {
|
||||
obj.GetID().ToV2().GetValue()[0]++
|
||||
obj.ID().ToV2().GetValue()[0]++
|
||||
},
|
||||
restore: func() {
|
||||
obj.GetID().ToV2().GetValue()[0]--
|
||||
obj.ID().ToV2().GetValue()[0]--
|
||||
},
|
||||
},
|
||||
{
|
||||
corrupt: func() {
|
||||
obj.GetSignature().Key()[0]++
|
||||
obj.Signature().Key()[0]++
|
||||
},
|
||||
restore: func() {
|
||||
obj.GetSignature().Key()[0]--
|
||||
obj.Signature().Key()[0]--
|
||||
},
|
||||
},
|
||||
{
|
||||
corrupt: func() {
|
||||
obj.GetSignature().Sign()[0]++
|
||||
obj.Signature().Sign()[0]++
|
||||
},
|
||||
restore: func() {
|
||||
obj.GetSignature().Sign()[0]--
|
||||
obj.Signature().Sign()[0]--
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ func TestRawObject_SetID(t *testing.T) {
|
|||
|
||||
obj.SetID(id)
|
||||
|
||||
require.Equal(t, id, obj.GetID())
|
||||
require.Equal(t, id, obj.ID())
|
||||
}
|
||||
|
||||
func TestRawObject_SetSignature(t *testing.T) {
|
||||
|
@ -60,7 +60,7 @@ func TestRawObject_SetSignature(t *testing.T) {
|
|||
|
||||
obj.SetSignature(sig)
|
||||
|
||||
require.Equal(t, sig, obj.GetSignature())
|
||||
require.Equal(t, sig, obj.Signature())
|
||||
}
|
||||
|
||||
func TestRawObject_SetPayload(t *testing.T) {
|
||||
|
@ -71,7 +71,7 @@ func TestRawObject_SetPayload(t *testing.T) {
|
|||
|
||||
obj.SetPayload(payload)
|
||||
|
||||
require.Equal(t, payload, obj.GetPayload())
|
||||
require.Equal(t, payload, obj.Payload())
|
||||
}
|
||||
|
||||
func TestRawObject_SetVersion(t *testing.T) {
|
||||
|
@ -83,7 +83,7 @@ func TestRawObject_SetVersion(t *testing.T) {
|
|||
|
||||
obj.SetVersion(ver)
|
||||
|
||||
require.Equal(t, ver, obj.GetVersion())
|
||||
require.Equal(t, ver, obj.Version())
|
||||
}
|
||||
|
||||
func TestRawObject_SetPayloadSize(t *testing.T) {
|
||||
|
@ -92,7 +92,7 @@ func TestRawObject_SetPayloadSize(t *testing.T) {
|
|||
sz := uint64(133)
|
||||
obj.SetPayloadSize(sz)
|
||||
|
||||
require.Equal(t, sz, obj.GetPayloadSize())
|
||||
require.Equal(t, sz, obj.PayloadSize())
|
||||
}
|
||||
|
||||
func TestRawObject_SetContainerID(t *testing.T) {
|
||||
|
@ -105,7 +105,7 @@ func TestRawObject_SetContainerID(t *testing.T) {
|
|||
|
||||
obj.SetContainerID(cid)
|
||||
|
||||
require.Equal(t, cid, obj.GetContainerID())
|
||||
require.Equal(t, cid, obj.ContainerID())
|
||||
}
|
||||
|
||||
func TestRawObject_SetOwnerID(t *testing.T) {
|
||||
|
@ -119,7 +119,7 @@ func TestRawObject_SetOwnerID(t *testing.T) {
|
|||
|
||||
obj.SetOwnerID(ownerID)
|
||||
|
||||
require.Equal(t, ownerID, obj.GetOwnerID())
|
||||
require.Equal(t, ownerID, obj.OwnerID())
|
||||
}
|
||||
|
||||
func TestRawObject_SetCreationEpoch(t *testing.T) {
|
||||
|
@ -128,7 +128,7 @@ func TestRawObject_SetCreationEpoch(t *testing.T) {
|
|||
creat := uint64(228)
|
||||
obj.setCreationEpoch(creat)
|
||||
|
||||
require.Equal(t, creat, obj.GetCreationEpoch())
|
||||
require.Equal(t, creat, obj.CreationEpoch())
|
||||
}
|
||||
|
||||
func TestRawObject_SetPayloadChecksum(t *testing.T) {
|
||||
|
@ -139,7 +139,7 @@ func TestRawObject_SetPayloadChecksum(t *testing.T) {
|
|||
|
||||
obj.SetPayloadChecksum(cs)
|
||||
|
||||
require.Equal(t, cs, obj.GetPayloadChecksum())
|
||||
require.Equal(t, cs, obj.PayloadChecksum())
|
||||
}
|
||||
|
||||
func TestRawObject_SetPayloadHomomorphicHash(t *testing.T) {
|
||||
|
@ -150,7 +150,7 @@ func TestRawObject_SetPayloadHomomorphicHash(t *testing.T) {
|
|||
|
||||
obj.SetPayloadHomomorphicHash(cs)
|
||||
|
||||
require.Equal(t, cs, obj.GetPayloadHomomorphicHash())
|
||||
require.Equal(t, cs, obj.PayloadHomomorphicHash())
|
||||
}
|
||||
|
||||
func TestRawObject_SetAttributes(t *testing.T) {
|
||||
|
@ -166,7 +166,7 @@ func TestRawObject_SetAttributes(t *testing.T) {
|
|||
|
||||
obj.SetAttributes(a1, a2)
|
||||
|
||||
require.Equal(t, []*Attribute{a1, a2}, obj.GetAttributes())
|
||||
require.Equal(t, []*Attribute{a1, a2}, obj.Attributes())
|
||||
}
|
||||
|
||||
func TestRawObject_SetPreviousID(t *testing.T) {
|
||||
|
@ -176,7 +176,7 @@ func TestRawObject_SetPreviousID(t *testing.T) {
|
|||
|
||||
obj.SetPreviousID(prev)
|
||||
|
||||
require.Equal(t, prev, obj.GetPreviousID())
|
||||
require.Equal(t, prev, obj.PreviousID())
|
||||
}
|
||||
|
||||
func TestRawObject_SetChildren(t *testing.T) {
|
||||
|
@ -187,13 +187,13 @@ func TestRawObject_SetChildren(t *testing.T) {
|
|||
|
||||
obj.SetChildren(id1, id2)
|
||||
|
||||
require.Equal(t, []*ID{id1, id2}, obj.GetChildren())
|
||||
require.Equal(t, []*ID{id1, id2}, obj.Children())
|
||||
}
|
||||
|
||||
func TestRawObject_SetParent(t *testing.T) {
|
||||
obj := NewRaw()
|
||||
|
||||
require.Nil(t, obj.GetParent())
|
||||
require.Nil(t, obj.Parent())
|
||||
|
||||
par := NewRaw()
|
||||
par.SetID(randID(t))
|
||||
|
@ -204,7 +204,7 @@ func TestRawObject_SetParent(t *testing.T) {
|
|||
|
||||
obj.SetParent(parObj)
|
||||
|
||||
require.Equal(t, parObj, obj.GetParent())
|
||||
require.Equal(t, parObj, obj.Parent())
|
||||
}
|
||||
|
||||
func TestRawObject_ToV2(t *testing.T) {
|
||||
|
@ -224,7 +224,7 @@ func TestRawObject_SetSessionToken(t *testing.T) {
|
|||
|
||||
obj.SetSessionToken(tok)
|
||||
|
||||
require.Equal(t, tok, obj.GetSessionToken())
|
||||
require.Equal(t, tok, obj.SessionToken())
|
||||
}
|
||||
|
||||
func TestRawObject_SetType(t *testing.T) {
|
||||
|
@ -234,7 +234,7 @@ func TestRawObject_SetType(t *testing.T) {
|
|||
|
||||
obj.SetType(typ)
|
||||
|
||||
require.Equal(t, typ, obj.GetType())
|
||||
require.Equal(t, typ, obj.Type())
|
||||
}
|
||||
|
||||
func TestRawObject_CutPayload(t *testing.T) {
|
||||
|
@ -248,20 +248,20 @@ func TestRawObject_CutPayload(t *testing.T) {
|
|||
|
||||
o2 := o1.CutPayload()
|
||||
|
||||
require.Equal(t, sz, o2.GetPayloadSize())
|
||||
require.Empty(t, o2.GetPayload())
|
||||
require.Equal(t, sz, o2.PayloadSize())
|
||||
require.Empty(t, o2.Payload())
|
||||
|
||||
sz++
|
||||
o1.SetPayloadSize(sz)
|
||||
|
||||
require.Equal(t, sz, o1.GetPayloadSize())
|
||||
require.Equal(t, sz, o2.GetPayloadSize())
|
||||
require.Equal(t, sz, o1.PayloadSize())
|
||||
require.Equal(t, sz, o2.PayloadSize())
|
||||
|
||||
p2 := []byte{4, 5, 6}
|
||||
o2.SetPayload(p2)
|
||||
|
||||
require.Equal(t, p2, o2.GetPayload())
|
||||
require.Equal(t, p1, o1.GetPayload())
|
||||
require.Equal(t, p2, o2.Payload())
|
||||
require.Equal(t, p1, o1.Payload())
|
||||
}
|
||||
|
||||
func TestRawObject_SetParentID(t *testing.T) {
|
||||
|
@ -270,7 +270,7 @@ func TestRawObject_SetParentID(t *testing.T) {
|
|||
id := randID(t)
|
||||
obj.setParentID(id)
|
||||
|
||||
require.Equal(t, id, obj.GetParentID())
|
||||
require.Equal(t, id, obj.ParentID())
|
||||
}
|
||||
|
||||
func TestRawObject_ResetRelations(t *testing.T) {
|
||||
|
@ -280,7 +280,7 @@ func TestRawObject_ResetRelations(t *testing.T) {
|
|||
|
||||
obj.ResetRelations()
|
||||
|
||||
require.Nil(t, obj.GetPreviousID())
|
||||
require.Nil(t, obj.PreviousID())
|
||||
}
|
||||
|
||||
func TestRwObject_HasParent(t *testing.T) {
|
||||
|
|
|
@ -42,8 +42,8 @@ func (o *rwObject) setSplitFields(setter func(*object.SplitHeader)) {
|
|||
})
|
||||
}
|
||||
|
||||
// GetID returns object identifier.
|
||||
func (o *rwObject) GetID() *ID {
|
||||
// ID returns object identifier.
|
||||
func (o *rwObject) ID() *ID {
|
||||
return NewIDFromV2(
|
||||
(*object.Object)(o).
|
||||
GetObjectID(),
|
||||
|
@ -55,8 +55,8 @@ func (o *rwObject) setID(v *ID) {
|
|||
SetObjectID(v.ToV2())
|
||||
}
|
||||
|
||||
// GetSignature returns signature of the object identifier.
|
||||
func (o *rwObject) GetSignature() *pkg.Signature {
|
||||
// Signature returns signature of the object identifier.
|
||||
func (o *rwObject) Signature() *pkg.Signature {
|
||||
return pkg.NewSignatureFromV2(
|
||||
(*object.Object)(o).
|
||||
GetSignature(),
|
||||
|
@ -68,8 +68,8 @@ func (o *rwObject) setSignature(v *pkg.Signature) {
|
|||
SetSignature(v.ToV2())
|
||||
}
|
||||
|
||||
// GetPayload returns payload bytes.
|
||||
func (o *rwObject) GetPayload() []byte {
|
||||
// Payload returns payload bytes.
|
||||
func (o *rwObject) Payload() []byte {
|
||||
return (*object.Object)(o).
|
||||
GetPayload()
|
||||
}
|
||||
|
@ -79,8 +79,8 @@ func (o *rwObject) setPayload(v []byte) {
|
|||
SetPayload(v)
|
||||
}
|
||||
|
||||
// GetVersion returns version of the object.
|
||||
func (o *rwObject) GetVersion() *pkg.Version {
|
||||
// Version returns version of the object.
|
||||
func (o *rwObject) Version() *pkg.Version {
|
||||
return pkg.NewVersionFromV2(
|
||||
(*object.Object)(o).
|
||||
GetHeader().
|
||||
|
@ -94,8 +94,8 @@ func (o *rwObject) setVersion(v *pkg.Version) {
|
|||
})
|
||||
}
|
||||
|
||||
// GetPayloadSize returns payload length of the object.
|
||||
func (o *rwObject) GetPayloadSize() uint64 {
|
||||
// PayloadSize returns payload length of the object.
|
||||
func (o *rwObject) PayloadSize() uint64 {
|
||||
return (*object.Object)(o).
|
||||
GetHeader().
|
||||
GetPayloadLength()
|
||||
|
@ -107,8 +107,8 @@ func (o *rwObject) setPayloadSize(v uint64) {
|
|||
})
|
||||
}
|
||||
|
||||
// GetContainerID returns identifier of the related container.
|
||||
func (o *rwObject) GetContainerID() *container.ID {
|
||||
// ContainerID returns identifier of the related container.
|
||||
func (o *rwObject) ContainerID() *container.ID {
|
||||
return container.NewIDFromV2(
|
||||
(*object.Object)(o).
|
||||
GetHeader().
|
||||
|
@ -122,8 +122,8 @@ func (o *rwObject) setContainerID(v *container.ID) {
|
|||
})
|
||||
}
|
||||
|
||||
// GetOwnerID returns identifier of the object owner.
|
||||
func (o *rwObject) GetOwnerID() *owner.ID {
|
||||
// OwnerID returns identifier of the object owner.
|
||||
func (o *rwObject) OwnerID() *owner.ID {
|
||||
return owner.NewIDFromV2(
|
||||
(*object.Object)(o).
|
||||
GetHeader().
|
||||
|
@ -137,8 +137,8 @@ func (o *rwObject) setOwnerID(v *owner.ID) {
|
|||
})
|
||||
}
|
||||
|
||||
// GetCreationEpoch returns epoch number in which object was created.
|
||||
func (o *rwObject) GetCreationEpoch() uint64 {
|
||||
// CreationEpoch returns epoch number in which object was created.
|
||||
func (o *rwObject) CreationEpoch() uint64 {
|
||||
return (*object.Object)(o).
|
||||
GetHeader().
|
||||
GetCreationEpoch()
|
||||
|
@ -150,8 +150,8 @@ func (o *rwObject) setCreationEpoch(v uint64) {
|
|||
})
|
||||
}
|
||||
|
||||
// GetPayloadChecksum returns checksum of the object payload.
|
||||
func (o *rwObject) GetPayloadChecksum() *pkg.Checksum {
|
||||
// PayloadChecksum returns checksum of the object payload.
|
||||
func (o *rwObject) PayloadChecksum() *pkg.Checksum {
|
||||
return pkg.NewChecksumFromV2(
|
||||
(*object.Object)(o).
|
||||
GetHeader().
|
||||
|
@ -165,8 +165,8 @@ func (o *rwObject) setPayloadChecksum(v *pkg.Checksum) {
|
|||
})
|
||||
}
|
||||
|
||||
// GetPayloadHomomorphicHash returns homomorphic hash of the object payload.
|
||||
func (o *rwObject) GetPayloadHomomorphicHash() *pkg.Checksum {
|
||||
// PayloadHomomorphicHash returns homomorphic hash of the object payload.
|
||||
func (o *rwObject) PayloadHomomorphicHash() *pkg.Checksum {
|
||||
return pkg.NewChecksumFromV2(
|
||||
(*object.Object)(o).
|
||||
GetHeader().
|
||||
|
@ -180,8 +180,8 @@ func (o *rwObject) setPayloadHomomorphicHash(v *pkg.Checksum) {
|
|||
})
|
||||
}
|
||||
|
||||
// GetAttributes returns object attributes.
|
||||
func (o *rwObject) GetAttributes() []*Attribute {
|
||||
// Attributes returns object attributes.
|
||||
func (o *rwObject) Attributes() []*Attribute {
|
||||
attrs := (*object.Object)(o).
|
||||
GetHeader().
|
||||
GetAttributes()
|
||||
|
@ -207,8 +207,8 @@ func (o *rwObject) setAttributes(v ...*Attribute) {
|
|||
})
|
||||
}
|
||||
|
||||
// GetPreviousID returns identifier of the previous sibling object.
|
||||
func (o *rwObject) GetPreviousID() *ID {
|
||||
// PreviousID returns identifier of the previous sibling object.
|
||||
func (o *rwObject) PreviousID() *ID {
|
||||
return NewIDFromV2(
|
||||
(*object.Object)(o).
|
||||
GetHeader().
|
||||
|
@ -223,8 +223,8 @@ func (o *rwObject) setPreviousID(v *ID) {
|
|||
})
|
||||
}
|
||||
|
||||
// GetChildren return list of the identifiers of the child objects.
|
||||
func (o *rwObject) GetChildren() []*ID {
|
||||
// Children return list of the identifiers of the child objects.
|
||||
func (o *rwObject) Children() []*ID {
|
||||
ids := (*object.Object)(o).
|
||||
GetHeader().
|
||||
GetSplit().
|
||||
|
@ -251,8 +251,8 @@ func (o *rwObject) setChildren(v ...*ID) {
|
|||
})
|
||||
}
|
||||
|
||||
// GetParentID returns identifier of the parent object.
|
||||
func (o *rwObject) GetParentID() *ID {
|
||||
// ParentID returns identifier of the parent object.
|
||||
func (o *rwObject) ParentID() *ID {
|
||||
return NewIDFromV2(
|
||||
(*object.Object)(o).
|
||||
GetHeader().
|
||||
|
@ -267,8 +267,8 @@ func (o *rwObject) setParentID(v *ID) {
|
|||
})
|
||||
}
|
||||
|
||||
// GetParent returns parent object w/o payload.
|
||||
func (o *rwObject) GetParent() *Object {
|
||||
// Parent returns parent object w/o payload.
|
||||
func (o *rwObject) Parent() *Object {
|
||||
h := (*object.Object)(o).
|
||||
GetHeader().
|
||||
GetSplit()
|
||||
|
@ -308,9 +308,9 @@ func (o *rwObject) resetRelations() {
|
|||
})
|
||||
}
|
||||
|
||||
// GetSessionToken returns token of the session
|
||||
// SessionToken returns token of the session
|
||||
// within which object was created.
|
||||
func (o *rwObject) GetSessionToken() *token.SessionToken {
|
||||
func (o *rwObject) SessionToken() *token.SessionToken {
|
||||
return token.NewSessionTokenFromV2(
|
||||
(*object.Object)(o).
|
||||
GetHeader().
|
||||
|
@ -324,8 +324,8 @@ func (o *rwObject) setSessionToken(v *token.SessionToken) {
|
|||
})
|
||||
}
|
||||
|
||||
// GetType returns type of the object.
|
||||
func (o *rwObject) GetType() Type {
|
||||
// Type returns type of the object.
|
||||
func (o *rwObject) Type() Type {
|
||||
return TypeFromV2(
|
||||
(*object.Object)(o).
|
||||
GetHeader().
|
||||
|
|
Loading…
Reference in a new issue