diff --git a/pkg/object/search.go b/pkg/object/search.go index b9383e2f..6c596d62 100644 --- a/pkg/object/search.go +++ b/pkg/object/search.go @@ -242,3 +242,8 @@ func (f *SearchFilters) AddNonChildfreeFilter() { func (f *SearchFilters) AddParentIDFilter(m SearchMatchType, id *ID) { f.addReservedFilter(m, fKeyParent, id) } + +// AddObjectIDFilter adds filter by object identifier. +func (f *SearchFilters) AddObjectIDFilter(m SearchMatchType, id *ID) { + f.addReservedFilter(m, fKeyObjectID, id) +} diff --git a/pkg/object/search_test.go b/pkg/object/search_test.go index ca28f1fe..b3407cc8 100644 --- a/pkg/object/search_test.go +++ b/pkg/object/search_test.go @@ -106,3 +106,20 @@ func TestSearchFilters_AddParentIDFilter(t *testing.T) { require.Equal(t, par.String(), fsV2[0].GetValue()) require.Equal(t, v2object.MatchStringEqual, fsV2[0].GetMatchType()) } + +func TestSearchFilters_AddObjectIDFilter(t *testing.T) { + id := testOID() + + fs := new(object.SearchFilters) + fs.AddObjectIDFilter(object.MatchStringEqual, id) + + t.Run("v2", func(t *testing.T) { + fsV2 := fs.ToV2() + + require.Len(t, fsV2, 1) + + require.Equal(t, v2object.FilterHeaderObjectID, fsV2[0].GetKey()) + require.Equal(t, id.String(), fsV2[0].GetValue()) + require.Equal(t, v2object.MatchStringEqual, fsV2[0].GetMatchType()) + }) +}