memo_service.proto 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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. // RenameMemoTag renames a tag for a memo.
  51. rpc RenameMemoTag(RenameMemoTagRequest) returns (google.protobuf.Empty) {
  52. option (google.api.http) = {
  53. patch: "/api/v1/{parent=memos/*}/tags:rename"
  54. body: "*"
  55. };
  56. }
  57. // DeleteMemoTag deletes a tag for a memo.
  58. rpc DeleteMemoTag(DeleteMemoTagRequest) returns (google.protobuf.Empty) {
  59. option (google.api.http) = {delete: "/api/v1/{parent=memos/*}/tags/{tag}"};
  60. }
  61. // SetMemoResources sets resources for a memo.
  62. rpc SetMemoResources(SetMemoResourcesRequest) returns (google.protobuf.Empty) {
  63. option (google.api.http) = {
  64. patch: "/api/v1/{name=memos/*}/resources"
  65. body: "*"
  66. };
  67. option (google.api.method_signature) = "name";
  68. }
  69. // ListMemoResources lists resources for a memo.
  70. rpc ListMemoResources(ListMemoResourcesRequest) returns (ListMemoResourcesResponse) {
  71. option (google.api.http) = {get: "/api/v1/{name=memos/*}/resources"};
  72. option (google.api.method_signature) = "name";
  73. }
  74. // SetMemoRelations sets relations for a memo.
  75. rpc SetMemoRelations(SetMemoRelationsRequest) returns (google.protobuf.Empty) {
  76. option (google.api.http) = {
  77. patch: "/api/v1/{name=memos/*}/relations"
  78. body: "*"
  79. };
  80. option (google.api.method_signature) = "name";
  81. }
  82. // ListMemoRelations lists relations for a memo.
  83. rpc ListMemoRelations(ListMemoRelationsRequest) returns (ListMemoRelationsResponse) {
  84. option (google.api.http) = {get: "/api/v1/{name=memos/*}/relations"};
  85. option (google.api.method_signature) = "name";
  86. }
  87. // CreateMemoComment creates a comment for a memo.
  88. rpc CreateMemoComment(CreateMemoCommentRequest) returns (Memo) {
  89. option (google.api.http) = {
  90. post: "/api/v1/{name=memos/*}/comments"
  91. body: "comment"
  92. };
  93. option (google.api.method_signature) = "name";
  94. }
  95. // ListMemoComments lists comments for a memo.
  96. rpc ListMemoComments(ListMemoCommentsRequest) returns (ListMemoCommentsResponse) {
  97. option (google.api.http) = {get: "/api/v1/{name=memos/*}/comments"};
  98. option (google.api.method_signature) = "name";
  99. }
  100. // ListMemoReactions lists reactions for a memo.
  101. rpc ListMemoReactions(ListMemoReactionsRequest) returns (ListMemoReactionsResponse) {
  102. option (google.api.http) = {get: "/api/v1/{name=memos/*}/reactions"};
  103. option (google.api.method_signature) = "name";
  104. }
  105. // UpsertMemoReaction upserts a reaction for a memo.
  106. rpc UpsertMemoReaction(UpsertMemoReactionRequest) returns (Reaction) {
  107. option (google.api.http) = {
  108. post: "/api/v1/{name=memos/*}/reactions"
  109. body: "*"
  110. };
  111. option (google.api.method_signature) = "name";
  112. }
  113. // DeleteMemoReaction deletes a reaction for a memo.
  114. rpc DeleteMemoReaction(DeleteMemoReactionRequest) returns (google.protobuf.Empty) {
  115. option (google.api.http) = {delete: "/api/v1/reactions/{id}"};
  116. option (google.api.method_signature) = "id";
  117. }
  118. }
  119. enum Visibility {
  120. VISIBILITY_UNSPECIFIED = 0;
  121. PRIVATE = 1;
  122. PROTECTED = 2;
  123. PUBLIC = 3;
  124. }
  125. message Memo {
  126. // The name of the memo.
  127. // Format: memos/{id}
  128. // id is the system generated id.
  129. string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  130. // The user defined id of the memo.
  131. string uid = 2;
  132. State state = 3;
  133. // The name of the creator.
  134. // Format: users/{user}
  135. string creator = 4;
  136. google.protobuf.Timestamp create_time = 5;
  137. google.protobuf.Timestamp update_time = 6;
  138. google.protobuf.Timestamp display_time = 7;
  139. string content = 8;
  140. repeated Node nodes = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
  141. Visibility visibility = 10;
  142. repeated string tags = 11 [(google.api.field_behavior) = OUTPUT_ONLY];
  143. bool pinned = 12;
  144. repeated Resource resources = 14;
  145. repeated MemoRelation relations = 15;
  146. repeated Reaction reactions = 16 [(google.api.field_behavior) = OUTPUT_ONLY];
  147. MemoProperty property = 17 [(google.api.field_behavior) = OUTPUT_ONLY];
  148. // The name of the parent memo.
  149. // Format: memos/{id}
  150. optional string parent = 18 [(google.api.field_behavior) = OUTPUT_ONLY];
  151. // The snippet of the memo content. Plain text only.
  152. string snippet = 19 [(google.api.field_behavior) = OUTPUT_ONLY];
  153. // The location of the memo.
  154. optional Location location = 20;
  155. }
  156. message MemoProperty {
  157. bool has_link = 1;
  158. bool has_task_list = 2;
  159. bool has_code = 3;
  160. bool has_incomplete_tasks = 4;
  161. }
  162. message Location {
  163. string placeholder = 1;
  164. double latitude = 2;
  165. double longitude = 3;
  166. }
  167. message CreateMemoRequest {
  168. string content = 1;
  169. Visibility visibility = 2;
  170. repeated Resource resources = 3;
  171. repeated MemoRelation relations = 4;
  172. optional Location location = 5;
  173. }
  174. message ListMemosRequest {
  175. // The maximum number of memos to return.
  176. int32 page_size = 1;
  177. // A page token, received from a previous `ListMemos` call.
  178. // Provide this to retrieve the subsequent page.
  179. string page_token = 2;
  180. // Filter is used to filter memos returned in the list.
  181. // Format: "creator == 'users/{user}' && visibilities == ['PUBLIC', 'PROTECTED']"
  182. string filter = 3;
  183. }
  184. message ListMemosResponse {
  185. repeated Memo memos = 1;
  186. // A token, which can be sent as `page_token` to retrieve the next page.
  187. // If this field is omitted, there are no subsequent pages.
  188. string next_page_token = 2;
  189. }
  190. message GetMemoRequest {
  191. // The name of the memo.
  192. // Format: memos/{id}
  193. string name = 1;
  194. }
  195. message GetMemoByUidRequest {
  196. // The uid of the memo.
  197. string uid = 1;
  198. }
  199. message UpdateMemoRequest {
  200. Memo memo = 1;
  201. google.protobuf.FieldMask update_mask = 2;
  202. }
  203. message DeleteMemoRequest {
  204. // The name of the memo.
  205. // Format: memos/{id}
  206. string name = 1;
  207. }
  208. message RenameMemoTagRequest {
  209. // The parent, who owns the tags.
  210. // Format: memos/{id}. Use "memos/-" to rename all tags.
  211. string parent = 1;
  212. string old_tag = 2;
  213. string new_tag = 3;
  214. }
  215. message DeleteMemoTagRequest {
  216. // The parent, who owns the tags.
  217. // Format: memos/{id}. Use "memos/-" to delete all tags.
  218. string parent = 1;
  219. string tag = 2;
  220. bool delete_related_memos = 3;
  221. }
  222. message SetMemoResourcesRequest {
  223. // The name of the memo.
  224. // Format: memos/{id}
  225. string name = 1;
  226. repeated Resource resources = 2;
  227. }
  228. message ListMemoResourcesRequest {
  229. // The name of the memo.
  230. // Format: memos/{id}
  231. string name = 1;
  232. }
  233. message ListMemoResourcesResponse {
  234. repeated Resource resources = 1;
  235. }
  236. message SetMemoRelationsRequest {
  237. // The name of the memo.
  238. // Format: memos/{id}
  239. string name = 1;
  240. repeated MemoRelation relations = 2;
  241. }
  242. message ListMemoRelationsRequest {
  243. // The name of the memo.
  244. // Format: memos/{id}
  245. string name = 1;
  246. }
  247. message ListMemoRelationsResponse {
  248. repeated MemoRelation relations = 1;
  249. }
  250. message CreateMemoCommentRequest {
  251. // The name of the memo.
  252. // Format: memos/{id}
  253. string name = 1;
  254. CreateMemoRequest comment = 2;
  255. }
  256. message ListMemoCommentsRequest {
  257. // The name of the memo.
  258. // Format: memos/{id}
  259. string name = 1;
  260. }
  261. message ListMemoCommentsResponse {
  262. repeated Memo memos = 1;
  263. }
  264. message ListMemoReactionsRequest {
  265. // The name of the memo.
  266. // Format: memos/{id}
  267. string name = 1;
  268. }
  269. message ListMemoReactionsResponse {
  270. repeated Reaction reactions = 1;
  271. }
  272. message UpsertMemoReactionRequest {
  273. // The name of the memo.
  274. // Format: memos/{id}
  275. string name = 1;
  276. Reaction reaction = 2;
  277. }
  278. message DeleteMemoReactionRequest {
  279. // The id of the reaction.
  280. // Refer to the `Reaction.id`.
  281. int32 id = 1;
  282. }