mirror of
https://github.com/usememos/memos.git
synced 2025-04-13 17:12:07 +02:00
chore: implement storage service
This commit is contained in:
parent
707e5caf89
commit
8f51529c78
@ -49,14 +49,22 @@ message IdentityProvider {
|
|||||||
|
|
||||||
string identifier_filter = 4;
|
string identifier_filter = 4;
|
||||||
|
|
||||||
message Config {
|
IdentityProviderConfig config = 5;
|
||||||
message FieldMapping {
|
}
|
||||||
|
|
||||||
|
message IdentityProviderConfig {
|
||||||
|
oneof config {
|
||||||
|
OAuth2Config oauth2 = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message FieldMapping {
|
||||||
string identifier = 1;
|
string identifier = 1;
|
||||||
string display_name = 2;
|
string display_name = 2;
|
||||||
string email = 3;
|
string email = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message OAuth2 {
|
message OAuth2Config {
|
||||||
string client_id = 1;
|
string client_id = 1;
|
||||||
string client_secret = 2;
|
string client_secret = 2;
|
||||||
string auth_url = 3;
|
string auth_url = 3;
|
||||||
@ -64,14 +72,6 @@ message IdentityProvider {
|
|||||||
string user_info_url = 5;
|
string user_info_url = 5;
|
||||||
repeated string scopes = 6;
|
repeated string scopes = 6;
|
||||||
FieldMapping field_mapping = 7;
|
FieldMapping field_mapping = 7;
|
||||||
}
|
|
||||||
|
|
||||||
oneof config {
|
|
||||||
OAuth2 oauth2 = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Config config = 5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message ListIdentityProvidersRequest {}
|
message ListIdentityProvidersRequest {}
|
||||||
|
109
proto/api/v2/storage_service.proto
Normal file
109
proto/api/v2/storage_service.proto
Normal 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 {}
|
@ -68,14 +68,14 @@
|
|||||||
- [CreateIdentityProviderResponse](#memos-api-v2-CreateIdentityProviderResponse)
|
- [CreateIdentityProviderResponse](#memos-api-v2-CreateIdentityProviderResponse)
|
||||||
- [DeleteIdentityProviderRequest](#memos-api-v2-DeleteIdentityProviderRequest)
|
- [DeleteIdentityProviderRequest](#memos-api-v2-DeleteIdentityProviderRequest)
|
||||||
- [DeleteIdentityProviderResponse](#memos-api-v2-DeleteIdentityProviderResponse)
|
- [DeleteIdentityProviderResponse](#memos-api-v2-DeleteIdentityProviderResponse)
|
||||||
|
- [FieldMapping](#memos-api-v2-FieldMapping)
|
||||||
- [GetIdentityProviderRequest](#memos-api-v2-GetIdentityProviderRequest)
|
- [GetIdentityProviderRequest](#memos-api-v2-GetIdentityProviderRequest)
|
||||||
- [GetIdentityProviderResponse](#memos-api-v2-GetIdentityProviderResponse)
|
- [GetIdentityProviderResponse](#memos-api-v2-GetIdentityProviderResponse)
|
||||||
- [IdentityProvider](#memos-api-v2-IdentityProvider)
|
- [IdentityProvider](#memos-api-v2-IdentityProvider)
|
||||||
- [IdentityProvider.Config](#memos-api-v2-IdentityProvider-Config)
|
- [IdentityProviderConfig](#memos-api-v2-IdentityProviderConfig)
|
||||||
- [IdentityProvider.Config.FieldMapping](#memos-api-v2-IdentityProvider-Config-FieldMapping)
|
|
||||||
- [IdentityProvider.Config.OAuth2](#memos-api-v2-IdentityProvider-Config-OAuth2)
|
|
||||||
- [ListIdentityProvidersRequest](#memos-api-v2-ListIdentityProvidersRequest)
|
- [ListIdentityProvidersRequest](#memos-api-v2-ListIdentityProvidersRequest)
|
||||||
- [ListIdentityProvidersResponse](#memos-api-v2-ListIdentityProvidersResponse)
|
- [ListIdentityProvidersResponse](#memos-api-v2-ListIdentityProvidersResponse)
|
||||||
|
- [OAuth2Config](#memos-api-v2-OAuth2Config)
|
||||||
- [UpdateIdentityProviderRequest](#memos-api-v2-UpdateIdentityProviderRequest)
|
- [UpdateIdentityProviderRequest](#memos-api-v2-UpdateIdentityProviderRequest)
|
||||||
- [UpdateIdentityProviderResponse](#memos-api-v2-UpdateIdentityProviderResponse)
|
- [UpdateIdentityProviderResponse](#memos-api-v2-UpdateIdentityProviderResponse)
|
||||||
|
|
||||||
@ -173,6 +173,25 @@
|
|||||||
|
|
||||||
- [MemoService](#memos-api-v2-MemoService)
|
- [MemoService](#memos-api-v2-MemoService)
|
||||||
|
|
||||||
|
- [api/v2/storage_service.proto](#api_v2_storage_service-proto)
|
||||||
|
- [CreateStorageRequest](#memos-api-v2-CreateStorageRequest)
|
||||||
|
- [CreateStorageResponse](#memos-api-v2-CreateStorageResponse)
|
||||||
|
- [DeleteStorageRequest](#memos-api-v2-DeleteStorageRequest)
|
||||||
|
- [DeleteStorageResponse](#memos-api-v2-DeleteStorageResponse)
|
||||||
|
- [GetStorageRequest](#memos-api-v2-GetStorageRequest)
|
||||||
|
- [GetStorageResponse](#memos-api-v2-GetStorageResponse)
|
||||||
|
- [ListStoragesRequest](#memos-api-v2-ListStoragesRequest)
|
||||||
|
- [ListStoragesResponse](#memos-api-v2-ListStoragesResponse)
|
||||||
|
- [S3Config](#memos-api-v2-S3Config)
|
||||||
|
- [Storage](#memos-api-v2-Storage)
|
||||||
|
- [StorageConfig](#memos-api-v2-StorageConfig)
|
||||||
|
- [UpdateStorageRequest](#memos-api-v2-UpdateStorageRequest)
|
||||||
|
- [UpdateStorageResponse](#memos-api-v2-UpdateStorageResponse)
|
||||||
|
|
||||||
|
- [Storage.Type](#memos-api-v2-Storage-Type)
|
||||||
|
|
||||||
|
- [StorageService](#memos-api-v2-StorageService)
|
||||||
|
|
||||||
- [api/v2/tag_service.proto](#api_v2_tag_service-proto)
|
- [api/v2/tag_service.proto](#api_v2_tag_service-proto)
|
||||||
- [BatchUpsertTagRequest](#memos-api-v2-BatchUpsertTagRequest)
|
- [BatchUpsertTagRequest](#memos-api-v2-BatchUpsertTagRequest)
|
||||||
- [BatchUpsertTagResponse](#memos-api-v2-BatchUpsertTagResponse)
|
- [BatchUpsertTagResponse](#memos-api-v2-BatchUpsertTagResponse)
|
||||||
@ -1067,6 +1086,23 @@ Used internally for obfuscating the page token.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="memos-api-v2-FieldMapping"></a>
|
||||||
|
|
||||||
|
### FieldMapping
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
| Field | Type | Label | Description |
|
||||||
|
| ----- | ---- | ----- | ----------- |
|
||||||
|
| identifier | [string](#string) | | |
|
||||||
|
| display_name | [string](#string) | | |
|
||||||
|
| email | [string](#string) | | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="memos-api-v2-GetIdentityProviderRequest"></a>
|
<a name="memos-api-v2-GetIdentityProviderRequest"></a>
|
||||||
|
|
||||||
### GetIdentityProviderRequest
|
### GetIdentityProviderRequest
|
||||||
@ -1109,60 +1145,22 @@ Used internally for obfuscating the page token.
|
|||||||
| type | [IdentityProvider.Type](#memos-api-v2-IdentityProvider-Type) | | |
|
| type | [IdentityProvider.Type](#memos-api-v2-IdentityProvider-Type) | | |
|
||||||
| title | [string](#string) | | |
|
| title | [string](#string) | | |
|
||||||
| identifier_filter | [string](#string) | | |
|
| identifier_filter | [string](#string) | | |
|
||||||
| config | [IdentityProvider.Config](#memos-api-v2-IdentityProvider-Config) | | |
|
| config | [IdentityProviderConfig](#memos-api-v2-IdentityProviderConfig) | | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="memos-api-v2-IdentityProvider-Config"></a>
|
<a name="memos-api-v2-IdentityProviderConfig"></a>
|
||||||
|
|
||||||
### IdentityProvider.Config
|
### IdentityProviderConfig
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
| Field | Type | Label | Description |
|
| Field | Type | Label | Description |
|
||||||
| ----- | ---- | ----- | ----------- |
|
| ----- | ---- | ----- | ----------- |
|
||||||
| oauth2 | [IdentityProvider.Config.OAuth2](#memos-api-v2-IdentityProvider-Config-OAuth2) | | |
|
| oauth2 | [OAuth2Config](#memos-api-v2-OAuth2Config) | | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="memos-api-v2-IdentityProvider-Config-FieldMapping"></a>
|
|
||||||
|
|
||||||
### IdentityProvider.Config.FieldMapping
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
| Field | Type | Label | Description |
|
|
||||||
| ----- | ---- | ----- | ----------- |
|
|
||||||
| identifier | [string](#string) | | |
|
|
||||||
| display_name | [string](#string) | | |
|
|
||||||
| email | [string](#string) | | |
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="memos-api-v2-IdentityProvider-Config-OAuth2"></a>
|
|
||||||
|
|
||||||
### IdentityProvider.Config.OAuth2
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
| Field | Type | Label | Description |
|
|
||||||
| ----- | ---- | ----- | ----------- |
|
|
||||||
| client_id | [string](#string) | | |
|
|
||||||
| client_secret | [string](#string) | | |
|
|
||||||
| auth_url | [string](#string) | | |
|
|
||||||
| token_url | [string](#string) | | |
|
|
||||||
| user_info_url | [string](#string) | | |
|
|
||||||
| scopes | [string](#string) | repeated | |
|
|
||||||
| field_mapping | [IdentityProvider.Config.FieldMapping](#memos-api-v2-IdentityProvider-Config-FieldMapping) | | |
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1194,6 +1192,27 @@ Used internally for obfuscating the page token.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="memos-api-v2-OAuth2Config"></a>
|
||||||
|
|
||||||
|
### OAuth2Config
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
| Field | Type | Label | Description |
|
||||||
|
| ----- | ---- | ----- | ----------- |
|
||||||
|
| client_id | [string](#string) | | |
|
||||||
|
| client_secret | [string](#string) | | |
|
||||||
|
| auth_url | [string](#string) | | |
|
||||||
|
| token_url | [string](#string) | | |
|
||||||
|
| user_info_url | [string](#string) | | |
|
||||||
|
| scopes | [string](#string) | repeated | |
|
||||||
|
| field_mapping | [FieldMapping](#memos-api-v2-FieldMapping) | | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="memos-api-v2-UpdateIdentityProviderRequest"></a>
|
<a name="memos-api-v2-UpdateIdentityProviderRequest"></a>
|
||||||
|
|
||||||
### UpdateIdentityProviderRequest
|
### UpdateIdentityProviderRequest
|
||||||
@ -2423,6 +2442,245 @@ Used internally for obfuscating the page token.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="api_v2_storage_service-proto"></a>
|
||||||
|
<p align="right"><a href="#top">Top</a></p>
|
||||||
|
|
||||||
|
## api/v2/storage_service.proto
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="memos-api-v2-CreateStorageRequest"></a>
|
||||||
|
|
||||||
|
### CreateStorageRequest
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
| Field | Type | Label | Description |
|
||||||
|
| ----- | ---- | ----- | ----------- |
|
||||||
|
| storage | [Storage](#memos-api-v2-Storage) | | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="memos-api-v2-CreateStorageResponse"></a>
|
||||||
|
|
||||||
|
### CreateStorageResponse
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
| Field | Type | Label | Description |
|
||||||
|
| ----- | ---- | ----- | ----------- |
|
||||||
|
| storage | [Storage](#memos-api-v2-Storage) | | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="memos-api-v2-DeleteStorageRequest"></a>
|
||||||
|
|
||||||
|
### DeleteStorageRequest
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
| Field | Type | Label | Description |
|
||||||
|
| ----- | ---- | ----- | ----------- |
|
||||||
|
| id | [int32](#int32) | | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="memos-api-v2-DeleteStorageResponse"></a>
|
||||||
|
|
||||||
|
### DeleteStorageResponse
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="memos-api-v2-GetStorageRequest"></a>
|
||||||
|
|
||||||
|
### GetStorageRequest
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
| Field | Type | Label | Description |
|
||||||
|
| ----- | ---- | ----- | ----------- |
|
||||||
|
| id | [int32](#int32) | | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="memos-api-v2-GetStorageResponse"></a>
|
||||||
|
|
||||||
|
### GetStorageResponse
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
| Field | Type | Label | Description |
|
||||||
|
| ----- | ---- | ----- | ----------- |
|
||||||
|
| storage | [Storage](#memos-api-v2-Storage) | | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="memos-api-v2-ListStoragesRequest"></a>
|
||||||
|
|
||||||
|
### ListStoragesRequest
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="memos-api-v2-ListStoragesResponse"></a>
|
||||||
|
|
||||||
|
### ListStoragesResponse
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
| Field | Type | Label | Description |
|
||||||
|
| ----- | ---- | ----- | ----------- |
|
||||||
|
| storages | [Storage](#memos-api-v2-Storage) | repeated | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="memos-api-v2-S3Config"></a>
|
||||||
|
|
||||||
|
### S3Config
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
| Field | Type | Label | Description |
|
||||||
|
| ----- | ---- | ----- | ----------- |
|
||||||
|
| end_point | [string](#string) | | |
|
||||||
|
| path | [string](#string) | | |
|
||||||
|
| region | [string](#string) | | |
|
||||||
|
| access_key | [string](#string) | | |
|
||||||
|
| secret_key | [string](#string) | | |
|
||||||
|
| bucket | [string](#string) | | |
|
||||||
|
| url_prefix | [string](#string) | | |
|
||||||
|
| url_suffix | [string](#string) | | |
|
||||||
|
| pre_sign | [bool](#bool) | | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="memos-api-v2-Storage"></a>
|
||||||
|
|
||||||
|
### Storage
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
| Field | Type | Label | Description |
|
||||||
|
| ----- | ---- | ----- | ----------- |
|
||||||
|
| id | [int32](#int32) | | |
|
||||||
|
| title | [string](#string) | | |
|
||||||
|
| type | [Storage.Type](#memos-api-v2-Storage-Type) | | |
|
||||||
|
| config | [StorageConfig](#memos-api-v2-StorageConfig) | | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="memos-api-v2-StorageConfig"></a>
|
||||||
|
|
||||||
|
### StorageConfig
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
| Field | Type | Label | Description |
|
||||||
|
| ----- | ---- | ----- | ----------- |
|
||||||
|
| s3_config | [S3Config](#memos-api-v2-S3Config) | | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="memos-api-v2-UpdateStorageRequest"></a>
|
||||||
|
|
||||||
|
### UpdateStorageRequest
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
| Field | Type | Label | Description |
|
||||||
|
| ----- | ---- | ----- | ----------- |
|
||||||
|
| storage | [Storage](#memos-api-v2-Storage) | | |
|
||||||
|
| update_mask | [google.protobuf.FieldMask](#google-protobuf-FieldMask) | | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="memos-api-v2-UpdateStorageResponse"></a>
|
||||||
|
|
||||||
|
### UpdateStorageResponse
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
| Field | Type | Label | Description |
|
||||||
|
| ----- | ---- | ----- | ----------- |
|
||||||
|
| storage | [Storage](#memos-api-v2-Storage) | | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="memos-api-v2-Storage-Type"></a>
|
||||||
|
|
||||||
|
### Storage.Type
|
||||||
|
|
||||||
|
|
||||||
|
| Name | Number | Description |
|
||||||
|
| ---- | ------ | ----------- |
|
||||||
|
| TYPE_UNSPECIFIED | 0 | |
|
||||||
|
| S3 | 1 | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="memos-api-v2-StorageService"></a>
|
||||||
|
|
||||||
|
### StorageService
|
||||||
|
|
||||||
|
|
||||||
|
| Method Name | Request Type | Response Type | Description |
|
||||||
|
| ----------- | ------------ | ------------- | ------------|
|
||||||
|
| CreateStorage | [CreateStorageRequest](#memos-api-v2-CreateStorageRequest) | [CreateStorageResponse](#memos-api-v2-CreateStorageResponse) | CreateStorage creates a new storage. |
|
||||||
|
| GetStorage | [GetStorageRequest](#memos-api-v2-GetStorageRequest) | [GetStorageResponse](#memos-api-v2-GetStorageResponse) | GetStorage returns a storage by id. |
|
||||||
|
| ListStorages | [ListStoragesRequest](#memos-api-v2-ListStoragesRequest) | [ListStoragesResponse](#memos-api-v2-ListStoragesResponse) | ListStorages returns a list of storages. |
|
||||||
|
| UpdateStorage | [UpdateStorageRequest](#memos-api-v2-UpdateStorageRequest) | [UpdateStorageResponse](#memos-api-v2-UpdateStorageResponse) | UpdateStorage updates a storage. |
|
||||||
|
| DeleteStorage | [DeleteStorageRequest](#memos-api-v2-DeleteStorageRequest) | [DeleteStorageResponse](#memos-api-v2-DeleteStorageResponse) | DeleteStorage deletes a storage by id. |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="api_v2_tag_service-proto"></a>
|
<a name="api_v2_tag_service-proto"></a>
|
||||||
<p align="right"><a href="#top">Top</a></p>
|
<p align="right"><a href="#top">Top</a></p>
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
1163
proto/gen/api/v2/storage_service.pb.go
Normal file
1163
proto/gen/api/v2/storage_service.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
597
proto/gen/api/v2/storage_service.pb.gw.go
Normal file
597
proto/gen/api/v2/storage_service.pb.gw.go
Normal file
@ -0,0 +1,597 @@
|
|||||||
|
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||||
|
// source: api/v2/storage_service.proto
|
||||||
|
|
||||||
|
/*
|
||||||
|
Package apiv2 is a reverse proxy.
|
||||||
|
|
||||||
|
It translates gRPC into RESTful JSON APIs.
|
||||||
|
*/
|
||||||
|
package apiv2
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||||
|
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/grpclog"
|
||||||
|
"google.golang.org/grpc/metadata"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Suppress "imported and not used" errors
|
||||||
|
var _ codes.Code
|
||||||
|
var _ io.Reader
|
||||||
|
var _ status.Status
|
||||||
|
var _ = runtime.String
|
||||||
|
var _ = utilities.NewDoubleArray
|
||||||
|
var _ = metadata.Join
|
||||||
|
|
||||||
|
func request_StorageService_CreateStorage_0(ctx context.Context, marshaler runtime.Marshaler, client StorageServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq CreateStorageRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||||
|
if berr != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||||
|
}
|
||||||
|
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := client.CreateStorage(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func local_request_StorageService_CreateStorage_0(ctx context.Context, marshaler runtime.Marshaler, server StorageServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq CreateStorageRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||||
|
if berr != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||||
|
}
|
||||||
|
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := server.CreateStorage(ctx, &protoReq)
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func request_StorageService_GetStorage_0(ctx context.Context, marshaler runtime.Marshaler, client StorageServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq GetStorageRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
var (
|
||||||
|
val string
|
||||||
|
ok bool
|
||||||
|
err error
|
||||||
|
_ = err
|
||||||
|
)
|
||||||
|
|
||||||
|
val, ok = pathParams["id"]
|
||||||
|
if !ok {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
|
||||||
|
}
|
||||||
|
|
||||||
|
protoReq.Id, err = runtime.Int32(val)
|
||||||
|
if err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := client.GetStorage(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func local_request_StorageService_GetStorage_0(ctx context.Context, marshaler runtime.Marshaler, server StorageServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq GetStorageRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
var (
|
||||||
|
val string
|
||||||
|
ok bool
|
||||||
|
err error
|
||||||
|
_ = err
|
||||||
|
)
|
||||||
|
|
||||||
|
val, ok = pathParams["id"]
|
||||||
|
if !ok {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
|
||||||
|
}
|
||||||
|
|
||||||
|
protoReq.Id, err = runtime.Int32(val)
|
||||||
|
if err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := server.GetStorage(ctx, &protoReq)
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func request_StorageService_ListStorages_0(ctx context.Context, marshaler runtime.Marshaler, client StorageServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq ListStoragesRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
msg, err := client.ListStorages(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func local_request_StorageService_ListStorages_0(ctx context.Context, marshaler runtime.Marshaler, server StorageServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq ListStoragesRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
msg, err := server.ListStorages(ctx, &protoReq)
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
filter_StorageService_UpdateStorage_0 = &utilities.DoubleArray{Encoding: map[string]int{"storage": 0, "id": 1}, Base: []int{1, 4, 5, 2, 0, 0, 0, 0}, Check: []int{0, 1, 1, 2, 4, 2, 2, 3}}
|
||||||
|
)
|
||||||
|
|
||||||
|
func request_StorageService_UpdateStorage_0(ctx context.Context, marshaler runtime.Marshaler, client StorageServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq UpdateStorageRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||||
|
if berr != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||||
|
}
|
||||||
|
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Storage); err != nil && err != io.EOF {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 {
|
||||||
|
if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Storage); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
} else {
|
||||||
|
protoReq.UpdateMask = fieldMask
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
val string
|
||||||
|
ok bool
|
||||||
|
err error
|
||||||
|
_ = err
|
||||||
|
)
|
||||||
|
|
||||||
|
val, ok = pathParams["storage.id"]
|
||||||
|
if !ok {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "storage.id")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = runtime.PopulateFieldFromPath(&protoReq, "storage.id", val)
|
||||||
|
if err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "storage.id", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := req.ParseForm(); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_StorageService_UpdateStorage_0); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := client.UpdateStorage(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func local_request_StorageService_UpdateStorage_0(ctx context.Context, marshaler runtime.Marshaler, server StorageServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq UpdateStorageRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||||
|
if berr != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||||
|
}
|
||||||
|
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Storage); err != nil && err != io.EOF {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 {
|
||||||
|
if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Storage); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
} else {
|
||||||
|
protoReq.UpdateMask = fieldMask
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
val string
|
||||||
|
ok bool
|
||||||
|
err error
|
||||||
|
_ = err
|
||||||
|
)
|
||||||
|
|
||||||
|
val, ok = pathParams["storage.id"]
|
||||||
|
if !ok {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "storage.id")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = runtime.PopulateFieldFromPath(&protoReq, "storage.id", val)
|
||||||
|
if err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "storage.id", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := req.ParseForm(); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_StorageService_UpdateStorage_0); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := server.UpdateStorage(ctx, &protoReq)
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func request_StorageService_DeleteStorage_0(ctx context.Context, marshaler runtime.Marshaler, client StorageServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq DeleteStorageRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
var (
|
||||||
|
val string
|
||||||
|
ok bool
|
||||||
|
err error
|
||||||
|
_ = err
|
||||||
|
)
|
||||||
|
|
||||||
|
val, ok = pathParams["id"]
|
||||||
|
if !ok {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
|
||||||
|
}
|
||||||
|
|
||||||
|
protoReq.Id, err = runtime.Int32(val)
|
||||||
|
if err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := client.DeleteStorage(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func local_request_StorageService_DeleteStorage_0(ctx context.Context, marshaler runtime.Marshaler, server StorageServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq DeleteStorageRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
var (
|
||||||
|
val string
|
||||||
|
ok bool
|
||||||
|
err error
|
||||||
|
_ = err
|
||||||
|
)
|
||||||
|
|
||||||
|
val, ok = pathParams["id"]
|
||||||
|
if !ok {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
|
||||||
|
}
|
||||||
|
|
||||||
|
protoReq.Id, err = runtime.Int32(val)
|
||||||
|
if err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := server.DeleteStorage(ctx, &protoReq)
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterStorageServiceHandlerServer registers the http handlers for service StorageService to "mux".
|
||||||
|
// UnaryRPC :call StorageServiceServer directly.
|
||||||
|
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||||
|
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterStorageServiceHandlerFromEndpoint instead.
|
||||||
|
func RegisterStorageServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server StorageServiceServer) error {
|
||||||
|
|
||||||
|
mux.Handle("POST", pattern_StorageService_CreateStorage_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
var stream runtime.ServerTransportStream
|
||||||
|
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
var err error
|
||||||
|
var annotatedContext context.Context
|
||||||
|
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.StorageService/CreateStorage", runtime.WithHTTPPathPattern("/api/v2/storages"))
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := local_request_StorageService_CreateStorage_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||||
|
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||||
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_StorageService_CreateStorage_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_StorageService_GetStorage_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
var stream runtime.ServerTransportStream
|
||||||
|
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
var err error
|
||||||
|
var annotatedContext context.Context
|
||||||
|
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.StorageService/GetStorage", runtime.WithHTTPPathPattern("/api/v2/storages/{id}"))
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := local_request_StorageService_GetStorage_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||||
|
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||||
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_StorageService_GetStorage_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_StorageService_ListStorages_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
var stream runtime.ServerTransportStream
|
||||||
|
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
var err error
|
||||||
|
var annotatedContext context.Context
|
||||||
|
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.StorageService/ListStorages", runtime.WithHTTPPathPattern("/api/v2/storages"))
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := local_request_StorageService_ListStorages_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||||
|
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||||
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_StorageService_ListStorages_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("PATCH", pattern_StorageService_UpdateStorage_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
var stream runtime.ServerTransportStream
|
||||||
|
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
var err error
|
||||||
|
var annotatedContext context.Context
|
||||||
|
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.StorageService/UpdateStorage", runtime.WithHTTPPathPattern("/api/v2/storages/{storage.id}"))
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := local_request_StorageService_UpdateStorage_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||||
|
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||||
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_StorageService_UpdateStorage_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("DELETE", pattern_StorageService_DeleteStorage_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
var stream runtime.ServerTransportStream
|
||||||
|
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
var err error
|
||||||
|
var annotatedContext context.Context
|
||||||
|
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.StorageService/DeleteStorage", runtime.WithHTTPPathPattern("/api/v2/storages/{id}"))
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := local_request_StorageService_DeleteStorage_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||||
|
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||||
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_StorageService_DeleteStorage_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterStorageServiceHandlerFromEndpoint is same as RegisterStorageServiceHandler but
|
||||||
|
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
||||||
|
func RegisterStorageServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
||||||
|
conn, err := grpc.DialContext(ctx, endpoint, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
if cerr := conn.Close(); cerr != nil {
|
||||||
|
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
go func() {
|
||||||
|
<-ctx.Done()
|
||||||
|
if cerr := conn.Close(); cerr != nil {
|
||||||
|
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}()
|
||||||
|
|
||||||
|
return RegisterStorageServiceHandler(ctx, mux, conn)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterStorageServiceHandler registers the http handlers for service StorageService to "mux".
|
||||||
|
// The handlers forward requests to the grpc endpoint over "conn".
|
||||||
|
func RegisterStorageServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
||||||
|
return RegisterStorageServiceHandlerClient(ctx, mux, NewStorageServiceClient(conn))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterStorageServiceHandlerClient registers the http handlers for service StorageService
|
||||||
|
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "StorageServiceClient".
|
||||||
|
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "StorageServiceClient"
|
||||||
|
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
|
||||||
|
// "StorageServiceClient" to call the correct interceptors.
|
||||||
|
func RegisterStorageServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client StorageServiceClient) error {
|
||||||
|
|
||||||
|
mux.Handle("POST", pattern_StorageService_CreateStorage_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
var err error
|
||||||
|
var annotatedContext context.Context
|
||||||
|
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/memos.api.v2.StorageService/CreateStorage", runtime.WithHTTPPathPattern("/api/v2/storages"))
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := request_StorageService_CreateStorage_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||||
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_StorageService_CreateStorage_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_StorageService_GetStorage_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
var err error
|
||||||
|
var annotatedContext context.Context
|
||||||
|
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/memos.api.v2.StorageService/GetStorage", runtime.WithHTTPPathPattern("/api/v2/storages/{id}"))
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := request_StorageService_GetStorage_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||||
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_StorageService_GetStorage_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_StorageService_ListStorages_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
var err error
|
||||||
|
var annotatedContext context.Context
|
||||||
|
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/memos.api.v2.StorageService/ListStorages", runtime.WithHTTPPathPattern("/api/v2/storages"))
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := request_StorageService_ListStorages_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||||
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_StorageService_ListStorages_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("PATCH", pattern_StorageService_UpdateStorage_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
var err error
|
||||||
|
var annotatedContext context.Context
|
||||||
|
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/memos.api.v2.StorageService/UpdateStorage", runtime.WithHTTPPathPattern("/api/v2/storages/{storage.id}"))
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := request_StorageService_UpdateStorage_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||||
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_StorageService_UpdateStorage_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("DELETE", pattern_StorageService_DeleteStorage_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
var err error
|
||||||
|
var annotatedContext context.Context
|
||||||
|
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/memos.api.v2.StorageService/DeleteStorage", runtime.WithHTTPPathPattern("/api/v2/storages/{id}"))
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := request_StorageService_DeleteStorage_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||||
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_StorageService_DeleteStorage_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
pattern_StorageService_CreateStorage_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v2", "storages"}, ""))
|
||||||
|
|
||||||
|
pattern_StorageService_GetStorage_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v2", "storages", "id"}, ""))
|
||||||
|
|
||||||
|
pattern_StorageService_ListStorages_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v2", "storages"}, ""))
|
||||||
|
|
||||||
|
pattern_StorageService_UpdateStorage_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v2", "storages", "storage.id"}, ""))
|
||||||
|
|
||||||
|
pattern_StorageService_DeleteStorage_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v2", "storages", "id"}, ""))
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
forward_StorageService_CreateStorage_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
forward_StorageService_GetStorage_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
forward_StorageService_ListStorages_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
forward_StorageService_UpdateStorage_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
forward_StorageService_DeleteStorage_0 = runtime.ForwardResponseMessage
|
||||||
|
)
|
267
proto/gen/api/v2/storage_service_grpc.pb.go
Normal file
267
proto/gen/api/v2/storage_service_grpc.pb.go
Normal file
@ -0,0 +1,267 @@
|
|||||||
|
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// - protoc-gen-go-grpc v1.3.0
|
||||||
|
// - protoc (unknown)
|
||||||
|
// source: api/v2/storage_service.proto
|
||||||
|
|
||||||
|
package apiv2
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "context"
|
||||||
|
grpc "google.golang.org/grpc"
|
||||||
|
codes "google.golang.org/grpc/codes"
|
||||||
|
status "google.golang.org/grpc/status"
|
||||||
|
)
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the grpc package it is being compiled against.
|
||||||
|
// Requires gRPC-Go v1.32.0 or later.
|
||||||
|
const _ = grpc.SupportPackageIsVersion7
|
||||||
|
|
||||||
|
const (
|
||||||
|
StorageService_CreateStorage_FullMethodName = "/memos.api.v2.StorageService/CreateStorage"
|
||||||
|
StorageService_GetStorage_FullMethodName = "/memos.api.v2.StorageService/GetStorage"
|
||||||
|
StorageService_ListStorages_FullMethodName = "/memos.api.v2.StorageService/ListStorages"
|
||||||
|
StorageService_UpdateStorage_FullMethodName = "/memos.api.v2.StorageService/UpdateStorage"
|
||||||
|
StorageService_DeleteStorage_FullMethodName = "/memos.api.v2.StorageService/DeleteStorage"
|
||||||
|
)
|
||||||
|
|
||||||
|
// StorageServiceClient is the client API for StorageService service.
|
||||||
|
//
|
||||||
|
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||||
|
type StorageServiceClient interface {
|
||||||
|
// CreateStorage creates a new storage.
|
||||||
|
CreateStorage(ctx context.Context, in *CreateStorageRequest, opts ...grpc.CallOption) (*CreateStorageResponse, error)
|
||||||
|
// GetStorage returns a storage by id.
|
||||||
|
GetStorage(ctx context.Context, in *GetStorageRequest, opts ...grpc.CallOption) (*GetStorageResponse, error)
|
||||||
|
// ListStorages returns a list of storages.
|
||||||
|
ListStorages(ctx context.Context, in *ListStoragesRequest, opts ...grpc.CallOption) (*ListStoragesResponse, error)
|
||||||
|
// UpdateStorage updates a storage.
|
||||||
|
UpdateStorage(ctx context.Context, in *UpdateStorageRequest, opts ...grpc.CallOption) (*UpdateStorageResponse, error)
|
||||||
|
// DeleteStorage deletes a storage by id.
|
||||||
|
DeleteStorage(ctx context.Context, in *DeleteStorageRequest, opts ...grpc.CallOption) (*DeleteStorageResponse, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type storageServiceClient struct {
|
||||||
|
cc grpc.ClientConnInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewStorageServiceClient(cc grpc.ClientConnInterface) StorageServiceClient {
|
||||||
|
return &storageServiceClient{cc}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *storageServiceClient) CreateStorage(ctx context.Context, in *CreateStorageRequest, opts ...grpc.CallOption) (*CreateStorageResponse, error) {
|
||||||
|
out := new(CreateStorageResponse)
|
||||||
|
err := c.cc.Invoke(ctx, StorageService_CreateStorage_FullMethodName, in, out, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *storageServiceClient) GetStorage(ctx context.Context, in *GetStorageRequest, opts ...grpc.CallOption) (*GetStorageResponse, error) {
|
||||||
|
out := new(GetStorageResponse)
|
||||||
|
err := c.cc.Invoke(ctx, StorageService_GetStorage_FullMethodName, in, out, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *storageServiceClient) ListStorages(ctx context.Context, in *ListStoragesRequest, opts ...grpc.CallOption) (*ListStoragesResponse, error) {
|
||||||
|
out := new(ListStoragesResponse)
|
||||||
|
err := c.cc.Invoke(ctx, StorageService_ListStorages_FullMethodName, in, out, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *storageServiceClient) UpdateStorage(ctx context.Context, in *UpdateStorageRequest, opts ...grpc.CallOption) (*UpdateStorageResponse, error) {
|
||||||
|
out := new(UpdateStorageResponse)
|
||||||
|
err := c.cc.Invoke(ctx, StorageService_UpdateStorage_FullMethodName, in, out, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *storageServiceClient) DeleteStorage(ctx context.Context, in *DeleteStorageRequest, opts ...grpc.CallOption) (*DeleteStorageResponse, error) {
|
||||||
|
out := new(DeleteStorageResponse)
|
||||||
|
err := c.cc.Invoke(ctx, StorageService_DeleteStorage_FullMethodName, in, out, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// StorageServiceServer is the server API for StorageService service.
|
||||||
|
// All implementations must embed UnimplementedStorageServiceServer
|
||||||
|
// for forward compatibility
|
||||||
|
type StorageServiceServer interface {
|
||||||
|
// CreateStorage creates a new storage.
|
||||||
|
CreateStorage(context.Context, *CreateStorageRequest) (*CreateStorageResponse, error)
|
||||||
|
// GetStorage returns a storage by id.
|
||||||
|
GetStorage(context.Context, *GetStorageRequest) (*GetStorageResponse, error)
|
||||||
|
// ListStorages returns a list of storages.
|
||||||
|
ListStorages(context.Context, *ListStoragesRequest) (*ListStoragesResponse, error)
|
||||||
|
// UpdateStorage updates a storage.
|
||||||
|
UpdateStorage(context.Context, *UpdateStorageRequest) (*UpdateStorageResponse, error)
|
||||||
|
// DeleteStorage deletes a storage by id.
|
||||||
|
DeleteStorage(context.Context, *DeleteStorageRequest) (*DeleteStorageResponse, error)
|
||||||
|
mustEmbedUnimplementedStorageServiceServer()
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnimplementedStorageServiceServer must be embedded to have forward compatible implementations.
|
||||||
|
type UnimplementedStorageServiceServer struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (UnimplementedStorageServiceServer) CreateStorage(context.Context, *CreateStorageRequest) (*CreateStorageResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method CreateStorage not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedStorageServiceServer) GetStorage(context.Context, *GetStorageRequest) (*GetStorageResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method GetStorage not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedStorageServiceServer) ListStorages(context.Context, *ListStoragesRequest) (*ListStoragesResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method ListStorages not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedStorageServiceServer) UpdateStorage(context.Context, *UpdateStorageRequest) (*UpdateStorageResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method UpdateStorage not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedStorageServiceServer) DeleteStorage(context.Context, *DeleteStorageRequest) (*DeleteStorageResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method DeleteStorage not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedStorageServiceServer) mustEmbedUnimplementedStorageServiceServer() {}
|
||||||
|
|
||||||
|
// UnsafeStorageServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||||
|
// Use of this interface is not recommended, as added methods to StorageServiceServer will
|
||||||
|
// result in compilation errors.
|
||||||
|
type UnsafeStorageServiceServer interface {
|
||||||
|
mustEmbedUnimplementedStorageServiceServer()
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterStorageServiceServer(s grpc.ServiceRegistrar, srv StorageServiceServer) {
|
||||||
|
s.RegisterService(&StorageService_ServiceDesc, srv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _StorageService_CreateStorage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(CreateStorageRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(StorageServiceServer).CreateStorage(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: StorageService_CreateStorage_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(StorageServiceServer).CreateStorage(ctx, req.(*CreateStorageRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _StorageService_GetStorage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(GetStorageRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(StorageServiceServer).GetStorage(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: StorageService_GetStorage_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(StorageServiceServer).GetStorage(ctx, req.(*GetStorageRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _StorageService_ListStorages_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(ListStoragesRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(StorageServiceServer).ListStorages(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: StorageService_ListStorages_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(StorageServiceServer).ListStorages(ctx, req.(*ListStoragesRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _StorageService_UpdateStorage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(UpdateStorageRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(StorageServiceServer).UpdateStorage(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: StorageService_UpdateStorage_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(StorageServiceServer).UpdateStorage(ctx, req.(*UpdateStorageRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _StorageService_DeleteStorage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(DeleteStorageRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(StorageServiceServer).DeleteStorage(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: StorageService_DeleteStorage_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(StorageServiceServer).DeleteStorage(ctx, req.(*DeleteStorageRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
// StorageService_ServiceDesc is the grpc.ServiceDesc for StorageService service.
|
||||||
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
|
// and not to be introspected or modified (even as a copy)
|
||||||
|
var StorageService_ServiceDesc = grpc.ServiceDesc{
|
||||||
|
ServiceName: "memos.api.v2.StorageService",
|
||||||
|
HandlerType: (*StorageServiceServer)(nil),
|
||||||
|
Methods: []grpc.MethodDesc{
|
||||||
|
{
|
||||||
|
MethodName: "CreateStorage",
|
||||||
|
Handler: _StorageService_CreateStorage_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "GetStorage",
|
||||||
|
Handler: _StorageService_GetStorage_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "ListStorages",
|
||||||
|
Handler: _StorageService_ListStorages_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "UpdateStorage",
|
||||||
|
Handler: _StorageService_UpdateStorage_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "DeleteStorage",
|
||||||
|
Handler: _StorageService_DeleteStorage_Handler,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Streams: []grpc.StreamDesc{},
|
||||||
|
Metadata: "api/v2/storage_service.proto",
|
||||||
|
}
|
@ -12,9 +12,9 @@
|
|||||||
- [RowStatus](#memos-store-RowStatus)
|
- [RowStatus](#memos-store-RowStatus)
|
||||||
|
|
||||||
- [store/idp.proto](#store_idp-proto)
|
- [store/idp.proto](#store_idp-proto)
|
||||||
|
- [FieldMapping](#memos-store-FieldMapping)
|
||||||
- [IdentityProviderConfig](#memos-store-IdentityProviderConfig)
|
- [IdentityProviderConfig](#memos-store-IdentityProviderConfig)
|
||||||
- [IdentityProviderConfig.FieldMapping](#memos-store-IdentityProviderConfig-FieldMapping)
|
- [OAuth2Config](#memos-store-OAuth2Config)
|
||||||
- [IdentityProviderConfig.OAuth2](#memos-store-IdentityProviderConfig-OAuth2)
|
|
||||||
|
|
||||||
- [store/inbox.proto](#store_inbox-proto)
|
- [store/inbox.proto](#store_inbox-proto)
|
||||||
- [InboxMessage](#memos-store-InboxMessage)
|
- [InboxMessage](#memos-store-InboxMessage)
|
||||||
@ -158,24 +158,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="memos-store-IdentityProviderConfig"></a>
|
<a name="memos-store-FieldMapping"></a>
|
||||||
|
|
||||||
### IdentityProviderConfig
|
### FieldMapping
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
| Field | Type | Label | Description |
|
|
||||||
| ----- | ---- | ----- | ----------- |
|
|
||||||
| oauth2 | [IdentityProviderConfig.OAuth2](#memos-store-IdentityProviderConfig-OAuth2) | | |
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="memos-store-IdentityProviderConfig-FieldMapping"></a>
|
|
||||||
|
|
||||||
### IdentityProviderConfig.FieldMapping
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -190,9 +175,24 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="memos-store-IdentityProviderConfig-OAuth2"></a>
|
<a name="memos-store-IdentityProviderConfig"></a>
|
||||||
|
|
||||||
### IdentityProviderConfig.OAuth2
|
### IdentityProviderConfig
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
| Field | Type | Label | Description |
|
||||||
|
| ----- | ---- | ----- | ----------- |
|
||||||
|
| oauth2 | [OAuth2Config](#memos-store-OAuth2Config) | | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="memos-store-OAuth2Config"></a>
|
||||||
|
|
||||||
|
### OAuth2Config
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -204,7 +204,7 @@
|
|||||||
| token_url | [string](#string) | | |
|
| token_url | [string](#string) | | |
|
||||||
| user_info_url | [string](#string) | | |
|
| user_info_url | [string](#string) | | |
|
||||||
| scopes | [string](#string) | repeated | |
|
| scopes | [string](#string) | repeated | |
|
||||||
| field_mapping | [IdentityProviderConfig.FieldMapping](#memos-store-IdentityProviderConfig-FieldMapping) | | |
|
| field_mapping | [FieldMapping](#memos-store-FieldMapping) | | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ func (m *IdentityProviderConfig) GetConfig() isIdentityProviderConfig_Config {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *IdentityProviderConfig) GetOauth2() *IdentityProviderConfig_OAuth2 {
|
func (x *IdentityProviderConfig) GetOauth2() *OAuth2Config {
|
||||||
if x, ok := x.GetConfig().(*IdentityProviderConfig_Oauth2); ok {
|
if x, ok := x.GetConfig().(*IdentityProviderConfig_Oauth2); ok {
|
||||||
return x.Oauth2
|
return x.Oauth2
|
||||||
}
|
}
|
||||||
@ -82,12 +82,12 @@ type isIdentityProviderConfig_Config interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type IdentityProviderConfig_Oauth2 struct {
|
type IdentityProviderConfig_Oauth2 struct {
|
||||||
Oauth2 *IdentityProviderConfig_OAuth2 `protobuf:"bytes,1,opt,name=oauth2,proto3,oneof"`
|
Oauth2 *OAuth2Config `protobuf:"bytes,1,opt,name=oauth2,proto3,oneof"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*IdentityProviderConfig_Oauth2) isIdentityProviderConfig_Config() {}
|
func (*IdentityProviderConfig_Oauth2) isIdentityProviderConfig_Config() {}
|
||||||
|
|
||||||
type IdentityProviderConfig_FieldMapping struct {
|
type FieldMapping struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
@ -97,8 +97,8 @@ type IdentityProviderConfig_FieldMapping struct {
|
|||||||
Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
|
Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *IdentityProviderConfig_FieldMapping) Reset() {
|
func (x *FieldMapping) Reset() {
|
||||||
*x = IdentityProviderConfig_FieldMapping{}
|
*x = FieldMapping{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_store_idp_proto_msgTypes[1]
|
mi := &file_store_idp_proto_msgTypes[1]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@ -106,13 +106,13 @@ func (x *IdentityProviderConfig_FieldMapping) Reset() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *IdentityProviderConfig_FieldMapping) String() string {
|
func (x *FieldMapping) String() string {
|
||||||
return protoimpl.X.MessageStringOf(x)
|
return protoimpl.X.MessageStringOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*IdentityProviderConfig_FieldMapping) ProtoMessage() {}
|
func (*FieldMapping) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *IdentityProviderConfig_FieldMapping) ProtoReflect() protoreflect.Message {
|
func (x *FieldMapping) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_store_idp_proto_msgTypes[1]
|
mi := &file_store_idp_proto_msgTypes[1]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@ -124,33 +124,33 @@ func (x *IdentityProviderConfig_FieldMapping) ProtoReflect() protoreflect.Messag
|
|||||||
return mi.MessageOf(x)
|
return mi.MessageOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: Use IdentityProviderConfig_FieldMapping.ProtoReflect.Descriptor instead.
|
// Deprecated: Use FieldMapping.ProtoReflect.Descriptor instead.
|
||||||
func (*IdentityProviderConfig_FieldMapping) Descriptor() ([]byte, []int) {
|
func (*FieldMapping) Descriptor() ([]byte, []int) {
|
||||||
return file_store_idp_proto_rawDescGZIP(), []int{0, 0}
|
return file_store_idp_proto_rawDescGZIP(), []int{1}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *IdentityProviderConfig_FieldMapping) GetIdentifier() string {
|
func (x *FieldMapping) GetIdentifier() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Identifier
|
return x.Identifier
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *IdentityProviderConfig_FieldMapping) GetDisplayName() string {
|
func (x *FieldMapping) GetDisplayName() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.DisplayName
|
return x.DisplayName
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *IdentityProviderConfig_FieldMapping) GetEmail() string {
|
func (x *FieldMapping) GetEmail() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Email
|
return x.Email
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
type IdentityProviderConfig_OAuth2 struct {
|
type OAuth2Config struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
@ -161,11 +161,11 @@ type IdentityProviderConfig_OAuth2 struct {
|
|||||||
TokenUrl string `protobuf:"bytes,4,opt,name=token_url,json=tokenUrl,proto3" json:"token_url,omitempty"`
|
TokenUrl string `protobuf:"bytes,4,opt,name=token_url,json=tokenUrl,proto3" json:"token_url,omitempty"`
|
||||||
UserInfoUrl string `protobuf:"bytes,5,opt,name=user_info_url,json=userInfoUrl,proto3" json:"user_info_url,omitempty"`
|
UserInfoUrl string `protobuf:"bytes,5,opt,name=user_info_url,json=userInfoUrl,proto3" json:"user_info_url,omitempty"`
|
||||||
Scopes []string `protobuf:"bytes,6,rep,name=scopes,proto3" json:"scopes,omitempty"`
|
Scopes []string `protobuf:"bytes,6,rep,name=scopes,proto3" json:"scopes,omitempty"`
|
||||||
FieldMapping *IdentityProviderConfig_FieldMapping `protobuf:"bytes,7,opt,name=field_mapping,json=fieldMapping,proto3" json:"field_mapping,omitempty"`
|
FieldMapping *FieldMapping `protobuf:"bytes,7,opt,name=field_mapping,json=fieldMapping,proto3" json:"field_mapping,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *IdentityProviderConfig_OAuth2) Reset() {
|
func (x *OAuth2Config) Reset() {
|
||||||
*x = IdentityProviderConfig_OAuth2{}
|
*x = OAuth2Config{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_store_idp_proto_msgTypes[2]
|
mi := &file_store_idp_proto_msgTypes[2]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@ -173,13 +173,13 @@ func (x *IdentityProviderConfig_OAuth2) Reset() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *IdentityProviderConfig_OAuth2) String() string {
|
func (x *OAuth2Config) String() string {
|
||||||
return protoimpl.X.MessageStringOf(x)
|
return protoimpl.X.MessageStringOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*IdentityProviderConfig_OAuth2) ProtoMessage() {}
|
func (*OAuth2Config) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *IdentityProviderConfig_OAuth2) ProtoReflect() protoreflect.Message {
|
func (x *OAuth2Config) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_store_idp_proto_msgTypes[2]
|
mi := &file_store_idp_proto_msgTypes[2]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@ -191,54 +191,54 @@ func (x *IdentityProviderConfig_OAuth2) ProtoReflect() protoreflect.Message {
|
|||||||
return mi.MessageOf(x)
|
return mi.MessageOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: Use IdentityProviderConfig_OAuth2.ProtoReflect.Descriptor instead.
|
// Deprecated: Use OAuth2Config.ProtoReflect.Descriptor instead.
|
||||||
func (*IdentityProviderConfig_OAuth2) Descriptor() ([]byte, []int) {
|
func (*OAuth2Config) Descriptor() ([]byte, []int) {
|
||||||
return file_store_idp_proto_rawDescGZIP(), []int{0, 1}
|
return file_store_idp_proto_rawDescGZIP(), []int{2}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *IdentityProviderConfig_OAuth2) GetClientId() string {
|
func (x *OAuth2Config) GetClientId() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.ClientId
|
return x.ClientId
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *IdentityProviderConfig_OAuth2) GetClientSecret() string {
|
func (x *OAuth2Config) GetClientSecret() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.ClientSecret
|
return x.ClientSecret
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *IdentityProviderConfig_OAuth2) GetAuthUrl() string {
|
func (x *OAuth2Config) GetAuthUrl() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.AuthUrl
|
return x.AuthUrl
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *IdentityProviderConfig_OAuth2) GetTokenUrl() string {
|
func (x *OAuth2Config) GetTokenUrl() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.TokenUrl
|
return x.TokenUrl
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *IdentityProviderConfig_OAuth2) GetUserInfoUrl() string {
|
func (x *OAuth2Config) GetUserInfoUrl() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.UserInfoUrl
|
return x.UserInfoUrl
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *IdentityProviderConfig_OAuth2) GetScopes() []string {
|
func (x *OAuth2Config) GetScopes() []string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Scopes
|
return x.Scopes
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *IdentityProviderConfig_OAuth2) GetFieldMapping() *IdentityProviderConfig_FieldMapping {
|
func (x *OAuth2Config) GetFieldMapping() *FieldMapping {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.FieldMapping
|
return x.FieldMapping
|
||||||
}
|
}
|
||||||
@ -249,48 +249,46 @@ var File_store_idp_proto protoreflect.FileDescriptor
|
|||||||
|
|
||||||
var file_store_idp_proto_rawDesc = []byte{
|
var file_store_idp_proto_rawDesc = []byte{
|
||||||
0x0a, 0x0f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x69, 0x64, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
0x0a, 0x0f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x69, 0x64, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||||
0x6f, 0x12, 0x0b, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x22, 0xe9,
|
0x6f, 0x12, 0x0b, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x22, 0x57,
|
||||||
0x03, 0x0a, 0x16, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69,
|
0x0a, 0x16, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64,
|
||||||
0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x44, 0x0a, 0x06, 0x6f, 0x61, 0x75,
|
0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x33, 0x0a, 0x06, 0x6f, 0x61, 0x75, 0x74,
|
||||||
0x74, 0x68, 0x32, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x6d, 0x65, 0x6d, 0x6f,
|
0x68, 0x32, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73,
|
||||||
0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79,
|
0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x4f, 0x41, 0x75, 0x74, 0x68, 0x32, 0x43, 0x6f, 0x6e,
|
||||||
0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x4f,
|
0x66, 0x69, 0x67, 0x48, 0x00, 0x52, 0x06, 0x6f, 0x61, 0x75, 0x74, 0x68, 0x32, 0x42, 0x08, 0x0a,
|
||||||
0x41, 0x75, 0x74, 0x68, 0x32, 0x48, 0x00, 0x52, 0x06, 0x6f, 0x61, 0x75, 0x74, 0x68, 0x32, 0x1a,
|
0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x67, 0x0a, 0x0c, 0x46, 0x69, 0x65, 0x6c, 0x64,
|
||||||
0x67, 0x0a, 0x0c, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x12,
|
0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74,
|
||||||
0x1e, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, 0x20,
|
0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x64, 0x65,
|
||||||
0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12,
|
0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x69, 0x73, 0x70, 0x6c,
|
||||||
0x21, 0x0a, 0x0c, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18,
|
0x61, 0x79, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64,
|
||||||
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4e, 0x61,
|
0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d,
|
||||||
0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28,
|
0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c,
|
||||||
0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x1a, 0x95, 0x02, 0x0a, 0x06, 0x4f, 0x41, 0x75,
|
0x22, 0x84, 0x02, 0x0a, 0x0c, 0x4f, 0x41, 0x75, 0x74, 0x68, 0x32, 0x43, 0x6f, 0x6e, 0x66, 0x69,
|
||||||
0x74, 0x68, 0x32, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64,
|
0x67, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01,
|
||||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64,
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x23,
|
||||||
0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x65, 0x63, 0x72, 0x65,
|
0x0a, 0x0d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18,
|
||||||
0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53,
|
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x63,
|
||||||
0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x75, 0x72,
|
0x72, 0x65, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x75, 0x72, 0x6c, 0x18,
|
||||||
0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x75, 0x74, 0x68, 0x55, 0x72, 0x6c,
|
0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x75, 0x74, 0x68, 0x55, 0x72, 0x6c, 0x12, 0x1b,
|
||||||
0x12, 0x1b, 0x0a, 0x09, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x04, 0x20,
|
0x0a, 0x09, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28,
|
||||||
0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x55, 0x72, 0x6c, 0x12, 0x22, 0x0a,
|
0x09, 0x52, 0x08, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x55, 0x72, 0x6c, 0x12, 0x22, 0x0a, 0x0d, 0x75,
|
||||||
0x0d, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x05,
|
0x73, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x05, 0x20, 0x01,
|
||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x75, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x55, 0x72,
|
0x28, 0x09, 0x52, 0x0b, 0x75, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x55, 0x72, 0x6c, 0x12,
|
||||||
0x6c, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28,
|
0x16, 0x0a, 0x06, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52,
|
||||||
0x09, 0x52, 0x06, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x12, 0x55, 0x0a, 0x0d, 0x66, 0x69, 0x65,
|
0x06, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x12, 0x3e, 0x0a, 0x0d, 0x66, 0x69, 0x65, 0x6c, 0x64,
|
||||||
0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b,
|
0x5f, 0x6d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19,
|
||||||
0x32, 0x30, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x49,
|
0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x46, 0x69, 0x65,
|
||||||
0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x43,
|
0x6c, 0x64, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x0c, 0x66, 0x69, 0x65, 0x6c, 0x64,
|
||||||
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x70, 0x70, 0x69,
|
0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x42, 0x93, 0x01, 0x0a, 0x0f, 0x63, 0x6f, 0x6d, 0x2e,
|
||||||
0x6e, 0x67, 0x52, 0x0c, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67,
|
0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x42, 0x08, 0x49, 0x64, 0x70,
|
||||||
0x42, 0x08, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x42, 0x93, 0x01, 0x0a, 0x0f, 0x63,
|
0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e,
|
||||||
0x6f, 0x6d, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x42, 0x08,
|
0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x73, 0x65, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, 0x65, 0x6d,
|
||||||
0x49, 0x64, 0x70, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68,
|
0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x73, 0x74, 0x6f,
|
||||||
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x73, 0x65, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f,
|
0x72, 0x65, 0xa2, 0x02, 0x03, 0x4d, 0x53, 0x58, 0xaa, 0x02, 0x0b, 0x4d, 0x65, 0x6d, 0x6f, 0x73,
|
||||||
0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f,
|
0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0xca, 0x02, 0x0b, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x53,
|
||||||
0x73, 0x74, 0x6f, 0x72, 0x65, 0xa2, 0x02, 0x03, 0x4d, 0x53, 0x58, 0xaa, 0x02, 0x0b, 0x4d, 0x65,
|
0x74, 0x6f, 0x72, 0x65, 0xe2, 0x02, 0x17, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x53, 0x74, 0x6f,
|
||||||
0x6d, 0x6f, 0x73, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0xca, 0x02, 0x0b, 0x4d, 0x65, 0x6d, 0x6f,
|
0x72, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02,
|
||||||
0x73, 0x5c, 0x53, 0x74, 0x6f, 0x72, 0x65, 0xe2, 0x02, 0x17, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c,
|
0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70,
|
||||||
0x53, 0x74, 0x6f, 0x72, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74,
|
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
0x61, 0xea, 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x53, 0x74, 0x6f, 0x72, 0x65,
|
|
||||||
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -308,12 +306,12 @@ func file_store_idp_proto_rawDescGZIP() []byte {
|
|||||||
var file_store_idp_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
var file_store_idp_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||||
var file_store_idp_proto_goTypes = []interface{}{
|
var file_store_idp_proto_goTypes = []interface{}{
|
||||||
(*IdentityProviderConfig)(nil), // 0: memos.store.IdentityProviderConfig
|
(*IdentityProviderConfig)(nil), // 0: memos.store.IdentityProviderConfig
|
||||||
(*IdentityProviderConfig_FieldMapping)(nil), // 1: memos.store.IdentityProviderConfig.FieldMapping
|
(*FieldMapping)(nil), // 1: memos.store.FieldMapping
|
||||||
(*IdentityProviderConfig_OAuth2)(nil), // 2: memos.store.IdentityProviderConfig.OAuth2
|
(*OAuth2Config)(nil), // 2: memos.store.OAuth2Config
|
||||||
}
|
}
|
||||||
var file_store_idp_proto_depIdxs = []int32{
|
var file_store_idp_proto_depIdxs = []int32{
|
||||||
2, // 0: memos.store.IdentityProviderConfig.oauth2:type_name -> memos.store.IdentityProviderConfig.OAuth2
|
2, // 0: memos.store.IdentityProviderConfig.oauth2:type_name -> memos.store.OAuth2Config
|
||||||
1, // 1: memos.store.IdentityProviderConfig.OAuth2.field_mapping:type_name -> memos.store.IdentityProviderConfig.FieldMapping
|
1, // 1: memos.store.OAuth2Config.field_mapping:type_name -> memos.store.FieldMapping
|
||||||
2, // [2:2] is the sub-list for method output_type
|
2, // [2:2] is the sub-list for method output_type
|
||||||
2, // [2:2] is the sub-list for method input_type
|
2, // [2:2] is the sub-list for method input_type
|
||||||
2, // [2:2] is the sub-list for extension type_name
|
2, // [2:2] is the sub-list for extension type_name
|
||||||
@ -340,7 +338,7 @@ func file_store_idp_proto_init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_store_idp_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
file_store_idp_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*IdentityProviderConfig_FieldMapping); i {
|
switch v := v.(*FieldMapping); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
case 1:
|
case 1:
|
||||||
@ -352,7 +350,7 @@ func file_store_idp_proto_init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_store_idp_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
file_store_idp_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*IdentityProviderConfig_OAuth2); i {
|
switch v := v.(*OAuth2Config); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -5,13 +5,18 @@ package memos.store;
|
|||||||
option go_package = "gen/store";
|
option go_package = "gen/store";
|
||||||
|
|
||||||
message IdentityProviderConfig {
|
message IdentityProviderConfig {
|
||||||
message FieldMapping {
|
oneof config {
|
||||||
|
OAuth2Config oauth2 = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message FieldMapping {
|
||||||
string identifier = 1;
|
string identifier = 1;
|
||||||
string display_name = 2;
|
string display_name = 2;
|
||||||
string email = 3;
|
string email = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message OAuth2 {
|
message OAuth2Config {
|
||||||
string client_id = 1;
|
string client_id = 1;
|
||||||
string client_secret = 2;
|
string client_secret = 2;
|
||||||
string auth_url = 3;
|
string auth_url = 3;
|
||||||
@ -19,9 +24,4 @@ message IdentityProviderConfig {
|
|||||||
string user_info_url = 5;
|
string user_info_url = 5;
|
||||||
repeated string scopes = 6;
|
repeated string scopes = 6;
|
||||||
FieldMapping field_mapping = 7;
|
FieldMapping field_mapping = 7;
|
||||||
}
|
|
||||||
|
|
||||||
oneof config {
|
|
||||||
OAuth2 oauth2 = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ tags:
|
|||||||
- name: LinkService
|
- name: LinkService
|
||||||
- name: ResourceService
|
- name: ResourceService
|
||||||
- name: MemoService
|
- name: MemoService
|
||||||
|
- name: StorageService
|
||||||
- name: TagService
|
- name: TagService
|
||||||
- name: WebhookService
|
- name: WebhookService
|
||||||
- name: WorkspaceService
|
- name: WorkspaceService
|
||||||
@ -515,6 +516,115 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
tags:
|
tags:
|
||||||
- ResourceService
|
- ResourceService
|
||||||
|
/api/v2/storages:
|
||||||
|
get:
|
||||||
|
summary: ListStorages returns a list of storages.
|
||||||
|
operationId: StorageService_ListStorages
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: A successful response.
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/v2ListStoragesResponse'
|
||||||
|
default:
|
||||||
|
description: An unexpected error response.
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/googlerpcStatus'
|
||||||
|
tags:
|
||||||
|
- StorageService
|
||||||
|
post:
|
||||||
|
summary: CreateStorage creates a new storage.
|
||||||
|
operationId: StorageService_CreateStorage
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: A successful response.
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/v2CreateStorageResponse'
|
||||||
|
default:
|
||||||
|
description: An unexpected error response.
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/googlerpcStatus'
|
||||||
|
parameters:
|
||||||
|
- name: body
|
||||||
|
in: body
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/v2CreateStorageRequest'
|
||||||
|
tags:
|
||||||
|
- StorageService
|
||||||
|
/api/v2/storages/{id}:
|
||||||
|
get:
|
||||||
|
summary: GetStorage returns a storage by id.
|
||||||
|
operationId: StorageService_GetStorage
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: A successful response.
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/v2GetStorageResponse'
|
||||||
|
default:
|
||||||
|
description: An unexpected error response.
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/googlerpcStatus'
|
||||||
|
parameters:
|
||||||
|
- name: id
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
tags:
|
||||||
|
- StorageService
|
||||||
|
delete:
|
||||||
|
summary: DeleteStorage deletes a storage by id.
|
||||||
|
operationId: StorageService_DeleteStorage
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: A successful response.
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/v2DeleteStorageResponse'
|
||||||
|
default:
|
||||||
|
description: An unexpected error response.
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/googlerpcStatus'
|
||||||
|
parameters:
|
||||||
|
- name: id
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
tags:
|
||||||
|
- StorageService
|
||||||
|
/api/v2/storages/{storage.id}:
|
||||||
|
patch:
|
||||||
|
summary: UpdateStorage updates a storage.
|
||||||
|
operationId: StorageService_UpdateStorage
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: A successful response.
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/v2UpdateStorageResponse'
|
||||||
|
default:
|
||||||
|
description: An unexpected error response.
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/googlerpcStatus'
|
||||||
|
parameters:
|
||||||
|
- name: storage.id
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
- name: storage
|
||||||
|
in: body
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
title:
|
||||||
|
type: string
|
||||||
|
type:
|
||||||
|
$ref: '#/definitions/apiv2StorageType'
|
||||||
|
config:
|
||||||
|
$ref: '#/definitions/apiv2StorageConfig'
|
||||||
|
tags:
|
||||||
|
- StorageService
|
||||||
/api/v2/tags:
|
/api/v2/tags:
|
||||||
get:
|
get:
|
||||||
summary: ListTags lists tags.
|
summary: ListTags lists tags.
|
||||||
@ -966,7 +1076,7 @@ paths:
|
|||||||
identifierFilter:
|
identifierFilter:
|
||||||
type: string
|
type: string
|
||||||
config:
|
config:
|
||||||
$ref: '#/definitions/IdentityProviderConfig'
|
$ref: '#/definitions/apiv2IdentityProviderConfig'
|
||||||
title: The identityProvider to update.
|
title: The identityProvider to update.
|
||||||
tags:
|
tags:
|
||||||
- IdentityProviderService
|
- IdentityProviderService
|
||||||
@ -1834,39 +1944,6 @@ paths:
|
|||||||
tags:
|
tags:
|
||||||
- ActivityService
|
- ActivityService
|
||||||
definitions:
|
definitions:
|
||||||
IdentityProviderConfig:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
oauth2:
|
|
||||||
$ref: '#/definitions/IdentityProviderConfigOAuth2'
|
|
||||||
IdentityProviderConfigFieldMapping:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
identifier:
|
|
||||||
type: string
|
|
||||||
displayName:
|
|
||||||
type: string
|
|
||||||
email:
|
|
||||||
type: string
|
|
||||||
IdentityProviderConfigOAuth2:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
clientId:
|
|
||||||
type: string
|
|
||||||
clientSecret:
|
|
||||||
type: string
|
|
||||||
authUrl:
|
|
||||||
type: string
|
|
||||||
tokenUrl:
|
|
||||||
type: string
|
|
||||||
userInfoUrl:
|
|
||||||
type: string
|
|
||||||
scopes:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
fieldMapping:
|
|
||||||
$ref: '#/definitions/IdentityProviderConfigFieldMapping'
|
|
||||||
MemoServiceSetMemoRelationsBody:
|
MemoServiceSetMemoRelationsBody:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@ -1920,6 +1997,39 @@ definitions:
|
|||||||
properties:
|
properties:
|
||||||
version:
|
version:
|
||||||
type: string
|
type: string
|
||||||
|
apiv2FieldMapping:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
identifier:
|
||||||
|
type: string
|
||||||
|
displayName:
|
||||||
|
type: string
|
||||||
|
email:
|
||||||
|
type: string
|
||||||
|
apiv2IdentityProviderConfig:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
oauth2:
|
||||||
|
$ref: '#/definitions/apiv2OAuth2Config'
|
||||||
|
apiv2OAuth2Config:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
clientId:
|
||||||
|
type: string
|
||||||
|
clientSecret:
|
||||||
|
type: string
|
||||||
|
authUrl:
|
||||||
|
type: string
|
||||||
|
tokenUrl:
|
||||||
|
type: string
|
||||||
|
userInfoUrl:
|
||||||
|
type: string
|
||||||
|
scopes:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
fieldMapping:
|
||||||
|
$ref: '#/definitions/apiv2FieldMapping'
|
||||||
apiv2Reaction:
|
apiv2Reaction:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@ -1959,6 +2069,50 @@ definitions:
|
|||||||
- ACTIVE
|
- ACTIVE
|
||||||
- ARCHIVED
|
- ARCHIVED
|
||||||
default: ROW_STATUS_UNSPECIFIED
|
default: ROW_STATUS_UNSPECIFIED
|
||||||
|
apiv2S3Config:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
endPoint:
|
||||||
|
type: string
|
||||||
|
path:
|
||||||
|
type: string
|
||||||
|
region:
|
||||||
|
type: string
|
||||||
|
accessKey:
|
||||||
|
type: string
|
||||||
|
secretKey:
|
||||||
|
type: string
|
||||||
|
bucket:
|
||||||
|
type: string
|
||||||
|
urlPrefix:
|
||||||
|
type: string
|
||||||
|
urlSuffix:
|
||||||
|
type: string
|
||||||
|
preSign:
|
||||||
|
type: boolean
|
||||||
|
apiv2Storage:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
title:
|
||||||
|
type: string
|
||||||
|
type:
|
||||||
|
$ref: '#/definitions/apiv2StorageType'
|
||||||
|
config:
|
||||||
|
$ref: '#/definitions/apiv2StorageConfig'
|
||||||
|
apiv2StorageConfig:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
s3Config:
|
||||||
|
$ref: '#/definitions/apiv2S3Config'
|
||||||
|
apiv2StorageType:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- TYPE_UNSPECIFIED
|
||||||
|
- S3
|
||||||
|
default: TYPE_UNSPECIFIED
|
||||||
apiv2UserSetting:
|
apiv2UserSetting:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@ -2163,6 +2317,16 @@ definitions:
|
|||||||
properties:
|
properties:
|
||||||
resource:
|
resource:
|
||||||
$ref: '#/definitions/v2Resource'
|
$ref: '#/definitions/v2Resource'
|
||||||
|
v2CreateStorageRequest:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
storage:
|
||||||
|
$ref: '#/definitions/apiv2Storage'
|
||||||
|
v2CreateStorageResponse:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
storage:
|
||||||
|
$ref: '#/definitions/apiv2Storage'
|
||||||
v2CreateUserAccessTokenResponse:
|
v2CreateUserAccessTokenResponse:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@ -2195,6 +2359,8 @@ definitions:
|
|||||||
type: object
|
type: object
|
||||||
v2DeleteResourceResponse:
|
v2DeleteResourceResponse:
|
||||||
type: object
|
type: object
|
||||||
|
v2DeleteStorageResponse:
|
||||||
|
type: object
|
||||||
v2DeleteTagResponse:
|
v2DeleteTagResponse:
|
||||||
type: object
|
type: object
|
||||||
v2DeleteUserAccessTokenResponse:
|
v2DeleteUserAccessTokenResponse:
|
||||||
@ -2240,6 +2406,11 @@ definitions:
|
|||||||
properties:
|
properties:
|
||||||
resource:
|
resource:
|
||||||
$ref: '#/definitions/v2Resource'
|
$ref: '#/definitions/v2Resource'
|
||||||
|
v2GetStorageResponse:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
storage:
|
||||||
|
$ref: '#/definitions/apiv2Storage'
|
||||||
v2GetTagSuggestionsResponse:
|
v2GetTagSuggestionsResponse:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@ -2298,7 +2469,7 @@ definitions:
|
|||||||
identifierFilter:
|
identifierFilter:
|
||||||
type: string
|
type: string
|
||||||
config:
|
config:
|
||||||
$ref: '#/definitions/IdentityProviderConfig'
|
$ref: '#/definitions/apiv2IdentityProviderConfig'
|
||||||
v2IdentityProviderType:
|
v2IdentityProviderType:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
@ -2421,6 +2592,14 @@ definitions:
|
|||||||
items:
|
items:
|
||||||
type: object
|
type: object
|
||||||
$ref: '#/definitions/v2Resource'
|
$ref: '#/definitions/v2Resource'
|
||||||
|
v2ListStoragesResponse:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
storages:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
$ref: '#/definitions/apiv2Storage'
|
||||||
v2ListTagsResponse:
|
v2ListTagsResponse:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@ -2658,6 +2837,11 @@ definitions:
|
|||||||
properties:
|
properties:
|
||||||
resource:
|
resource:
|
||||||
$ref: '#/definitions/v2Resource'
|
$ref: '#/definitions/v2Resource'
|
||||||
|
v2UpdateStorageResponse:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
storage:
|
||||||
|
$ref: '#/definitions/apiv2Storage'
|
||||||
v2UpdateUserResponse:
|
v2UpdateUserResponse:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
156
server/route/api/v2/storage_service.go
Normal file
156
server/route/api/v2/storage_service.go
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
package v2
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
|
|
||||||
|
apiv2pb "github.com/usememos/memos/proto/gen/api/v2"
|
||||||
|
storepb "github.com/usememos/memos/proto/gen/store"
|
||||||
|
"github.com/usememos/memos/store"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *APIV2Service) CreateStorage(ctx context.Context, request *apiv2pb.CreateStorageRequest) (*apiv2pb.CreateStorageResponse, error) {
|
||||||
|
currentUser, err := getCurrentUser(ctx, s.Store)
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to get user: %v", err)
|
||||||
|
}
|
||||||
|
if currentUser.Role != store.RoleHost {
|
||||||
|
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||||
|
}
|
||||||
|
|
||||||
|
storage, err := s.Store.CreateStorageV1(ctx, convertStorageToStore(request.Storage))
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to create storage, error: %+v", err)
|
||||||
|
}
|
||||||
|
return &apiv2pb.CreateStorageResponse{
|
||||||
|
Storage: convertStorageFromStore(storage),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *APIV2Service) ListStorages(ctx context.Context, _ *apiv2pb.ListStoragesRequest) (*apiv2pb.ListStoragesResponse, error) {
|
||||||
|
storages, err := s.Store.ListStoragesV1(ctx, &store.FindStorage{})
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to list storages, error: %+v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
response := &apiv2pb.ListStoragesResponse{
|
||||||
|
Storages: []*apiv2pb.Storage{},
|
||||||
|
}
|
||||||
|
for _, storage := range storages {
|
||||||
|
response.Storages = append(response.Storages, convertStorageFromStore(storage))
|
||||||
|
}
|
||||||
|
return response, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *APIV2Service) GetStorage(ctx context.Context, request *apiv2pb.GetStorageRequest) (*apiv2pb.GetStorageResponse, error) {
|
||||||
|
storage, err := s.Store.GetStorageV1(ctx, &store.FindStorage{
|
||||||
|
ID: &request.Id,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to get storage, error: %+v", err)
|
||||||
|
}
|
||||||
|
if storage == nil {
|
||||||
|
return nil, status.Errorf(codes.NotFound, "storage not found")
|
||||||
|
}
|
||||||
|
return &apiv2pb.GetStorageResponse{
|
||||||
|
Storage: convertStorageFromStore(storage),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *APIV2Service) UpdateStorage(ctx context.Context, request *apiv2pb.UpdateStorageRequest) (*apiv2pb.UpdateStorageResponse, error) {
|
||||||
|
if request.UpdateMask == nil || len(request.UpdateMask.Paths) == 0 {
|
||||||
|
return nil, status.Errorf(codes.InvalidArgument, "update_mask is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
update := &store.UpdateStorageV1{
|
||||||
|
ID: request.Storage.Id,
|
||||||
|
Type: storepb.Storage_Type(storepb.Storage_Type_value[request.Storage.Type.String()]),
|
||||||
|
}
|
||||||
|
for _, field := range request.UpdateMask.Paths {
|
||||||
|
switch field {
|
||||||
|
case "name":
|
||||||
|
update.Name = &request.Storage.Title
|
||||||
|
case "config":
|
||||||
|
update.Config = convertStorageConfigToStore(request.Storage.Type, request.Storage.Config)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
storage, err := s.Store.UpdateStorageV1(ctx, update)
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to update storage, error: %+v", err)
|
||||||
|
}
|
||||||
|
return &apiv2pb.UpdateStorageResponse{
|
||||||
|
Storage: convertStorageFromStore(storage),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *APIV2Service) DeleteStorage(ctx context.Context, request *apiv2pb.DeleteStorageRequest) (*apiv2pb.DeleteStorageResponse, error) {
|
||||||
|
err := s.Store.DeleteStorage(ctx, &store.DeleteStorage{
|
||||||
|
ID: request.Id,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to delete storage, error: %+v", err)
|
||||||
|
}
|
||||||
|
return &apiv2pb.DeleteStorageResponse{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func convertStorageFromStore(storage *storepb.Storage) *apiv2pb.Storage {
|
||||||
|
temp := &apiv2pb.Storage{
|
||||||
|
Id: storage.Id,
|
||||||
|
Title: storage.Name,
|
||||||
|
Type: apiv2pb.Storage_Type(apiv2pb.Storage_Type_value[storage.Type.String()]),
|
||||||
|
}
|
||||||
|
if storage.Type == storepb.Storage_S3 {
|
||||||
|
s3Config := storage.Config.GetS3Config()
|
||||||
|
temp.Config = &apiv2pb.StorageConfig{
|
||||||
|
StorageConfig: &apiv2pb.StorageConfig_S3Config{
|
||||||
|
S3Config: &apiv2pb.S3Config{
|
||||||
|
EndPoint: s3Config.EndPoint,
|
||||||
|
Path: s3Config.Path,
|
||||||
|
Region: s3Config.Region,
|
||||||
|
AccessKey: s3Config.AccessKey,
|
||||||
|
SecretKey: s3Config.SecretKey,
|
||||||
|
Bucket: s3Config.Bucket,
|
||||||
|
UrlPrefix: s3Config.UrlPrefix,
|
||||||
|
UrlSuffix: s3Config.UrlSuffix,
|
||||||
|
PreSign: s3Config.PreSign,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return temp
|
||||||
|
}
|
||||||
|
|
||||||
|
func convertStorageToStore(storage *apiv2pb.Storage) *storepb.Storage {
|
||||||
|
temp := &storepb.Storage{
|
||||||
|
Id: storage.Id,
|
||||||
|
Name: storage.Title,
|
||||||
|
Type: storepb.Storage_Type(storepb.Storage_Type_value[storage.Type.String()]),
|
||||||
|
Config: convertStorageConfigToStore(storage.Type, storage.Config),
|
||||||
|
}
|
||||||
|
return temp
|
||||||
|
}
|
||||||
|
|
||||||
|
func convertStorageConfigToStore(storageType apiv2pb.Storage_Type, config *apiv2pb.StorageConfig) *storepb.StorageConfig {
|
||||||
|
if storageType == apiv2pb.Storage_S3 {
|
||||||
|
s3Config := config.GetS3Config()
|
||||||
|
return &storepb.StorageConfig{
|
||||||
|
StorageConfig: &storepb.StorageConfig_S3Config{
|
||||||
|
S3Config: &storepb.S3Config{
|
||||||
|
EndPoint: s3Config.EndPoint,
|
||||||
|
Path: s3Config.Path,
|
||||||
|
Region: s3Config.Region,
|
||||||
|
AccessKey: s3Config.AccessKey,
|
||||||
|
SecretKey: s3Config.SecretKey,
|
||||||
|
Bucket: s3Config.Bucket,
|
||||||
|
UrlPrefix: s3Config.UrlPrefix,
|
||||||
|
UrlSuffix: s3Config.UrlSuffix,
|
||||||
|
PreSign: s3Config.PreSign,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
@ -31,6 +31,7 @@ type APIV2Service struct {
|
|||||||
apiv2pb.UnimplementedActivityServiceServer
|
apiv2pb.UnimplementedActivityServiceServer
|
||||||
apiv2pb.UnimplementedWebhookServiceServer
|
apiv2pb.UnimplementedWebhookServiceServer
|
||||||
apiv2pb.UnimplementedLinkServiceServer
|
apiv2pb.UnimplementedLinkServiceServer
|
||||||
|
apiv2pb.UnimplementedStorageServiceServer
|
||||||
|
|
||||||
Secret string
|
Secret string
|
||||||
Profile *profile.Profile
|
Profile *profile.Profile
|
||||||
@ -68,6 +69,7 @@ func NewAPIV2Service(secret string, profile *profile.Profile, store *store.Store
|
|||||||
apiv2pb.RegisterActivityServiceServer(grpcServer, apiv2Service)
|
apiv2pb.RegisterActivityServiceServer(grpcServer, apiv2Service)
|
||||||
apiv2pb.RegisterWebhookServiceServer(grpcServer, apiv2Service)
|
apiv2pb.RegisterWebhookServiceServer(grpcServer, apiv2Service)
|
||||||
apiv2pb.RegisterLinkServiceServer(grpcServer, apiv2Service)
|
apiv2pb.RegisterLinkServiceServer(grpcServer, apiv2Service)
|
||||||
|
apiv2pb.RegisterStorageServiceServer(grpcServer, apiv2Service)
|
||||||
reflection.Register(grpcServer)
|
reflection.Register(grpcServer)
|
||||||
|
|
||||||
return apiv2Service
|
return apiv2Service
|
||||||
@ -124,6 +126,9 @@ func (s *APIV2Service) RegisterGateway(ctx context.Context, e *echo.Echo) error
|
|||||||
if err := apiv2pb.RegisterLinkServiceHandler(context.Background(), gwMux, conn); err != nil {
|
if err := apiv2pb.RegisterLinkServiceHandler(context.Background(), gwMux, conn); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := apiv2pb.RegisterStorageServiceHandler(context.Background(), gwMux, conn); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
e.Any("/api/v2/*", echo.WrapHandler(gwMux))
|
e.Any("/api/v2/*", echo.WrapHandler(gwMux))
|
||||||
|
|
||||||
// GRPC web proxy.
|
// GRPC web proxy.
|
||||||
|
@ -55,7 +55,7 @@ func (s *APIV2Service) GetWebhook(ctx context.Context, request *apiv2pb.GetWebho
|
|||||||
return nil, status.Errorf(codes.Internal, "failed to get user: %v", err)
|
return nil, status.Errorf(codes.Internal, "failed to get user: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
webhook, err := s.Store.GetWebhooks(ctx, &store.FindWebhook{
|
webhook, err := s.Store.GetWebhook(ctx, &store.FindWebhook{
|
||||||
ID: &request.Id,
|
ID: &request.Id,
|
||||||
CreatorID: ¤tUser.ID,
|
CreatorID: ¤tUser.ID,
|
||||||
})
|
})
|
||||||
|
@ -162,7 +162,7 @@ func convertStorageConfigFromRaw(storageType storepb.Storage_Type, configRaw str
|
|||||||
storageConfig := &storepb.StorageConfig{}
|
storageConfig := &storepb.StorageConfig{}
|
||||||
if storageType == storepb.Storage_S3 {
|
if storageType == storepb.Storage_S3 {
|
||||||
s3Config := &storepb.S3Config{}
|
s3Config := &storepb.S3Config{}
|
||||||
err := proto.Unmarshal([]byte(configRaw), s3Config)
|
err := protojsonUnmarshaler.Unmarshal([]byte(configRaw), s3Config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ func (s *Store) ListWebhooks(ctx context.Context, find *FindWebhook) ([]*storepb
|
|||||||
return s.driver.ListWebhooks(ctx, find)
|
return s.driver.ListWebhooks(ctx, find)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Store) GetWebhooks(ctx context.Context, find *FindWebhook) (*storepb.Webhook, error) {
|
func (s *Store) GetWebhook(ctx context.Context, find *FindWebhook) (*storepb.Webhook, error) {
|
||||||
list, err := s.ListWebhooks(ctx, find)
|
list, err := s.ListWebhooks(ctx, find)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { Button, IconButton, Input, Checkbox, Typography } from "@mui/joy";
|
import { Button, IconButton, Input, Checkbox, Typography } from "@mui/joy";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { toast } from "react-hot-toast";
|
import { toast } from "react-hot-toast";
|
||||||
import * as api from "@/helpers/api";
|
import { storageServiceClient } from "@/grpcweb";
|
||||||
|
import { S3Config, Storage, Storage_Type } from "@/types/proto/api/v2/storage_service";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
import { generateDialog } from "./Dialog";
|
import { generateDialog } from "./Dialog";
|
||||||
import Icon from "./Icon";
|
import Icon from "./Icon";
|
||||||
@ -9,7 +10,7 @@ import LearnMore from "./LearnMore";
|
|||||||
import RequiredBadge from "./RequiredBadge";
|
import RequiredBadge from "./RequiredBadge";
|
||||||
|
|
||||||
interface Props extends DialogProps {
|
interface Props extends DialogProps {
|
||||||
storage?: ObjectStorage;
|
storage?: Storage;
|
||||||
confirmCallback?: () => void;
|
confirmCallback?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,10 +18,10 @@ const CreateStorageServiceDialog: React.FC<Props> = (props: Props) => {
|
|||||||
const t = useTranslate();
|
const t = useTranslate();
|
||||||
const { destroy, storage, confirmCallback } = props;
|
const { destroy, storage, confirmCallback } = props;
|
||||||
const [basicInfo, setBasicInfo] = useState({
|
const [basicInfo, setBasicInfo] = useState({
|
||||||
name: "",
|
title: "",
|
||||||
});
|
});
|
||||||
const [type, setType] = useState<StorageType>("S3");
|
const [type] = useState<Storage_Type>(Storage_Type.S3);
|
||||||
const [s3Config, setS3Config] = useState<StorageS3Config>({
|
const [s3Config, setS3Config] = useState<S3Config>({
|
||||||
endPoint: "",
|
endPoint: "",
|
||||||
region: "",
|
region: "",
|
||||||
accessKey: "",
|
accessKey: "",
|
||||||
@ -29,18 +30,17 @@ const CreateStorageServiceDialog: React.FC<Props> = (props: Props) => {
|
|||||||
bucket: "",
|
bucket: "",
|
||||||
urlPrefix: "",
|
urlPrefix: "",
|
||||||
urlSuffix: "",
|
urlSuffix: "",
|
||||||
presign: false,
|
preSign: false,
|
||||||
});
|
});
|
||||||
const isCreating = storage === undefined;
|
const isCreating = storage === undefined;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (storage) {
|
if (storage) {
|
||||||
setBasicInfo({
|
setBasicInfo({
|
||||||
name: storage.name,
|
title: storage.title,
|
||||||
});
|
});
|
||||||
setType(storage.type);
|
|
||||||
if (storage.type === "S3") {
|
if (storage.type === "S3") {
|
||||||
setS3Config(storage.config.s3Config);
|
setS3Config(S3Config.fromPartial(storage.config?.s3Config || {}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
@ -50,7 +50,7 @@ const CreateStorageServiceDialog: React.FC<Props> = (props: Props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const allowConfirmAction = () => {
|
const allowConfirmAction = () => {
|
||||||
if (basicInfo.name === "") {
|
if (basicInfo.title === "") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (type === "S3") {
|
if (type === "S3") {
|
||||||
@ -70,21 +70,25 @@ const CreateStorageServiceDialog: React.FC<Props> = (props: Props) => {
|
|||||||
const handleConfirmBtnClick = async () => {
|
const handleConfirmBtnClick = async () => {
|
||||||
try {
|
try {
|
||||||
if (isCreating) {
|
if (isCreating) {
|
||||||
await api.createStorage({
|
await storageServiceClient.createStorage({
|
||||||
...basicInfo,
|
storage: Storage.fromPartial({
|
||||||
|
title: basicInfo.title,
|
||||||
type: type,
|
type: type,
|
||||||
config: {
|
config: {
|
||||||
s3Config: s3Config,
|
s3Config: s3Config,
|
||||||
},
|
},
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await api.patchStorage({
|
await storageServiceClient.updateStorage({
|
||||||
id: storage.id,
|
storage: Storage.fromPartial({
|
||||||
|
title: basicInfo.title,
|
||||||
type: type,
|
type: type,
|
||||||
...basicInfo,
|
|
||||||
config: {
|
config: {
|
||||||
s3Config: s3Config,
|
s3Config: s3Config,
|
||||||
},
|
},
|
||||||
|
}),
|
||||||
|
updateMask: ["title", "config"],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
@ -97,7 +101,7 @@ const CreateStorageServiceDialog: React.FC<Props> = (props: Props) => {
|
|||||||
destroy();
|
destroy();
|
||||||
};
|
};
|
||||||
|
|
||||||
const setPartialS3Config = (state: Partial<StorageS3Config>) => {
|
const setPartialS3Config = (state: Partial<S3Config>) => {
|
||||||
setS3Config({
|
setS3Config({
|
||||||
...s3Config,
|
...s3Config,
|
||||||
...state,
|
...state,
|
||||||
@ -120,11 +124,11 @@ const CreateStorageServiceDialog: React.FC<Props> = (props: Props) => {
|
|||||||
<Input
|
<Input
|
||||||
className="mb-2"
|
className="mb-2"
|
||||||
placeholder={t("common.name")}
|
placeholder={t("common.name")}
|
||||||
value={basicInfo.name}
|
value={basicInfo.title}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
setBasicInfo({
|
setBasicInfo({
|
||||||
...basicInfo,
|
...basicInfo,
|
||||||
name: e.target.value,
|
title: e.target.value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
fullWidth
|
fullWidth
|
||||||
@ -222,8 +226,8 @@ const CreateStorageServiceDialog: React.FC<Props> = (props: Props) => {
|
|||||||
<Checkbox
|
<Checkbox
|
||||||
className="mb-2"
|
className="mb-2"
|
||||||
label={t("setting.storage-section.presign-placeholder")}
|
label={t("setting.storage-section.presign-placeholder")}
|
||||||
checked={s3Config.presign}
|
checked={s3Config.preSign}
|
||||||
onChange={(e) => setPartialS3Config({ presign: e.target.checked })}
|
onChange={(e) => setPartialS3Config({ preSign: e.target.checked })}
|
||||||
/>
|
/>
|
||||||
<div className="mt-2 w-full flex flex-row justify-end items-center space-x-1">
|
<div className="mt-2 w-full flex flex-row justify-end items-center space-x-1">
|
||||||
<Button variant="plain" color="neutral" onClick={handleCloseBtnClick}>
|
<Button variant="plain" color="neutral" onClick={handleCloseBtnClick}>
|
||||||
@ -238,7 +242,7 @@ const CreateStorageServiceDialog: React.FC<Props> = (props: Props) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
function showCreateStorageServiceDialog(storage?: ObjectStorage, confirmCallback?: () => void) {
|
function showCreateStorageServiceDialog(storage?: Storage, confirmCallback?: () => void) {
|
||||||
generateDialog(
|
generateDialog(
|
||||||
{
|
{
|
||||||
className: "create-storage-service-dialog",
|
className: "create-storage-service-dialog",
|
||||||
|
@ -18,8 +18,9 @@ import { isEqual } from "lodash-es";
|
|||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
import { toast } from "react-hot-toast";
|
import { toast } from "react-hot-toast";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import * as api from "@/helpers/api";
|
import { storageServiceClient } from "@/grpcweb";
|
||||||
import { WorkspaceSettingPrefix, useWorkspaceSettingStore } from "@/store/v1";
|
import { WorkspaceSettingPrefix, useWorkspaceSettingStore } from "@/store/v1";
|
||||||
|
import { Storage } from "@/types/proto/api/v2/storage_service";
|
||||||
import { WorkspaceStorageSetting, WorkspaceStorageSetting_StorageType } from "@/types/proto/api/v2/workspace_setting_service";
|
import { WorkspaceStorageSetting, WorkspaceStorageSetting_StorageType } from "@/types/proto/api/v2/workspace_setting_service";
|
||||||
import { WorkspaceSettingKey } from "@/types/proto/store/workspace_setting";
|
import { WorkspaceSettingKey } from "@/types/proto/store/workspace_setting";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
@ -31,7 +32,7 @@ import LearnMore from "../LearnMore";
|
|||||||
const StorageSection = () => {
|
const StorageSection = () => {
|
||||||
const t = useTranslate();
|
const t = useTranslate();
|
||||||
const workspaceSettingStore = useWorkspaceSettingStore();
|
const workspaceSettingStore = useWorkspaceSettingStore();
|
||||||
const [storageList, setStorageList] = useState<ObjectStorage[]>([]);
|
const [storageList, setStorageList] = useState<Storage[]>([]);
|
||||||
const [workspaceStorageSetting, setWorkspaceStorageSetting] = useState<WorkspaceStorageSetting>(
|
const [workspaceStorageSetting, setWorkspaceStorageSetting] = useState<WorkspaceStorageSetting>(
|
||||||
WorkspaceStorageSetting.fromPartial(
|
WorkspaceStorageSetting.fromPartial(
|
||||||
workspaceSettingStore.getWorkspaceSettingByKey(WorkspaceSettingKey.WORKSPACE_SETTING_STORAGE)?.storageSetting || {},
|
workspaceSettingStore.getWorkspaceSettingByKey(WorkspaceSettingKey.WORKSPACE_SETTING_STORAGE)?.storageSetting || {},
|
||||||
@ -63,8 +64,8 @@ const StorageSection = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const fetchStorageList = async () => {
|
const fetchStorageList = async () => {
|
||||||
const { data: storageList } = await api.getStorageList();
|
const { storages } = await storageServiceClient.listStorages({});
|
||||||
setStorageList(storageList);
|
setStorageList(storages);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMaxUploadSizeChanged = async (event: React.FocusEvent<HTMLInputElement>) => {
|
const handleMaxUploadSizeChanged = async (event: React.FocusEvent<HTMLInputElement>) => {
|
||||||
@ -111,15 +112,15 @@ const StorageSection = () => {
|
|||||||
toast.success("Updated");
|
toast.success("Updated");
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteStorage = (storage: ObjectStorage) => {
|
const handleDeleteStorage = (storage: Storage) => {
|
||||||
showCommonDialog({
|
showCommonDialog({
|
||||||
title: t("setting.storage-section.delete-storage"),
|
title: t("setting.storage-section.delete-storage"),
|
||||||
content: t("setting.storage-section.warning-text", { name: storage.name }),
|
content: t("setting.storage-section.warning-text", { name: storage.title }),
|
||||||
style: "danger",
|
style: "danger",
|
||||||
dialogName: "delete-storage-dialog",
|
dialogName: "delete-storage-dialog",
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
try {
|
try {
|
||||||
await api.deleteStorage(storage.id);
|
await storageServiceClient.deleteStorage({ id: storage.id });
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
toast.error(error.response.data.message);
|
toast.error(error.response.data.message);
|
||||||
@ -179,7 +180,7 @@ const StorageSection = () => {
|
|||||||
>
|
>
|
||||||
{storageList.map((storage) => (
|
{storageList.map((storage) => (
|
||||||
<Option key={storage.id} value={storage.id}>
|
<Option key={storage.id} value={storage.id}>
|
||||||
{storage.name}
|
{storage.title}
|
||||||
</Option>
|
</Option>
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
@ -205,7 +206,7 @@ const StorageSection = () => {
|
|||||||
className="py-2 w-full border-t last:border-b dark:border-zinc-700 flex flex-row items-center justify-between"
|
className="py-2 w-full border-t last:border-b dark:border-zinc-700 flex flex-row items-center justify-between"
|
||||||
>
|
>
|
||||||
<div className="flex flex-row items-center">
|
<div className="flex flex-row items-center">
|
||||||
<p className="ml-2">{storage.name}</p>
|
<p className="ml-2">{storage.title}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-row items-center">
|
<div className="flex flex-row items-center">
|
||||||
<Dropdown>
|
<Dropdown>
|
||||||
|
@ -5,6 +5,7 @@ import { InboxServiceDefinition } from "./types/proto/api/v2/inbox_service";
|
|||||||
import { LinkServiceDefinition } from "./types/proto/api/v2/link_service";
|
import { LinkServiceDefinition } from "./types/proto/api/v2/link_service";
|
||||||
import { MemoServiceDefinition } from "./types/proto/api/v2/memo_service";
|
import { MemoServiceDefinition } from "./types/proto/api/v2/memo_service";
|
||||||
import { ResourceServiceDefinition } from "./types/proto/api/v2/resource_service";
|
import { ResourceServiceDefinition } from "./types/proto/api/v2/resource_service";
|
||||||
|
import { StorageServiceDefinition } from "./types/proto/api/v2/storage_service";
|
||||||
import { TagServiceDefinition } from "./types/proto/api/v2/tag_service";
|
import { TagServiceDefinition } from "./types/proto/api/v2/tag_service";
|
||||||
import { UserServiceDefinition } from "./types/proto/api/v2/user_service";
|
import { UserServiceDefinition } from "./types/proto/api/v2/user_service";
|
||||||
import { WebhookServiceDefinition } from "./types/proto/api/v2/webhook_service";
|
import { WebhookServiceDefinition } from "./types/proto/api/v2/webhook_service";
|
||||||
@ -41,3 +42,5 @@ export const activityServiceClient = clientFactory.create(ActivityServiceDefinit
|
|||||||
export const webhookServiceClient = clientFactory.create(WebhookServiceDefinition, channel);
|
export const webhookServiceClient = clientFactory.create(WebhookServiceDefinition, channel);
|
||||||
|
|
||||||
export const linkServiceClient = clientFactory.create(LinkServiceDefinition, channel);
|
export const linkServiceClient = clientFactory.create(LinkServiceDefinition, channel);
|
||||||
|
|
||||||
|
export const storageServiceClient = clientFactory.create(StorageServiceDefinition, channel);
|
||||||
|
@ -3,22 +3,6 @@ import axios from "axios";
|
|||||||
axios.defaults.baseURL = import.meta.env.VITE_API_BASE_URL || "";
|
axios.defaults.baseURL = import.meta.env.VITE_API_BASE_URL || "";
|
||||||
axios.defaults.withCredentials = true;
|
axios.defaults.withCredentials = true;
|
||||||
|
|
||||||
export function getStorageList() {
|
|
||||||
return axios.get<ObjectStorage[]>(`/api/v1/storage`);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createStorage(storageCreate: StorageCreate) {
|
|
||||||
return axios.post<ObjectStorage>(`/api/v1/storage`, storageCreate);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function patchStorage(storagePatch: StoragePatch) {
|
|
||||||
return axios.patch<ObjectStorage>(`/api/v1/storage/${storagePatch.id}`, storagePatch);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function deleteStorage(storageId: StorageId) {
|
|
||||||
return axios.delete(`/api/v1/storage/${storageId}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getIdentityProviderList() {
|
export function getIdentityProviderList() {
|
||||||
return axios.get<IdentityProvider[]>(`/api/v1/idp`);
|
return axios.get<IdentityProvider[]>(`/api/v1/idp`);
|
||||||
}
|
}
|
||||||
|
40
web/src/types/modules/storage.d.ts
vendored
40
web/src/types/modules/storage.d.ts
vendored
@ -1,40 +0,0 @@
|
|||||||
type StorageId = number;
|
|
||||||
|
|
||||||
type StorageType = "S3";
|
|
||||||
|
|
||||||
interface StorageS3Config {
|
|
||||||
endPoint: string;
|
|
||||||
region: string;
|
|
||||||
accessKey: string;
|
|
||||||
secretKey: string;
|
|
||||||
path: string;
|
|
||||||
bucket: string;
|
|
||||||
urlPrefix: string;
|
|
||||||
urlSuffix: string;
|
|
||||||
presign: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface StorageConfig {
|
|
||||||
s3Config: StorageS3Config;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: Storage is a reserved word in TypeScript. So we use ObjectStorage instead.
|
|
||||||
interface ObjectStorage {
|
|
||||||
id: StorageId;
|
|
||||||
name: string;
|
|
||||||
type: StorageType;
|
|
||||||
config: StorageConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface StorageCreate {
|
|
||||||
name: string;
|
|
||||||
type: StorageType;
|
|
||||||
config: StorageConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface StoragePatch {
|
|
||||||
id: StorageId;
|
|
||||||
name: string;
|
|
||||||
type: StorageType;
|
|
||||||
config: StorageConfig;
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user