diff --git a/pkg/object/search.go b/pkg/object/search.go index d23b3df3..5d59e1a8 100644 --- a/pkg/object/search.go +++ b/pkg/object/search.go @@ -240,3 +240,8 @@ func (f *SearchFilters) AddObjectIDFilter(m SearchMatchType, id *ID) { func (f *SearchFilters) AddSplitIDFilter(m SearchMatchType, id *SplitID) { f.addReservedFilter(m, fKeySplitID, id) } + +// AddTypeFilter adds filter by object type. +func (f *SearchFilters) AddTypeFilter(m SearchMatchType, typ Type) { + f.addReservedFilter(m, fKeyType, typ) +} diff --git a/pkg/object/search_test.go b/pkg/object/search_test.go index f477f4f2..82a06d39 100644 --- a/pkg/object/search_test.go +++ b/pkg/object/search_test.go @@ -140,3 +140,20 @@ func TestSearchFilters_AddSplitIDFilter(t *testing.T) { require.Equal(t, v2object.MatchStringEqual, fsV2[0].GetMatchType()) }) } + +func TestSearchFilters_AddTypeFilter(t *testing.T) { + typ := object.TypeTombstone + + fs := new(object.SearchFilters) + fs.AddTypeFilter(object.MatchStringEqual, typ) + + t.Run("v2", func(t *testing.T) { + fsV2 := fs.ToV2() + + require.Len(t, fsV2, 1) + + require.Equal(t, v2object.FilterHeaderObjectType, fsV2[0].GetKey()) + require.Equal(t, typ.String(), fsV2[0].GetValue()) + require.Equal(t, v2object.MatchStringEqual, fsV2[0].GetMatchType()) + }) +}