2023-08-05 09:32:52 +08:00
|
|
|
syntax = "proto3";
|
|
|
|
|
|
|
|
package memos.api.v2;
|
|
|
|
|
|
|
|
import "api/v2/common.proto";
|
2023-12-17 09:53:22 +08:00
|
|
|
import "api/v2/markdown_service.proto";
|
2023-12-21 21:24:08 +08:00
|
|
|
import "api/v2/memo_relation_service.proto";
|
2023-12-20 23:46:04 +08:00
|
|
|
import "api/v2/resource_service.proto";
|
2023-08-05 09:32:52 +08:00
|
|
|
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";
|
2023-08-05 09:32:52 +08:00
|
|
|
|
|
|
|
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.
|
2023-08-05 09:32:52 +08:00
|
|
|
rpc ListMemos(ListMemosRequest) returns (ListMemosResponse) {
|
|
|
|
option (google.api.http) = {get: "/api/v2/memos"};
|
|
|
|
}
|
2023-12-21 22:42:06 +08:00
|
|
|
// GetMemo gets a memo by id.
|
2023-08-05 09:32:52 +08:00
|
|
|
rpc GetMemo(GetMemoRequest) returns (GetMemoResponse) {
|
|
|
|
option (google.api.http) = {get: "/api/v2/memos/{id}"};
|
|
|
|
option (google.api.method_signature) = "id";
|
|
|
|
}
|
2024-01-20 23:48:35 +08:00
|
|
|
// GetMemoByName gets a memo by name.
|
|
|
|
rpc GetMemoByName(GetMemoByNameRequest) returns (GetMemoByNameResponse) {
|
|
|
|
option (google.api.http) = {get: "/api/v2/memos/{name}"};
|
|
|
|
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) = {
|
|
|
|
patch: "/api/v2/memos/{id}"
|
|
|
|
body: "*"
|
|
|
|
};
|
|
|
|
option (google.api.method_signature) = "id, update_mask";
|
|
|
|
}
|
2023-12-21 22:42:06 +08:00
|
|
|
// DeleteMemo deletes a memo by id.
|
2023-12-20 23:14:15 +08:00
|
|
|
rpc DeleteMemo(DeleteMemoRequest) returns (DeleteMemoResponse) {
|
|
|
|
option (google.api.http) = {delete: "/api/v2/memos/{id}"};
|
|
|
|
option (google.api.method_signature) = "id";
|
|
|
|
}
|
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) = {
|
|
|
|
post: "/api/v2/memos/{id}/resources"
|
|
|
|
body: "*"
|
|
|
|
};
|
|
|
|
option (google.api.method_signature) = "id";
|
|
|
|
}
|
2023-12-21 22:42:06 +08:00
|
|
|
// ListMemoResources lists resources for a memo.
|
2023-12-20 23:46:04 +08:00
|
|
|
rpc ListMemoResources(ListMemoResourcesRequest) returns (ListMemoResourcesResponse) {
|
|
|
|
option (google.api.http) = {get: "/api/v2/memos/{id}/resources"};
|
|
|
|
option (google.api.method_signature) = "id";
|
|
|
|
}
|
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) = {
|
|
|
|
post: "/api/v2/memos/{id}/relations"
|
|
|
|
body: "*"
|
|
|
|
};
|
|
|
|
option (google.api.method_signature) = "id";
|
|
|
|
}
|
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) {
|
|
|
|
option (google.api.http) = {get: "/api/v2/memos/{id}/relations"};
|
|
|
|
option (google.api.method_signature) = "id";
|
|
|
|
}
|
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) {
|
|
|
|
option (google.api.http) = {post: "/api/v2/memos/{id}/comments"};
|
|
|
|
option (google.api.method_signature) = "id";
|
|
|
|
}
|
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) {
|
|
|
|
option (google.api.http) = {get: "/api/v2/memos/{id}/comments"};
|
|
|
|
option (google.api.method_signature) = "id";
|
|
|
|
}
|
2023-12-23 18:35:47 +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";
|
|
|
|
}
|
2023-10-01 14:44:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
enum Visibility {
|
|
|
|
VISIBILITY_UNSPECIFIED = 0;
|
|
|
|
|
|
|
|
PRIVATE = 1;
|
|
|
|
|
|
|
|
PROTECTED = 2;
|
|
|
|
|
|
|
|
PUBLIC = 3;
|
2023-08-05 09:32:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
message Memo {
|
2024-01-20 23:48:35 +08:00
|
|
|
// id is the unique auto-incremented id.
|
2023-08-05 09:32:52 +08:00
|
|
|
int32 id = 1;
|
|
|
|
|
2024-01-20 23:48:35 +08:00
|
|
|
// name is the user-defined name.
|
|
|
|
string name = 2;
|
|
|
|
|
|
|
|
RowStatus row_status = 3;
|
2023-08-05 09:32:52 +08:00
|
|
|
|
2023-12-21 22:42:06 +08:00
|
|
|
// The name of the creator.
|
|
|
|
// Format: users/{username}
|
2024-01-20 23:48:35 +08:00
|
|
|
string creator = 4;
|
2023-12-21 22:42:06 +08:00
|
|
|
|
2024-01-20 23:48:35 +08:00
|
|
|
int32 creator_id = 5;
|
2023-08-05 09:32:52 +08:00
|
|
|
|
2024-01-20 23:48:35 +08:00
|
|
|
google.protobuf.Timestamp create_time = 6;
|
2023-08-05 09:32:52 +08:00
|
|
|
|
2024-01-20 23:48:35 +08:00
|
|
|
google.protobuf.Timestamp update_time = 7;
|
2023-08-05 09:32:52 +08:00
|
|
|
|
2024-01-20 23:48:35 +08:00
|
|
|
google.protobuf.Timestamp display_time = 8;
|
2023-08-05 09:32:52 +08:00
|
|
|
|
2024-01-20 23:48:35 +08:00
|
|
|
string content = 9;
|
2023-08-05 09:32:52 +08:00
|
|
|
|
2024-01-20 23:48:35 +08:00
|
|
|
repeated Node nodes = 10;
|
2023-12-17 09:53:22 +08:00
|
|
|
|
2024-01-20 23:48:35 +08:00
|
|
|
Visibility visibility = 11;
|
2023-12-19 23:49:24 +08:00
|
|
|
|
2024-01-20 23:48:35 +08:00
|
|
|
bool pinned = 12;
|
2023-12-22 20:18:31 +08:00
|
|
|
|
2024-01-20 23:48:35 +08:00
|
|
|
optional int32 parent_id = 13 [(google.api.field_behavior) = OUTPUT_ONLY];
|
2023-12-22 20:18:31 +08:00
|
|
|
|
2024-01-20 23:48:35 +08:00
|
|
|
repeated Resource resources = 14 [(google.api.field_behavior) = OUTPUT_ONLY];
|
2024-01-06 09:48:11 +08:00
|
|
|
|
2024-01-20 23:48:35 +08:00
|
|
|
repeated MemoRelation relations = 15 [(google.api.field_behavior) = OUTPUT_ONLY];
|
2023-08-05 09:32:52 +08:00
|
|
|
}
|
|
|
|
|
2023-10-01 14:44:10 +08:00
|
|
|
message CreateMemoRequest {
|
|
|
|
string content = 1;
|
|
|
|
|
|
|
|
Visibility visibility = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
message CreateMemoResponse {
|
|
|
|
Memo memo = 1;
|
|
|
|
}
|
|
|
|
|
2023-08-05 09:32:52 +08:00
|
|
|
message ListMemosRequest {
|
2023-12-21 23:40:43 +08:00
|
|
|
// offset is the offset of the first memo to return.
|
|
|
|
int32 offset = 1;
|
2023-08-05 09:32:52 +08:00
|
|
|
|
2023-12-21 23:40:43 +08:00
|
|
|
// limit is the maximum number of memos to return.
|
|
|
|
int32 limit = 2;
|
2023-08-05 09:32:52 +08:00
|
|
|
|
|
|
|
// Filter is used to filter memos returned in the list.
|
2023-12-22 00:31:29 +08:00
|
|
|
// Format: "creator == users/{username} && visibilities == ['PUBLIC', 'PROTECTED']"
|
2023-08-05 09:32:52 +08:00
|
|
|
string filter = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
message ListMemosResponse {
|
|
|
|
repeated Memo memos = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message GetMemoRequest {
|
|
|
|
int32 id = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message GetMemoResponse {
|
|
|
|
Memo memo = 1;
|
|
|
|
}
|
|
|
|
|
2024-01-20 23:48:35 +08:00
|
|
|
message GetMemoByNameRequest {
|
|
|
|
string name = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message GetMemoByNameResponse {
|
|
|
|
Memo memo = 1;
|
|
|
|
}
|
|
|
|
|
2023-12-20 23:14:15 +08:00
|
|
|
message UpdateMemoRequest {
|
|
|
|
int32 id = 1;
|
|
|
|
|
|
|
|
Memo memo = 2;
|
|
|
|
|
|
|
|
google.protobuf.FieldMask update_mask = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
message UpdateMemoResponse {
|
|
|
|
Memo memo = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message DeleteMemoRequest {
|
|
|
|
int32 id = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message DeleteMemoResponse {}
|
|
|
|
|
2023-12-21 21:24:08 +08:00
|
|
|
message SetMemoResourcesRequest {
|
|
|
|
int32 id = 1;
|
|
|
|
|
|
|
|
repeated Resource resources = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
message SetMemoResourcesResponse {}
|
|
|
|
|
2023-12-20 23:46:04 +08:00
|
|
|
message ListMemoResourcesRequest {
|
|
|
|
int32 id = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message ListMemoResourcesResponse {
|
|
|
|
repeated Resource resources = 1;
|
|
|
|
}
|
|
|
|
|
2023-12-21 21:24:08 +08:00
|
|
|
message SetMemoRelationsRequest {
|
|
|
|
int32 id = 1;
|
|
|
|
|
|
|
|
repeated MemoRelation relations = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
message SetMemoRelationsResponse {}
|
|
|
|
|
|
|
|
message ListMemoRelationsRequest {
|
|
|
|
int32 id = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message ListMemoRelationsResponse {
|
|
|
|
repeated MemoRelation relations = 1;
|
|
|
|
}
|
|
|
|
|
2023-10-01 14:44:10 +08:00
|
|
|
message CreateMemoCommentRequest {
|
|
|
|
// id is the memo id to create comment for.
|
|
|
|
int32 id = 1;
|
2023-08-05 09:32:52 +08:00
|
|
|
|
2023-10-01 14:44:10 +08:00
|
|
|
CreateMemoRequest create = 2;
|
|
|
|
}
|
2023-08-05 09:32:52 +08:00
|
|
|
|
2023-10-01 14:44:10 +08:00
|
|
|
message CreateMemoCommentResponse {
|
|
|
|
Memo memo = 1;
|
|
|
|
}
|
2023-08-05 09:32:52 +08:00
|
|
|
|
2023-10-01 14:44:10 +08:00
|
|
|
message ListMemoCommentsRequest {
|
|
|
|
int32 id = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message ListMemoCommentsResponse {
|
|
|
|
repeated Memo memos = 1;
|
2023-08-05 09:32:52 +08:00
|
|
|
}
|
2023-12-23 18:35:47 +08:00
|
|
|
|
|
|
|
message GetUserMemosStatsRequest {
|
|
|
|
// name is the name of the user to get stats for.
|
|
|
|
// Format: users/{username}
|
|
|
|
string name = 1;
|
2024-01-16 18:02:09 +08:00
|
|
|
|
|
|
|
// 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;
|
2023-12-23 18:35:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2023-12-23 18:35:47 +08:00
|
|
|
}
|