memo_service.proto 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. syntax = "proto3";
  2. package memos.api.v1;
  3. import "api/v1/common.proto";
  4. import "api/v1/markdown_service.proto";
  5. import "api/v1/memo_relation_service.proto";
  6. import "api/v1/reaction_service.proto";
  7. import "api/v1/resource_service.proto";
  8. import "google/api/annotations.proto";
  9. import "google/api/client.proto";
  10. import "google/api/field_behavior.proto";
  11. import "google/protobuf/empty.proto";
  12. import "google/protobuf/field_mask.proto";
  13. import "google/protobuf/timestamp.proto";
  14. option go_package = "gen/api/v1";
  15. service MemoService {
  16. // CreateMemo creates a memo.
  17. rpc CreateMemo(CreateMemoRequest) returns (Memo) {
  18. option (google.api.http) = {
  19. post: "/api/v1/memos"
  20. body: "*"
  21. };
  22. }
  23. // ListMemos lists memos with pagination and filter.
  24. rpc ListMemos(ListMemosRequest) returns (ListMemosResponse) {
  25. option (google.api.http) = {get: "/api/v1/memos"};
  26. }
  27. // GetMemo gets a memo.
  28. rpc GetMemo(GetMemoRequest) returns (Memo) {
  29. option (google.api.http) = {get: "/api/v1/{name=memos/*}"};
  30. option (google.api.method_signature) = "name";
  31. }
  32. // GetMemoByUid gets a memo by uid
  33. rpc GetMemoByUid(GetMemoByUidRequest) returns (Memo) {
  34. option (google.api.http) = {get: "/api/v1/memos:by-uid/{uid}"};
  35. option (google.api.method_signature) = "uid";
  36. }
  37. // UpdateMemo updates a memo.
  38. rpc UpdateMemo(UpdateMemoRequest) returns (Memo) {
  39. option (google.api.http) = {
  40. patch: "/api/v1/{memo.name=memos/*}"
  41. body: "memo"
  42. };
  43. option (google.api.method_signature) = "memo,update_mask";
  44. }
  45. // DeleteMemo deletes a memo.
  46. rpc DeleteMemo(DeleteMemoRequest) returns (google.protobuf.Empty) {
  47. option (google.api.http) = {delete: "/api/v1/{name=memos/*}"};
  48. option (google.api.method_signature) = "name";
  49. }
  50. // ListMemoProperties lists memo properties.
  51. rpc ListMemoProperties(ListMemoPropertiesRequest) returns (ListMemoPropertiesResponse) {
  52. option (google.api.http) = {get: "/api/v1/{name=memos/*}/properties"};
  53. }
  54. // RebuildMemoProperty rebuilds a memo property.
  55. rpc RebuildMemoProperty(RebuildMemoPropertyRequest) returns (google.protobuf.Empty) {
  56. option (google.api.http) = {
  57. post: "/api/v1/{name=memos/*}/properties:rebuild"
  58. body: "*"
  59. };
  60. }
  61. // ListMemoTags lists tags for a memo.
  62. rpc ListMemoTags(ListMemoTagsRequest) returns (ListMemoTagsResponse) {
  63. option (google.api.http) = {get: "/api/v1/{parent=memos/*}/tags"};
  64. }
  65. // RenameMemoTag renames a tag for a memo.
  66. rpc RenameMemoTag(RenameMemoTagRequest) returns (google.protobuf.Empty) {
  67. option (google.api.http) = {
  68. patch: "/api/v1/{parent=memos/*}/tags:rename"
  69. body: "*"
  70. };
  71. }
  72. // DeleteMemoTag deletes a tag for a memo.
  73. rpc DeleteMemoTag(DeleteMemoTagRequest) returns (google.protobuf.Empty) {
  74. option (google.api.http) = {delete: "/api/v1/{parent=memos/*}/tags/{tag}"};
  75. }
  76. // SetMemoResources sets resources for a memo.
  77. rpc SetMemoResources(SetMemoResourcesRequest) returns (google.protobuf.Empty) {
  78. option (google.api.http) = {
  79. patch: "/api/v1/{name=memos/*}/resources"
  80. body: "*"
  81. };
  82. option (google.api.method_signature) = "name";
  83. }
  84. // ListMemoResources lists resources for a memo.
  85. rpc ListMemoResources(ListMemoResourcesRequest) returns (ListMemoResourcesResponse) {
  86. option (google.api.http) = {get: "/api/v1/{name=memos/*}/resources"};
  87. option (google.api.method_signature) = "name";
  88. }
  89. // SetMemoRelations sets relations for a memo.
  90. rpc SetMemoRelations(SetMemoRelationsRequest) returns (google.protobuf.Empty) {
  91. option (google.api.http) = {
  92. patch: "/api/v1/{name=memos/*}/relations"
  93. body: "*"
  94. };
  95. option (google.api.method_signature) = "name";
  96. }
  97. // ListMemoRelations lists relations for a memo.
  98. rpc ListMemoRelations(ListMemoRelationsRequest) returns (ListMemoRelationsResponse) {
  99. option (google.api.http) = {get: "/api/v1/{name=memos/*}/relations"};
  100. option (google.api.method_signature) = "name";
  101. }
  102. // CreateMemoComment creates a comment for a memo.
  103. rpc CreateMemoComment(CreateMemoCommentRequest) returns (Memo) {
  104. option (google.api.http) = {
  105. post: "/api/v1/{name=memos/*}/comments"
  106. body: "comment"
  107. };
  108. option (google.api.method_signature) = "name";
  109. }
  110. // ListMemoComments lists comments for a memo.
  111. rpc ListMemoComments(ListMemoCommentsRequest) returns (ListMemoCommentsResponse) {
  112. option (google.api.http) = {get: "/api/v1/{name=memos/*}/comments"};
  113. option (google.api.method_signature) = "name";
  114. }
  115. // ListMemoReactions lists reactions for a memo.
  116. rpc ListMemoReactions(ListMemoReactionsRequest) returns (ListMemoReactionsResponse) {
  117. option (google.api.http) = {get: "/api/v1/{name=memos/*}/reactions"};
  118. option (google.api.method_signature) = "name";
  119. }
  120. // UpsertMemoReaction upserts a reaction for a memo.
  121. rpc UpsertMemoReaction(UpsertMemoReactionRequest) returns (Reaction) {
  122. option (google.api.http) = {
  123. post: "/api/v1/{name=memos/*}/reactions"
  124. body: "*"
  125. };
  126. option (google.api.method_signature) = "name";
  127. }
  128. // DeleteMemoReaction deletes a reaction for a memo.
  129. rpc DeleteMemoReaction(DeleteMemoReactionRequest) returns (google.protobuf.Empty) {
  130. option (google.api.http) = {delete: "/api/v1/reactions/{reaction_id}"};
  131. option (google.api.method_signature) = "reaction_id";
  132. }
  133. }
  134. enum Visibility {
  135. VISIBILITY_UNSPECIFIED = 0;
  136. PRIVATE = 1;
  137. PROTECTED = 2;
  138. PUBLIC = 3;
  139. }
  140. message Memo {
  141. // The name of the memo.
  142. // Format: memos/{id}
  143. // id is the system generated id.
  144. string name = 1;
  145. // The user defined id of the memo.
  146. string uid = 2;
  147. RowStatus row_status = 3;
  148. // The name of the creator.
  149. // Format: users/{id}
  150. string creator = 4;
  151. google.protobuf.Timestamp create_time = 5;
  152. google.protobuf.Timestamp update_time = 6;
  153. google.protobuf.Timestamp display_time = 7;
  154. string content = 8;
  155. repeated Node nodes = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
  156. Visibility visibility = 10;
  157. repeated string tags = 11;
  158. bool pinned = 12;
  159. repeated Resource resources = 14;
  160. repeated MemoRelation relations = 15;
  161. repeated Reaction reactions = 16 [(google.api.field_behavior) = OUTPUT_ONLY];
  162. MemoProperty property = 17 [(google.api.field_behavior) = OUTPUT_ONLY];
  163. // The name of the parent memo.
  164. // Format: memos/{id}
  165. optional string parent = 18 [(google.api.field_behavior) = OUTPUT_ONLY];
  166. // The snippet of the memo content. Plain text only.
  167. string snippet = 19;
  168. // The location of the memo.
  169. optional Location location = 20;
  170. }
  171. message MemoProperty {
  172. repeated string tags = 1;
  173. bool has_link = 2;
  174. bool has_task_list = 3;
  175. bool has_code = 4;
  176. bool has_incomplete_tasks = 5;
  177. }
  178. message Location {
  179. string placeholder = 1;
  180. double latitude = 2;
  181. double longitude = 3;
  182. }
  183. message CreateMemoRequest {
  184. string content = 1;
  185. Visibility visibility = 2;
  186. repeated Resource resources = 3;
  187. repeated MemoRelation relations = 4;
  188. optional Location location = 5;
  189. }
  190. message ListMemosRequest {
  191. // The maximum number of memos to return.
  192. int32 page_size = 1;
  193. // A page token, received from a previous `ListMemos` call.
  194. // Provide this to retrieve the subsequent page.
  195. string page_token = 2;
  196. // Filter is used to filter memos returned in the list.
  197. // Format: "creator == 'users/{uid}' && visibilities == ['PUBLIC', 'PROTECTED']"
  198. string filter = 3;
  199. }
  200. message ListMemosResponse {
  201. repeated Memo memos = 1;
  202. // A token, which can be sent as `page_token` to retrieve the next page.
  203. // If this field is omitted, there are no subsequent pages.
  204. string next_page_token = 2;
  205. }
  206. message GetMemoRequest {
  207. // The name of the memo.
  208. // Format: memos/{id}
  209. string name = 1;
  210. }
  211. message GetMemoByUidRequest {
  212. // The uid of the memo.
  213. string uid = 1;
  214. }
  215. message UpdateMemoRequest {
  216. Memo memo = 1;
  217. google.protobuf.FieldMask update_mask = 2;
  218. }
  219. message DeleteMemoRequest {
  220. // The name of the memo.
  221. // Format: memos/{id}
  222. string name = 1;
  223. }
  224. message ListMemoPropertiesRequest {
  225. // The name of the memo.
  226. // Format: memos/{id}. Use "memos/-" to list all properties.
  227. string name = 1;
  228. }
  229. message ListMemoPropertiesResponse {
  230. repeated MemoPropertyEntity entities = 1;
  231. }
  232. message MemoPropertyEntity {
  233. // The name of the memo property.
  234. // Format: memos/{id}/properties/{property_id}
  235. string name = 1;
  236. MemoProperty property = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
  237. google.protobuf.Timestamp display_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
  238. }
  239. message RebuildMemoPropertyRequest {
  240. // The name of the memo.
  241. // Format: memos/{id}. Use "memos/-" to rebuild all memos.
  242. string name = 1;
  243. }
  244. message ListMemoTagsRequest {
  245. // The parent, who owns the tags.
  246. // Format: memos/{id}. Use "memos/-" to list all tags.
  247. string parent = 1;
  248. // Filter is used to filter memos.
  249. // Format: "creator == 'users/{uid}' && visibilities == ['PUBLIC', 'PROTECTED']"
  250. string filter = 2;
  251. }
  252. message ListMemoTagsResponse {
  253. // tag_amounts is the amount of tags.
  254. // key is the tag name. e.g. "tag1".
  255. // value is the amount of the tag.
  256. map<string, int32> tag_amounts = 1;
  257. }
  258. message RenameMemoTagRequest {
  259. // The parent, who owns the tags.
  260. // Format: memos/{id}. Use "memos/-" to rename all tags.
  261. string parent = 1;
  262. string old_tag = 2;
  263. string new_tag = 3;
  264. }
  265. message DeleteMemoTagRequest {
  266. // The parent, who owns the tags.
  267. // Format: memos/{id}. Use "memos/-" to delete all tags.
  268. string parent = 1;
  269. string tag = 2;
  270. bool delete_related_memos = 3;
  271. }
  272. message SetMemoResourcesRequest {
  273. // The name of the memo.
  274. // Format: memos/{id}
  275. string name = 1;
  276. repeated Resource resources = 2;
  277. }
  278. message ListMemoResourcesRequest {
  279. // The name of the memo.
  280. // Format: memos/{id}
  281. string name = 1;
  282. }
  283. message ListMemoResourcesResponse {
  284. repeated Resource resources = 1;
  285. }
  286. message SetMemoRelationsRequest {
  287. // The name of the memo.
  288. // Format: memos/{id}
  289. string name = 1;
  290. repeated MemoRelation relations = 2;
  291. }
  292. message ListMemoRelationsRequest {
  293. // The name of the memo.
  294. // Format: memos/{id}
  295. string name = 1;
  296. }
  297. message ListMemoRelationsResponse {
  298. repeated MemoRelation relations = 1;
  299. }
  300. message CreateMemoCommentRequest {
  301. // The name of the memo.
  302. // Format: memos/{id}
  303. string name = 1;
  304. CreateMemoRequest comment = 2;
  305. }
  306. message ListMemoCommentsRequest {
  307. // The name of the memo.
  308. // Format: memos/{id}
  309. string name = 1;
  310. }
  311. message ListMemoCommentsResponse {
  312. repeated Memo memos = 1;
  313. }
  314. message ListMemoReactionsRequest {
  315. // The name of the memo.
  316. // Format: memos/{id}
  317. string name = 1;
  318. }
  319. message ListMemoReactionsResponse {
  320. repeated Reaction reactions = 1;
  321. }
  322. message UpsertMemoReactionRequest {
  323. // The name of the memo.
  324. // Format: memos/{id}
  325. string name = 1;
  326. Reaction reaction = 2;
  327. }
  328. message DeleteMemoReactionRequest {
  329. int32 reaction_id = 1;
  330. }