From 5278ae217fc6e60f1f02b0ec997e132d7240e532 Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Mon, 23 Sep 2019 20:56:05 +0200 Subject: [PATCH] Prefix user grpc service & messages, add role finder --- codegen.sh | 2 +- compose/service/system_role.go | 41 ++++++ compose/service/system_user.go | 4 +- system/grpc/roles_service.go | 45 ++++++ system/grpc/server.go | 4 + system/grpc/users_service.go | 8 +- system/proto/role.pb.go | 254 +++++++++++++++++++++++++++++++++ system/proto/user.pb.go | 208 +++++++++++++-------------- 8 files changed, 455 insertions(+), 111 deletions(-) create mode 100644 compose/service/system_role.go create mode 100644 system/grpc/roles_service.go create mode 100644 system/proto/role.pb.go diff --git a/codegen.sh b/codegen.sh index abcb041e6..5a64ccdb8 100755 --- a/codegen.sh +++ b/codegen.sh @@ -189,7 +189,7 @@ function proto { PATH=$PATH:$GOPATH/bin protoc \ --proto_path ${CORTEZA_PROTOBUF_PATH}/system \ --go_out=plugins=grpc:system/proto \ - user.proto mail_message.proto + user.proto role.proto mail_message.proto green "OK" } diff --git a/compose/service/system_role.go b/compose/service/system_role.go new file mode 100644 index 000000000..6386e7541 --- /dev/null +++ b/compose/service/system_role.go @@ -0,0 +1,41 @@ +package service + +import ( + "context" + + "github.com/cortezaproject/corteza-server/system/proto" + "github.com/cortezaproject/corteza-server/system/types" +) + +// gRPC client for + +type ( + systemRole struct { + client proto.RolesClient + } +) + +func SystemRole(c proto.RolesClient) *systemRole { + return &systemRole{ + client: c, + } +} + +func (svc systemRole) Find(ctx context.Context, ID uint64) (rr types.RoleSet, err error) { + rsp, err := svc.client.Find(ctx, &proto.FindRoleRequest{}) + if err != nil { + return nil, err + } + + rr = make([]*types.Role, len(rsp.Roles)) + + for i := range rsp.Roles { + rr[i] = &types.Role{ + ID: rsp.Roles[i].ID, + Name: rsp.Roles[i].Name, + Handle: rsp.Roles[i].Handle, + } + } + + return rr, nil +} diff --git a/compose/service/system_user.go b/compose/service/system_user.go index 3a05aef09..7a5dcd4b3 100644 --- a/compose/service/system_user.go +++ b/compose/service/system_user.go @@ -30,7 +30,7 @@ func (svc systemUser) MakeJWT(ctx context.Context, ID uint64) (string, error) { "jwt": []string{auth.GetJwtFromContext(ctx)}, }) - rsp, err := svc.client.MakeJWT(ctx, &proto.MakeJWTRequest{UserID: ID}, grpc.WaitForReady(true)) + rsp, err := svc.client.MakeJWT(ctx, &proto.MakeJWTUserRequest{UserID: ID}, grpc.WaitForReady(true)) if err != nil { return "", err } @@ -39,7 +39,7 @@ func (svc systemUser) MakeJWT(ctx context.Context, ID uint64) (string, error) { } func (svc systemUser) FindByID(ctx context.Context, ID uint64) (*types.User, error) { - rsp, err := svc.client.FindByID(ctx, &proto.FindByIDRequest{UserID: ID}) + rsp, err := svc.client.FindByID(ctx, &proto.FindByIDUserRequest{UserID: ID}) if err != nil { return nil, err } diff --git a/system/grpc/roles_service.go b/system/grpc/roles_service.go new file mode 100644 index 000000000..474a7f71a --- /dev/null +++ b/system/grpc/roles_service.go @@ -0,0 +1,45 @@ +package grpc + +import ( + "context" + + "github.com/cortezaproject/corteza-server/system/proto" + "github.com/cortezaproject/corteza-server/system/service" + "github.com/cortezaproject/corteza-server/system/types" +) + +type ( + roleService struct { + roles service.RoleService + } +) + +func NewRoleService(roles service.RoleService) *roleService { + return &roleService{ + roles: roles, + } +} + +func (gs roleService) Find(ctx context.Context, req *proto.FindRoleRequest) (rsp *proto.FindRoleResponse, err error) { + var ( + rr types.RoleSet + ) + + if rr, err = gs.roles.Find(&types.RoleFilter{}); err != nil { + return + } + + rsp = &proto.FindRoleResponse{ + Roles: make([]*proto.Role, len(rr)), + } + + for i := range rr { + rsp.Roles[i] = &proto.Role{ + ID: rr[i].ID, + Handle: rr[i].Handle, + Name: rr[i].Name, + } + } + + return +} diff --git a/system/grpc/server.go b/system/grpc/server.go index d30d217d0..153d647dd 100644 --- a/system/grpc/server.go +++ b/system/grpc/server.go @@ -27,6 +27,10 @@ func NewServer() *grpc.Server { service.DefaultAccessControl, )) + proto.RegisterRolesServer(s, NewRoleService( + service.DefaultRole, + )) + return s } diff --git a/system/grpc/users_service.go b/system/grpc/users_service.go index e9a9a4800..d0c14fb82 100644 --- a/system/grpc/users_service.go +++ b/system/grpc/users_service.go @@ -34,7 +34,7 @@ func NewUserService(users service.UserService, auth service.AuthService, jwt aut } } -func (gs userService) MakeJWT(ctx context.Context, req *proto.MakeJWTRequest) (rsp *proto.MakeJWTResponse, err error) { +func (gs userService) MakeJWT(ctx context.Context, req *proto.MakeJWTUserRequest) (rsp *proto.MakeJWTUserResponse, err error) { var ( u *types.User ) @@ -51,14 +51,14 @@ func (gs userService) MakeJWT(ctx context.Context, req *proto.MakeJWTRequest) (r return } - rsp = &proto.MakeJWTResponse{ + rsp = &proto.MakeJWTUserResponse{ JWT: gs.jwt.Encode(u), } return } -func (gs userService) FindByID(ctx context.Context, req *proto.FindByIDRequest) (rsp *proto.FindByIDResponse, err error) { +func (gs userService) FindByID(ctx context.Context, req *proto.FindByIDUserRequest) (rsp *proto.FindByIDUserResponse, err error) { var ( u *types.User ) @@ -67,7 +67,7 @@ func (gs userService) FindByID(ctx context.Context, req *proto.FindByIDRequest) return } - rsp = &proto.FindByIDResponse{ + rsp = &proto.FindByIDUserResponse{ User: &proto.User{ ID: u.ID, Email: u.Email, diff --git a/system/proto/role.pb.go b/system/proto/role.pb.go new file mode 100644 index 000000000..c1263a319 --- /dev/null +++ b/system/proto/role.pb.go @@ -0,0 +1,254 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: role.proto + +package proto + +import ( + context "context" + fmt "fmt" + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type FindRoleRequest struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *FindRoleRequest) Reset() { *m = FindRoleRequest{} } +func (m *FindRoleRequest) String() string { return proto.CompactTextString(m) } +func (*FindRoleRequest) ProtoMessage() {} +func (*FindRoleRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_48a3ff9f7c9032f8, []int{0} +} + +func (m *FindRoleRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_FindRoleRequest.Unmarshal(m, b) +} +func (m *FindRoleRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_FindRoleRequest.Marshal(b, m, deterministic) +} +func (m *FindRoleRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_FindRoleRequest.Merge(m, src) +} +func (m *FindRoleRequest) XXX_Size() int { + return xxx_messageInfo_FindRoleRequest.Size(m) +} +func (m *FindRoleRequest) XXX_DiscardUnknown() { + xxx_messageInfo_FindRoleRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_FindRoleRequest proto.InternalMessageInfo + +type FindRoleResponse struct { + Roles []*Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *FindRoleResponse) Reset() { *m = FindRoleResponse{} } +func (m *FindRoleResponse) String() string { return proto.CompactTextString(m) } +func (*FindRoleResponse) ProtoMessage() {} +func (*FindRoleResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_48a3ff9f7c9032f8, []int{1} +} + +func (m *FindRoleResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_FindRoleResponse.Unmarshal(m, b) +} +func (m *FindRoleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_FindRoleResponse.Marshal(b, m, deterministic) +} +func (m *FindRoleResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_FindRoleResponse.Merge(m, src) +} +func (m *FindRoleResponse) XXX_Size() int { + return xxx_messageInfo_FindRoleResponse.Size(m) +} +func (m *FindRoleResponse) XXX_DiscardUnknown() { + xxx_messageInfo_FindRoleResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_FindRoleResponse proto.InternalMessageInfo + +func (m *FindRoleResponse) GetRoles() []*Role { + if m != nil { + return m.Roles + } + return nil +} + +type Role struct { + ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` + Handle string `protobuf:"bytes,2,opt,name=handle,proto3" json:"handle,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Role) Reset() { *m = Role{} } +func (m *Role) String() string { return proto.CompactTextString(m) } +func (*Role) ProtoMessage() {} +func (*Role) Descriptor() ([]byte, []int) { + return fileDescriptor_48a3ff9f7c9032f8, []int{2} +} + +func (m *Role) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Role.Unmarshal(m, b) +} +func (m *Role) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Role.Marshal(b, m, deterministic) +} +func (m *Role) XXX_Merge(src proto.Message) { + xxx_messageInfo_Role.Merge(m, src) +} +func (m *Role) XXX_Size() int { + return xxx_messageInfo_Role.Size(m) +} +func (m *Role) XXX_DiscardUnknown() { + xxx_messageInfo_Role.DiscardUnknown(m) +} + +var xxx_messageInfo_Role proto.InternalMessageInfo + +func (m *Role) GetID() uint64 { + if m != nil { + return m.ID + } + return 0 +} + +func (m *Role) GetHandle() string { + if m != nil { + return m.Handle + } + return "" +} + +func (m *Role) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func init() { + proto.RegisterType((*FindRoleRequest)(nil), "system.FindRoleRequest") + proto.RegisterType((*FindRoleResponse)(nil), "system.FindRoleResponse") + proto.RegisterType((*Role)(nil), "system.Role") +} + +func init() { proto.RegisterFile("role.proto", fileDescriptor_48a3ff9f7c9032f8) } + +var fileDescriptor_48a3ff9f7c9032f8 = []byte{ + // 189 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2a, 0xca, 0xcf, 0x49, + 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x2b, 0xae, 0x2c, 0x2e, 0x49, 0xcd, 0x55, 0x12, + 0xe4, 0xe2, 0x77, 0xcb, 0xcc, 0x4b, 0x09, 0xca, 0xcf, 0x49, 0x0d, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, + 0x2e, 0x51, 0x32, 0xe3, 0x12, 0x40, 0x08, 0x15, 0x17, 0xe4, 0xe7, 0x15, 0xa7, 0x0a, 0x29, 0x71, + 0xb1, 0x82, 0x34, 0x17, 0x4b, 0x30, 0x2a, 0x30, 0x6b, 0x70, 0x1b, 0xf1, 0xe8, 0x41, 0xb4, 0xeb, + 0x81, 0x15, 0x41, 0xa4, 0x94, 0x9c, 0xb8, 0x58, 0x40, 0x5c, 0x21, 0x3e, 0x2e, 0x26, 0x4f, 0x17, + 0x09, 0x46, 0x05, 0x46, 0x0d, 0x96, 0x20, 0x26, 0x4f, 0x17, 0x21, 0x31, 0x2e, 0xb6, 0x8c, 0xc4, + 0xbc, 0x94, 0x9c, 0x54, 0x09, 0x26, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x28, 0x4f, 0x48, 0x88, 0x8b, + 0x25, 0x2f, 0x31, 0x37, 0x55, 0x82, 0x19, 0x2c, 0x0a, 0x66, 0x1b, 0x39, 0x71, 0xb1, 0x82, 0xcc, + 0x28, 0x16, 0xb2, 0xe4, 0x62, 0x01, 0x39, 0x42, 0x48, 0x1c, 0x66, 0x13, 0x9a, 0x2b, 0xa5, 0x24, + 0x30, 0x25, 0x20, 0x6e, 0x75, 0x62, 0x8f, 0x62, 0x05, 0xfb, 0x31, 0x89, 0x0d, 0x4c, 0x19, 0x03, + 0x02, 0x00, 0x00, 0xff, 0xff, 0x80, 0x25, 0xf0, 0xe7, 0xf8, 0x00, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// RolesClient is the client API for Roles service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type RolesClient interface { + Find(ctx context.Context, in *FindRoleRequest, opts ...grpc.CallOption) (*FindRoleResponse, error) +} + +type rolesClient struct { + cc *grpc.ClientConn +} + +func NewRolesClient(cc *grpc.ClientConn) RolesClient { + return &rolesClient{cc} +} + +func (c *rolesClient) Find(ctx context.Context, in *FindRoleRequest, opts ...grpc.CallOption) (*FindRoleResponse, error) { + out := new(FindRoleResponse) + err := c.cc.Invoke(ctx, "/system.Roles/Find", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// RolesServer is the server API for Roles service. +type RolesServer interface { + Find(context.Context, *FindRoleRequest) (*FindRoleResponse, error) +} + +// UnimplementedRolesServer can be embedded to have forward compatible implementations. +type UnimplementedRolesServer struct { +} + +func (*UnimplementedRolesServer) Find(ctx context.Context, req *FindRoleRequest) (*FindRoleResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Find not implemented") +} + +func RegisterRolesServer(s *grpc.Server, srv RolesServer) { + s.RegisterService(&_Roles_serviceDesc, srv) +} + +func _Roles_Find_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(FindRoleRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RolesServer).Find(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/system.Roles/Find", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RolesServer).Find(ctx, req.(*FindRoleRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Roles_serviceDesc = grpc.ServiceDesc{ + ServiceName: "system.Roles", + HandlerType: (*RolesServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Find", + Handler: _Roles_Find_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "role.proto", +} diff --git a/system/proto/user.pb.go b/system/proto/user.pb.go index 144902e9d..565eb60c7 100644 --- a/system/proto/user.pb.go +++ b/system/proto/user.pb.go @@ -24,156 +24,156 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package -type MakeJWTRequest struct { +type MakeJWTUserRequest struct { UserID uint64 `protobuf:"varint,1,opt,name=userID,proto3" json:"userID,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` } -func (m *MakeJWTRequest) Reset() { *m = MakeJWTRequest{} } -func (m *MakeJWTRequest) String() string { return proto.CompactTextString(m) } -func (*MakeJWTRequest) ProtoMessage() {} -func (*MakeJWTRequest) Descriptor() ([]byte, []int) { +func (m *MakeJWTUserRequest) Reset() { *m = MakeJWTUserRequest{} } +func (m *MakeJWTUserRequest) String() string { return proto.CompactTextString(m) } +func (*MakeJWTUserRequest) ProtoMessage() {} +func (*MakeJWTUserRequest) Descriptor() ([]byte, []int) { return fileDescriptor_116e343673f7ffaf, []int{0} } -func (m *MakeJWTRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_MakeJWTRequest.Unmarshal(m, b) +func (m *MakeJWTUserRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_MakeJWTUserRequest.Unmarshal(m, b) } -func (m *MakeJWTRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_MakeJWTRequest.Marshal(b, m, deterministic) +func (m *MakeJWTUserRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_MakeJWTUserRequest.Marshal(b, m, deterministic) } -func (m *MakeJWTRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_MakeJWTRequest.Merge(m, src) +func (m *MakeJWTUserRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MakeJWTUserRequest.Merge(m, src) } -func (m *MakeJWTRequest) XXX_Size() int { - return xxx_messageInfo_MakeJWTRequest.Size(m) +func (m *MakeJWTUserRequest) XXX_Size() int { + return xxx_messageInfo_MakeJWTUserRequest.Size(m) } -func (m *MakeJWTRequest) XXX_DiscardUnknown() { - xxx_messageInfo_MakeJWTRequest.DiscardUnknown(m) +func (m *MakeJWTUserRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MakeJWTUserRequest.DiscardUnknown(m) } -var xxx_messageInfo_MakeJWTRequest proto.InternalMessageInfo +var xxx_messageInfo_MakeJWTUserRequest proto.InternalMessageInfo -func (m *MakeJWTRequest) GetUserID() uint64 { +func (m *MakeJWTUserRequest) GetUserID() uint64 { if m != nil { return m.UserID } return 0 } -type MakeJWTResponse struct { +type MakeJWTUserResponse struct { JWT string `protobuf:"bytes,1,opt,name=JWT,proto3" json:"JWT,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` } -func (m *MakeJWTResponse) Reset() { *m = MakeJWTResponse{} } -func (m *MakeJWTResponse) String() string { return proto.CompactTextString(m) } -func (*MakeJWTResponse) ProtoMessage() {} -func (*MakeJWTResponse) Descriptor() ([]byte, []int) { +func (m *MakeJWTUserResponse) Reset() { *m = MakeJWTUserResponse{} } +func (m *MakeJWTUserResponse) String() string { return proto.CompactTextString(m) } +func (*MakeJWTUserResponse) ProtoMessage() {} +func (*MakeJWTUserResponse) Descriptor() ([]byte, []int) { return fileDescriptor_116e343673f7ffaf, []int{1} } -func (m *MakeJWTResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_MakeJWTResponse.Unmarshal(m, b) +func (m *MakeJWTUserResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_MakeJWTUserResponse.Unmarshal(m, b) } -func (m *MakeJWTResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_MakeJWTResponse.Marshal(b, m, deterministic) +func (m *MakeJWTUserResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_MakeJWTUserResponse.Marshal(b, m, deterministic) } -func (m *MakeJWTResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MakeJWTResponse.Merge(m, src) +func (m *MakeJWTUserResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MakeJWTUserResponse.Merge(m, src) } -func (m *MakeJWTResponse) XXX_Size() int { - return xxx_messageInfo_MakeJWTResponse.Size(m) +func (m *MakeJWTUserResponse) XXX_Size() int { + return xxx_messageInfo_MakeJWTUserResponse.Size(m) } -func (m *MakeJWTResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MakeJWTResponse.DiscardUnknown(m) +func (m *MakeJWTUserResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MakeJWTUserResponse.DiscardUnknown(m) } -var xxx_messageInfo_MakeJWTResponse proto.InternalMessageInfo +var xxx_messageInfo_MakeJWTUserResponse proto.InternalMessageInfo -func (m *MakeJWTResponse) GetJWT() string { +func (m *MakeJWTUserResponse) GetJWT() string { if m != nil { return m.JWT } return "" } -type FindByIDRequest struct { +type FindByIDUserRequest struct { UserID uint64 `protobuf:"varint,1,opt,name=userID,proto3" json:"userID,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` } -func (m *FindByIDRequest) Reset() { *m = FindByIDRequest{} } -func (m *FindByIDRequest) String() string { return proto.CompactTextString(m) } -func (*FindByIDRequest) ProtoMessage() {} -func (*FindByIDRequest) Descriptor() ([]byte, []int) { +func (m *FindByIDUserRequest) Reset() { *m = FindByIDUserRequest{} } +func (m *FindByIDUserRequest) String() string { return proto.CompactTextString(m) } +func (*FindByIDUserRequest) ProtoMessage() {} +func (*FindByIDUserRequest) Descriptor() ([]byte, []int) { return fileDescriptor_116e343673f7ffaf, []int{2} } -func (m *FindByIDRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_FindByIDRequest.Unmarshal(m, b) +func (m *FindByIDUserRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_FindByIDUserRequest.Unmarshal(m, b) } -func (m *FindByIDRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_FindByIDRequest.Marshal(b, m, deterministic) +func (m *FindByIDUserRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_FindByIDUserRequest.Marshal(b, m, deterministic) } -func (m *FindByIDRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_FindByIDRequest.Merge(m, src) +func (m *FindByIDUserRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_FindByIDUserRequest.Merge(m, src) } -func (m *FindByIDRequest) XXX_Size() int { - return xxx_messageInfo_FindByIDRequest.Size(m) +func (m *FindByIDUserRequest) XXX_Size() int { + return xxx_messageInfo_FindByIDUserRequest.Size(m) } -func (m *FindByIDRequest) XXX_DiscardUnknown() { - xxx_messageInfo_FindByIDRequest.DiscardUnknown(m) +func (m *FindByIDUserRequest) XXX_DiscardUnknown() { + xxx_messageInfo_FindByIDUserRequest.DiscardUnknown(m) } -var xxx_messageInfo_FindByIDRequest proto.InternalMessageInfo +var xxx_messageInfo_FindByIDUserRequest proto.InternalMessageInfo -func (m *FindByIDRequest) GetUserID() uint64 { +func (m *FindByIDUserRequest) GetUserID() uint64 { if m != nil { return m.UserID } return 0 } -type FindByIDResponse struct { +type FindByIDUserResponse struct { User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` } -func (m *FindByIDResponse) Reset() { *m = FindByIDResponse{} } -func (m *FindByIDResponse) String() string { return proto.CompactTextString(m) } -func (*FindByIDResponse) ProtoMessage() {} -func (*FindByIDResponse) Descriptor() ([]byte, []int) { +func (m *FindByIDUserResponse) Reset() { *m = FindByIDUserResponse{} } +func (m *FindByIDUserResponse) String() string { return proto.CompactTextString(m) } +func (*FindByIDUserResponse) ProtoMessage() {} +func (*FindByIDUserResponse) Descriptor() ([]byte, []int) { return fileDescriptor_116e343673f7ffaf, []int{3} } -func (m *FindByIDResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_FindByIDResponse.Unmarshal(m, b) +func (m *FindByIDUserResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_FindByIDUserResponse.Unmarshal(m, b) } -func (m *FindByIDResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_FindByIDResponse.Marshal(b, m, deterministic) +func (m *FindByIDUserResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_FindByIDUserResponse.Marshal(b, m, deterministic) } -func (m *FindByIDResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_FindByIDResponse.Merge(m, src) +func (m *FindByIDUserResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_FindByIDUserResponse.Merge(m, src) } -func (m *FindByIDResponse) XXX_Size() int { - return xxx_messageInfo_FindByIDResponse.Size(m) +func (m *FindByIDUserResponse) XXX_Size() int { + return xxx_messageInfo_FindByIDUserResponse.Size(m) } -func (m *FindByIDResponse) XXX_DiscardUnknown() { - xxx_messageInfo_FindByIDResponse.DiscardUnknown(m) +func (m *FindByIDUserResponse) XXX_DiscardUnknown() { + xxx_messageInfo_FindByIDUserResponse.DiscardUnknown(m) } -var xxx_messageInfo_FindByIDResponse proto.InternalMessageInfo +var xxx_messageInfo_FindByIDUserResponse proto.InternalMessageInfo -func (m *FindByIDResponse) GetUser() *User { +func (m *FindByIDUserResponse) GetUser() *User { if m != nil { return m.User } @@ -252,34 +252,34 @@ func (m *User) GetKind() string { } func init() { - proto.RegisterType((*MakeJWTRequest)(nil), "system.MakeJWTRequest") - proto.RegisterType((*MakeJWTResponse)(nil), "system.MakeJWTResponse") - proto.RegisterType((*FindByIDRequest)(nil), "system.FindByIDRequest") - proto.RegisterType((*FindByIDResponse)(nil), "system.FindByIDResponse") + proto.RegisterType((*MakeJWTUserRequest)(nil), "system.MakeJWTUserRequest") + proto.RegisterType((*MakeJWTUserResponse)(nil), "system.MakeJWTUserResponse") + proto.RegisterType((*FindByIDUserRequest)(nil), "system.FindByIDUserRequest") + proto.RegisterType((*FindByIDUserResponse)(nil), "system.FindByIDUserResponse") proto.RegisterType((*User)(nil), "system.User") } func init() { proto.RegisterFile("user.proto", fileDescriptor_116e343673f7ffaf) } var fileDescriptor_116e343673f7ffaf = []byte{ - // 269 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xbf, 0x4b, 0xc3, 0x40, - 0x14, 0xc7, 0x49, 0x7a, 0x49, 0xf5, 0x29, 0x6d, 0x79, 0x48, 0x3d, 0x3a, 0x95, 0xb8, 0xd4, 0x25, - 0x43, 0x75, 0x12, 0x5c, 0x4a, 0x10, 0x52, 0x70, 0x09, 0x95, 0x82, 0x5b, 0x24, 0x0f, 0x0c, 0x4d, - 0x2e, 0x35, 0x97, 0x0e, 0x5d, 0xfd, 0xcb, 0xe5, 0x5e, 0xae, 0x11, 0xcd, 0xd0, 0x29, 0xef, 0xfb, - 0x7d, 0x9f, 0xbc, 0x5f, 0x07, 0x70, 0xd0, 0x54, 0x87, 0xfb, 0xba, 0x6a, 0x2a, 0xf4, 0xf5, 0x51, - 0x37, 0x54, 0x06, 0x0b, 0x18, 0xbd, 0xa6, 0x3b, 0x5a, 0x6f, 0x37, 0x09, 0x7d, 0x1d, 0x48, 0x37, - 0x38, 0x05, 0xdf, 0x70, 0x71, 0x24, 0x9d, 0xb9, 0xb3, 0x10, 0x89, 0x55, 0xc1, 0x1d, 0x8c, 0x3b, - 0x52, 0xef, 0x2b, 0xa5, 0x09, 0x27, 0x30, 0x58, 0x6f, 0x37, 0xcc, 0x5d, 0x26, 0x26, 0x0c, 0xee, - 0x61, 0xfc, 0x92, 0xab, 0x6c, 0x75, 0x8c, 0xa3, 0x73, 0xf5, 0x1e, 0x61, 0xf2, 0x8b, 0xda, 0x82, - 0x73, 0x10, 0x26, 0xcb, 0xe4, 0xd5, 0xf2, 0x3a, 0x6c, 0x87, 0x0c, 0xdf, 0x34, 0xd5, 0x09, 0x67, - 0x82, 0x02, 0x84, 0x51, 0x38, 0x02, 0xb7, 0xab, 0xe8, 0xc6, 0x11, 0xde, 0x80, 0x47, 0x65, 0x9a, - 0x17, 0xd2, 0xe5, 0x61, 0x5a, 0x61, 0x7a, 0x7f, 0xa6, 0x2a, 0x2b, 0x48, 0x0e, 0xd8, 0xb6, 0x0a, - 0x11, 0x84, 0x4a, 0x4b, 0x92, 0x82, 0x5d, 0x8e, 0x8d, 0xb7, 0xcb, 0x55, 0x26, 0xbd, 0xd6, 0x33, - 0xf1, 0xf2, 0xdb, 0x01, 0xcf, 0xb4, 0xd3, 0xf8, 0x04, 0x43, 0xbb, 0x3d, 0x4e, 0x4f, 0x63, 0xfd, - 0x3d, 0xdc, 0xec, 0xb6, 0xe7, 0xdb, 0xad, 0x9e, 0xe1, 0xe2, 0xb4, 0x29, 0x76, 0xd0, 0xbf, 0x33, - 0xcd, 0x64, 0x3f, 0xd1, 0xfe, 0xbe, 0x1a, 0xbe, 0x7b, 0xfc, 0x66, 0x1f, 0x3e, 0x7f, 0x1e, 0x7e, - 0x02, 0x00, 0x00, 0xff, 0xff, 0x04, 0x91, 0x4b, 0x16, 0xc8, 0x01, 0x00, 0x00, + // 271 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0x41, 0x4b, 0xc3, 0x40, + 0x10, 0x85, 0x49, 0xba, 0x49, 0x75, 0x14, 0x91, 0x69, 0x91, 0x25, 0x7a, 0x28, 0xb9, 0xe8, 0x41, + 0x73, 0xa8, 0x17, 0xcf, 0x21, 0x0a, 0x29, 0x78, 0x09, 0x95, 0x82, 0xb7, 0x48, 0x06, 0x0c, 0x4d, + 0x36, 0x35, 0x9b, 0x1e, 0xfa, 0x37, 0xfc, 0xc5, 0xb2, 0x93, 0x6d, 0xa1, 0x98, 0x43, 0x4f, 0x99, + 0xf7, 0xe6, 0xe3, 0xed, 0xcc, 0x04, 0x60, 0xab, 0xa9, 0x8d, 0x36, 0x6d, 0xd3, 0x35, 0xe8, 0xeb, + 0x9d, 0xee, 0xa8, 0x0e, 0x1f, 0x01, 0xdf, 0xf3, 0x35, 0x2d, 0x56, 0xcb, 0x0f, 0x4d, 0x6d, 0x46, + 0x3f, 0x5b, 0xd2, 0x1d, 0xde, 0x80, 0x6f, 0xd8, 0x34, 0x91, 0xce, 0xcc, 0x79, 0x10, 0x99, 0x55, + 0xe1, 0x3d, 0x4c, 0x8e, 0x68, 0xbd, 0x69, 0x94, 0x26, 0xbc, 0x86, 0xd1, 0x62, 0xb5, 0x64, 0xf6, + 0x3c, 0x33, 0x65, 0xf8, 0x04, 0x93, 0xb7, 0x52, 0x15, 0xf1, 0x2e, 0x4d, 0x4e, 0xc9, 0x7d, 0x81, + 0xe9, 0x31, 0x6e, 0x83, 0x67, 0x20, 0x0c, 0xc1, 0xf4, 0xc5, 0xfc, 0x32, 0xea, 0x87, 0x8e, 0x98, + 0xe1, 0x4e, 0x58, 0x81, 0x30, 0x0a, 0xaf, 0xc0, 0x3d, 0xa4, 0xba, 0x69, 0x82, 0x53, 0xf0, 0xa8, + 0xce, 0xcb, 0x4a, 0xba, 0x3c, 0x54, 0x2f, 0xcc, 0xfb, 0xdf, 0xb9, 0x2a, 0x2a, 0x92, 0x23, 0xb6, + 0xad, 0x42, 0x04, 0xa1, 0xf2, 0x9a, 0xa4, 0x60, 0x97, 0x6b, 0xe3, 0xad, 0x4b, 0x55, 0x48, 0xaf, + 0xf7, 0x4c, 0x3d, 0xff, 0x75, 0xc0, 0x33, 0xcf, 0x69, 0x8c, 0x61, 0x6c, 0x2f, 0x81, 0xc1, 0x7e, + 0xac, 0xff, 0x87, 0x0c, 0x6e, 0x07, 0x7b, 0x76, 0xbb, 0x57, 0x38, 0xdb, 0x6f, 0x8d, 0x07, 0x70, + 0xe0, 0x6c, 0xc1, 0xdd, 0x70, 0xb3, 0x8f, 0x89, 0xc7, 0x9f, 0x1e, 0xff, 0xd3, 0x2f, 0x9f, 0x3f, + 0xcf, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x0e, 0x54, 0x3b, 0x6a, 0xe8, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -294,8 +294,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type UsersClient interface { - MakeJWT(ctx context.Context, in *MakeJWTRequest, opts ...grpc.CallOption) (*MakeJWTResponse, error) - FindByID(ctx context.Context, in *FindByIDRequest, opts ...grpc.CallOption) (*FindByIDResponse, error) + MakeJWT(ctx context.Context, in *MakeJWTUserRequest, opts ...grpc.CallOption) (*MakeJWTUserResponse, error) + FindByID(ctx context.Context, in *FindByIDUserRequest, opts ...grpc.CallOption) (*FindByIDUserResponse, error) } type usersClient struct { @@ -306,8 +306,8 @@ func NewUsersClient(cc *grpc.ClientConn) UsersClient { return &usersClient{cc} } -func (c *usersClient) MakeJWT(ctx context.Context, in *MakeJWTRequest, opts ...grpc.CallOption) (*MakeJWTResponse, error) { - out := new(MakeJWTResponse) +func (c *usersClient) MakeJWT(ctx context.Context, in *MakeJWTUserRequest, opts ...grpc.CallOption) (*MakeJWTUserResponse, error) { + out := new(MakeJWTUserResponse) err := c.cc.Invoke(ctx, "/system.Users/MakeJWT", in, out, opts...) if err != nil { return nil, err @@ -315,8 +315,8 @@ func (c *usersClient) MakeJWT(ctx context.Context, in *MakeJWTRequest, opts ...g return out, nil } -func (c *usersClient) FindByID(ctx context.Context, in *FindByIDRequest, opts ...grpc.CallOption) (*FindByIDResponse, error) { - out := new(FindByIDResponse) +func (c *usersClient) FindByID(ctx context.Context, in *FindByIDUserRequest, opts ...grpc.CallOption) (*FindByIDUserResponse, error) { + out := new(FindByIDUserResponse) err := c.cc.Invoke(ctx, "/system.Users/FindByID", in, out, opts...) if err != nil { return nil, err @@ -326,18 +326,18 @@ func (c *usersClient) FindByID(ctx context.Context, in *FindByIDRequest, opts .. // UsersServer is the server API for Users service. type UsersServer interface { - MakeJWT(context.Context, *MakeJWTRequest) (*MakeJWTResponse, error) - FindByID(context.Context, *FindByIDRequest) (*FindByIDResponse, error) + MakeJWT(context.Context, *MakeJWTUserRequest) (*MakeJWTUserResponse, error) + FindByID(context.Context, *FindByIDUserRequest) (*FindByIDUserResponse, error) } // UnimplementedUsersServer can be embedded to have forward compatible implementations. type UnimplementedUsersServer struct { } -func (*UnimplementedUsersServer) MakeJWT(ctx context.Context, req *MakeJWTRequest) (*MakeJWTResponse, error) { +func (*UnimplementedUsersServer) MakeJWT(ctx context.Context, req *MakeJWTUserRequest) (*MakeJWTUserResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method MakeJWT not implemented") } -func (*UnimplementedUsersServer) FindByID(ctx context.Context, req *FindByIDRequest) (*FindByIDResponse, error) { +func (*UnimplementedUsersServer) FindByID(ctx context.Context, req *FindByIDUserRequest) (*FindByIDUserResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method FindByID not implemented") } @@ -346,7 +346,7 @@ func RegisterUsersServer(s *grpc.Server, srv UsersServer) { } func _Users_MakeJWT_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MakeJWTRequest) + in := new(MakeJWTUserRequest) if err := dec(in); err != nil { return nil, err } @@ -358,13 +358,13 @@ func _Users_MakeJWT_Handler(srv interface{}, ctx context.Context, dec func(inter FullMethod: "/system.Users/MakeJWT", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UsersServer).MakeJWT(ctx, req.(*MakeJWTRequest)) + return srv.(UsersServer).MakeJWT(ctx, req.(*MakeJWTUserRequest)) } return interceptor(ctx, in, info, handler) } func _Users_FindByID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(FindByIDRequest) + in := new(FindByIDUserRequest) if err := dec(in); err != nil { return nil, err } @@ -376,7 +376,7 @@ func _Users_FindByID_Handler(srv interface{}, ctx context.Context, dec func(inte FullMethod: "/system.Users/FindByID", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UsersServer).FindByID(ctx, req.(*FindByIDRequest)) + return srv.(UsersServer).FindByID(ctx, req.(*FindByIDUserRequest)) } return interceptor(ctx, in, info, handler) }