chore: implement storage service

This commit is contained in:
Steven
2024-04-13 02:55:40 +08:00
parent 707e5caf89
commit 8f51529c78
21 changed files with 3466 additions and 778 deletions

View File

@@ -49,29 +49,29 @@ message IdentityProvider {
string identifier_filter = 4;
message Config {
message FieldMapping {
string identifier = 1;
string display_name = 2;
string email = 3;
}
IdentityProviderConfig config = 5;
}
message OAuth2 {
string client_id = 1;
string client_secret = 2;
string auth_url = 3;
string token_url = 4;
string user_info_url = 5;
repeated string scopes = 6;
FieldMapping field_mapping = 7;
}
oneof config {
OAuth2 oauth2 = 1;
}
message IdentityProviderConfig {
oneof config {
OAuth2Config oauth2 = 1;
}
}
Config config = 5;
message FieldMapping {
string identifier = 1;
string display_name = 2;
string email = 3;
}
message OAuth2Config {
string client_id = 1;
string client_secret = 2;
string auth_url = 3;
string token_url = 4;
string user_info_url = 5;
repeated string scopes = 6;
FieldMapping field_mapping = 7;
}
message ListIdentityProvidersRequest {}

View File

@@ -0,0 +1,109 @@
syntax = "proto3";
package memos.api.v2;
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/protobuf/field_mask.proto";
option go_package = "gen/api/v2";
service StorageService {
// CreateStorage creates a new storage.
rpc CreateStorage(CreateStorageRequest) returns (CreateStorageResponse) {
option (google.api.http) = {
post: "/api/v2/storages"
body: "*"
};
}
// GetStorage returns a storage by id.
rpc GetStorage(GetStorageRequest) returns (GetStorageResponse) {
option (google.api.http) = {get: "/api/v2/storages/{id}"};
option (google.api.method_signature) = "id";
}
// ListStorages returns a list of storages.
rpc ListStorages(ListStoragesRequest) returns (ListStoragesResponse) {
option (google.api.http) = {get: "/api/v2/storages"};
}
// UpdateStorage updates a storage.
rpc UpdateStorage(UpdateStorageRequest) returns (UpdateStorageResponse) {
option (google.api.http) = {
patch: "/api/v2/storages/{storage.id}"
body: "storage"
};
option (google.api.method_signature) = "storage,update_mask";
}
// DeleteStorage deletes a storage by id.
rpc DeleteStorage(DeleteStorageRequest) returns (DeleteStorageResponse) {
option (google.api.http) = {delete: "/api/v2/storages/{id}"};
option (google.api.method_signature) = "id";
}
}
message Storage {
int32 id = 1;
string title = 2;
enum Type {
TYPE_UNSPECIFIED = 0;
S3 = 1;
}
Type type = 3;
StorageConfig config = 4;
}
message StorageConfig {
oneof storage_config {
S3Config s3_config = 1;
}
}
message S3Config {
string end_point = 1;
string path = 2;
string region = 3;
string access_key = 4;
string secret_key = 5;
string bucket = 6;
string url_prefix = 7;
string url_suffix = 8;
bool pre_sign = 9;
}
message CreateStorageRequest {
Storage storage = 1;
}
message CreateStorageResponse {
Storage storage = 1;
}
message GetStorageRequest {
int32 id = 1;
}
message GetStorageResponse {
Storage storage = 1;
}
message ListStoragesRequest {}
message ListStoragesResponse {
repeated Storage storages = 1;
}
message UpdateStorageRequest {
Storage storage = 1;
google.protobuf.FieldMask update_mask = 2;
}
message UpdateStorageResponse {
Storage storage = 1;
}
message DeleteStorageRequest {
int32 id = 1;
}
message DeleteStorageResponse {}