mirror of
https://github.com/usememos/memos.git
synced 2024-12-18 16:41:44 +03:00
choer: add system setting api (#2194)
This commit is contained in:
parent
9987337eca
commit
8b1f7c52aa
@ -3,6 +3,7 @@ package v2
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
apiv2pb "github.com/usememos/memos/proto/gen/api/v2"
|
||||
"github.com/usememos/memos/server/profile"
|
||||
@ -53,3 +54,64 @@ func (s *SystemService) GetSystemInfo(ctx context.Context, _ *apiv2pb.GetSystemI
|
||||
}
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (s *SystemService) UpdateSystemInfo(ctx context.Context, request *apiv2pb.UpdateSystemInfoRequest) (*apiv2pb.UpdateSystemInfoResponse, error) {
|
||||
userID := ctx.Value(UserIDContextKey).(int32)
|
||||
user, err := s.Store.GetUser(ctx, &store.FindUser{
|
||||
ID: &userID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to get user: %v", err)
|
||||
}
|
||||
if user.Role != store.RoleHost {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
if request.UpdateMask == nil || len(request.UpdateMask) == 0 {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "update mask is required")
|
||||
}
|
||||
|
||||
// Update system settings.
|
||||
for _, path := range request.UpdateMask {
|
||||
if path == "allow_registration" {
|
||||
_, err := s.Store.UpsertSystemSetting(ctx, &store.SystemSetting{
|
||||
Name: "allow-signup",
|
||||
Value: strconv.FormatBool(request.SystemInfo.AllowRegistration),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to update allow_registration system setting: %v", err)
|
||||
}
|
||||
} else if path == "disable_password_login" {
|
||||
_, err := s.Store.UpsertSystemSetting(ctx, &store.SystemSetting{
|
||||
Name: "disable-password-login",
|
||||
Value: strconv.FormatBool(request.SystemInfo.DisablePasswordLogin),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to update disable_password_login system setting: %v", err)
|
||||
}
|
||||
} else if path == "additional_script" {
|
||||
_, err := s.Store.UpsertSystemSetting(ctx, &store.SystemSetting{
|
||||
Name: "additional-script",
|
||||
Value: request.SystemInfo.AdditionalScript,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to update additional_script system setting: %v", err)
|
||||
}
|
||||
} else if path == "additional_style" {
|
||||
_, err := s.Store.UpsertSystemSetting(ctx, &store.SystemSetting{
|
||||
Name: "additional-style",
|
||||
Value: request.SystemInfo.AdditionalStyle,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to update additional_style system setting: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
systemInfo, err := s.GetSystemInfo(ctx, &apiv2pb.GetSystemInfoRequest{})
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to get system info: %v", err)
|
||||
}
|
||||
return &apiv2pb.UpdateSystemInfoResponse{
|
||||
SystemInfo: systemInfo.SystemInfo,
|
||||
}, nil
|
||||
}
|
||||
|
@ -10,6 +10,9 @@ service SystemService {
|
||||
rpc GetSystemInfo(GetSystemInfoRequest) returns (GetSystemInfoResponse) {
|
||||
option (google.api.http) = {get: "/api/v2/system/info"};
|
||||
}
|
||||
rpc UpdateSystemInfo(UpdateSystemInfoRequest) returns (UpdateSystemInfoResponse) {
|
||||
option (google.api.http) = {post: "/api/v2/system/info"};
|
||||
}
|
||||
}
|
||||
|
||||
message SystemInfo {
|
||||
@ -27,3 +30,14 @@ message GetSystemInfoRequest {}
|
||||
message GetSystemInfoResponse {
|
||||
SystemInfo system_info = 1;
|
||||
}
|
||||
|
||||
message UpdateSystemInfoRequest {
|
||||
// System info is the updated data.
|
||||
SystemInfo system_info = 1;
|
||||
// Update mask is the array of paths.
|
||||
repeated string update_mask = 2;
|
||||
}
|
||||
|
||||
message UpdateSystemInfoResponse {
|
||||
SystemInfo system_info = 1;
|
||||
}
|
||||
|
@ -21,6 +21,8 @@
|
||||
- [GetSystemInfoRequest](#memos-api-v2-GetSystemInfoRequest)
|
||||
- [GetSystemInfoResponse](#memos-api-v2-GetSystemInfoResponse)
|
||||
- [SystemInfo](#memos-api-v2-SystemInfo)
|
||||
- [UpdateSystemInfoRequest](#memos-api-v2-UpdateSystemInfoRequest)
|
||||
- [UpdateSystemInfoResponse](#memos-api-v2-UpdateSystemInfoResponse)
|
||||
|
||||
- [SystemService](#memos-api-v2-SystemService)
|
||||
|
||||
@ -255,6 +257,37 @@
|
||||
|
||||
|
||||
|
||||
<a name="memos-api-v2-UpdateSystemInfoRequest"></a>
|
||||
|
||||
### UpdateSystemInfoRequest
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| system_info | [SystemInfo](#memos-api-v2-SystemInfo) | | System info is the updated data. |
|
||||
| update_mask | [string](#string) | repeated | Update mask is the array of paths. |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="memos-api-v2-UpdateSystemInfoResponse"></a>
|
||||
|
||||
### UpdateSystemInfoResponse
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| system_info | [SystemInfo](#memos-api-v2-SystemInfo) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -269,6 +302,7 @@
|
||||
| Method Name | Request Type | Response Type | Description |
|
||||
| ----------- | ------------ | ------------- | ------------|
|
||||
| GetSystemInfo | [GetSystemInfoRequest](#memos-api-v2-GetSystemInfoRequest) | [GetSystemInfoResponse](#memos-api-v2-GetSystemInfoResponse) | |
|
||||
| UpdateSystemInfo | [UpdateSystemInfoRequest](#memos-api-v2-UpdateSystemInfoRequest) | [UpdateSystemInfoResponse](#memos-api-v2-UpdateSystemInfoResponse) | |
|
||||
|
||||
|
||||
|
||||
|
@ -201,6 +201,110 @@ func (x *GetSystemInfoResponse) GetSystemInfo() *SystemInfo {
|
||||
return nil
|
||||
}
|
||||
|
||||
type UpdateSystemInfoRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// System info is the updated data.
|
||||
SystemInfo *SystemInfo `protobuf:"bytes,1,opt,name=system_info,json=systemInfo,proto3" json:"system_info,omitempty"`
|
||||
// Update mask is the array of paths.
|
||||
UpdateMask []string `protobuf:"bytes,2,rep,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"`
|
||||
}
|
||||
|
||||
func (x *UpdateSystemInfoRequest) Reset() {
|
||||
*x = UpdateSystemInfoRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_api_v2_system_service_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *UpdateSystemInfoRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UpdateSystemInfoRequest) ProtoMessage() {}
|
||||
|
||||
func (x *UpdateSystemInfoRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v2_system_service_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UpdateSystemInfoRequest.ProtoReflect.Descriptor instead.
|
||||
func (*UpdateSystemInfoRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v2_system_service_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *UpdateSystemInfoRequest) GetSystemInfo() *SystemInfo {
|
||||
if x != nil {
|
||||
return x.SystemInfo
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *UpdateSystemInfoRequest) GetUpdateMask() []string {
|
||||
if x != nil {
|
||||
return x.UpdateMask
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type UpdateSystemInfoResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
SystemInfo *SystemInfo `protobuf:"bytes,1,opt,name=system_info,json=systemInfo,proto3" json:"system_info,omitempty"`
|
||||
}
|
||||
|
||||
func (x *UpdateSystemInfoResponse) Reset() {
|
||||
*x = UpdateSystemInfoResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_api_v2_system_service_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *UpdateSystemInfoResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UpdateSystemInfoResponse) ProtoMessage() {}
|
||||
|
||||
func (x *UpdateSystemInfoResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v2_system_service_proto_msgTypes[4]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UpdateSystemInfoResponse.ProtoReflect.Descriptor instead.
|
||||
func (*UpdateSystemInfoResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_v2_system_service_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *UpdateSystemInfoResponse) GetSystemInfo() *SystemInfo {
|
||||
if x != nil {
|
||||
return x.SystemInfo
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_api_v2_system_service_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_api_v2_system_service_proto_rawDesc = []byte{
|
||||
@ -232,27 +336,48 @@ var file_api_v2_system_service_proto_rawDesc = []byte{
|
||||
0x0b, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76,
|
||||
0x32, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0a, 0x73, 0x79,
|
||||
0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x32, 0x86, 0x01, 0x0a, 0x0d, 0x53, 0x79, 0x73,
|
||||
0x74, 0x65, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x75, 0x0a, 0x0d, 0x47, 0x65,
|
||||
0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x22, 0x2e, 0x6d, 0x65,
|
||||
0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x79,
|
||||
0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
|
||||
0x23, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x47,
|
||||
0x65, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70,
|
||||
0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x12, 0x13, 0x2f, 0x61,
|
||||
0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x69, 0x6e, 0x66,
|
||||
0x6f, 0x42, 0xaa, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e,
|
||||
0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x42, 0x12, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x53, 0x65,
|
||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69,
|
||||
0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x73, 0x65, 0x6d, 0x65, 0x6d, 0x6f,
|
||||
0x73, 0x2f, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65,
|
||||
0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x3b, 0x61, 0x70, 0x69, 0x76, 0x32, 0xa2, 0x02,
|
||||
0x03, 0x4d, 0x41, 0x58, 0xaa, 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x70, 0x69,
|
||||
0x2e, 0x56, 0x32, 0xca, 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c,
|
||||
0x56, 0x32, 0xe2, 0x02, 0x18, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56,
|
||||
0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0e,
|
||||
0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x75, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61,
|
||||
0x74, 0x65, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x12, 0x39, 0x0a, 0x0b, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5f, 0x69, 0x6e,
|
||||
0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73,
|
||||
0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e,
|
||||
0x66, 0x6f, 0x52, 0x0a, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1f,
|
||||
0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x02, 0x20,
|
||||
0x03, 0x28, 0x09, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x6b, 0x22,
|
||||
0x55, 0x0a, 0x18, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49,
|
||||
0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x39, 0x0a, 0x0b, 0x73,
|
||||
0x79, 0x73, 0x74, 0x65, 0x6d, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b,
|
||||
0x32, 0x18, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e,
|
||||
0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0a, 0x73, 0x79, 0x73, 0x74,
|
||||
0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x32, 0x86, 0x02, 0x0a, 0x0d, 0x53, 0x79, 0x73, 0x74, 0x65,
|
||||
0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x75, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x53,
|
||||
0x79, 0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x22, 0x2e, 0x6d, 0x65, 0x6d, 0x6f,
|
||||
0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x79, 0x73, 0x74,
|
||||
0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e,
|
||||
0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74,
|
||||
0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
|
||||
0x73, 0x65, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x12, 0x13, 0x2f, 0x61, 0x70, 0x69,
|
||||
0x2f, 0x76, 0x32, 0x2f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x69, 0x6e, 0x66, 0x6f, 0x12,
|
||||
0x7e, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49,
|
||||
0x6e, 0x66, 0x6f, 0x12, 0x25, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e,
|
||||
0x76, 0x32, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49,
|
||||
0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x6d, 0x65, 0x6d,
|
||||
0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
|
||||
0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
|
||||
0x73, 0x65, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x22, 0x13, 0x2f, 0x61, 0x70, 0x69,
|
||||
0x2f, 0x76, 0x32, 0x2f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x69, 0x6e, 0x66, 0x6f, 0x42,
|
||||
0xaa, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70,
|
||||
0x69, 0x2e, 0x76, 0x32, 0x42, 0x12, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x53, 0x65, 0x72, 0x76,
|
||||
0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68,
|
||||
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x73, 0x65, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f,
|
||||
0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f,
|
||||
0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x3b, 0x61, 0x70, 0x69, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x4d,
|
||||
0x41, 0x58, 0xaa, 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x70, 0x69, 0x2e, 0x56,
|
||||
0x32, 0xca, 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x32,
|
||||
0xe2, 0x02, 0x18, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x32, 0x5c,
|
||||
0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0e, 0x4d, 0x65,
|
||||
0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@ -267,21 +392,27 @@ func file_api_v2_system_service_proto_rawDescGZIP() []byte {
|
||||
return file_api_v2_system_service_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_api_v2_system_service_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_api_v2_system_service_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||
var file_api_v2_system_service_proto_goTypes = []interface{}{
|
||||
(*SystemInfo)(nil), // 0: memos.api.v2.SystemInfo
|
||||
(*GetSystemInfoRequest)(nil), // 1: memos.api.v2.GetSystemInfoRequest
|
||||
(*GetSystemInfoResponse)(nil), // 2: memos.api.v2.GetSystemInfoResponse
|
||||
(*UpdateSystemInfoRequest)(nil), // 3: memos.api.v2.UpdateSystemInfoRequest
|
||||
(*UpdateSystemInfoResponse)(nil), // 4: memos.api.v2.UpdateSystemInfoResponse
|
||||
}
|
||||
var file_api_v2_system_service_proto_depIdxs = []int32{
|
||||
0, // 0: memos.api.v2.GetSystemInfoResponse.system_info:type_name -> memos.api.v2.SystemInfo
|
||||
1, // 1: memos.api.v2.SystemService.GetSystemInfo:input_type -> memos.api.v2.GetSystemInfoRequest
|
||||
2, // 2: memos.api.v2.SystemService.GetSystemInfo:output_type -> memos.api.v2.GetSystemInfoResponse
|
||||
2, // [2:3] is the sub-list for method output_type
|
||||
1, // [1:2] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
0, // 1: memos.api.v2.UpdateSystemInfoRequest.system_info:type_name -> memos.api.v2.SystemInfo
|
||||
0, // 2: memos.api.v2.UpdateSystemInfoResponse.system_info:type_name -> memos.api.v2.SystemInfo
|
||||
1, // 3: memos.api.v2.SystemService.GetSystemInfo:input_type -> memos.api.v2.GetSystemInfoRequest
|
||||
3, // 4: memos.api.v2.SystemService.UpdateSystemInfo:input_type -> memos.api.v2.UpdateSystemInfoRequest
|
||||
2, // 5: memos.api.v2.SystemService.GetSystemInfo:output_type -> memos.api.v2.GetSystemInfoResponse
|
||||
4, // 6: memos.api.v2.SystemService.UpdateSystemInfo:output_type -> memos.api.v2.UpdateSystemInfoResponse
|
||||
5, // [5:7] is the sub-list for method output_type
|
||||
3, // [3:5] is the sub-list for method input_type
|
||||
3, // [3:3] is the sub-list for extension type_name
|
||||
3, // [3:3] is the sub-list for extension extendee
|
||||
0, // [0:3] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_api_v2_system_service_proto_init() }
|
||||
@ -326,6 +457,30 @@ func file_api_v2_system_service_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_api_v2_system_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*UpdateSystemInfoRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_api_v2_system_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*UpdateSystemInfoResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
@ -333,7 +488,7 @@ func file_api_v2_system_service_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_api_v2_system_service_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 3,
|
||||
NumMessages: 5,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
|
@ -49,6 +49,42 @@ func local_request_SystemService_GetSystemInfo_0(ctx context.Context, marshaler
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_SystemService_UpdateSystemInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
|
||||
func request_SystemService_UpdateSystemInfo_0(ctx context.Context, marshaler runtime.Marshaler, client SystemServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq UpdateSystemInfoRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SystemService_UpdateSystemInfo_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.UpdateSystemInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_SystemService_UpdateSystemInfo_0(ctx context.Context, marshaler runtime.Marshaler, server SystemServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq UpdateSystemInfoRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SystemService_UpdateSystemInfo_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.UpdateSystemInfo(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
// RegisterSystemServiceHandlerServer registers the http handlers for service SystemService to "mux".
|
||||
// UnaryRPC :call SystemServiceServer directly.
|
||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||
@ -80,6 +116,31 @@ func RegisterSystemServiceHandlerServer(ctx context.Context, mux *runtime.ServeM
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_SystemService_UpdateSystemInfo_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.SystemService/UpdateSystemInfo", runtime.WithHTTPPathPattern("/api/v2/system/info"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_SystemService_UpdateSystemInfo_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_SystemService_UpdateSystemInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -143,13 +204,39 @@ func RegisterSystemServiceHandlerClient(ctx context.Context, mux *runtime.ServeM
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_SystemService_UpdateSystemInfo_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.SystemService/UpdateSystemInfo", runtime.WithHTTPPathPattern("/api/v2/system/info"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_SystemService_UpdateSystemInfo_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_SystemService_UpdateSystemInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_SystemService_GetSystemInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v2", "system", "info"}, ""))
|
||||
|
||||
pattern_SystemService_UpdateSystemInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v2", "system", "info"}, ""))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_SystemService_GetSystemInfo_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_SystemService_UpdateSystemInfo_0 = runtime.ForwardResponseMessage
|
||||
)
|
||||
|
@ -20,6 +20,7 @@ const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
const (
|
||||
SystemService_GetSystemInfo_FullMethodName = "/memos.api.v2.SystemService/GetSystemInfo"
|
||||
SystemService_UpdateSystemInfo_FullMethodName = "/memos.api.v2.SystemService/UpdateSystemInfo"
|
||||
)
|
||||
|
||||
// SystemServiceClient is the client API for SystemService service.
|
||||
@ -27,6 +28,7 @@ const (
|
||||
// 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 SystemServiceClient interface {
|
||||
GetSystemInfo(ctx context.Context, in *GetSystemInfoRequest, opts ...grpc.CallOption) (*GetSystemInfoResponse, error)
|
||||
UpdateSystemInfo(ctx context.Context, in *UpdateSystemInfoRequest, opts ...grpc.CallOption) (*UpdateSystemInfoResponse, error)
|
||||
}
|
||||
|
||||
type systemServiceClient struct {
|
||||
@ -46,11 +48,21 @@ func (c *systemServiceClient) GetSystemInfo(ctx context.Context, in *GetSystemIn
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *systemServiceClient) UpdateSystemInfo(ctx context.Context, in *UpdateSystemInfoRequest, opts ...grpc.CallOption) (*UpdateSystemInfoResponse, error) {
|
||||
out := new(UpdateSystemInfoResponse)
|
||||
err := c.cc.Invoke(ctx, SystemService_UpdateSystemInfo_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// SystemServiceServer is the server API for SystemService service.
|
||||
// All implementations must embed UnimplementedSystemServiceServer
|
||||
// for forward compatibility
|
||||
type SystemServiceServer interface {
|
||||
GetSystemInfo(context.Context, *GetSystemInfoRequest) (*GetSystemInfoResponse, error)
|
||||
UpdateSystemInfo(context.Context, *UpdateSystemInfoRequest) (*UpdateSystemInfoResponse, error)
|
||||
mustEmbedUnimplementedSystemServiceServer()
|
||||
}
|
||||
|
||||
@ -61,6 +73,9 @@ type UnimplementedSystemServiceServer struct {
|
||||
func (UnimplementedSystemServiceServer) GetSystemInfo(context.Context, *GetSystemInfoRequest) (*GetSystemInfoResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetSystemInfo not implemented")
|
||||
}
|
||||
func (UnimplementedSystemServiceServer) UpdateSystemInfo(context.Context, *UpdateSystemInfoRequest) (*UpdateSystemInfoResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateSystemInfo not implemented")
|
||||
}
|
||||
func (UnimplementedSystemServiceServer) mustEmbedUnimplementedSystemServiceServer() {}
|
||||
|
||||
// UnsafeSystemServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
@ -92,6 +107,24 @@ func _SystemService_GetSystemInfo_Handler(srv interface{}, ctx context.Context,
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SystemService_UpdateSystemInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpdateSystemInfoRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SystemServiceServer).UpdateSystemInfo(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SystemService_UpdateSystemInfo_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SystemServiceServer).UpdateSystemInfo(ctx, req.(*UpdateSystemInfoRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// SystemService_ServiceDesc is the grpc.ServiceDesc for SystemService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
@ -103,6 +136,10 @@ var SystemService_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "GetSystemInfo",
|
||||
Handler: _SystemService_GetSystemInfo_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateSystemInfo",
|
||||
Handler: _SystemService_UpdateSystemInfo_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api/v2/system_service.proto",
|
||||
|
@ -103,3 +103,60 @@ export declare class GetSystemInfoResponse extends Message<GetSystemInfoResponse
|
||||
static equals(a: GetSystemInfoResponse | PlainMessage<GetSystemInfoResponse> | undefined, b: GetSystemInfoResponse | PlainMessage<GetSystemInfoResponse> | undefined): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @generated from message memos.api.v2.UpdateSystemInfoRequest
|
||||
*/
|
||||
export declare class UpdateSystemInfoRequest extends Message<UpdateSystemInfoRequest> {
|
||||
/**
|
||||
* System info is the updated data.
|
||||
*
|
||||
* @generated from field: memos.api.v2.SystemInfo system_info = 1;
|
||||
*/
|
||||
systemInfo?: SystemInfo;
|
||||
|
||||
/**
|
||||
* Update mask is the array of paths.
|
||||
*
|
||||
* @generated from field: repeated string update_mask = 2;
|
||||
*/
|
||||
updateMask: string[];
|
||||
|
||||
constructor(data?: PartialMessage<UpdateSystemInfoRequest>);
|
||||
|
||||
static readonly runtime: typeof proto3;
|
||||
static readonly typeName = "memos.api.v2.UpdateSystemInfoRequest";
|
||||
static readonly fields: FieldList;
|
||||
|
||||
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): UpdateSystemInfoRequest;
|
||||
|
||||
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): UpdateSystemInfoRequest;
|
||||
|
||||
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): UpdateSystemInfoRequest;
|
||||
|
||||
static equals(a: UpdateSystemInfoRequest | PlainMessage<UpdateSystemInfoRequest> | undefined, b: UpdateSystemInfoRequest | PlainMessage<UpdateSystemInfoRequest> | undefined): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @generated from message memos.api.v2.UpdateSystemInfoResponse
|
||||
*/
|
||||
export declare class UpdateSystemInfoResponse extends Message<UpdateSystemInfoResponse> {
|
||||
/**
|
||||
* @generated from field: memos.api.v2.SystemInfo system_info = 1;
|
||||
*/
|
||||
systemInfo?: SystemInfo;
|
||||
|
||||
constructor(data?: PartialMessage<UpdateSystemInfoResponse>);
|
||||
|
||||
static readonly runtime: typeof proto3;
|
||||
static readonly typeName = "memos.api.v2.UpdateSystemInfoResponse";
|
||||
static readonly fields: FieldList;
|
||||
|
||||
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): UpdateSystemInfoResponse;
|
||||
|
||||
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): UpdateSystemInfoResponse;
|
||||
|
||||
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): UpdateSystemInfoResponse;
|
||||
|
||||
static equals(a: UpdateSystemInfoResponse | PlainMessage<UpdateSystemInfoResponse> | undefined, b: UpdateSystemInfoResponse | PlainMessage<UpdateSystemInfoResponse> | undefined): boolean;
|
||||
}
|
||||
|
||||
|
@ -39,3 +39,24 @@ export const GetSystemInfoResponse = proto3.makeMessageType(
|
||||
],
|
||||
);
|
||||
|
||||
/**
|
||||
* @generated from message memos.api.v2.UpdateSystemInfoRequest
|
||||
*/
|
||||
export const UpdateSystemInfoRequest = proto3.makeMessageType(
|
||||
"memos.api.v2.UpdateSystemInfoRequest",
|
||||
() => [
|
||||
{ no: 1, name: "system_info", kind: "message", T: SystemInfo },
|
||||
{ no: 2, name: "update_mask", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
|
||||
],
|
||||
);
|
||||
|
||||
/**
|
||||
* @generated from message memos.api.v2.UpdateSystemInfoResponse
|
||||
*/
|
||||
export const UpdateSystemInfoResponse = proto3.makeMessageType(
|
||||
"memos.api.v2.UpdateSystemInfoResponse",
|
||||
() => [
|
||||
{ no: 1, name: "system_info", kind: "message", T: SystemInfo },
|
||||
],
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user