diff --git a/buf.yaml b/buf.yaml index c7e30e3..6aa4477 100644 --- a/buf.yaml +++ b/buf.yaml @@ -4,6 +4,14 @@ modules: lint: use: - STANDARD + ignore_only: + # To not break existing APIs. + ENUM_FIRST_VALUE_ZERO: + - proto/kms/api/cmk/eventprocessor/task/v1/task.proto + ENUM_VALUE_PREFIX: + - proto/kms/api/cmk/eventprocessor/task/v1/task.proto + ENUM_ZERO_VALUE_SUFFIX: + - proto/kms/api/cmk/eventprocessor/task/v1/task.proto breaking: use: - FILE diff --git a/proto/kms/api/cmk/eventprocessor/task/v1/task.pb.go b/proto/kms/api/cmk/eventprocessor/task/v1/task.pb.go new file mode 100644 index 0000000..438c194 --- /dev/null +++ b/proto/kms/api/cmk/eventprocessor/task/v1/task.pb.go @@ -0,0 +1,471 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc (unknown) +// source: kms/api/cmk/eventprocessor/task/v1/task.proto + +package taskv1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type TaskType int32 + +const ( + TaskType_KEY_ENABLE TaskType = 0 + TaskType_KEY_DISABLE TaskType = 1 + TaskType_KEY_DELETE TaskType = 2 + TaskType_KEY_ROTATE TaskType = 3 + TaskType_SYSTEM_LINK TaskType = 4 + TaskType_SYSTEM_UNLINK TaskType = 5 + TaskType_SYSTEM_SWITCH TaskType = 6 + TaskType_KEY_DETACH TaskType = 7 +) + +// Enum value maps for TaskType. +var ( + TaskType_name = map[int32]string{ + 0: "KEY_ENABLE", + 1: "KEY_DISABLE", + 2: "KEY_DELETE", + 3: "KEY_ROTATE", + 4: "SYSTEM_LINK", + 5: "SYSTEM_UNLINK", + 6: "SYSTEM_SWITCH", + 7: "KEY_DETACH", + } + TaskType_value = map[string]int32{ + "KEY_ENABLE": 0, + "KEY_DISABLE": 1, + "KEY_DELETE": 2, + "KEY_ROTATE": 3, + "SYSTEM_LINK": 4, + "SYSTEM_UNLINK": 5, + "SYSTEM_SWITCH": 6, + "KEY_DETACH": 7, + } +) + +func (x TaskType) Enum() *TaskType { + p := new(TaskType) + *p = x + return p +} + +func (x TaskType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (TaskType) Descriptor() protoreflect.EnumDescriptor { + return file_kms_api_cmk_eventprocessor_task_v1_task_proto_enumTypes[0].Descriptor() +} + +func (TaskType) Type() protoreflect.EnumType { + return &file_kms_api_cmk_eventprocessor_task_v1_task_proto_enumTypes[0] +} + +func (x TaskType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use TaskType.Descriptor instead. +func (TaskType) EnumDescriptor() ([]byte, []int) { + return file_kms_api_cmk_eventprocessor_task_v1_task_proto_rawDescGZIP(), []int{0} +} + +// Wrapped proto for Orbital TaskRequest.data +type Data struct { + state protoimpl.MessageState `protogen:"open.v1"` + TaskType TaskType `protobuf:"varint,5,opt,name=task_type,json=taskType,proto3,enum=kms.api.cmk.eventprocessor.task.v1.TaskType" json:"task_type,omitempty"` + // Types that are valid to be assigned to Data: + // + // *Data_KeyAction + // *Data_SystemAction + Data isData_Data `protobuf_oneof:"data"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Data) Reset() { + *x = Data{} + mi := &file_kms_api_cmk_eventprocessor_task_v1_task_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Data) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Data) ProtoMessage() {} + +func (x *Data) ProtoReflect() protoreflect.Message { + mi := &file_kms_api_cmk_eventprocessor_task_v1_task_proto_msgTypes[0] + 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 Data.ProtoReflect.Descriptor instead. +func (*Data) Descriptor() ([]byte, []int) { + return file_kms_api_cmk_eventprocessor_task_v1_task_proto_rawDescGZIP(), []int{0} +} + +func (x *Data) GetTaskType() TaskType { + if x != nil { + return x.TaskType + } + return TaskType_KEY_ENABLE +} + +func (x *Data) GetData() isData_Data { + if x != nil { + return x.Data + } + return nil +} + +func (x *Data) GetKeyAction() *KeyAction { + if x != nil { + if x, ok := x.Data.(*Data_KeyAction); ok { + return x.KeyAction + } + } + return nil +} + +func (x *Data) GetSystemAction() *SystemAction { + if x != nil { + if x, ok := x.Data.(*Data_SystemAction); ok { + return x.SystemAction + } + } + return nil +} + +type isData_Data interface { + isData_Data() +} + +type Data_KeyAction struct { + KeyAction *KeyAction `protobuf:"bytes,10,opt,name=key_action,json=keyAction,proto3,oneof"` +} + +type Data_SystemAction struct { + SystemAction *SystemAction `protobuf:"bytes,20,opt,name=system_action,json=systemAction,proto3,oneof"` +} + +func (*Data_KeyAction) isData_Data() {} + +func (*Data_SystemAction) isData_Data() {} + +// TaskType KEY_ENABLE, KEY_DISABLE, KEY_DELETE, KEY_ROTATE, KEY_DETACH +type KeyAction struct { + state protoimpl.MessageState `protogen:"open.v1"` + KeyId string `protobuf:"bytes,10,opt,name=key_id,json=keyId,proto3" json:"key_id,omitempty"` + TenantId string `protobuf:"bytes,20,opt,name=tenant_id,json=tenantId,proto3" json:"tenant_id,omitempty"` + CmkRegion string `protobuf:"bytes,30,opt,name=cmk_region,json=cmkRegion,proto3" json:"cmk_region,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *KeyAction) Reset() { + *x = KeyAction{} + mi := &file_kms_api_cmk_eventprocessor_task_v1_task_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *KeyAction) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*KeyAction) ProtoMessage() {} + +func (x *KeyAction) ProtoReflect() protoreflect.Message { + mi := &file_kms_api_cmk_eventprocessor_task_v1_task_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 KeyAction.ProtoReflect.Descriptor instead. +func (*KeyAction) Descriptor() ([]byte, []int) { + return file_kms_api_cmk_eventprocessor_task_v1_task_proto_rawDescGZIP(), []int{1} +} + +func (x *KeyAction) GetKeyId() string { + if x != nil { + return x.KeyId + } + return "" +} + +func (x *KeyAction) GetTenantId() string { + if x != nil { + return x.TenantId + } + return "" +} + +func (x *KeyAction) GetCmkRegion() string { + if x != nil { + return x.CmkRegion + } + return "" +} + +// TaskType SYSTEM_LINK, SYSTEM_UNLINK, SYSTEM_SWITCH +type SystemAction struct { + state protoimpl.MessageState `protogen:"open.v1"` + SystemId string `protobuf:"bytes,10,opt,name=system_id,json=systemId,proto3" json:"system_id,omitempty"` + SystemRegion string `protobuf:"bytes,12,opt,name=system_region,json=systemRegion,proto3" json:"system_region,omitempty"` + SystemType string `protobuf:"bytes,15,opt,name=system_type,json=systemType,proto3" json:"system_type,omitempty"` + KeyIdFrom string `protobuf:"bytes,20,opt,name=key_id_from,json=keyIdFrom,proto3" json:"key_id_from,omitempty"` + KeyIdTo string `protobuf:"bytes,30,opt,name=key_id_to,json=keyIdTo,proto3" json:"key_id_to,omitempty"` + KeyProvider string `protobuf:"bytes,35,opt,name=key_provider,json=keyProvider,proto3" json:"key_provider,omitempty"` + KeyAccessMetaData []byte `protobuf:"bytes,40,opt,name=key_access_meta_data,json=keyAccessMetaData,proto3" json:"key_access_meta_data,omitempty"` + TenantId string `protobuf:"bytes,50,opt,name=tenant_id,json=tenantId,proto3" json:"tenant_id,omitempty"` + TenantOwnerId string `protobuf:"bytes,51,opt,name=tenant_owner_id,json=tenantOwnerId,proto3" json:"tenant_owner_id,omitempty"` + TenantOwnerType string `protobuf:"bytes,52,opt,name=tenant_owner_type,json=tenantOwnerType,proto3" json:"tenant_owner_type,omitempty"` + CmkRegion string `protobuf:"bytes,60,opt,name=cmk_region,json=cmkRegion,proto3" json:"cmk_region,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SystemAction) Reset() { + *x = SystemAction{} + mi := &file_kms_api_cmk_eventprocessor_task_v1_task_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SystemAction) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SystemAction) ProtoMessage() {} + +func (x *SystemAction) ProtoReflect() protoreflect.Message { + mi := &file_kms_api_cmk_eventprocessor_task_v1_task_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 SystemAction.ProtoReflect.Descriptor instead. +func (*SystemAction) Descriptor() ([]byte, []int) { + return file_kms_api_cmk_eventprocessor_task_v1_task_proto_rawDescGZIP(), []int{2} +} + +func (x *SystemAction) GetSystemId() string { + if x != nil { + return x.SystemId + } + return "" +} + +func (x *SystemAction) GetSystemRegion() string { + if x != nil { + return x.SystemRegion + } + return "" +} + +func (x *SystemAction) GetSystemType() string { + if x != nil { + return x.SystemType + } + return "" +} + +func (x *SystemAction) GetKeyIdFrom() string { + if x != nil { + return x.KeyIdFrom + } + return "" +} + +func (x *SystemAction) GetKeyIdTo() string { + if x != nil { + return x.KeyIdTo + } + return "" +} + +func (x *SystemAction) GetKeyProvider() string { + if x != nil { + return x.KeyProvider + } + return "" +} + +func (x *SystemAction) GetKeyAccessMetaData() []byte { + if x != nil { + return x.KeyAccessMetaData + } + return nil +} + +func (x *SystemAction) GetTenantId() string { + if x != nil { + return x.TenantId + } + return "" +} + +func (x *SystemAction) GetTenantOwnerId() string { + if x != nil { + return x.TenantOwnerId + } + return "" +} + +func (x *SystemAction) GetTenantOwnerType() string { + if x != nil { + return x.TenantOwnerType + } + return "" +} + +func (x *SystemAction) GetCmkRegion() string { + if x != nil { + return x.CmkRegion + } + return "" +} + +var File_kms_api_cmk_eventprocessor_task_v1_task_proto protoreflect.FileDescriptor + +const file_kms_api_cmk_eventprocessor_task_v1_task_proto_rawDesc = "" + + "\n" + + "-kms/api/cmk/eventprocessor/task/v1/task.proto\x12\"kms.api.cmk.eventprocessor.task.v1\"\x82\x02\n" + + "\x04Data\x12I\n" + + "\ttask_type\x18\x05 \x01(\x0e2,.kms.api.cmk.eventprocessor.task.v1.TaskTypeR\btaskType\x12N\n" + + "\n" + + "key_action\x18\n" + + " \x01(\v2-.kms.api.cmk.eventprocessor.task.v1.KeyActionH\x00R\tkeyAction\x12W\n" + + "\rsystem_action\x18\x14 \x01(\v20.kms.api.cmk.eventprocessor.task.v1.SystemActionH\x00R\fsystemActionB\x06\n" + + "\x04data\"^\n" + + "\tKeyAction\x12\x15\n" + + "\x06key_id\x18\n" + + " \x01(\tR\x05keyId\x12\x1b\n" + + "\ttenant_id\x18\x14 \x01(\tR\btenantId\x12\x1d\n" + + "\n" + + "cmk_region\x18\x1e \x01(\tR\tcmkRegion\"\x91\x03\n" + + "\fSystemAction\x12\x1b\n" + + "\tsystem_id\x18\n" + + " \x01(\tR\bsystemId\x12#\n" + + "\rsystem_region\x18\f \x01(\tR\fsystemRegion\x12\x1f\n" + + "\vsystem_type\x18\x0f \x01(\tR\n" + + "systemType\x12\x1e\n" + + "\vkey_id_from\x18\x14 \x01(\tR\tkeyIdFrom\x12\x1a\n" + + "\tkey_id_to\x18\x1e \x01(\tR\akeyIdTo\x12!\n" + + "\fkey_provider\x18# \x01(\tR\vkeyProvider\x12/\n" + + "\x14key_access_meta_data\x18( \x01(\fR\x11keyAccessMetaData\x12\x1b\n" + + "\ttenant_id\x182 \x01(\tR\btenantId\x12&\n" + + "\x0ftenant_owner_id\x183 \x01(\tR\rtenantOwnerId\x12*\n" + + "\x11tenant_owner_type\x184 \x01(\tR\x0ftenantOwnerType\x12\x1d\n" + + "\n" + + "cmk_region\x18< \x01(\tR\tcmkRegion*\x92\x01\n" + + "\bTaskType\x12\x0e\n" + + "\n" + + "KEY_ENABLE\x10\x00\x12\x0f\n" + + "\vKEY_DISABLE\x10\x01\x12\x0e\n" + + "\n" + + "KEY_DELETE\x10\x02\x12\x0e\n" + + "\n" + + "KEY_ROTATE\x10\x03\x12\x0f\n" + + "\vSYSTEM_LINK\x10\x04\x12\x11\n" + + "\rSYSTEM_UNLINK\x10\x05\x12\x11\n" + + "\rSYSTEM_SWITCH\x10\x06\x12\x0e\n" + + "\n" + + "KEY_DETACH\x10\aB\xae\x02\n" + + "&com.kms.api.cmk.eventprocessor.task.v1B\tTaskProtoP\x01ZJgithub.com/openkcm/api-sdk/proto/kms/api/cmk/eventprocessor/task/v1;taskv1\xa2\x02\x05KACET\xaa\x02\"Kms.Api.Cmk.Eventprocessor.Task.V1\xca\x02\"Kms\\Api\\Cmk\\Eventprocessor\\Task\\V1\xe2\x02.Kms\\Api\\Cmk\\Eventprocessor\\Task\\V1\\GPBMetadata\xea\x02'Kms::Api::Cmk::Eventprocessor::Task::V1b\x06proto3" + +var ( + file_kms_api_cmk_eventprocessor_task_v1_task_proto_rawDescOnce sync.Once + file_kms_api_cmk_eventprocessor_task_v1_task_proto_rawDescData []byte +) + +func file_kms_api_cmk_eventprocessor_task_v1_task_proto_rawDescGZIP() []byte { + file_kms_api_cmk_eventprocessor_task_v1_task_proto_rawDescOnce.Do(func() { + file_kms_api_cmk_eventprocessor_task_v1_task_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_kms_api_cmk_eventprocessor_task_v1_task_proto_rawDesc), len(file_kms_api_cmk_eventprocessor_task_v1_task_proto_rawDesc))) + }) + return file_kms_api_cmk_eventprocessor_task_v1_task_proto_rawDescData +} + +var file_kms_api_cmk_eventprocessor_task_v1_task_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_kms_api_cmk_eventprocessor_task_v1_task_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_kms_api_cmk_eventprocessor_task_v1_task_proto_goTypes = []any{ + (TaskType)(0), // 0: kms.api.cmk.eventprocessor.task.v1.TaskType + (*Data)(nil), // 1: kms.api.cmk.eventprocessor.task.v1.Data + (*KeyAction)(nil), // 2: kms.api.cmk.eventprocessor.task.v1.KeyAction + (*SystemAction)(nil), // 3: kms.api.cmk.eventprocessor.task.v1.SystemAction +} +var file_kms_api_cmk_eventprocessor_task_v1_task_proto_depIdxs = []int32{ + 0, // 0: kms.api.cmk.eventprocessor.task.v1.Data.task_type:type_name -> kms.api.cmk.eventprocessor.task.v1.TaskType + 2, // 1: kms.api.cmk.eventprocessor.task.v1.Data.key_action:type_name -> kms.api.cmk.eventprocessor.task.v1.KeyAction + 3, // 2: kms.api.cmk.eventprocessor.task.v1.Data.system_action:type_name -> kms.api.cmk.eventprocessor.task.v1.SystemAction + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_kms_api_cmk_eventprocessor_task_v1_task_proto_init() } +func file_kms_api_cmk_eventprocessor_task_v1_task_proto_init() { + if File_kms_api_cmk_eventprocessor_task_v1_task_proto != nil { + return + } + file_kms_api_cmk_eventprocessor_task_v1_task_proto_msgTypes[0].OneofWrappers = []any{ + (*Data_KeyAction)(nil), + (*Data_SystemAction)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_kms_api_cmk_eventprocessor_task_v1_task_proto_rawDesc), len(file_kms_api_cmk_eventprocessor_task_v1_task_proto_rawDesc)), + NumEnums: 1, + NumMessages: 3, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_kms_api_cmk_eventprocessor_task_v1_task_proto_goTypes, + DependencyIndexes: file_kms_api_cmk_eventprocessor_task_v1_task_proto_depIdxs, + EnumInfos: file_kms_api_cmk_eventprocessor_task_v1_task_proto_enumTypes, + MessageInfos: file_kms_api_cmk_eventprocessor_task_v1_task_proto_msgTypes, + }.Build() + File_kms_api_cmk_eventprocessor_task_v1_task_proto = out.File + file_kms_api_cmk_eventprocessor_task_v1_task_proto_goTypes = nil + file_kms_api_cmk_eventprocessor_task_v1_task_proto_depIdxs = nil +} diff --git a/proto/kms/api/cmk/eventprocessor/task/v1/task.pb.validate.go b/proto/kms/api/cmk/eventprocessor/task/v1/task.pb.validate.go new file mode 100644 index 0000000..693cca5 --- /dev/null +++ b/proto/kms/api/cmk/eventprocessor/task/v1/task.pb.validate.go @@ -0,0 +1,449 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: kms/api/cmk/eventprocessor/task/v1/task.proto + +package taskv1 + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on Data with the rules defined in the proto +// definition for this message. If any rules are violated, the first error +// encountered is returned, or nil if there are no violations. +func (m *Data) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Data with the rules defined in the +// proto definition for this message. If any rules are violated, the result is +// a list of violation errors wrapped in DataMultiError, or nil if none found. +func (m *Data) ValidateAll() error { + return m.validate(true) +} + +func (m *Data) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for TaskType + + switch v := m.Data.(type) { + case *Data_KeyAction: + if v == nil { + err := DataValidationError{ + field: "Data", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetKeyAction()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DataValidationError{ + field: "KeyAction", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DataValidationError{ + field: "KeyAction", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetKeyAction()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DataValidationError{ + field: "KeyAction", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *Data_SystemAction: + if v == nil { + err := DataValidationError{ + field: "Data", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetSystemAction()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DataValidationError{ + field: "SystemAction", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DataValidationError{ + field: "SystemAction", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSystemAction()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DataValidationError{ + field: "SystemAction", + reason: "embedded message failed validation", + cause: err, + } + } + } + + default: + _ = v // ensures v is used + } + + if len(errors) > 0 { + return DataMultiError(errors) + } + + return nil +} + +// DataMultiError is an error wrapping multiple validation errors returned by +// Data.ValidateAll() if the designated constraints aren't met. +type DataMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DataMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DataMultiError) AllErrors() []error { return m } + +// DataValidationError is the validation error returned by Data.Validate if the +// designated constraints aren't met. +type DataValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DataValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DataValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DataValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DataValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DataValidationError) ErrorName() string { return "DataValidationError" } + +// Error satisfies the builtin error interface +func (e DataValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sData.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DataValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DataValidationError{} + +// Validate checks the field values on KeyAction with the rules defined in the +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *KeyAction) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on KeyAction with the rules defined in +// the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in KeyActionMultiError, or nil +// if none found. +func (m *KeyAction) ValidateAll() error { + return m.validate(true) +} + +func (m *KeyAction) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for KeyId + + // no validation rules for TenantId + + // no validation rules for CmkRegion + + if len(errors) > 0 { + return KeyActionMultiError(errors) + } + + return nil +} + +// KeyActionMultiError is an error wrapping multiple validation errors returned +// by KeyAction.ValidateAll() if the designated constraints aren't met. +type KeyActionMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m KeyActionMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m KeyActionMultiError) AllErrors() []error { return m } + +// KeyActionValidationError is the validation error returned by +// KeyAction.Validate if the designated constraints aren't met. +type KeyActionValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e KeyActionValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e KeyActionValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e KeyActionValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e KeyActionValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e KeyActionValidationError) ErrorName() string { return "KeyActionValidationError" } + +// Error satisfies the builtin error interface +func (e KeyActionValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sKeyAction.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = KeyActionValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = KeyActionValidationError{} + +// Validate checks the field values on SystemAction with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *SystemAction) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on SystemAction with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in SystemActionMultiError, or +// nil if none found. +func (m *SystemAction) ValidateAll() error { + return m.validate(true) +} + +func (m *SystemAction) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for SystemId + + // no validation rules for SystemRegion + + // no validation rules for SystemType + + // no validation rules for KeyIdFrom + + // no validation rules for KeyIdTo + + // no validation rules for KeyProvider + + // no validation rules for KeyAccessMetaData + + // no validation rules for TenantId + + // no validation rules for TenantOwnerId + + // no validation rules for TenantOwnerType + + // no validation rules for CmkRegion + + if len(errors) > 0 { + return SystemActionMultiError(errors) + } + + return nil +} + +// SystemActionMultiError is an error wrapping multiple validation errors +// returned by SystemAction.ValidateAll() if the designated constraints aren't met. +type SystemActionMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m SystemActionMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m SystemActionMultiError) AllErrors() []error { return m } + +// SystemActionValidationError is the validation error returned by +// SystemAction.Validate if the designated constraints aren't met. +type SystemActionValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e SystemActionValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e SystemActionValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e SystemActionValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e SystemActionValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e SystemActionValidationError) ErrorName() string { return "SystemActionValidationError" } + +// Error satisfies the builtin error interface +func (e SystemActionValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sSystemAction.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = SystemActionValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = SystemActionValidationError{} diff --git a/proto/kms/api/cmk/eventprocessor/task/v1/task.proto b/proto/kms/api/cmk/eventprocessor/task/v1/task.proto new file mode 100644 index 0000000..ad4b95c --- /dev/null +++ b/proto/kms/api/cmk/eventprocessor/task/v1/task.proto @@ -0,0 +1,45 @@ +syntax = "proto3"; + +package kms.api.cmk.eventprocessor.task.v1; + +enum TaskType { + KEY_ENABLE = 0; + KEY_DISABLE = 1; + KEY_DELETE = 2; + KEY_ROTATE = 3; + SYSTEM_LINK = 4; + SYSTEM_UNLINK = 5; + SYSTEM_SWITCH = 6; + KEY_DETACH = 7; +} + +// Wrapped proto for Orbital TaskRequest.data +message Data { + TaskType task_type = 5; + oneof data { + KeyAction key_action = 10; + SystemAction system_action = 20; + } +} + +// TaskType KEY_ENABLE, KEY_DISABLE, KEY_DELETE, KEY_ROTATE, KEY_DETACH +message KeyAction { + string key_id = 10; + string tenant_id = 20; + string cmk_region = 30; +} + +// TaskType SYSTEM_LINK, SYSTEM_UNLINK, SYSTEM_SWITCH +message SystemAction { + string system_id = 10; + string system_region = 12; + string system_type = 15; + string key_id_from = 20; + string key_id_to = 30; + string key_provider = 35; + bytes key_access_meta_data = 40; + string tenant_id = 50; + string tenant_owner_id = 51; + string tenant_owner_type = 52; + string cmk_region = 60; +}