diff --git a/api/library/library.pb.go b/api/library/library.pb.go index f3fd8a2..fa47bf0 100644 --- a/api/library/library.pb.go +++ b/api/library/library.pb.go @@ -21,16 +21,97 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type Library struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + UserId string `protobuf:"bytes,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + CreatedAt string `protobuf:"bytes,4,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + UpdatedAt string `protobuf:"bytes,5,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` +} + +func (x *Library) Reset() { + *x = Library{} + if protoimpl.UnsafeEnabled { + mi := &file_api_library_library_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Library) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Library) ProtoMessage() {} + +func (x *Library) ProtoReflect() protoreflect.Message { + mi := &file_api_library_library_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 Library.ProtoReflect.Descriptor instead. +func (*Library) Descriptor() ([]byte, []int) { + return file_api_library_library_proto_rawDescGZIP(), []int{0} +} + +func (x *Library) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Library) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Library) GetUserId() string { + if x != nil { + return x.UserId + } + return "" +} + +func (x *Library) GetCreatedAt() string { + if x != nil { + return x.CreatedAt + } + return "" +} + +func (x *Library) GetUpdatedAt() string { + if x != nil { + return x.UpdatedAt + } + return "" +} + type ListLibraryRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Page int32 `protobuf:"varint,1,opt,name=page,proto3" json:"page,omitempty"` } func (x *ListLibraryRequest) Reset() { *x = ListLibraryRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_library_library_proto_msgTypes[0] + mi := &file_api_library_library_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -43,7 +124,7 @@ func (x *ListLibraryRequest) String() string { func (*ListLibraryRequest) ProtoMessage() {} func (x *ListLibraryRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_library_library_proto_msgTypes[0] + mi := &file_api_library_library_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -56,19 +137,28 @@ func (x *ListLibraryRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ListLibraryRequest.ProtoReflect.Descriptor instead. func (*ListLibraryRequest) Descriptor() ([]byte, []int) { - return file_api_library_library_proto_rawDescGZIP(), []int{0} + return file_api_library_library_proto_rawDescGZIP(), []int{1} +} + +func (x *ListLibraryRequest) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 } type ListLibraryResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Libraries []*Library `protobuf:"bytes,1,rep,name=libraries,proto3" json:"libraries,omitempty"` } func (x *ListLibraryResponse) Reset() { *x = ListLibraryResponse{} if protoimpl.UnsafeEnabled { - mi := &file_api_library_library_proto_msgTypes[1] + mi := &file_api_library_library_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -81,7 +171,7 @@ func (x *ListLibraryResponse) String() string { func (*ListLibraryResponse) ProtoMessage() {} func (x *ListLibraryResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_library_library_proto_msgTypes[1] + mi := &file_api_library_library_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -94,7 +184,108 @@ func (x *ListLibraryResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ListLibraryResponse.ProtoReflect.Descriptor instead. func (*ListLibraryResponse) Descriptor() ([]byte, []int) { - return file_api_library_library_proto_rawDescGZIP(), []int{1} + return file_api_library_library_proto_rawDescGZIP(), []int{2} +} + +func (x *ListLibraryResponse) GetLibraries() []*Library { + if x != nil { + return x.Libraries + } + return nil +} + +type CreateLibraryRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *CreateLibraryRequest) Reset() { + *x = CreateLibraryRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_api_library_library_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateLibraryRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateLibraryRequest) ProtoMessage() {} + +func (x *CreateLibraryRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_library_library_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 CreateLibraryRequest.ProtoReflect.Descriptor instead. +func (*CreateLibraryRequest) Descriptor() ([]byte, []int) { + return file_api_library_library_proto_rawDescGZIP(), []int{3} +} + +func (x *CreateLibraryRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +type CreateLibraryResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Library *Library `protobuf:"bytes,1,opt,name=library,proto3" json:"library,omitempty"` +} + +func (x *CreateLibraryResponse) Reset() { + *x = CreateLibraryResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_api_library_library_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateLibraryResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateLibraryResponse) ProtoMessage() {} + +func (x *CreateLibraryResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_library_library_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateLibraryResponse.ProtoReflect.Descriptor instead. +func (*CreateLibraryResponse) Descriptor() ([]byte, []int) { + return file_api_library_library_proto_rawDescGZIP(), []int{4} +} + +func (x *CreateLibraryResponse) GetLibrary() *Library { + if x != nil { + return x.Library + } + return nil } var File_api_library_library_proto protoreflect.FileDescriptor @@ -104,20 +295,49 @@ var file_api_library_library_proto_rawDesc = []byte{ 0x62, 0x72, 0x61, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 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, 0x22, 0x14, 0x0a, 0x12, 0x4c, 0x69, 0x73, - 0x74, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, - 0x15, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x7a, 0x0a, 0x0e, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, - 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x68, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, - 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x12, 0x22, 0x2e, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, - 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4c, 0x69, 0x62, - 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x4c, 0x69, - 0x62, 0x72, 0x61, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4c, 0x69, 0x73, - 0x74, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x10, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0a, 0x12, 0x08, 0x2f, 0x6c, 0x69, 0x62, 0x72, 0x61, - 0x72, 0x79, 0x42, 0x24, 0x5a, 0x22, 0x6c, 0x65, 0x61, 0x66, 0x64, 0x65, 0x76, 0x2e, 0x74, 0x6f, - 0x70, 0x2f, 0x6c, 0x65, 0x61, 0x66, 0x2f, 0x72, 0x61, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2f, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x84, 0x01, 0x0a, 0x07, 0x4c, 0x69, + 0x62, 0x72, 0x61, 0x72, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, + 0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, + 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, + 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, + 0x22, 0x28, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x67, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x61, 0x67, 0x65, 0x22, 0x4c, 0x0a, 0x13, 0x4c, 0x69, + 0x73, 0x74, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x35, 0x0a, 0x09, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x09, 0x6c, + 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x22, 0x2a, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x4a, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x69, + 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x31, 0x0a, + 0x07, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, + 0x2e, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, + 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x07, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, + 0x32, 0xfc, 0x01, 0x0a, 0x0e, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x12, 0x71, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x4c, 0x69, 0x62, 0x72, 0x61, + 0x72, 0x79, 0x12, 0x22, 0x2e, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4c, 0x69, 0x62, 0x72, + 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x13, 0x12, 0x11, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x6c, 0x69, 0x62, + 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x12, 0x77, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x12, 0x24, 0x2e, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, + 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, + 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, + 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x22, 0x11, 0x2f, 0x61, + 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x42, + 0x24, 0x5a, 0x22, 0x6c, 0x65, 0x61, 0x66, 0x64, 0x65, 0x76, 0x2e, 0x74, 0x6f, 0x70, 0x2f, 0x6c, + 0x65, 0x61, 0x66, 0x2f, 0x72, 0x61, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6c, 0x69, + 0x62, 0x72, 0x61, 0x72, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -132,19 +352,26 @@ func file_api_library_library_proto_rawDescGZIP() []byte { return file_api_library_library_proto_rawDescData } -var file_api_library_library_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_api_library_library_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_api_library_library_proto_goTypes = []interface{}{ - (*ListLibraryRequest)(nil), // 0: LibraryService.ListLibraryRequest - (*ListLibraryResponse)(nil), // 1: LibraryService.ListLibraryResponse + (*Library)(nil), // 0: LibraryService.Library + (*ListLibraryRequest)(nil), // 1: LibraryService.ListLibraryRequest + (*ListLibraryResponse)(nil), // 2: LibraryService.ListLibraryResponse + (*CreateLibraryRequest)(nil), // 3: LibraryService.CreateLibraryRequest + (*CreateLibraryResponse)(nil), // 4: LibraryService.CreateLibraryResponse } var file_api_library_library_proto_depIdxs = []int32{ - 0, // 0: LibraryService.LibraryService.ListLibrary:input_type -> LibraryService.ListLibraryRequest - 1, // 1: LibraryService.LibraryService.ListLibrary:output_type -> LibraryService.ListLibraryResponse - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 0, // 0: LibraryService.ListLibraryResponse.libraries:type_name -> LibraryService.Library + 0, // 1: LibraryService.CreateLibraryResponse.library:type_name -> LibraryService.Library + 1, // 2: LibraryService.LibraryService.ListLibrary:input_type -> LibraryService.ListLibraryRequest + 3, // 3: LibraryService.LibraryService.CreateLibrary:input_type -> LibraryService.CreateLibraryRequest + 2, // 4: LibraryService.LibraryService.ListLibrary:output_type -> LibraryService.ListLibraryResponse + 4, // 5: LibraryService.LibraryService.CreateLibrary:output_type -> LibraryService.CreateLibraryResponse + 4, // [4:6] is the sub-list for method output_type + 2, // [2:4] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_api_library_library_proto_init() } @@ -154,7 +381,7 @@ func file_api_library_library_proto_init() { } if !protoimpl.UnsafeEnabled { file_api_library_library_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListLibraryRequest); i { + switch v := v.(*Library); i { case 0: return &v.state case 1: @@ -166,6 +393,18 @@ func file_api_library_library_proto_init() { } } file_api_library_library_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListLibraryRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_library_library_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListLibraryResponse); i { case 0: return &v.state @@ -177,6 +416,30 @@ func file_api_library_library_proto_init() { return nil } } + file_api_library_library_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateLibraryRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_library_library_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateLibraryResponse); 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{ @@ -184,7 +447,7 @@ func file_api_library_library_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_api_library_library_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 5, NumExtensions: 0, NumServices: 1, }, diff --git a/api/library/library.pb.gw.go b/api/library/library.pb.gw.go index e5062a6..80ed9bb 100644 --- a/api/library/library.pb.gw.go +++ b/api/library/library.pb.gw.go @@ -31,10 +31,21 @@ var _ = runtime.String var _ = utilities.NewDoubleArray var _ = metadata.Join +var ( + filter_LibraryService_ListLibrary_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + func request_LibraryService_ListLibrary_0(ctx context.Context, marshaler runtime.Marshaler, client LibraryServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq ListLibraryRequest var metadata runtime.ServerMetadata + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LibraryService_ListLibrary_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ListLibrary(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -44,11 +55,54 @@ func local_request_LibraryService_ListLibrary_0(ctx context.Context, marshaler r var protoReq ListLibraryRequest var metadata runtime.ServerMetadata + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LibraryService_ListLibrary_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ListLibrary(ctx, &protoReq) return msg, metadata, err } +var ( + filter_LibraryService_CreateLibrary_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_LibraryService_CreateLibrary_0(ctx context.Context, marshaler runtime.Marshaler, client LibraryServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateLibraryRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LibraryService_CreateLibrary_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CreateLibrary(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_LibraryService_CreateLibrary_0(ctx context.Context, marshaler runtime.Marshaler, server LibraryServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateLibraryRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LibraryService_CreateLibrary_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.CreateLibrary(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterLibraryServiceHandlerServer registers the http handlers for service LibraryService to "mux". // UnaryRPC :call LibraryServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -63,7 +117,7 @@ func RegisterLibraryServiceHandlerServer(ctx context.Context, mux *runtime.Serve inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/LibraryService.LibraryService/ListLibrary", runtime.WithHTTPPathPattern("/library")) + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/LibraryService.LibraryService/ListLibrary", runtime.WithHTTPPathPattern("/api/v1/libraries")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -80,6 +134,31 @@ func RegisterLibraryServiceHandlerServer(ctx context.Context, mux *runtime.Serve }) + mux.Handle("POST", pattern_LibraryService_CreateLibrary_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/LibraryService.LibraryService/CreateLibrary", runtime.WithHTTPPathPattern("/api/v1/libraries")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_LibraryService_CreateLibrary_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_LibraryService_CreateLibrary_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -127,7 +206,7 @@ func RegisterLibraryServiceHandlerClient(ctx context.Context, mux *runtime.Serve inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/LibraryService.LibraryService/ListLibrary", runtime.WithHTTPPathPattern("/library")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/LibraryService.LibraryService/ListLibrary", runtime.WithHTTPPathPattern("/api/v1/libraries")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -143,13 +222,39 @@ func RegisterLibraryServiceHandlerClient(ctx context.Context, mux *runtime.Serve }) + mux.Handle("POST", pattern_LibraryService_CreateLibrary_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/LibraryService.LibraryService/CreateLibrary", runtime.WithHTTPPathPattern("/api/v1/libraries")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_LibraryService_CreateLibrary_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_LibraryService_CreateLibrary_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( - pattern_LibraryService_ListLibrary_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"library"}, "")) + pattern_LibraryService_ListLibrary_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "libraries"}, "")) + + pattern_LibraryService_CreateLibrary_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "libraries"}, "")) ) var ( forward_LibraryService_ListLibrary_0 = runtime.ForwardResponseMessage + + forward_LibraryService_CreateLibrary_0 = runtime.ForwardResponseMessage ) diff --git a/api/library/library.proto b/api/library/library.proto index 941cc94..01cb0e6 100644 --- a/api/library/library.proto +++ b/api/library/library.proto @@ -5,21 +5,43 @@ package LibraryService; option go_package = "leafdev.top/leaf/rag/proto/library"; import "google/api/annotations.proto"; + //import "google.golang.org/grpc/health/grpc_health_v1"; service LibraryService { rpc ListLibrary(ListLibraryRequest) returns (ListLibraryResponse) { option (google.api.http) = { - get: "/library" + get: "/api/v1/libraries" }; } + rpc CreateLibrary(CreateLibraryRequest) returns (CreateLibraryResponse) { + option (google.api.http) = { + post: "/api/v1/libraries" + }; + } +} + +message Library { + int64 id = 1; + string name = 2; + string user_id = 3; + string created_at = 4; + string updated_at = 5; } message ListLibraryRequest { - + int32 page = 1; } message ListLibraryResponse { + repeated Library libraries = 1; +} -} \ No newline at end of file +message CreateLibraryRequest { + string name = 1; +} + +message CreateLibraryResponse { + Library library = 1; +} diff --git a/api/library/library.swagger.json b/api/library/library.swagger.json index a3848c3..4f5bd5d 100644 --- a/api/library/library.swagger.json +++ b/api/library/library.swagger.json @@ -16,7 +16,7 @@ "application/json" ], "paths": { - "/library": { + "/api/v1/libraries": { "get": { "operationId": "LibraryService_ListLibrary", "responses": { @@ -33,6 +33,43 @@ } } }, + "parameters": [ + { + "name": "page", + "in": "query", + "required": false, + "type": "integer", + "format": "int32" + } + ], + "tags": [ + "LibraryService" + ] + }, + "post": { + "operationId": "LibraryService_CreateLibrary", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/LibraryServiceCreateLibraryResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "name", + "in": "query", + "required": false, + "type": "string" + } + ], "tags": [ "LibraryService" ] @@ -40,8 +77,46 @@ } }, "definitions": { + "LibraryServiceCreateLibraryResponse": { + "type": "object", + "properties": { + "library": { + "$ref": "#/definitions/LibraryServiceLibrary" + } + } + }, + "LibraryServiceLibrary": { + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "int64" + }, + "name": { + "type": "string" + }, + "userId": { + "type": "string" + }, + "createdAt": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, "LibraryServiceListLibraryResponse": { - "type": "object" + "type": "object", + "properties": { + "libraries": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/LibraryServiceLibrary" + } + } + } }, "protobufAny": { "type": "object", diff --git a/api/library/library_grpc.pb.go b/api/library/library_grpc.pb.go index 0360f0b..6a8d160 100644 --- a/api/library/library_grpc.pb.go +++ b/api/library/library_grpc.pb.go @@ -23,6 +23,7 @@ const _ = grpc.SupportPackageIsVersion7 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type LibraryServiceClient interface { ListLibrary(ctx context.Context, in *ListLibraryRequest, opts ...grpc.CallOption) (*ListLibraryResponse, error) + CreateLibrary(ctx context.Context, in *CreateLibraryRequest, opts ...grpc.CallOption) (*CreateLibraryResponse, error) } type libraryServiceClient struct { @@ -42,11 +43,21 @@ func (c *libraryServiceClient) ListLibrary(ctx context.Context, in *ListLibraryR return out, nil } +func (c *libraryServiceClient) CreateLibrary(ctx context.Context, in *CreateLibraryRequest, opts ...grpc.CallOption) (*CreateLibraryResponse, error) { + out := new(CreateLibraryResponse) + err := c.cc.Invoke(ctx, "/LibraryService.LibraryService/CreateLibrary", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // LibraryServiceServer is the server API for LibraryService service. // All implementations must embed UnimplementedLibraryServiceServer // for forward compatibility type LibraryServiceServer interface { ListLibrary(context.Context, *ListLibraryRequest) (*ListLibraryResponse, error) + CreateLibrary(context.Context, *CreateLibraryRequest) (*CreateLibraryResponse, error) mustEmbedUnimplementedLibraryServiceServer() } @@ -57,6 +68,9 @@ type UnimplementedLibraryServiceServer struct { func (UnimplementedLibraryServiceServer) ListLibrary(context.Context, *ListLibraryRequest) (*ListLibraryResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListLibrary not implemented") } +func (UnimplementedLibraryServiceServer) CreateLibrary(context.Context, *CreateLibraryRequest) (*CreateLibraryResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateLibrary not implemented") +} func (UnimplementedLibraryServiceServer) mustEmbedUnimplementedLibraryServiceServer() {} // UnsafeLibraryServiceServer may be embedded to opt out of forward compatibility for this service. @@ -88,6 +102,24 @@ func _LibraryService_ListLibrary_Handler(srv interface{}, ctx context.Context, d return interceptor(ctx, in, info, handler) } +func _LibraryService_CreateLibrary_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateLibraryRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(LibraryServiceServer).CreateLibrary(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/LibraryService.LibraryService/CreateLibrary", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(LibraryServiceServer).CreateLibrary(ctx, req.(*CreateLibraryRequest)) + } + return interceptor(ctx, in, info, handler) +} + // LibraryService_ServiceDesc is the grpc.ServiceDesc for LibraryService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -99,6 +131,10 @@ var LibraryService_ServiceDesc = grpc.ServiceDesc{ MethodName: "ListLibrary", Handler: _LibraryService_ListLibrary_Handler, }, + { + MethodName: "CreateLibrary", + Handler: _LibraryService_CreateLibrary_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "api/library/library.proto",