forked from TrueCloudLab/frostfs-api-go
[#155] sdk/object: Add object type getter/setter
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
2fb1547cd8
commit
dbb5102c02
3 changed files with 30 additions and 0 deletions
|
@ -115,3 +115,8 @@ func (o *RawObject) SetParent(v *Object) {
|
|||
func (o *RawObject) SetSessionToken(v *token.SessionToken) {
|
||||
o.setSessionToken(v)
|
||||
}
|
||||
|
||||
// SetType sets type of the object.
|
||||
func (o *RawObject) SetType(v Type) {
|
||||
o.setType(v)
|
||||
}
|
||||
|
|
|
@ -214,3 +214,13 @@ func TestRawObject_SetSessionToken(t *testing.T) {
|
|||
|
||||
require.Equal(t, tok, obj.GetSessionToken())
|
||||
}
|
||||
|
||||
func TestRawObject_SetType(t *testing.T) {
|
||||
obj := NewRaw()
|
||||
|
||||
typ := TypeStorageGroup
|
||||
|
||||
obj.SetType(typ)
|
||||
|
||||
require.Equal(t, typ, obj.GetType())
|
||||
}
|
||||
|
|
|
@ -288,3 +288,18 @@ func (o *rwObject) setSessionToken(v *token.SessionToken) {
|
|||
h.SetSessionToken(v.ToV2())
|
||||
})
|
||||
}
|
||||
|
||||
// GetType returns type of the object.
|
||||
func (o *rwObject) GetType() Type {
|
||||
return TypeFromV2(
|
||||
(*object.Object)(o).
|
||||
GetHeader().
|
||||
GetObjectType(),
|
||||
)
|
||||
}
|
||||
|
||||
func (o *rwObject) setType(t Type) {
|
||||
o.setHeaderField(func(h *object.Header) {
|
||||
h.SetObjectType(t.ToV2())
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue