memos/proto/api/v1/memo_service.proto

406 lines
11 KiB
Protocol Buffer
Raw Normal View History

syntax = "proto3";
2024-04-28 00:44:29 +08:00
package memos.api.v1;
2024-04-28 00:44:29 +08:00
import "api/v1/common.proto";
2024-04-29 08:00:37 +08:00
import "api/v1/markdown_service.proto";
2024-04-28 00:44:29 +08:00
import "api/v1/memo_relation_service.proto";
import "api/v1/reaction_service.proto";
import "api/v1/resource_service.proto";
import "google/api/annotations.proto";
import "google/api/client.proto";
2023-12-22 20:18:31 +08:00
import "google/api/field_behavior.proto";
2024-04-27 22:02:15 +08:00
import "google/protobuf/empty.proto";
2023-12-20 23:14:15 +08:00
import "google/protobuf/field_mask.proto";
2023-12-19 23:49:24 +08:00
import "google/protobuf/timestamp.proto";
2024-04-28 00:44:29 +08:00
option go_package = "gen/api/v1";
service MemoService {
2023-12-21 22:42:06 +08:00
// CreateMemo creates a memo.
2024-04-27 22:02:15 +08:00
rpc CreateMemo(CreateMemoRequest) returns (Memo) {
2023-12-20 23:14:15 +08:00
option (google.api.http) = {
2024-04-28 00:44:29 +08:00
post: "/api/v1/memos"
2023-12-20 23:14:15 +08:00
body: "*"
};
2023-10-01 14:44:10 +08:00
}
2023-12-21 22:42:06 +08:00
// ListMemos lists memos with pagination and filter.
rpc ListMemos(ListMemosRequest) returns (ListMemosResponse) {
2024-04-28 00:44:29 +08:00
option (google.api.http) = {get: "/api/v1/memos"};
}
2024-03-18 23:23:53 +08:00
// GetMemo gets a memo.
2024-04-27 22:02:15 +08:00
rpc GetMemo(GetMemoRequest) returns (Memo) {
2024-04-28 00:44:29 +08:00
option (google.api.http) = {get: "/api/v1/{name=memos/*}"};
2024-01-20 23:48:35 +08:00
option (google.api.method_signature) = "name";
}
2024-07-11 23:31:50 +08:00
// GetMemoByUid gets a memo by uid
rpc GetMemoByUid(GetMemoByUidRequest) returns (Memo) {
option (google.api.http) = {get: "/api/v1/memos:by-uid/{uid}"};
option (google.api.method_signature) = "uid";
}
2023-12-21 22:42:06 +08:00
// UpdateMemo updates a memo.
2024-04-27 22:02:15 +08:00
rpc UpdateMemo(UpdateMemoRequest) returns (Memo) {
2023-12-20 23:14:15 +08:00
option (google.api.http) = {
2024-04-28 00:44:29 +08:00
patch: "/api/v1/{memo.name=memos/*}"
2024-02-06 20:55:27 +08:00
body: "memo"
2023-12-20 23:14:15 +08:00
};
2024-02-06 20:55:27 +08:00
option (google.api.method_signature) = "memo,update_mask";
2023-12-20 23:14:15 +08:00
}
2024-03-18 23:23:53 +08:00
// DeleteMemo deletes a memo.
2024-04-27 22:02:15 +08:00
rpc DeleteMemo(DeleteMemoRequest) returns (google.protobuf.Empty) {
2024-04-28 00:44:29 +08:00
option (google.api.http) = {delete: "/api/v1/{name=memos/*}"};
2024-03-18 23:23:53 +08:00
option (google.api.method_signature) = "name";
2023-12-20 23:14:15 +08:00
}
2024-02-08 11:54:59 +08:00
// ExportMemos exports memos.
rpc ExportMemos(ExportMemosRequest) returns (ExportMemosResponse) {
2024-04-16 22:33:25 +08:00
option (google.api.http) = {
2024-06-19 22:07:51 +08:00
post: "/api/v1/memos:export"
2024-04-16 22:33:25 +08:00
body: "*"
};
2024-02-08 11:54:59 +08:00
}
// ListMemoProperties lists memo properties.
rpc ListMemoProperties(ListMemoPropertiesRequest) returns (ListMemoPropertiesResponse) {
option (google.api.http) = {get: "/api/v1/{name=memos/*}/properties"};
}
2024-05-13 22:04:37 +08:00
// RebuildMemoProperty rebuilds a memo property.
rpc RebuildMemoProperty(RebuildMemoPropertyRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
post: "/api/v1/{name=memos/*}/properties:rebuild"
2024-05-13 22:04:37 +08:00
body: "*"
};
}
2024-05-08 20:03:01 +08:00
// ListMemoTags lists tags for a memo.
rpc ListMemoTags(ListMemoTagsRequest) returns (ListMemoTagsResponse) {
option (google.api.http) = {get: "/api/v1/{parent=memos/*}/tags"};
}
// RenameMemoTag renames a tag for a memo.
rpc RenameMemoTag(RenameMemoTagRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
patch: "/api/v1/{parent=memos/*}/tags:rename"
body: "*"
};
}
// DeleteMemoTag deletes a tag for a memo.
rpc DeleteMemoTag(DeleteMemoTagRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {delete: "/api/v1/{parent=memos/*}/tags/{tag}"};
}
2023-12-21 22:42:06 +08:00
// SetMemoResources sets resources for a memo.
2024-04-27 22:02:15 +08:00
rpc SetMemoResources(SetMemoResourcesRequest) returns (google.protobuf.Empty) {
2023-12-21 21:24:08 +08:00
option (google.api.http) = {
2024-04-28 00:44:29 +08:00
patch: "/api/v1/{name=memos/*}/resources"
2023-12-21 21:24:08 +08:00
body: "*"
};
2024-03-18 23:23:53 +08:00
option (google.api.method_signature) = "name";
2023-12-21 21:24:08 +08:00
}
2023-12-21 22:42:06 +08:00
// ListMemoResources lists resources for a memo.
rpc ListMemoResources(ListMemoResourcesRequest) returns (ListMemoResourcesResponse) {
2024-04-28 00:44:29 +08:00
option (google.api.http) = {get: "/api/v1/{name=memos/*}/resources"};
2024-03-18 23:23:53 +08:00
option (google.api.method_signature) = "name";
}
2023-12-21 22:42:06 +08:00
// SetMemoRelations sets relations for a memo.
2024-04-27 22:02:15 +08:00
rpc SetMemoRelations(SetMemoRelationsRequest) returns (google.protobuf.Empty) {
2023-12-21 21:24:08 +08:00
option (google.api.http) = {
2024-04-28 00:44:29 +08:00
patch: "/api/v1/{name=memos/*}/relations"
2023-12-21 21:24:08 +08:00
body: "*"
};
2024-03-18 23:23:53 +08:00
option (google.api.method_signature) = "name";
2023-12-21 21:24:08 +08:00
}
2023-12-21 22:42:06 +08:00
// ListMemoRelations lists relations for a memo.
2023-12-21 21:24:08 +08:00
rpc ListMemoRelations(ListMemoRelationsRequest) returns (ListMemoRelationsResponse) {
2024-04-28 00:44:29 +08:00
option (google.api.http) = {get: "/api/v1/{name=memos/*}/relations"};
2024-03-18 23:23:53 +08:00
option (google.api.method_signature) = "name";
2023-12-21 21:24:08 +08:00
}
2023-12-21 22:42:06 +08:00
// CreateMemoComment creates a comment for a memo.
2024-04-27 22:02:15 +08:00
rpc CreateMemoComment(CreateMemoCommentRequest) returns (Memo) {
2024-04-16 22:33:25 +08:00
option (google.api.http) = {
2024-06-19 22:07:51 +08:00
post: "/api/v1/{name=memos/*}/comments"
2024-04-27 22:02:15 +08:00
body: "comment"
2024-04-16 22:33:25 +08:00
};
2024-03-18 23:23:53 +08:00
option (google.api.method_signature) = "name";
2023-10-01 14:44:10 +08:00
}
2023-12-21 22:42:06 +08:00
// ListMemoComments lists comments for a memo.
2023-10-01 14:44:10 +08:00
rpc ListMemoComments(ListMemoCommentsRequest) returns (ListMemoCommentsResponse) {
2024-04-28 00:44:29 +08:00
option (google.api.http) = {get: "/api/v1/{name=memos/*}/comments"};
2024-03-18 23:23:53 +08:00
option (google.api.method_signature) = "name";
2023-10-01 14:44:10 +08:00
}
2024-02-08 11:54:59 +08:00
// ListMemoReactions lists reactions for a memo.
rpc ListMemoReactions(ListMemoReactionsRequest) returns (ListMemoReactionsResponse) {
2024-04-28 00:44:29 +08:00
option (google.api.http) = {get: "/api/v1/{name=memos/*}/reactions"};
2024-03-18 23:23:53 +08:00
option (google.api.method_signature) = "name";
2024-02-08 11:54:59 +08:00
}
// UpsertMemoReaction upserts a reaction for a memo.
2024-04-27 22:02:15 +08:00
rpc UpsertMemoReaction(UpsertMemoReactionRequest) returns (Reaction) {
2024-04-16 22:33:25 +08:00
option (google.api.http) = {
2024-06-19 22:07:51 +08:00
post: "/api/v1/{name=memos/*}/reactions"
2024-04-16 22:33:25 +08:00
body: "*"
};
2024-03-18 23:23:53 +08:00
option (google.api.method_signature) = "name";
2024-02-08 11:54:59 +08:00
}
// DeleteMemoReaction deletes a reaction for a memo.
2024-04-27 22:02:15 +08:00
rpc DeleteMemoReaction(DeleteMemoReactionRequest) returns (google.protobuf.Empty) {
2024-04-28 00:44:29 +08:00
option (google.api.http) = {delete: "/api/v1/reactions/{reaction_id}"};
2024-04-08 20:52:46 +08:00
option (google.api.method_signature) = "reaction_id";
2024-02-08 11:54:59 +08:00
}
2023-10-01 14:44:10 +08:00
}
enum Visibility {
VISIBILITY_UNSPECIFIED = 0;
PRIVATE = 1;
PROTECTED = 2;
PUBLIC = 3;
}
message Memo {
2024-03-18 23:23:53 +08:00
// The name of the memo.
2024-03-20 20:39:16 +08:00
// Format: memos/{id}
// id is the system generated id.
2024-03-18 23:23:53 +08:00
string name = 1;
2024-03-20 20:39:16 +08:00
// The user defined id of the memo.
string uid = 2;
2024-01-20 23:48:35 +08:00
RowStatus row_status = 3;
2023-12-21 22:42:06 +08:00
// The name of the creator.
2024-03-20 20:39:16 +08:00
// Format: users/{id}
2024-01-20 23:48:35 +08:00
string creator = 4;
2023-12-21 22:42:06 +08:00
2024-03-18 12:56:52 +08:00
google.protobuf.Timestamp create_time = 5;
2024-03-18 12:56:52 +08:00
google.protobuf.Timestamp update_time = 6;
2024-04-29 08:00:37 +08:00
google.protobuf.Timestamp display_time = 7;
2024-03-18 12:56:52 +08:00
string content = 8;
2024-04-29 08:00:37 +08:00
repeated Node nodes = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
2024-04-29 08:00:37 +08:00
Visibility visibility = 10;
2023-12-19 23:49:24 +08:00
2024-05-08 20:03:01 +08:00
repeated string tags = 11;
2023-12-22 20:18:31 +08:00
2024-05-08 20:03:01 +08:00
bool pinned = 12;
2023-12-22 20:18:31 +08:00
2024-05-22 21:52:41 +08:00
optional int32 parent_id = 13 [
deprecated = true,
(google.api.field_behavior) = OUTPUT_ONLY
];
2024-05-22 21:52:41 +08:00
repeated Resource resources = 14 [(google.api.field_behavior) = OUTPUT_ONLY];
2024-05-22 21:52:41 +08:00
repeated MemoRelation relations = 15 [(google.api.field_behavior) = OUTPUT_ONLY];
2024-05-22 21:52:41 +08:00
repeated Reaction reactions = 16 [(google.api.field_behavior) = OUTPUT_ONLY];
2024-04-29 08:00:37 +08:00
2024-05-22 21:52:41 +08:00
MemoProperty property = 17 [(google.api.field_behavior) = OUTPUT_ONLY];
// The name of the parent memo.
// Format: memos/{id}
optional string parent = 18 [(google.api.field_behavior) = OUTPUT_ONLY];
// The snippet of the memo content. Plain text only.
string snippet = 19;
}
2024-05-08 20:03:01 +08:00
message MemoProperty {
repeated string tags = 1;
bool has_link = 2;
bool has_task_list = 3;
2024-05-27 19:43:57 +08:00
bool has_code = 4;
bool has_incomplete_tasks = 5;
}
2023-10-01 14:44:10 +08:00
message CreateMemoRequest {
string content = 1;
Visibility visibility = 2;
}
message ListMemosRequest {
2024-01-27 11:14:17 +08:00
// The maximum number of memos to return.
int32 page_size = 1;
2024-01-27 11:14:17 +08:00
// A page token, received from a previous `ListMemos` call.
// Provide this to retrieve the subsequent page.
string page_token = 2;
// Filter is used to filter memos returned in the list.
2024-05-20 22:15:51 +08:00
// Format: "creator == 'users/{uid}' && visibilities == ['PUBLIC', 'PROTECTED']"
string filter = 3;
}
message ListMemosResponse {
repeated Memo memos = 1;
2024-01-27 11:14:17 +08:00
// A token, which can be sent as `page_token` to retrieve the next page.
// If this field is omitted, there are no subsequent pages.
string next_page_token = 2;
}
2024-03-18 23:23:53 +08:00
message GetMemoRequest {
// The name of the memo.
2024-03-20 20:39:16 +08:00
// Format: memos/{id}
2024-01-20 23:48:35 +08:00
string name = 1;
}
2024-07-11 23:31:50 +08:00
message GetMemoByUidRequest {
// The uid of the memo.
string uid = 1;
}
2023-12-20 23:14:15 +08:00
message UpdateMemoRequest {
2024-02-06 20:55:27 +08:00
Memo memo = 1;
2023-12-20 23:14:15 +08:00
2024-02-06 20:55:27 +08:00
google.protobuf.FieldMask update_mask = 2;
2023-12-20 23:14:15 +08:00
}
message DeleteMemoRequest {
2024-03-18 23:23:53 +08:00
// The name of the memo.
2024-03-20 20:39:16 +08:00
// Format: memos/{id}
2024-03-18 23:23:53 +08:00
string name = 1;
2023-12-20 23:14:15 +08:00
}
2024-02-08 11:54:59 +08:00
message ExportMemosRequest {
// Same as ListMemosRequest.filter
string filter = 1;
}
message ExportMemosResponse {
bytes content = 1;
}
message ListMemoPropertiesRequest {
// The name of the memo.
// Format: memos/{id}. Use "memos/-" to list all properties.
string name = 1;
}
message ListMemoPropertiesResponse {
2024-07-27 09:47:12 +08:00
repeated MemoPropertyEntity entities = 1;
}
message MemoPropertyEntity {
// The name of the memo property.
// Format: memos/{id}/properties/{property_id}
string name = 1;
MemoProperty property = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
google.protobuf.Timestamp display_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
}
2024-05-13 22:04:37 +08:00
message RebuildMemoPropertyRequest {
// The name of the memo.
// Format: memos/{id}. Use "memos/-" to rebuild all memos.
string name = 1;
}
2024-05-08 20:03:01 +08:00
message ListMemoTagsRequest {
// The parent, who owns the tags.
// Format: memos/{id}. Use "memos/-" to list all tags.
string parent = 1;
2024-05-14 08:12:25 +08:00
// Filter is used to filter memos.
2024-05-20 22:15:51 +08:00
// Format: "creator == 'users/{uid}' && visibilities == ['PUBLIC', 'PROTECTED']"
2024-05-14 08:12:25 +08:00
string filter = 2;
2024-05-08 20:03:01 +08:00
}
message ListMemoTagsResponse {
// tag_amounts is the amount of tags.
// key is the tag name. e.g. "tag1".
// value is the amount of the tag.
map<string, int32> tag_amounts = 1;
}
message RenameMemoTagRequest {
// The parent, who owns the tags.
// Format: memos/{id}. Use "memos/-" to rename all tags.
string parent = 1;
string old_tag = 2;
string new_tag = 3;
}
message DeleteMemoTagRequest {
// The parent, who owns the tags.
// Format: memos/{id}. Use "memos/-" to delete all tags.
string parent = 1;
string tag = 2;
bool delete_related_memos = 3;
}
2023-12-21 21:24:08 +08:00
message SetMemoResourcesRequest {
2024-03-18 23:23:53 +08:00
// The name of the memo.
2024-03-20 20:39:16 +08:00
// Format: memos/{id}
2024-03-18 23:23:53 +08:00
string name = 1;
2023-12-21 21:24:08 +08:00
repeated Resource resources = 2;
}
message ListMemoResourcesRequest {
2024-03-18 23:23:53 +08:00
// The name of the memo.
2024-03-20 20:39:16 +08:00
// Format: memos/{id}
2024-03-18 23:23:53 +08:00
string name = 1;
}
message ListMemoResourcesResponse {
repeated Resource resources = 1;
}
2023-12-21 21:24:08 +08:00
message SetMemoRelationsRequest {
2024-03-18 23:23:53 +08:00
// The name of the memo.
2024-03-20 20:39:16 +08:00
// Format: memos/{id}
2024-03-18 23:23:53 +08:00
string name = 1;
2023-12-21 21:24:08 +08:00
repeated MemoRelation relations = 2;
}
message ListMemoRelationsRequest {
2024-03-18 23:23:53 +08:00
// The name of the memo.
2024-03-20 20:39:16 +08:00
// Format: memos/{id}
2024-03-18 23:23:53 +08:00
string name = 1;
2023-12-21 21:24:08 +08:00
}
message ListMemoRelationsResponse {
repeated MemoRelation relations = 1;
}
2023-10-01 14:44:10 +08:00
message CreateMemoCommentRequest {
2024-03-18 23:23:53 +08:00
// The name of the memo.
2024-03-20 20:39:16 +08:00
// Format: memos/{id}
2024-03-18 23:23:53 +08:00
string name = 1;
2024-03-18 23:23:53 +08:00
CreateMemoRequest comment = 2;
2023-10-01 14:44:10 +08:00
}
2023-10-01 14:44:10 +08:00
message ListMemoCommentsRequest {
2024-03-18 23:23:53 +08:00
// The name of the memo.
2024-03-20 20:39:16 +08:00
// Format: memos/{id}
2024-03-18 23:23:53 +08:00
string name = 1;
2023-10-01 14:44:10 +08:00
}
message ListMemoCommentsResponse {
repeated Memo memos = 1;
}
2024-02-08 11:54:59 +08:00
message ListMemoReactionsRequest {
2024-03-18 23:23:53 +08:00
// The name of the memo.
2024-03-20 20:39:16 +08:00
// Format: memos/{id}
2024-03-18 23:23:53 +08:00
string name = 1;
}
2024-02-08 11:54:59 +08:00
message ListMemoReactionsResponse {
repeated Reaction reactions = 1;
}
message UpsertMemoReactionRequest {
2024-03-18 23:23:53 +08:00
// The name of the memo.
2024-03-20 20:39:16 +08:00
// Format: memos/{id}
2024-03-18 23:23:53 +08:00
string name = 1;
2024-02-08 11:54:59 +08:00
Reaction reaction = 2;
}
message DeleteMemoReactionRequest {
2024-04-08 20:52:46 +08:00
int32 reaction_id = 1;
2024-02-08 11:54:59 +08:00
}