memos/proto/api/v2/memo_service.proto

350 lines
9.1 KiB
Protocol Buffer
Raw Normal View History

syntax = "proto3";
package memos.api.v2;
import "api/v2/common.proto";
2023-12-21 21:24:08 +08:00
import "api/v2/memo_relation_service.proto";
2024-02-08 11:54:59 +08:00
import "api/v2/reaction_service.proto";
import "api/v2/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";
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";
option go_package = "gen/api/v2";
service MemoService {
2023-12-21 22:42:06 +08:00
// CreateMemo creates a memo.
2023-10-01 14:44:10 +08:00
rpc CreateMemo(CreateMemoRequest) returns (CreateMemoResponse) {
2023-12-20 23:14:15 +08:00
option (google.api.http) = {
post: "/api/v2/memos"
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) {
option (google.api.http) = {get: "/api/v2/memos"};
}
2024-03-20 21:17:04 +08:00
// SearchMemos searches memos.
2024-03-18 23:23:53 +08:00
rpc SearchMemos(SearchMemosRequest) returns (SearchMemosResponse) {
option (google.api.http) = {get: "/api/v2/memos:search"};
}
2024-03-18 23:23:53 +08:00
// GetMemo gets a memo.
rpc GetMemo(GetMemoRequest) returns (GetMemoResponse) {
option (google.api.http) = {get: "/api/v2/{name=memos/*}"};
2024-01-20 23:48:35 +08:00
option (google.api.method_signature) = "name";
}
2023-12-21 22:42:06 +08:00
// UpdateMemo updates a memo.
2023-12-20 23:14:15 +08:00
rpc UpdateMemo(UpdateMemoRequest) returns (UpdateMemoResponse) {
option (google.api.http) = {
2024-03-18 23:23:53 +08:00
patch: "/api/v2/{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.
2023-12-20 23:14:15 +08:00
rpc DeleteMemo(DeleteMemoRequest) returns (DeleteMemoResponse) {
2024-03-18 23:23:53 +08:00
option (google.api.http) = {delete: "/api/v2/{name=memos/*}"};
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) {
option (google.api.http) = {post: "/api/v2/memos:export"};
}
2023-12-21 22:42:06 +08:00
// SetMemoResources sets resources for a memo.
2023-12-21 21:24:08 +08:00
rpc SetMemoResources(SetMemoResourcesRequest) returns (SetMemoResourcesResponse) {
option (google.api.http) = {
2024-03-18 23:23:53 +08:00
post: "/api/v2/{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-03-18 23:23:53 +08:00
option (google.api.http) = {get: "/api/v2/{name=memos/*}/resources"};
option (google.api.method_signature) = "name";
}
2023-12-21 22:42:06 +08:00
// SetMemoRelations sets relations for a memo.
2023-12-21 21:24:08 +08:00
rpc SetMemoRelations(SetMemoRelationsRequest) returns (SetMemoRelationsResponse) {
option (google.api.http) = {
2024-03-18 23:23:53 +08:00
post: "/api/v2/{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-03-18 23:23:53 +08:00
option (google.api.http) = {get: "/api/v2/{name=memos/*}/relations"};
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.
2023-10-01 14:44:10 +08:00
rpc CreateMemoComment(CreateMemoCommentRequest) returns (CreateMemoCommentResponse) {
2024-03-18 23:23:53 +08:00
option (google.api.http) = {post: "/api/v2/{name=memos/*}/comments"};
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-03-18 23:23:53 +08:00
option (google.api.http) = {get: "/api/v2/{name=memos/*}/comments"};
option (google.api.method_signature) = "name";
2023-10-01 14:44:10 +08:00
}
// GetUserMemosStats gets stats of memos for a user.
rpc GetUserMemosStats(GetUserMemosStatsRequest) returns (GetUserMemosStatsResponse) {
option (google.api.http) = {get: "/api/v2/memos/stats"};
option (google.api.method_signature) = "username";
}
2024-02-08 11:54:59 +08:00
// ListMemoReactions lists reactions for a memo.
rpc ListMemoReactions(ListMemoReactionsRequest) returns (ListMemoReactionsResponse) {
2024-03-18 23:23:53 +08:00
option (google.api.http) = {get: "/api/v2/{name=memos/*}/reactions"};
option (google.api.method_signature) = "name";
2024-02-08 11:54:59 +08:00
}
// UpsertMemoReaction upserts a reaction for a memo.
rpc UpsertMemoReaction(UpsertMemoReactionRequest) returns (UpsertMemoReactionResponse) {
2024-03-18 23:23:53 +08:00
option (google.api.http) = {post: "/api/v2/{name=memos/*}/reactions"};
option (google.api.method_signature) = "name";
2024-02-08 11:54:59 +08:00
}
// DeleteMemoReaction deletes a reaction for a memo.
rpc DeleteMemoReaction(DeleteMemoReactionRequest) returns (DeleteMemoReactionResponse) {
2024-03-18 23:23:53 +08:00
option (google.api.http) = {delete: "/api/v2/{name=memos/*}/reactions/{reaction_id}"};
option (google.api.method_signature) = "name,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-03-18 12:56:52 +08:00
google.protobuf.Timestamp display_time = 78;
2024-03-18 12:56:52 +08:00
string content = 8;
2024-03-18 12:56:52 +08:00
Visibility visibility = 9;
2024-03-18 12:56:52 +08:00
bool pinned = 10;
2023-12-19 23:49:24 +08:00
2024-03-18 12:56:52 +08:00
optional int32 parent_id = 11 [(google.api.field_behavior) = OUTPUT_ONLY];
2023-12-22 20:18:31 +08:00
2024-03-18 12:56:52 +08:00
repeated Resource resources = 12 [(google.api.field_behavior) = OUTPUT_ONLY];
2023-12-22 20:18:31 +08:00
2024-03-18 12:56:52 +08:00
repeated MemoRelation relations = 13 [(google.api.field_behavior) = OUTPUT_ONLY];
2024-03-18 12:56:52 +08:00
repeated Reaction reactions = 14 [(google.api.field_behavior) = OUTPUT_ONLY];
}
2023-10-01 14:44:10 +08:00
message CreateMemoRequest {
string content = 1;
Visibility visibility = 2;
}
message CreateMemoResponse {
Memo memo = 1;
}
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-03-18 12:56:52 +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 SearchMemosRequest {
// Filter is used to filter memos returned.
// Format: "creator == users/{uid} && visibilities == ['PUBLIC', 'PROTECTED']"
string filter = 1;
}
2024-03-18 23:23:53 +08:00
message SearchMemosResponse {
repeated Memo memos = 1;
}
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-03-18 23:23:53 +08:00
message GetMemoResponse {
2024-01-20 23:48:35 +08:00
Memo memo = 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 UpdateMemoResponse {
Memo memo = 1;
}
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
}
message DeleteMemoResponse {}
2024-02-08 11:54:59 +08:00
message ExportMemosRequest {
// Same as ListMemosRequest.filter
string filter = 1;
}
message ExportMemosResponse {
bytes content = 1;
}
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 SetMemoResourcesResponse {}
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 SetMemoRelationsResponse {}
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 CreateMemoCommentResponse {
Memo memo = 1;
}
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;
}
message GetUserMemosStatsRequest {
// name is the name of the user to get stats for.
2024-03-20 20:39:16 +08:00
// Format: users/{id}
string name = 1;
// timezone location
// Format: uses tz identifier
// https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
string timezone = 2;
2024-01-18 08:06:59 +08:00
// Same as ListMemosRequest.filter
string filter = 3;
}
message GetUserMemosStatsResponse {
2024-01-17 09:17:33 +08:00
// stats is the stats of memo creating/updating activities.
// key is the year-month-day string. e.g. "2020-01-01".
map<string, int32> stats = 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 UpsertMemoReactionResponse {
Reaction reaction = 1;
}
2024-02-08 11:54:59 +08:00
message DeleteMemoReactionRequest {
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
int32 reaction_id = 2;
}
message DeleteMemoReactionResponse {}