263 lines
4.9 KiB
Protocol Buffer
263 lines
4.9 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
package crabs.smm_core;
|
|
|
|
import "google/api/annotations.proto";
|
|
import "protoc-gen-openapiv2/options/annotations.proto";
|
|
|
|
option go_package = "pkg/proto";
|
|
|
|
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {};
|
|
|
|
service SmmCore {
|
|
|
|
// ping
|
|
rpc Ping(PingReq) returns (PingRsp) {
|
|
option (google.api.http) = {
|
|
get: "/ping"
|
|
};
|
|
}
|
|
|
|
// login
|
|
rpc Login(LoginReq) returns (User) {
|
|
option (google.api.http) = {
|
|
post: "/login",
|
|
body: "*"
|
|
};
|
|
}
|
|
|
|
// budgets
|
|
rpc AddBudget(AddBudgetReq) returns (Budget) {
|
|
option (google.api.http) = {
|
|
post: "/budgets",
|
|
body: "*"
|
|
};
|
|
}
|
|
rpc UpdateBudget(UpdateBudgetReq) returns (Budget) {
|
|
option (google.api.http) = {
|
|
put: "/budgets/{id}",
|
|
body: "*"
|
|
};
|
|
}
|
|
rpc GetBudgets(GetBudgetsReq) returns (Budgets) {
|
|
option (google.api.http) = {
|
|
get: "/budgets"
|
|
};
|
|
}
|
|
rpc DeleteBudget(DeleteBudgetReq) returns (Budget) {
|
|
option (google.api.http) = {
|
|
delete: "/budgets/{id}"
|
|
};
|
|
}
|
|
|
|
// budget users
|
|
rpc AddUserToBudget(AddUserToBudgetReq) returns (OK) {
|
|
option (google.api.http) = {
|
|
put: "/budgets/{budget_id}/users",
|
|
body: "*"
|
|
};
|
|
}
|
|
rpc GetBudgetUsers(GetBudgetUsersReq) returns (Users) {
|
|
option (google.api.http) = {
|
|
get: "/budgets/{id}/users"
|
|
};
|
|
}
|
|
rpc RemoveUserFromBudget(RemoveUserFromBudgetReq) returns (Budget) {
|
|
option (google.api.http) = {
|
|
delete: "/budgets/{budget_id}/users/{user_id}"
|
|
};
|
|
}
|
|
rpc GetBudgetCategories(GetBudgetCategoriesReq) returns (Categories) {
|
|
option (google.api.http) = {
|
|
get: "/budgets/{budget_id}/categories"
|
|
};
|
|
}
|
|
|
|
// categories
|
|
rpc AddCategory(AddCategoryReq) returns (Category) {
|
|
option (google.api.http) = {
|
|
post: "/categories",
|
|
body: "*"
|
|
};
|
|
}
|
|
rpc UpdateCategory(UpdateCategoryReq) returns (Category) {
|
|
option (google.api.http) = {
|
|
put: "/categories/{id}"
|
|
};
|
|
}
|
|
rpc DeleteCategories(DeleteCategoriesReq) returns (Category) {
|
|
option (google.api.http) = {
|
|
delete: "/categories/{id}"
|
|
};
|
|
}
|
|
|
|
// wastes
|
|
rpc AddWaste(AddWasteReq) returns (Waste) {
|
|
option (google.api.http) = {
|
|
post: "/wastes",
|
|
body: "*"
|
|
};
|
|
}
|
|
rpc AddWasteByText(AddWasteTextReq) returns (Waste) {
|
|
option (google.api.http) = {
|
|
post: "/wastes/text",
|
|
body: "*"
|
|
};
|
|
}
|
|
rpc DeleteWaste(DeleteWasteReq) returns (Waste) {
|
|
option (google.api.http) = {
|
|
delete: "/wastes/{id}"
|
|
};
|
|
}
|
|
|
|
// stat
|
|
rpc GetCategoriesStat(GetCategoriesStatReq) returns (CategoriesStat) {
|
|
option (google.api.http) = {
|
|
get: "/stat"
|
|
};
|
|
}
|
|
}
|
|
|
|
message PingReq {}
|
|
|
|
message PingRsp {}
|
|
|
|
message OK {}
|
|
|
|
message AddUserReq {
|
|
string username = 1;
|
|
string password = 2;
|
|
}
|
|
|
|
message User {
|
|
int32 id = 1;
|
|
string username = 2;
|
|
}
|
|
|
|
message LoginReq {
|
|
string username = 1;
|
|
string password = 2;
|
|
}
|
|
|
|
message AddBudgetReq {
|
|
string name = 1;
|
|
int32 start_day = 2;
|
|
int32 monthly_limit = 3;
|
|
}
|
|
|
|
message Budget {
|
|
int32 id = 1;
|
|
string name = 2;
|
|
int32 start_day = 3;
|
|
int32 monthly_limit = 4;
|
|
repeated Category categories = 5;
|
|
}
|
|
|
|
message UpdateBudgetReq {
|
|
int32 id = 1;
|
|
string name = 2;
|
|
int32 start_day = 3;
|
|
int32 monthly_limit = 4;
|
|
}
|
|
|
|
message GetBudgetsReq {}
|
|
|
|
message Budgets {
|
|
repeated Budget budgets = 1;
|
|
}
|
|
|
|
message DeleteBudgetReq {
|
|
int32 id = 1;
|
|
}
|
|
|
|
message AddUserToBudgetReq {
|
|
int32 user_id = 1;
|
|
int32 budget_id = 2;
|
|
}
|
|
|
|
message GetBudgetUsersReq {
|
|
int32 id = 1;
|
|
}
|
|
|
|
message Users {
|
|
repeated User users = 1;
|
|
}
|
|
|
|
message RemoveUserFromBudgetReq {
|
|
int32 user_id = 1;
|
|
int32 budget_id = 2;
|
|
}
|
|
|
|
message GetBudgetCategoriesReq {
|
|
int32 budget_id = 2;
|
|
}
|
|
|
|
message AddCategoryReq {
|
|
string name = 1;
|
|
int32 budget_id = 2;
|
|
bool favorite = 3;
|
|
int32 monthly_limit = 4;
|
|
}
|
|
|
|
message Category {
|
|
int32 id = 1;
|
|
string name = 2;
|
|
int32 budget_id = 3;
|
|
bool favorite = 4;
|
|
int32 monthly_limit = 5;
|
|
}
|
|
|
|
message UpdateCategoryReq {
|
|
int32 id = 1;
|
|
string name = 2;
|
|
bool favorite = 3;
|
|
int32 monthly_limit = 4;
|
|
}
|
|
|
|
message Categories {
|
|
repeated Category categories = 1;
|
|
}
|
|
|
|
message DeleteCategoriesReq {
|
|
int32 id = 1;
|
|
}
|
|
|
|
message AddWasteReq {
|
|
string name = 1;
|
|
int32 price = 2;
|
|
float amount = 3;
|
|
int32 category_id = 4;
|
|
int32 budget_id = 5;
|
|
}
|
|
|
|
message AddWasteTextReq {
|
|
string text = 1;
|
|
int32 category_id = 2;
|
|
int32 budget_id = 3;
|
|
}
|
|
|
|
message Waste {
|
|
int32 id = 1;
|
|
string name = 2;
|
|
int32 price = 3;
|
|
float amount = 4;
|
|
}
|
|
|
|
message DeleteWasteReq {
|
|
int32 id = 1;
|
|
}
|
|
|
|
message GetCategoriesStatReq {
|
|
repeated int32 ids = 1;
|
|
}
|
|
|
|
message CategoriesStat {
|
|
repeated CategoriesStat stat = 1;
|
|
}
|
|
|
|
message CategoryStat {
|
|
string name = 1;
|
|
int32 monthly_limit = 2;
|
|
int32 amount = 3;
|
|
}
|