chore: tweak shortcut service response

This commit is contained in:
johnnyjoy
2024-08-17 21:18:43 +08:00
parent da94907913
commit c356bc03e5
7 changed files with 433 additions and 886 deletions

View File

@ -5,6 +5,7 @@ package slash.api.v1;
import "api/v1/common.proto";
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";
@ -16,21 +17,21 @@ service ShortcutService {
option (google.api.http) = {get: "/api/v1/shortcuts"};
}
// GetShortcut returns a shortcut by id.
rpc GetShortcut(GetShortcutRequest) returns (GetShortcutResponse) {
rpc GetShortcut(GetShortcutRequest) returns (Shortcut) {
option (google.api.http) = {get: "/api/v1/shortcuts/{id}"};
option (google.api.method_signature) = "id";
}
// GetShortcutByName returns a shortcut by name.
rpc GetShortcutByName(GetShortcutByNameRequest) returns (GetShortcutByNameResponse) {}
rpc GetShortcutByName(GetShortcutByNameRequest) returns (Shortcut) {}
// CreateShortcut creates a shortcut.
rpc CreateShortcut(CreateShortcutRequest) returns (CreateShortcutResponse) {
rpc CreateShortcut(CreateShortcutRequest) returns (Shortcut) {
option (google.api.http) = {
post: "/api/v1/shortcuts"
body: "shortcut"
};
}
// UpdateShortcut updates a shortcut.
rpc UpdateShortcut(UpdateShortcutRequest) returns (UpdateShortcutResponse) {
rpc UpdateShortcut(UpdateShortcutRequest) returns (Shortcut) {
option (google.api.http) = {
put: "/api/v1/shortcuts/{shortcut.id}"
body: "shortcut"
@ -38,7 +39,7 @@ service ShortcutService {
option (google.api.method_signature) = "shortcut,update_mask";
}
// DeleteShortcut deletes a shortcut by name.
rpc DeleteShortcut(DeleteShortcutRequest) returns (DeleteShortcutResponse) {
rpc DeleteShortcut(DeleteShortcutRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {delete: "/api/v1/shortcuts/{id}"};
option (google.api.method_signature) = "id";
}
@ -75,15 +76,16 @@ message Shortcut {
int32 view_count = 12;
OpenGraphMetadata og_metadata = 13;
message OpenGraphMetadata {
string title = 1;
string description = 2;
string image = 3;
}
}
message OpenGraphMetadata {
string title = 1;
string description = 2;
string image = 3;
}
message ListShortcutsRequest {}
@ -95,42 +97,24 @@ message GetShortcutRequest {
int32 id = 1;
}
message GetShortcutResponse {
Shortcut shortcut = 1;
}
message GetShortcutByNameRequest {
string name = 1;
}
message GetShortcutByNameResponse {
Shortcut shortcut = 1;
}
message CreateShortcutRequest {
Shortcut shortcut = 1;
}
message CreateShortcutResponse {
Shortcut shortcut = 1;
}
message UpdateShortcutRequest {
Shortcut shortcut = 1;
google.protobuf.FieldMask update_mask = 2;
}
message UpdateShortcutResponse {
Shortcut shortcut = 1;
}
message DeleteShortcutRequest {
int32 id = 1;
}
message DeleteShortcutResponse {}
message GetShortcutAnalyticsRequest {
int32 id = 1;
}