memos/proto/api/v1/memo_service.proto

390 lines
11 KiB
Protocol Buffer
Raw Permalink Normal View History

syntax = "proto3";
2024-04-27 19:44:29 +03:00
package memos.api.v1;
2024-04-27 19:44:29 +03:00
import "api/v1/common.proto";
2024-04-29 03:00:37 +03:00
import "api/v1/markdown_service.proto";
2024-04-27 19:44:29 +03: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 15:18:31 +03:00
import "google/api/field_behavior.proto";
2024-04-27 17:02:15 +03:00
import "google/protobuf/empty.proto";
2023-12-20 18:14:15 +03:00
import "google/protobuf/field_mask.proto";
2023-12-19 18:49:24 +03:00
import "google/protobuf/timestamp.proto";
2024-04-27 19:44:29 +03:00
option go_package = "gen/api/v1";
service MemoService {
2023-12-21 17:42:06 +03:00
// CreateMemo creates a memo.
2024-04-27 17:02:15 +03:00
rpc CreateMemo(CreateMemoRequest) returns (Memo) {
2023-12-20 18:14:15 +03:00
option (google.api.http) = {
2024-04-27 19:44:29 +03:00
post: "/api/v1/memos"
2023-12-20 18:14:15 +03:00
body: "*"
};
2023-10-01 09:44:10 +03:00
}
2023-12-21 17:42:06 +03:00
// ListMemos lists memos with pagination and filter.
rpc ListMemos(ListMemosRequest) returns (ListMemosResponse) {
2024-04-27 19:44:29 +03:00
option (google.api.http) = {get: "/api/v1/memos"};
}
2024-03-18 18:23:53 +03:00
// GetMemo gets a memo.
2024-04-27 17:02:15 +03:00
rpc GetMemo(GetMemoRequest) returns (Memo) {
2024-04-27 19:44:29 +03:00
option (google.api.http) = {get: "/api/v1/{name=memos/*}"};
2024-01-20 18:48:35 +03:00
option (google.api.method_signature) = "name";
}
2024-07-11 18:31:50 +03: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 17:42:06 +03:00
// UpdateMemo updates a memo.
2024-04-27 17:02:15 +03:00
rpc UpdateMemo(UpdateMemoRequest) returns (Memo) {
2023-12-20 18:14:15 +03:00
option (google.api.http) = {
2024-04-27 19:44:29 +03:00
patch: "/api/v1/{memo.name=memos/*}"
2024-02-06 15:55:27 +03:00
body: "memo"
2023-12-20 18:14:15 +03:00
};
2024-02-06 15:55:27 +03:00
option (google.api.method_signature) = "memo,update_mask";
2023-12-20 18:14:15 +03:00
}
2024-03-18 18:23:53 +03:00
// DeleteMemo deletes a memo.
2024-04-27 17:02:15 +03:00
rpc DeleteMemo(DeleteMemoRequest) returns (google.protobuf.Empty) {
2024-04-27 19:44:29 +03:00
option (google.api.http) = {delete: "/api/v1/{name=memos/*}"};
2024-03-18 18:23:53 +03:00
option (google.api.method_signature) = "name";
2023-12-20 18:14:15 +03:00
}
// ListMemoProperties lists memo properties.
rpc ListMemoProperties(ListMemoPropertiesRequest) returns (ListMemoPropertiesResponse) {
option (google.api.http) = {get: "/api/v1/{name=memos/*}/properties"};
}
2024-05-13 17:04:37 +03: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 17:04:37 +03:00
body: "*"
};
}
2024-05-08 15:03:01 +03: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 17:42:06 +03:00
// SetMemoResources sets resources for a memo.
2024-04-27 17:02:15 +03:00
rpc SetMemoResources(SetMemoResourcesRequest) returns (google.protobuf.Empty) {
2023-12-21 16:24:08 +03:00
option (google.api.http) = {
2024-04-27 19:44:29 +03:00
patch: "/api/v1/{name=memos/*}/resources"
2023-12-21 16:24:08 +03:00
body: "*"
};
2024-03-18 18:23:53 +03:00
option (google.api.method_signature) = "name";
2023-12-21 16:24:08 +03:00
}
2023-12-21 17:42:06 +03:00
// ListMemoResources lists resources for a memo.
rpc ListMemoResources(ListMemoResourcesRequest) returns (ListMemoResourcesResponse) {
2024-04-27 19:44:29 +03:00
option (google.api.http) = {get: "/api/v1/{name=memos/*}/resources"};
2024-03-18 18:23:53 +03:00
option (google.api.method_signature) = "name";
}
2023-12-21 17:42:06 +03:00
// SetMemoRelations sets relations for a memo.
2024-04-27 17:02:15 +03:00
rpc SetMemoRelations(SetMemoRelationsRequest) returns (google.protobuf.Empty) {
2023-12-21 16:24:08 +03:00
option (google.api.http) = {
2024-04-27 19:44:29 +03:00
patch: "/api/v1/{name=memos/*}/relations"
2023-12-21 16:24:08 +03:00
body: "*"
};
2024-03-18 18:23:53 +03:00
option (google.api.method_signature) = "name";
2023-12-21 16:24:08 +03:00
}
2023-12-21 17:42:06 +03:00
// ListMemoRelations lists relations for a memo.
2023-12-21 16:24:08 +03:00
rpc ListMemoRelations(ListMemoRelationsRequest) returns (ListMemoRelationsResponse) {
2024-04-27 19:44:29 +03:00
option (google.api.http) = {get: "/api/v1/{name=memos/*}/relations"};
2024-03-18 18:23:53 +03:00
option (google.api.method_signature) = "name";
2023-12-21 16:24:08 +03:00
}
2023-12-21 17:42:06 +03:00
// CreateMemoComment creates a comment for a memo.
2024-04-27 17:02:15 +03:00
rpc CreateMemoComment(CreateMemoCommentRequest) returns (Memo) {
2024-04-16 17:33:25 +03:00
option (google.api.http) = {
2024-06-19 17:07:51 +03:00
post: "/api/v1/{name=memos/*}/comments"
2024-04-27 17:02:15 +03:00
body: "comment"
2024-04-16 17:33:25 +03:00
};
2024-03-18 18:23:53 +03:00
option (google.api.method_signature) = "name";
2023-10-01 09:44:10 +03:00
}
2023-12-21 17:42:06 +03:00
// ListMemoComments lists comments for a memo.
2023-10-01 09:44:10 +03:00
rpc ListMemoComments(ListMemoCommentsRequest) returns (ListMemoCommentsResponse) {
2024-04-27 19:44:29 +03:00
option (google.api.http) = {get: "/api/v1/{name=memos/*}/comments"};
2024-03-18 18:23:53 +03:00
option (google.api.method_signature) = "name";
2023-10-01 09:44:10 +03:00
}
2024-02-08 06:54:59 +03:00
// ListMemoReactions lists reactions for a memo.
rpc ListMemoReactions(ListMemoReactionsRequest) returns (ListMemoReactionsResponse) {
2024-04-27 19:44:29 +03:00
option (google.api.http) = {get: "/api/v1/{name=memos/*}/reactions"};
2024-03-18 18:23:53 +03:00
option (google.api.method_signature) = "name";
2024-02-08 06:54:59 +03:00
}
// UpsertMemoReaction upserts a reaction for a memo.
2024-04-27 17:02:15 +03:00
rpc UpsertMemoReaction(UpsertMemoReactionRequest) returns (Reaction) {
2024-04-16 17:33:25 +03:00
option (google.api.http) = {
2024-06-19 17:07:51 +03:00
post: "/api/v1/{name=memos/*}/reactions"
2024-04-16 17:33:25 +03:00
body: "*"
};
2024-03-18 18:23:53 +03:00
option (google.api.method_signature) = "name";
2024-02-08 06:54:59 +03:00
}
// DeleteMemoReaction deletes a reaction for a memo.
2024-04-27 17:02:15 +03:00
rpc DeleteMemoReaction(DeleteMemoReactionRequest) returns (google.protobuf.Empty) {
2024-04-27 19:44:29 +03:00
option (google.api.http) = {delete: "/api/v1/reactions/{reaction_id}"};
2024-04-08 15:52:46 +03:00
option (google.api.method_signature) = "reaction_id";
2024-02-08 06:54:59 +03:00
}
2023-10-01 09:44:10 +03:00
}
enum Visibility {
VISIBILITY_UNSPECIFIED = 0;
PRIVATE = 1;
PROTECTED = 2;
PUBLIC = 3;
}
message Memo {
2024-03-18 18:23:53 +03:00
// The name of the memo.
2024-03-20 15:39:16 +03:00
// Format: memos/{id}
// id is the system generated id.
2024-03-18 18:23:53 +03:00
string name = 1;
2024-03-20 15:39:16 +03:00
// The user defined id of the memo.
string uid = 2;
2024-01-20 18:48:35 +03:00
RowStatus row_status = 3;
2023-12-21 17:42:06 +03:00
// The name of the creator.
2024-03-20 15:39:16 +03:00
// Format: users/{id}
2024-01-20 18:48:35 +03:00
string creator = 4;
2023-12-21 17:42:06 +03:00
2024-03-18 07:56:52 +03:00
google.protobuf.Timestamp create_time = 5;
2024-03-18 07:56:52 +03:00
google.protobuf.Timestamp update_time = 6;
2024-04-29 03:00:37 +03:00
google.protobuf.Timestamp display_time = 7;
2024-03-18 07:56:52 +03:00
string content = 8;
2024-04-29 03:00:37 +03:00
repeated Node nodes = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
2024-04-29 03:00:37 +03:00
Visibility visibility = 10;
2023-12-19 18:49:24 +03:00
2024-05-08 15:03:01 +03:00
repeated string tags = 11;
2023-12-22 15:18:31 +03:00
2024-05-08 15:03:01 +03:00
bool pinned = 12;
2023-12-22 15:18:31 +03:00
2024-05-22 16:52:41 +03:00
optional int32 parent_id = 13 [
deprecated = true,
(google.api.field_behavior) = OUTPUT_ONLY
];
2024-05-22 16:52:41 +03:00
repeated Resource resources = 14 [(google.api.field_behavior) = OUTPUT_ONLY];
2024-05-22 16:52:41 +03:00
repeated MemoRelation relations = 15 [(google.api.field_behavior) = OUTPUT_ONLY];
2024-05-22 16:52:41 +03:00
repeated Reaction reactions = 16 [(google.api.field_behavior) = OUTPUT_ONLY];
2024-04-29 03:00:37 +03:00
2024-05-22 16:52:41 +03: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 15:03:01 +03:00
message MemoProperty {
repeated string tags = 1;
bool has_link = 2;
bool has_task_list = 3;
2024-05-27 14:43:57 +03:00
bool has_code = 4;
bool has_incomplete_tasks = 5;
}
2023-10-01 09:44:10 +03:00
message CreateMemoRequest {
string content = 1;
Visibility visibility = 2;
}
message ListMemosRequest {
2024-01-27 06:14:17 +03:00
// The maximum number of memos to return.
int32 page_size = 1;
2024-01-27 06:14:17 +03: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 17:15:51 +03:00
// Format: "creator == 'users/{uid}' && visibilities == ['PUBLIC', 'PROTECTED']"
string filter = 3;
}
message ListMemosResponse {
repeated Memo memos = 1;
2024-01-27 06:14:17 +03: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 18:23:53 +03:00
message GetMemoRequest {
// The name of the memo.
2024-03-20 15:39:16 +03:00
// Format: memos/{id}
2024-01-20 18:48:35 +03:00
string name = 1;
}
2024-07-11 18:31:50 +03:00
message GetMemoByUidRequest {
// The uid of the memo.
string uid = 1;
}
2023-12-20 18:14:15 +03:00
message UpdateMemoRequest {
2024-02-06 15:55:27 +03:00
Memo memo = 1;
2023-12-20 18:14:15 +03:00
2024-02-06 15:55:27 +03:00
google.protobuf.FieldMask update_mask = 2;
2023-12-20 18:14:15 +03:00
}
message DeleteMemoRequest {
2024-03-18 18:23:53 +03:00
// The name of the memo.
2024-03-20 15:39:16 +03:00
// Format: memos/{id}
2024-03-18 18:23:53 +03:00
string name = 1;
2023-12-20 18:14:15 +03:00
}
message ListMemoPropertiesRequest {
// The name of the memo.
// Format: memos/{id}. Use "memos/-" to list all properties.
string name = 1;
}
message ListMemoPropertiesResponse {
2024-07-27 04:47:12 +03: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 17:04:37 +03:00
message RebuildMemoPropertyRequest {
// The name of the memo.
// Format: memos/{id}. Use "memos/-" to rebuild all memos.
string name = 1;
}
2024-05-08 15:03:01 +03:00
message ListMemoTagsRequest {
// The parent, who owns the tags.
// Format: memos/{id}. Use "memos/-" to list all tags.
string parent = 1;
2024-05-14 03:12:25 +03:00
// Filter is used to filter memos.
2024-05-20 17:15:51 +03:00
// Format: "creator == 'users/{uid}' && visibilities == ['PUBLIC', 'PROTECTED']"
2024-05-14 03:12:25 +03:00
string filter = 2;
2024-05-08 15:03:01 +03: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 16:24:08 +03:00
message SetMemoResourcesRequest {
2024-03-18 18:23:53 +03:00
// The name of the memo.
2024-03-20 15:39:16 +03:00
// Format: memos/{id}
2024-03-18 18:23:53 +03:00
string name = 1;
2023-12-21 16:24:08 +03:00
repeated Resource resources = 2;
}
message ListMemoResourcesRequest {
2024-03-18 18:23:53 +03:00
// The name of the memo.
2024-03-20 15:39:16 +03:00
// Format: memos/{id}
2024-03-18 18:23:53 +03:00
string name = 1;
}
message ListMemoResourcesResponse {
repeated Resource resources = 1;
}
2023-12-21 16:24:08 +03:00
message SetMemoRelationsRequest {
2024-03-18 18:23:53 +03:00
// The name of the memo.
2024-03-20 15:39:16 +03:00
// Format: memos/{id}
2024-03-18 18:23:53 +03:00
string name = 1;
2023-12-21 16:24:08 +03:00
repeated MemoRelation relations = 2;
}
message ListMemoRelationsRequest {
2024-03-18 18:23:53 +03:00
// The name of the memo.
2024-03-20 15:39:16 +03:00
// Format: memos/{id}
2024-03-18 18:23:53 +03:00
string name = 1;
2023-12-21 16:24:08 +03:00
}
message ListMemoRelationsResponse {
repeated MemoRelation relations = 1;
}
2023-10-01 09:44:10 +03:00
message CreateMemoCommentRequest {
2024-03-18 18:23:53 +03:00
// The name of the memo.
2024-03-20 15:39:16 +03:00
// Format: memos/{id}
2024-03-18 18:23:53 +03:00
string name = 1;
2024-03-18 18:23:53 +03:00
CreateMemoRequest comment = 2;
2023-10-01 09:44:10 +03:00
}
2023-10-01 09:44:10 +03:00
message ListMemoCommentsRequest {
2024-03-18 18:23:53 +03:00
// The name of the memo.
2024-03-20 15:39:16 +03:00
// Format: memos/{id}
2024-03-18 18:23:53 +03:00
string name = 1;
2023-10-01 09:44:10 +03:00
}
message ListMemoCommentsResponse {
repeated Memo memos = 1;
}
2024-02-08 06:54:59 +03:00
message ListMemoReactionsRequest {
2024-03-18 18:23:53 +03:00
// The name of the memo.
2024-03-20 15:39:16 +03:00
// Format: memos/{id}
2024-03-18 18:23:53 +03:00
string name = 1;
}
2024-02-08 06:54:59 +03:00
message ListMemoReactionsResponse {
repeated Reaction reactions = 1;
}
message UpsertMemoReactionRequest {
2024-03-18 18:23:53 +03:00
// The name of the memo.
2024-03-20 15:39:16 +03:00
// Format: memos/{id}
2024-03-18 18:23:53 +03:00
string name = 1;
2024-02-08 06:54:59 +03:00
Reaction reaction = 2;
}
message DeleteMemoReactionRequest {
2024-04-08 15:52:46 +03:00
int32 reaction_id = 1;
2024-02-08 06:54:59 +03:00
}