memo_service.proto 9.1 KB

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