Add missing gRPC functions

This commit is contained in:
2022-08-11 17:14:21 +02:00
parent 26090e9299
commit 6530d024f8
12 changed files with 448 additions and 164 deletions

View File

@@ -46,12 +46,18 @@ func (lc LocalAuth) ToStorageType() storage.LocalAuth {
}
}
func AccountFromStorageType(account *storage.Account) *Account {
func AccountFromStorageType(account *storage.Account) (*Account, error) {
lc := LocalAuthFromStorageType(account.Authentication.Local)
data, err := structpb.NewStruct(account.Data)
d, err := sanitizeData(account.Data)
if err != nil {
return nil
return nil, err
}
data, err := structpb.NewStruct(d)
if err != nil {
fmt.Println(err)
return nil, err
}
return &Account{
@@ -61,7 +67,7 @@ func AccountFromStorageType(account *storage.Account) *Account {
Authentication: &AccountAuth{
Local: lc,
},
}
}, nil
}
func LocalAuthFromStorageType(lc storage.LocalAuth) *LocalAuth {
@@ -72,3 +78,16 @@ func LocalAuthFromStorageType(lc storage.LocalAuth) *LocalAuth {
PhoneNumber: lc.PhoneNumber,
}
}
func sanitizeData(data map[string]any) (d map[string]any, err error) {
j, err := json.Marshal(data)
if err != nil {
return nil, err
}
if err = json.Unmarshal(j, &d); err != nil {
return nil, err
}
return d, nil
}

View File

@@ -524,6 +524,100 @@ func (x *GetAccountsResponse) GetAccounts() []*Account {
return nil
}
type GetAccountsBatchRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Accountids []string `protobuf:"bytes,13,rep,name=accountids,proto3" json:"accountids,omitempty"` // Filter on namespaces
}
func (x *GetAccountsBatchRequest) Reset() {
*x = GetAccountsBatchRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_comasvc_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetAccountsBatchRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetAccountsBatchRequest) ProtoMessage() {}
func (x *GetAccountsBatchRequest) ProtoReflect() protoreflect.Message {
mi := &file_comasvc_proto_msgTypes[10]
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 GetAccountsBatchRequest.ProtoReflect.Descriptor instead.
func (*GetAccountsBatchRequest) Descriptor() ([]byte, []int) {
return file_comasvc_proto_rawDescGZIP(), []int{10}
}
func (x *GetAccountsBatchRequest) GetAccountids() []string {
if x != nil {
return x.Accountids
}
return nil
}
type GetAccountsBatchResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Accounts []*Account `protobuf:"bytes,14,rep,name=accounts,proto3" json:"accounts,omitempty"`
}
func (x *GetAccountsBatchResponse) Reset() {
*x = GetAccountsBatchResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_comasvc_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetAccountsBatchResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetAccountsBatchResponse) ProtoMessage() {}
func (x *GetAccountsBatchResponse) ProtoReflect() protoreflect.Message {
mi := &file_comasvc_proto_msgTypes[11]
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 GetAccountsBatchResponse.ProtoReflect.Descriptor instead.
func (*GetAccountsBatchResponse) Descriptor() ([]byte, []int) {
return file_comasvc_proto_rawDescGZIP(), []int{11}
}
func (x *GetAccountsBatchResponse) GetAccounts() []*Account {
if x != nil {
return x.Accounts
}
return nil
}
type ChangePasswordRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -536,7 +630,7 @@ type ChangePasswordRequest struct {
func (x *ChangePasswordRequest) Reset() {
*x = ChangePasswordRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_comasvc_proto_msgTypes[10]
mi := &file_comasvc_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -549,7 +643,7 @@ func (x *ChangePasswordRequest) String() string {
func (*ChangePasswordRequest) ProtoMessage() {}
func (x *ChangePasswordRequest) ProtoReflect() protoreflect.Message {
mi := &file_comasvc_proto_msgTypes[10]
mi := &file_comasvc_proto_msgTypes[12]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -562,7 +656,7 @@ func (x *ChangePasswordRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use ChangePasswordRequest.ProtoReflect.Descriptor instead.
func (*ChangePasswordRequest) Descriptor() ([]byte, []int) {
return file_comasvc_proto_rawDescGZIP(), []int{10}
return file_comasvc_proto_rawDescGZIP(), []int{12}
}
func (x *ChangePasswordRequest) GetId() string {
@@ -588,7 +682,7 @@ type ChangePasswordResponse struct {
func (x *ChangePasswordResponse) Reset() {
*x = ChangePasswordResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_comasvc_proto_msgTypes[11]
mi := &file_comasvc_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -601,7 +695,7 @@ func (x *ChangePasswordResponse) String() string {
func (*ChangePasswordResponse) ProtoMessage() {}
func (x *ChangePasswordResponse) ProtoReflect() protoreflect.Message {
mi := &file_comasvc_proto_msgTypes[11]
mi := &file_comasvc_proto_msgTypes[13]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -614,7 +708,7 @@ func (x *ChangePasswordResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use ChangePasswordResponse.ProtoReflect.Descriptor instead.
func (*ChangePasswordResponse) Descriptor() ([]byte, []int) {
return file_comasvc_proto_rawDescGZIP(), []int{11}
return file_comasvc_proto_rawDescGZIP(), []int{13}
}
var File_comasvc_proto protoreflect.FileDescriptor
@@ -662,39 +756,52 @@ var file_comasvc_proto_rawDesc = []byte{
0x65, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x24, 0x0a, 0x08, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x18, 0x0e,
0x20, 0x03, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x08,
0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x22, 0x43, 0x0a, 0x15, 0x43, 0x68, 0x61, 0x6e,
0x67, 0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69,
0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x10, 0x20,
0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x18, 0x0a,
0x16, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xe2, 0x02, 0x0a, 0x10, 0x4d, 0x6f, 0x62, 0x69,
0x6c, 0x69, 0x74, 0x79, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x12, 0x31, 0x0a, 0x08,
0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x10, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73,
0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x52, 0x65, 0x67,
0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
0x37, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x44, 0x61, 0x74, 0x61, 0x12, 0x12, 0x2e,
0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x13, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x37, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x41,
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f,
0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x47, 0x65, 0x74,
0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
0x00, 0x12, 0x3a, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73,
0x12, 0x13, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75,
0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x28, 0x0a,
0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x0d, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0e, 0x43, 0x68, 0x61, 0x6e, 0x67,
0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x16, 0x2e, 0x43, 0x68, 0x61, 0x6e,
0x67, 0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x17, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f,
0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x39, 0x5a, 0x37,
0x67, 0x69, 0x74, 0x2e, 0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x2e, 0x69, 0x6f, 0x2f, 0x63, 0x6f,
0x6f, 0x70, 0x67, 0x6f, 0x2d, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x2f, 0x6d, 0x6f,
0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2d, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f,
0x67, 0x72, 0x70, 0x63, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x22, 0x39, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x41,
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x64,
0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74,
0x69, 0x64, 0x73, 0x22, 0x40, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e,
0x74, 0x73, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x24, 0x0a, 0x08, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x18, 0x0e, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x08, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x08, 0x61, 0x63, 0x63,
0x6f, 0x75, 0x6e, 0x74, 0x73, 0x22, 0x43, 0x0a, 0x15, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50,
0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e,
0x0a, 0x02, 0x69, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a,
0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x10, 0x20, 0x01, 0x28, 0x09,
0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x18, 0x0a, 0x16, 0x43, 0x68,
0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x32, 0xad, 0x03, 0x0a, 0x10, 0x4d, 0x6f, 0x62, 0x69, 0x6c, 0x69, 0x74,
0x79, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x12, 0x31, 0x0a, 0x08, 0x52, 0x65, 0x67,
0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x10, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74,
0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x37, 0x0a, 0x0a,
0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x44, 0x61, 0x74, 0x61, 0x12, 0x12, 0x2e, 0x55, 0x70, 0x64,
0x61, 0x74, 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13,
0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x37, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f,
0x75, 0x6e, 0x74, 0x12, 0x12, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63,
0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3a,
0x0a, 0x0b, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x12, 0x13, 0x2e,
0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x14, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x49, 0x0a, 0x10, 0x47, 0x65,
0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x42, 0x61, 0x74, 0x63, 0x68, 0x12, 0x18,
0x2e, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x42, 0x61, 0x74, 0x63,
0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x63,
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x28, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x0d,
0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e,
0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
0x43, 0x0a, 0x0e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72,
0x64, 0x12, 0x16, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f,
0x72, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x43, 0x68, 0x61, 0x6e,
0x67, 0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x22, 0x00, 0x42, 0x39, 0x5a, 0x37, 0x67, 0x69, 0x74, 0x2e, 0x63, 0x6f, 0x6f, 0x70,
0x67, 0x6f, 0x2e, 0x69, 0x6f, 0x2f, 0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x2d, 0x70, 0x6c, 0x61,
0x74, 0x66, 0x6f, 0x72, 0x6d, 0x2f, 0x6d, 0x6f, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2d, 0x61,
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x61, 0x70, 0x69, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -709,47 +816,52 @@ func file_comasvc_proto_rawDescGZIP() []byte {
return file_comasvc_proto_rawDescData
}
var file_comasvc_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_comasvc_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
var file_comasvc_proto_goTypes = []interface{}{
(*LoginRequest)(nil), // 0: LoginRequest
(*LoginResponse)(nil), // 1: LoginResponse
(*RegisterRequest)(nil), // 2: RegisterRequest
(*RegisterResponse)(nil), // 3: RegisterResponse
(*UpdateDataRequest)(nil), // 4: UpdateDataRequest
(*UpdateDataResponse)(nil), // 5: UpdateDataResponse
(*GetAccountRequest)(nil), // 6: GetAccountRequest
(*GetAccountResponse)(nil), // 7: GetAccountResponse
(*GetAccountsRequest)(nil), // 8: GetAccountsRequest
(*GetAccountsResponse)(nil), // 9: GetAccountsResponse
(*ChangePasswordRequest)(nil), // 10: ChangePasswordRequest
(*ChangePasswordResponse)(nil), // 11: ChangePasswordResponse
(*Account)(nil), // 12: Account
(*LoginRequest)(nil), // 0: LoginRequest
(*LoginResponse)(nil), // 1: LoginResponse
(*RegisterRequest)(nil), // 2: RegisterRequest
(*RegisterResponse)(nil), // 3: RegisterResponse
(*UpdateDataRequest)(nil), // 4: UpdateDataRequest
(*UpdateDataResponse)(nil), // 5: UpdateDataResponse
(*GetAccountRequest)(nil), // 6: GetAccountRequest
(*GetAccountResponse)(nil), // 7: GetAccountResponse
(*GetAccountsRequest)(nil), // 8: GetAccountsRequest
(*GetAccountsResponse)(nil), // 9: GetAccountsResponse
(*GetAccountsBatchRequest)(nil), // 10: GetAccountsBatchRequest
(*GetAccountsBatchResponse)(nil), // 11: GetAccountsBatchResponse
(*ChangePasswordRequest)(nil), // 12: ChangePasswordRequest
(*ChangePasswordResponse)(nil), // 13: ChangePasswordResponse
(*Account)(nil), // 14: Account
}
var file_comasvc_proto_depIdxs = []int32{
12, // 0: LoginResponse.account:type_name -> Account
12, // 1: RegisterRequest.account:type_name -> Account
12, // 2: RegisterResponse.account:type_name -> Account
12, // 3: UpdateDataRequest.account:type_name -> Account
12, // 4: UpdateDataResponse.account:type_name -> Account
12, // 5: GetAccountResponse.account:type_name -> Account
12, // 6: GetAccountsResponse.accounts:type_name -> Account
2, // 7: MobilityAccounts.Register:input_type -> RegisterRequest
4, // 8: MobilityAccounts.UpdateData:input_type -> UpdateDataRequest
6, // 9: MobilityAccounts.GetAccount:input_type -> GetAccountRequest
8, // 10: MobilityAccounts.GetAccounts:input_type -> GetAccountsRequest
0, // 11: MobilityAccounts.Login:input_type -> LoginRequest
10, // 12: MobilityAccounts.ChangePassword:input_type -> ChangePasswordRequest
3, // 13: MobilityAccounts.Register:output_type -> RegisterResponse
5, // 14: MobilityAccounts.UpdateData:output_type -> UpdateDataResponse
7, // 15: MobilityAccounts.GetAccount:output_type -> GetAccountResponse
9, // 16: MobilityAccounts.GetAccounts:output_type -> GetAccountsResponse
1, // 17: MobilityAccounts.Login:output_type -> LoginResponse
11, // 18: MobilityAccounts.ChangePassword:output_type -> ChangePasswordResponse
13, // [13:19] is the sub-list for method output_type
7, // [7:13] is the sub-list for method input_type
7, // [7:7] is the sub-list for extension type_name
7, // [7:7] is the sub-list for extension extendee
0, // [0:7] is the sub-list for field type_name
14, // 0: LoginResponse.account:type_name -> Account
14, // 1: RegisterRequest.account:type_name -> Account
14, // 2: RegisterResponse.account:type_name -> Account
14, // 3: UpdateDataRequest.account:type_name -> Account
14, // 4: UpdateDataResponse.account:type_name -> Account
14, // 5: GetAccountResponse.account:type_name -> Account
14, // 6: GetAccountsResponse.accounts:type_name -> Account
14, // 7: GetAccountsBatchResponse.accounts:type_name -> Account
2, // 8: MobilityAccounts.Register:input_type -> RegisterRequest
4, // 9: MobilityAccounts.UpdateData:input_type -> UpdateDataRequest
6, // 10: MobilityAccounts.GetAccount:input_type -> GetAccountRequest
8, // 11: MobilityAccounts.GetAccounts:input_type -> GetAccountsRequest
10, // 12: MobilityAccounts.GetAccountsBatch:input_type -> GetAccountsBatchRequest
0, // 13: MobilityAccounts.Login:input_type -> LoginRequest
12, // 14: MobilityAccounts.ChangePassword:input_type -> ChangePasswordRequest
3, // 15: MobilityAccounts.Register:output_type -> RegisterResponse
5, // 16: MobilityAccounts.UpdateData:output_type -> UpdateDataResponse
7, // 17: MobilityAccounts.GetAccount:output_type -> GetAccountResponse
9, // 18: MobilityAccounts.GetAccounts:output_type -> GetAccountsResponse
11, // 19: MobilityAccounts.GetAccountsBatch:output_type -> GetAccountsBatchResponse
1, // 20: MobilityAccounts.Login:output_type -> LoginResponse
13, // 21: MobilityAccounts.ChangePassword:output_type -> ChangePasswordResponse
15, // [15:22] is the sub-list for method output_type
8, // [8:15] is the sub-list for method input_type
8, // [8:8] is the sub-list for extension type_name
8, // [8:8] is the sub-list for extension extendee
0, // [0:8] is the sub-list for field type_name
}
func init() { file_comasvc_proto_init() }
@@ -880,7 +992,7 @@ func file_comasvc_proto_init() {
}
}
file_comasvc_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ChangePasswordRequest); i {
switch v := v.(*GetAccountsBatchRequest); i {
case 0:
return &v.state
case 1:
@@ -892,6 +1004,30 @@ func file_comasvc_proto_init() {
}
}
file_comasvc_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetAccountsBatchResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_comasvc_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ChangePasswordRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_comasvc_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ChangePasswordResponse); i {
case 0:
return &v.state
@@ -910,7 +1046,7 @@ func file_comasvc_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_comasvc_proto_rawDesc,
NumEnums: 0,
NumMessages: 12,
NumMessages: 14,
NumExtensions: 0,
NumServices: 1,
},

View File

@@ -11,6 +11,7 @@ service MobilityAccounts {
rpc UpdateData(UpdateDataRequest) returns (UpdateDataResponse) {}
rpc GetAccount(GetAccountRequest) returns (GetAccountResponse) {}
rpc GetAccounts(GetAccountsRequest) returns (GetAccountsResponse) {}
rpc GetAccountsBatch(GetAccountsBatchRequest) returns (GetAccountsBatchResponse) {}
// Authentication functions
rpc Login(LoginRequest) returns (LoginResponse) {}
@@ -61,6 +62,14 @@ message GetAccountsResponse {
repeated Account accounts = 14;
}
message GetAccountsBatchRequest {
repeated string accountids = 13; // Filter on namespaces
}
message GetAccountsBatchResponse {
repeated Account accounts = 14;
}
message ChangePasswordRequest {
string id = 15;
string password = 16;

View File

@@ -26,6 +26,7 @@ type MobilityAccountsClient interface {
UpdateData(ctx context.Context, in *UpdateDataRequest, opts ...grpc.CallOption) (*UpdateDataResponse, error)
GetAccount(ctx context.Context, in *GetAccountRequest, opts ...grpc.CallOption) (*GetAccountResponse, error)
GetAccounts(ctx context.Context, in *GetAccountsRequest, opts ...grpc.CallOption) (*GetAccountsResponse, error)
GetAccountsBatch(ctx context.Context, in *GetAccountsBatchRequest, opts ...grpc.CallOption) (*GetAccountsBatchResponse, error)
// Authentication functions
Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error)
ChangePassword(ctx context.Context, in *ChangePasswordRequest, opts ...grpc.CallOption) (*ChangePasswordResponse, error)
@@ -75,6 +76,15 @@ func (c *mobilityAccountsClient) GetAccounts(ctx context.Context, in *GetAccount
return out, nil
}
func (c *mobilityAccountsClient) GetAccountsBatch(ctx context.Context, in *GetAccountsBatchRequest, opts ...grpc.CallOption) (*GetAccountsBatchResponse, error) {
out := new(GetAccountsBatchResponse)
err := c.cc.Invoke(ctx, "/MobilityAccounts/GetAccountsBatch", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *mobilityAccountsClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) {
out := new(LoginResponse)
err := c.cc.Invoke(ctx, "/MobilityAccounts/Login", in, out, opts...)
@@ -101,6 +111,7 @@ type MobilityAccountsServer interface {
UpdateData(context.Context, *UpdateDataRequest) (*UpdateDataResponse, error)
GetAccount(context.Context, *GetAccountRequest) (*GetAccountResponse, error)
GetAccounts(context.Context, *GetAccountsRequest) (*GetAccountsResponse, error)
GetAccountsBatch(context.Context, *GetAccountsBatchRequest) (*GetAccountsBatchResponse, error)
// Authentication functions
Login(context.Context, *LoginRequest) (*LoginResponse, error)
ChangePassword(context.Context, *ChangePasswordRequest) (*ChangePasswordResponse, error)
@@ -123,6 +134,9 @@ func (UnimplementedMobilityAccountsServer) GetAccount(context.Context, *GetAccou
func (UnimplementedMobilityAccountsServer) GetAccounts(context.Context, *GetAccountsRequest) (*GetAccountsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetAccounts not implemented")
}
func (UnimplementedMobilityAccountsServer) GetAccountsBatch(context.Context, *GetAccountsBatchRequest) (*GetAccountsBatchResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetAccountsBatch not implemented")
}
func (UnimplementedMobilityAccountsServer) Login(context.Context, *LoginRequest) (*LoginResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Login not implemented")
}
@@ -214,6 +228,24 @@ func _MobilityAccounts_GetAccounts_Handler(srv interface{}, ctx context.Context,
return interceptor(ctx, in, info, handler)
}
func _MobilityAccounts_GetAccountsBatch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetAccountsBatchRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MobilityAccountsServer).GetAccountsBatch(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/MobilityAccounts/GetAccountsBatch",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MobilityAccountsServer).GetAccountsBatch(ctx, req.(*GetAccountsBatchRequest))
}
return interceptor(ctx, in, info, handler)
}
func _MobilityAccounts_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(LoginRequest)
if err := dec(in); err != nil {
@@ -273,6 +305,10 @@ var MobilityAccounts_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetAccounts",
Handler: _MobilityAccounts_GetAccounts_Handler,
},
{
MethodName: "GetAccountsBatch",
Handler: _MobilityAccounts_GetAccountsBatch_Handler,
},
{
MethodName: "Login",
Handler: _MobilityAccounts_Login_Handler,

View File

@@ -29,7 +29,11 @@ func (s MobilityAccountsServerImpl) Login(ctx context.Context, req *LoginRequest
if err != nil {
return nil, status.Errorf(codes.NotFound, "could not log in : %v", err)
}
response := AccountFromStorageType(account)
response, err := AccountFromStorageType(account)
if err != nil {
fmt.Println(err)
return nil, status.Errorf(codes.Internal, "issue while retrieving account : %v", err)
}
return &LoginResponse{Account: response}, nil
}
func (s MobilityAccountsServerImpl) Register(ctx context.Context, req *RegisterRequest) (*RegisterResponse, error) {
@@ -39,14 +43,38 @@ func (s MobilityAccountsServerImpl) Register(ctx context.Context, req *RegisterR
fmt.Println(err)
return nil, status.Errorf(codes.AlreadyExists, "account creation failed : %v", err)
}
response := AccountFromStorageType(account)
response, err := AccountFromStorageType(account)
if err != nil {
fmt.Println(err)
return nil, status.Errorf(codes.Internal, "issue while retrieving account : %v", err)
}
return &RegisterResponse{Account: response}, nil
}
func (MobilityAccountsServerImpl) UpdateData(context.Context, *UpdateDataRequest) (*UpdateDataResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateData not implemented")
func (s MobilityAccountsServerImpl) UpdateData(ctx context.Context, req *UpdateDataRequest) (*UpdateDataResponse, error) {
a := req.Account.ToStorageType()
account, err := s.handler.UpdateData(a.ID, a.Data)
if err != nil {
return nil, status.Errorf(codes.Internal, "issue while apdating account : %v", err)
}
response, err := AccountFromStorageType(account)
if err != nil {
fmt.Println(err)
return nil, status.Errorf(codes.Internal, "issue while retrieving account : %v", err)
}
return &UpdateDataResponse{Account: response}, nil
}
func (MobilityAccountsServerImpl) GetAccount(context.Context, *GetAccountRequest) (*GetAccountResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetAccount not implemented")
func (s MobilityAccountsServerImpl) GetAccount(ctx context.Context, req *GetAccountRequest) (*GetAccountResponse, error) {
account, err := s.handler.GetAccount(req.Id)
if err != nil {
fmt.Println(err)
return nil, status.Errorf(codes.AlreadyExists, "issue while retrieving account : %v", err)
}
response, err := AccountFromStorageType(account)
if err != nil {
fmt.Println(err)
return nil, status.Errorf(codes.Internal, "issue while retrieving account : %v", err)
}
return &GetAccountResponse{Account: response}, nil
}
func (s MobilityAccountsServerImpl) GetAccounts(ctx context.Context, req *GetAccountsRequest) (*GetAccountsResponse, error) {
responses, err := s.handler.GetAccounts(req.Namespaces)
@@ -54,11 +82,32 @@ func (s MobilityAccountsServerImpl) GetAccounts(ctx context.Context, req *GetAcc
return nil, status.Errorf(codes.NotFound, "could not get accounts : %v", err)
}
var accounts []*Account
for _, a := range responses {
accounts = append(accounts, AccountFromStorageType(&a))
account, err := AccountFromStorageType(&a)
if err != nil {
return nil, status.Errorf(codes.Internal, "could not get accounts : %v", err)
}
accounts = append(accounts, account)
}
return &GetAccountsResponse{Accounts: accounts}, nil
}
func (s MobilityAccountsServerImpl) GetAccountsBatch(ctx context.Context, req *GetAccountsBatchRequest) (*GetAccountsBatchResponse, error) {
responses, err := s.handler.GetAccountsBatch(req.Accountids)
if err != nil {
return nil, status.Errorf(codes.NotFound, "could not get accounts : %v", err)
}
var accounts []*Account
for _, a := range responses {
account, err := AccountFromStorageType(&a)
if err != nil {
return nil, status.Errorf(codes.Internal, "could not get accounts : %v", err)
}
accounts = append(accounts, account)
}
return &GetAccountsBatchResponse{Accounts: accounts}, nil
}
func (MobilityAccountsServerImpl) ChangePassword(ctc context.Context, req *ChangePasswordRequest) (*ChangePasswordResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method not implemented")
}