diff --git a/api/go/gosdn/core/core.pb.go b/api/go/gosdn/core/core.pb.go index 562655fc9c3001e2e5992ff509111d1a7c06ea27..fb190ee9c49be4820013ee45119c93a35e119cd5 100644 --- a/api/go/gosdn/core/core.pb.go +++ b/api/go/gosdn/core/core.pb.go @@ -71,16 +71,17 @@ func (Status) EnumDescriptor() ([]byte, []int) { return file_gosdn_core_core_proto_rawDescGZIP(), []int{0} } -type GetPndListRequest struct { +type GetPndRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // Timestamp in nanoseconds since Epoch. + Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // Timestamp in nanoseconds since Epoch. + Pid string `protobuf:"bytes,2,opt,name=pid,proto3" json:"pid,omitempty"` } -func (x *GetPndListRequest) Reset() { - *x = GetPndListRequest{} +func (x *GetPndRequest) Reset() { + *x = GetPndRequest{} if protoimpl.UnsafeEnabled { mi := &file_gosdn_core_core_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -88,13 +89,13 @@ func (x *GetPndListRequest) Reset() { } } -func (x *GetPndListRequest) String() string { +func (x *GetPndRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetPndListRequest) ProtoMessage() {} +func (*GetPndRequest) ProtoMessage() {} -func (x *GetPndListRequest) ProtoReflect() protoreflect.Message { +func (x *GetPndRequest) ProtoReflect() protoreflect.Message { mi := &file_gosdn_core_core_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -106,29 +107,36 @@ func (x *GetPndListRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetPndListRequest.ProtoReflect.Descriptor instead. -func (*GetPndListRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use GetPndRequest.ProtoReflect.Descriptor instead. +func (*GetPndRequest) Descriptor() ([]byte, []int) { return file_gosdn_core_core_proto_rawDescGZIP(), []int{0} } -func (x *GetPndListRequest) GetTimestamp() int64 { +func (x *GetPndRequest) GetTimestamp() int64 { if x != nil { return x.Timestamp } return 0 } -type GetPndRequest struct { +func (x *GetPndRequest) GetPid() string { + if x != nil { + return x.Pid + } + return "" +} + +type GetPndResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // Timestamp in nanoseconds since Epoch. - Pid []string `protobuf:"bytes,3,rep,name=pid,proto3" json:"pid,omitempty"` + Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // Timestamp in nanoseconds since Epoch. + Pnd *pnd.PrincipalNetworkDomain `protobuf:"bytes,2,opt,name=pnd,proto3" json:"pnd,omitempty"` } -func (x *GetPndRequest) Reset() { - *x = GetPndRequest{} +func (x *GetPndResponse) Reset() { + *x = GetPndResponse{} if protoimpl.UnsafeEnabled { mi := &file_gosdn_core_core_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -136,13 +144,13 @@ func (x *GetPndRequest) Reset() { } } -func (x *GetPndRequest) String() string { +func (x *GetPndResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetPndRequest) ProtoMessage() {} +func (*GetPndResponse) ProtoMessage() {} -func (x *GetPndRequest) ProtoReflect() protoreflect.Message { +func (x *GetPndResponse) ProtoReflect() protoreflect.Message { mi := &file_gosdn_core_core_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -154,36 +162,35 @@ func (x *GetPndRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetPndRequest.ProtoReflect.Descriptor instead. -func (*GetPndRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use GetPndResponse.ProtoReflect.Descriptor instead. +func (*GetPndResponse) Descriptor() ([]byte, []int) { return file_gosdn_core_core_proto_rawDescGZIP(), []int{1} } -func (x *GetPndRequest) GetTimestamp() int64 { +func (x *GetPndResponse) GetTimestamp() int64 { if x != nil { return x.Timestamp } return 0 } -func (x *GetPndRequest) GetPid() []string { +func (x *GetPndResponse) GetPnd() *pnd.PrincipalNetworkDomain { if x != nil { - return x.Pid + return x.Pnd } return nil } -type GetPndListResponse struct { +type GetPndListRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // Timestamp in nanoseconds since Epoch. - Pnd []*pnd.PrincipalNetworkDomain `protobuf:"bytes,2,rep,name=pnd,proto3" json:"pnd,omitempty"` + Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // Timestamp in nanoseconds since Epoch. } -func (x *GetPndListResponse) Reset() { - *x = GetPndListResponse{} +func (x *GetPndListRequest) Reset() { + *x = GetPndListRequest{} if protoimpl.UnsafeEnabled { mi := &file_gosdn_core_core_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -191,13 +198,13 @@ func (x *GetPndListResponse) Reset() { } } -func (x *GetPndListResponse) String() string { +func (x *GetPndListRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetPndListResponse) ProtoMessage() {} +func (*GetPndListRequest) ProtoMessage() {} -func (x *GetPndListResponse) ProtoReflect() protoreflect.Message { +func (x *GetPndListRequest) ProtoReflect() protoreflect.Message { mi := &file_gosdn_core_core_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -209,26 +216,19 @@ func (x *GetPndListResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetPndListResponse.ProtoReflect.Descriptor instead. -func (*GetPndListResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use GetPndListRequest.ProtoReflect.Descriptor instead. +func (*GetPndListRequest) Descriptor() ([]byte, []int) { return file_gosdn_core_core_proto_rawDescGZIP(), []int{2} } -func (x *GetPndListResponse) GetTimestamp() int64 { +func (x *GetPndListRequest) GetTimestamp() int64 { if x != nil { return x.Timestamp } return 0 } -func (x *GetPndListResponse) GetPnd() []*pnd.PrincipalNetworkDomain { - if x != nil { - return x.Pnd - } - return nil -} - -type GetPndResponse struct { +type GetPndListResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -237,8 +237,8 @@ type GetPndResponse struct { Pnd []*pnd.PrincipalNetworkDomain `protobuf:"bytes,2,rep,name=pnd,proto3" json:"pnd,omitempty"` } -func (x *GetPndResponse) Reset() { - *x = GetPndResponse{} +func (x *GetPndListResponse) Reset() { + *x = GetPndListResponse{} if protoimpl.UnsafeEnabled { mi := &file_gosdn_core_core_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -246,13 +246,13 @@ func (x *GetPndResponse) Reset() { } } -func (x *GetPndResponse) String() string { +func (x *GetPndListResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetPndResponse) ProtoMessage() {} +func (*GetPndListResponse) ProtoMessage() {} -func (x *GetPndResponse) ProtoReflect() protoreflect.Message { +func (x *GetPndListResponse) ProtoReflect() protoreflect.Message { mi := &file_gosdn_core_core_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -264,19 +264,19 @@ func (x *GetPndResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetPndResponse.ProtoReflect.Descriptor instead. -func (*GetPndResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use GetPndListResponse.ProtoReflect.Descriptor instead. +func (*GetPndListResponse) Descriptor() ([]byte, []int) { return file_gosdn_core_core_proto_rawDescGZIP(), []int{3} } -func (x *GetPndResponse) GetTimestamp() int64 { +func (x *GetPndListResponse) GetTimestamp() int64 { if x != nil { return x.Timestamp } return 0 } -func (x *GetPndResponse) GetPnd() []*pnd.PrincipalNetworkDomain { +func (x *GetPndListResponse) GetPnd() []*pnd.PrincipalNetworkDomain { if x != nil { return x.Pnd } @@ -574,21 +574,21 @@ var file_gosdn_core_core_proto_rawDesc = []byte{ 0x6f, 0x72, 0x65, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x13, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2f, 0x70, 0x6e, 0x64, 0x2f, 0x70, 0x6e, 0x64, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x31, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x50, 0x6e, 0x64, - 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, - 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x3f, 0x0a, 0x0d, 0x47, 0x65, 0x74, - 0x50, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x69, 0x64, 0x18, - 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x70, 0x69, 0x64, 0x22, 0x67, 0x0a, 0x12, 0x47, 0x65, - 0x74, 0x50, 0x6e, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x33, - 0x0a, 0x03, 0x70, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x67, 0x6f, - 0x73, 0x64, 0x6e, 0x2e, 0x70, 0x6e, 0x64, 0x2e, 0x50, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, - 0x6c, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x03, - 0x70, 0x6e, 0x64, 0x22, 0x63, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x50, 0x6e, 0x64, 0x52, 0x65, 0x73, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3f, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x50, 0x6e, 0x64, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x70, 0x69, 0x64, 0x22, 0x63, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x50, 0x6e, + 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x33, 0x0a, 0x03, 0x70, 0x6e, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x70, 0x6e, 0x64, + 0x2e, 0x50, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, 0x6c, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, + 0x6b, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x03, 0x70, 0x6e, 0x64, 0x22, 0x31, 0x0a, 0x11, + 0x47, 0x65, 0x74, 0x50, 0x6e, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, + 0x67, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x50, 0x6e, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x33, 0x0a, 0x03, 0x70, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, @@ -674,10 +674,10 @@ var file_gosdn_core_core_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_gosdn_core_core_proto_msgTypes = make([]protoimpl.MessageInfo, 9) var file_gosdn_core_core_proto_goTypes = []interface{}{ (Status)(0), // 0: gosdn.core.Status - (*GetPndListRequest)(nil), // 1: gosdn.core.GetPndListRequest - (*GetPndRequest)(nil), // 2: gosdn.core.GetPndRequest - (*GetPndListResponse)(nil), // 3: gosdn.core.GetPndListResponse - (*GetPndResponse)(nil), // 4: gosdn.core.GetPndResponse + (*GetPndRequest)(nil), // 1: gosdn.core.GetPndRequest + (*GetPndResponse)(nil), // 2: gosdn.core.GetPndResponse + (*GetPndListRequest)(nil), // 3: gosdn.core.GetPndListRequest + (*GetPndListResponse)(nil), // 4: gosdn.core.GetPndListResponse (*CreatePndListRequest)(nil), // 5: gosdn.core.CreatePndListRequest (*PndCreateProperties)(nil), // 6: gosdn.core.PndCreateProperties (*CreatePndListResponse)(nil), // 7: gosdn.core.CreatePndListResponse @@ -686,17 +686,17 @@ var file_gosdn_core_core_proto_goTypes = []interface{}{ (*pnd.PrincipalNetworkDomain)(nil), // 10: gosdn.pnd.PrincipalNetworkDomain } var file_gosdn_core_core_proto_depIdxs = []int32{ - 10, // 0: gosdn.core.GetPndListResponse.pnd:type_name -> gosdn.pnd.PrincipalNetworkDomain - 10, // 1: gosdn.core.GetPndResponse.pnd:type_name -> gosdn.pnd.PrincipalNetworkDomain + 10, // 0: gosdn.core.GetPndResponse.pnd:type_name -> gosdn.pnd.PrincipalNetworkDomain + 10, // 1: gosdn.core.GetPndListResponse.pnd:type_name -> gosdn.pnd.PrincipalNetworkDomain 6, // 2: gosdn.core.CreatePndListRequest.pnd:type_name -> gosdn.core.PndCreateProperties 0, // 3: gosdn.core.CreatePndListResponse.status:type_name -> gosdn.core.Status 0, // 4: gosdn.core.DeletePndResponse.status:type_name -> gosdn.core.Status - 2, // 5: gosdn.core.CoreService.GetPnd:input_type -> gosdn.core.GetPndRequest - 1, // 6: gosdn.core.CoreService.GetPndList:input_type -> gosdn.core.GetPndListRequest + 1, // 5: gosdn.core.CoreService.GetPnd:input_type -> gosdn.core.GetPndRequest + 3, // 6: gosdn.core.CoreService.GetPndList:input_type -> gosdn.core.GetPndListRequest 5, // 7: gosdn.core.CoreService.CreatePndList:input_type -> gosdn.core.CreatePndListRequest 8, // 8: gosdn.core.CoreService.DeletePnd:input_type -> gosdn.core.DeletePndRequest - 4, // 9: gosdn.core.CoreService.GetPnd:output_type -> gosdn.core.GetPndResponse - 3, // 10: gosdn.core.CoreService.GetPndList:output_type -> gosdn.core.GetPndListResponse + 2, // 9: gosdn.core.CoreService.GetPnd:output_type -> gosdn.core.GetPndResponse + 4, // 10: gosdn.core.CoreService.GetPndList:output_type -> gosdn.core.GetPndListResponse 7, // 11: gosdn.core.CoreService.CreatePndList:output_type -> gosdn.core.CreatePndListResponse 9, // 12: gosdn.core.CoreService.DeletePnd:output_type -> gosdn.core.DeletePndResponse 9, // [9:13] is the sub-list for method output_type @@ -713,7 +713,7 @@ func file_gosdn_core_core_proto_init() { } if !protoimpl.UnsafeEnabled { file_gosdn_core_core_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetPndListRequest); i { + switch v := v.(*GetPndRequest); i { case 0: return &v.state case 1: @@ -725,7 +725,7 @@ func file_gosdn_core_core_proto_init() { } } file_gosdn_core_core_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetPndRequest); i { + switch v := v.(*GetPndResponse); i { case 0: return &v.state case 1: @@ -737,7 +737,7 @@ func file_gosdn_core_core_proto_init() { } } file_gosdn_core_core_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetPndListResponse); i { + switch v := v.(*GetPndListRequest); i { case 0: return &v.state case 1: @@ -749,7 +749,7 @@ func file_gosdn_core_core_proto_init() { } } file_gosdn_core_core_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetPndResponse); i { + switch v := v.(*GetPndListResponse); i { case 0: return &v.state case 1: diff --git a/api/go/gosdn/core/core.pb.gw.go b/api/go/gosdn/core/core.pb.gw.go index f20b6b3fcf07850e55869757651a55ebdeccda38..8c56242b632551449573f8c7e56c895e2fe3c12f 100644 --- a/api/go/gosdn/core/core.pb.gw.go +++ b/api/go/gosdn/core/core.pb.gw.go @@ -51,7 +51,7 @@ func request_CoreService_GetPnd_0(ctx context.Context, marshaler runtime.Marshal return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pid") } - protoReq.Pid, err = runtime.StringSlice(val, ",") + protoReq.Pid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pid", err) } @@ -84,7 +84,7 @@ func local_request_CoreService_GetPnd_0(ctx context.Context, marshaler runtime.M return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pid") } - protoReq.Pid, err = runtime.StringSlice(val, ",") + protoReq.Pid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pid", err) } diff --git a/api/go/gosdn/pnd/pnd.pb.go b/api/go/gosdn/pnd/pnd.pb.go index 9c8932f78882451f848dd0f992e8c66bfd44b5b3..8b52d80fe24ce2736647ae104ff754eaa8be9562 100644 --- a/api/go/gosdn/pnd/pnd.pb.go +++ b/api/go/gosdn/pnd/pnd.pb.go @@ -346,9 +346,9 @@ type GetOndRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // Timestamp in nanoseconds since Epoch. - Did []string `protobuf:"bytes,2,rep,name=did,proto3" json:"did,omitempty"` - Pid string `protobuf:"bytes,3,opt,name=pid,proto3" json:"pid,omitempty"` + Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // Timestamp in nanoseconds since Epoch. + Did string `protobuf:"bytes,2,opt,name=did,proto3" json:"did,omitempty"` + Pid string `protobuf:"bytes,3,opt,name=pid,proto3" json:"pid,omitempty"` } func (x *GetOndRequest) Reset() { @@ -390,11 +390,11 @@ func (x *GetOndRequest) GetTimestamp() int64 { return 0 } -func (x *GetOndRequest) GetDid() []string { +func (x *GetOndRequest) GetDid() string { if x != nil { return x.Did } - return nil + return "" } func (x *GetOndRequest) GetPid() string { @@ -464,9 +464,9 @@ type GetSbiRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // Timestamp in nanoseconds since Epoch. - Sid []string `protobuf:"bytes,2,rep,name=sid,proto3" json:"sid,omitempty"` - Pid string `protobuf:"bytes,3,opt,name=pid,proto3" json:"pid,omitempty"` + Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // Timestamp in nanoseconds since Epoch. + Sid string `protobuf:"bytes,2,opt,name=sid,proto3" json:"sid,omitempty"` + Pid string `protobuf:"bytes,3,opt,name=pid,proto3" json:"pid,omitempty"` } func (x *GetSbiRequest) Reset() { @@ -508,11 +508,11 @@ func (x *GetSbiRequest) GetTimestamp() int64 { return 0 } -func (x *GetSbiRequest) GetSid() []string { +func (x *GetSbiRequest) GetSid() string { if x != nil { return x.Sid } - return nil + return "" } func (x *GetSbiRequest) GetPid() string { @@ -719,8 +719,8 @@ type GetOndResponse struct { Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // Timestamp in nanoseconds since Epoch. // TODO: Check if this is really needed. Perhaps a reference to the PND's ID // is also sufficient. - Pnd *PrincipalNetworkDomain `protobuf:"bytes,2,opt,name=pnd,proto3" json:"pnd,omitempty"` - Ond []*OrchestratedNetworkingDevice `protobuf:"bytes,3,rep,name=ond,proto3" json:"ond,omitempty"` + Pnd *PrincipalNetworkDomain `protobuf:"bytes,2,opt,name=pnd,proto3" json:"pnd,omitempty"` + Ond *OrchestratedNetworkingDevice `protobuf:"bytes,3,opt,name=ond,proto3" json:"ond,omitempty"` } func (x *GetOndResponse) Reset() { @@ -769,7 +769,7 @@ func (x *GetOndResponse) GetPnd() *PrincipalNetworkDomain { return nil } -func (x *GetOndResponse) GetOnd() []*OrchestratedNetworkingDevice { +func (x *GetOndResponse) GetOnd() *OrchestratedNetworkingDevice { if x != nil { return x.Ond } @@ -849,8 +849,8 @@ type GetSbiResponse struct { Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // Timestamp in nanoseconds since Epoch. // TODO: Check if this is really needed. Perhaps a reference to the PND's ID // is also sufficient. - Pnd *PrincipalNetworkDomain `protobuf:"bytes,2,opt,name=pnd,proto3" json:"pnd,omitempty"` - Sbi []*southbound.SouthboundInterface `protobuf:"bytes,3,rep,name=sbi,proto3" json:"sbi,omitempty"` + Pnd *PrincipalNetworkDomain `protobuf:"bytes,2,opt,name=pnd,proto3" json:"pnd,omitempty"` + Sbi *southbound.SouthboundInterface `protobuf:"bytes,3,opt,name=sbi,proto3" json:"sbi,omitempty"` } func (x *GetSbiResponse) Reset() { @@ -899,7 +899,7 @@ func (x *GetSbiResponse) GetPnd() *PrincipalNetworkDomain { return nil } -func (x *GetSbiResponse) GetSbi() []*southbound.SouthboundInterface { +func (x *GetSbiResponse) GetSbi() *southbound.SouthboundInterface { if x != nil { return x.Sbi } @@ -2383,7 +2383,7 @@ var file_gosdn_pnd_pnd_proto_rawDesc = []byte{ 0x65, 0x74, 0x4f, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x64, 0x69, - 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x64, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, + 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x64, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x70, 0x69, 0x64, 0x22, 0x43, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x53, 0x62, 0x69, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, @@ -2392,7 +2392,7 @@ var file_gosdn_pnd_pnd_proto_rawDesc = []byte{ 0x70, 0x69, 0x64, 0x22, 0x51, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x53, 0x62, 0x69, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x6d, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x70, 0x69, 0x64, 0x22, 0x46, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, @@ -2417,7 +2417,7 @@ var file_gosdn_pnd_pnd_proto_rawDesc = []byte{ 0x33, 0x0a, 0x03, 0x70, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x70, 0x6e, 0x64, 0x2e, 0x50, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, 0x6c, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, - 0x03, 0x70, 0x6e, 0x64, 0x12, 0x39, 0x0a, 0x03, 0x6f, 0x6e, 0x64, 0x18, 0x03, 0x20, 0x03, 0x28, + 0x03, 0x70, 0x6e, 0x64, 0x12, 0x39, 0x0a, 0x03, 0x6f, 0x6e, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x70, 0x6e, 0x64, 0x2e, 0x4f, 0x72, 0x63, 0x68, 0x65, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x52, 0x03, 0x6f, 0x6e, 0x64, 0x22, @@ -2438,7 +2438,7 @@ var file_gosdn_pnd_pnd_proto_rawDesc = []byte{ 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x70, 0x6e, 0x64, 0x2e, 0x50, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, 0x6c, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x03, 0x70, 0x6e, 0x64, 0x12, 0x37, 0x0a, 0x03, 0x73, 0x62, - 0x69, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, + 0x69, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x73, 0x6f, 0x75, 0x74, 0x68, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x2e, 0x53, 0x6f, 0x75, 0x74, 0x68, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x52, 0x03, 0x73, 0x62, 0x69, 0x22, 0xa0, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x53, 0x62, 0x69, 0x4c, 0x69, diff --git a/api/go/gosdn/pnd/pnd.pb.gw.go b/api/go/gosdn/pnd/pnd.pb.gw.go index 61782289d2fe3e82e9d8c6ed67ec974f1e0d025a..2c59921a9a36b169854bf52d9cdbb2f9dc37c5c1 100644 --- a/api/go/gosdn/pnd/pnd.pb.gw.go +++ b/api/go/gosdn/pnd/pnd.pb.gw.go @@ -131,7 +131,7 @@ func request_PndService_GetOnd_0(ctx context.Context, marshaler runtime.Marshale return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "did") } - protoReq.Did, err = runtime.StringSlice(val, ",") + protoReq.Did, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "did", err) } @@ -174,7 +174,7 @@ func local_request_PndService_GetOnd_0(ctx context.Context, marshaler runtime.Ma return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "did") } - protoReq.Did, err = runtime.StringSlice(val, ",") + protoReq.Did, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "did", err) } @@ -359,7 +359,7 @@ func request_PndService_GetSbi_0(ctx context.Context, marshaler runtime.Marshale return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sid") } - protoReq.Sid, err = runtime.StringSlice(val, ",") + protoReq.Sid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sid", err) } @@ -402,7 +402,7 @@ func local_request_PndService_GetSbi_0(ctx context.Context, marshaler runtime.Ma return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sid") } - protoReq.Sid, err = runtime.StringSlice(val, ",") + protoReq.Sid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sid", err) } diff --git a/api/openapiv2/gosdn_northbound.swagger.json b/api/openapiv2/gosdn_northbound.swagger.json index 17faac28f31e826652b51dfb0d6a88fa76b87b9d..7752e8aa07811f91ea044176236fd0e4dcf505a3 100644 --- a/api/openapiv2/gosdn_northbound.swagger.json +++ b/api/openapiv2/gosdn_northbound.swagger.json @@ -18,13 +18,13 @@ "name": "PndService" }, { - "name": "gNMI" + "name": "Collector" }, { - "name": "AuthService" + "name": "gNMI" }, { - "name": "UserService" + "name": "AgentManager" }, { "name": "SbiService" @@ -36,13 +36,13 @@ "name": "CsbiService" }, { - "name": "AgentManager" + "name": "AuthService" }, { "name": "RoleService" }, { - "name": "Collector" + "name": "UserService" } ], "consumes": [ @@ -146,12 +146,7 @@ "name": "pid", "in": "path", "required": true, - "type": "array", - "items": { - "type": "string" - }, - "collectionFormat": "csv", - "minItems": 1 + "type": "string" }, { "name": "timestamp", @@ -432,12 +427,7 @@ "name": "did", "in": "path", "required": true, - "type": "array", - "items": { - "type": "string" - }, - "collectionFormat": "csv", - "minItems": 1 + "type": "string" }, { "name": "timestamp", @@ -800,12 +790,7 @@ "name": "sid", "in": "path", "required": true, - "type": "array", - "items": { - "type": "string" - }, - "collectionFormat": "csv", - "minItems": 1 + "type": "string" }, { "name": "timestamp", @@ -1319,10 +1304,7 @@ "format": "int64" }, "pnd": { - "type": "array", - "items": { - "$ref": "#/definitions/pndPrincipalNetworkDomain" - } + "$ref": "#/definitions/pndPrincipalNetworkDomain" } } }, @@ -2688,10 +2670,7 @@ "description": "TODO: Check if this is really needed. Perhaps a reference to the PND's ID\nis also sufficient." }, "ond": { - "type": "array", - "items": { - "$ref": "#/definitions/pndOrchestratedNetworkingDevice" - } + "$ref": "#/definitions/pndOrchestratedNetworkingDevice" } } }, @@ -2745,10 +2724,7 @@ "description": "TODO: Check if this is really needed. Perhaps a reference to the PND's ID\nis also sufficient." }, "sbi": { - "type": "array", - "items": { - "$ref": "#/definitions/southboundSouthboundInterface" - } + "$ref": "#/definitions/southboundSouthboundInterface" } } }, diff --git a/api/proto/buf.lock b/api/proto/buf.lock index ffdb2e27965db67d48e5a62a29ce2580e19fadec..87b5db40a38f740a05fd512626def460cf8ce415 100644 --- a/api/proto/buf.lock +++ b/api/proto/buf.lock @@ -4,14 +4,8 @@ deps: - remote: buf.build owner: googleapis repository: googleapis - branch: main - commit: f3590c56d388417ebbedefae77ac12bf - digest: b1-nbZ1ZLsYdwXyEysqVWKYATvTXYr_alNRBebrjXpIv6k= - create_time: 2022-04-23T15:03:48.462865Z + commit: 8ab0a452adb64b36ac7a40ae95bd59b2 - remote: buf.build owner: grpc-ecosystem repository: grpc-gateway - branch: main commit: febd9e8be39b4f4b878b9c64bcc203fd - digest: b1-K5jSHBrJ24jZXRgQgkmphZuP-cAL2b90ssKrgvDK2hU= - create_time: 2022-04-17T01:28:07.574665Z diff --git a/api/proto/gosdn/core/core.proto b/api/proto/gosdn/core/core.proto index a55a8dd17293a84a0353569cb49aa55762ef46bc..d2476f3897755c07298973f159a11ca888ae96e6 100644 --- a/api/proto/gosdn/core/core.proto +++ b/api/proto/gosdn/core/core.proto @@ -35,25 +35,26 @@ service CoreService { } } -message GetPndListRequest { - int64 timestamp = 1; // Timestamp in nanoseconds since Epoch. -} message GetPndRequest { int64 timestamp = 1; // Timestamp in nanoseconds since Epoch. - repeated string pid = 3; + string pid = 2; } -message GetPndListResponse { +message GetPndResponse { int64 timestamp = 1; // Timestamp in nanoseconds since Epoch. - repeated .gosdn.pnd.PrincipalNetworkDomain pnd = 2; + .gosdn.pnd.PrincipalNetworkDomain pnd = 2; } -message GetPndResponse { - int64 timestamp = 1; // Timestamp in nanoseconds since Epoch. - repeated .gosdn.pnd.PrincipalNetworkDomain pnd = 2; +message GetPndListRequest { + int64 timestamp = 1; // Timestamp in nanoseconds since Epoch. } +message GetPndListResponse { + int64 timestamp = 1; // Timestamp in nanoseconds since Epoch. + repeated .gosdn.pnd.PrincipalNetworkDomain pnd = 2; + } + message CreatePndListRequest { int64 timestamp = 1; // Timestamp in nanoseconds since Epoch. repeated PndCreateProperties pnd = 2; diff --git a/api/proto/gosdn/pnd/pnd.proto b/api/proto/gosdn/pnd/pnd.proto index 927c0cd89cfa4e6b04fb3e7b3fa1f20546dd1585..d68ef4940e68f6987808b4482fe8137136a9393f 100644 --- a/api/proto/gosdn/pnd/pnd.proto +++ b/api/proto/gosdn/pnd/pnd.proto @@ -123,7 +123,7 @@ message GetOndListRequest { message GetOndRequest { int64 timestamp = 1; // Timestamp in nanoseconds since Epoch. - repeated string did = 2; + string did = 2; string pid = 3; } @@ -131,9 +131,10 @@ message GetSbiListRequest { int64 timestamp = 1; // Timestamp in nanoseconds since Epoch. string pid = 2; } + message GetSbiRequest { int64 timestamp = 1; // Timestamp in nanoseconds since Epoch. - repeated string sid = 2; + string sid = 2; string pid = 3; } @@ -160,7 +161,7 @@ message GetOndResponse { // TODO: Check if this is really needed. Perhaps a reference to the PND's ID // is also sufficient. PrincipalNetworkDomain pnd = 2; - repeated OrchestratedNetworkingDevice ond = 3; + OrchestratedNetworkingDevice ond = 3; } message GetOndListResponse { @@ -176,7 +177,7 @@ message GetSbiResponse { // TODO: Check if this is really needed. Perhaps a reference to the PND's ID // is also sufficient. PrincipalNetworkDomain pnd = 2; - repeated .gosdn.southbound.SouthboundInterface sbi = 3; + .gosdn.southbound.SouthboundInterface sbi = 3; } message GetSbiListResponse { diff --git a/cli/adapter/PndAdapter.go b/cli/adapter/PndAdapter.go index 53339e847d9db71e8f9d58506cd49e8f32721b75..a02ac56ea36adfc4f457dd03484b76fbf1d8e8fa 100644 --- a/cli/adapter/PndAdapter.go +++ b/cli/adapter/PndAdapter.go @@ -66,8 +66,8 @@ func (p *PndAdapter) GetSbiSchemaTree(ctx context.Context, sid uuid.UUID) (map[s // GetDevice requests one or multiple devices belonging to a given // PrincipalNetworkDomain from the controller. -func (p *PndAdapter) GetDevice(ctx context.Context, identifier ...string) (*ppb.GetOndResponse, error) { - resp, err := api.GetDevice(ctx, p.endpoint, p.id.String(), identifier...) +func (p *PndAdapter) GetDevice(ctx context.Context, identifier string) (*ppb.GetOndResponse, error) { + resp, err := api.GetDevice(ctx, p.endpoint, p.id.String(), identifier) if err != nil { return nil, err } @@ -165,8 +165,8 @@ func (p *PndAdapter) ContainsDevice(uuid.UUID) bool { // GetSbi sends an API call to the controller requesting the // registered SBI with the provided ID. -func (p *PndAdapter) GetSbi(ctx context.Context, sid ...string) (*ppb.GetSbiResponse, error) { - resp, err := api.GetSbi(ctx, p.endpoint, p.id.String(), sid...) +func (p *PndAdapter) GetSbi(ctx context.Context, sid string) (*ppb.GetSbiResponse, error) { + resp, err := api.GetSbi(ctx, p.endpoint, p.id.String(), sid) if err != nil { return nil, err } diff --git a/cli/cmd/deviceShow.go b/cli/cmd/deviceShow.go index 1e15368251a87e3bf089c1841491e356ef291f01..12b08b7269fbb435d4e83556122789a16d4a222a 100644 --- a/cli/cmd/deviceShow.go +++ b/cli/cmd/deviceShow.go @@ -52,10 +52,23 @@ The actual device is not queried directly.`, pterm.Error.Println(err) return err } - data := pterm.TableData{[]string{"UUID", "Name", "SBI-UUID", "SBI-Type"}} - for _, dev := range resp.GetOnd() { - data = append(data, []string{dev.GetId(), dev.GetName(), dev.GetSbi().GetId(), dev.GetSbi().GetType().String()}) - } + + dev := resp.GetOnd() + + panel1 := pterm.DefaultBox.WithTitle("UUID:").Sprint(dev.Id) + panel2 := pterm.DefaultBox.WithTitle("Name:").Sprint(dev.Name) + panel3 := pterm.DefaultBox.WithTitle("SBI-UUID:").Sprint(dev.Sbi.Id) + panel4 := pterm.DefaultBox.WithTitle("SBI-Type:").Sprint(dev.Sbi.Type.String()) + + panels, _ := pterm.DefaultPanel.WithPanels(pterm.Panels{ + {{Data: panel1}}, + {{Data: panel2}}, + {{Data: panel3}}, + {{Data: panel4}}, + }).Srender() + + pterm.DefaultBox.WithRightPadding(0).WithBottomPadding(0).Println(panels) + return nil }, } diff --git a/cli/cmd/pndGet.go b/cli/cmd/pndGet.go index 7fa6c956fa3f98f299e46c0ea46d3df2e80d67a6..735018a6f0077c51b07a5ba0c305d08d9b1c2954 100644 --- a/cli/cmd/pndGet.go +++ b/cli/cmd/pndGet.go @@ -40,23 +40,31 @@ import ( // pndGetCmd represents the get command var pndGetCmd = &cobra.Command{ Use: "get", - Short: "get one or multiple PNDs by uuid or name and print them to stdout", - Long: `Get one or multiple PNDs by uuid or name and print them to stdout.`, + Args: cobra.ExactArgs(1), + Short: "Request a PND by uuid.", + Long: `Request a PND specified by uuid. The PND's UUID, Name and Description are returned.`, RunE: func(cmd *cobra.Command, args []string) error { spinner, _ := pterm.DefaultSpinner.Start("Fetching requested PNDs from controller.") - resp, err := api.GetPnd(createContextWithAuthorization(), viper.GetString("controllerApiEndpoint"), args...) + resp, err := api.GetPnd(createContextWithAuthorization(), viper.GetString("controllerApiEndpoint"), args[0]) if err != nil { spinner.Fail(err) return err } - data := pterm.TableData{[]string{"UUID", "Name", "Description"}} - for _, pnd := range resp.Pnd { - data = append(data, []string{pnd.GetId(), pnd.GetName(), pnd.GetDescription()}) - } + pnd := resp.Pnd + panel1 := pterm.DefaultBox.WithTitle("UUID:").Sprint(pnd.Id) + panel2 := pterm.DefaultBox.WithTitle("Name:").Sprint(pnd.Name) + panel3 := pterm.DefaultBox.WithTitle("Description:").Sprint(pnd.Description) + + panels, _ := pterm.DefaultPanel.WithPanels(pterm.Panels{ + {{Data: panel1}}, + {{Data: panel2}}, + {{Data: panel3}}, + }).Srender() + spinner.Success() - pterm.DefaultTable.WithHasHeader().WithData(data).Render() + pterm.DefaultBox.WithRightPadding(0).WithBottomPadding(0).Println(panels) return nil }, } diff --git a/cli/cmd/prompt.go b/cli/cmd/prompt.go index ecbb6f12ac5f933fe6cbb131d6cb6c16f1708ca8..20be885d3f62c66c944dbf81f5492af868a640b4 100644 --- a/cli/cmd/prompt.go +++ b/cli/cmd/prompt.go @@ -265,7 +265,7 @@ func getSchemaTreeForDeviceID(id string) (map[string]*yang.Entry, error) { spinner.Fail(err) return nil, err } - sid, err := uuid.Parse(dev.GetOnd()[0].GetSbi().GetId()) + sid, err := uuid.Parse(dev.GetOnd().GetSbi().GetId()) if err != nil { spinner.Fail(err) return nil, err diff --git a/controller/api/apiIntegration_test.go b/controller/api/apiIntegration_test.go index 8a288847339ff1ff24aa6388d0cad891b469de3c..a97a54820db061d3e85f91105982bb903c2547cb 100644 --- a/controller/api/apiIntegration_test.go +++ b/controller/api/apiIntegration_test.go @@ -86,7 +86,6 @@ func TestApiIntegration(t *testing.T) { context.TODO(), testAPIEndpoint, cliPnd, - "", did, ) if (err != nil) != tt.wantErr { @@ -109,7 +108,7 @@ func TestApiIntegration(t *testing.T) { return } - resp, err := GetDevice(context.TODO(), testAddress, testUsername, testPassword, testPath) + resp, err := GetDevice(context.TODO(), testAddress, testUsername, testPassword) if err != nil { if !tt.wantErr { t.Errorf("Get() error = %v, wantErr %v", err, tt.wantErr) @@ -118,7 +117,7 @@ func TestApiIntegration(t *testing.T) { } var got string if resp != nil { - got = resp.Ond[0].Name + got = resp.Ond.Name } else { t.Errorf("integration test failed got cannot be nil") } diff --git a/controller/api/api_test.go b/controller/api/api_test.go index 0f4f904af2aa7dedc1a393879e137cccf037145e..a789e65b18d39981c98b18b2c2b60219849ff011 100644 --- a/controller/api/api_test.go +++ b/controller/api/api_test.go @@ -47,7 +47,7 @@ func Test_GetPnd(t *testing.T) { t.Error(err) return } - got := resp.Pnd[0].Id + got := resp.Pnd.Id if got != pndID { t.Errorf("PND ID is %v, expected %v", got, pndID) } @@ -101,7 +101,7 @@ func Test_GetDevice(t *testing.T) { t.Error(err) return } - got := resp.Ond[0].Id + got := resp.Ond.Id if got != ondID { t.Errorf("PND ID is %v, expected %v", got, ondID) } diff --git a/controller/api/device.go b/controller/api/device.go index b8c6a00141d54df49b6db447e549f18fa782e8b2..9ac80f41bf95713d42959155e1dc51c7d161ab58 100644 --- a/controller/api/device.go +++ b/controller/api/device.go @@ -52,7 +52,7 @@ func AddDevice(ctx context.Context, addr, deviceName string, opt *tpb.TransportO // GetDevice requests one device belonging to a given // PrincipalNetworkDomain from the controller. If no device identifier // is provided, an error is thrown. -func GetDevice(ctx context.Context, addr, pid string, did ...string) (*ppb.GetOndResponse, error) { +func GetDevice(ctx context.Context, addr, pid string, did string) (*ppb.GetOndResponse, error) { pndClient, err := nbi.PndClient(addr, dialOptions...) if err != nil { return nil, err diff --git a/controller/api/pnd.go b/controller/api/pnd.go index 01957053a2a0ca671f19d61653c8c67120f3b05d..a6c9eb0ac0e9c3eb57d88db980c702fd9ebf7b9e 100644 --- a/controller/api/pnd.go +++ b/controller/api/pnd.go @@ -33,7 +33,7 @@ func AddPnd(ctx context.Context, addr, name, description, sbi string) (*pb.Creat // GetPnd requests one PrincipalNetworkDomain from the // controller. -func GetPnd(ctx context.Context, addr string, args ...string) (*pb.GetPndResponse, error) { +func GetPnd(ctx context.Context, addr string, args string) (*pb.GetPndResponse, error) { coreClient, err := nbi.CoreClient(addr, dialOptions...) if err != nil { return nil, err diff --git a/controller/api/sbi.go b/controller/api/sbi.go index 30de02ab087ea5c0698a80d96eaeb76505d26b6f..e34ec6a9d4c61fdbc52dc3876770a7515b7501e2 100644 --- a/controller/api/sbi.go +++ b/controller/api/sbi.go @@ -10,7 +10,7 @@ import ( // GetSbi requests one or more to the provided PND belonging SBIs from the // controller. -func GetSbi(ctx context.Context, addr string, pid string, sid ...string) (*ppb.GetSbiResponse, error) { +func GetSbi(ctx context.Context, addr string, pid string, sid string) (*ppb.GetSbiResponse, error) { client, err := nbi.PndClient(addr, dialOptions...) if err != nil { return nil, err diff --git a/controller/northbound/server/core.go b/controller/northbound/server/core.go index d002ded24df4cc088af9d432aeffb0095d1ce0ad..13a7304c5975738d97f543a7f02f6452c25da171 100644 --- a/controller/northbound/server/core.go +++ b/controller/northbound/server/core.go @@ -22,27 +22,25 @@ func (s core) GetPnd(ctx context.Context, request *pb.GetPndRequest) (*pb.GetPnd start := metrics.StartHook(labels, grpcRequestsTotal) defer metrics.FinishHook(labels, start, grpcRequestDurationSecondsTotal, grpcRequestDurationSeconds) - pndList, err := stringToUUID(request.Pid) + pndID, err := uuid.Parse(request.Pid) if err != nil { return nil, handleRPCError(labels, err) } - pnds := make([]*ppb.PrincipalNetworkDomain, len(pndList)) - for i, id := range pndList { - pnd, err := pndc.Get(store.Query{ID: id}) - if err != nil { - return nil, err - } + storedPnd, err := pndc.Get(store.Query{ID: pndID}) + if err != nil { + return nil, err + } - pnds[i] = &ppb.PrincipalNetworkDomain{ - Id: pnd.ID().String(), - Name: pnd.GetName(), - Description: pnd.GetDescription(), - } + pnd := &ppb.PrincipalNetworkDomain{ + Id: storedPnd.ID().String(), + Name: storedPnd.GetName(), + Description: storedPnd.GetDescription(), } + return &pb.GetPndResponse{ Timestamp: time.Now().UnixNano(), - Pnd: pnds, + Pnd: pnd, }, nil } diff --git a/controller/northbound/server/core_test.go b/controller/northbound/server/core_test.go index 86a36afc739716c1bbac9f1306edb60e368debdc..ba01c8c4c930d12f0a80fc71e3ee89f568205aff 100644 --- a/controller/northbound/server/core_test.go +++ b/controller/northbound/server/core_test.go @@ -66,7 +66,6 @@ func Test_core_GetPnd(t *testing.T) { name string args args want []string - length int wantErr bool }{ { @@ -74,12 +73,9 @@ func Test_core_GetPnd(t *testing.T) { args: args{ ctx: context.Background(), request: &pb.GetPndRequest{ - Pid: []string{ - pndID, - }, + Pid: pndID, }, }, - length: 1, want: []string{ pndID, "test", @@ -87,6 +83,7 @@ func Test_core_GetPnd(t *testing.T) { }, }, } + for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { s := core{ @@ -100,18 +97,14 @@ func Test_core_GetPnd(t *testing.T) { if tt.name == "default" { got := []string{ - resp.Pnd[0].Id, - resp.Pnd[0].Name, - resp.Pnd[0].Description, + resp.Pnd.Id, + resp.Pnd.Name, + resp.Pnd.Description, } if !reflect.DeepEqual(got, tt.want) { t.Errorf("core.GetPnd() = %v, want %v", got, tt.want) } } - length := len(resp.Pnd) - if tt.length != length { - t.Errorf("core.GetPnd() = %v, want %v", length, tt.length) - } }) } } diff --git a/controller/northbound/server/pnd.go b/controller/northbound/server/pnd.go index 2ef00339a2aabb3c4ac8faabe6268e8bfdbabae1..fbd7e730879d7e3a5b55229729a9ef49dee45f9a 100644 --- a/controller/northbound/server/pnd.go +++ b/controller/northbound/server/pnd.go @@ -42,7 +42,7 @@ func (p pndServer) GetOnd(ctx context.Context, request *ppb.GetOndRequest) (*ppb log.Error(err) return nil, status.Errorf(codes.Aborted, "%v", err) } - onds, err := fillOnds(pnd, false, request.Did...) + onds, err := fillOnd(pnd, request.Did) if err != nil { log.Error(err) return nil, status.Errorf(codes.Aborted, "%v", err) @@ -72,7 +72,7 @@ func (p pndServer) GetOndList(ctx context.Context, request *ppb.GetOndListReques log.Error(err) return nil, status.Errorf(codes.Aborted, "%v", err) } - onds, err := fillOnds(pnd, true) + onds, err := fillOnds(pnd) if err != nil { log.Error(err) return nil, status.Errorf(codes.Aborted, "%v", err) @@ -88,58 +88,50 @@ func (p pndServer) GetOndList(ctx context.Context, request *ppb.GetOndListReques }, nil } -func fillOnds(pnd networkdomain.NetworkDomain, all bool, did ...string) ([]*ppb.OrchestratedNetworkingDevice, error) { - var ondList []device.Device - var onds []*ppb.OrchestratedNetworkingDevice +func fillOnd(pnd networkdomain.NetworkDomain, did string) (*ppb.OrchestratedNetworkingDevice, error) { + d, err := pnd.GetDevice(did) + if err != nil { + log.Error(err) + return nil, status.Errorf(codes.Aborted, "%v", err) + } + cfg := ygot.GNMINotificationsConfig{} + dev, err := ygot.TogNMINotifications(d.GetModel(), time.Now().UnixNano(), cfg) + if err != nil { + log.Error(err) + return nil, status.Errorf(codes.Aborted, "%v", err) + } - // all indicates if a client wants all devices or only a single one - switch all { - case true: - ondList = pnd.Devices() - onds = make([]*ppb.OrchestratedNetworkingDevice, len(ondList)) - for _, dev := range ondList { - did = append(did, dev.ID().String()) - } + sbi := spb.SouthboundInterface{} + if d.SBI() != nil { + sbi.Id = d.SBI().ID().String() + sbi.Type = d.SBI().Type() + } - default: - if len(did) == 0 { - err := &errors.ErrInvalidParameters{ - Func: fillOnds, - Param: "length of 'did' cannot be '0' when 'all' is set to 'false'", - } - log.Error(err) + return &ppb.OrchestratedNetworkingDevice{ + Id: did, + Name: d.Name(), + Device: dev, + Sbi: &sbi, + }, nil +} - return nil, err - } +func fillOnds(pnd networkdomain.NetworkDomain) ([]*ppb.OrchestratedNetworkingDevice, error) { + var ondList []device.Device + var onds []*ppb.OrchestratedNetworkingDevice + + ondList = pnd.Devices() + var did []string - onds = make([]*ppb.OrchestratedNetworkingDevice, 1) + for _, dev := range ondList { + did = append(did, dev.ID().String()) } - for i, id := range did { - d, err := pnd.GetDevice(id) + for _, id := range did { + ond, err := fillOnd(pnd, id) if err != nil { - log.Error(err) - return nil, status.Errorf(codes.Aborted, "%v", err) - } - cfg := ygot.GNMINotificationsConfig{} - dev, err := ygot.TogNMINotifications(d.GetModel(), time.Now().UnixNano(), cfg) - if err != nil { - log.Error(err) - return nil, status.Errorf(codes.Aborted, "%v", err) - } - - sbi := spb.SouthboundInterface{} - if d.SBI() != nil { - sbi.Id = d.SBI().ID().String() - sbi.Type = d.SBI().Type() - } - - onds[i] = &ppb.OrchestratedNetworkingDevice{ - Id: id, - Name: d.Name(), - Device: dev, - Sbi: &sbi, + return nil, err } + onds = append(onds, ond) } return onds, nil @@ -253,7 +245,13 @@ func (p pndServer) GetSbi(ctx context.Context, request *ppb.GetSbiRequest) (*ppb log.Error(err) return nil, status.Errorf(codes.Aborted, "%v", err) } - sbis, err := fillSbis(pnd, false, request.Sid...) + + sbiID, err := uuid.Parse(request.Sid) + if err != nil { + return nil, err + } + + sbi, err := pnd.GetSBI(sbiID) if err != nil { log.Error(err) return nil, status.Errorf(codes.Aborted, "%v", err) @@ -265,7 +263,10 @@ func (p pndServer) GetSbi(ctx context.Context, request *ppb.GetSbiRequest) (*ppb Name: pnd.GetName(), Description: pnd.GetDescription(), }, - Sbi: sbis, + Sbi: &spb.SouthboundInterface{ + Id: sbiID.String(), + Type: sbi.Type(), + }, }, nil } @@ -283,7 +284,7 @@ func (p pndServer) GetSbiList(ctx context.Context, request *ppb.GetSbiListReques log.Error(err) return nil, status.Errorf(codes.Aborted, "%v", err) } - sbis, err := fillSbis(pnd, true, "") + sbis, err := fillSbis(pnd) if err != nil { log.Error(err) return nil, status.Errorf(codes.Aborted, "%v", err) @@ -299,7 +300,7 @@ func (p pndServer) GetSbiList(ctx context.Context, request *ppb.GetSbiListReques }, nil } -func fillSbis(pnd networkdomain.NetworkDomain, all bool, sid ...string) ([]*spb.SouthboundInterface, error) { +func fillSbis(pnd networkdomain.NetworkDomain) ([]*spb.SouthboundInterface, error) { sbis, err := pnd.GetSBIs() if err != nil { return nil, err @@ -320,7 +321,7 @@ func fillSbis(pnd networkdomain.NetworkDomain, all bool, sid ...string) ([]*spb. return sbisToReturn, nil } -func stringToUUID(sid []string) ([]uuid.UUID, error) { +func stringArrayToUUIDs(sid []string) ([]uuid.UUID, error) { UUIDs := make([]uuid.UUID, len(sid)) for i, id := range sid { parsed, err := uuid.Parse(id) @@ -454,7 +455,7 @@ func fillChanges(pnd networkdomain.NetworkDomain, all bool, cuid ...string) ([]* Param: "length of 'did' cannot be '0' when 'all' is set to 'false'", } } - changeList, err = stringToUUID(cuid) + changeList, err = stringArrayToUUIDs(cuid) if err != nil { log.Error(err) return nil, status.Errorf(codes.Aborted, "%v", err) diff --git a/controller/northbound/server/pnd_test.go b/controller/northbound/server/pnd_test.go index 6fa7ea4064a2fd9b6b60c6777cb9c344797b60df..a50a8185724aec2751ceece8b68f349214cface8 100644 --- a/controller/northbound/server/pnd_test.go +++ b/controller/northbound/server/pnd_test.go @@ -180,19 +180,18 @@ func Test_pnd_Get(t *testing.T) { args: args{ ctx: context.Background(), request: &pb.GetPndRequest{ - Pid: []string{ - pndID}, + Pid: pndID, }, }, want: &pb.GetPndResponse{ - Pnd: []*ppb.PrincipalNetworkDomain{ - {Id: pndID, - Name: "test", - Description: "test"}, - }, + Pnd: &ppb.PrincipalNetworkDomain{ + Id: pndID, + Name: "test", + Description: "test"}, }, }, } + for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { p := core{