From be0ce71de61a5f80b2e58460dc298eaba656a9f8 Mon Sep 17 00:00:00 2001 From: Fedorov Vladimir Date: Tue, 19 Nov 2024 15:13:01 +0700 Subject: [PATCH] add api --- api/smm_core.proto | 47 +++- proto/smm_core.pb.go | 410 +++++++++++++++++++++++++++++--- proto/smm_core.pb.gw.go | 295 +++++++++++++++++++++++ proto/smm_core_grpc.pb.go | 118 ++++++++- resources/smm_core.swagger.json | 166 ++++++++++++- 5 files changed, 1003 insertions(+), 33 deletions(-) diff --git a/api/smm_core.proto b/api/smm_core.proto index 6e9613f..58cbf0c 100644 --- a/api/smm_core.proto +++ b/api/smm_core.proto @@ -3,7 +3,6 @@ syntax = "proto3"; package crabs.smm_core; import "google/api/annotations.proto"; -import "google/api/httpbody.proto"; import "protoc-gen-openapiv2/options/annotations.proto"; option go_package = "pkg/proto"; @@ -16,8 +15,54 @@ service SmmCore { get: "/ping" }; } + + // categories + rpc AddCategory(CreateCategoryReq) returns (Category) { + option (google.api.http) = { + post: "/categories" + }; + } + rpc UpdateCategory(UpdateCategoryReq) returns (Category) { + option (google.api.http) = { + put: "/categories/{id}" + }; + } + rpc GetCategories(CategoryFilterReq) returns (Categories) { + option (google.api.http) = { + get: "/categories" + }; + } } message PingReq {} message PingRsp {} + +message CreateCategoryReq { + string name = 1; + int32 user_id = 2; + bool favorite = 3; + int32 monthly_limit = 4; +} + +message UpdateCategoryReq { + int32 id = 1; + string name = 2; + bool favorite = 3; + int32 monthly_limit = 4; +} + +message Category { + int32 id = 1; + string name = 2; + bool favorite = 4; + int32 monthly_limit = 5; +} + +message CategoryFilterReq { + bool favorite = 1; +} + +message Categories { + repeated Category categories = 1; +} diff --git a/proto/smm_core.pb.go b/proto/smm_core.pb.go index 9a960f6..5888a5e 100644 --- a/proto/smm_core.pb.go +++ b/proto/smm_core.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.35.2 // protoc v5.27.2 // source: smm_core.proto @@ -9,7 +9,6 @@ package proto import ( _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" _ "google.golang.org/genproto/googleapis/api/annotations" - _ "google.golang.org/genproto/googleapis/api/httpbody" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -95,26 +94,371 @@ func (*PingRsp) Descriptor() ([]byte, []int) { return file_smm_core_proto_rawDescGZIP(), []int{1} } +type CreateCategoryReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + UserId int32 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + Favorite bool `protobuf:"varint,3,opt,name=favorite,proto3" json:"favorite,omitempty"` + MonthlyLimit int32 `protobuf:"varint,4,opt,name=monthly_limit,json=monthlyLimit,proto3" json:"monthly_limit,omitempty"` +} + +func (x *CreateCategoryReq) Reset() { + *x = CreateCategoryReq{} + mi := &file_smm_core_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateCategoryReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateCategoryReq) ProtoMessage() {} + +func (x *CreateCategoryReq) ProtoReflect() protoreflect.Message { + mi := &file_smm_core_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateCategoryReq.ProtoReflect.Descriptor instead. +func (*CreateCategoryReq) Descriptor() ([]byte, []int) { + return file_smm_core_proto_rawDescGZIP(), []int{2} +} + +func (x *CreateCategoryReq) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *CreateCategoryReq) GetUserId() int32 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *CreateCategoryReq) GetFavorite() bool { + if x != nil { + return x.Favorite + } + return false +} + +func (x *CreateCategoryReq) GetMonthlyLimit() int32 { + if x != nil { + return x.MonthlyLimit + } + return 0 +} + +type UpdateCategoryReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Favorite bool `protobuf:"varint,3,opt,name=favorite,proto3" json:"favorite,omitempty"` + MonthlyLimit int32 `protobuf:"varint,4,opt,name=monthly_limit,json=monthlyLimit,proto3" json:"monthly_limit,omitempty"` +} + +func (x *UpdateCategoryReq) Reset() { + *x = UpdateCategoryReq{} + mi := &file_smm_core_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateCategoryReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateCategoryReq) ProtoMessage() {} + +func (x *UpdateCategoryReq) ProtoReflect() protoreflect.Message { + mi := &file_smm_core_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateCategoryReq.ProtoReflect.Descriptor instead. +func (*UpdateCategoryReq) Descriptor() ([]byte, []int) { + return file_smm_core_proto_rawDescGZIP(), []int{3} +} + +func (x *UpdateCategoryReq) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UpdateCategoryReq) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *UpdateCategoryReq) GetFavorite() bool { + if x != nil { + return x.Favorite + } + return false +} + +func (x *UpdateCategoryReq) GetMonthlyLimit() int32 { + if x != nil { + return x.MonthlyLimit + } + return 0 +} + +type Category struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Favorite bool `protobuf:"varint,4,opt,name=favorite,proto3" json:"favorite,omitempty"` + MonthlyLimit int32 `protobuf:"varint,5,opt,name=monthly_limit,json=monthlyLimit,proto3" json:"monthly_limit,omitempty"` +} + +func (x *Category) Reset() { + *x = Category{} + mi := &file_smm_core_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Category) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Category) ProtoMessage() {} + +func (x *Category) ProtoReflect() protoreflect.Message { + mi := &file_smm_core_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Category.ProtoReflect.Descriptor instead. +func (*Category) Descriptor() ([]byte, []int) { + return file_smm_core_proto_rawDescGZIP(), []int{4} +} + +func (x *Category) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Category) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Category) GetFavorite() bool { + if x != nil { + return x.Favorite + } + return false +} + +func (x *Category) GetMonthlyLimit() int32 { + if x != nil { + return x.MonthlyLimit + } + return 0 +} + +type CategoryFilterReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Favorite bool `protobuf:"varint,1,opt,name=favorite,proto3" json:"favorite,omitempty"` +} + +func (x *CategoryFilterReq) Reset() { + *x = CategoryFilterReq{} + mi := &file_smm_core_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CategoryFilterReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CategoryFilterReq) ProtoMessage() {} + +func (x *CategoryFilterReq) ProtoReflect() protoreflect.Message { + mi := &file_smm_core_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CategoryFilterReq.ProtoReflect.Descriptor instead. +func (*CategoryFilterReq) Descriptor() ([]byte, []int) { + return file_smm_core_proto_rawDescGZIP(), []int{5} +} + +func (x *CategoryFilterReq) GetFavorite() bool { + if x != nil { + return x.Favorite + } + return false +} + +type Categories struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Categories []*Category `protobuf:"bytes,1,rep,name=categories,proto3" json:"categories,omitempty"` +} + +func (x *Categories) Reset() { + *x = Categories{} + mi := &file_smm_core_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Categories) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Categories) ProtoMessage() {} + +func (x *Categories) ProtoReflect() protoreflect.Message { + mi := &file_smm_core_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Categories.ProtoReflect.Descriptor instead. +func (*Categories) Descriptor() ([]byte, []int) { + return file_smm_core_proto_rawDescGZIP(), []int{6} +} + +func (x *Categories) GetCategories() []*Category { + if x != nil { + return x.Categories + } + return nil +} + var File_smm_core_proto protoreflect.FileDescriptor var file_smm_core_proto_rawDesc = []byte{ 0x0a, 0x0e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 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, 0x1a, 0x19, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x62, - 0x6f, 0x64, 0x79, 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, 0x22, 0x09, 0x0a, 0x07, 0x50, 0x69, 0x6e, - 0x67, 0x52, 0x65, 0x71, 0x22, 0x09, 0x0a, 0x07, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x73, 0x70, 0x32, - 0x52, 0x0a, 0x07, 0x53, 0x6d, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x12, 0x47, 0x0a, 0x04, 0x50, 0x69, - 0x6e, 0x67, 0x12, 0x17, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, - 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x63, 0x72, - 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x69, 0x6e, - 0x67, 0x52, 0x73, 0x70, 0x22, 0x0d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x07, 0x12, 0x05, 0x2f, 0x70, - 0x69, 0x6e, 0x67, 0x42, 0x0e, 0x92, 0x41, 0x00, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 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, 0x22, 0x09, + 0x0a, 0x07, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x22, 0x09, 0x0a, 0x07, 0x50, 0x69, 0x6e, + 0x67, 0x52, 0x73, 0x70, 0x22, 0x81, 0x01, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, + 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x17, + 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x61, 0x76, 0x6f, 0x72, + 0x69, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x66, 0x61, 0x76, 0x6f, 0x72, + 0x69, 0x74, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x5f, 0x6c, + 0x69, 0x6d, 0x69, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x6d, 0x6f, 0x6e, 0x74, + 0x68, 0x6c, 0x79, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x78, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 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, 0x1a, 0x0a, 0x08, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x08, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x12, 0x23, 0x0a, + 0x0d, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x4c, 0x69, 0x6d, + 0x69, 0x74, 0x22, 0x6f, 0x0a, 0x08, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 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, 0x1a, 0x0a, 0x08, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x12, 0x23, + 0x0a, 0x0d, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x4c, 0x69, + 0x6d, 0x69, 0x74, 0x22, 0x2f, 0x0a, 0x11, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x46, + 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x61, 0x76, 0x6f, + 0x72, 0x69, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x66, 0x61, 0x76, 0x6f, + 0x72, 0x69, 0x74, 0x65, 0x22, 0x46, 0x0a, 0x0a, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, + 0x65, 0x73, 0x12, 0x38, 0x0a, 0x0a, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, + 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, + 0x52, 0x0a, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x32, 0x81, 0x03, 0x0a, + 0x07, 0x53, 0x6d, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x12, 0x47, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, + 0x12, 0x17, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, + 0x65, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x63, 0x72, 0x61, 0x62, + 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, + 0x73, 0x70, 0x22, 0x0d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x07, 0x12, 0x05, 0x2f, 0x70, 0x69, 0x6e, + 0x67, 0x12, 0x5f, 0x0a, 0x0b, 0x41, 0x64, 0x64, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, + 0x12, 0x21, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, + 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, + 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, + 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x22, 0x13, 0x82, + 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x22, 0x0b, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, + 0x65, 0x73, 0x12, 0x67, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, + 0x67, 0x6f, 0x72, 0x79, 0x12, 0x21, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, + 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, + 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, + 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, + 0x79, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x1a, 0x10, 0x2f, 0x63, 0x61, 0x74, 0x65, + 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x63, 0x0a, 0x0d, 0x47, + 0x65, 0x74, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, 0x21, 0x2e, 0x63, + 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x61, + 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, + 0x1a, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, + 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x22, 0x13, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x0d, 0x12, 0x0b, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, + 0x42, 0x0e, 0x92, 0x41, 0x00, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -129,19 +473,31 @@ func file_smm_core_proto_rawDescGZIP() []byte { return file_smm_core_proto_rawDescData } -var file_smm_core_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_smm_core_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_smm_core_proto_goTypes = []any{ - (*PingReq)(nil), // 0: crabs.smm_core.PingReq - (*PingRsp)(nil), // 1: crabs.smm_core.PingRsp + (*PingReq)(nil), // 0: crabs.smm_core.PingReq + (*PingRsp)(nil), // 1: crabs.smm_core.PingRsp + (*CreateCategoryReq)(nil), // 2: crabs.smm_core.CreateCategoryReq + (*UpdateCategoryReq)(nil), // 3: crabs.smm_core.UpdateCategoryReq + (*Category)(nil), // 4: crabs.smm_core.Category + (*CategoryFilterReq)(nil), // 5: crabs.smm_core.CategoryFilterReq + (*Categories)(nil), // 6: crabs.smm_core.Categories } var file_smm_core_proto_depIdxs = []int32{ - 0, // 0: crabs.smm_core.SmmCore.Ping:input_type -> crabs.smm_core.PingReq - 1, // 1: crabs.smm_core.SmmCore.Ping:output_type -> crabs.smm_core.PingRsp - 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 + 4, // 0: crabs.smm_core.Categories.categories:type_name -> crabs.smm_core.Category + 0, // 1: crabs.smm_core.SmmCore.Ping:input_type -> crabs.smm_core.PingReq + 2, // 2: crabs.smm_core.SmmCore.AddCategory:input_type -> crabs.smm_core.CreateCategoryReq + 3, // 3: crabs.smm_core.SmmCore.UpdateCategory:input_type -> crabs.smm_core.UpdateCategoryReq + 5, // 4: crabs.smm_core.SmmCore.GetCategories:input_type -> crabs.smm_core.CategoryFilterReq + 1, // 5: crabs.smm_core.SmmCore.Ping:output_type -> crabs.smm_core.PingRsp + 4, // 6: crabs.smm_core.SmmCore.AddCategory:output_type -> crabs.smm_core.Category + 4, // 7: crabs.smm_core.SmmCore.UpdateCategory:output_type -> crabs.smm_core.Category + 6, // 8: crabs.smm_core.SmmCore.GetCategories:output_type -> crabs.smm_core.Categories + 5, // [5:9] is the sub-list for method output_type + 1, // [1:5] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_smm_core_proto_init() } @@ -155,7 +511,7 @@ func file_smm_core_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_smm_core_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 7, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/smm_core.pb.gw.go b/proto/smm_core.pb.gw.go index c471a3d..39abe3c 100644 --- a/proto/smm_core.pb.gw.go +++ b/proto/smm_core.pb.gw.go @@ -49,6 +49,148 @@ func local_request_SmmCore_Ping_0(ctx context.Context, marshaler runtime.Marshal } +var ( + filter_SmmCore_AddCategory_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_SmmCore_AddCategory_0(ctx context.Context, marshaler runtime.Marshaler, client SmmCoreClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateCategoryReq + 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_SmmCore_AddCategory_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.AddCategory(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SmmCore_AddCategory_0(ctx context.Context, marshaler runtime.Marshaler, server SmmCoreServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateCategoryReq + 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_SmmCore_AddCategory_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.AddCategory(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_SmmCore_UpdateCategory_0 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_SmmCore_UpdateCategory_0(ctx context.Context, marshaler runtime.Marshaler, client SmmCoreClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateCategoryReq + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.Int32(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SmmCore_UpdateCategory_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.UpdateCategory(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SmmCore_UpdateCategory_0(ctx context.Context, marshaler runtime.Marshaler, server SmmCoreServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateCategoryReq + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.Int32(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SmmCore_UpdateCategory_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.UpdateCategory(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_SmmCore_GetCategories_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_SmmCore_GetCategories_0(ctx context.Context, marshaler runtime.Marshaler, client SmmCoreClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CategoryFilterReq + 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_SmmCore_GetCategories_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetCategories(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SmmCore_GetCategories_0(ctx context.Context, marshaler runtime.Marshaler, server SmmCoreServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CategoryFilterReq + 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_SmmCore_GetCategories_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetCategories(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterSmmCoreHandlerServer registers the http handlers for service SmmCore to "mux". // UnaryRPC :call SmmCoreServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -81,6 +223,81 @@ func RegisterSmmCoreHandlerServer(ctx context.Context, mux *runtime.ServeMux, se }) + mux.Handle("POST", pattern_SmmCore_AddCategory_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, "/crabs.smm_core.SmmCore/AddCategory", runtime.WithHTTPPathPattern("/categories")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SmmCore_AddCategory_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_SmmCore_AddCategory_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_SmmCore_UpdateCategory_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, "/crabs.smm_core.SmmCore/UpdateCategory", runtime.WithHTTPPathPattern("/categories/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SmmCore_UpdateCategory_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_SmmCore_UpdateCategory_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SmmCore_GetCategories_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, "/crabs.smm_core.SmmCore/GetCategories", runtime.WithHTTPPathPattern("/categories")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SmmCore_GetCategories_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_SmmCore_GetCategories_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -144,13 +361,91 @@ func RegisterSmmCoreHandlerClient(ctx context.Context, mux *runtime.ServeMux, cl }) + mux.Handle("POST", pattern_SmmCore_AddCategory_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, "/crabs.smm_core.SmmCore/AddCategory", runtime.WithHTTPPathPattern("/categories")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SmmCore_AddCategory_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SmmCore_AddCategory_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PUT", pattern_SmmCore_UpdateCategory_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, "/crabs.smm_core.SmmCore/UpdateCategory", runtime.WithHTTPPathPattern("/categories/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SmmCore_UpdateCategory_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SmmCore_UpdateCategory_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SmmCore_GetCategories_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, "/crabs.smm_core.SmmCore/GetCategories", runtime.WithHTTPPathPattern("/categories")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SmmCore_GetCategories_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SmmCore_GetCategories_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( pattern_SmmCore_Ping_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"ping"}, "")) + + pattern_SmmCore_AddCategory_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"categories"}, "")) + + pattern_SmmCore_UpdateCategory_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"categories", "id"}, "")) + + pattern_SmmCore_GetCategories_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"categories"}, "")) ) var ( forward_SmmCore_Ping_0 = runtime.ForwardResponseMessage + + forward_SmmCore_AddCategory_0 = runtime.ForwardResponseMessage + + forward_SmmCore_UpdateCategory_0 = runtime.ForwardResponseMessage + + forward_SmmCore_GetCategories_0 = runtime.ForwardResponseMessage ) diff --git a/proto/smm_core_grpc.pb.go b/proto/smm_core_grpc.pb.go index cda39a5..9b5a7b7 100644 --- a/proto/smm_core_grpc.pb.go +++ b/proto/smm_core_grpc.pb.go @@ -19,7 +19,10 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - SmmCore_Ping_FullMethodName = "/crabs.smm_core.SmmCore/Ping" + SmmCore_Ping_FullMethodName = "/crabs.smm_core.SmmCore/Ping" + SmmCore_AddCategory_FullMethodName = "/crabs.smm_core.SmmCore/AddCategory" + SmmCore_UpdateCategory_FullMethodName = "/crabs.smm_core.SmmCore/UpdateCategory" + SmmCore_GetCategories_FullMethodName = "/crabs.smm_core.SmmCore/GetCategories" ) // SmmCoreClient is the client API for SmmCore service. @@ -27,6 +30,10 @@ const ( // 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 SmmCoreClient interface { Ping(ctx context.Context, in *PingReq, opts ...grpc.CallOption) (*PingRsp, error) + // categories + AddCategory(ctx context.Context, in *CreateCategoryReq, opts ...grpc.CallOption) (*Category, error) + UpdateCategory(ctx context.Context, in *UpdateCategoryReq, opts ...grpc.CallOption) (*Category, error) + GetCategories(ctx context.Context, in *CategoryFilterReq, opts ...grpc.CallOption) (*Categories, error) } type smmCoreClient struct { @@ -47,11 +54,45 @@ func (c *smmCoreClient) Ping(ctx context.Context, in *PingReq, opts ...grpc.Call return out, nil } +func (c *smmCoreClient) AddCategory(ctx context.Context, in *CreateCategoryReq, opts ...grpc.CallOption) (*Category, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Category) + err := c.cc.Invoke(ctx, SmmCore_AddCategory_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *smmCoreClient) UpdateCategory(ctx context.Context, in *UpdateCategoryReq, opts ...grpc.CallOption) (*Category, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Category) + err := c.cc.Invoke(ctx, SmmCore_UpdateCategory_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *smmCoreClient) GetCategories(ctx context.Context, in *CategoryFilterReq, opts ...grpc.CallOption) (*Categories, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Categories) + err := c.cc.Invoke(ctx, SmmCore_GetCategories_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // SmmCoreServer is the server API for SmmCore service. // All implementations must embed UnimplementedSmmCoreServer // for forward compatibility. type SmmCoreServer interface { Ping(context.Context, *PingReq) (*PingRsp, error) + // categories + AddCategory(context.Context, *CreateCategoryReq) (*Category, error) + UpdateCategory(context.Context, *UpdateCategoryReq) (*Category, error) + GetCategories(context.Context, *CategoryFilterReq) (*Categories, error) mustEmbedUnimplementedSmmCoreServer() } @@ -65,6 +106,15 @@ type UnimplementedSmmCoreServer struct{} func (UnimplementedSmmCoreServer) Ping(context.Context, *PingReq) (*PingRsp, error) { return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented") } +func (UnimplementedSmmCoreServer) AddCategory(context.Context, *CreateCategoryReq) (*Category, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddCategory not implemented") +} +func (UnimplementedSmmCoreServer) UpdateCategory(context.Context, *UpdateCategoryReq) (*Category, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateCategory not implemented") +} +func (UnimplementedSmmCoreServer) GetCategories(context.Context, *CategoryFilterReq) (*Categories, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetCategories not implemented") +} func (UnimplementedSmmCoreServer) mustEmbedUnimplementedSmmCoreServer() {} func (UnimplementedSmmCoreServer) testEmbeddedByValue() {} @@ -104,6 +154,60 @@ func _SmmCore_Ping_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _SmmCore_AddCategory_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateCategoryReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SmmCoreServer).AddCategory(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SmmCore_AddCategory_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SmmCoreServer).AddCategory(ctx, req.(*CreateCategoryReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _SmmCore_UpdateCategory_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateCategoryReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SmmCoreServer).UpdateCategory(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SmmCore_UpdateCategory_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SmmCoreServer).UpdateCategory(ctx, req.(*UpdateCategoryReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _SmmCore_GetCategories_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CategoryFilterReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SmmCoreServer).GetCategories(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SmmCore_GetCategories_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SmmCoreServer).GetCategories(ctx, req.(*CategoryFilterReq)) + } + return interceptor(ctx, in, info, handler) +} + // SmmCore_ServiceDesc is the grpc.ServiceDesc for SmmCore service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -115,6 +219,18 @@ var SmmCore_ServiceDesc = grpc.ServiceDesc{ MethodName: "Ping", Handler: _SmmCore_Ping_Handler, }, + { + MethodName: "AddCategory", + Handler: _SmmCore_AddCategory_Handler, + }, + { + MethodName: "UpdateCategory", + Handler: _SmmCore_UpdateCategory_Handler, + }, + { + MethodName: "GetCategories", + Handler: _SmmCore_GetCategories_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "smm_core.proto", diff --git a/resources/smm_core.swagger.json b/resources/smm_core.swagger.json index 6634317..a541690 100644 --- a/resources/smm_core.swagger.json +++ b/resources/smm_core.swagger.json @@ -16,6 +16,135 @@ "application/json" ], "paths": { + "/categories": { + "get": { + "operationId": "SmmCore_GetCategories", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/smm_coreCategories" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "favorite", + "in": "query", + "required": false, + "type": "boolean" + } + ], + "tags": [ + "SmmCore" + ] + }, + "post": { + "summary": "categories", + "operationId": "SmmCore_AddCategory", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/smm_coreCategory" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "name", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "userId", + "in": "query", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "favorite", + "in": "query", + "required": false, + "type": "boolean" + }, + { + "name": "monthlyLimit", + "in": "query", + "required": false, + "type": "integer", + "format": "int32" + } + ], + "tags": [ + "SmmCore" + ] + } + }, + "/categories/{id}": { + "put": { + "operationId": "SmmCore_UpdateCategory", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/smm_coreCategory" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "type": "integer", + "format": "int32" + }, + { + "name": "name", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "favorite", + "in": "query", + "required": false, + "type": "boolean" + }, + { + "name": "monthlyLimit", + "in": "query", + "required": false, + "type": "integer", + "format": "int32" + } + ], + "tags": [ + "SmmCore" + ] + } + }, "/ping": { "get": { "operationId": "SmmCore_Ping", @@ -44,12 +173,10 @@ "type": "object", "properties": { "@type": { - "type": "string", - "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics." + "type": "string" } }, - "additionalProperties": {}, - "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }" + "additionalProperties": {} }, "rpcStatus": { "type": "object", @@ -70,6 +197,37 @@ } } }, + "smm_coreCategories": { + "type": "object", + "properties": { + "categories": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/smm_coreCategory" + } + } + } + }, + "smm_coreCategory": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "name": { + "type": "string" + }, + "favorite": { + "type": "boolean" + }, + "monthlyLimit": { + "type": "integer", + "format": "int32" + } + } + }, "smm_corePingRsp": { "type": "object" }