forked from TrueCloudLab/frostfs-sdk-go
[#271] object: Add UserAttributes
method
Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
parent
6009d089fc
commit
6821fe6fb2
2 changed files with 48 additions and 0 deletions
|
@ -3,7 +3,10 @@ package object
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/container"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"
|
||||
v2session "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session"
|
||||
|
@ -312,6 +315,26 @@ func (o *Object) Attributes() []Attribute {
|
|||
return res
|
||||
}
|
||||
|
||||
// UserAttributes returns object user attributes.
|
||||
func (o *Object) UserAttributes() []Attribute {
|
||||
attrs := (*object.Object)(o).
|
||||
GetHeader().
|
||||
GetAttributes()
|
||||
|
||||
res := make([]Attribute, 0, len(attrs))
|
||||
|
||||
for _, attr := range attrs {
|
||||
key := attr.GetKey()
|
||||
|
||||
if !strings.HasPrefix(key, container.SysAttributePrefix) &&
|
||||
!strings.HasPrefix(key, container.SysAttributePrefixNeoFS) {
|
||||
res = append(res, *NewAttributeFromV2(&attr))
|
||||
}
|
||||
}
|
||||
|
||||
return slices.Clip(res)
|
||||
}
|
||||
|
||||
// SetAttributes sets object attributes.
|
||||
func (o *Object) SetAttributes(v ...Attribute) {
|
||||
attrs := make([]object.Attribute, len(v))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue