memos/proto/api/v1/resource_service.proto

130 lines
3.6 KiB
Protocol Buffer
Raw Permalink Normal View History

2023-09-15 19:11:07 +03:00
syntax = "proto3";
2024-04-27 19:44:29 +03:00
package memos.api.v1;
2023-09-15 19:11:07 +03:00
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/httpbody.proto";
2024-04-27 17:02:15 +03:00
import "google/protobuf/empty.proto";
2023-10-21 07:41:55 +03:00
import "google/protobuf/field_mask.proto";
2023-09-16 06:48:53 +03:00
import "google/protobuf/timestamp.proto";
2023-09-15 19:11:07 +03:00
2024-04-27 19:44:29 +03:00
option go_package = "gen/api/v1";
2023-09-15 19:11:07 +03:00
service ResourceService {
2024-02-01 16:26:09 +03:00
// CreateResource creates a new resource.
2024-04-27 17:02:15 +03:00
rpc CreateResource(CreateResourceRequest) returns (Resource) {
2024-04-16 17:33:25 +03:00
option (google.api.http) = {
2024-06-19 17:07:51 +03:00
post: "/api/v1/resources"
2024-04-16 17:33:25 +03:00
body: "resource"
};
2023-10-03 18:44:14 +03:00
}
2024-02-01 16:26:09 +03:00
// ListResources lists all resources.
2023-09-15 19:11:07 +03:00
rpc ListResources(ListResourcesRequest) returns (ListResourcesResponse) {
2024-04-27 19:44:29 +03:00
option (google.api.http) = {get: "/api/v1/resources"};
2023-09-15 19:11:07 +03:00
}
2024-03-20 16:17:04 +03:00
// GetResource returns a resource by name.
2024-04-27 17:02:15 +03:00
rpc GetResource(GetResourceRequest) returns (Resource) {
2024-04-27 19:44:29 +03:00
option (google.api.http) = {get: "/api/v1/{name=resources/*}"};
option (google.api.method_signature) = "name";
}
// GetResourceByUid returns a resource by uid.
rpc GetResourceByUid(GetResourceByUidRequest) returns (Resource) {
option (google.api.http) = {get: "/api/v1/resources:by-uid/{uid}"};
option (google.api.method_signature) = "uid";
}
// GetResourceBinary returns a resource binary by name.
rpc GetResourceBinary(GetResourceBinaryRequest) returns (google.api.HttpBody) {
2024-05-21 16:25:21 +03:00
option (google.api.http) = {get: "/file/{name=resources/*}/{filename}"};
option (google.api.method_signature) = "name,filename";
}
2024-02-01 16:26:09 +03:00
// UpdateResource updates a resource.
2024-04-27 17:02:15 +03:00
rpc UpdateResource(UpdateResourceRequest) returns (Resource) {
2023-10-21 07:41:55 +03:00
option (google.api.http) = {
2024-06-19 17:07:51 +03:00
patch: "/api/v1/{resource.name=resources/*}"
2023-10-21 07:41:55 +03:00
body: "resource"
};
option (google.api.method_signature) = "resource,update_mask";
2023-10-03 18:44:14 +03:00
}
2024-03-20 16:17:04 +03:00
// DeleteResource deletes a resource by name.
2024-04-27 17:02:15 +03:00
rpc DeleteResource(DeleteResourceRequest) returns (google.protobuf.Empty) {
2024-04-27 19:44:29 +03:00
option (google.api.http) = {delete: "/api/v1/{name=resources/*}"};
2024-03-20 16:17:04 +03:00
option (google.api.method_signature) = "name";
}
2023-09-15 19:11:07 +03:00
}
message Resource {
2024-03-20 16:17:04 +03:00
// The name of the resource.
// Format: resources/{id}
2024-01-21 05:55:49 +03:00
// id is the system generated unique identifier.
2024-03-20 16:17:04 +03:00
string name = 1;
2024-01-21 05:55:49 +03:00
2024-03-20 16:17:04 +03:00
// The user defined id of the resource.
string uid = 2;
2024-01-21 05:55:49 +03:00
google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
2024-01-21 05:55:49 +03:00
string filename = 4;
bytes content = 5 [(google.api.field_behavior) = INPUT_ONLY];
2024-01-21 05:55:49 +03:00
string external_link = 6;
2024-01-21 05:55:49 +03:00
string type = 7;
2024-01-21 05:55:49 +03:00
int64 size = 8;
// The related memo.
// Format: memos/{id}
optional string memo = 9;
2023-09-15 19:11:07 +03:00
}
2023-10-03 18:44:14 +03:00
message CreateResourceRequest {
Resource resource = 1;
2023-10-03 18:44:14 +03:00
}
2023-09-15 19:11:07 +03:00
message ListResourcesRequest {}
message ListResourcesResponse {
repeated Resource resources = 1;
}
2024-03-20 16:17:04 +03:00
message GetResourceRequest {
// The name of the resource.
// Format: resources/{id}
// id is the system generated unique identifier.
string name = 1;
}
message GetResourceByUidRequest {
// The uid of the resource.
string uid = 1;
}
message GetResourceBinaryRequest {
// The name of the resource.
// Format: resources/{id}
// id is the system generated unique identifier.
string name = 1;
2024-05-21 16:25:21 +03:00
// The filename of the resource. Mainly used for downloading.
string filename = 2;
// A flag indicating if the thumbnail version of the resource should be returned
bool thumbnail = 3;
}
2023-10-03 18:44:14 +03:00
message UpdateResourceRequest {
2023-10-21 07:41:55 +03:00
Resource resource = 1;
2023-10-03 18:44:14 +03:00
2023-10-21 07:41:55 +03:00
google.protobuf.FieldMask update_mask = 2;
2023-10-03 18:44:14 +03:00
}
message DeleteResourceRequest {
// The name of the resource.
// Format: resources/{id}
// id is the system generated unique identifier.
2024-03-20 16:17:04 +03:00
string name = 1;
}