Skip to content
Snippets Groups Projects

Using string type for IDs

Merged Cristina Pauna requested to merge id-as-string into main
8 files
+ 296
138
Compare changes
  • Side-by-side
  • Inline
Files
8
+ 200
45
@@ -22,13 +22,125 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// The broad type of error, should not be too collection module specific
type Error_Code int32
const (
Error_ERROR_UNKNOWN Error_Code = 0
Error_ERROR_INVALID_CONFIGURATION Error_Code = 1 // The collection module configuration did not allow for collection
// (e.g. Port number 1000000)
Error_ERROR_CONNECTION_FAILURE Error_Code = 2 // The service could not be reached (e.g. Timeout)
Error_ERROR_PROTOCOL_VIOLATION Error_Code = 3 // The service did not behave as expected
)
// Enum value maps for Error_Code.
var (
Error_Code_name = map[int32]string{
0: "ERROR_UNKNOWN",
1: "ERROR_INVALID_CONFIGURATION",
2: "ERROR_CONNECTION_FAILURE",
3: "ERROR_PROTOCOL_VIOLATION",
}
Error_Code_value = map[string]int32{
"ERROR_UNKNOWN": 0,
"ERROR_INVALID_CONFIGURATION": 1,
"ERROR_CONNECTION_FAILURE": 2,
"ERROR_PROTOCOL_VIOLATION": 3,
}
)
func (x Error_Code) Enum() *Error_Code {
p := new(Error_Code)
*p = x
return p
}
func (x Error_Code) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (Error_Code) Descriptor() protoreflect.EnumDescriptor {
return file_api_common_evidence_proto_enumTypes[0].Descriptor()
}
func (Error_Code) Type() protoreflect.EnumType {
return &file_api_common_evidence_proto_enumTypes[0]
}
func (x Error_Code) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use Error_Code.Descriptor instead.
func (Error_Code) EnumDescriptor() ([]byte, []int) {
return file_api_common_evidence_proto_rawDescGZIP(), []int{0, 0}
}
// An error result
type Error struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// The type of error
Code Error_Code `protobuf:"varint,1,opt,name=code,proto3,enum=cam.Error_Code" json:"code,omitempty"`
// Optional. A human-readable description of the error.
Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
}
func (x *Error) Reset() {
*x = Error{}
if protoimpl.UnsafeEnabled {
mi := &file_api_common_evidence_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Error) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Error) ProtoMessage() {}
func (x *Error) ProtoReflect() protoreflect.Message {
mi := &file_api_common_evidence_proto_msgTypes[0]
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 Error.ProtoReflect.Descriptor instead.
func (*Error) Descriptor() ([]byte, []int) {
return file_api_common_evidence_proto_rawDescGZIP(), []int{0}
}
func (x *Error) GetCode() Error_Code {
if x != nil {
return x.Code
}
return Error_ERROR_UNKNOWN
}
func (x *Error) GetDescription() string {
if x != nil {
return x.Description
}
return ""
}
// An evidence resource
type Evidence struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
TargetService string `protobuf:"bytes,3,opt,name=target_service,json=targetService,proto3" json:"target_service,omitempty"`
// Optional. Specific to the service, e.g. resource ID within service
@@ -37,8 +149,11 @@ type Evidence struct {
GatheredUsing string `protobuf:"bytes,5,opt,name=gathered_using,json=gatheredUsing,proto3" json:"gathered_using,omitempty"`
// Time of evidence creation
GatheredAt *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=gathered_at,json=gatheredAt,proto3" json:"gathered_at,omitempty"`
// Depends on the type of evidence
// Conditional, Mutually exclusive with error. The measured value. Depends on
// the type of evidence
Value *structpb.Value `protobuf:"bytes,7,opt,name=value,proto3" json:"value,omitempty"`
// Conditional, Mutually exclusive with value. An error
Error *Error `protobuf:"bytes,8,opt,name=error,proto3" json:"error,omitempty"`
// Optional. E.g. a JSON representation of the raw underlying evidence
RawEvidence string `protobuf:"bytes,10,opt,name=raw_evidence,json=rawEvidence,proto3" json:"raw_evidence,omitempty"`
}
@@ -46,7 +161,7 @@ type Evidence struct {
func (x *Evidence) Reset() {
*x = Evidence{}
if protoimpl.UnsafeEnabled {
mi := &file_api_common_evidence_proto_msgTypes[0]
mi := &file_api_common_evidence_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -59,7 +174,7 @@ func (x *Evidence) String() string {
func (*Evidence) ProtoMessage() {}
func (x *Evidence) ProtoReflect() protoreflect.Message {
mi := &file_api_common_evidence_proto_msgTypes[0]
mi := &file_api_common_evidence_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -72,14 +187,14 @@ func (x *Evidence) ProtoReflect() protoreflect.Message {
// Deprecated: Use Evidence.ProtoReflect.Descriptor instead.
func (*Evidence) Descriptor() ([]byte, []int) {
return file_api_common_evidence_proto_rawDescGZIP(), []int{0}
return file_api_common_evidence_proto_rawDescGZIP(), []int{1}
}
func (x *Evidence) GetId() int64 {
func (x *Evidence) GetId() string {
if x != nil {
return x.Id
}
return 0
return ""
}
func (x *Evidence) GetName() string {
@@ -124,6 +239,13 @@ func (x *Evidence) GetValue() *structpb.Value {
return nil
}
func (x *Evidence) GetError() *Error {
if x != nil {
return x.Error
}
return nil
}
func (x *Evidence) GetRawEvidence() string {
if x != nil {
return x.RawEvidence
@@ -140,31 +262,46 @@ var file_api_common_evidence_proto_rawDesc = []byte{
0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f,
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f,
0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
0xb3, 0x02, 0x0a, 0x08, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02,
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04,
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65,
0x12, 0x25, 0x0a, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69,
0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74,
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x74, 0x61, 0x72, 0x67, 0x65,
0x74, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09,
0x52, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
0x12, 0x25, 0x0a, 0x0e, 0x67, 0x61, 0x74, 0x68, 0x65, 0x72, 0x65, 0x64, 0x5f, 0x75, 0x73, 0x69,
0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x67, 0x61, 0x74, 0x68, 0x65, 0x72,
0x65, 0x64, 0x55, 0x73, 0x69, 0x6e, 0x67, 0x12, 0x3b, 0x0a, 0x0b, 0x67, 0x61, 0x74, 0x68, 0x65,
0x72, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67,
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54,
0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x67, 0x61, 0x74, 0x68, 0x65, 0x72,
0x65, 0x64, 0x41, 0x74, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x07, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c,
0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x72, 0x61, 0x77, 0x5f, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e,
0x63, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x72, 0x61, 0x77, 0x45, 0x76, 0x69,
0x64, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x4a, 0x5a, 0x48, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x2e,
0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x61, 0x69, 0x61, 0x2d, 0x78, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2d,
0x69, 0x6e, 0x66, 0x72, 0x61, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x65, 0x2d, 0x66,
0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x73, 0x2f, 0x63, 0x61, 0x6d, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f,
0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0xc6, 0x01, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x23, 0x0a, 0x04, 0x63, 0x6f, 0x64,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0f, 0x2e, 0x63, 0x61, 0x6d, 0x2e, 0x45, 0x72,
0x72, 0x6f, 0x72, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x20,
0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e,
0x22, 0x76, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x11, 0x0a, 0x0d, 0x45, 0x52, 0x52, 0x4f,
0x52, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x1f, 0x0a, 0x1b, 0x45,
0x52, 0x52, 0x4f, 0x52, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x5f, 0x43, 0x4f, 0x4e,
0x46, 0x49, 0x47, 0x55, 0x52, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x01, 0x12, 0x1c, 0x0a, 0x18,
0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e,
0x5f, 0x46, 0x41, 0x49, 0x4c, 0x55, 0x52, 0x45, 0x10, 0x02, 0x12, 0x1c, 0x0a, 0x18, 0x45, 0x52,
0x52, 0x4f, 0x52, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x43, 0x4f, 0x4c, 0x5f, 0x56, 0x49, 0x4f,
0x4c, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x03, 0x22, 0xd5, 0x02, 0x0a, 0x08, 0x45, 0x76, 0x69,
0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x61, 0x72,
0x67, 0x65, 0x74, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28,
0x09, 0x52, 0x0d, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x12, 0x27, 0x0a, 0x0f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75,
0x72, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65,
0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x67, 0x61, 0x74,
0x68, 0x65, 0x72, 0x65, 0x64, 0x5f, 0x75, 0x73, 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28,
0x09, 0x52, 0x0d, 0x67, 0x61, 0x74, 0x68, 0x65, 0x72, 0x65, 0x64, 0x55, 0x73, 0x69, 0x6e, 0x67,
0x12, 0x3b, 0x0a, 0x0b, 0x67, 0x61, 0x74, 0x68, 0x65, 0x72, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18,
0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d,
0x70, 0x52, 0x0a, 0x67, 0x61, 0x74, 0x68, 0x65, 0x72, 0x65, 0x64, 0x41, 0x74, 0x12, 0x2c, 0x0a,
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67,
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56,
0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x20, 0x0a, 0x05, 0x65,
0x72, 0x72, 0x6f, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x63, 0x61, 0x6d,
0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x21, 0x0a,
0x0c, 0x72, 0x61, 0x77, 0x5f, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x0a, 0x20,
0x01, 0x28, 0x09, 0x52, 0x0b, 0x72, 0x61, 0x77, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65,
0x42, 0x4a, 0x5a, 0x48, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67,
0x61, 0x69, 0x61, 0x2d, 0x78, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2d, 0x69, 0x6e, 0x66, 0x72, 0x61,
0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x65, 0x2d, 0x66, 0x65, 0x64, 0x65, 0x72, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x63, 0x61,
0x6d, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -179,20 +316,25 @@ func file_api_common_evidence_proto_rawDescGZIP() []byte {
return file_api_common_evidence_proto_rawDescData
}
var file_api_common_evidence_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_api_common_evidence_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_api_common_evidence_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_api_common_evidence_proto_goTypes = []interface{}{
(*Evidence)(nil), // 0: cam.Evidence
(*timestamppb.Timestamp)(nil), // 1: google.protobuf.Timestamp
(*structpb.Value)(nil), // 2: google.protobuf.Value
(Error_Code)(0), // 0: cam.Error.Code
(*Error)(nil), // 1: cam.Error
(*Evidence)(nil), // 2: cam.Evidence
(*timestamppb.Timestamp)(nil), // 3: google.protobuf.Timestamp
(*structpb.Value)(nil), // 4: google.protobuf.Value
}
var file_api_common_evidence_proto_depIdxs = []int32{
1, // 0: cam.Evidence.gathered_at:type_name -> google.protobuf.Timestamp
2, // 1: cam.Evidence.value:type_name -> google.protobuf.Value
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
0, // 0: cam.Error.code:type_name -> cam.Error.Code
3, // 1: cam.Evidence.gathered_at:type_name -> google.protobuf.Timestamp
4, // 2: cam.Evidence.value:type_name -> google.protobuf.Value
1, // 3: cam.Evidence.error:type_name -> cam.Error
4, // [4:4] is the sub-list for method output_type
4, // [4:4] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_api_common_evidence_proto_init() }
@@ -202,6 +344,18 @@ func file_api_common_evidence_proto_init() {
}
if !protoimpl.UnsafeEnabled {
file_api_common_evidence_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Error); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_api_common_evidence_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Evidence); i {
case 0:
return &v.state
@@ -219,13 +373,14 @@ func file_api_common_evidence_proto_init() {
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_api_common_evidence_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumEnums: 1,
NumMessages: 2,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_api_common_evidence_proto_goTypes,
DependencyIndexes: file_api_common_evidence_proto_depIdxs,
EnumInfos: file_api_common_evidence_proto_enumTypes,
MessageInfos: file_api_common_evidence_proto_msgTypes,
}.Build()
File_api_common_evidence_proto = out.File
Loading