diff --git a/api/gen/homeops/hub.pb.go b/api/gen/homeops/hub.pb.go index d002a53..0e317ab 100644 --- a/api/gen/homeops/hub.pb.go +++ b/api/gen/homeops/hub.pb.go @@ -66,15 +66,145 @@ func (x *PongResponse) GetPong() string { return "" } +type RegisterAgentRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + AgentId string `protobuf:"bytes,1,opt,name=agent_id,json=agentId,proto3" json:"agent_id,omitempty"` + AgentName string `protobuf:"bytes,2,opt,name=agent_name,json=agentName,proto3" json:"agent_name,omitempty"` + Hostname string `protobuf:"bytes,3,opt,name=hostname,proto3" json:"hostname,omitempty"` + Version string `protobuf:"bytes,4,opt,name=version,proto3" json:"version,omitempty"` + Arch string `protobuf:"bytes,5,opt,name=arch,proto3" json:"arch,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RegisterAgentRequest) Reset() { + *x = RegisterAgentRequest{} + mi := &file_homeops_hub_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RegisterAgentRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RegisterAgentRequest) ProtoMessage() {} + +func (x *RegisterAgentRequest) ProtoReflect() protoreflect.Message { + mi := &file_homeops_hub_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RegisterAgentRequest.ProtoReflect.Descriptor instead. +func (*RegisterAgentRequest) Descriptor() ([]byte, []int) { + return file_homeops_hub_proto_rawDescGZIP(), []int{1} +} + +func (x *RegisterAgentRequest) GetAgentId() string { + if x != nil { + return x.AgentId + } + return "" +} + +func (x *RegisterAgentRequest) GetAgentName() string { + if x != nil { + return x.AgentName + } + return "" +} + +func (x *RegisterAgentRequest) GetHostname() string { + if x != nil { + return x.Hostname + } + return "" +} + +func (x *RegisterAgentRequest) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +func (x *RegisterAgentRequest) GetArch() string { + if x != nil { + return x.Arch + } + return "" +} + +type RegisterAgentResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + HeartbeatIntervalSecond int64 `protobuf:"varint,1,opt,name=heartbeat_interval_second,json=heartbeatIntervalSecond,proto3" json:"heartbeat_interval_second,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RegisterAgentResponse) Reset() { + *x = RegisterAgentResponse{} + mi := &file_homeops_hub_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RegisterAgentResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RegisterAgentResponse) ProtoMessage() {} + +func (x *RegisterAgentResponse) ProtoReflect() protoreflect.Message { + mi := &file_homeops_hub_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RegisterAgentResponse.ProtoReflect.Descriptor instead. +func (*RegisterAgentResponse) Descriptor() ([]byte, []int) { + return file_homeops_hub_proto_rawDescGZIP(), []int{2} +} + +func (x *RegisterAgentResponse) GetHeartbeatIntervalSecond() int64 { + if x != nil { + return x.HeartbeatIntervalSecond + } + return 0 +} + var File_homeops_hub_proto protoreflect.FileDescriptor const file_homeops_hub_proto_rawDesc = "" + "\n" + "\x11homeops/hub.proto\x1a\x1bgoogle/protobuf/empty.proto\"\"\n" + "\fPongResponse\x12\x12\n" + - "\x04pong\x18\x01 \x01(\tR\x04pong26\n" + + "\x04pong\x18\x01 \x01(\tR\x04pong\"\x9a\x01\n" + + "\x14RegisterAgentRequest\x12\x19\n" + + "\bagent_id\x18\x01 \x01(\tR\aagentId\x12\x1d\n" + + "\n" + + "agent_name\x18\x02 \x01(\tR\tagentName\x12\x1a\n" + + "\bhostname\x18\x03 \x01(\tR\bhostname\x12\x18\n" + + "\aversion\x18\x04 \x01(\tR\aversion\x12\x12\n" + + "\x04arch\x18\x05 \x01(\tR\x04arch\"S\n" + + "\x15RegisterAgentResponse\x12:\n" + + "\x19heartbeat_interval_second\x18\x01 \x01(\x03R\x17heartbeatIntervalSecond2x\n" + "\x03Hub\x12/\n" + - "\x04Ping\x12\x16.google.protobuf.Empty\x1a\r.PongResponse\"\x00B google.protobuf.Empty - 0, // 1: Hub.Ping:output_type -> PongResponse - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type + 3, // 0: Hub.Ping:input_type -> google.protobuf.Empty + 1, // 1: Hub.RegisterAgent:input_type -> RegisterAgentRequest + 0, // 2: Hub.Ping:output_type -> PongResponse + 2, // 3: Hub.RegisterAgent:output_type -> RegisterAgentResponse + 2, // [2:4] is the sub-list for method output_type + 0, // [0:2] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name @@ -114,7 +248,7 @@ func file_homeops_hub_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_homeops_hub_proto_rawDesc), len(file_homeops_hub_proto_rawDesc)), NumEnums: 0, - NumMessages: 1, + NumMessages: 3, NumExtensions: 0, NumServices: 1, }, diff --git a/api/gen/homeops/hub_grpc.pb.go b/api/gen/homeops/hub_grpc.pb.go index 7a39a48..e032d6c 100644 --- a/api/gen/homeops/hub_grpc.pb.go +++ b/api/gen/homeops/hub_grpc.pb.go @@ -20,7 +20,8 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - Hub_Ping_FullMethodName = "/Hub/Ping" + Hub_Ping_FullMethodName = "/Hub/Ping" + Hub_RegisterAgent_FullMethodName = "/Hub/RegisterAgent" ) // HubClient is the client API for Hub service. @@ -28,6 +29,7 @@ const ( // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type HubClient interface { Ping(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*PongResponse, error) + RegisterAgent(ctx context.Context, in *RegisterAgentRequest, opts ...grpc.CallOption) (*RegisterAgentResponse, error) } type hubClient struct { @@ -48,11 +50,22 @@ func (c *hubClient) Ping(ctx context.Context, in *emptypb.Empty, opts ...grpc.Ca return out, nil } +func (c *hubClient) RegisterAgent(ctx context.Context, in *RegisterAgentRequest, opts ...grpc.CallOption) (*RegisterAgentResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(RegisterAgentResponse) + err := c.cc.Invoke(ctx, Hub_RegisterAgent_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // HubServer is the server API for Hub service. // All implementations must embed UnimplementedHubServer // for forward compatibility. type HubServer interface { Ping(context.Context, *emptypb.Empty) (*PongResponse, error) + RegisterAgent(context.Context, *RegisterAgentRequest) (*RegisterAgentResponse, error) mustEmbedUnimplementedHubServer() } @@ -66,6 +79,9 @@ type UnimplementedHubServer struct{} func (UnimplementedHubServer) Ping(context.Context, *emptypb.Empty) (*PongResponse, error) { return nil, status.Error(codes.Unimplemented, "method Ping not implemented") } +func (UnimplementedHubServer) RegisterAgent(context.Context, *RegisterAgentRequest) (*RegisterAgentResponse, error) { + return nil, status.Error(codes.Unimplemented, "method RegisterAgent not implemented") +} func (UnimplementedHubServer) mustEmbedUnimplementedHubServer() {} func (UnimplementedHubServer) testEmbeddedByValue() {} @@ -105,6 +121,24 @@ func _Hub_Ping_Handler(srv interface{}, ctx context.Context, dec func(interface{ return interceptor(ctx, in, info, handler) } +func _Hub_RegisterAgent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RegisterAgentRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HubServer).RegisterAgent(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Hub_RegisterAgent_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HubServer).RegisterAgent(ctx, req.(*RegisterAgentRequest)) + } + return interceptor(ctx, in, info, handler) +} + // Hub_ServiceDesc is the grpc.ServiceDesc for Hub service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -116,6 +150,10 @@ var Hub_ServiceDesc = grpc.ServiceDesc{ MethodName: "Ping", Handler: _Hub_Ping_Handler, }, + { + MethodName: "RegisterAgent", + Handler: _Hub_RegisterAgent_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "homeops/hub.proto", diff --git a/api/proto/homeops/hub.proto b/api/proto/homeops/hub.proto index 3a45528..4c987f2 100644 --- a/api/proto/homeops/hub.proto +++ b/api/proto/homeops/hub.proto @@ -6,8 +6,21 @@ option go_package = "github.com/lorsanstand/HomeOps-Hub/api/gen/homeops;homeops" service Hub { rpc Ping (google.protobuf.Empty) returns (PongResponse) {} + rpc RegisterAgent (RegisterAgentRequest) returns (RegisterAgentResponse) {} } message PongResponse { string pong = 1; +} + +message RegisterAgentRequest { + string agent_id = 1; + string agent_name = 2; + string hostname = 3; + string version = 4; + string arch = 5; +} + +message RegisterAgentResponse { + int64 heartbeat_interval_second = 1; } \ No newline at end of file