From a865b79b92252cf90fadc68ccb556e29f55aff68 Mon Sep 17 00:00:00 2001 From: Saman Hosseini Date: Wed, 19 Oct 2022 15:55:28 +0200 Subject: [PATCH] refactor(api/proto): extract `filepb` package --- api/proto/gen/file/v0/file.go | 17 ++ api/proto/gen/file/v0/storage.pb.go | 157 +++++++++++++++++ api/proto/gen/image/v0/image.go | 17 +- api/proto/gen/image/v0/image.pb.go | 181 ++++++-------------- api/proto/mediaentity/file/v0/storage.proto | 9 + api/proto/mediaentity/image/v0/image.proto | 10 +- 6 files changed, 244 insertions(+), 147 deletions(-) create mode 100644 api/proto/gen/file/v0/file.go create mode 100644 api/proto/gen/file/v0/storage.pb.go create mode 100644 api/proto/mediaentity/file/v0/storage.proto diff --git a/api/proto/gen/file/v0/file.go b/api/proto/gen/file/v0/file.go new file mode 100644 index 0000000..3019c17 --- /dev/null +++ b/api/proto/gen/file/v0/file.go @@ -0,0 +1,17 @@ +package filepb + +import "github.com/modernice/media-entity/file" + +func NewStorage(s file.Storage) *Storage { + return &Storage{ + Provider: s.Provider, + Path: s.Path, + } +} + +func (s *Storage) AsStorage() file.Storage { + return file.Storage{ + Provider: s.GetProvider(), + Path: s.GetPath(), + } +} diff --git a/api/proto/gen/file/v0/storage.pb.go b/api/proto/gen/file/v0/storage.pb.go new file mode 100644 index 0000000..0ad80ba --- /dev/null +++ b/api/proto/gen/file/v0/storage.pb.go @@ -0,0 +1,157 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.1 +// protoc v3.15.3 +// source: mediaentity/file/v0/storage.proto + +package filepb + +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) +) + +// Storage provides the storage information of a file. +type Storage struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Provider string `protobuf:"bytes,1,opt,name=provider,proto3" json:"provider,omitempty"` + Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` +} + +func (x *Storage) Reset() { + *x = Storage{} + if protoimpl.UnsafeEnabled { + mi := &file_mediaentity_file_v0_storage_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Storage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Storage) ProtoMessage() {} + +func (x *Storage) ProtoReflect() protoreflect.Message { + mi := &file_mediaentity_file_v0_storage_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 Storage.ProtoReflect.Descriptor instead. +func (*Storage) Descriptor() ([]byte, []int) { + return file_mediaentity_file_v0_storage_proto_rawDescGZIP(), []int{0} +} + +func (x *Storage) GetProvider() string { + if x != nil { + return x.Provider + } + return "" +} + +func (x *Storage) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +var File_mediaentity_file_v0_storage_proto protoreflect.FileDescriptor + +var file_mediaentity_file_v0_storage_proto_rawDesc = []byte{ + 0x0a, 0x21, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2f, 0x66, 0x69, + 0x6c, 0x65, 0x2f, 0x76, 0x30, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x13, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, + 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x76, 0x30, 0x22, 0x39, 0x0a, 0x07, 0x53, 0x74, 0x6f, 0x72, + 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, + 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, + 0x61, 0x74, 0x68, 0x42, 0x40, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x72, 0x6e, 0x69, 0x63, 0x65, 0x2f, 0x6d, 0x65, 0x64, 0x69, + 0x61, 0x2d, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x2f, 0x76, 0x30, 0x3b, 0x66, + 0x69, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_mediaentity_file_v0_storage_proto_rawDescOnce sync.Once + file_mediaentity_file_v0_storage_proto_rawDescData = file_mediaentity_file_v0_storage_proto_rawDesc +) + +func file_mediaentity_file_v0_storage_proto_rawDescGZIP() []byte { + file_mediaentity_file_v0_storage_proto_rawDescOnce.Do(func() { + file_mediaentity_file_v0_storage_proto_rawDescData = protoimpl.X.CompressGZIP(file_mediaentity_file_v0_storage_proto_rawDescData) + }) + return file_mediaentity_file_v0_storage_proto_rawDescData +} + +var file_mediaentity_file_v0_storage_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_mediaentity_file_v0_storage_proto_goTypes = []interface{}{ + (*Storage)(nil), // 0: mediaentity.file.v0.Storage +} +var file_mediaentity_file_v0_storage_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] 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 +} + +func init() { file_mediaentity_file_v0_storage_proto_init() } +func file_mediaentity_file_v0_storage_proto_init() { + if File_mediaentity_file_v0_storage_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_mediaentity_file_v0_storage_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Storage); 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_mediaentity_file_v0_storage_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_mediaentity_file_v0_storage_proto_goTypes, + DependencyIndexes: file_mediaentity_file_v0_storage_proto_depIdxs, + MessageInfos: file_mediaentity_file_v0_storage_proto_msgTypes, + }.Build() + File_mediaentity_file_v0_storage_proto = out.File + file_mediaentity_file_v0_storage_proto_rawDesc = nil + file_mediaentity_file_v0_storage_proto_goTypes = nil + file_mediaentity_file_v0_storage_proto_depIdxs = nil +} diff --git a/api/proto/gen/image/v0/image.go b/api/proto/gen/image/v0/image.go index cbead74..d3d943c 100644 --- a/api/proto/gen/image/v0/image.go +++ b/api/proto/gen/image/v0/image.go @@ -1,6 +1,7 @@ package imagepb import ( + filepb "github.com/modernice/media-entity/api/proto/gen/file/v0" "github.com/modernice/media-entity/image" "github.com/modernice/media-entity/internal/mapx" "github.com/modernice/media-entity/internal/slicex" @@ -8,7 +9,7 @@ import ( func New(img image.Image) *Image { return &Image{ - Storage: NewStorage(img.Storage), + Storage: filepb.NewStorage(img.Storage), Filename: img.Filename, Filesize: int64(img.Filesize), Dimensions: NewDimensions(img.Dimensions), @@ -30,20 +31,6 @@ func (img *Image) AsImage() image.Image { } } -func NewStorage(s image.Storage) *Storage { - return &Storage{ - Provider: s.Provider, - Path: s.Path, - } -} - -func (s *Storage) AsStorage() image.Storage { - return image.Storage{ - Provider: s.GetProvider(), - Path: s.GetPath(), - } -} - func NewDimensions(d image.Dimensions) *Dimensions { return &Dimensions{ Width: int64(d.Width()), diff --git a/api/proto/gen/image/v0/image.pb.go b/api/proto/gen/image/v0/image.pb.go index f3ed343..5b28a51 100644 --- a/api/proto/gen/image/v0/image.pb.go +++ b/api/proto/gen/image/v0/image.pb.go @@ -7,6 +7,7 @@ package imagepb import ( + v0 "github.com/modernice/media-entity/api/proto/gen/file/v0" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -26,7 +27,7 @@ type Image struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Storage *Storage `protobuf:"bytes,1,opt,name=storage,proto3" json:"storage,omitempty"` + Storage *v0.Storage `protobuf:"bytes,1,opt,name=storage,proto3" json:"storage,omitempty"` Filename string `protobuf:"bytes,2,opt,name=filename,proto3" json:"filename,omitempty"` Filesize int64 `protobuf:"varint,3,opt,name=filesize,proto3" json:"filesize,omitempty"` Dimensions *Dimensions `protobuf:"bytes,4,opt,name=dimensions,proto3" json:"dimensions,omitempty"` @@ -67,7 +68,7 @@ func (*Image) Descriptor() ([]byte, []int) { return file_mediaentity_image_v0_image_proto_rawDescGZIP(), []int{0} } -func (x *Image) GetStorage() *Storage { +func (x *Image) GetStorage() *v0.Storage { if x != nil { return x.Storage } @@ -116,62 +117,6 @@ func (x *Image) GetTags() []string { return nil } -// Storage provides the storage information of an image. -type Storage struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Provider string `protobuf:"bytes,1,opt,name=provider,proto3" json:"provider,omitempty"` - Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` -} - -func (x *Storage) Reset() { - *x = Storage{} - if protoimpl.UnsafeEnabled { - mi := &file_mediaentity_image_v0_image_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Storage) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Storage) ProtoMessage() {} - -func (x *Storage) ProtoReflect() protoreflect.Message { - mi := &file_mediaentity_image_v0_image_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 Storage.ProtoReflect.Descriptor instead. -func (*Storage) Descriptor() ([]byte, []int) { - return file_mediaentity_image_v0_image_proto_rawDescGZIP(), []int{1} -} - -func (x *Storage) GetProvider() string { - if x != nil { - return x.Provider - } - return "" -} - -func (x *Storage) GetPath() string { - if x != nil { - return x.Path - } - return "" -} - // Dimensions are the width and height of an image. type Dimensions struct { state protoimpl.MessageState @@ -185,7 +130,7 @@ type Dimensions struct { func (x *Dimensions) Reset() { *x = Dimensions{} if protoimpl.UnsafeEnabled { - mi := &file_mediaentity_image_v0_image_proto_msgTypes[2] + mi := &file_mediaentity_image_v0_image_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -198,7 +143,7 @@ func (x *Dimensions) String() string { func (*Dimensions) ProtoMessage() {} func (x *Dimensions) ProtoReflect() protoreflect.Message { - mi := &file_mediaentity_image_v0_image_proto_msgTypes[2] + mi := &file_mediaentity_image_v0_image_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -211,7 +156,7 @@ func (x *Dimensions) ProtoReflect() protoreflect.Message { // Deprecated: Use Dimensions.ProtoReflect.Descriptor instead. func (*Dimensions) Descriptor() ([]byte, []int) { - return file_mediaentity_image_v0_image_proto_rawDescGZIP(), []int{2} + return file_mediaentity_image_v0_image_proto_rawDescGZIP(), []int{1} } func (x *Dimensions) GetWidth() int64 { @@ -234,49 +179,47 @@ var file_mediaentity_image_v0_image_proto_rawDesc = []byte{ 0x0a, 0x20, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x76, 0x30, 0x2f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, - 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x30, 0x22, 0xda, 0x03, 0x0a, 0x05, 0x49, 0x6d, 0x61, - 0x67, 0x65, 0x12, 0x37, 0x0a, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x65, 0x6e, 0x74, 0x69, 0x74, - 0x79, 0x2e, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x30, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, - 0x67, 0x65, 0x52, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x66, - 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, - 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x73, - 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x73, - 0x69, 0x7a, 0x65, 0x12, 0x40, 0x0a, 0x0a, 0x64, 0x69, 0x6d, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, - 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x65, - 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x30, 0x2e, 0x44, - 0x69, 0x6d, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x0a, 0x64, 0x69, 0x6d, 0x65, 0x6e, - 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x3c, 0x0a, 0x05, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x05, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x65, 0x6e, 0x74, 0x69, - 0x74, 0x79, 0x2e, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x30, 0x2e, 0x49, 0x6d, 0x61, 0x67, - 0x65, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x6e, 0x61, - 0x6d, 0x65, 0x73, 0x12, 0x51, 0x0a, 0x0c, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x6d, 0x65, 0x64, 0x69, + 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x30, 0x1a, 0x21, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x65, + 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x2f, 0x76, 0x30, 0x2f, 0x73, 0x74, + 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd9, 0x03, 0x0a, 0x05, + 0x49, 0x6d, 0x61, 0x67, 0x65, 0x12, 0x36, 0x0a, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x65, 0x6e, + 0x74, 0x69, 0x74, 0x79, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x76, 0x30, 0x2e, 0x53, 0x74, 0x6f, + 0x72, 0x61, 0x67, 0x65, 0x52, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, + 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, + 0x65, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x66, 0x69, 0x6c, + 0x65, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x40, 0x0a, 0x0a, 0x64, 0x69, 0x6d, 0x65, 0x6e, 0x73, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x30, - 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x2e, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0c, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x07, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x1a, 0x38, 0x0a, 0x0a, 0x4e, 0x61, - 0x6d, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3f, 0x0a, 0x11, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x39, 0x0a, 0x07, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, - 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, - 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, - 0x22, 0x3a, 0x0a, 0x0a, 0x44, 0x69, 0x6d, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x14, - 0x0a, 0x05, 0x77, 0x69, 0x64, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x77, - 0x69, 0x64, 0x74, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x42, 0x42, 0x5a, 0x40, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x72, - 0x6e, 0x69, 0x63, 0x65, 0x2f, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x2d, 0x65, 0x6e, 0x74, 0x69, 0x74, - 0x79, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, - 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x76, 0x30, 0x3b, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x70, 0x62, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x44, 0x69, 0x6d, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x0a, 0x64, 0x69, 0x6d, + 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x3c, 0x0a, 0x05, 0x6e, 0x61, 0x6d, 0x65, 0x73, + 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x65, 0x6e, + 0x74, 0x69, 0x74, 0x79, 0x2e, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x30, 0x2e, 0x49, 0x6d, + 0x61, 0x67, 0x65, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, + 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x51, 0x0a, 0x0c, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x6d, 0x65, + 0x64, 0x69, 0x61, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2e, + 0x76, 0x30, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x2e, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0c, 0x64, 0x65, 0x73, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, + 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x1a, 0x38, 0x0a, 0x0a, + 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3f, 0x0a, 0x11, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x3a, 0x0a, 0x0a, 0x44, 0x69, 0x6d, 0x65, 0x6e, + 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x77, 0x69, 0x64, 0x74, 0x68, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x77, 0x69, 0x64, 0x74, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x68, + 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x68, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x42, 0x42, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x72, 0x6e, 0x69, 0x63, 0x65, 0x2f, 0x6d, 0x65, 0x64, 0x69, + 0x61, 0x2d, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x76, 0x30, 0x3b, + 0x69, 0x6d, 0x61, 0x67, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -291,19 +234,19 @@ func file_mediaentity_image_v0_image_proto_rawDescGZIP() []byte { return file_mediaentity_image_v0_image_proto_rawDescData } -var file_mediaentity_image_v0_image_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_mediaentity_image_v0_image_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_mediaentity_image_v0_image_proto_goTypes = []interface{}{ (*Image)(nil), // 0: mediaentity.image.v0.Image - (*Storage)(nil), // 1: mediaentity.image.v0.Storage - (*Dimensions)(nil), // 2: mediaentity.image.v0.Dimensions - nil, // 3: mediaentity.image.v0.Image.NamesEntry - nil, // 4: mediaentity.image.v0.Image.DescriptionsEntry + (*Dimensions)(nil), // 1: mediaentity.image.v0.Dimensions + nil, // 2: mediaentity.image.v0.Image.NamesEntry + nil, // 3: mediaentity.image.v0.Image.DescriptionsEntry + (*v0.Storage)(nil), // 4: mediaentity.file.v0.Storage } var file_mediaentity_image_v0_image_proto_depIdxs = []int32{ - 1, // 0: mediaentity.image.v0.Image.storage:type_name -> mediaentity.image.v0.Storage - 2, // 1: mediaentity.image.v0.Image.dimensions:type_name -> mediaentity.image.v0.Dimensions - 3, // 2: mediaentity.image.v0.Image.names:type_name -> mediaentity.image.v0.Image.NamesEntry - 4, // 3: mediaentity.image.v0.Image.descriptions:type_name -> mediaentity.image.v0.Image.DescriptionsEntry + 4, // 0: mediaentity.image.v0.Image.storage:type_name -> mediaentity.file.v0.Storage + 1, // 1: mediaentity.image.v0.Image.dimensions:type_name -> mediaentity.image.v0.Dimensions + 2, // 2: mediaentity.image.v0.Image.names:type_name -> mediaentity.image.v0.Image.NamesEntry + 3, // 3: mediaentity.image.v0.Image.descriptions:type_name -> mediaentity.image.v0.Image.DescriptionsEntry 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 @@ -330,18 +273,6 @@ func file_mediaentity_image_v0_image_proto_init() { } } file_mediaentity_image_v0_image_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Storage); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_mediaentity_image_v0_image_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Dimensions); i { case 0: return &v.state @@ -360,7 +291,7 @@ func file_mediaentity_image_v0_image_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_mediaentity_image_v0_image_proto_rawDesc, NumEnums: 0, - NumMessages: 5, + NumMessages: 4, NumExtensions: 0, NumServices: 0, }, diff --git a/api/proto/mediaentity/file/v0/storage.proto b/api/proto/mediaentity/file/v0/storage.proto new file mode 100644 index 0000000..f884145 --- /dev/null +++ b/api/proto/mediaentity/file/v0/storage.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; +package mediaentity.file.v0; +option go_package = "github.com/modernice/media-entity/api/proto/gen/file/v0;filepb"; + +// Storage provides the storage information of a file. +message Storage { + string provider = 1; + string path = 2; +} diff --git a/api/proto/mediaentity/image/v0/image.proto b/api/proto/mediaentity/image/v0/image.proto index 496dc94..0649868 100644 --- a/api/proto/mediaentity/image/v0/image.proto +++ b/api/proto/mediaentity/image/v0/image.proto @@ -2,9 +2,11 @@ syntax = "proto3"; package mediaentity.image.v0; option go_package = "github.com/modernice/media-entity/api/proto/gen/image/v0;imagepb"; +import "mediaentity/file/v0/storage.proto"; + // Image represents an image. message Image { - Storage storage = 1; + mediaentity.file.v0.Storage storage = 1; string filename = 2; int64 filesize = 3; Dimensions dimensions = 4; @@ -13,12 +15,6 @@ message Image { repeated string tags = 7; } -// Storage provides the storage information of an image. -message Storage { - string provider = 1; - string path = 2; -} - // Dimensions are the width and height of an image. message Dimensions { int64 width = 1;