2023-09-16 00:11:07 +08:00
|
|
|
syntax = "proto3";
|
|
|
|
|
|
|
|
package memos.api.v2;
|
|
|
|
|
|
|
|
import "google/api/annotations.proto";
|
2023-09-27 08:09:30 +08:00
|
|
|
import "google/api/client.proto";
|
2024-04-11 17:53:00 +08:00
|
|
|
import "google/api/field_behavior.proto";
|
2023-10-21 12:41:55 +08:00
|
|
|
import "google/protobuf/field_mask.proto";
|
2023-09-16 11:48:53 +08:00
|
|
|
import "google/protobuf/timestamp.proto";
|
2023-09-16 00:11:07 +08:00
|
|
|
|
|
|
|
option go_package = "gen/api/v2";
|
|
|
|
|
|
|
|
service ResourceService {
|
2024-02-01 21:26:09 +08:00
|
|
|
// CreateResource creates a new resource.
|
2023-10-03 23:44:14 +08:00
|
|
|
rpc CreateResource(CreateResourceRequest) returns (CreateResourceResponse) {
|
|
|
|
option (google.api.http) = {post: "/api/v2/resources"};
|
|
|
|
}
|
2024-02-01 21:26:09 +08:00
|
|
|
// ListResources lists all resources.
|
2023-09-16 00:11:07 +08:00
|
|
|
rpc ListResources(ListResourcesRequest) returns (ListResourcesResponse) {
|
|
|
|
option (google.api.http) = {get: "/api/v2/resources"};
|
|
|
|
}
|
2024-03-20 21:17:04 +08:00
|
|
|
// SearchResources searches memos.
|
|
|
|
rpc SearchResources(SearchResourcesRequest) returns (SearchResourcesResponse) {
|
|
|
|
option (google.api.http) = {get: "/api/v2/resources:search"};
|
2024-01-20 09:17:31 +08:00
|
|
|
}
|
2024-03-20 21:17:04 +08:00
|
|
|
// GetResource returns a resource by name.
|
|
|
|
rpc GetResource(GetResourceRequest) returns (GetResourceResponse) {
|
|
|
|
option (google.api.http) = {get: "/api/v2/{name=resources/*}"};
|
2024-01-21 21:27:04 +08:00
|
|
|
option (google.api.method_signature) = "name";
|
|
|
|
}
|
2024-02-01 21:26:09 +08:00
|
|
|
// UpdateResource updates a resource.
|
2023-10-03 23:44:14 +08:00
|
|
|
rpc UpdateResource(UpdateResourceRequest) returns (UpdateResourceResponse) {
|
2023-10-21 12:41:55 +08:00
|
|
|
option (google.api.http) = {
|
2024-03-20 21:17:04 +08:00
|
|
|
patch: "/api/v2/{resource.name=resources/*}",
|
2023-10-21 12:41:55 +08:00
|
|
|
body: "resource"
|
|
|
|
};
|
|
|
|
option (google.api.method_signature) = "resource,update_mask";
|
2023-10-03 23:44:14 +08:00
|
|
|
}
|
2024-03-20 21:17:04 +08:00
|
|
|
// DeleteResource deletes a resource by name.
|
2023-09-27 08:09:30 +08:00
|
|
|
rpc DeleteResource(DeleteResourceRequest) returns (DeleteResourceResponse) {
|
2024-03-20 21:17:04 +08:00
|
|
|
option (google.api.http) = {delete: "/api/v2/{name=resources/*}"};
|
|
|
|
option (google.api.method_signature) = "name";
|
2023-09-27 08:09:30 +08:00
|
|
|
}
|
2023-09-16 00:11:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
message Resource {
|
2024-03-20 21:17:04 +08:00
|
|
|
// The name of the resource.
|
|
|
|
// Format: resources/{id}
|
2024-01-21 10:55:49 +08:00
|
|
|
// id is the system generated unique identifier.
|
2024-03-20 21:17:04 +08:00
|
|
|
string name = 1;
|
2024-01-21 10:55:49 +08:00
|
|
|
|
2024-03-20 21:17:04 +08:00
|
|
|
// The user defined id of the resource.
|
|
|
|
string uid = 2;
|
2024-01-21 10:55:49 +08:00
|
|
|
|
2024-04-11 17:53:00 +08:00
|
|
|
google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
|
2024-01-21 10:55:49 +08:00
|
|
|
|
|
|
|
string filename = 4;
|
|
|
|
|
2024-04-11 17:53:00 +08:00
|
|
|
bytes content = 5 [(google.api.field_behavior) = INPUT_ONLY];
|
2024-01-21 10:55:49 +08:00
|
|
|
|
2024-04-11 17:53:00 +08:00
|
|
|
string external_link = 6;
|
2024-01-21 10:55:49 +08:00
|
|
|
|
2024-04-11 17:53:00 +08:00
|
|
|
string type = 7;
|
2024-01-21 10:55:49 +08:00
|
|
|
|
2024-04-11 17:53:00 +08:00
|
|
|
int64 size = 8;
|
|
|
|
|
|
|
|
// The related memo.
|
2024-03-30 08:26:28 +08:00
|
|
|
// Format: memos/{id}
|
2024-04-11 17:53:00 +08:00
|
|
|
optional string memo = 9;
|
2023-09-16 00:11:07 +08:00
|
|
|
}
|
|
|
|
|
2023-10-03 23:44:14 +08:00
|
|
|
message CreateResourceRequest {
|
2024-04-11 17:53:00 +08:00
|
|
|
Resource resource = 1;
|
2023-10-03 23:44:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
message CreateResourceResponse {
|
|
|
|
Resource resource = 1;
|
|
|
|
}
|
|
|
|
|
2023-09-16 00:11:07 +08:00
|
|
|
message ListResourcesRequest {}
|
|
|
|
|
|
|
|
message ListResourcesResponse {
|
|
|
|
repeated Resource resources = 1;
|
|
|
|
}
|
2023-09-27 08:09:30 +08:00
|
|
|
|
2024-03-20 21:17:04 +08:00
|
|
|
message SearchResourcesRequest {
|
|
|
|
string filter = 1;
|
2024-01-20 09:17:31 +08:00
|
|
|
}
|
|
|
|
|
2024-03-20 21:17:04 +08:00
|
|
|
message SearchResourcesResponse {
|
|
|
|
repeated Resource resources = 1;
|
2024-01-20 09:17:31 +08:00
|
|
|
}
|
|
|
|
|
2024-03-20 21:17:04 +08:00
|
|
|
message GetResourceRequest {
|
2024-04-11 17:53:00 +08:00
|
|
|
// The name of the resource.
|
|
|
|
// Format: resources/{id}
|
|
|
|
// id is the system generated unique identifier.
|
2024-01-21 21:27:04 +08:00
|
|
|
string name = 1;
|
|
|
|
}
|
|
|
|
|
2024-03-20 21:17:04 +08:00
|
|
|
message GetResourceResponse {
|
2024-01-21 21:27:04 +08:00
|
|
|
Resource resource = 1;
|
|
|
|
}
|
|
|
|
|
2023-10-03 23:44:14 +08:00
|
|
|
message UpdateResourceRequest {
|
2023-10-21 12:41:55 +08:00
|
|
|
Resource resource = 1;
|
2023-10-03 23:44:14 +08:00
|
|
|
|
2023-10-21 12:41:55 +08:00
|
|
|
google.protobuf.FieldMask update_mask = 2;
|
2023-10-03 23:44:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
message UpdateResourceResponse {
|
|
|
|
Resource resource = 1;
|
|
|
|
}
|
|
|
|
|
2023-09-27 08:09:30 +08:00
|
|
|
message DeleteResourceRequest {
|
2024-04-11 17:53:00 +08:00
|
|
|
// The name of the resource.
|
|
|
|
// Format: resources/{id}
|
|
|
|
// id is the system generated unique identifier.
|
2024-03-20 21:17:04 +08:00
|
|
|
string name = 1;
|
2023-09-27 08:09:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
message DeleteResourceResponse {}
|