From 2ea182243f641d2f22ede0d4184925884d694b7a Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Tue, 28 Apr 2020 19:47:04 +0200 Subject: [PATCH] Add settings value protobuf and store implementation --- go.mod | 1 + pkg/proto/v0/settings.pb.go | 651 +++++++++++++++++++++++++---- pkg/proto/v0/settings.pb.micro.go | 70 ++++ pkg/proto/v0/settings.pb.web.go | 369 +++++++++++++++- pkg/proto/v0/settings.proto | 78 +++- pkg/proto/v0/settings.swagger.json | 177 +++++++- pkg/server/grpc/server.go | 5 +- pkg/server/http/server.go | 6 +- pkg/service/v0/service.go | 26 +- pkg/settings/settings.go | 17 +- pkg/store/filesystem/bundles.go | 73 ++++ pkg/store/filesystem/paths.go | 50 ++- pkg/store/filesystem/store.go | 67 --- pkg/store/filesystem/values.go | 60 +++ ui/client/settings/index.js | 137 +++++- 15 files changed, 1575 insertions(+), 212 deletions(-) create mode 100644 pkg/store/filesystem/bundles.go create mode 100644 pkg/store/filesystem/values.go diff --git a/go.mod b/go.mod index e4b58b9ef7..9f463fb837 100644 --- a/go.mod +++ b/go.mod @@ -22,6 +22,7 @@ require ( go.opencensus.io v0.22.2 golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa google.golang.org/genproto v0.0.0-20200420144010-e5e8543f8aeb + google.golang.org/grpc v1.27.0 ) replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 diff --git a/pkg/proto/v0/settings.pb.go b/pkg/proto/v0/settings.pb.go index 667d932ad0..c4ecb6f80c 100644 --- a/pkg/proto/v0/settings.pb.go +++ b/pkg/proto/v0/settings.pb.go @@ -22,7 +22,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package -// requests and responses +// requests and responses for settings bundles type CreateSettingsBundleRequest struct { SettingsBundle *SettingsBundle `protobuf:"bytes,1,opt,name=settings_bundle,json=settingsBundle,proto3" json:"settings_bundle,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -103,7 +103,7 @@ func (m *CreateSettingsBundleResponse) GetSettingsBundle() *SettingsBundle { type GetSettingsBundleRequest struct { Extension string `protobuf:"bytes,1,opt,name=extension,proto3" json:"extension,omitempty"` - Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` + BundleKey string `protobuf:"bytes,2,opt,name=bundle_key,json=bundleKey,proto3" json:"bundle_key,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -141,9 +141,9 @@ func (m *GetSettingsBundleRequest) GetExtension() string { return "" } -func (m *GetSettingsBundleRequest) GetKey() string { +func (m *GetSettingsBundleRequest) GetBundleKey() string { if m != nil { - return m.Key + return m.BundleKey } return "" } @@ -265,10 +265,191 @@ func (m *ListSettingsBundlesResponse) GetSettingsBundles() []*SettingsBundle { return nil } -// payloads +// requests and responses for settings values +type SaveSettingsValueRequest struct { + SettingsValue *SettingsValue `protobuf:"bytes,1,opt,name=settings_value,json=settingsValue,proto3" json:"settings_value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SaveSettingsValueRequest) Reset() { *m = SaveSettingsValueRequest{} } +func (m *SaveSettingsValueRequest) String() string { return proto.CompactTextString(m) } +func (*SaveSettingsValueRequest) ProtoMessage() {} +func (*SaveSettingsValueRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_6c7cab62fa432213, []int{6} +} + +func (m *SaveSettingsValueRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SaveSettingsValueRequest.Unmarshal(m, b) +} +func (m *SaveSettingsValueRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SaveSettingsValueRequest.Marshal(b, m, deterministic) +} +func (m *SaveSettingsValueRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SaveSettingsValueRequest.Merge(m, src) +} +func (m *SaveSettingsValueRequest) XXX_Size() int { + return xxx_messageInfo_SaveSettingsValueRequest.Size(m) +} +func (m *SaveSettingsValueRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SaveSettingsValueRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SaveSettingsValueRequest proto.InternalMessageInfo + +func (m *SaveSettingsValueRequest) GetSettingsValue() *SettingsValue { + if m != nil { + return m.SettingsValue + } + return nil +} + +type SaveSettingsValueResponse struct { + SettingsValue *SettingsValue `protobuf:"bytes,1,opt,name=settings_value,json=settingsValue,proto3" json:"settings_value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SaveSettingsValueResponse) Reset() { *m = SaveSettingsValueResponse{} } +func (m *SaveSettingsValueResponse) String() string { return proto.CompactTextString(m) } +func (*SaveSettingsValueResponse) ProtoMessage() {} +func (*SaveSettingsValueResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_6c7cab62fa432213, []int{7} +} + +func (m *SaveSettingsValueResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SaveSettingsValueResponse.Unmarshal(m, b) +} +func (m *SaveSettingsValueResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SaveSettingsValueResponse.Marshal(b, m, deterministic) +} +func (m *SaveSettingsValueResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_SaveSettingsValueResponse.Merge(m, src) +} +func (m *SaveSettingsValueResponse) XXX_Size() int { + return xxx_messageInfo_SaveSettingsValueResponse.Size(m) +} +func (m *SaveSettingsValueResponse) XXX_DiscardUnknown() { + xxx_messageInfo_SaveSettingsValueResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_SaveSettingsValueResponse proto.InternalMessageInfo + +func (m *SaveSettingsValueResponse) GetSettingsValue() *SettingsValue { + if m != nil { + return m.SettingsValue + } + return nil +} + +type GetSettingsValueRequest struct { + AccountUuid string `protobuf:"bytes,1,opt,name=account_uuid,json=accountUuid,proto3" json:"account_uuid,omitempty"` + Extension string `protobuf:"bytes,2,opt,name=extension,proto3" json:"extension,omitempty"` + BundleKey string `protobuf:"bytes,3,opt,name=bundle_key,json=bundleKey,proto3" json:"bundle_key,omitempty"` + SettingKey string `protobuf:"bytes,4,opt,name=setting_key,json=settingKey,proto3" json:"setting_key,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetSettingsValueRequest) Reset() { *m = GetSettingsValueRequest{} } +func (m *GetSettingsValueRequest) String() string { return proto.CompactTextString(m) } +func (*GetSettingsValueRequest) ProtoMessage() {} +func (*GetSettingsValueRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_6c7cab62fa432213, []int{8} +} + +func (m *GetSettingsValueRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetSettingsValueRequest.Unmarshal(m, b) +} +func (m *GetSettingsValueRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetSettingsValueRequest.Marshal(b, m, deterministic) +} +func (m *GetSettingsValueRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetSettingsValueRequest.Merge(m, src) +} +func (m *GetSettingsValueRequest) XXX_Size() int { + return xxx_messageInfo_GetSettingsValueRequest.Size(m) +} +func (m *GetSettingsValueRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetSettingsValueRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetSettingsValueRequest proto.InternalMessageInfo + +func (m *GetSettingsValueRequest) GetAccountUuid() string { + if m != nil { + return m.AccountUuid + } + return "" +} + +func (m *GetSettingsValueRequest) GetExtension() string { + if m != nil { + return m.Extension + } + return "" +} + +func (m *GetSettingsValueRequest) GetBundleKey() string { + if m != nil { + return m.BundleKey + } + return "" +} + +func (m *GetSettingsValueRequest) GetSettingKey() string { + if m != nil { + return m.SettingKey + } + return "" +} + +type GetSettingsValueResponse struct { + SettingsValue *SettingsValue `protobuf:"bytes,1,opt,name=settings_value,json=settingsValue,proto3" json:"settings_value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetSettingsValueResponse) Reset() { *m = GetSettingsValueResponse{} } +func (m *GetSettingsValueResponse) String() string { return proto.CompactTextString(m) } +func (*GetSettingsValueResponse) ProtoMessage() {} +func (*GetSettingsValueResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_6c7cab62fa432213, []int{9} +} + +func (m *GetSettingsValueResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetSettingsValueResponse.Unmarshal(m, b) +} +func (m *GetSettingsValueResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetSettingsValueResponse.Marshal(b, m, deterministic) +} +func (m *GetSettingsValueResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetSettingsValueResponse.Merge(m, src) +} +func (m *GetSettingsValueResponse) XXX_Size() int { + return xxx_messageInfo_GetSettingsValueResponse.Size(m) +} +func (m *GetSettingsValueResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GetSettingsValueResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GetSettingsValueResponse proto.InternalMessageInfo + +func (m *GetSettingsValueResponse) GetSettingsValue() *SettingsValue { + if m != nil { + return m.SettingsValue + } + return nil +} + +// payloads for settings bundles type SettingsBundle struct { Extension string `protobuf:"bytes,1,opt,name=extension,proto3" json:"extension,omitempty"` - Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` + BundleKey string `protobuf:"bytes,2,opt,name=bundle_key,json=bundleKey,proto3" json:"bundle_key,omitempty"` DisplayName string `protobuf:"bytes,3,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"` Settings []*Setting `protobuf:"bytes,4,rep,name=settings,proto3" json:"settings,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -280,7 +461,7 @@ func (m *SettingsBundle) Reset() { *m = SettingsBundle{} } func (m *SettingsBundle) String() string { return proto.CompactTextString(m) } func (*SettingsBundle) ProtoMessage() {} func (*SettingsBundle) Descriptor() ([]byte, []int) { - return fileDescriptor_6c7cab62fa432213, []int{6} + return fileDescriptor_6c7cab62fa432213, []int{10} } func (m *SettingsBundle) XXX_Unmarshal(b []byte) error { @@ -308,9 +489,9 @@ func (m *SettingsBundle) GetExtension() string { return "" } -func (m *SettingsBundle) GetKey() string { +func (m *SettingsBundle) GetBundleKey() string { if m != nil { - return m.Key + return m.BundleKey } return "" } @@ -330,7 +511,7 @@ func (m *SettingsBundle) GetSettings() []*Setting { } type Setting struct { - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + SettingKey string `protobuf:"bytes,1,opt,name=setting_key,json=settingKey,proto3" json:"setting_key,omitempty"` DisplayName string `protobuf:"bytes,2,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"` Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` // Types that are valid to be assigned to Value: @@ -349,7 +530,7 @@ func (m *Setting) Reset() { *m = Setting{} } func (m *Setting) String() string { return proto.CompactTextString(m) } func (*Setting) ProtoMessage() {} func (*Setting) Descriptor() ([]byte, []int) { - return fileDescriptor_6c7cab62fa432213, []int{7} + return fileDescriptor_6c7cab62fa432213, []int{11} } func (m *Setting) XXX_Unmarshal(b []byte) error { @@ -370,9 +551,9 @@ func (m *Setting) XXX_DiscardUnknown() { var xxx_messageInfo_Setting proto.InternalMessageInfo -func (m *Setting) GetKey() string { +func (m *Setting) GetSettingKey() string { if m != nil { - return m.Key + return m.SettingKey } return "" } @@ -493,7 +674,7 @@ func (m *IntSetting) Reset() { *m = IntSetting{} } func (m *IntSetting) String() string { return proto.CompactTextString(m) } func (*IntSetting) ProtoMessage() {} func (*IntSetting) Descriptor() ([]byte, []int) { - return fileDescriptor_6c7cab62fa432213, []int{8} + return fileDescriptor_6c7cab62fa432213, []int{12} } func (m *IntSetting) XXX_Unmarshal(b []byte) error { @@ -564,7 +745,7 @@ func (m *StringSetting) Reset() { *m = StringSetting{} } func (m *StringSetting) String() string { return proto.CompactTextString(m) } func (*StringSetting) ProtoMessage() {} func (*StringSetting) Descriptor() ([]byte, []int) { - return fileDescriptor_6c7cab62fa432213, []int{9} + return fileDescriptor_6c7cab62fa432213, []int{13} } func (m *StringSetting) XXX_Unmarshal(b []byte) error { @@ -632,7 +813,7 @@ func (m *BoolSetting) Reset() { *m = BoolSetting{} } func (m *BoolSetting) String() string { return proto.CompactTextString(m) } func (*BoolSetting) ProtoMessage() {} func (*BoolSetting) Descriptor() ([]byte, []int) { - return fileDescriptor_6c7cab62fa432213, []int{10} + return fileDescriptor_6c7cab62fa432213, []int{14} } func (m *BoolSetting) XXX_Unmarshal(b []byte) error { @@ -678,7 +859,7 @@ func (m *SingleChoiceListSetting) Reset() { *m = SingleChoiceListSetting func (m *SingleChoiceListSetting) String() string { return proto.CompactTextString(m) } func (*SingleChoiceListSetting) ProtoMessage() {} func (*SingleChoiceListSetting) Descriptor() ([]byte, []int) { - return fileDescriptor_6c7cab62fa432213, []int{11} + return fileDescriptor_6c7cab62fa432213, []int{15} } func (m *SingleChoiceListSetting) XXX_Unmarshal(b []byte) error { @@ -717,7 +898,7 @@ func (m *MultiChoiceListSetting) Reset() { *m = MultiChoiceListSetting{} func (m *MultiChoiceListSetting) String() string { return proto.CompactTextString(m) } func (*MultiChoiceListSetting) ProtoMessage() {} func (*MultiChoiceListSetting) Descriptor() ([]byte, []int) { - return fileDescriptor_6c7cab62fa432213, []int{12} + return fileDescriptor_6c7cab62fa432213, []int{16} } func (m *MultiChoiceListSetting) XXX_Unmarshal(b []byte) error { @@ -761,7 +942,7 @@ func (m *ListOption) Reset() { *m = ListOption{} } func (m *ListOption) String() string { return proto.CompactTextString(m) } func (*ListOption) ProtoMessage() {} func (*ListOption) Descriptor() ([]byte, []int) { - return fileDescriptor_6c7cab62fa432213, []int{13} + return fileDescriptor_6c7cab62fa432213, []int{17} } func (m *ListOption) XXX_Unmarshal(b []byte) error { @@ -841,6 +1022,282 @@ func (*ListOption) XXX_OneofWrappers() []interface{} { } } +// payloads for settings values +type SettingsValue struct { + AccountUuid string `protobuf:"bytes,1,opt,name=account_uuid,json=accountUuid,proto3" json:"account_uuid,omitempty"` + Extension string `protobuf:"bytes,2,opt,name=extension,proto3" json:"extension,omitempty"` + BundleKey string `protobuf:"bytes,3,opt,name=bundle_key,json=bundleKey,proto3" json:"bundle_key,omitempty"` + SettingKey string `protobuf:"bytes,4,opt,name=setting_key,json=settingKey,proto3" json:"setting_key,omitempty"` + // Types that are valid to be assigned to Value: + // *SettingsValue_BoolValue + // *SettingsValue_IntValue + // *SettingsValue_StringValue + // *SettingsValue_IntListValue + // *SettingsValue_StringListValue + Value isSettingsValue_Value `protobuf_oneof:"value"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SettingsValue) Reset() { *m = SettingsValue{} } +func (m *SettingsValue) String() string { return proto.CompactTextString(m) } +func (*SettingsValue) ProtoMessage() {} +func (*SettingsValue) Descriptor() ([]byte, []int) { + return fileDescriptor_6c7cab62fa432213, []int{18} +} + +func (m *SettingsValue) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SettingsValue.Unmarshal(m, b) +} +func (m *SettingsValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SettingsValue.Marshal(b, m, deterministic) +} +func (m *SettingsValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_SettingsValue.Merge(m, src) +} +func (m *SettingsValue) XXX_Size() int { + return xxx_messageInfo_SettingsValue.Size(m) +} +func (m *SettingsValue) XXX_DiscardUnknown() { + xxx_messageInfo_SettingsValue.DiscardUnknown(m) +} + +var xxx_messageInfo_SettingsValue proto.InternalMessageInfo + +func (m *SettingsValue) GetAccountUuid() string { + if m != nil { + return m.AccountUuid + } + return "" +} + +func (m *SettingsValue) GetExtension() string { + if m != nil { + return m.Extension + } + return "" +} + +func (m *SettingsValue) GetBundleKey() string { + if m != nil { + return m.BundleKey + } + return "" +} + +func (m *SettingsValue) GetSettingKey() string { + if m != nil { + return m.SettingKey + } + return "" +} + +type isSettingsValue_Value interface { + isSettingsValue_Value() +} + +type SettingsValue_BoolValue struct { + BoolValue bool `protobuf:"varint,5,opt,name=bool_value,json=boolValue,proto3,oneof"` +} + +type SettingsValue_IntValue struct { + IntValue int64 `protobuf:"varint,6,opt,name=int_value,json=intValue,proto3,oneof"` +} + +type SettingsValue_StringValue struct { + StringValue string `protobuf:"bytes,7,opt,name=string_value,json=stringValue,proto3,oneof"` +} + +type SettingsValue_IntListValue struct { + IntListValue *IntListValue `protobuf:"bytes,8,opt,name=int_list_value,json=intListValue,proto3,oneof"` +} + +type SettingsValue_StringListValue struct { + StringListValue *StringListValue `protobuf:"bytes,9,opt,name=string_list_value,json=stringListValue,proto3,oneof"` +} + +func (*SettingsValue_BoolValue) isSettingsValue_Value() {} + +func (*SettingsValue_IntValue) isSettingsValue_Value() {} + +func (*SettingsValue_StringValue) isSettingsValue_Value() {} + +func (*SettingsValue_IntListValue) isSettingsValue_Value() {} + +func (*SettingsValue_StringListValue) isSettingsValue_Value() {} + +func (m *SettingsValue) GetValue() isSettingsValue_Value { + if m != nil { + return m.Value + } + return nil +} + +func (m *SettingsValue) GetBoolValue() bool { + if x, ok := m.GetValue().(*SettingsValue_BoolValue); ok { + return x.BoolValue + } + return false +} + +func (m *SettingsValue) GetIntValue() int64 { + if x, ok := m.GetValue().(*SettingsValue_IntValue); ok { + return x.IntValue + } + return 0 +} + +func (m *SettingsValue) GetStringValue() string { + if x, ok := m.GetValue().(*SettingsValue_StringValue); ok { + return x.StringValue + } + return "" +} + +func (m *SettingsValue) GetIntListValue() *IntListValue { + if x, ok := m.GetValue().(*SettingsValue_IntListValue); ok { + return x.IntListValue + } + return nil +} + +func (m *SettingsValue) GetStringListValue() *StringListValue { + if x, ok := m.GetValue().(*SettingsValue_StringListValue); ok { + return x.StringListValue + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*SettingsValue) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*SettingsValue_BoolValue)(nil), + (*SettingsValue_IntValue)(nil), + (*SettingsValue_StringValue)(nil), + (*SettingsValue_IntListValue)(nil), + (*SettingsValue_StringListValue)(nil), + } +} + +type IntListValue struct { + Value []int64 `protobuf:"varint,1,rep,packed,name=value,proto3" json:"value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *IntListValue) Reset() { *m = IntListValue{} } +func (m *IntListValue) String() string { return proto.CompactTextString(m) } +func (*IntListValue) ProtoMessage() {} +func (*IntListValue) Descriptor() ([]byte, []int) { + return fileDescriptor_6c7cab62fa432213, []int{19} +} + +func (m *IntListValue) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_IntListValue.Unmarshal(m, b) +} +func (m *IntListValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_IntListValue.Marshal(b, m, deterministic) +} +func (m *IntListValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_IntListValue.Merge(m, src) +} +func (m *IntListValue) XXX_Size() int { + return xxx_messageInfo_IntListValue.Size(m) +} +func (m *IntListValue) XXX_DiscardUnknown() { + xxx_messageInfo_IntListValue.DiscardUnknown(m) +} + +var xxx_messageInfo_IntListValue proto.InternalMessageInfo + +func (m *IntListValue) GetValue() []int64 { + if m != nil { + return m.Value + } + return nil +} + +type StringListValue struct { + Value []string `protobuf:"bytes,1,rep,name=value,proto3" json:"value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StringListValue) Reset() { *m = StringListValue{} } +func (m *StringListValue) String() string { return proto.CompactTextString(m) } +func (*StringListValue) ProtoMessage() {} +func (*StringListValue) Descriptor() ([]byte, []int) { + return fileDescriptor_6c7cab62fa432213, []int{20} +} + +func (m *StringListValue) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StringListValue.Unmarshal(m, b) +} +func (m *StringListValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StringListValue.Marshal(b, m, deterministic) +} +func (m *StringListValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_StringListValue.Merge(m, src) +} +func (m *StringListValue) XXX_Size() int { + return xxx_messageInfo_StringListValue.Size(m) +} +func (m *StringListValue) XXX_DiscardUnknown() { + xxx_messageInfo_StringListValue.DiscardUnknown(m) +} + +var xxx_messageInfo_StringListValue proto.InternalMessageInfo + +func (m *StringListValue) GetValue() []string { + if m != nil { + return m.Value + } + return nil +} + +// only meant for serialization +type SettingsValues struct { + Values map[string]*SettingsValue `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SettingsValues) Reset() { *m = SettingsValues{} } +func (m *SettingsValues) String() string { return proto.CompactTextString(m) } +func (*SettingsValues) ProtoMessage() {} +func (*SettingsValues) Descriptor() ([]byte, []int) { + return fileDescriptor_6c7cab62fa432213, []int{21} +} + +func (m *SettingsValues) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SettingsValues.Unmarshal(m, b) +} +func (m *SettingsValues) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SettingsValues.Marshal(b, m, deterministic) +} +func (m *SettingsValues) XXX_Merge(src proto.Message) { + xxx_messageInfo_SettingsValues.Merge(m, src) +} +func (m *SettingsValues) XXX_Size() int { + return xxx_messageInfo_SettingsValues.Size(m) +} +func (m *SettingsValues) XXX_DiscardUnknown() { + xxx_messageInfo_SettingsValues.DiscardUnknown(m) +} + +var xxx_messageInfo_SettingsValues proto.InternalMessageInfo + +func (m *SettingsValues) GetValues() map[string]*SettingsValue { + if m != nil { + return m.Values + } + return nil +} + func init() { proto.RegisterType((*CreateSettingsBundleRequest)(nil), "proto.CreateSettingsBundleRequest") proto.RegisterType((*CreateSettingsBundleResponse)(nil), "proto.CreateSettingsBundleResponse") @@ -848,6 +1305,10 @@ func init() { proto.RegisterType((*GetSettingsBundleResponse)(nil), "proto.GetSettingsBundleResponse") proto.RegisterType((*ListSettingsBundlesRequest)(nil), "proto.ListSettingsBundlesRequest") proto.RegisterType((*ListSettingsBundlesResponse)(nil), "proto.ListSettingsBundlesResponse") + proto.RegisterType((*SaveSettingsValueRequest)(nil), "proto.SaveSettingsValueRequest") + proto.RegisterType((*SaveSettingsValueResponse)(nil), "proto.SaveSettingsValueResponse") + proto.RegisterType((*GetSettingsValueRequest)(nil), "proto.GetSettingsValueRequest") + proto.RegisterType((*GetSettingsValueResponse)(nil), "proto.GetSettingsValueResponse") proto.RegisterType((*SettingsBundle)(nil), "proto.SettingsBundle") proto.RegisterType((*Setting)(nil), "proto.Setting") proto.RegisterType((*IntSetting)(nil), "proto.IntSetting") @@ -856,6 +1317,11 @@ func init() { proto.RegisterType((*SingleChoiceListSetting)(nil), "proto.SingleChoiceListSetting") proto.RegisterType((*MultiChoiceListSetting)(nil), "proto.MultiChoiceListSetting") proto.RegisterType((*ListOption)(nil), "proto.ListOption") + proto.RegisterType((*SettingsValue)(nil), "proto.SettingsValue") + proto.RegisterType((*IntListValue)(nil), "proto.IntListValue") + proto.RegisterType((*StringListValue)(nil), "proto.StringListValue") + proto.RegisterType((*SettingsValues)(nil), "proto.SettingsValues") + proto.RegisterMapType((map[string]*SettingsValue)(nil), "proto.SettingsValues.ValuesEntry") } func init() { @@ -863,67 +1329,88 @@ func init() { } var fileDescriptor_6c7cab62fa432213 = []byte{ - // 986 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcf, 0x6f, 0xe3, 0x44, - 0x14, 0x5e, 0xc7, 0x6d, 0x93, 0xbc, 0x6c, 0xdb, 0x74, 0x36, 0xb0, 0x21, 0xdb, 0x42, 0xea, 0x5e, - 0xd8, 0x42, 0xe3, 0x92, 0x9e, 0x88, 0xb4, 0x68, 0xb7, 0xa5, 0xb4, 0x0b, 0xed, 0xb2, 0x72, 0x25, - 0x0e, 0x20, 0x88, 0x26, 0xce, 0xe0, 0x0c, 0x6b, 0xcf, 0x78, 0x3d, 0xe3, 0x36, 0x55, 0xb5, 0x12, - 0x70, 0xe1, 0x88, 0x04, 0x27, 0xae, 0x48, 0xdc, 0x80, 0x7f, 0x86, 0x7f, 0x81, 0x3f, 0x04, 0x79, - 0x3c, 0x8e, 0x93, 0x34, 0x29, 0xbb, 0x82, 0x93, 0x3d, 0xef, 0x7d, 0xdf, 0xf7, 0x3e, 0xcf, 0x9b, - 0x1f, 0x86, 0x15, 0x41, 0xa4, 0xa4, 0xcc, 0x13, 0xad, 0x30, 0xe2, 0x92, 0xa3, 0x45, 0xf5, 0x68, - 0xac, 0x7b, 0x9c, 0x7b, 0x3e, 0xb1, 0x71, 0x48, 0x6d, 0xcc, 0x18, 0x97, 0x58, 0x52, 0xce, 0x34, - 0xa8, 0xf1, 0xae, 0x7a, 0xb8, 0x3b, 0x1e, 0x61, 0x3b, 0xe2, 0x02, 0x7b, 0x1e, 0x89, 0x6c, 0x1e, - 0x2a, 0xc4, 0x75, 0xb4, 0xf5, 0x25, 0xdc, 0x3b, 0x88, 0x08, 0x96, 0xe4, 0x4c, 0x97, 0xda, 0x8f, - 0x59, 0xdf, 0x27, 0x0e, 0x79, 0x1e, 0x13, 0x21, 0xd1, 0x07, 0xb0, 0x9a, 0x79, 0xe8, 0xf6, 0x54, - 0xa6, 0x6e, 0x34, 0x8d, 0xb7, 0x2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 0xed, 0x6e, 0x17, - 0x8c, 0x42, 0xbb, 0x8a, 0xc3, 0xd0, 0xa7, 0xae, 0xfa, 0x69, 0xb2, 0xbf, 0x11, 0x9c, 0x75, 0xae, - 0x45, 0xa2, 0x23, 0xa8, 0x7e, 0x48, 0xce, 0x89, 0xcf, 0x43, 0x12, 0x35, 0x4f, 0x31, 0x8b, 0xb1, - 0x8f, 0xf6, 0x92, 0xfa, 0x1d, 0x7b, 0x54, 0xb3, 0xa5, 0x7d, 0x50, 0x6e, 0x8f, 0xda, 0x22, 0x94, - 0x91, 0xee, 0xc8, 0xc8, 0xe7, 0xe9, 0x0f, 0x5e, 0x6f, 0x49, 0x3d, 0xf6, 0xfe, 0x09, 0x00, 0x00, - 0xff, 0xff, 0xc7, 0xed, 0x58, 0x58, 0x00, 0x0a, 0x00, 0x00, + // 1318 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x57, 0xdd, 0x6e, 0x1b, 0xc5, + 0x17, 0xef, 0x7a, 0xf3, 0x61, 0x1f, 0xe7, 0x73, 0x9a, 0x7f, 0xeb, 0xba, 0x49, 0xe3, 0x6e, 0xfe, + 0x12, 0x25, 0x10, 0x6f, 0x9a, 0xdc, 0x50, 0x57, 0x45, 0x6d, 0xd2, 0xd0, 0x54, 0x6d, 0xda, 0x6a, + 0xa3, 0x02, 0x02, 0x81, 0xb5, 0x5e, 0x0f, 0xf6, 0xc0, 0x7a, 0x67, 0xbb, 0x33, 0x9b, 0x26, 0x44, + 0x41, 0x80, 0x78, 0x01, 0xe0, 0x0a, 0xc4, 0x15, 0x12, 0x37, 0x95, 0xe0, 0x96, 0x0b, 0x1e, 0x83, + 0x57, 0xe0, 0x41, 0xd0, 0xce, 0xce, 0x7e, 0x7a, 0x1d, 0x8a, 0x52, 0x89, 0xab, 0xf5, 0x9e, 0xcf, + 0xdf, 0xfe, 0xce, 0x99, 0x33, 0xc7, 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 0x12, + 0xde, 0x7d, 0x27, 0xaa, 0xc0, 0xee, 0x39, 0xa3, 0x4c, 0x1c, 0x2e, 0x28, 0x44, 0x37, 0x60, 0x8a, + 0x71, 0x2f, 0x80, 0x15, 0x3a, 0x8d, 0x67, 0xd9, 0x17, 0xaa, 0xc4, 0xaf, 0x1a, 0xda, 0x86, 0xae, + 0x9b, 0x00, 0x1d, 0x4a, 0x6d, 0xe9, 0x38, 0x21, 0x1c, 0x91, 0x74, 0xdc, 0xa2, 0xd4, 0x4e, 0xdc, + 0x2a, 0x81, 0x5d, 0xe8, 0xf4, 0x04, 0xce, 0x33, 0xe2, 0xf4, 0x6c, 0xdc, 0xb6, 0xfa, 0x94, 0x58, + 0x58, 0x7a, 0x4f, 0x0a, 0xef, 0x2b, 0x51, 0x5a, 0x61, 0xb1, 0x2d, 0x0c, 0x52, 0x47, 0x7d, 0xf7, + 0x9c, 0x31, 0xcf, 0x52, 0xaa, 0x30, 0xe2, 0x1e, 0xa0, 0x81, 0x6f, 0x73, 0x92, 0x0d, 0x58, 0x16, + 0x01, 0x97, 0x64, 0xc0, 0xbd, 0xc0, 0xa0, 0x28, 0xde, 0xdc, 0x20, 0xd1, 0x88, 0x70, 0x5b, 0x93, + 0x30, 0x2e, 0x22, 0x68, 0x5f, 0x2a, 0x00, 0x09, 0x69, 0xa8, 0x06, 0x93, 0x5d, 0xfc, 0x89, 0xe9, + 0xdb, 0x5c, 0x14, 0x4f, 0x35, 0xa2, 0x57, 0x34, 0x07, 0xea, 0x80, 0x84, 0xc7, 0x46, 0x35, 0x82, + 0x9f, 0x42, 0x62, 0x1e, 0x8a, 0x02, 0x05, 0x12, 0xf3, 0x10, 0x21, 0x18, 0x63, 0x1c, 0xbb, 0xa2, + 0x26, 0xaa, 0x21, 0x7e, 0x07, 0xe5, 0x74, 0x6d, 0xd3, 0xc2, 0x7d, 0x6a, 0x77, 0xb1, 0x27, 0x98, + 0xaf, 0x18, 0x69, 0x91, 0xf6, 0x8b, 0x02, 0xd3, 0x99, 0x12, 0xe4, 0x51, 0x54, 0x12, 0x14, 0x75, + 0x28, 0x7b, 0xf8, 0x99, 0x4f, 0x3c, 0xdc, 0x15, 0x50, 0xca, 0x46, 0xfc, 0x1e, 0xb4, 0xfd, 0x80, + 0x38, 0x6d, 0x1b, 0x3b, 0x3d, 0xde, 0x17, 0xb0, 0xc6, 0x8d, 0xca, 0x80, 0x38, 0x0f, 0x85, 0x40, + 0xa8, 0xcd, 0xc3, 0x48, 0x3d, 0x26, 0xd5, 0xe6, 0xa1, 0x54, 0xff, 0x33, 0xce, 0x5b, 0x50, 0x4d, + 0x15, 0x3c, 0x0f, 0xb2, 0x9c, 0x80, 0x5c, 0x80, 0x71, 0xdb, 0xec, 0x60, 0x5b, 0x76, 0x77, 0xf8, + 0xa2, 0xbd, 0x03, 0x17, 0x47, 0x54, 0x1c, 0xbd, 0x01, 0x93, 0xf2, 0xe6, 0x96, 0x33, 0x3c, 0x6a, + 0xe7, 0xc0, 0xe8, 0xb1, 0xd0, 0x18, 0x91, 0x85, 0xb6, 0x03, 0x17, 0x8a, 0x0b, 0xfd, 0xef, 0xc2, + 0xfc, 0xa0, 0x00, 0x24, 0x72, 0xb4, 0x92, 0x3b, 0x21, 0x82, 0xf7, 0xfc, 0x59, 0x58, 0x4a, 0x1f, + 0x3c, 0xd1, 0x09, 0x99, 0x53, 0x96, 0x62, 0x44, 0xcd, 0x32, 0xb2, 0x02, 0xd3, 0xd1, 0xb1, 0x4f, + 0x4e, 0x6d, 0xc5, 0x88, 0x66, 0x41, 0xd8, 0x93, 0x65, 0x98, 0x08, 0xc1, 0x69, 0x5f, 0xa9, 0x30, + 0x9d, 0x19, 0x89, 0xff, 0xf9, 0x74, 0x47, 0xcb, 0x99, 0x31, 0x10, 0x74, 0x47, 0x39, 0x7b, 0xe4, + 0x33, 0xdc, 0x4c, 0x0c, 0x71, 0x93, 0xe7, 0x77, 0xb2, 0x88, 0xdf, 0x9b, 0x30, 0x13, 0xc4, 0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xba, 0xd4, 0xe3, 0xb7, + 0x23, 0x7d, 0x60, 0xbc, 0xfa, 0x00, 0xe0, 0x8e, 0x6b, 0x5a, 0x7d, 0xbc, 0xb6, 0xd1, 0x5c, 0x47, + 0xb7, 0x5e, 0x3a, 0x9c, 0xde, 0xb1, 0x69, 0x47, 0x1f, 0x98, 0x8c, 0x63, 0x4f, 0x7f, 0x78, 0x7f, + 0x7b, 0xe7, 0xd1, 0xfe, 0xce, 0x86, 0x7a, 0xbd, 0xb9, 0xbe, 0x5a, 0x52, 0x4a, 0x1b, 0x73, 0xa6, + 0xeb, 0xda, 0xc4, 0x12, 0xff, 0x6a, 0xf5, 0x4f, 0x19, 0x75, 0x5a, 0x43, 0x12, 0xef, 0x1e, 0xcc, + 0xdd, 0xc5, 0x07, 0xd8, 0xa6, 0x2e, 0xf6, 0x1a, 0x7b, 0xa6, 0xe3, 0x9b, 0x36, 0xda, 0x0c, 0xf2, + 0xb7, 0xf4, 0x38, 0x67, 0x53, 0xe2, 0x20, 0x54, 0x8f, 0x49, 0x63, 0x02, 0x48, 0x3b, 0x06, 0xf2, + 0x41, 0xf8, 0x0f, 0xbc, 0x33, 0x21, 0x1e, 0x9b, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0x7f, 0x0f, + 0x46, 0x4c, 0xa1, 0x0f, 0x00, 0x00, } diff --git a/pkg/proto/v0/settings.pb.micro.go b/pkg/proto/v0/settings.pb.micro.go index 86e718a15d..b32eac0b1e 100644 --- a/pkg/proto/v0/settings.pb.micro.go +++ b/pkg/proto/v0/settings.pb.micro.go @@ -119,3 +119,73 @@ func (h *bundleServiceHandler) GetSettingsBundle(ctx context.Context, in *GetSet func (h *bundleServiceHandler) ListSettingsBundles(ctx context.Context, in *ListSettingsBundlesRequest, out *ListSettingsBundlesResponse) error { return h.BundleServiceHandler.ListSettingsBundles(ctx, in, out) } + +// Client API for ValueService service + +type ValueService interface { + SaveSettingsValue(ctx context.Context, in *SaveSettingsValueRequest, opts ...client.CallOption) (*SaveSettingsValueResponse, error) + GetSettingsValue(ctx context.Context, in *GetSettingsValueRequest, opts ...client.CallOption) (*GetSettingsValueResponse, error) +} + +type valueService struct { + c client.Client + name string +} + +func NewValueService(name string, c client.Client) ValueService { + return &valueService{ + c: c, + name: name, + } +} + +func (c *valueService) SaveSettingsValue(ctx context.Context, in *SaveSettingsValueRequest, opts ...client.CallOption) (*SaveSettingsValueResponse, error) { + req := c.c.NewRequest(c.name, "ValueService.SaveSettingsValue", in) + out := new(SaveSettingsValueResponse) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *valueService) GetSettingsValue(ctx context.Context, in *GetSettingsValueRequest, opts ...client.CallOption) (*GetSettingsValueResponse, error) { + req := c.c.NewRequest(c.name, "ValueService.GetSettingsValue", in) + out := new(GetSettingsValueResponse) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// Server API for ValueService service + +type ValueServiceHandler interface { + SaveSettingsValue(context.Context, *SaveSettingsValueRequest, *SaveSettingsValueResponse) error + GetSettingsValue(context.Context, *GetSettingsValueRequest, *GetSettingsValueResponse) error +} + +func RegisterValueServiceHandler(s server.Server, hdlr ValueServiceHandler, opts ...server.HandlerOption) error { + type valueService interface { + SaveSettingsValue(ctx context.Context, in *SaveSettingsValueRequest, out *SaveSettingsValueResponse) error + GetSettingsValue(ctx context.Context, in *GetSettingsValueRequest, out *GetSettingsValueResponse) error + } + type ValueService struct { + valueService + } + h := &valueServiceHandler{hdlr} + return s.Handle(s.NewHandler(&ValueService{h}, opts...)) +} + +type valueServiceHandler struct { + ValueServiceHandler +} + +func (h *valueServiceHandler) SaveSettingsValue(ctx context.Context, in *SaveSettingsValueRequest, out *SaveSettingsValueResponse) error { + return h.ValueServiceHandler.SaveSettingsValue(ctx, in, out) +} + +func (h *valueServiceHandler) GetSettingsValue(ctx context.Context, in *GetSettingsValueRequest, out *GetSettingsValueResponse) error { + return h.ValueServiceHandler.GetSettingsValue(ctx, in, out) +} diff --git a/pkg/proto/v0/settings.pb.web.go b/pkg/proto/v0/settings.pb.web.go index f5410c2fed..ee8bcf2542 100644 --- a/pkg/proto/v0/settings.pb.web.go +++ b/pkg/proto/v0/settings.pb.web.go @@ -53,10 +53,10 @@ func (h *webBundleServiceHandler) GetSettingsBundle(w http.ResponseWriter, r *ht resp := &GetSettingsBundleResponse{} - if err := json.NewDecoder(r.Body).Decode(&req); err != nil { - http.Error(w, err.Error(), http.StatusPreconditionFailed) - return - } + //if err := json.NewDecoder(r.Body).Decode(&req); err != nil { + // http.Error(w, err.Error(), http.StatusPreconditionFailed) + // return + //} if err := h.h.GetSettingsBundle( context.Background(), @@ -101,9 +101,76 @@ func RegisterBundleServiceWeb(r chi.Router, i BundleServiceHandler, middlewares h: i, } - r.MethodFunc("POST", "/api/v0/bundles", handler.CreateSettingsBundle) - r.MethodFunc("GET", "/api/v0/bundles/{extension}/{key}", handler.GetSettingsBundle) - r.MethodFunc("GET", "/api/v0/bundles", handler.ListSettingsBundles) + r.MethodFunc("POST", "/api/v0/settings/bundles", handler.CreateSettingsBundle) + r.MethodFunc("GET", "/api/v0/settings/bundles/{extension}/{bundle_key}", handler.GetSettingsBundle) + r.MethodFunc("GET", "/api/v0/settings/bundles", handler.ListSettingsBundles) +} + +type webValueServiceHandler struct { + r chi.Router + h ValueServiceHandler +} + +func (h *webValueServiceHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + h.r.ServeHTTP(w, r) +} + +func (h *webValueServiceHandler) SaveSettingsValue(w http.ResponseWriter, r *http.Request) { + + req := &SaveSettingsValueRequest{} + + resp := &SaveSettingsValueResponse{} + + if err := json.NewDecoder(r.Body).Decode(&req); err != nil { + http.Error(w, err.Error(), http.StatusPreconditionFailed) + return + } + + if err := h.h.SaveSettingsValue( + context.Background(), + req, + resp, + ); err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + + render.Status(r, http.StatusCreated) + render.JSON(w, r, resp) +} + +func (h *webValueServiceHandler) GetSettingsValue(w http.ResponseWriter, r *http.Request) { + + req := &GetSettingsValueRequest{} + + resp := &GetSettingsValueResponse{} + + //if err := json.NewDecoder(r.Body).Decode(&req); err != nil { + // http.Error(w, err.Error(), http.StatusPreconditionFailed) + // return + //} + + if err := h.h.GetSettingsValue( + context.Background(), + req, + resp, + ); err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + + render.Status(r, http.StatusOK) + render.JSON(w, r, resp) +} + +func RegisterValueServiceWeb(r chi.Router, i ValueServiceHandler, middlewares ...func(http.Handler) http.Handler) { + handler := &webValueServiceHandler{ + r: r, + h: i, + } + + r.MethodFunc("POST", "/api/v0/settings/values", handler.SaveSettingsValue) + r.MethodFunc("GET", "/api/v0/settings/values/{account_uuid}/{extension}/{bundle_key}/{setting_key}", handler.GetSettingsValue) } // CreateSettingsBundleRequestJSONMarshaler describes the default jsonpb.Marshaler used by all @@ -322,6 +389,150 @@ func (m *ListSettingsBundlesResponse) UnmarshalJSON(b []byte) error { var _ json.Unmarshaler = (*ListSettingsBundlesResponse)(nil) +// SaveSettingsValueRequestJSONMarshaler describes the default jsonpb.Marshaler used by all +// instances of SaveSettingsValueRequest. This struct is safe to replace or modify but +// should not be done so concurrently. +var SaveSettingsValueRequestJSONMarshaler = new(jsonpb.Marshaler) + +// MarshalJSON satisfies the encoding/json Marshaler interface. This method +// uses the more correct jsonpb package to correctly marshal the message. +func (m *SaveSettingsValueRequest) MarshalJSON() ([]byte, error) { + if m == nil { + return json.Marshal(nil) + } + + buf := &bytes.Buffer{} + + if err := SaveSettingsValueRequestJSONMarshaler.Marshal(buf, m); err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +var _ json.Marshaler = (*SaveSettingsValueRequest)(nil) + +// SaveSettingsValueRequestJSONUnmarshaler describes the default jsonpb.Unmarshaler used by all +// instances of SaveSettingsValueRequest. This struct is safe to replace or modify but +// should not be done so concurrently. +var SaveSettingsValueRequestJSONUnmarshaler = new(jsonpb.Unmarshaler) + +// UnmarshalJSON satisfies the encoding/json Unmarshaler interface. This method +// uses the more correct jsonpb package to correctly unmarshal the message. +func (m *SaveSettingsValueRequest) UnmarshalJSON(b []byte) error { + return SaveSettingsValueRequestJSONUnmarshaler.Unmarshal(bytes.NewReader(b), m) +} + +var _ json.Unmarshaler = (*SaveSettingsValueRequest)(nil) + +// SaveSettingsValueResponseJSONMarshaler describes the default jsonpb.Marshaler used by all +// instances of SaveSettingsValueResponse. This struct is safe to replace or modify but +// should not be done so concurrently. +var SaveSettingsValueResponseJSONMarshaler = new(jsonpb.Marshaler) + +// MarshalJSON satisfies the encoding/json Marshaler interface. This method +// uses the more correct jsonpb package to correctly marshal the message. +func (m *SaveSettingsValueResponse) MarshalJSON() ([]byte, error) { + if m == nil { + return json.Marshal(nil) + } + + buf := &bytes.Buffer{} + + if err := SaveSettingsValueResponseJSONMarshaler.Marshal(buf, m); err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +var _ json.Marshaler = (*SaveSettingsValueResponse)(nil) + +// SaveSettingsValueResponseJSONUnmarshaler describes the default jsonpb.Unmarshaler used by all +// instances of SaveSettingsValueResponse. This struct is safe to replace or modify but +// should not be done so concurrently. +var SaveSettingsValueResponseJSONUnmarshaler = new(jsonpb.Unmarshaler) + +// UnmarshalJSON satisfies the encoding/json Unmarshaler interface. This method +// uses the more correct jsonpb package to correctly unmarshal the message. +func (m *SaveSettingsValueResponse) UnmarshalJSON(b []byte) error { + return SaveSettingsValueResponseJSONUnmarshaler.Unmarshal(bytes.NewReader(b), m) +} + +var _ json.Unmarshaler = (*SaveSettingsValueResponse)(nil) + +// GetSettingsValueRequestJSONMarshaler describes the default jsonpb.Marshaler used by all +// instances of GetSettingsValueRequest. This struct is safe to replace or modify but +// should not be done so concurrently. +var GetSettingsValueRequestJSONMarshaler = new(jsonpb.Marshaler) + +// MarshalJSON satisfies the encoding/json Marshaler interface. This method +// uses the more correct jsonpb package to correctly marshal the message. +func (m *GetSettingsValueRequest) MarshalJSON() ([]byte, error) { + if m == nil { + return json.Marshal(nil) + } + + buf := &bytes.Buffer{} + + if err := GetSettingsValueRequestJSONMarshaler.Marshal(buf, m); err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +var _ json.Marshaler = (*GetSettingsValueRequest)(nil) + +// GetSettingsValueRequestJSONUnmarshaler describes the default jsonpb.Unmarshaler used by all +// instances of GetSettingsValueRequest. This struct is safe to replace or modify but +// should not be done so concurrently. +var GetSettingsValueRequestJSONUnmarshaler = new(jsonpb.Unmarshaler) + +// UnmarshalJSON satisfies the encoding/json Unmarshaler interface. This method +// uses the more correct jsonpb package to correctly unmarshal the message. +func (m *GetSettingsValueRequest) UnmarshalJSON(b []byte) error { + return GetSettingsValueRequestJSONUnmarshaler.Unmarshal(bytes.NewReader(b), m) +} + +var _ json.Unmarshaler = (*GetSettingsValueRequest)(nil) + +// GetSettingsValueResponseJSONMarshaler describes the default jsonpb.Marshaler used by all +// instances of GetSettingsValueResponse. This struct is safe to replace or modify but +// should not be done so concurrently. +var GetSettingsValueResponseJSONMarshaler = new(jsonpb.Marshaler) + +// MarshalJSON satisfies the encoding/json Marshaler interface. This method +// uses the more correct jsonpb package to correctly marshal the message. +func (m *GetSettingsValueResponse) MarshalJSON() ([]byte, error) { + if m == nil { + return json.Marshal(nil) + } + + buf := &bytes.Buffer{} + + if err := GetSettingsValueResponseJSONMarshaler.Marshal(buf, m); err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +var _ json.Marshaler = (*GetSettingsValueResponse)(nil) + +// GetSettingsValueResponseJSONUnmarshaler describes the default jsonpb.Unmarshaler used by all +// instances of GetSettingsValueResponse. This struct is safe to replace or modify but +// should not be done so concurrently. +var GetSettingsValueResponseJSONUnmarshaler = new(jsonpb.Unmarshaler) + +// UnmarshalJSON satisfies the encoding/json Unmarshaler interface. This method +// uses the more correct jsonpb package to correctly unmarshal the message. +func (m *GetSettingsValueResponse) UnmarshalJSON(b []byte) error { + return GetSettingsValueResponseJSONUnmarshaler.Unmarshal(bytes.NewReader(b), m) +} + +var _ json.Unmarshaler = (*GetSettingsValueResponse)(nil) + // SettingsBundleJSONMarshaler describes the default jsonpb.Marshaler used by all // instances of SettingsBundle. This struct is safe to replace or modify but // should not be done so concurrently. @@ -609,3 +820,147 @@ func (m *ListOption) UnmarshalJSON(b []byte) error { } var _ json.Unmarshaler = (*ListOption)(nil) + +// SettingsValueJSONMarshaler describes the default jsonpb.Marshaler used by all +// instances of SettingsValue. This struct is safe to replace or modify but +// should not be done so concurrently. +var SettingsValueJSONMarshaler = new(jsonpb.Marshaler) + +// MarshalJSON satisfies the encoding/json Marshaler interface. This method +// uses the more correct jsonpb package to correctly marshal the message. +func (m *SettingsValue) MarshalJSON() ([]byte, error) { + if m == nil { + return json.Marshal(nil) + } + + buf := &bytes.Buffer{} + + if err := SettingsValueJSONMarshaler.Marshal(buf, m); err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +var _ json.Marshaler = (*SettingsValue)(nil) + +// SettingsValueJSONUnmarshaler describes the default jsonpb.Unmarshaler used by all +// instances of SettingsValue. This struct is safe to replace or modify but +// should not be done so concurrently. +var SettingsValueJSONUnmarshaler = new(jsonpb.Unmarshaler) + +// UnmarshalJSON satisfies the encoding/json Unmarshaler interface. This method +// uses the more correct jsonpb package to correctly unmarshal the message. +func (m *SettingsValue) UnmarshalJSON(b []byte) error { + return SettingsValueJSONUnmarshaler.Unmarshal(bytes.NewReader(b), m) +} + +var _ json.Unmarshaler = (*SettingsValue)(nil) + +// IntListValueJSONMarshaler describes the default jsonpb.Marshaler used by all +// instances of IntListValue. This struct is safe to replace or modify but +// should not be done so concurrently. +var IntListValueJSONMarshaler = new(jsonpb.Marshaler) + +// MarshalJSON satisfies the encoding/json Marshaler interface. This method +// uses the more correct jsonpb package to correctly marshal the message. +func (m *IntListValue) MarshalJSON() ([]byte, error) { + if m == nil { + return json.Marshal(nil) + } + + buf := &bytes.Buffer{} + + if err := IntListValueJSONMarshaler.Marshal(buf, m); err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +var _ json.Marshaler = (*IntListValue)(nil) + +// IntListValueJSONUnmarshaler describes the default jsonpb.Unmarshaler used by all +// instances of IntListValue. This struct is safe to replace or modify but +// should not be done so concurrently. +var IntListValueJSONUnmarshaler = new(jsonpb.Unmarshaler) + +// UnmarshalJSON satisfies the encoding/json Unmarshaler interface. This method +// uses the more correct jsonpb package to correctly unmarshal the message. +func (m *IntListValue) UnmarshalJSON(b []byte) error { + return IntListValueJSONUnmarshaler.Unmarshal(bytes.NewReader(b), m) +} + +var _ json.Unmarshaler = (*IntListValue)(nil) + +// StringListValueJSONMarshaler describes the default jsonpb.Marshaler used by all +// instances of StringListValue. This struct is safe to replace or modify but +// should not be done so concurrently. +var StringListValueJSONMarshaler = new(jsonpb.Marshaler) + +// MarshalJSON satisfies the encoding/json Marshaler interface. This method +// uses the more correct jsonpb package to correctly marshal the message. +func (m *StringListValue) MarshalJSON() ([]byte, error) { + if m == nil { + return json.Marshal(nil) + } + + buf := &bytes.Buffer{} + + if err := StringListValueJSONMarshaler.Marshal(buf, m); err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +var _ json.Marshaler = (*StringListValue)(nil) + +// StringListValueJSONUnmarshaler describes the default jsonpb.Unmarshaler used by all +// instances of StringListValue. This struct is safe to replace or modify but +// should not be done so concurrently. +var StringListValueJSONUnmarshaler = new(jsonpb.Unmarshaler) + +// UnmarshalJSON satisfies the encoding/json Unmarshaler interface. This method +// uses the more correct jsonpb package to correctly unmarshal the message. +func (m *StringListValue) UnmarshalJSON(b []byte) error { + return StringListValueJSONUnmarshaler.Unmarshal(bytes.NewReader(b), m) +} + +var _ json.Unmarshaler = (*StringListValue)(nil) + +// SettingsValuesJSONMarshaler describes the default jsonpb.Marshaler used by all +// instances of SettingsValues. This struct is safe to replace or modify but +// should not be done so concurrently. +var SettingsValuesJSONMarshaler = new(jsonpb.Marshaler) + +// MarshalJSON satisfies the encoding/json Marshaler interface. This method +// uses the more correct jsonpb package to correctly marshal the message. +func (m *SettingsValues) MarshalJSON() ([]byte, error) { + if m == nil { + return json.Marshal(nil) + } + + buf := &bytes.Buffer{} + + if err := SettingsValuesJSONMarshaler.Marshal(buf, m); err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +var _ json.Marshaler = (*SettingsValues)(nil) + +// SettingsValuesJSONUnmarshaler describes the default jsonpb.Unmarshaler used by all +// instances of SettingsValues. This struct is safe to replace or modify but +// should not be done so concurrently. +var SettingsValuesJSONUnmarshaler = new(jsonpb.Unmarshaler) + +// UnmarshalJSON satisfies the encoding/json Unmarshaler interface. This method +// uses the more correct jsonpb package to correctly unmarshal the message. +func (m *SettingsValues) UnmarshalJSON(b []byte) error { + return SettingsValuesJSONUnmarshaler.Unmarshal(bytes.NewReader(b), m) +} + +var _ json.Unmarshaler = (*SettingsValues)(nil) diff --git a/pkg/proto/v0/settings.proto b/pkg/proto/v0/settings.proto index 52d700e0d7..0a4a708cc0 100644 --- a/pkg/proto/v0/settings.proto +++ b/pkg/proto/v0/settings.proto @@ -33,23 +33,37 @@ option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = { service BundleService { rpc CreateSettingsBundle(CreateSettingsBundleRequest) returns (CreateSettingsBundleResponse) { option (google.api.http) = { - post: "/api/v0/bundles", + post: "/api/v0/settings/bundles", body: "*" }; }; rpc GetSettingsBundle(GetSettingsBundleRequest) returns (GetSettingsBundleResponse) { option (google.api.http) = { - get: "/api/v0/bundles/{extension}/{key}" + get: "/api/v0/settings/bundles/{extension}/{bundle_key}" }; }; rpc ListSettingsBundles(ListSettingsBundlesRequest) returns (ListSettingsBundlesResponse) { option (google.api.http) = { - get: "/api/v0/bundles" + get: "/api/v0/settings/bundles" }; }; } -// requests and responses +service ValueService { + rpc SaveSettingsValue(SaveSettingsValueRequest) returns (SaveSettingsValueResponse) { + option (google.api.http) = { + post: "/api/v0/settings/values", + body: "*" + }; + }; + rpc GetSettingsValue(GetSettingsValueRequest) returns (GetSettingsValueResponse) { + option (google.api.http) = { + get: "/api/v0/settings/values/{account_uuid}/{extension}/{bundle_key}/{setting_key}" + }; + }; +} + +// requests and responses for settings bundles message CreateSettingsBundleRequest { SettingsBundle settings_bundle = 1; } @@ -60,7 +74,7 @@ message CreateSettingsBundleResponse { message GetSettingsBundleRequest { string extension = 1; - string key = 2; + string bundle_key = 2; } message GetSettingsBundleResponse { @@ -75,16 +89,36 @@ message ListSettingsBundlesResponse { repeated SettingsBundle settings_bundles = 1; } -// payloads +// requests and responses for settings values +message SaveSettingsValueRequest { + SettingsValue settings_value = 1; +} + +message SaveSettingsValueResponse { + SettingsValue settings_value = 1; +} + +message GetSettingsValueRequest { + string account_uuid = 1; + string extension = 2; + string bundle_key = 3; + string setting_key = 4; +} + +message GetSettingsValueResponse { + SettingsValue settings_value = 1; +} + +// payloads for settings bundles message SettingsBundle { string extension = 1; - string key = 2; + string bundle_key = 2; string display_name = 3; repeated Setting settings = 4; } message Setting { - string key = 1; + string setting_key = 1; string display_name = 2; string description = 3; oneof value { @@ -133,3 +167,31 @@ message ListOption { bool default = 3; string display_value = 4; } + +// payloads for settings values +message SettingsValue { + string account_uuid = 1; + string extension = 2; + string bundle_key = 3; + string setting_key = 4; + oneof value { + bool bool_value = 5; + int64 int_value = 6; + string string_value = 7; + IntListValue int_list_value = 8; + StringListValue string_list_value = 9; + } +} + +message IntListValue { + repeated int64 value = 1; +} + +message StringListValue { + repeated string value = 1; +} + +// only meant for serialization +message SettingsValues { + map values = 1; +} diff --git a/pkg/proto/v0/settings.swagger.json b/pkg/proto/v0/settings.swagger.json index 464fe74b41..4567d64a68 100644 --- a/pkg/proto/v0/settings.swagger.json +++ b/pkg/proto/v0/settings.swagger.json @@ -24,7 +24,7 @@ "application/json" ], "paths": { - "/api/v0/bundles": { + "/api/v0/settings/bundles": { "get": { "operationId": "ListSettingsBundles", "responses": { @@ -84,7 +84,7 @@ ] } }, - "/api/v0/bundles/{extension}/{key}": { + "/api/v0/settings/bundles/{extension}/{bundle_key}": { "get": { "operationId": "GetSettingsBundle", "responses": { @@ -109,7 +109,7 @@ "type": "string" }, { - "name": "key", + "name": "bundle_key", "in": "path", "required": true, "type": "string" @@ -119,6 +119,86 @@ "BundleService" ] } + }, + "/api/v0/settings/values": { + "post": { + "operationId": "SaveSettingsValue", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/protoSaveSettingsValueResponse" + } + }, + "default": { + "description": "An unexpected error response", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/protoSaveSettingsValueRequest" + } + } + ], + "tags": [ + "ValueService" + ] + } + }, + "/api/v0/settings/values/{account_uuid}/{extension}/{bundle_key}/{setting_key}": { + "get": { + "operationId": "GetSettingsValue", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/protoGetSettingsValueResponse" + } + }, + "default": { + "description": "An unexpected error response", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + }, + "parameters": [ + { + "name": "account_uuid", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "extension", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "bundle_key", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "setting_key", + "in": "path", + "required": true, + "type": "string" + } + ], + "tags": [ + "ValueService" + ] + } } }, "definitions": { @@ -141,7 +221,7 @@ "$ref": "#/definitions/protoSettingsBundle" } }, - "title": "requests and responses" + "title": "requests and responses for settings bundles" }, "protoCreateSettingsBundleResponse": { "type": "object", @@ -159,6 +239,26 @@ } } }, + "protoGetSettingsValueResponse": { + "type": "object", + "properties": { + "settings_value": { + "$ref": "#/definitions/protoSettingsValue" + } + } + }, + "protoIntListValue": { + "type": "object", + "properties": { + "value": { + "type": "array", + "items": { + "type": "string", + "format": "int64" + } + } + } + }, "protoIntSetting": { "type": "object", "properties": { @@ -224,10 +324,27 @@ } } }, + "protoSaveSettingsValueRequest": { + "type": "object", + "properties": { + "settings_value": { + "$ref": "#/definitions/protoSettingsValue" + } + }, + "title": "requests and responses for settings values" + }, + "protoSaveSettingsValueResponse": { + "type": "object", + "properties": { + "settings_value": { + "$ref": "#/definitions/protoSettingsValue" + } + } + }, "protoSetting": { "type": "object", "properties": { - "key": { + "setting_key": { "type": "string" }, "display_name": { @@ -259,7 +376,7 @@ "extension": { "type": "string" }, - "key": { + "bundle_key": { "type": "string" }, "display_name": { @@ -272,7 +389,42 @@ } } }, - "title": "payloads" + "title": "payloads for settings bundles" + }, + "protoSettingsValue": { + "type": "object", + "properties": { + "account_uuid": { + "type": "string" + }, + "extension": { + "type": "string" + }, + "bundle_key": { + "type": "string" + }, + "setting_key": { + "type": "string" + }, + "bool_value": { + "type": "boolean", + "format": "boolean" + }, + "int_value": { + "type": "string", + "format": "int64" + }, + "string_value": { + "type": "string" + }, + "int_list_value": { + "$ref": "#/definitions/protoIntListValue" + }, + "string_list_value": { + "$ref": "#/definitions/protoStringListValue" + } + }, + "title": "payloads for settings values" }, "protoSingleChoiceListSetting": { "type": "object", @@ -285,6 +437,17 @@ } } }, + "protoStringListValue": { + "type": "object", + "properties": { + "value": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, "protoStringSetting": { "type": "object", "properties": { diff --git a/pkg/server/grpc/server.go b/pkg/server/grpc/server.go index 039fc6ffec..6b2f0946c0 100644 --- a/pkg/server/grpc/server.go +++ b/pkg/server/grpc/server.go @@ -23,7 +23,10 @@ func Server(opts ...Option) grpc.Service { handle := svc.NewService(options.Config) if err := proto.RegisterBundleServiceHandler(service.Server(), handle); err != nil { - options.Logger.Fatal().Err(err).Msg("could not register service handler") + options.Logger.Fatal().Err(err).Msg("could not register SettingsBundles service handler") + } + if err := proto.RegisterValueServiceHandler(service.Server(), handle); err != nil { + options.Logger.Fatal().Err(err).Msg("could not register SettingsValues service handler") } service.Init() diff --git a/pkg/server/http/server.go b/pkg/server/http/server.go index c8eb37f1b6..9c82d793a6 100644 --- a/pkg/server/http/server.go +++ b/pkg/server/http/server.go @@ -58,10 +58,8 @@ func Server(opts ...Option) http.Service { )) mux.Route(options.Config.HTTP.Root, func(r chi.Router) { - proto.RegisterBundleServiceWeb( - r, - handle, - ) + proto.RegisterBundleServiceWeb(r, handle) + proto.RegisterValueServiceWeb(r, handle) }) service.Handle( diff --git a/pkg/service/v0/service.go b/pkg/service/v0/service.go index 8b87e7e79b..7fe0156d97 100644 --- a/pkg/service/v0/service.go +++ b/pkg/service/v0/service.go @@ -11,8 +11,8 @@ import ( ) type Service struct { - config *config.Config - manager settings.Manager + config *config.Config + manager settings.Manager } // NewService returns a service implementation for Service. @@ -24,7 +24,7 @@ func NewService(cfg *config.Config) Service { } func (g Service) CreateSettingsBundle(c context.Context, req *proto.CreateSettingsBundleRequest, res *proto.CreateSettingsBundleResponse) error { - r, err := g.manager.Write(req.SettingsBundle) + r, err := g.manager.WriteBundle(req.SettingsBundle) if err != nil { return err } @@ -33,7 +33,7 @@ func (g Service) CreateSettingsBundle(c context.Context, req *proto.CreateSettin } func (g Service) GetSettingsBundle(c context.Context, req *proto.GetSettingsBundleRequest, res *proto.GetSettingsBundleResponse) error { - r, err := g.manager.Read(req.Extension, req.Key) + r, err := g.manager.ReadBundle(req.Extension, req.BundleKey) if err != nil { return err } @@ -49,3 +49,21 @@ func (g Service) ListSettingsBundles(c context.Context, req *proto.ListSettingsB res.SettingsBundles = r return nil } + +func (g Service) SaveSettingsValue(c context.Context, req *proto.SaveSettingsValueRequest, res *proto.SaveSettingsValueResponse) error { + r, err := g.manager.WriteValue(req.SettingsValue) + if err != nil { + return err + } + res.SettingsValue = r + return nil +} + +func (g Service) GetSettingsValue(c context.Context, req *proto.GetSettingsValueRequest, res *proto.GetSettingsValueResponse) error { + r, err := g.manager.ReadValue(req.AccountUuid, req.Extension, req.BundleKey, req.SettingKey) + if err != nil { + return err + } + res.SettingsValue = r + return nil +} diff --git a/pkg/settings/settings.go b/pkg/settings/settings.go index b6e8fcc45d..50cfadad60 100644 --- a/pkg/settings/settings.go +++ b/pkg/settings/settings.go @@ -13,9 +13,20 @@ var ( // RegisterFunc stores store constructors type RegisterFunc func(*config.Config) Manager -// Manager type Manager interface { - Read(extension string, key string) (*proto.SettingsBundle, error) - Write(bundle *proto.SettingsBundle) (*proto.SettingsBundle, error) + BundleManager + ValueManager +} + +// BundleManager +type BundleManager interface { + ReadBundle(extension string, bundleKey string) (*proto.SettingsBundle, error) + WriteBundle(bundle *proto.SettingsBundle) (*proto.SettingsBundle, error) ListByExtension(extension string) ([]*proto.SettingsBundle, error) } + +// ValueManager +type ValueManager interface { + ReadValue(accountUuid string, extension string, bundleKey string, settingKey string) (*proto.SettingsValue, error) + WriteValue(value *proto.SettingsValue) (*proto.SettingsValue, error) +} diff --git a/pkg/store/filesystem/bundles.go b/pkg/store/filesystem/bundles.go new file mode 100644 index 0000000000..911ebb10ba --- /dev/null +++ b/pkg/store/filesystem/bundles.go @@ -0,0 +1,73 @@ +// Package store implements the go-micro store interface +package store + +import ( + "github.com/owncloud/ocis-settings/pkg/proto/v0" + "google.golang.org/grpc/codes" + gstatus "google.golang.org/grpc/status" + "io/ioutil" + "path" +) + +// ListByExtension returns all bundles in the mountPath folder belonging to the given extension +func (s Store) ListByExtension(extension string) ([]*proto.SettingsBundle, error) { + bundlesFolder := s.buildFolderPathBundles() + extensionFolders, err := ioutil.ReadDir(bundlesFolder) + if err != nil { + s.Logger.Err(err).Msgf("error reading %v", bundlesFolder) + return nil, err + } + + s.Logger.Info().Msgf("listing bundles by extension %v", extension) + var records []*proto.SettingsBundle + for _, extensionFolder := range extensionFolders { + extensionPath := path.Join(bundlesFolder, extensionFolder.Name()) + bundleFiles, err := ioutil.ReadDir(extensionPath) + if err == nil { + for _, bundleFile := range bundleFiles { + record := proto.SettingsBundle{} + err = s.parseRecordFromFile(&record, path.Join(extensionPath, bundleFile.Name())) + if err == nil && (len(extension) == 0 || extension == record.Extension) { + records = append(records, &record) + } + } + } else { + s.Logger.Err(err).Msgf("error reading %v", extensionPath) + } + } + + return records, nil +} + +// Read tries to find a bundle by the given extension and key within the mountPath +func (s Store) ReadBundle(extension string, bundleKey string) (*proto.SettingsBundle, error) { + if len(extension) < 1 || len(bundleKey) < 1 { + s.Logger.Error().Msg("extension and bundleKey cannot be empty") + return nil, gstatus.Error(codes.InvalidArgument, "Missing a required identifier attribute") + } + + filePath := s.buildFilePathFromBundleArgs(extension, bundleKey) + record := proto.SettingsBundle{} + if err := s.parseRecordFromFile(&record, filePath); err != nil { + return nil, err + } + + s.Logger.Debug().Msgf("read contents from file: %v", filePath) + return &record, nil +} + +// Write writes the given record into a file within the mountPath +func (s Store) WriteBundle(record *proto.SettingsBundle) (*proto.SettingsBundle, error) { + if len(record.Extension) < 1 || len(record.BundleKey) < 1 { + s.Logger.Error().Msg("extension and bundleKey cannot be empty") + return nil, gstatus.Error(codes.InvalidArgument, "Missing a required identifier attribute") + } + + filePath := s.buildFilePathFromBundle(record) + if err := s.writeRecordToFile(record, filePath); err != nil { + return nil, err + } + + s.Logger.Debug().Msgf("request contents written to file: %v", filePath) + return record, nil +} diff --git a/pkg/store/filesystem/paths.go b/pkg/store/filesystem/paths.go index 28b303aeef..fdc8edf221 100644 --- a/pkg/store/filesystem/paths.go +++ b/pkg/store/filesystem/paths.go @@ -7,32 +7,52 @@ import ( ) const folderNameBundles = "bundles" -const folderNameSettings = "settings" +const folderNameValues = "values" // Builds the folder path for storing settings bundles -func buildFolderPathBundles(mountPath string) string { - folderPath := path.Join(mountPath, folderNameBundles) - ensureFolderExists(folderPath) +func (s Store) buildFolderPathBundles() string { + folderPath := path.Join(s.mountPath, folderNameBundles) + s.ensureFolderExists(folderPath) return folderPath } -// Builds a unique file name from the given bundle -func buildFilePathFromBundle(mountPath string, bundle *proto.SettingsBundle) string { - return buildFilePathFromBundleArgs(mountPath, bundle.Extension, bundle.Key) +// Builds a unique file name from the given settings bundle +func (s Store) buildFilePathFromBundle(bundle *proto.SettingsBundle) string { + return s.buildFilePathFromBundleArgs(bundle.Extension, bundle.BundleKey) } // Builds a unique file name from the given params -func buildFilePathFromBundleArgs(mountPath string, extension string, key string) string { - extensionFolder := path.Join(mountPath, folderNameBundles, extension) - if _, err := os.Stat(extensionFolder); os.IsNotExist(err) { - _ = os.MkdirAll(extensionFolder, 0700) - } - return path.Join(extensionFolder, key + ".json") +func (s Store) buildFilePathFromBundleArgs(extension string, bundleKey string) string { + extensionFolder := path.Join(s.mountPath, folderNameBundles, extension) + s.ensureFolderExists(extensionFolder) + return path.Join(extensionFolder, bundleKey+".json") +} + +// Builds the folder path for storing settings values +func (s Store) buildFolderPathValues() string { + folderPath := path.Join(s.mountPath, folderNameValues) + s.ensureFolderExists(folderPath) + return folderPath +} + +// Builds a unique file name from the given settings value +func (s Store) buildFilePathFromValue(value *proto.SettingsValue) string { + return s.buildFilePathFromValueArgs(value.AccountUuid, value.Extension, value.BundleKey) +} + +// Builds a unique file name from the given params +func (s Store) buildFilePathFromValueArgs(accountUuid string, extension string, bundleKey string) string { + extensionFolder := path.Join(s.mountPath, folderNameValues, accountUuid, extension) + s.ensureFolderExists(extensionFolder) + return path.Join(extensionFolder, bundleKey+".json") } // Checks if the given path is an existing folder and creates one if not existing -func ensureFolderExists(path string) { +func (s Store) ensureFolderExists(path string) { if _, err := os.Stat(path); os.IsNotExist(err) { - _ = os.MkdirAll(path, 0700) + err = os.MkdirAll(path, 0700) + if err != nil { + s.Logger.Err(err).Msgf("Error creating folder %v", path) + } } } diff --git a/pkg/store/filesystem/store.go b/pkg/store/filesystem/store.go index 0c63c13f01..f52a27bfbe 100644 --- a/pkg/store/filesystem/store.go +++ b/pkg/store/filesystem/store.go @@ -2,14 +2,11 @@ package store import ( - "fmt" - "io/ioutil" "os" "path" olog "github.com/owncloud/ocis-pkg/v2/log" "github.com/owncloud/ocis-settings/pkg/config" - "github.com/owncloud/ocis-settings/pkg/proto/v0" "github.com/owncloud/ocis-settings/pkg/settings" ) @@ -17,7 +14,6 @@ var ( // StoreName is the default name for the settings store StoreName = "ocis-settings-store" managerName = "filesystem" - emptyKeyError = "key cannot be empty" ) // Store interacts with the filesystem to manage settings information @@ -43,69 +39,6 @@ func New(cfg *config.Config) settings.Manager { return &s } -// ListByExtension returns all bundles in the mountPath folder belonging to the given extension -func (s Store) ListByExtension(extension string) ([]*proto.SettingsBundle, error) { - bundlesFolder := buildFolderPathBundles(s.mountPath) - extensionFolders, err := ioutil.ReadDir(bundlesFolder) - if err != nil { - s.Logger.Err(err).Msgf("error reading %v", bundlesFolder) - return nil, err - } - - s.Logger.Info().Msgf("listing bundles by extension %v", extension) - var records []*proto.SettingsBundle - for _, extensionFolder := range extensionFolders { - extensionPath := path.Join(bundlesFolder, extensionFolder.Name()) - bundleFiles, err := ioutil.ReadDir(extensionPath) - if err == nil { - for _, bundleFile := range bundleFiles { - record := proto.SettingsBundle{} - err = s.parseRecordFromFile(&record, path.Join(extensionPath, bundleFile.Name())) - if err == nil && (len(extension) == 0 || extension == record.Extension) { - records = append(records, &record) - } - } - } else { - s.Logger.Err(err).Msgf("error reading %v", extensionPath) - } - } - - return records, nil -} - -// Read tries to find a bundle by the given extension and key within the mountPath -func (s Store) Read(extension string, key string) (*proto.SettingsBundle, error) { - if len(extension) < 1 || len(key) < 1 { - s.Logger.Error().Msg("extension and key cannot be empty") - return nil, fmt.Errorf(emptyKeyError) - } - - filePath := buildFilePathFromBundleArgs(s.mountPath, extension, key) - record := proto.SettingsBundle{} - if err := s.parseRecordFromFile(&record, filePath); err != nil { - return nil, err - } - - s.Logger.Debug().Msgf("read contents from file: %v", filePath) - return &record, nil -} - -// Write writes the given record into a file within the mountPath -func (s Store) Write(record *proto.SettingsBundle) (*proto.SettingsBundle, error) { - if len(record.Extension) < 1 || len(record.Key) < 1 { - s.Logger.Error().Msg("extension and key cannot be empty") - return nil, fmt.Errorf(emptyKeyError) - } - - filePath := buildFilePathFromBundle(s.mountPath, record) - if err := s.writeRecordToFile(record, filePath); err != nil { - return nil, err - } - - s.Logger.Debug().Msgf("request contents written to file: %v", filePath) - return record, nil -} - func init() { settings.Registry[managerName] = New } diff --git a/pkg/store/filesystem/values.go b/pkg/store/filesystem/values.go new file mode 100644 index 0000000000..2b0177e001 --- /dev/null +++ b/pkg/store/filesystem/values.go @@ -0,0 +1,60 @@ +// Package store implements the go-micro store interface +package store + +import ( + "github.com/owncloud/ocis-settings/pkg/proto/v0" + "google.golang.org/grpc/codes" + gstatus "google.golang.org/grpc/status" + "os" +) + +// Read tries to find a value by the given identifier attributes within the mountPath +func (s Store) ReadValue(accountUuid string, extension string, bundleKey string, settingKey string) (*proto.SettingsValue, error) { + if len(accountUuid) < 1 || len(extension) < 1 || len(bundleKey) < 1 || len(settingKey) < 1 { + s.Logger.Error().Msg("account, extension, bundle and setting are required") + return nil, gstatus.Errorf(codes.InvalidArgument, "Missing a required identifier attribute") + } + + filePath := s.buildFilePathFromValueArgs(accountUuid, extension, bundleKey) + values, err := s.readValuesMapFromFile(filePath) + if err != nil { + return nil, err + } + if value := values.Values[settingKey]; value != nil { + return value, nil + } + // TODO: we want to return sensible defaults here, when the value was not found + return nil, gstatus.Error(codes.NotFound, "SettingsValue not set") +} + +// Write writes the given SettingsValue into a file within the mountPath +func (s Store) WriteValue(value *proto.SettingsValue) (*proto.SettingsValue, error) { + if len(value.AccountUuid) < 1 || len(value.Extension) < 1 || len(value.BundleKey) < 1 || len(value.SettingKey) < 1 { + s.Logger.Error().Msg("account, extension, bundle and setting are required") + return nil, gstatus.Errorf(codes.InvalidArgument, "Missing a required identifier attribute") + } + + filePath := s.buildFilePathFromValue(value) + values, err := s.readValuesMapFromFile(filePath) + if err != nil { + return nil, err + } + values.Values[value.SettingKey] = value + if err := s.writeRecordToFile(values, filePath); err != nil { + return nil, err + } + return value, nil +} + +func (s Store) readValuesMapFromFile(filePath string) (*proto.SettingsValues, error) { + values := &proto.SettingsValues{} + err := s.parseRecordFromFile(values, filePath) + if err != nil { + if os.IsNotExist(err) { + values.Values = map[string]*proto.SettingsValue{} + } else { + return nil, err + } + } + return values, nil +} diff --git a/ui/client/settings/index.js b/ui/client/settings/index.js index a89d34ba05..673cd28170 100644 --- a/ui/client/settings/index.js +++ b/ui/client/settings/index.js @@ -38,7 +38,7 @@ export const request = (method, url, body, queryParameters, form, config) => { export const ListSettingsBundles = function(parameters = {}) { const domain = parameters.$domain ? parameters.$domain : getDomain() const config = parameters.$config - let path = '/api/v0/bundles' + let path = '/api/v0/settings/bundles' let body let queryParameters = {} let form = {} @@ -53,7 +53,7 @@ export const ListSettingsBundles = function(parameters = {}) { return request('get', domain + path, body, queryParameters, form, config) } export const ListSettingsBundles_RAW_URL = function() { - return '/api/v0/bundles' + return '/api/v0/settings/bundles' } export const ListSettingsBundles_TYPE = function() { return 'get' @@ -61,7 +61,7 @@ export const ListSettingsBundles_TYPE = function() { export const ListSettingsBundlesURL = function(parameters = {}) { let queryParameters = {} const domain = parameters.$domain ? parameters.$domain : getDomain() - let path = '/api/v0/bundles' + let path = '/api/v0/settings/bundles' if (parameters['extension'] !== undefined) { queryParameters['extension'] = parameters['extension'] } @@ -84,7 +84,7 @@ export const ListSettingsBundlesURL = function(parameters = {}) { export const CreateSettingsBundle = function(parameters = {}) { const domain = parameters.$domain ? parameters.$domain : getDomain() const config = parameters.$config - let path = '/api/v0/bundles' + let path = '/api/v0/settings/bundles' let body let queryParameters = {} let form = {} @@ -102,7 +102,7 @@ export const CreateSettingsBundle = function(parameters = {}) { return request('post', domain + path, body, queryParameters, form, config) } export const CreateSettingsBundle_RAW_URL = function() { - return '/api/v0/bundles' + return '/api/v0/settings/bundles' } export const CreateSettingsBundle_TYPE = function() { return 'post' @@ -110,7 +110,7 @@ export const CreateSettingsBundle_TYPE = function() { export const CreateSettingsBundleURL = function(parameters = {}) { let queryParameters = {} const domain = parameters.$domain ? parameters.$domain : getDomain() - let path = '/api/v0/bundles' + let path = '/api/v0/settings/bundles' if (parameters.$queryParameters) { Object.keys(parameters.$queryParameters).forEach(function(parameterName) { queryParameters[parameterName] = parameters.$queryParameters[parameterName] @@ -126,12 +126,12 @@ export const CreateSettingsBundleURL = function(parameters = {}) { * method: GetSettingsBundle_TYPE * raw_url: GetSettingsBundle_RAW_URL * @param extension - - * @param key - + * @param bundleKey - */ export const GetSettingsBundle = function(parameters = {}) { const domain = parameters.$domain ? parameters.$domain : getDomain() const config = parameters.$config - let path = '/api/v0/bundles/{extension}/{key}' + let path = '/api/v0/settings/bundles/{extension}/{bundle_key}' let body let queryParameters = {} let form = {} @@ -139,9 +139,9 @@ export const GetSettingsBundle = function(parameters = {}) { if (parameters['extension'] === undefined) { return Promise.reject(new Error('Missing required parameter: extension')) } - path = path.replace('{key}', `${parameters['key']}`) - if (parameters['key'] === undefined) { - return Promise.reject(new Error('Missing required parameter: key')) + path = path.replace('{bundle_key}', `${parameters['bundleKey']}`) + if (parameters['bundleKey'] === undefined) { + return Promise.reject(new Error('Missing required parameter: bundleKey')) } if (parameters.$queryParameters) { Object.keys(parameters.$queryParameters).forEach(function(parameterName) { @@ -151,7 +151,7 @@ export const GetSettingsBundle = function(parameters = {}) { return request('get', domain + path, body, queryParameters, form, config) } export const GetSettingsBundle_RAW_URL = function() { - return '/api/v0/bundles/{extension}/{key}' + return '/api/v0/settings/bundles/{extension}/{bundle_key}' } export const GetSettingsBundle_TYPE = function() { return 'get' @@ -159,9 +159,118 @@ export const GetSettingsBundle_TYPE = function() { export const GetSettingsBundleURL = function(parameters = {}) { let queryParameters = {} const domain = parameters.$domain ? parameters.$domain : getDomain() - let path = '/api/v0/bundles/{extension}/{key}' + let path = '/api/v0/settings/bundles/{extension}/{bundle_key}' path = path.replace('{extension}', `${parameters['extension']}`) - path = path.replace('{key}', `${parameters['key']}`) + path = path.replace('{bundle_key}', `${parameters['bundleKey']}`) + if (parameters.$queryParameters) { + Object.keys(parameters.$queryParameters).forEach(function(parameterName) { + queryParameters[parameterName] = parameters.$queryParameters[parameterName] + }) + } + let keys = Object.keys(queryParameters) + return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '') +} +/** + * + * request: SaveSettingsValue + * url: SaveSettingsValueURL + * method: SaveSettingsValue_TYPE + * raw_url: SaveSettingsValue_RAW_URL + * @param body - + */ +export const SaveSettingsValue = function(parameters = {}) { + const domain = parameters.$domain ? parameters.$domain : getDomain() + const config = parameters.$config + let path = '/api/v0/settings/values' + let body + let queryParameters = {} + let form = {} + if (parameters['body'] !== undefined) { + body = parameters['body'] + } + if (parameters['body'] === undefined) { + return Promise.reject(new Error('Missing required parameter: body')) + } + if (parameters.$queryParameters) { + Object.keys(parameters.$queryParameters).forEach(function(parameterName) { + queryParameters[parameterName] = parameters.$queryParameters[parameterName] + }); + } + return request('post', domain + path, body, queryParameters, form, config) +} +export const SaveSettingsValue_RAW_URL = function() { + return '/api/v0/settings/values' +} +export const SaveSettingsValue_TYPE = function() { + return 'post' +} +export const SaveSettingsValueURL = function(parameters = {}) { + let queryParameters = {} + const domain = parameters.$domain ? parameters.$domain : getDomain() + let path = '/api/v0/settings/values' + if (parameters.$queryParameters) { + Object.keys(parameters.$queryParameters).forEach(function(parameterName) { + queryParameters[parameterName] = parameters.$queryParameters[parameterName] + }) + } + let keys = Object.keys(queryParameters) + return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '') +} +/** + * + * request: GetSettingsValue + * url: GetSettingsValueURL + * method: GetSettingsValue_TYPE + * raw_url: GetSettingsValue_RAW_URL + * @param accountUuid - + * @param extension - + * @param bundleKey - + * @param settingKey - + */ +export const GetSettingsValue = function(parameters = {}) { + const domain = parameters.$domain ? parameters.$domain : getDomain() + const config = parameters.$config + let path = '/api/v0/settings/values/{account_uuid}/{extension}/{bundle_key}/{setting_key}' + let body + let queryParameters = {} + let form = {} + path = path.replace('{account_uuid}', `${parameters['accountUuid']}`) + if (parameters['accountUuid'] === undefined) { + return Promise.reject(new Error('Missing required parameter: accountUuid')) + } + path = path.replace('{extension}', `${parameters['extension']}`) + if (parameters['extension'] === undefined) { + return Promise.reject(new Error('Missing required parameter: extension')) + } + path = path.replace('{bundle_key}', `${parameters['bundleKey']}`) + if (parameters['bundleKey'] === undefined) { + return Promise.reject(new Error('Missing required parameter: bundleKey')) + } + path = path.replace('{setting_key}', `${parameters['settingKey']}`) + if (parameters['settingKey'] === undefined) { + return Promise.reject(new Error('Missing required parameter: settingKey')) + } + if (parameters.$queryParameters) { + Object.keys(parameters.$queryParameters).forEach(function(parameterName) { + queryParameters[parameterName] = parameters.$queryParameters[parameterName] + }); + } + return request('get', domain + path, body, queryParameters, form, config) +} +export const GetSettingsValue_RAW_URL = function() { + return '/api/v0/settings/values/{account_uuid}/{extension}/{bundle_key}/{setting_key}' +} +export const GetSettingsValue_TYPE = function() { + return 'get' +} +export const GetSettingsValueURL = function(parameters = {}) { + let queryParameters = {} + const domain = parameters.$domain ? parameters.$domain : getDomain() + let path = '/api/v0/settings/values/{account_uuid}/{extension}/{bundle_key}/{setting_key}' + path = path.replace('{account_uuid}', `${parameters['accountUuid']}`) + path = path.replace('{extension}', `${parameters['extension']}`) + path = path.replace('{bundle_key}', `${parameters['bundleKey']}`) + path = path.replace('{setting_key}', `${parameters['settingKey']}`) if (parameters.$queryParameters) { Object.keys(parameters.$queryParameters).forEach(function(parameterName) { queryParameters[parameterName] = parameters.$queryParameters[parameterName]