From 656ef9d6aeb9e0a7d1b753fad7e59fb4706c1ca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Wed, 27 Apr 2022 09:50:53 +0200 Subject: [PATCH] Add a IndexSpace method to the search provider IndexSpace recursively traverses a given space and (re-)index all files it finds. --- extensions/search/pkg/search/index/index.go | 3 - .../search/pkg/search/index/index_test.go | 2 - .../search/pkg/search/mocks/ProviderClient.go | 23 ++ .../pkg/search/provider/searchprovider.go | 92 ++++++- .../search/provider/searchprovider_test.go | 53 +++- extensions/search/pkg/search/search.go | 3 + extensions/search/pkg/service/v0/service.go | 7 +- extensions/webdav/pkg/service/v0/search.go | 16 ++ .../gen/ocis/services/search/v0/search.pb.go | 242 ++++++++++++++---- .../services/search/v0/search.pb.micro.go | 31 +++ .../ocis/services/search/v0/search.pb.web.go | 95 +++++++ .../services/search/v0/search.swagger.json | 46 ++++ .../ocis/services/search/v0/search.proto | 16 +- 13 files changed, 545 insertions(+), 84 deletions(-) diff --git a/extensions/search/pkg/search/index/index.go b/extensions/search/pkg/search/index/index.go index a7752b383e..ed4b88dfa2 100644 --- a/extensions/search/pkg/search/index/index.go +++ b/extensions/search/pkg/search/index/index.go @@ -39,7 +39,6 @@ type indexDocument struct { ID string Name string - Etag string Size uint64 Mtime string MimeType string @@ -123,7 +122,6 @@ func toEntity(ref *sprovider.Reference, ri *sprovider.ResourceInfo) *indexDocume Path: ref.Path, ID: idToBleveId(ri.Id), Name: ri.Path, - Etag: ri.Etag, Size: ri.Size, MimeType: ri.MimeType, } @@ -154,7 +152,6 @@ func fromFields(fields map[string]interface{}) (*searchmsg.Match, error) { }, Name: fields["Name"].(string), Size: uint64(fields["Size"].(float64)), - Etag: fields["Etag"].(string), MimeType: fields["MimeType"].(string), }, } diff --git a/extensions/search/pkg/search/index/index_test.go b/extensions/search/pkg/search/index/index_test.go index 34c0957d0a..bde7dffef4 100644 --- a/extensions/search/pkg/search/index/index_test.go +++ b/extensions/search/pkg/search/index/index_test.go @@ -46,7 +46,6 @@ var _ = Describe("Index", func() { }, Path: "foo.pdf", Size: 12345, - Etag: "abcde", MimeType: "application/pdf", Mtime: &typesv1beta1.Timestamp{Seconds: 4000}, } @@ -124,7 +123,6 @@ var _ = Describe("Index", func() { Expect(match.Entity.Id.OpaqueId).To(Equal(ri.Id.OpaqueId)) Expect(match.Entity.Name).To(Equal(ri.Path)) Expect(match.Entity.Size).To(Equal(ri.Size)) - Expect(match.Entity.Etag).To(Equal(ri.Etag)) Expect(match.Entity.MimeType).To(Equal(ri.MimeType)) Expect(uint64(match.Entity.LastModifiedTime.AsTime().Unix())).To(Equal(ri.Mtime.Seconds)) }) diff --git a/extensions/search/pkg/search/mocks/ProviderClient.go b/extensions/search/pkg/search/mocks/ProviderClient.go index be426b7534..d1d551909e 100644 --- a/extensions/search/pkg/search/mocks/ProviderClient.go +++ b/extensions/search/pkg/search/mocks/ProviderClient.go @@ -15,6 +15,29 @@ type ProviderClient struct { mock.Mock } +// IndexSpace provides a mock function with given fields: ctx, req +func (_m *ProviderClient) IndexSpace(ctx context.Context, req *v0.IndexSpaceRequest) (*v0.IndexSpaceResponse, error) { + ret := _m.Called(ctx, req) + + var r0 *v0.IndexSpaceResponse + if rf, ok := ret.Get(0).(func(context.Context, *v0.IndexSpaceRequest) *v0.IndexSpaceResponse); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v0.IndexSpaceResponse) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, *v0.IndexSpaceRequest) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // Search provides a mock function with given fields: ctx, req func (_m *ProviderClient) Search(ctx context.Context, req *v0.SearchRequest) (*v0.SearchResponse, error) { ret := _m.Called(ctx, req) diff --git a/extensions/search/pkg/search/provider/searchprovider.go b/extensions/search/pkg/search/provider/searchprovider.go index 4c8c6d423d..5a3658f06c 100644 --- a/extensions/search/pkg/search/provider/searchprovider.go +++ b/extensions/search/pkg/search/provider/searchprovider.go @@ -2,19 +2,23 @@ package provider import ( "context" + "fmt" + "path/filepath" "strings" gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1" user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" rpcv1beta1 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" - providerv1beta1 "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" + provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" typesv1beta1 "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" ctxpkg "github.com/cs3org/reva/v2/pkg/ctx" "github.com/cs3org/reva/v2/pkg/errtypes" "github.com/cs3org/reva/v2/pkg/events" + "github.com/cs3org/reva/v2/pkg/storage/utils/walker" "github.com/cs3org/reva/v2/pkg/utils" "github.com/owncloud/ocis/extensions/search/pkg/search" + "github.com/owncloud/ocis/ocis-pkg/log" "google.golang.org/grpc/metadata" searchmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/search/v0" @@ -22,16 +26,24 @@ import ( ) type Provider struct { + logger log.Logger gwClient gateway.GatewayAPIClient indexClient search.IndexClient machineAuthAPIKey string } -func New(gwClient gateway.GatewayAPIClient, indexClient search.IndexClient, machineAuthAPIKey string, eventsChan <-chan interface{}) *Provider { +func New(gwClient gateway.GatewayAPIClient, indexClient search.IndexClient, machineAuthAPIKey string, eventsChan <-chan interface{}, logger log.Logger) *Provider { + p := &Provider{ + gwClient: gwClient, + indexClient: indexClient, + machineAuthAPIKey: machineAuthAPIKey, + logger: logger, + } + go func() { for { ev := <-eventsChan - var ref *providerv1beta1.Reference + var ref *provider.Reference var owner *user.User switch e := ev.(type) { case events.FileUploaded: @@ -46,23 +58,29 @@ func New(gwClient gateway.GatewayAPIClient, indexClient search.IndexClient, mach // Get auth ownerCtx := ctxpkg.ContextSetUser(context.Background(), owner) - authRes, err := gwClient.Authenticate(ownerCtx, &gateway.AuthenticateRequest{ + authRes, err := p.gwClient.Authenticate(ownerCtx, &gateway.AuthenticateRequest{ Type: "machine", ClientId: "userid:" + owner.Id.OpaqueId, ClientSecret: machineAuthAPIKey, }) if err != nil || authRes.GetStatus().GetCode() != rpc.Code_CODE_OK { - // TODO: log error + p.logger.Error().Err(err).Interface("authRes", authRes).Msg("error using machine auth") } ownerCtx = metadata.AppendToOutgoingContext(ownerCtx, ctxpkg.TokenHeader, authRes.Token) // Stat changed resource resource - statRes, err := gwClient.Stat(ownerCtx, &providerv1beta1.StatRequest{Ref: ref}) + statRes, err := gwClient.Stat(ownerCtx, &provider.StatRequest{Ref: ref}) if err != nil || statRes.Status.Code != rpc.Code_CODE_OK { - // TODO: log error + p.logger.Error().Err(err).Interface("statRes", statRes).Msg("failed to stat the changed resource") + } + + err = p.indexClient.Add(ref, statRes.Info) + if err != nil { + p.logger.Error().Err(err).Msg("error adding resource to the index") + } else { + p.logDocCount() } - indexClient.Add(ref, statRes.Info) } }() @@ -82,7 +100,7 @@ func (p *Provider) Search(ctx context.Context, req *searchsvc.SearchRequest) (*s return nil, errtypes.PreconditionFailed("empty query provided") } - listSpacesRes, err := p.gwClient.ListStorageSpaces(ctx, &providerv1beta1.ListStorageSpacesRequest{ + listSpacesRes, err := p.gwClient.ListStorageSpaces(ctx, &provider.ListStorageSpacesRequest{ Opaque: &typesv1beta1.Opaque{Map: map[string]*typesv1beta1.OpaqueEntry{ "path": { Decoder: "plain", @@ -98,7 +116,7 @@ func (p *Provider) Search(ctx context.Context, req *searchsvc.SearchRequest) (*s for _, space := range listSpacesRes.StorageSpaces { pathPrefix := "" if space.SpaceType == "grant" { - gpRes, err := p.gwClient.GetPath(ctx, &providerv1beta1.GetPathRequest{ + gpRes, err := p.gwClient.GetPath(ctx, &provider.GetPathRequest{ ResourceId: space.Root, }) if err != nil { @@ -136,3 +154,57 @@ func (p *Provider) Search(ctx context.Context, req *searchsvc.SearchRequest) (*s Matches: matches, }, nil } + +func (p *Provider) IndexSpace(ctx context.Context, req *searchsvc.IndexSpaceRequest) (*searchsvc.IndexSpaceResponse, error) { + // get user + res, err := p.gwClient.GetUserByClaim(context.Background(), &user.GetUserByClaimRequest{ + Claim: "username", + Value: req.UserId, + }) + if err != nil || res.Status.Code != rpc.Code_CODE_OK { + fmt.Println("error: Could not get user by userid") + return nil, err + } + + // Get auth context + ownerCtx := ctxpkg.ContextSetUser(context.Background(), res.User) + authRes, err := p.gwClient.Authenticate(ownerCtx, &gateway.AuthenticateRequest{ + Type: "machine", + ClientId: "userid:" + res.User.Id.OpaqueId, + ClientSecret: p.machineAuthAPIKey, + }) + if err != nil || authRes.GetStatus().GetCode() != rpc.Code_CODE_OK { + return nil, err + } + + if authRes.GetStatus().GetCode() != rpc.Code_CODE_OK { + return nil, fmt.Errorf("could not get authenticated context for user") + } + ownerCtx = metadata.AppendToOutgoingContext(ownerCtx, ctxpkg.TokenHeader, authRes.Token) + + // Walk the space and index all files + walker := walker.NewWalker(p.gwClient) + rootId := &provider.ResourceId{StorageId: req.SpaceId, OpaqueId: req.SpaceId} + err = walker.Walk(ownerCtx, rootId, func(wd string, info *provider.ResourceInfo, err error) error { + if err != nil { + p.logger.Error().Err(err).Msg("error walking the tree") + } + ref := &provider.Reference{ + Path: utils.MakeRelativePath(filepath.Join(wd, info.Path)), + ResourceId: rootId, + } + err = p.indexClient.Add(ref, info) + if err != nil { + p.logger.Error().Err(err).Msg("error adding resource to the index") + } else { + p.logger.Debug().Interface("ref", ref).Msg("added resource to index") + } + return nil + }) + if err != nil { + return nil, err + } + + p.logDocCount() + return &searchsvc.IndexSpaceResponse{}, nil +} diff --git a/extensions/search/pkg/search/provider/searchprovider_test.go b/extensions/search/pkg/search/provider/searchprovider_test.go index 46a6d14d65..30b3c13cfe 100644 --- a/extensions/search/pkg/search/provider/searchprovider_test.go +++ b/extensions/search/pkg/search/provider/searchprovider_test.go @@ -16,6 +16,7 @@ import ( cs3mocks "github.com/cs3org/reva/v2/tests/cs3mocks/mocks" "github.com/owncloud/ocis/extensions/search/pkg/search/mocks" provider "github.com/owncloud/ocis/extensions/search/pkg/search/provider" + "github.com/owncloud/ocis/ocis-pkg/log" searchmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/search/v0" searchsvc "github.com/owncloud/ocis/protogen/gen/ocis/services/search/v0" ) @@ -29,6 +30,12 @@ var _ = Describe("Searchprovider", func() { ctx context.Context eventsChan chan interface{} + logger = log.NewLogger() + user = &userv1beta1.User{ + Id: &userv1beta1.UserId{ + OpaqueId: "user", + }, + } otherUser = &userv1beta1.User{ Id: &userv1beta1.UserId{ OpaqueId: "otheruser", @@ -71,27 +78,27 @@ var _ = Describe("Searchprovider", func() { gwClient = &cs3mocks.GatewayAPIClient{} indexClient = &mocks.IndexClient{} - p = provider.New(gwClient, indexClient, "", eventsChan) + p = provider.New(gwClient, indexClient, "", eventsChan, logger) + + gwClient.On("Authenticate", mock.Anything, mock.Anything).Return(&gateway.AuthenticateResponse{ + Status: status.NewOK(ctx), + Token: "authtoken", + }, nil) + gwClient.On("Stat", mock.Anything, mock.Anything).Return(&sprovider.StatResponse{ + Status: status.NewOK(context.Background()), + Info: ri, + }, nil) + indexClient.On("DocCount").Return(uint64(1), nil) }) Describe("New", func() { It("returns a new instance", func() { - p := provider.New(gwClient, indexClient, "", eventsChan) + p := provider.New(gwClient, indexClient, "", eventsChan, logger) Expect(p).ToNot(BeNil()) }) }) Describe("events", func() { - BeforeEach(func() { - gwClient.On("Authenticate", mock.Anything, mock.Anything).Return(&gateway.AuthenticateResponse{ - Token: "authtoken", - }, nil) - gwClient.On("Stat", mock.Anything, mock.Anything).Return(&sprovider.StatResponse{ - Status: status.NewOK(context.Background()), - Info: ri, - }, nil) - }) - It("trigger an index update when a file has been uploaded", func() { called := false indexClient.On("Add", mock.Anything, mock.MatchedBy(func(riToIndex *sprovider.ResourceInfo) bool { @@ -100,7 +107,8 @@ var _ = Describe("Searchprovider", func() { called = true }) eventsChan <- events.FileUploaded{ - FileID: ref, + FileID: ref, + Executant: user.Id, } Eventually(func() bool { @@ -109,6 +117,25 @@ var _ = Describe("Searchprovider", func() { }) }) + Describe("IndexSpace", func() { + It("walks the space and indexes all files", func() { + gwClient.On("GetUserByClaim", mock.Anything, mock.Anything).Return(&userv1beta1.GetUserByClaimResponse{ + Status: status.NewOK(context.Background()), + User: user, + }, nil) + indexClient.On("Add", mock.Anything, mock.MatchedBy(func(riToIndex *sprovider.ResourceInfo) bool { + return riToIndex.Id.OpaqueId == ri.Id.OpaqueId + })).Return(nil) + + res, err := p.IndexSpace(ctx, &searchsvc.IndexSpaceRequest{ + SpaceId: "storageid", + UserId: "user", + }) + Expect(err).ToNot(HaveOccurred()) + Expect(res).ToNot(BeNil()) + }) + }) + Describe("Search", func() { It("fails when an empty query is given", func() { res, err := p.Search(ctx, &searchsvc.SearchRequest{ diff --git a/extensions/search/pkg/search/search.go b/extensions/search/pkg/search/search.go index 4e23b568b0..8200a364af 100644 --- a/extensions/search/pkg/search/search.go +++ b/extensions/search/pkg/search/search.go @@ -31,10 +31,13 @@ import ( // ProviderClient is the interface to the search provider service type ProviderClient interface { Search(ctx context.Context, req *searchsvc.SearchRequest) (*searchsvc.SearchResponse, error) + IndexSpace(ctx context.Context, req *searchsvc.IndexSpaceRequest) (*searchsvc.IndexSpaceResponse, error) } // IndexClient is the interface to the search index type IndexClient interface { Search(ctx context.Context, req *searchsvc.SearchIndexRequest) (*searchsvc.SearchIndexResponse, error) Add(ref *providerv1beta1.Reference, ri *providerv1beta1.ResourceInfo) error + Remove(ri *providerv1beta1.ResourceInfo) error + DocCount() (uint64, error) } diff --git a/extensions/search/pkg/service/v0/service.go b/extensions/search/pkg/service/v0/service.go index a214fa1bd2..90349b4393 100644 --- a/extensions/search/pkg/service/v0/service.go +++ b/extensions/search/pkg/service/v0/service.go @@ -61,7 +61,7 @@ func NewHandler(opts ...Option) (searchsvc.SearchProviderHandler, error) { logger.Fatal().Err(err).Str("addr", cfg.Reva.Address).Msg("could not get reva client") } - provider := searchprovider.New(gwclient, index, cfg.MachineAuthAPIKey, evts) + provider := searchprovider.New(gwclient, index, cfg.MachineAuthAPIKey, evts, logger) return &Service{ id: cfg.GRPC.Namespace + "." + cfg.Service.Name, @@ -99,3 +99,8 @@ func (s Service) Search(ctx context.Context, in *searchsvc.SearchRequest, out *s out.NextPageToken = res.NextPageToken return nil } + +func (s Service) IndexSpace(ctx context.Context, in *searchsvc.IndexSpaceRequest, out *searchsvc.IndexSpaceResponse) error { + _, err := s.provider.IndexSpace(ctx, in) + return err +} diff --git a/extensions/webdav/pkg/service/v0/search.go b/extensions/webdav/pkg/service/v0/search.go index 3bce68236d..5a7d15f545 100644 --- a/extensions/webdav/pkg/service/v0/search.go +++ b/extensions/webdav/pkg/service/v0/search.go @@ -106,6 +106,22 @@ func matchToPropResponse(ctx context.Context, match *searchmsg.Match) (*propfind Prop: []prop.PropertyXML{}, } + // RDNVW + // 0 + // demo + // demo + // + // https://demo.owncloud.com/f/7 + // application/pdf + // + // + // done: + // 7 + // 6668668 + // 6668668 + // "0cdcdd1bb13a8fed3e54d3b2325dc97c" + // Mon, 25 Apr 2022 06:48:26 GMT + propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("oc:fileid", match.Entity.Id.StorageId+"!"+match.Entity.Id.OpaqueId)) propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("d:getetag", match.Entity.Etag)) propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("d:getlastmodified", match.Entity.LastModifiedTime.AsTime().Format(time.RFC3339))) diff --git a/protogen/gen/ocis/services/search/v0/search.pb.go b/protogen/gen/ocis/services/search/v0/search.pb.go index 7ccbc467b3..236bfe95a0 100644 --- a/protogen/gen/ocis/services/search/v0/search.pb.go +++ b/protogen/gen/ocis/services/search/v0/search.pb.go @@ -278,6 +278,99 @@ func (x *SearchIndexResponse) GetNextPageToken() string { return "" } +type IndexSpaceRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SpaceId string `protobuf:"bytes,1,opt,name=space_id,json=spaceId,proto3" json:"space_id,omitempty"` + UserId string `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` +} + +func (x *IndexSpaceRequest) Reset() { + *x = IndexSpaceRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_ocis_services_search_v0_search_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IndexSpaceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IndexSpaceRequest) ProtoMessage() {} + +func (x *IndexSpaceRequest) ProtoReflect() protoreflect.Message { + mi := &file_ocis_services_search_v0_search_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use IndexSpaceRequest.ProtoReflect.Descriptor instead. +func (*IndexSpaceRequest) Descriptor() ([]byte, []int) { + return file_ocis_services_search_v0_search_proto_rawDescGZIP(), []int{4} +} + +func (x *IndexSpaceRequest) GetSpaceId() string { + if x != nil { + return x.SpaceId + } + return "" +} + +func (x *IndexSpaceRequest) GetUserId() string { + if x != nil { + return x.UserId + } + return "" +} + +type IndexSpaceResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *IndexSpaceResponse) Reset() { + *x = IndexSpaceResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_ocis_services_search_v0_search_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IndexSpaceResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IndexSpaceResponse) ProtoMessage() {} + +func (x *IndexSpaceResponse) ProtoReflect() protoreflect.Message { + mi := &file_ocis_services_search_v0_search_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use IndexSpaceResponse.ProtoReflect.Descriptor instead. +func (*IndexSpaceResponse) Descriptor() ([]byte, []int) { + return file_ocis_services_search_v0_search_proto_rawDescGZIP(), []int{5} +} + var File_ocis_services_search_v0_search_proto protoreflect.FileDescriptor var file_ocis_services_search_v0_search_proto_rawDesc = []byte{ @@ -329,48 +422,63 @@ var file_ocis_services_search_v0_search_proto_rawDesc = []byte{ 0x63, 0x68, 0x52, 0x07, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, - 0x6b, 0x65, 0x6e, 0x32, 0x8d, 0x01, 0x0a, 0x0e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x50, 0x72, - 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x7b, 0x0a, 0x06, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, - 0x12, 0x26, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2e, 0x76, 0x30, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, - 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2e, - 0x76, 0x30, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x22, 0x15, 0x2f, 0x61, 0x70, 0x69, 0x2f, - 0x76, 0x30, 0x2f, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2f, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, - 0x3a, 0x01, 0x2a, 0x32, 0x9d, 0x01, 0x0a, 0x0d, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x50, 0x72, 0x6f, - 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x8b, 0x01, 0x0a, 0x06, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, - 0x12, 0x2b, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2e, 0x76, 0x30, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, - 0x68, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, + 0x6b, 0x65, 0x6e, 0x22, 0x47, 0x0a, 0x11, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x53, 0x70, 0x61, 0x63, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x14, 0x0a, 0x12, + 0x49, 0x6e, 0x64, 0x65, 0x78, 0x53, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x32, 0x9c, 0x02, 0x0a, 0x0e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x50, 0x72, 0x6f, + 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x7b, 0x0a, 0x06, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x12, + 0x26, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, + 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2e, 0x76, 0x30, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2e, 0x76, + 0x30, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x22, 0x15, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, + 0x30, 0x2f, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2f, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x3a, + 0x01, 0x2a, 0x12, 0x8c, 0x01, 0x0a, 0x0a, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x53, 0x70, 0x61, 0x63, + 0x65, 0x12, 0x2a, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x73, 0x2e, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2e, 0x76, 0x30, 0x2e, 0x49, 0x6e, 0x64, 0x65, + 0x78, 0x53, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x65, - 0x61, 0x72, 0x63, 0x68, 0x2e, 0x76, 0x30, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x49, 0x6e, - 0x64, 0x65, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x26, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x20, 0x22, 0x1b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x30, 0x2f, 0x73, 0x65, 0x61, - 0x72, 0x63, 0x68, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2f, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, - 0x3a, 0x01, 0x2a, 0x42, 0xde, 0x02, 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x6f, 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2f, 0x6f, 0x63, 0x69, 0x73, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x6f, 0x63, - 0x69, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x73, 0x65, 0x61, 0x72, 0x63, - 0x68, 0x2f, 0x76, 0x30, 0x92, 0x41, 0x9c, 0x02, 0x12, 0xb4, 0x01, 0x0a, 0x1e, 0x6f, 0x77, 0x6e, - 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x20, 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x65, 0x20, 0x53, - 0x63, 0x61, 0x6c, 0x65, 0x20, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x22, 0x47, 0x0a, 0x0d, 0x6f, - 0x77, 0x6e, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x20, 0x47, 0x6d, 0x62, 0x48, 0x12, 0x20, 0x68, 0x74, - 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x6f, 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2f, 0x6f, 0x63, 0x69, 0x73, 0x1a, 0x14, - 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x40, 0x6f, 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, - 0x2e, 0x63, 0x6f, 0x6d, 0x2a, 0x42, 0x0a, 0x0a, 0x41, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2d, 0x32, - 0x2e, 0x30, 0x12, 0x34, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2f, - 0x6f, 0x63, 0x69, 0x73, 0x2f, 0x62, 0x6c, 0x6f, 0x62, 0x2f, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, - 0x2f, 0x4c, 0x49, 0x43, 0x45, 0x4e, 0x53, 0x45, 0x32, 0x05, 0x31, 0x2e, 0x30, 0x2e, 0x30, 0x2a, - 0x02, 0x01, 0x02, 0x32, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x2f, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x2f, 0x6a, 0x73, 0x6f, 0x6e, 0x72, 0x3b, 0x0a, 0x10, 0x44, 0x65, 0x76, 0x65, 0x6c, - 0x6f, 0x70, 0x65, 0x72, 0x20, 0x4d, 0x61, 0x6e, 0x75, 0x61, 0x6c, 0x12, 0x27, 0x68, 0x74, 0x74, - 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x6f, 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x64, 0x65, - 0x76, 0x2f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x73, 0x65, 0x61, - 0x72, 0x63, 0x68, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x72, 0x63, 0x68, 0x2e, 0x76, 0x30, 0x2e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x53, 0x70, 0x61, + 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x25, 0x82, 0xd3, 0xe4, 0x93, + 0x02, 0x1f, 0x22, 0x1a, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x30, 0x2f, 0x73, 0x65, 0x61, 0x72, + 0x63, 0x68, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2d, 0x73, 0x70, 0x61, 0x63, 0x65, 0x3a, 0x01, + 0x2a, 0x32, 0x9d, 0x01, 0x0a, 0x0d, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x50, 0x72, 0x6f, 0x76, 0x69, + 0x64, 0x65, 0x72, 0x12, 0x8b, 0x01, 0x0a, 0x06, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x12, 0x2b, + 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, + 0x65, 0x61, 0x72, 0x63, 0x68, 0x2e, 0x76, 0x30, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x49, + 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x6f, 0x63, + 0x69, 0x73, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x65, 0x61, 0x72, + 0x63, 0x68, 0x2e, 0x76, 0x30, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x49, 0x6e, 0x64, 0x65, + 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x26, 0x82, 0xd3, 0xe4, 0x93, 0x02, + 0x20, 0x22, 0x1b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x30, 0x2f, 0x73, 0x65, 0x61, 0x72, 0x63, + 0x68, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2f, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x3a, 0x01, + 0x2a, 0x42, 0xde, 0x02, 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x6f, 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2f, 0x6f, 0x63, 0x69, 0x73, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x6f, 0x63, 0x69, 0x73, + 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2f, + 0x76, 0x30, 0x92, 0x41, 0x9c, 0x02, 0x12, 0xb4, 0x01, 0x0a, 0x1e, 0x6f, 0x77, 0x6e, 0x43, 0x6c, + 0x6f, 0x75, 0x64, 0x20, 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x65, 0x20, 0x53, 0x63, 0x61, + 0x6c, 0x65, 0x20, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x22, 0x47, 0x0a, 0x0d, 0x6f, 0x77, 0x6e, + 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x20, 0x47, 0x6d, 0x62, 0x48, 0x12, 0x20, 0x68, 0x74, 0x74, 0x70, + 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, + 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2f, 0x6f, 0x63, 0x69, 0x73, 0x1a, 0x14, 0x73, 0x75, + 0x70, 0x70, 0x6f, 0x72, 0x74, 0x40, 0x6f, 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x63, + 0x6f, 0x6d, 0x2a, 0x42, 0x0a, 0x0a, 0x41, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2d, 0x32, 0x2e, 0x30, + 0x12, 0x34, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2f, 0x6f, 0x63, + 0x69, 0x73, 0x2f, 0x62, 0x6c, 0x6f, 0x62, 0x2f, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x2f, 0x4c, + 0x49, 0x43, 0x45, 0x4e, 0x53, 0x45, 0x32, 0x05, 0x31, 0x2e, 0x30, 0x2e, 0x30, 0x2a, 0x02, 0x01, + 0x02, 0x32, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6a, + 0x73, 0x6f, 0x6e, 0x3a, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x2f, 0x6a, 0x73, 0x6f, 0x6e, 0x72, 0x3b, 0x0a, 0x10, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, + 0x65, 0x72, 0x20, 0x4d, 0x61, 0x6e, 0x75, 0x61, 0x6c, 0x12, 0x27, 0x68, 0x74, 0x74, 0x70, 0x73, + 0x3a, 0x2f, 0x2f, 0x6f, 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x64, 0x65, 0x76, 0x2f, + 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x73, 0x65, 0x61, 0x72, 0x63, + 0x68, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -385,25 +493,29 @@ func file_ocis_services_search_v0_search_proto_rawDescGZIP() []byte { return file_ocis_services_search_v0_search_proto_rawDescData } -var file_ocis_services_search_v0_search_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_ocis_services_search_v0_search_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_ocis_services_search_v0_search_proto_goTypes = []interface{}{ (*SearchRequest)(nil), // 0: ocis.services.search.v0.SearchRequest (*SearchResponse)(nil), // 1: ocis.services.search.v0.SearchResponse (*SearchIndexRequest)(nil), // 2: ocis.services.search.v0.SearchIndexRequest (*SearchIndexResponse)(nil), // 3: ocis.services.search.v0.SearchIndexResponse - (*v0.Match)(nil), // 4: ocis.messages.search.v0.Match - (*v0.Reference)(nil), // 5: ocis.messages.search.v0.Reference + (*IndexSpaceRequest)(nil), // 4: ocis.services.search.v0.IndexSpaceRequest + (*IndexSpaceResponse)(nil), // 5: ocis.services.search.v0.IndexSpaceResponse + (*v0.Match)(nil), // 6: ocis.messages.search.v0.Match + (*v0.Reference)(nil), // 7: ocis.messages.search.v0.Reference } var file_ocis_services_search_v0_search_proto_depIdxs = []int32{ - 4, // 0: ocis.services.search.v0.SearchResponse.matches:type_name -> ocis.messages.search.v0.Match - 5, // 1: ocis.services.search.v0.SearchIndexRequest.ref:type_name -> ocis.messages.search.v0.Reference - 4, // 2: ocis.services.search.v0.SearchIndexResponse.matches:type_name -> ocis.messages.search.v0.Match + 6, // 0: ocis.services.search.v0.SearchResponse.matches:type_name -> ocis.messages.search.v0.Match + 7, // 1: ocis.services.search.v0.SearchIndexRequest.ref:type_name -> ocis.messages.search.v0.Reference + 6, // 2: ocis.services.search.v0.SearchIndexResponse.matches:type_name -> ocis.messages.search.v0.Match 0, // 3: ocis.services.search.v0.SearchProvider.Search:input_type -> ocis.services.search.v0.SearchRequest - 2, // 4: ocis.services.search.v0.IndexProvider.Search:input_type -> ocis.services.search.v0.SearchIndexRequest - 1, // 5: ocis.services.search.v0.SearchProvider.Search:output_type -> ocis.services.search.v0.SearchResponse - 3, // 6: ocis.services.search.v0.IndexProvider.Search:output_type -> ocis.services.search.v0.SearchIndexResponse - 5, // [5:7] is the sub-list for method output_type - 3, // [3:5] is the sub-list for method input_type + 4, // 4: ocis.services.search.v0.SearchProvider.IndexSpace:input_type -> ocis.services.search.v0.IndexSpaceRequest + 2, // 5: ocis.services.search.v0.IndexProvider.Search:input_type -> ocis.services.search.v0.SearchIndexRequest + 1, // 6: ocis.services.search.v0.SearchProvider.Search:output_type -> ocis.services.search.v0.SearchResponse + 5, // 7: ocis.services.search.v0.SearchProvider.IndexSpace:output_type -> ocis.services.search.v0.IndexSpaceResponse + 3, // 8: ocis.services.search.v0.IndexProvider.Search:output_type -> ocis.services.search.v0.SearchIndexResponse + 6, // [6:9] is the sub-list for method output_type + 3, // [3:6] is the sub-list for method input_type 3, // [3:3] is the sub-list for extension type_name 3, // [3:3] is the sub-list for extension extendee 0, // [0:3] is the sub-list for field type_name @@ -463,6 +575,30 @@ func file_ocis_services_search_v0_search_proto_init() { return nil } } + file_ocis_services_search_v0_search_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IndexSpaceRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ocis_services_search_v0_search_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IndexSpaceResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -470,7 +606,7 @@ func file_ocis_services_search_v0_search_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_ocis_services_search_v0_search_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 6, NumExtensions: 0, NumServices: 2, }, diff --git a/protogen/gen/ocis/services/search/v0/search.pb.micro.go b/protogen/gen/ocis/services/search/v0/search.pb.micro.go index 2c45e6a7ee..06e5ea9aed 100644 --- a/protogen/gen/ocis/services/search/v0/search.pb.micro.go +++ b/protogen/gen/ocis/services/search/v0/search.pb.micro.go @@ -42,6 +42,13 @@ func NewSearchProviderEndpoints() []*api.Endpoint { Body: "*", Handler: "rpc", }, + { + Name: "SearchProvider.IndexSpace", + Path: []string{"/api/v0/search/index-space"}, + Method: []string{"POST"}, + Body: "*", + Handler: "rpc", + }, } } @@ -49,6 +56,7 @@ func NewSearchProviderEndpoints() []*api.Endpoint { type SearchProviderService interface { Search(ctx context.Context, in *SearchRequest, opts ...client.CallOption) (*SearchResponse, error) + IndexSpace(ctx context.Context, in *IndexSpaceRequest, opts ...client.CallOption) (*IndexSpaceResponse, error) } type searchProviderService struct { @@ -73,15 +81,27 @@ func (c *searchProviderService) Search(ctx context.Context, in *SearchRequest, o return out, nil } +func (c *searchProviderService) IndexSpace(ctx context.Context, in *IndexSpaceRequest, opts ...client.CallOption) (*IndexSpaceResponse, error) { + req := c.c.NewRequest(c.name, "SearchProvider.IndexSpace", in) + out := new(IndexSpaceResponse) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // Server API for SearchProvider service type SearchProviderHandler interface { Search(context.Context, *SearchRequest, *SearchResponse) error + IndexSpace(context.Context, *IndexSpaceRequest, *IndexSpaceResponse) error } func RegisterSearchProviderHandler(s server.Server, hdlr SearchProviderHandler, opts ...server.HandlerOption) error { type searchProvider interface { Search(ctx context.Context, in *SearchRequest, out *SearchResponse) error + IndexSpace(ctx context.Context, in *IndexSpaceRequest, out *IndexSpaceResponse) error } type SearchProvider struct { searchProvider @@ -94,6 +114,13 @@ func RegisterSearchProviderHandler(s server.Server, hdlr SearchProviderHandler, Body: "*", Handler: "rpc", })) + opts = append(opts, api.WithEndpoint(&api.Endpoint{ + Name: "SearchProvider.IndexSpace", + Path: []string{"/api/v0/search/index-space"}, + Method: []string{"POST"}, + Body: "*", + Handler: "rpc", + })) return s.Handle(s.NewHandler(&SearchProvider{h}, opts...)) } @@ -105,6 +132,10 @@ func (h *searchProviderHandler) Search(ctx context.Context, in *SearchRequest, o return h.SearchProviderHandler.Search(ctx, in, out) } +func (h *searchProviderHandler) IndexSpace(ctx context.Context, in *IndexSpaceRequest, out *IndexSpaceResponse) error { + return h.SearchProviderHandler.IndexSpace(ctx, in, out) +} + // Api Endpoints for IndexProvider service func NewIndexProviderEndpoints() []*api.Endpoint { diff --git a/protogen/gen/ocis/services/search/v0/search.pb.web.go b/protogen/gen/ocis/services/search/v0/search.pb.web.go index 46105d3300..427033152b 100644 --- a/protogen/gen/ocis/services/search/v0/search.pb.web.go +++ b/protogen/gen/ocis/services/search/v0/search.pb.web.go @@ -44,6 +44,28 @@ func (h *webSearchProviderHandler) Search(w http.ResponseWriter, r *http.Request render.JSON(w, r, resp) } +func (h *webSearchProviderHandler) IndexSpace(w http.ResponseWriter, r *http.Request) { + req := &IndexSpaceRequest{} + resp := &IndexSpaceResponse{} + + if err := json.NewDecoder(r.Body).Decode(&req); err != nil { + http.Error(w, err.Error(), http.StatusPreconditionFailed) + return + } + + if err := h.h.IndexSpace( + r.Context(), + req, + resp, + ); err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + + render.Status(r, http.StatusCreated) + render.JSON(w, r, resp) +} + func RegisterSearchProviderWeb(r chi.Router, i SearchProviderHandler, middlewares ...func(http.Handler) http.Handler) { handler := &webSearchProviderHandler{ r: r, @@ -51,6 +73,7 @@ func RegisterSearchProviderWeb(r chi.Router, i SearchProviderHandler, middleware } r.MethodFunc("POST", "/api/v0/search/search", handler.Search) + r.MethodFunc("POST", "/api/v0/search/index-space", handler.IndexSpace) } type webIndexProviderHandler struct { @@ -236,3 +259,75 @@ func (m *SearchIndexResponse) UnmarshalJSON(b []byte) error { } var _ json.Unmarshaler = (*SearchIndexResponse)(nil) + +// IndexSpaceRequestJSONMarshaler describes the default jsonpb.Marshaler used by all +// instances of IndexSpaceRequest. This struct is safe to replace or modify but +// should not be done so concurrently. +var IndexSpaceRequestJSONMarshaler = new(jsonpb.Marshaler) + +// MarshalJSON satisfies the encoding/json Marshaler interface. This method +// uses the more correct jsonpb package to correctly marshal the message. +func (m *IndexSpaceRequest) MarshalJSON() ([]byte, error) { + if m == nil { + return json.Marshal(nil) + } + + buf := &bytes.Buffer{} + + if err := IndexSpaceRequestJSONMarshaler.Marshal(buf, m); err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +var _ json.Marshaler = (*IndexSpaceRequest)(nil) + +// IndexSpaceRequestJSONUnmarshaler describes the default jsonpb.Unmarshaler used by all +// instances of IndexSpaceRequest. This struct is safe to replace or modify but +// should not be done so concurrently. +var IndexSpaceRequestJSONUnmarshaler = new(jsonpb.Unmarshaler) + +// UnmarshalJSON satisfies the encoding/json Unmarshaler interface. This method +// uses the more correct jsonpb package to correctly unmarshal the message. +func (m *IndexSpaceRequest) UnmarshalJSON(b []byte) error { + return IndexSpaceRequestJSONUnmarshaler.Unmarshal(bytes.NewReader(b), m) +} + +var _ json.Unmarshaler = (*IndexSpaceRequest)(nil) + +// IndexSpaceResponseJSONMarshaler describes the default jsonpb.Marshaler used by all +// instances of IndexSpaceResponse. This struct is safe to replace or modify but +// should not be done so concurrently. +var IndexSpaceResponseJSONMarshaler = new(jsonpb.Marshaler) + +// MarshalJSON satisfies the encoding/json Marshaler interface. This method +// uses the more correct jsonpb package to correctly marshal the message. +func (m *IndexSpaceResponse) MarshalJSON() ([]byte, error) { + if m == nil { + return json.Marshal(nil) + } + + buf := &bytes.Buffer{} + + if err := IndexSpaceResponseJSONMarshaler.Marshal(buf, m); err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +var _ json.Marshaler = (*IndexSpaceResponse)(nil) + +// IndexSpaceResponseJSONUnmarshaler describes the default jsonpb.Unmarshaler used by all +// instances of IndexSpaceResponse. This struct is safe to replace or modify but +// should not be done so concurrently. +var IndexSpaceResponseJSONUnmarshaler = new(jsonpb.Unmarshaler) + +// UnmarshalJSON satisfies the encoding/json Unmarshaler interface. This method +// uses the more correct jsonpb package to correctly unmarshal the message. +func (m *IndexSpaceResponse) UnmarshalJSON(b []byte) error { + return IndexSpaceResponseJSONUnmarshaler.Unmarshal(bytes.NewReader(b), m) +} + +var _ json.Unmarshaler = (*IndexSpaceResponse)(nil) diff --git a/protogen/gen/ocis/services/search/v0/search.swagger.json b/protogen/gen/ocis/services/search/v0/search.swagger.json index b06c03da83..26567aab88 100644 --- a/protogen/gen/ocis/services/search/v0/search.swagger.json +++ b/protogen/gen/ocis/services/search/v0/search.swagger.json @@ -32,6 +32,38 @@ "application/json" ], "paths": { + "/api/v0/search/index-space": { + "post": { + "operationId": "SearchProvider_IndexSpace", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v0IndexSpaceResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v0IndexSpaceRequest" + } + } + ], + "tags": [ + "SearchProvider" + ] + } + }, "/api/v0/search/index/search": { "post": { "operationId": "IndexProvider_Search", @@ -156,6 +188,20 @@ } } }, + "v0IndexSpaceRequest": { + "type": "object", + "properties": { + "spaceId": { + "type": "string" + }, + "userId": { + "type": "string" + } + } + }, + "v0IndexSpaceResponse": { + "type": "object" + }, "v0Match": { "type": "object", "properties": { diff --git a/protogen/proto/ocis/services/search/v0/search.proto b/protogen/proto/ocis/services/search/v0/search.proto index 8bc8fb3925..7d78dae35a 100644 --- a/protogen/proto/ocis/services/search/v0/search.proto +++ b/protogen/proto/ocis/services/search/v0/search.proto @@ -36,17 +36,21 @@ option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { service SearchProvider { rpc Search(SearchRequest) returns (SearchResponse) { - // List method maps to HTTP GET option (google.api.http) = { post: "/api/v0/search/search", body: "*" }; }; + rpc IndexSpace(IndexSpaceRequest) returns (IndexSpaceResponse) { + option (google.api.http) = { + post: "/api/v0/search/index-space", + body: "*" + }; + } } service IndexProvider { rpc Search(SearchIndexRequest) returns (SearchIndexResponse) { - // List method maps to HTTP GET option (google.api.http) = { post: "/api/v0/search/index/search", body: "*" @@ -92,4 +96,12 @@ message SearchIndexResponse { // Token to retrieve the next page of results, or empty if there are no // more results in the list string next_page_token = 2; +} + +message IndexSpaceRequest { + string space_id = 1; + string user_id = 2; +} + +message IndexSpaceResponse { } \ No newline at end of file