diff --git a/protogen/gen/ocis/messages/search/v0/search.pb.go b/protogen/gen/ocis/messages/search/v0/search.pb.go new file mode 100644 index 000000000..9e22a09d8 --- /dev/null +++ b/protogen/gen/ocis/messages/search/v0/search.pb.go @@ -0,0 +1,405 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.1 +// protoc v3.17.3 +// source: ocis/messages/search/v0/search.proto + +package v0 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ResourceID struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + StorageId string `protobuf:"bytes,1,opt,name=storage_id,json=storageId,proto3" json:"storage_id,omitempty"` + OpaqueId string `protobuf:"bytes,2,opt,name=opaque_id,json=opaqueId,proto3" json:"opaque_id,omitempty"` +} + +func (x *ResourceID) Reset() { + *x = ResourceID{} + if protoimpl.UnsafeEnabled { + mi := &file_ocis_messages_search_v0_search_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ResourceID) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResourceID) ProtoMessage() {} + +func (x *ResourceID) ProtoReflect() protoreflect.Message { + mi := &file_ocis_messages_search_v0_search_proto_msgTypes[0] + 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 ResourceID.ProtoReflect.Descriptor instead. +func (*ResourceID) Descriptor() ([]byte, []int) { + return file_ocis_messages_search_v0_search_proto_rawDescGZIP(), []int{0} +} + +func (x *ResourceID) GetStorageId() string { + if x != nil { + return x.StorageId + } + return "" +} + +func (x *ResourceID) GetOpaqueId() string { + if x != nil { + return x.OpaqueId + } + return "" +} + +type Reference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ResourceId *ResourceID `protobuf:"bytes,1,opt,name=resource_id,json=resourceId,proto3" json:"resource_id,omitempty"` + Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` +} + +func (x *Reference) Reset() { + *x = Reference{} + if protoimpl.UnsafeEnabled { + mi := &file_ocis_messages_search_v0_search_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Reference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Reference) ProtoMessage() {} + +func (x *Reference) ProtoReflect() protoreflect.Message { + mi := &file_ocis_messages_search_v0_search_proto_msgTypes[1] + 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 Reference.ProtoReflect.Descriptor instead. +func (*Reference) Descriptor() ([]byte, []int) { + return file_ocis_messages_search_v0_search_proto_rawDescGZIP(), []int{1} +} + +func (x *Reference) GetResourceId() *ResourceID { + if x != nil { + return x.ResourceId + } + return nil +} + +func (x *Reference) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +type Entity struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Ref *Reference `protobuf:"bytes,1,opt,name=ref,proto3" json:"ref,omitempty"` + Id *ResourceID `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + Size int64 `protobuf:"varint,4,opt,name=size,proto3" json:"size,omitempty"` +} + +func (x *Entity) Reset() { + *x = Entity{} + if protoimpl.UnsafeEnabled { + mi := &file_ocis_messages_search_v0_search_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Entity) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Entity) ProtoMessage() {} + +func (x *Entity) ProtoReflect() protoreflect.Message { + mi := &file_ocis_messages_search_v0_search_proto_msgTypes[2] + 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 Entity.ProtoReflect.Descriptor instead. +func (*Entity) Descriptor() ([]byte, []int) { + return file_ocis_messages_search_v0_search_proto_rawDescGZIP(), []int{2} +} + +func (x *Entity) GetRef() *Reference { + if x != nil { + return x.Ref + } + return nil +} + +func (x *Entity) GetId() *ResourceID { + if x != nil { + return x.Id + } + return nil +} + +func (x *Entity) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Entity) GetSize() int64 { + if x != nil { + return x.Size + } + return 0 +} + +type Match struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // the matched entity + Entity *Entity `protobuf:"bytes,1,opt,name=entity,proto3" json:"entity,omitempty"` + // the match score + Score float32 `protobuf:"fixed32,2,opt,name=score,proto3" json:"score,omitempty"` +} + +func (x *Match) Reset() { + *x = Match{} + if protoimpl.UnsafeEnabled { + mi := &file_ocis_messages_search_v0_search_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Match) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Match) ProtoMessage() {} + +func (x *Match) ProtoReflect() protoreflect.Message { + mi := &file_ocis_messages_search_v0_search_proto_msgTypes[3] + 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 Match.ProtoReflect.Descriptor instead. +func (*Match) Descriptor() ([]byte, []int) { + return file_ocis_messages_search_v0_search_proto_rawDescGZIP(), []int{3} +} + +func (x *Match) GetEntity() *Entity { + if x != nil { + return x.Entity + } + return nil +} + +func (x *Match) GetScore() float32 { + if x != nil { + return x.Score + } + return 0 +} + +var File_ocis_messages_search_v0_search_proto protoreflect.FileDescriptor + +var file_ocis_messages_search_v0_search_proto_rawDesc = []byte{ + 0x0a, 0x24, 0x6f, 0x63, 0x69, 0x73, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2f, + 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2f, 0x76, 0x30, 0x2f, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x17, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x6d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2e, 0x76, 0x30, 0x22, + 0x48, 0x0a, 0x0a, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x44, 0x12, 0x1d, 0x0a, + 0x0a, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, + 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x49, 0x64, 0x22, 0x65, 0x0a, 0x09, 0x52, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x44, 0x0a, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x6f, 0x63, + 0x69, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x73, 0x65, 0x61, 0x72, + 0x63, 0x68, 0x2e, 0x76, 0x30, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x44, + 0x52, 0x0a, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, + 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, + 0x22, 0x9b, 0x01, 0x0a, 0x06, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x34, 0x0a, 0x03, 0x72, + 0x65, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2e, + 0x76, 0x30, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x03, 0x72, 0x65, + 0x66, 0x12, 0x33, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, + 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x73, 0x65, + 0x61, 0x72, 0x63, 0x68, 0x2e, 0x76, 0x30, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x49, 0x44, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, + 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0x56, + 0x0a, 0x05, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x12, 0x37, 0x0a, 0x06, 0x65, 0x6e, 0x74, 0x69, 0x74, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2e, 0x76, + 0x30, 0x2e, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x06, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, + 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x02, 0x52, + 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x42, 0x3f, 0x5a, 0x3d, 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, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2f, 0x73, 0x65, + 0x61, 0x72, 0x63, 0x68, 0x2f, 0x76, 0x30, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_ocis_messages_search_v0_search_proto_rawDescOnce sync.Once + file_ocis_messages_search_v0_search_proto_rawDescData = file_ocis_messages_search_v0_search_proto_rawDesc +) + +func file_ocis_messages_search_v0_search_proto_rawDescGZIP() []byte { + file_ocis_messages_search_v0_search_proto_rawDescOnce.Do(func() { + file_ocis_messages_search_v0_search_proto_rawDescData = protoimpl.X.CompressGZIP(file_ocis_messages_search_v0_search_proto_rawDescData) + }) + return file_ocis_messages_search_v0_search_proto_rawDescData +} + +var file_ocis_messages_search_v0_search_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_ocis_messages_search_v0_search_proto_goTypes = []interface{}{ + (*ResourceID)(nil), // 0: ocis.messages.search.v0.ResourceID + (*Reference)(nil), // 1: ocis.messages.search.v0.Reference + (*Entity)(nil), // 2: ocis.messages.search.v0.Entity + (*Match)(nil), // 3: ocis.messages.search.v0.Match +} +var file_ocis_messages_search_v0_search_proto_depIdxs = []int32{ + 0, // 0: ocis.messages.search.v0.Reference.resource_id:type_name -> ocis.messages.search.v0.ResourceID + 1, // 1: ocis.messages.search.v0.Entity.ref:type_name -> ocis.messages.search.v0.Reference + 0, // 2: ocis.messages.search.v0.Entity.id:type_name -> ocis.messages.search.v0.ResourceID + 2, // 3: ocis.messages.search.v0.Match.entity:type_name -> ocis.messages.search.v0.Entity + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_ocis_messages_search_v0_search_proto_init() } +func file_ocis_messages_search_v0_search_proto_init() { + if File_ocis_messages_search_v0_search_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_ocis_messages_search_v0_search_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ResourceID); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ocis_messages_search_v0_search_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Reference); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ocis_messages_search_v0_search_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Entity); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ocis_messages_search_v0_search_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Match); 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{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_ocis_messages_search_v0_search_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_ocis_messages_search_v0_search_proto_goTypes, + DependencyIndexes: file_ocis_messages_search_v0_search_proto_depIdxs, + MessageInfos: file_ocis_messages_search_v0_search_proto_msgTypes, + }.Build() + File_ocis_messages_search_v0_search_proto = out.File + file_ocis_messages_search_v0_search_proto_rawDesc = nil + file_ocis_messages_search_v0_search_proto_goTypes = nil + file_ocis_messages_search_v0_search_proto_depIdxs = nil +} diff --git a/protogen/gen/ocis/messages/search/v0/search.pb.micro.go b/protogen/gen/ocis/messages/search/v0/search.pb.micro.go new file mode 100644 index 000000000..5f507f0ae --- /dev/null +++ b/protogen/gen/ocis/messages/search/v0/search.pb.micro.go @@ -0,0 +1,15 @@ +// Code generated by protoc-gen-micro. DO NOT EDIT. +// source: ocis/messages/search/v0/search.proto + +package v0 + +import ( + fmt "fmt" + proto "google.golang.org/protobuf/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf diff --git a/protogen/gen/ocis/messages/search/v0/search.pb.web.go b/protogen/gen/ocis/messages/search/v0/search.pb.web.go new file mode 100644 index 000000000..7055e8349 --- /dev/null +++ b/protogen/gen/ocis/messages/search/v0/search.pb.web.go @@ -0,0 +1,155 @@ +// Code generated by protoc-gen-microweb. DO NOT EDIT. +// source: v0.proto + +package v0 + +import ( + "bytes" + "encoding/json" + + "github.com/golang/protobuf/jsonpb" +) + +// ResourceIDJSONMarshaler describes the default jsonpb.Marshaler used by all +// instances of ResourceID. This struct is safe to replace or modify but +// should not be done so concurrently. +var ResourceIDJSONMarshaler = 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 *ResourceID) MarshalJSON() ([]byte, error) { + if m == nil { + return json.Marshal(nil) + } + + buf := &bytes.Buffer{} + + if err := ResourceIDJSONMarshaler.Marshal(buf, m); err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +var _ json.Marshaler = (*ResourceID)(nil) + +// ResourceIDJSONUnmarshaler describes the default jsonpb.Unmarshaler used by all +// instances of ResourceID. This struct is safe to replace or modify but +// should not be done so concurrently. +var ResourceIDJSONUnmarshaler = 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 *ResourceID) UnmarshalJSON(b []byte) error { + return ResourceIDJSONUnmarshaler.Unmarshal(bytes.NewReader(b), m) +} + +var _ json.Unmarshaler = (*ResourceID)(nil) + +// ReferenceJSONMarshaler describes the default jsonpb.Marshaler used by all +// instances of Reference. This struct is safe to replace or modify but +// should not be done so concurrently. +var ReferenceJSONMarshaler = 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 *Reference) MarshalJSON() ([]byte, error) { + if m == nil { + return json.Marshal(nil) + } + + buf := &bytes.Buffer{} + + if err := ReferenceJSONMarshaler.Marshal(buf, m); err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +var _ json.Marshaler = (*Reference)(nil) + +// ReferenceJSONUnmarshaler describes the default jsonpb.Unmarshaler used by all +// instances of Reference. This struct is safe to replace or modify but +// should not be done so concurrently. +var ReferenceJSONUnmarshaler = 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 *Reference) UnmarshalJSON(b []byte) error { + return ReferenceJSONUnmarshaler.Unmarshal(bytes.NewReader(b), m) +} + +var _ json.Unmarshaler = (*Reference)(nil) + +// EntityJSONMarshaler describes the default jsonpb.Marshaler used by all +// instances of Entity. This struct is safe to replace or modify but +// should not be done so concurrently. +var EntityJSONMarshaler = 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 *Entity) MarshalJSON() ([]byte, error) { + if m == nil { + return json.Marshal(nil) + } + + buf := &bytes.Buffer{} + + if err := EntityJSONMarshaler.Marshal(buf, m); err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +var _ json.Marshaler = (*Entity)(nil) + +// EntityJSONUnmarshaler describes the default jsonpb.Unmarshaler used by all +// instances of Entity. This struct is safe to replace or modify but +// should not be done so concurrently. +var EntityJSONUnmarshaler = 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 *Entity) UnmarshalJSON(b []byte) error { + return EntityJSONUnmarshaler.Unmarshal(bytes.NewReader(b), m) +} + +var _ json.Unmarshaler = (*Entity)(nil) + +// MatchJSONMarshaler describes the default jsonpb.Marshaler used by all +// instances of Match. This struct is safe to replace or modify but +// should not be done so concurrently. +var MatchJSONMarshaler = 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 *Match) MarshalJSON() ([]byte, error) { + if m == nil { + return json.Marshal(nil) + } + + buf := &bytes.Buffer{} + + if err := MatchJSONMarshaler.Marshal(buf, m); err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +var _ json.Marshaler = (*Match)(nil) + +// MatchJSONUnmarshaler describes the default jsonpb.Unmarshaler used by all +// instances of Match. This struct is safe to replace or modify but +// should not be done so concurrently. +var MatchJSONUnmarshaler = 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 *Match) UnmarshalJSON(b []byte) error { + return MatchJSONUnmarshaler.Unmarshal(bytes.NewReader(b), m) +} + +var _ json.Unmarshaler = (*Match)(nil) diff --git a/protogen/gen/ocis/messages/search/v0/search.swagger.json b/protogen/gen/ocis/messages/search/v0/search.swagger.json new file mode 100644 index 000000000..dd7fdc358 --- /dev/null +++ b/protogen/gen/ocis/messages/search/v0/search.swagger.json @@ -0,0 +1,43 @@ +{ + "swagger": "2.0", + "info": { + "title": "ocis/messages/search/v0/search.proto", + "version": "version not set" + }, + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": {}, + "definitions": { + "protobufAny": { + "type": "object", + "properties": { + "@type": { + "type": "string" + } + }, + "additionalProperties": {} + }, + "rpcStatus": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "details": { + "type": "array", + "items": { + "$ref": "#/definitions/protobufAny" + } + } + } + } + } +} diff --git a/protogen/gen/ocis/services/search/v0/search.pb.go b/protogen/gen/ocis/services/search/v0/search.pb.go new file mode 100644 index 000000000..73d450a6b --- /dev/null +++ b/protogen/gen/ocis/services/search/v0/search.pb.go @@ -0,0 +1,485 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.1 +// protoc v3.17.3 +// source: ocis/services/search/v0/search.proto + +package v0 + +import ( + _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" + v0 "github.com/owncloud/ocis/protogen/gen/ocis/messages/search/v0" + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + _ "google.golang.org/protobuf/types/known/fieldmaskpb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type SearchRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Optional. The maximum number of entries to return in the response + PageSize int32 `protobuf:"varint,1,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` + // Optional. A pagination token returned from a previous call to `Get` + // that indicates from where search should continue + PageToken string `protobuf:"bytes,2,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` + Query string `protobuf:"bytes,3,opt,name=query,proto3" json:"query,omitempty"` +} + +func (x *SearchRequest) Reset() { + *x = SearchRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_ocis_services_search_v0_search_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SearchRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SearchRequest) ProtoMessage() {} + +func (x *SearchRequest) ProtoReflect() protoreflect.Message { + mi := &file_ocis_services_search_v0_search_proto_msgTypes[0] + 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 SearchRequest.ProtoReflect.Descriptor instead. +func (*SearchRequest) Descriptor() ([]byte, []int) { + return file_ocis_services_search_v0_search_proto_rawDescGZIP(), []int{0} +} + +func (x *SearchRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *SearchRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *SearchRequest) GetQuery() string { + if x != nil { + return x.Query + } + return "" +} + +type SearchResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Matches []*v0.Match `protobuf:"bytes,1,rep,name=matches,proto3" json:"matches,omitempty"` + // Token to retrieve the next page of results, or empty if there are no + // more results in the list + NextPageToken string `protobuf:"bytes,2,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` +} + +func (x *SearchResponse) Reset() { + *x = SearchResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_ocis_services_search_v0_search_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SearchResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SearchResponse) ProtoMessage() {} + +func (x *SearchResponse) ProtoReflect() protoreflect.Message { + mi := &file_ocis_services_search_v0_search_proto_msgTypes[1] + 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 SearchResponse.ProtoReflect.Descriptor instead. +func (*SearchResponse) Descriptor() ([]byte, []int) { + return file_ocis_services_search_v0_search_proto_rawDescGZIP(), []int{1} +} + +func (x *SearchResponse) GetMatches() []*v0.Match { + if x != nil { + return x.Matches + } + return nil +} + +func (x *SearchResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +type SearchIndexRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Optional. The maximum number of entries to return in the response + PageSize int32 `protobuf:"varint,1,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` + // Optional. A pagination token returned from a previous call to `Get` + // that indicates from where search should continue + PageToken string `protobuf:"bytes,2,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` + Query string `protobuf:"bytes,3,opt,name=query,proto3" json:"query,omitempty"` + Ref *v0.Reference `protobuf:"bytes,4,opt,name=ref,proto3" json:"ref,omitempty"` +} + +func (x *SearchIndexRequest) Reset() { + *x = SearchIndexRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_ocis_services_search_v0_search_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SearchIndexRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SearchIndexRequest) ProtoMessage() {} + +func (x *SearchIndexRequest) ProtoReflect() protoreflect.Message { + mi := &file_ocis_services_search_v0_search_proto_msgTypes[2] + 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 SearchIndexRequest.ProtoReflect.Descriptor instead. +func (*SearchIndexRequest) Descriptor() ([]byte, []int) { + return file_ocis_services_search_v0_search_proto_rawDescGZIP(), []int{2} +} + +func (x *SearchIndexRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *SearchIndexRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *SearchIndexRequest) GetQuery() string { + if x != nil { + return x.Query + } + return "" +} + +func (x *SearchIndexRequest) GetRef() *v0.Reference { + if x != nil { + return x.Ref + } + return nil +} + +type SearchIndexResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Matches []*v0.Match `protobuf:"bytes,1,rep,name=matches,proto3" json:"matches,omitempty"` + // Token to retrieve the next page of results, or empty if there are no + // more results in the list + NextPageToken string `protobuf:"bytes,2,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` +} + +func (x *SearchIndexResponse) Reset() { + *x = SearchIndexResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_ocis_services_search_v0_search_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SearchIndexResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SearchIndexResponse) ProtoMessage() {} + +func (x *SearchIndexResponse) ProtoReflect() protoreflect.Message { + mi := &file_ocis_services_search_v0_search_proto_msgTypes[3] + 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 SearchIndexResponse.ProtoReflect.Descriptor instead. +func (*SearchIndexResponse) Descriptor() ([]byte, []int) { + return file_ocis_services_search_v0_search_proto_rawDescGZIP(), []int{3} +} + +func (x *SearchIndexResponse) GetMatches() []*v0.Match { + if x != nil { + return x.Matches + } + return nil +} + +func (x *SearchIndexResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +var File_ocis_services_search_v0_search_proto protoreflect.FileDescriptor + +var file_ocis_services_search_v0_search_proto_rawDesc = []byte{ + 0x0a, 0x24, 0x6f, 0x63, 0x69, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, + 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2f, 0x76, 0x30, 0x2f, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x17, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2e, 0x76, 0x30, 0x1a, + 0x24, 0x6f, 0x63, 0x69, 0x73, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2f, 0x73, + 0x65, 0x61, 0x72, 0x63, 0x68, 0x2f, 0x76, 0x30, 0x2f, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, + 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, + 0x69, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, + 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6d, 0x0a, 0x0d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, + 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x01, + 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x23, 0x0a, 0x0a, 0x70, 0x61, + 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, + 0xe2, 0x41, 0x01, 0x01, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, + 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x71, 0x75, 0x65, 0x72, 0x79, 0x22, 0x72, 0x0a, 0x0e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x38, 0x0a, 0x07, 0x6d, 0x61, 0x74, 0x63, 0x68, + 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2e, + 0x76, 0x30, 0x2e, 0x4d, 0x61, 0x74, 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, 0x22, 0xae, 0x01, 0x0a, 0x12, 0x53, 0x65, + 0x61, 0x72, 0x63, 0x68, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x21, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x01, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, + 0x69, 0x7a, 0x65, 0x12, 0x23, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, + 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x01, 0x52, 0x09, 0x70, + 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, + 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x3a, + 0x0a, 0x03, 0x72, 0x65, 0x66, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x6f, 0x63, + 0x69, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x73, 0x65, 0x61, 0x72, + 0x63, 0x68, 0x2e, 0x76, 0x30, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, + 0x04, 0xe2, 0x41, 0x01, 0x01, 0x52, 0x03, 0x72, 0x65, 0x66, 0x22, 0x77, 0x0a, 0x13, 0x53, 0x65, + 0x61, 0x72, 0x63, 0x68, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x38, 0x0a, 0x07, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x73, 0x2e, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2e, 0x76, 0x30, 0x2e, 0x4d, 0x61, 0x74, + 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, + 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 ( + file_ocis_services_search_v0_search_proto_rawDescOnce sync.Once + file_ocis_services_search_v0_search_proto_rawDescData = file_ocis_services_search_v0_search_proto_rawDesc +) + +func file_ocis_services_search_v0_search_proto_rawDescGZIP() []byte { + file_ocis_services_search_v0_search_proto_rawDescOnce.Do(func() { + file_ocis_services_search_v0_search_proto_rawDescData = protoimpl.X.CompressGZIP(file_ocis_services_search_v0_search_proto_rawDescData) + }) + 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_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 +} +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 + 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 + 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 +} + +func init() { file_ocis_services_search_v0_search_proto_init() } +func file_ocis_services_search_v0_search_proto_init() { + if File_ocis_services_search_v0_search_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_ocis_services_search_v0_search_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SearchRequest); 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[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SearchResponse); 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[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SearchIndexRequest); 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[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SearchIndexResponse); 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{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_ocis_services_search_v0_search_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 2, + }, + GoTypes: file_ocis_services_search_v0_search_proto_goTypes, + DependencyIndexes: file_ocis_services_search_v0_search_proto_depIdxs, + MessageInfos: file_ocis_services_search_v0_search_proto_msgTypes, + }.Build() + File_ocis_services_search_v0_search_proto = out.File + file_ocis_services_search_v0_search_proto_rawDesc = nil + file_ocis_services_search_v0_search_proto_goTypes = nil + file_ocis_services_search_v0_search_proto_depIdxs = nil +} diff --git a/protogen/gen/ocis/services/search/v0/search.pb.micro.go b/protogen/gen/ocis/services/search/v0/search.pb.micro.go new file mode 100644 index 000000000..2c45e6a7e --- /dev/null +++ b/protogen/gen/ocis/services/search/v0/search.pb.micro.go @@ -0,0 +1,180 @@ +// Code generated by protoc-gen-micro. DO NOT EDIT. +// source: ocis/services/search/v0/search.proto + +package v0 + +import ( + fmt "fmt" + _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" + _ "github.com/owncloud/ocis/protogen/gen/ocis/messages/search/v0" + _ "google.golang.org/genproto/googleapis/api/annotations" + proto "google.golang.org/protobuf/proto" + _ "google.golang.org/protobuf/types/known/fieldmaskpb" + math "math" +) + +import ( + context "context" + api "go-micro.dev/v4/api" + client "go-micro.dev/v4/client" + server "go-micro.dev/v4/server" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// Reference imports to suppress errors if they are not otherwise used. +var _ api.Endpoint +var _ context.Context +var _ client.Option +var _ server.Option + +// Api Endpoints for SearchProvider service + +func NewSearchProviderEndpoints() []*api.Endpoint { + return []*api.Endpoint{ + { + Name: "SearchProvider.Search", + Path: []string{"/api/v0/search/search"}, + Method: []string{"POST"}, + Body: "*", + Handler: "rpc", + }, + } +} + +// Client API for SearchProvider service + +type SearchProviderService interface { + Search(ctx context.Context, in *SearchRequest, opts ...client.CallOption) (*SearchResponse, error) +} + +type searchProviderService struct { + c client.Client + name string +} + +func NewSearchProviderService(name string, c client.Client) SearchProviderService { + return &searchProviderService{ + c: c, + name: name, + } +} + +func (c *searchProviderService) Search(ctx context.Context, in *SearchRequest, opts ...client.CallOption) (*SearchResponse, error) { + req := c.c.NewRequest(c.name, "SearchProvider.Search", in) + out := new(SearchResponse) + 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 +} + +func RegisterSearchProviderHandler(s server.Server, hdlr SearchProviderHandler, opts ...server.HandlerOption) error { + type searchProvider interface { + Search(ctx context.Context, in *SearchRequest, out *SearchResponse) error + } + type SearchProvider struct { + searchProvider + } + h := &searchProviderHandler{hdlr} + opts = append(opts, api.WithEndpoint(&api.Endpoint{ + Name: "SearchProvider.Search", + Path: []string{"/api/v0/search/search"}, + Method: []string{"POST"}, + Body: "*", + Handler: "rpc", + })) + return s.Handle(s.NewHandler(&SearchProvider{h}, opts...)) +} + +type searchProviderHandler struct { + SearchProviderHandler +} + +func (h *searchProviderHandler) Search(ctx context.Context, in *SearchRequest, out *SearchResponse) error { + return h.SearchProviderHandler.Search(ctx, in, out) +} + +// Api Endpoints for IndexProvider service + +func NewIndexProviderEndpoints() []*api.Endpoint { + return []*api.Endpoint{ + { + Name: "IndexProvider.Search", + Path: []string{"/api/v0/search/index/search"}, + Method: []string{"POST"}, + Body: "*", + Handler: "rpc", + }, + } +} + +// Client API for IndexProvider service + +type IndexProviderService interface { + Search(ctx context.Context, in *SearchIndexRequest, opts ...client.CallOption) (*SearchIndexResponse, error) +} + +type indexProviderService struct { + c client.Client + name string +} + +func NewIndexProviderService(name string, c client.Client) IndexProviderService { + return &indexProviderService{ + c: c, + name: name, + } +} + +func (c *indexProviderService) Search(ctx context.Context, in *SearchIndexRequest, opts ...client.CallOption) (*SearchIndexResponse, error) { + req := c.c.NewRequest(c.name, "IndexProvider.Search", in) + out := new(SearchIndexResponse) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// Server API for IndexProvider service + +type IndexProviderHandler interface { + Search(context.Context, *SearchIndexRequest, *SearchIndexResponse) error +} + +func RegisterIndexProviderHandler(s server.Server, hdlr IndexProviderHandler, opts ...server.HandlerOption) error { + type indexProvider interface { + Search(ctx context.Context, in *SearchIndexRequest, out *SearchIndexResponse) error + } + type IndexProvider struct { + indexProvider + } + h := &indexProviderHandler{hdlr} + opts = append(opts, api.WithEndpoint(&api.Endpoint{ + Name: "IndexProvider.Search", + Path: []string{"/api/v0/search/index/search"}, + Method: []string{"POST"}, + Body: "*", + Handler: "rpc", + })) + return s.Handle(s.NewHandler(&IndexProvider{h}, opts...)) +} + +type indexProviderHandler struct { + IndexProviderHandler +} + +func (h *indexProviderHandler) Search(ctx context.Context, in *SearchIndexRequest, out *SearchIndexResponse) error { + return h.IndexProviderHandler.Search(ctx, in, out) +} diff --git a/protogen/gen/ocis/services/search/v0/search.pb.web.go b/protogen/gen/ocis/services/search/v0/search.pb.web.go new file mode 100644 index 000000000..46105d330 --- /dev/null +++ b/protogen/gen/ocis/services/search/v0/search.pb.web.go @@ -0,0 +1,238 @@ +// Code generated by protoc-gen-microweb. DO NOT EDIT. +// source: v0.proto + +package v0 + +import ( + "bytes" + "encoding/json" + "net/http" + + "github.com/go-chi/chi/v5" + "github.com/go-chi/render" + "github.com/golang/protobuf/jsonpb" +) + +type webSearchProviderHandler struct { + r chi.Router + h SearchProviderHandler +} + +func (h *webSearchProviderHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + h.r.ServeHTTP(w, r) +} + +func (h *webSearchProviderHandler) Search(w http.ResponseWriter, r *http.Request) { + req := &SearchRequest{} + resp := &SearchResponse{} + + if err := json.NewDecoder(r.Body).Decode(&req); err != nil { + http.Error(w, err.Error(), http.StatusPreconditionFailed) + return + } + + if err := h.h.Search( + 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, + h: i, + } + + r.MethodFunc("POST", "/api/v0/search/search", handler.Search) +} + +type webIndexProviderHandler struct { + r chi.Router + h IndexProviderHandler +} + +func (h *webIndexProviderHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + h.r.ServeHTTP(w, r) +} + +func (h *webIndexProviderHandler) Search(w http.ResponseWriter, r *http.Request) { + req := &SearchIndexRequest{} + resp := &SearchIndexResponse{} + + if err := json.NewDecoder(r.Body).Decode(&req); err != nil { + http.Error(w, err.Error(), http.StatusPreconditionFailed) + return + } + + if err := h.h.Search( + 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 RegisterIndexProviderWeb(r chi.Router, i IndexProviderHandler, middlewares ...func(http.Handler) http.Handler) { + handler := &webIndexProviderHandler{ + r: r, + h: i, + } + + r.MethodFunc("POST", "/api/v0/search/index/search", handler.Search) +} + +// SearchRequestJSONMarshaler describes the default jsonpb.Marshaler used by all +// instances of SearchRequest. This struct is safe to replace or modify but +// should not be done so concurrently. +var SearchRequestJSONMarshaler = 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 *SearchRequest) MarshalJSON() ([]byte, error) { + if m == nil { + return json.Marshal(nil) + } + + buf := &bytes.Buffer{} + + if err := SearchRequestJSONMarshaler.Marshal(buf, m); err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +var _ json.Marshaler = (*SearchRequest)(nil) + +// SearchRequestJSONUnmarshaler describes the default jsonpb.Unmarshaler used by all +// instances of SearchRequest. This struct is safe to replace or modify but +// should not be done so concurrently. +var SearchRequestJSONUnmarshaler = 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 *SearchRequest) UnmarshalJSON(b []byte) error { + return SearchRequestJSONUnmarshaler.Unmarshal(bytes.NewReader(b), m) +} + +var _ json.Unmarshaler = (*SearchRequest)(nil) + +// SearchResponseJSONMarshaler describes the default jsonpb.Marshaler used by all +// instances of SearchResponse. This struct is safe to replace or modify but +// should not be done so concurrently. +var SearchResponseJSONMarshaler = 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 *SearchResponse) MarshalJSON() ([]byte, error) { + if m == nil { + return json.Marshal(nil) + } + + buf := &bytes.Buffer{} + + if err := SearchResponseJSONMarshaler.Marshal(buf, m); err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +var _ json.Marshaler = (*SearchResponse)(nil) + +// SearchResponseJSONUnmarshaler describes the default jsonpb.Unmarshaler used by all +// instances of SearchResponse. This struct is safe to replace or modify but +// should not be done so concurrently. +var SearchResponseJSONUnmarshaler = 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 *SearchResponse) UnmarshalJSON(b []byte) error { + return SearchResponseJSONUnmarshaler.Unmarshal(bytes.NewReader(b), m) +} + +var _ json.Unmarshaler = (*SearchResponse)(nil) + +// SearchIndexRequestJSONMarshaler describes the default jsonpb.Marshaler used by all +// instances of SearchIndexRequest. This struct is safe to replace or modify but +// should not be done so concurrently. +var SearchIndexRequestJSONMarshaler = 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 *SearchIndexRequest) MarshalJSON() ([]byte, error) { + if m == nil { + return json.Marshal(nil) + } + + buf := &bytes.Buffer{} + + if err := SearchIndexRequestJSONMarshaler.Marshal(buf, m); err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +var _ json.Marshaler = (*SearchIndexRequest)(nil) + +// SearchIndexRequestJSONUnmarshaler describes the default jsonpb.Unmarshaler used by all +// instances of SearchIndexRequest. This struct is safe to replace or modify but +// should not be done so concurrently. +var SearchIndexRequestJSONUnmarshaler = 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 *SearchIndexRequest) UnmarshalJSON(b []byte) error { + return SearchIndexRequestJSONUnmarshaler.Unmarshal(bytes.NewReader(b), m) +} + +var _ json.Unmarshaler = (*SearchIndexRequest)(nil) + +// SearchIndexResponseJSONMarshaler describes the default jsonpb.Marshaler used by all +// instances of SearchIndexResponse. This struct is safe to replace or modify but +// should not be done so concurrently. +var SearchIndexResponseJSONMarshaler = 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 *SearchIndexResponse) MarshalJSON() ([]byte, error) { + if m == nil { + return json.Marshal(nil) + } + + buf := &bytes.Buffer{} + + if err := SearchIndexResponseJSONMarshaler.Marshal(buf, m); err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +var _ json.Marshaler = (*SearchIndexResponse)(nil) + +// SearchIndexResponseJSONUnmarshaler describes the default jsonpb.Unmarshaler used by all +// instances of SearchIndexResponse. This struct is safe to replace or modify but +// should not be done so concurrently. +var SearchIndexResponseJSONUnmarshaler = 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 *SearchIndexResponse) UnmarshalJSON(b []byte) error { + return SearchIndexResponseJSONUnmarshaler.Unmarshal(bytes.NewReader(b), m) +} + +var _ json.Unmarshaler = (*SearchIndexResponse)(nil) diff --git a/protogen/gen/ocis/services/search/v0/search.swagger.json b/protogen/gen/ocis/services/search/v0/search.swagger.json new file mode 100644 index 000000000..8b582b7ad --- /dev/null +++ b/protogen/gen/ocis/services/search/v0/search.swagger.json @@ -0,0 +1,254 @@ +{ + "swagger": "2.0", + "info": { + "title": "ownCloud Infinite Scale search", + "version": "1.0.0", + "contact": { + "name": "ownCloud GmbH", + "url": "https://github.com/owncloud/ocis", + "email": "support@owncloud.com" + }, + "license": { + "name": "Apache-2.0", + "url": "https://github.com/owncloud/ocis/blob/master/LICENSE" + } + }, + "tags": [ + { + "name": "SearchProvider" + }, + { + "name": "IndexProvider" + } + ], + "schemes": [ + "http", + "https" + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/api/v0/search/index/search": { + "post": { + "operationId": "IndexProvider_Search", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v0SearchIndexResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v0SearchIndexRequest" + } + } + ], + "tags": [ + "IndexProvider" + ] + } + }, + "/api/v0/search/search": { + "post": { + "operationId": "SearchProvider_Search", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v0SearchResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v0SearchRequest" + } + } + ], + "tags": [ + "SearchProvider" + ] + } + } + }, + "definitions": { + "protobufAny": { + "type": "object", + "properties": { + "@type": { + "type": "string" + } + }, + "additionalProperties": {} + }, + "rpcStatus": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "details": { + "type": "array", + "items": { + "$ref": "#/definitions/protobufAny" + } + } + } + }, + "v0Entity": { + "type": "object", + "properties": { + "ref": { + "$ref": "#/definitions/v0Reference" + }, + "id": { + "$ref": "#/definitions/v0ResourceID" + }, + "name": { + "type": "string" + }, + "size": { + "type": "string", + "format": "int64" + } + } + }, + "v0Match": { + "type": "object", + "properties": { + "entity": { + "$ref": "#/definitions/v0Entity", + "title": "the matched entity" + }, + "score": { + "type": "number", + "format": "float", + "title": "the match score" + } + } + }, + "v0Reference": { + "type": "object", + "properties": { + "resourceId": { + "$ref": "#/definitions/v0ResourceID" + }, + "path": { + "type": "string" + } + } + }, + "v0ResourceID": { + "type": "object", + "properties": { + "storageId": { + "type": "string" + }, + "opaqueId": { + "type": "string" + } + } + }, + "v0SearchIndexRequest": { + "type": "object", + "properties": { + "pageSize": { + "type": "integer", + "format": "int32", + "title": "Optional. The maximum number of entries to return in the response" + }, + "pageToken": { + "type": "string", + "title": "Optional. A pagination token returned from a previous call to `Get`\nthat indicates from where search should continue" + }, + "query": { + "type": "string" + }, + "ref": { + "$ref": "#/definitions/v0Reference" + } + } + }, + "v0SearchIndexResponse": { + "type": "object", + "properties": { + "matches": { + "type": "array", + "items": { + "$ref": "#/definitions/v0Match" + } + }, + "nextPageToken": { + "type": "string", + "title": "Token to retrieve the next page of results, or empty if there are no\nmore results in the list" + } + } + }, + "v0SearchRequest": { + "type": "object", + "properties": { + "pageSize": { + "type": "integer", + "format": "int32", + "title": "Optional. The maximum number of entries to return in the response" + }, + "pageToken": { + "type": "string", + "title": "Optional. A pagination token returned from a previous call to `Get`\nthat indicates from where search should continue" + }, + "query": { + "type": "string" + } + } + }, + "v0SearchResponse": { + "type": "object", + "properties": { + "matches": { + "type": "array", + "items": { + "$ref": "#/definitions/v0Match" + } + }, + "nextPageToken": { + "type": "string", + "title": "Token to retrieve the next page of results, or empty if there are no\nmore results in the list" + } + } + } + }, + "externalDocs": { + "description": "Developer Manual", + "url": "https://owncloud.dev/extensions/search/" + } +} diff --git a/protogen/proto/ocis/messages/search/search.proto b/protogen/proto/ocis/messages/search/search.proto deleted file mode 100644 index 948e5fd2a..000000000 --- a/protogen/proto/ocis/messages/search/search.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; - -package ocis.messages.search.v0; - -option go_package = "github.com/owncloud/ocis/protogen/gen/ocis/messages/search/v0"; - -message Match { - // key of the recorda - string key = 1; - // value in the record - bytes value = 2; - // time.Duration (signed int64 nanoseconds) - int64 expiry = 3; - // the associated metadata - map metadata = 4; -} \ No newline at end of file diff --git a/protogen/proto/ocis/messages/search/v0/search.proto b/protogen/proto/ocis/messages/search/v0/search.proto new file mode 100644 index 000000000..cf46dd348 --- /dev/null +++ b/protogen/proto/ocis/messages/search/v0/search.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; + +package ocis.messages.search.v0; + +option go_package = "github.com/owncloud/ocis/protogen/gen/ocis/messages/search/v0"; + +message ResourceID { + string storage_id = 1; + string opaque_id = 2; +} + +message Reference { + ResourceID resource_id = 1; + string path = 2; +} + +message Entity { + Reference ref = 1; + ResourceID id = 2; + string name = 3; + int64 size = 4; +} + +message Match { + // the matched entity + Entity entity = 1; + // the match score + float score = 2; +} \ No newline at end of file diff --git a/protogen/proto/ocis/services/search/search.proto b/protogen/proto/ocis/services/search/search.proto deleted file mode 100644 index 7f95a226d..000000000 --- a/protogen/proto/ocis/services/search/search.proto +++ /dev/null @@ -1,84 +0,0 @@ -syntax = "proto3"; - -package ocis.services.search.v0; - -option go_package = "github.com/owncloud/ocis/protogen/gen/ocis/service/search/v0"; - -import "ocis/messages/search/v0/search.proto"; -import "protoc-gen-openapiv2/options/annotations.proto"; -import "cs3/storage/provider/v1beta1/resources.proto"; - -option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { - info: { - title: "ownCloud Infinite Scale search"; - version: "1.0.0"; - contact: { - name: "ownCloud GmbH"; - url: "https://github.com/owncloud/ocis"; - email: "support@owncloud.com"; - }; - license: { - name: "Apache-2.0"; - url: "https://github.com/owncloud/ocis/blob/master/LICENSE"; - }; - }; - schemes: HTTP; - schemes: HTTPS; - consumes: "application/json"; - produces: "application/json"; - external_docs: { - description: "Developer Manual"; - url: "https://owncloud.dev/extensions/search/"; - }; -}; - -service SearchProvider { - rpc Search(SearchRequest) returns (SearchResponse) {}; -} - -service IndexProvider { - rpc Search(SearchIndexRequest) returns (SearchIndexResponse) {}; - rpc Index(IndexRequest) returns (IndexResponse) {}; - rpc Remove(RemoveRequest) returns (RemoveResponse) {}; -} - -message SearchRequest { - // Optional. The maximum number of entries to return in the response - int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A pagination token returned from a previous call to `Get` - // that indicates from where search should continue - string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Used to specify a subset of fields that should be - // returned by a get operation or modified by an update operation. - google.protobuf.FieldMask field_mask = 3; - string query = 4; -} - -message SearchResponse { - repeated ocis.messages.search.v0.Match matches = 1; - - // 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 SearchIndexRequest { - // Optional. The maximum number of entries to return in the response - int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A pagination token returned from a previous call to `Get` - // that indicates from where search should continue - string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Used to specify a subset of fields that should be - // returned by a get operation or modified by an update operation. - google.protobuf.FieldMask field_mask = 3; - string query = 4; - string -} - -message SearchIndexResponse { - repeated ocis.messages.search.v0.Record records = 1; -} diff --git a/protogen/proto/ocis/services/search/v0/search.proto b/protogen/proto/ocis/services/search/v0/search.proto new file mode 100644 index 000000000..8bc8fb392 --- /dev/null +++ b/protogen/proto/ocis/services/search/v0/search.proto @@ -0,0 +1,95 @@ +syntax = "proto3"; + +package ocis.services.search.v0; + +option go_package = "github.com/owncloud/ocis/protogen/gen/ocis/service/search/v0"; + +import "ocis/messages/search/v0/search.proto"; +import "protoc-gen-openapiv2/options/annotations.proto"; +import "google/api/field_behavior.proto"; +import "google/api/annotations.proto"; +import "google/protobuf/field_mask.proto"; + +option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { + info: { + title: "ownCloud Infinite Scale search"; + version: "1.0.0"; + contact: { + name: "ownCloud GmbH"; + url: "https://github.com/owncloud/ocis"; + email: "support@owncloud.com"; + }; + license: { + name: "Apache-2.0"; + url: "https://github.com/owncloud/ocis/blob/master/LICENSE"; + }; + }; + schemes: HTTP; + schemes: HTTPS; + consumes: "application/json"; + produces: "application/json"; + external_docs: { + description: "Developer Manual"; + url: "https://owncloud.dev/extensions/search/"; + }; +}; + +service SearchProvider { + rpc Search(SearchRequest) returns (SearchResponse) { + // List method maps to HTTP GET + option (google.api.http) = { + post: "/api/v0/search/search", + 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: "*" + }; + }; + // rpc Remove(RemoveRequest) returns (RemoveResponse) {}; +} + +message SearchRequest { + // Optional. The maximum number of entries to return in the response + int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A pagination token returned from a previous call to `Get` + // that indicates from where search should continue + string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; + + string query = 3; +} + +message SearchResponse { + repeated ocis.messages.search.v0.Match matches = 1; + + // 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 SearchIndexRequest { + // Optional. The maximum number of entries to return in the response + int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A pagination token returned from a previous call to `Get` + // that indicates from where search should continue + string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; + + string query = 3; + ocis.messages.search.v0.Reference ref = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +message SearchIndexResponse { + repeated ocis.messages.search.v0.Match matches = 1; + + // Token to retrieve the next page of results, or empty if there are no + // more results in the list + string next_page_token = 2; +} \ No newline at end of file diff --git a/search/pkg/command/server.go b/search/pkg/command/server.go index cff21ee66..c09ba5196 100644 --- a/search/pkg/command/server.go +++ b/search/pkg/command/server.go @@ -5,13 +5,14 @@ import ( "fmt" "github.com/oklog/run" - "github.com/owncloud/ocis/idp/pkg/server/http" "github.com/owncloud/ocis/ocis-pkg/version" "github.com/owncloud/ocis/search/pkg/config" "github.com/owncloud/ocis/search/pkg/config/parser" "github.com/owncloud/ocis/search/pkg/logging" "github.com/owncloud/ocis/search/pkg/metrics" "github.com/owncloud/ocis/search/pkg/server/debug" + "github.com/owncloud/ocis/search/pkg/server/grpc" + svc "github.com/owncloud/ocis/search/pkg/service/v0" "github.com/owncloud/ocis/search/pkg/tracing" "github.com/urfave/cli/v2" ) @@ -45,47 +46,40 @@ func Server(cfg *config.Config) *cli.Command { mtrcs.BuildInfo.WithLabelValues(version.String).Set(1) - { - server, err := http.Server( - http.Logger(logger), - http.Context(ctx), - http.Config(cfg), - http.Metrics(mtrcs), - ) + handler, err := svc.New(svc.Logger(logger), svc.Config(cfg)) + if err != nil { + logger.Error().Err(err).Msg("handler init") + return err + } + grpcServer := grpc.Server( + grpc.Config(cfg), + grpc.Logger(logger), + grpc.Name(cfg.Service.Name), + grpc.Context(ctx), + grpc.Metrics(mtrcs), + grpc.Handler(handler), + ) - if err != nil { - logger.Info().Err(err).Str("transport", "http").Msg("Failed to initialize server") - return err - } + gr.Add(grpcServer.Run, func(_ error) { + logger.Info().Str("server", "grpc").Msg("shutting down server") + cancel() + }) - gr.Add(func() error { - return server.Run() - }, func(_ error) { - logger.Info(). - Str("transport", "http"). - Msg("Shutting down server") + server, err := debug.Server( + debug.Logger(logger), + debug.Context(ctx), + debug.Config(cfg), + ) - cancel() - }) + if err != nil { + logger.Info().Err(err).Str("transport", "debug").Msg("Failed to initialize server") + return err } - { - server, err := debug.Server( - debug.Logger(logger), - debug.Context(ctx), - debug.Config(cfg), - ) - - if err != nil { - logger.Info().Err(err).Str("transport", "debug").Msg("Failed to initialize server") - return err - } - - gr.Add(server.ListenAndServe, func(_ error) { - _ = server.Shutdown(ctx) - cancel() - }) - } + gr.Add(server.ListenAndServe, func(_ error) { + _ = server.Shutdown(ctx) + cancel() + }) return gr.Run() }, diff --git a/search/pkg/config/config.go b/search/pkg/config/config.go index 2cc26d055..65e85f028 100644 --- a/search/pkg/config/config.go +++ b/search/pkg/config/config.go @@ -17,6 +17,7 @@ type Config struct { Debug Debug `ocisConfig:"debug"` HTTP HTTP `ocisConfig:"http"` + GRPC GRPC `ocisConfig:"grpc"` Reva Reva `ocisConfig:"reva"` TokenManager TokenManager `ocisConfig:"token_manager"` diff --git a/search/pkg/config/defaults/defaultconfig.go b/search/pkg/config/defaults/defaultconfig.go index 8fc349789..b770cabc1 100644 --- a/search/pkg/config/defaults/defaultconfig.go +++ b/search/pkg/config/defaults/defaultconfig.go @@ -17,6 +17,10 @@ func DefaultConfig() *config.Config { Namespace: "com.owncloud.search", Root: "/search", }, + GRPC: config.GRPC{ + Addr: "127.0.0.1:9180", + Namespace: "com.owncloud.api", + }, Service: config.Service{ Name: "search", }, diff --git a/search/pkg/config/grpc.go b/search/pkg/config/grpc.go new file mode 100644 index 000000000..148fda925 --- /dev/null +++ b/search/pkg/config/grpc.go @@ -0,0 +1,7 @@ +package config + +// GRPC defines the available grpc configuration. +type GRPC struct { + Addr string `ocisConfig:"addr" env:"ACCOUNTS_GRPC_ADDR" desc:"The address of the grpc service."` + Namespace string `ocisConfig:"-" yaml:"-"` +} diff --git a/search/pkg/search/index/index.go b/search/pkg/search/index/index.go index ec8480c2d..5b6b80465 100644 --- a/search/pkg/search/index/index.go +++ b/search/pkg/search/index/index.go @@ -35,16 +35,6 @@ type Index struct { bleveIndex bleve.Index } -// Entity describes an Entity stored in the index -type Entity struct { - RootID string - Path string - ID string - - Name string - Size uint64 -} - // NewPersisted returns a new instance of Index with the data being persisted in the given directory func NewPersisted(path string) (*Index, error) { bi, err := bleve.New(path, BuildMapping()) diff --git a/search/pkg/search/mocks/IndexClient.go b/search/pkg/search/mocks/IndexClient.go index 45f1c25e3..e8a62ceca 100644 --- a/search/pkg/search/mocks/IndexClient.go +++ b/search/pkg/search/mocks/IndexClient.go @@ -5,8 +5,9 @@ package mocks import ( context "context" - search "github.com/owncloud/ocis/search/pkg/search" mock "github.com/stretchr/testify/mock" + + v0 "github.com/owncloud/ocis/protogen/gen/ocis/services/search/v0" ) // IndexClient is an autogenerated mock type for the IndexClient type @@ -15,20 +16,20 @@ type IndexClient struct { } // Search provides a mock function with given fields: ctx, req -func (_m *IndexClient) Search(ctx context.Context, req *search.SearchIndexRequest) (*search.SearchIndexResult, error) { +func (_m *IndexClient) Search(ctx context.Context, req *v0.SearchIndexRequest) (*v0.SearchIndexResponse, error) { ret := _m.Called(ctx, req) - var r0 *search.SearchIndexResult - if rf, ok := ret.Get(0).(func(context.Context, *search.SearchIndexRequest) *search.SearchIndexResult); ok { + var r0 *v0.SearchIndexResponse + if rf, ok := ret.Get(0).(func(context.Context, *v0.SearchIndexRequest) *v0.SearchIndexResponse); ok { r0 = rf(ctx, req) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*search.SearchIndexResult) + r0 = ret.Get(0).(*v0.SearchIndexResponse) } } var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *search.SearchIndexRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *v0.SearchIndexRequest) error); ok { r1 = rf(ctx, req) } else { r1 = ret.Error(1) diff --git a/search/pkg/search/mocks/ProviderClient.go b/search/pkg/search/mocks/ProviderClient.go index 0e097d54e..be426b753 100644 --- a/search/pkg/search/mocks/ProviderClient.go +++ b/search/pkg/search/mocks/ProviderClient.go @@ -5,8 +5,9 @@ package mocks import ( context "context" - search "github.com/owncloud/ocis/search/pkg/search" mock "github.com/stretchr/testify/mock" + + v0 "github.com/owncloud/ocis/protogen/gen/ocis/services/search/v0" ) // ProviderClient is an autogenerated mock type for the ProviderClient type @@ -15,20 +16,20 @@ type ProviderClient struct { } // Search provides a mock function with given fields: ctx, req -func (_m *ProviderClient) Search(ctx context.Context, req *search.SearchRequest) (*search.SearchResult, error) { +func (_m *ProviderClient) Search(ctx context.Context, req *v0.SearchRequest) (*v0.SearchResponse, error) { ret := _m.Called(ctx, req) - var r0 *search.SearchResult - if rf, ok := ret.Get(0).(func(context.Context, *search.SearchRequest) *search.SearchResult); ok { + var r0 *v0.SearchResponse + if rf, ok := ret.Get(0).(func(context.Context, *v0.SearchRequest) *v0.SearchResponse); ok { r0 = rf(ctx, req) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*search.SearchResult) + r0 = ret.Get(0).(*v0.SearchResponse) } } var r1 error - if rf, ok := ret.Get(1).(func(context.Context, *search.SearchRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *v0.SearchRequest) error); ok { r1 = rf(ctx, req) } else { r1 = ret.Error(1) diff --git a/search/pkg/search/provider/searchprovider.go b/search/pkg/search/provider/searchprovider.go index 0afdc4524..b96358b90 100644 --- a/search/pkg/search/provider/searchprovider.go +++ b/search/pkg/search/provider/searchprovider.go @@ -29,6 +29,9 @@ import ( "github.com/cs3org/reva/v2/pkg/errtypes" "github.com/cs3org/reva/v2/pkg/utils" "github.com/owncloud/ocis/search/pkg/search" + + searchmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/search/v0" + searchsvc "github.com/owncloud/ocis/protogen/gen/ocis/services/search/v0" ) type Provider struct { @@ -43,7 +46,7 @@ func New(gwClient gateway.GatewayAPIClient, indexClient search.IndexClient) *Pro } } -func (p *Provider) Search(ctx context.Context, req *search.SearchRequest) (*search.SearchResult, error) { +func (p *Provider) Search(ctx context.Context, req *searchsvc.SearchRequest) (*searchsvc.SearchResponse, error) { if req.Query == "" { return nil, errtypes.PreconditionFailed("empty query provided") } @@ -60,7 +63,7 @@ func (p *Provider) Search(ctx context.Context, req *search.SearchRequest) (*sear return nil, err } - matches := []search.Match{} + matches := []*searchmsg.Match{} for _, space := range listSpacesRes.StorageSpaces { pathPrefix := "" if space.SpaceType == "grant" { @@ -76,11 +79,14 @@ func (p *Provider) Search(ctx context.Context, req *search.SearchRequest) (*sear pathPrefix = utils.MakeRelativePath(gpRes.Path) } - res, err := p.indexClient.Search(ctx, &search.SearchIndexRequest{ + res, err := p.indexClient.Search(ctx, &searchsvc.SearchIndexRequest{ Query: req.Query, - Reference: &providerv1beta1.Reference{ - ResourceId: space.Root, - Path: pathPrefix, + Ref: &searchmsg.Reference{ + ResourceId: &searchmsg.ResourceID{ + StorageId: space.Root.StorageId, + OpaqueId: space.Root.OpaqueId, + }, + Path: pathPrefix, }, }) if err != nil { @@ -89,11 +95,13 @@ func (p *Provider) Search(ctx context.Context, req *search.SearchRequest) (*sear for _, match := range res.Matches { if pathPrefix != "" { - match.Reference.Path = utils.MakeRelativePath(strings.TrimPrefix(match.Reference.Path, pathPrefix)) + match.Entity.Ref.Path = utils.MakeRelativePath(strings.TrimPrefix(match.Entity.Ref.Path, pathPrefix)) } matches = append(matches, match) } } - return &search.SearchResult{Matches: matches}, nil + return &searchsvc.SearchResponse{ + Matches: matches, + }, nil } diff --git a/search/pkg/search/provider/searchprovider_test.go b/search/pkg/search/provider/searchprovider_test.go index 9f57fc45a..575d5d56d 100644 --- a/search/pkg/search/provider/searchprovider_test.go +++ b/search/pkg/search/provider/searchprovider_test.go @@ -30,7 +30,8 @@ import ( typesv1beta1 "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" "github.com/cs3org/reva/v2/pkg/rgrpc/status" cs3mocks "github.com/cs3org/reva/v2/tests/cs3mocks/mocks" - "github.com/owncloud/ocis/search/pkg/search" + searchmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/search/v0" + searchsvc "github.com/owncloud/ocis/protogen/gen/ocis/services/search/v0" "github.com/owncloud/ocis/search/pkg/search/mocks" provider "github.com/owncloud/ocis/search/pkg/search/provider" ) @@ -80,7 +81,7 @@ var _ = Describe("Searchprovider", func() { Describe("Search", func() { It("fails when an empty query is given", func() { - res, err := p.Search(ctx, &search.SearchRequest{ + res, err := p.Search(ctx, &searchsvc.SearchRequest{ Query: "", }) Expect(err).To(HaveOccurred()) @@ -96,19 +97,22 @@ var _ = Describe("Searchprovider", func() { Status: status.NewOK(ctx), StorageSpaces: []*sprovider.StorageSpace{personalSpace}, }, nil) - indexClient.On("Search", mock.Anything, mock.Anything).Return(&search.SearchIndexResult{ - Matches: []search.Match{ + indexClient.On("Search", mock.Anything, mock.Anything).Return(&searchsvc.SearchIndexResponse{ + Matches: []*searchmsg.Match{ { - Reference: &sprovider.Reference{ - ResourceId: personalSpace.Root, - Path: "./path/to/Foo.pdf", - }, - Info: &sprovider.ResourceInfo{ - Id: &sprovider.ResourceId{ + Entity: &searchmsg.Entity{ + Ref: &searchmsg.Reference{ + ResourceId: &searchmsg.ResourceID{ + StorageId: personalSpace.Root.StorageId, + OpaqueId: personalSpace.Root.OpaqueId, + }, + Path: "./path/to/Foo.pdf", + }, + Id: &searchmsg.ResourceID{ StorageId: personalSpace.Root.StorageId, OpaqueId: "foo-id", }, - Path: "Foo.pdf", + Name: "Foo.pdf", }, }, }, @@ -116,20 +120,20 @@ var _ = Describe("Searchprovider", func() { }) It("searches the personal user space", func() { - res, err := p.Search(ctx, &search.SearchRequest{ + res, err := p.Search(ctx, &searchsvc.SearchRequest{ Query: "foo", }) Expect(err).ToNot(HaveOccurred()) Expect(res).ToNot(BeNil()) Expect(len(res.Matches)).To(Equal(1)) match := res.Matches[0] - Expect(match.Info.Id.OpaqueId).To(Equal("foo-id")) - Expect(match.Info.Path).To(Equal("Foo.pdf")) - Expect(match.Reference.ResourceId).To(Equal(personalSpace.Root)) - Expect(match.Reference.Path).To(Equal("./path/to/Foo.pdf")) + Expect(match.Entity.Id.OpaqueId).To(Equal("foo-id")) + Expect(match.Entity.Name).To(Equal("Foo.pdf")) + Expect(match.Entity.Ref.ResourceId.OpaqueId).To(Equal(personalSpace.Root.OpaqueId)) + Expect(match.Entity.Ref.Path).To(Equal("./path/to/Foo.pdf")) - indexClient.AssertCalled(GinkgoT(), "Search", mock.Anything, mock.MatchedBy(func(req *search.SearchIndexRequest) bool { - return req.Query == "foo" && req.Reference.ResourceId == personalSpace.Root && req.Reference.Path == "" + indexClient.AssertCalled(GinkgoT(), "Search", mock.Anything, mock.MatchedBy(func(req *searchsvc.SearchIndexRequest) bool { + return req.Query == "foo" && req.Ref.ResourceId.OpaqueId == personalSpace.Root.OpaqueId && req.Ref.Path == "" })) }) }) @@ -161,38 +165,41 @@ var _ = Describe("Searchprovider", func() { Status: status.NewOK(ctx), StorageSpaces: []*sprovider.StorageSpace{grantSpace}, }, nil) - indexClient.On("Search", mock.Anything, mock.Anything).Return(&search.SearchIndexResult{ - Matches: []search.Match{ + indexClient.On("Search", mock.Anything, mock.Anything).Return(&searchsvc.SearchIndexResponse{ + Matches: []*searchmsg.Match{ { - Reference: &sprovider.Reference{ - ResourceId: grantSpace.Root, - Path: "./grant/path/to/Shared.pdf", - }, - Info: &sprovider.ResourceInfo{ - Id: &sprovider.ResourceId{ + Entity: &searchmsg.Entity{ + Ref: &searchmsg.Reference{ + ResourceId: &searchmsg.ResourceID{ + StorageId: grantSpace.Root.StorageId, + OpaqueId: grantSpace.Root.OpaqueId, + }, + Path: "./grant/path/to/Shared.pdf", + }, + Id: &searchmsg.ResourceID{ StorageId: grantSpace.Root.StorageId, OpaqueId: "grant-shared-id", }, - Path: "Shared.pdf", + Name: "Shared.pdf", }, }, }, }, nil) - res, err := p.Search(ctx, &search.SearchRequest{ + res, err := p.Search(ctx, &searchsvc.SearchRequest{ Query: "foo", }) Expect(err).ToNot(HaveOccurred()) Expect(res).ToNot(BeNil()) Expect(len(res.Matches)).To(Equal(1)) match := res.Matches[0] - Expect(match.Info.Id.OpaqueId).To(Equal("grant-shared-id")) - Expect(match.Info.Path).To(Equal("Shared.pdf")) - Expect(match.Reference.ResourceId).To(Equal(grantSpace.Root)) - Expect(match.Reference.Path).To(Equal("./to/Shared.pdf")) + Expect(match.Entity.Id.OpaqueId).To(Equal("grant-shared-id")) + Expect(match.Entity.Name).To(Equal("Shared.pdf")) + Expect(match.Entity.Ref.ResourceId.OpaqueId).To(Equal(grantSpace.Root.OpaqueId)) + Expect(match.Entity.Ref.Path).To(Equal("./to/Shared.pdf")) - indexClient.AssertCalled(GinkgoT(), "Search", mock.Anything, mock.MatchedBy(func(req *search.SearchIndexRequest) bool { - return req.Query == "foo" && req.Reference.ResourceId == grantSpace.Root && req.Reference.Path == "./grant/path" + indexClient.AssertCalled(GinkgoT(), "Search", mock.Anything, mock.MatchedBy(func(req *searchsvc.SearchIndexRequest) bool { + return req.Query == "foo" && req.Ref.ResourceId.OpaqueId == grantSpace.Root.OpaqueId && req.Ref.Path == "./grant/path" })) }) @@ -204,52 +211,58 @@ var _ = Describe("Searchprovider", func() { Status: status.NewOK(ctx), StorageSpaces: []*sprovider.StorageSpace{personalSpace, grantSpace}, }, nil) - indexClient.On("Search", mock.Anything, mock.MatchedBy(func(req *search.SearchIndexRequest) bool { - return req.Reference.ResourceId == grantSpace.Root - })).Return(&search.SearchIndexResult{ - Matches: []search.Match{ + indexClient.On("Search", mock.Anything, mock.MatchedBy(func(req *searchsvc.SearchIndexRequest) bool { + return req.Ref.ResourceId.OpaqueId == grantSpace.Root.OpaqueId + })).Return(&searchsvc.SearchIndexResponse{ + Matches: []*searchmsg.Match{ { - Reference: &sprovider.Reference{ - ResourceId: grantSpace.Root, - Path: "./grant/path/to/Shared.pdf", - }, - Info: &sprovider.ResourceInfo{ - Id: &sprovider.ResourceId{ + Entity: &searchmsg.Entity{ + Ref: &searchmsg.Reference{ + ResourceId: &searchmsg.ResourceID{ + StorageId: grantSpace.Root.StorageId, + OpaqueId: grantSpace.Root.OpaqueId, + }, + Path: "./grant/path/to/Shared.pdf", + }, + Id: &searchmsg.ResourceID{ StorageId: grantSpace.Root.StorageId, OpaqueId: "grant-shared-id", }, - Path: "Shared.pdf", + Name: "Shared.pdf", }, }, }, }, nil) - indexClient.On("Search", mock.Anything, mock.MatchedBy(func(req *search.SearchIndexRequest) bool { - return req.Reference.ResourceId == personalSpace.Root - })).Return(&search.SearchIndexResult{ - Matches: []search.Match{ + indexClient.On("Search", mock.Anything, mock.MatchedBy(func(req *searchsvc.SearchIndexRequest) bool { + return req.Ref.ResourceId.OpaqueId == personalSpace.Root.OpaqueId + })).Return(&searchsvc.SearchIndexResponse{ + Matches: []*searchmsg.Match{ { - Reference: &sprovider.Reference{ - ResourceId: personalSpace.Root, - Path: "./path/to/Foo.pdf", - }, - Info: &sprovider.ResourceInfo{ - Id: &sprovider.ResourceId{ + Entity: &searchmsg.Entity{ + Ref: &searchmsg.Reference{ + ResourceId: &searchmsg.ResourceID{ + StorageId: personalSpace.Root.StorageId, + OpaqueId: personalSpace.Root.OpaqueId, + }, + Path: "./path/to/Foo.pdf", + }, + Id: &searchmsg.ResourceID{ StorageId: personalSpace.Root.StorageId, OpaqueId: "foo-id", }, - Path: "Foo.pdf", + Name: "Foo.pdf", }, }, }, }, nil) - res, err := p.Search(ctx, &search.SearchRequest{ + res, err := p.Search(ctx, &searchsvc.SearchRequest{ Query: "foo", }) Expect(err).ToNot(HaveOccurred()) Expect(res).ToNot(BeNil()) Expect(len(res.Matches)).To(Equal(2)) - ids := []string{res.Matches[0].Info.Id.OpaqueId, res.Matches[1].Info.Id.OpaqueId} + ids := []string{res.Matches[0].Entity.Id.OpaqueId, res.Matches[1].Entity.Id.OpaqueId} Expect(ids).To(ConsistOf("foo-id", "grant-shared-id")) }) }) diff --git a/search/pkg/search/search.go b/search/pkg/search/search.go index 27acf38b0..b28563b77 100644 --- a/search/pkg/search/search.go +++ b/search/pkg/search/search.go @@ -21,45 +21,18 @@ package search import ( "context" - sprovider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" + searchsvc "github.com/owncloud/ocis/protogen/gen/ocis/services/search/v0" ) //go:generate mockery --name=ProviderClient //go:generate mockery --name=IndexClient -// SearchRequest represents a search request from a user to the search provider -type SearchRequest struct { - Query string -} - -// Match holds the information of a matched resource in a search -type Match struct { - Reference *sprovider.Reference - Info *sprovider.ResourceInfo -} - -// SearchResult contains the matches being returned for a search -type SearchResult struct { - Matches []Match -} - // ProviderClient is the interface to the search provider service type ProviderClient interface { - Search(ctx context.Context, req *SearchRequest) (*SearchResult, error) -} - -// SearchIndexRequest represents a search request to the index -type SearchIndexRequest struct { - Reference *sprovider.Reference - Query string -} - -// SearchResult contains the matches in the index being returned for a search -type SearchIndexResult struct { - Matches []Match + Search(ctx context.Context, req *searchsvc.SearchRequest) (*searchsvc.SearchResponse, error) } // IndexClient is the interface to the search index type IndexClient interface { - Search(ctx context.Context, req *SearchIndexRequest) (*SearchIndexResult, error) + Search(ctx context.Context, req *searchsvc.SearchIndexRequest) (*searchsvc.SearchIndexResponse, error) } diff --git a/search/pkg/server/grpc/server.go b/search/pkg/server/grpc/server.go index 48def49bd..d8adea91d 100644 --- a/search/pkg/server/grpc/server.go +++ b/search/pkg/server/grpc/server.go @@ -1,8 +1,6 @@ package grpc import ( - accountssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/accounts/v0" - "github.com/owncloud/ocis/ocis-pkg/service/grpc" "github.com/owncloud/ocis/ocis-pkg/version" ) @@ -22,15 +20,9 @@ func Server(opts ...Option) grpc.Service { grpc.Version(version.String), ) - if err := accountssvc.RegisterAccountsServiceHandler(service.Server(), handler); err != nil { + if err := searchsvc.RegisterSearchServiceHandler(service.Server(), handler); err != nil { options.Logger.Fatal().Err(err).Msg("could not register service handler") } - if err := accountssvc.RegisterGroupsServiceHandler(service.Server(), handler); err != nil { - options.Logger.Fatal().Err(err).Msg("could not register groups handler") - } - if err := accountssvc.RegisterIndexServiceHandler(service.Server(), handler); err != nil { - options.Logger.Fatal().Err(err).Msg("could not register index handler") - } return service } diff --git a/search/pkg/service/v0/option.go b/search/pkg/service/v0/option.go index 4658ba8b0..fca7bd5fc 100644 --- a/search/pkg/service/v0/option.go +++ b/search/pkg/service/v0/option.go @@ -1,10 +1,8 @@ package service import ( - "github.com/owncloud/ocis/accounts/pkg/config" "github.com/owncloud/ocis/ocis-pkg/log" - "github.com/owncloud/ocis/ocis-pkg/roles" - settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v0" + "github.com/owncloud/ocis/search/pkg/config" ) // Option defines a single option function. @@ -12,10 +10,8 @@ type Option func(o *Options) // Options defines the available options for this package. type Options struct { - Logger log.Logger - Config *config.Config - RoleService settingssvc.RoleService - RoleManager *roles.Manager + Logger log.Logger + Config *config.Config } func newOptions(opts ...Option) Options { @@ -41,17 +37,3 @@ func Config(val *config.Config) Option { o.Config = val } } - -// RoleService provides a function to set the RoleService option. -func RoleService(val settingssvc.RoleService) Option { - return func(o *Options) { - o.RoleService = val - } -} - -// RoleManager provides a function to set the RoleManager option. -func RoleManager(val *roles.Manager) Option { - return func(o *Options) { - o.RoleManager = val - } -} diff --git a/search/pkg/service/v0/service.go b/search/pkg/service/v0/service.go index b2d479f74..951d48311 100644 --- a/search/pkg/service/v0/service.go +++ b/search/pkg/service/v0/service.go @@ -1,71 +1,53 @@ package service import ( - "time" - - "github.com/pkg/errors" - - "github.com/owncloud/ocis/ocis-pkg/service/grpc" - - "github.com/owncloud/ocis/ocis-pkg/indexer" + "github.com/blevesearch/bleve/v2" + "github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool" "github.com/owncloud/ocis/ocis-pkg/log" - oreg "github.com/owncloud/ocis/ocis-pkg/registry" - "github.com/owncloud/ocis/ocis-pkg/roles" - settingssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/settings/v0" "github.com/owncloud/ocis/search/pkg/config" + "github.com/owncloud/ocis/search/pkg/search" + "github.com/owncloud/ocis/search/pkg/search/index" + searchprovider "github.com/owncloud/ocis/search/pkg/search/provider" ) // userDefaultGID is the default integer representing the "users" group. const userDefaultGID = 30000 // New returns a new instance of Service -func New(opts ...Option) (s *Service, err error) { +func New(opts ...Option) (*Service, error) { options := newOptions(opts...) logger := options.Logger cfg := options.Config - roleService := options.RoleService - if roleService == nil { - roleService = settingssvc.NewRoleService("com.owncloud.api.settings", grpc.DefaultClient) - } - roleManager := options.RoleManager - if roleManager == nil { - m := roles.NewManager( - roles.CacheSize(1024), - roles.CacheTTL(time.Hour*24*7), - roles.Logger(options.Logger), - roles.RoleService(roleService), - ) - roleManager = &m - } - - storage, err := createMetadataStorage(cfg, logger) + bleveIndex, err := bleve.NewMemOnly(index.BuildMapping()) if err != nil { - return nil, errors.Wrap(err, "could not create metadata storage") + return nil, err + } + index, err := index.New(bleveIndex) + if err != nil { + return nil, err } - s = &Service{ - id: cfg.GRPC.Namespace + "." + cfg.Service.Name, - log: logger, - Config: cfg, + gwclient, err := pool.GetGatewayServiceClient(cfg.Reva.Address) + if err != nil { + logger.Fatal().Msgf("could not get reva client at address %s", cfg.Reva.Address) } - r := oreg.GetRegistry() - if cfg.Repo.Backend == "cs3" { - if _, err := r.GetService("com.owncloud.storage.metadata"); err != nil { - logger.Error().Err(err).Msg("index: storage-metadata service not present") - return nil, err - } - } + provider := searchprovider.New(gwclient, index) - return + return &Service{ + id: cfg.GRPC.Namespace + "." + cfg.Service.Name, + log: logger, + Config: cfg, + provider: provider, + }, nil } // Service implements the searchServiceHandler interface type Service struct { - id string - log log.Logger - Config *config.Config - index *indexer.Indexer + id string + log log.Logger + Config *config.Config + provider search.ProviderClient }