resource_service.proto 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. syntax = "proto3";
  2. package memos.api.v1;
  3. import "google/api/annotations.proto";
  4. import "google/api/client.proto";
  5. import "google/api/field_behavior.proto";
  6. import "google/api/httpbody.proto";
  7. import "google/protobuf/empty.proto";
  8. import "google/protobuf/field_mask.proto";
  9. import "google/protobuf/timestamp.proto";
  10. option go_package = "gen/api/v1";
  11. service ResourceService {
  12. // CreateResource creates a new resource.
  13. rpc CreateResource(CreateResourceRequest) returns (Resource) {
  14. option (google.api.http) = {
  15. post: "/api/v1/resources"
  16. body: "resource"
  17. };
  18. }
  19. // ListResources lists all resources.
  20. rpc ListResources(ListResourcesRequest) returns (ListResourcesResponse) {
  21. option (google.api.http) = {get: "/api/v1/resources"};
  22. }
  23. // GetResource returns a resource by name.
  24. rpc GetResource(GetResourceRequest) returns (Resource) {
  25. option (google.api.http) = {get: "/api/v1/{name=resources/*}"};
  26. option (google.api.method_signature) = "name";
  27. }
  28. // GetResourceByUid returns a resource by uid.
  29. rpc GetResourceByUid(GetResourceByUidRequest) returns (Resource) {
  30. option (google.api.http) = {get: "/api/v1/resources:by-uid/{uid}"};
  31. option (google.api.method_signature) = "uid";
  32. }
  33. // GetResourceBinary returns a resource binary by name.
  34. rpc GetResourceBinary(GetResourceBinaryRequest) returns (google.api.HttpBody) {
  35. option (google.api.http) = {get: "/file/{name=resources/*}/{filename}"};
  36. option (google.api.method_signature) = "name,filename";
  37. }
  38. // UpdateResource updates a resource.
  39. rpc UpdateResource(UpdateResourceRequest) returns (Resource) {
  40. option (google.api.http) = {
  41. patch: "/api/v1/{resource.name=resources/*}"
  42. body: "resource"
  43. };
  44. option (google.api.method_signature) = "resource,update_mask";
  45. }
  46. // DeleteResource deletes a resource by name.
  47. rpc DeleteResource(DeleteResourceRequest) returns (google.protobuf.Empty) {
  48. option (google.api.http) = {delete: "/api/v1/{name=resources/*}"};
  49. option (google.api.method_signature) = "name";
  50. }
  51. }
  52. message Resource {
  53. // The name of the resource.
  54. // Format: resources/{id}
  55. // id is the system generated unique identifier.
  56. string name = 1;
  57. // The user defined id of the resource.
  58. string uid = 2;
  59. google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
  60. string filename = 4;
  61. bytes content = 5 [(google.api.field_behavior) = INPUT_ONLY];
  62. string external_link = 6;
  63. string type = 7;
  64. int64 size = 8;
  65. // The related memo.
  66. // Format: memos/{id}
  67. optional string memo = 9;
  68. }
  69. message CreateResourceRequest {
  70. Resource resource = 1;
  71. }
  72. message ListResourcesRequest {}
  73. message ListResourcesResponse {
  74. repeated Resource resources = 1;
  75. }
  76. message GetResourceRequest {
  77. // The name of the resource.
  78. // Format: resources/{id}
  79. // id is the system generated unique identifier.
  80. string name = 1;
  81. }
  82. message GetResourceByUidRequest {
  83. // The uid of the resource.
  84. string uid = 1;
  85. }
  86. message GetResourceBinaryRequest {
  87. // The name of the resource.
  88. // Format: resources/{id}
  89. // id is the system generated unique identifier.
  90. string name = 1;
  91. // The filename of the resource. Mainly used for downloading.
  92. string filename = 2;
  93. // A flag indicating if the thumbnail version of the resource should be returned
  94. bool thumbnail = 3;
  95. }
  96. message UpdateResourceRequest {
  97. Resource resource = 1;
  98. google.protobuf.FieldMask update_mask = 2;
  99. }
  100. message DeleteResourceRequest {
  101. // The name of the resource.
  102. // Format: resources/{id}
  103. // id is the system generated unique identifier.
  104. string name = 1;
  105. }