diff --git a/cmd/protoc-gen-go-extension/main.go b/cmd/protoc-gen-go-extension/main.go index 33dd7a6..da6e412 100644 --- a/cmd/protoc-gen-go-extension/main.go +++ b/cmd/protoc-gen-go-extension/main.go @@ -99,7 +99,7 @@ func generateServiceBridges(g *protogen.GeneratedFile, serviceName, serviceFullN g.P() g.P("const (") if isPlugin { - g.P(" Type = ", strconv.Quote(serviceName)) + g.P(" Type = ", strconv.Quote(strings.TrimSuffix(serviceName, "Service"))) } g.P(" GRPCServiceFullName = ", strconv.Quote(serviceFullName)) g.P(")") diff --git a/go.mod b/go.mod index 3f060fa..9fbe3d9 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,11 @@ module github.com/openkcm/plugin-sdk -go 1.25.4 +go 1.26.0 require ( buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20260209202127-80ab13bee0bf.1 buf.build/go/protovalidate v1.1.2 + github.com/cloudflare/cfssl v1.6.5 github.com/hashicorp/go-hclog v1.6.3 github.com/hashicorp/go-plugin v1.7.0 github.com/stretchr/testify v1.11.1 diff --git a/go.sum b/go.sum index 2fbcbf1..067ec1a 100644 --- a/go.sum +++ b/go.sum @@ -12,6 +12,8 @@ github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/ github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cloudflare/cfssl v1.6.5 h1:46zpNkm6dlNkMZH/wMW22ejih6gIaJbzL2du6vD7ZeI= +github.com/cloudflare/cfssl v1.6.5/go.mod h1:Bk1si7sq8h2+yVEDrFJiz3d7Aw+pfjjJSZVaD+Taky4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/proto/plugin/certificate_issuer/v1/certificate_issuer.pb.go b/proto/plugin/certificate_issuer/v1/certificate_issuer.pb.go index 56fd24d..d6cb3dd 100644 --- a/proto/plugin/certificate_issuer/v1/certificate_issuer.pb.go +++ b/proto/plugin/certificate_issuer/v1/certificate_issuer.pb.go @@ -11,8 +11,11 @@ import ( sync "sync" unsafe "unsafe" + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + durationpb "google.golang.org/protobuf/types/known/durationpb" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" ) const ( @@ -22,82 +25,186 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type ValidityType int32 +type IssueCertificateRequest_CertificateFormat int32 const ( - ValidityType_VALIDITY_TYPE_UNSPECIFIED ValidityType = 0 - ValidityType_VALIDITY_TYPE_DAYS ValidityType = 1 - ValidityType_VALIDITY_TYPE_MONTHS ValidityType = 2 - ValidityType_VALIDITY_TYPE_YEARS ValidityType = 3 + IssueCertificateRequest_CERTIFICATE_FORMAT_UNSPECIFIED IssueCertificateRequest_CertificateFormat = 0 + IssueCertificateRequest_CERTIFICATE_FORMAT_PEM IssueCertificateRequest_CertificateFormat = 1 + IssueCertificateRequest_CERTIFICATE_FORMAT_DER IssueCertificateRequest_CertificateFormat = 2 + IssueCertificateRequest_CERTIFICATE_FORMAT_PKCS7 IssueCertificateRequest_CertificateFormat = 3 ) -// Enum value maps for ValidityType. +// Enum value maps for IssueCertificateRequest_CertificateFormat. var ( - ValidityType_name = map[int32]string{ - 0: "VALIDITY_TYPE_UNSPECIFIED", - 1: "VALIDITY_TYPE_DAYS", - 2: "VALIDITY_TYPE_MONTHS", - 3: "VALIDITY_TYPE_YEARS", - } - ValidityType_value = map[string]int32{ - "VALIDITY_TYPE_UNSPECIFIED": 0, - "VALIDITY_TYPE_DAYS": 1, - "VALIDITY_TYPE_MONTHS": 2, - "VALIDITY_TYPE_YEARS": 3, + IssueCertificateRequest_CertificateFormat_name = map[int32]string{ + 0: "CERTIFICATE_FORMAT_UNSPECIFIED", + 1: "CERTIFICATE_FORMAT_PEM", + 2: "CERTIFICATE_FORMAT_DER", + 3: "CERTIFICATE_FORMAT_PKCS7", + } + IssueCertificateRequest_CertificateFormat_value = map[string]int32{ + "CERTIFICATE_FORMAT_UNSPECIFIED": 0, + "CERTIFICATE_FORMAT_PEM": 1, + "CERTIFICATE_FORMAT_DER": 2, + "CERTIFICATE_FORMAT_PKCS7": 3, } ) -func (x ValidityType) Enum() *ValidityType { - p := new(ValidityType) +func (x IssueCertificateRequest_CertificateFormat) Enum() *IssueCertificateRequest_CertificateFormat { + p := new(IssueCertificateRequest_CertificateFormat) *p = x return p } -func (x ValidityType) String() string { +func (x IssueCertificateRequest_CertificateFormat) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -func (ValidityType) Descriptor() protoreflect.EnumDescriptor { +func (IssueCertificateRequest_CertificateFormat) Descriptor() protoreflect.EnumDescriptor { return file_plugin_certificate_issuer_v1_certificate_issuer_proto_enumTypes[0].Descriptor() } -func (ValidityType) Type() protoreflect.EnumType { +func (IssueCertificateRequest_CertificateFormat) Type() protoreflect.EnumType { return &file_plugin_certificate_issuer_v1_certificate_issuer_proto_enumTypes[0] } -func (x ValidityType) Number() protoreflect.EnumNumber { +func (x IssueCertificateRequest_CertificateFormat) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } -// Deprecated: Use ValidityType.Descriptor instead. -func (ValidityType) EnumDescriptor() ([]byte, []int) { - return file_plugin_certificate_issuer_v1_certificate_issuer_proto_rawDescGZIP(), []int{0} +// Deprecated: Use IssueCertificateRequest_CertificateFormat.Descriptor instead. +func (IssueCertificateRequest_CertificateFormat) EnumDescriptor() ([]byte, []int) { + return file_plugin_certificate_issuer_v1_certificate_issuer_proto_rawDescGZIP(), []int{0, 0} } -type GetCertificateRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - CommonName string `protobuf:"bytes,1,opt,name=common_name,json=commonName,proto3" json:"common_name,omitempty"` - Locality []string `protobuf:"bytes,2,rep,name=locality,proto3" json:"locality,omitempty"` - Validity *GetCertificateValidity `protobuf:"bytes,3,opt,name=validity,proto3" json:"validity,omitempty"` - PrivateKey *PrivateKey `protobuf:"bytes,4,opt,name=private_key,json=privateKey,proto3" json:"private_key,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache +type PrivateKey_KeyFormat int32 + +const ( + PrivateKey_KEY_FORMAT_UNSPECIFIED PrivateKey_KeyFormat = 0 + PrivateKey_KEY_FORMAT_PKCS1 PrivateKey_KeyFormat = 1 + PrivateKey_KEY_FORMAT_PKCS8 PrivateKey_KeyFormat = 2 + PrivateKey_KEY_FORMAT_SEC1 PrivateKey_KeyFormat = 3 +) + +// Enum value maps for PrivateKey_KeyFormat. +var ( + PrivateKey_KeyFormat_name = map[int32]string{ + 0: "KEY_FORMAT_UNSPECIFIED", + 1: "KEY_FORMAT_PKCS1", + 2: "KEY_FORMAT_PKCS8", + 3: "KEY_FORMAT_SEC1", + } + PrivateKey_KeyFormat_value = map[string]int32{ + "KEY_FORMAT_UNSPECIFIED": 0, + "KEY_FORMAT_PKCS1": 1, + "KEY_FORMAT_PKCS8": 2, + "KEY_FORMAT_SEC1": 3, + } +) + +func (x PrivateKey_KeyFormat) Enum() *PrivateKey_KeyFormat { + p := new(PrivateKey_KeyFormat) + *p = x + return p +} + +func (x PrivateKey_KeyFormat) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (PrivateKey_KeyFormat) Descriptor() protoreflect.EnumDescriptor { + return file_plugin_certificate_issuer_v1_certificate_issuer_proto_enumTypes[1].Descriptor() +} + +func (PrivateKey_KeyFormat) Type() protoreflect.EnumType { + return &file_plugin_certificate_issuer_v1_certificate_issuer_proto_enumTypes[1] +} + +func (x PrivateKey_KeyFormat) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use PrivateKey_KeyFormat.Descriptor instead. +func (PrivateKey_KeyFormat) EnumDescriptor() ([]byte, []int) { + return file_plugin_certificate_issuer_v1_certificate_issuer_proto_rawDescGZIP(), []int{3, 0} +} + +type RelativeValidity_ValidityUnit int32 + +const ( + RelativeValidity_VALIDITY_UNIT_UNSPECIFIED RelativeValidity_ValidityUnit = 0 + RelativeValidity_VALIDITY_UNIT_DAYS RelativeValidity_ValidityUnit = 1 + RelativeValidity_VALIDITY_UNIT_MONTHS RelativeValidity_ValidityUnit = 2 + RelativeValidity_VALIDITY_UNIT_YEARS RelativeValidity_ValidityUnit = 3 +) + +// Enum value maps for RelativeValidity_ValidityUnit. +var ( + RelativeValidity_ValidityUnit_name = map[int32]string{ + 0: "VALIDITY_UNIT_UNSPECIFIED", + 1: "VALIDITY_UNIT_DAYS", + 2: "VALIDITY_UNIT_MONTHS", + 3: "VALIDITY_UNIT_YEARS", + } + RelativeValidity_ValidityUnit_value = map[string]int32{ + "VALIDITY_UNIT_UNSPECIFIED": 0, + "VALIDITY_UNIT_DAYS": 1, + "VALIDITY_UNIT_MONTHS": 2, + "VALIDITY_UNIT_YEARS": 3, + } +) + +func (x RelativeValidity_ValidityUnit) Enum() *RelativeValidity_ValidityUnit { + p := new(RelativeValidity_ValidityUnit) + *p = x + return p +} + +func (x RelativeValidity_ValidityUnit) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (RelativeValidity_ValidityUnit) Descriptor() protoreflect.EnumDescriptor { + return file_plugin_certificate_issuer_v1_certificate_issuer_proto_enumTypes[2].Descriptor() +} + +func (RelativeValidity_ValidityUnit) Type() protoreflect.EnumType { + return &file_plugin_certificate_issuer_v1_certificate_issuer_proto_enumTypes[2] +} + +func (x RelativeValidity_ValidityUnit) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use RelativeValidity_ValidityUnit.Descriptor instead. +func (RelativeValidity_ValidityUnit) EnumDescriptor() ([]byte, []int) { + return file_plugin_certificate_issuer_v1_certificate_issuer_proto_rawDescGZIP(), []int{5, 0} } -func (x *GetCertificateRequest) Reset() { - *x = GetCertificateRequest{} +type IssueCertificateRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Lifetime *CertificateLifetime `protobuf:"bytes,1,opt,name=lifetime,proto3" json:"lifetime,omitempty"` + Subject *Subject `protobuf:"bytes,2,opt,name=subject,proto3" json:"subject,omitempty"` + PrivateKey *PrivateKey `protobuf:"bytes,3,opt,name=private_key,json=privateKey,proto3,oneof" json:"private_key,omitempty"` + PreferredFormat IssueCertificateRequest_CertificateFormat `protobuf:"varint,4,opt,name=preferred_format,json=preferredFormat,proto3,enum=plugin.certificate_issuer.v1.IssueCertificateRequest_CertificateFormat" json:"preferred_format,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *IssueCertificateRequest) Reset() { + *x = IssueCertificateRequest{} mi := &file_plugin_certificate_issuer_v1_certificate_issuer_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *GetCertificateRequest) String() string { +func (x *IssueCertificateRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetCertificateRequest) ProtoMessage() {} +func (*IssueCertificateRequest) ProtoMessage() {} -func (x *GetCertificateRequest) ProtoReflect() protoreflect.Message { +func (x *IssueCertificateRequest) ProtoReflect() protoreflect.Message { mi := &file_plugin_certificate_issuer_v1_certificate_issuer_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -109,61 +216,62 @@ func (x *GetCertificateRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetCertificateRequest.ProtoReflect.Descriptor instead. -func (*GetCertificateRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use IssueCertificateRequest.ProtoReflect.Descriptor instead. +func (*IssueCertificateRequest) Descriptor() ([]byte, []int) { return file_plugin_certificate_issuer_v1_certificate_issuer_proto_rawDescGZIP(), []int{0} } -func (x *GetCertificateRequest) GetCommonName() string { +func (x *IssueCertificateRequest) GetLifetime() *CertificateLifetime { if x != nil { - return x.CommonName + return x.Lifetime } - return "" + return nil } -func (x *GetCertificateRequest) GetLocality() []string { +func (x *IssueCertificateRequest) GetSubject() *Subject { if x != nil { - return x.Locality + return x.Subject } return nil } -func (x *GetCertificateRequest) GetValidity() *GetCertificateValidity { +func (x *IssueCertificateRequest) GetPrivateKey() *PrivateKey { if x != nil { - return x.Validity + return x.PrivateKey } return nil } -func (x *GetCertificateRequest) GetPrivateKey() *PrivateKey { +func (x *IssueCertificateRequest) GetPreferredFormat() IssueCertificateRequest_CertificateFormat { if x != nil { - return x.PrivateKey + return x.PreferredFormat } - return nil + return IssueCertificateRequest_CERTIFICATE_FORMAT_UNSPECIFIED } -type GetCertificateValidity struct { - state protoimpl.MessageState `protogen:"open.v1"` - Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` - Type ValidityType `protobuf:"varint,2,opt,name=type,proto3,enum=plugin.certificate_issuer.v1.ValidityType" json:"type,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache +type IssueCertificateResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + CertificateData []byte `protobuf:"bytes,1,opt,name=certificate_data,json=certificateData,proto3" json:"certificate_data,omitempty"` + Format IssueCertificateRequest_CertificateFormat `protobuf:"varint,2,opt,name=format,proto3,enum=plugin.certificate_issuer.v1.IssueCertificateRequest_CertificateFormat" json:"format,omitempty"` + CaChain [][]byte `protobuf:"bytes,3,rep,name=ca_chain,json=caChain,proto3" json:"ca_chain,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } -func (x *GetCertificateValidity) Reset() { - *x = GetCertificateValidity{} +func (x *IssueCertificateResponse) Reset() { + *x = IssueCertificateResponse{} mi := &file_plugin_certificate_issuer_v1_certificate_issuer_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *GetCertificateValidity) String() string { +func (x *IssueCertificateResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetCertificateValidity) ProtoMessage() {} +func (*IssueCertificateResponse) ProtoMessage() {} -func (x *GetCertificateValidity) ProtoReflect() protoreflect.Message { +func (x *IssueCertificateResponse) ProtoReflect() protoreflect.Message { mi := &file_plugin_certificate_issuer_v1_certificate_issuer_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -175,35 +283,87 @@ func (x *GetCertificateValidity) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetCertificateValidity.ProtoReflect.Descriptor instead. -func (*GetCertificateValidity) Descriptor() ([]byte, []int) { +// Deprecated: Use IssueCertificateResponse.ProtoReflect.Descriptor instead. +func (*IssueCertificateResponse) Descriptor() ([]byte, []int) { return file_plugin_certificate_issuer_v1_certificate_issuer_proto_rawDescGZIP(), []int{1} } -func (x *GetCertificateValidity) GetValue() int64 { +func (x *IssueCertificateResponse) GetCertificateData() []byte { if x != nil { - return x.Value + return x.CertificateData } - return 0 + return nil +} + +func (x *IssueCertificateResponse) GetFormat() IssueCertificateRequest_CertificateFormat { + if x != nil { + return x.Format + } + return IssueCertificateRequest_CERTIFICATE_FORMAT_UNSPECIFIED } -func (x *GetCertificateValidity) GetType() ValidityType { +func (x *IssueCertificateResponse) GetCaChain() [][]byte { if x != nil { - return x.Type + return x.CaChain } - return ValidityType_VALIDITY_TYPE_UNSPECIFIED + return nil +} + +type Subject struct { + state protoimpl.MessageState `protogen:"open.v1"` + CommonName string `protobuf:"bytes,1,opt,name=common_name,json=commonName,proto3" json:"common_name,omitempty"` // CN + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Subject) Reset() { + *x = Subject{} + mi := &file_plugin_certificate_issuer_v1_certificate_issuer_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Subject) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Subject) ProtoMessage() {} + +func (x *Subject) ProtoReflect() protoreflect.Message { + mi := &file_plugin_certificate_issuer_v1_certificate_issuer_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 Subject.ProtoReflect.Descriptor instead. +func (*Subject) Descriptor() ([]byte, []int) { + return file_plugin_certificate_issuer_v1_certificate_issuer_proto_rawDescGZIP(), []int{2} +} + +func (x *Subject) GetCommonName() string { + if x != nil { + return x.CommonName + } + return "" } type PrivateKey struct { state protoimpl.MessageState `protogen:"open.v1"` Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + Format PrivateKey_KeyFormat `protobuf:"varint,2,opt,name=format,proto3,enum=plugin.certificate_issuer.v1.PrivateKey_KeyFormat" json:"format,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *PrivateKey) Reset() { *x = PrivateKey{} - mi := &file_plugin_certificate_issuer_v1_certificate_issuer_proto_msgTypes[2] + mi := &file_plugin_certificate_issuer_v1_certificate_issuer_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -215,7 +375,7 @@ func (x *PrivateKey) String() string { func (*PrivateKey) ProtoMessage() {} func (x *PrivateKey) ProtoReflect() protoreflect.Message { - mi := &file_plugin_certificate_issuer_v1_certificate_issuer_proto_msgTypes[2] + mi := &file_plugin_certificate_issuer_v1_certificate_issuer_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -228,7 +388,7 @@ func (x *PrivateKey) ProtoReflect() protoreflect.Message { // Deprecated: Use PrivateKey.ProtoReflect.Descriptor instead. func (*PrivateKey) Descriptor() ([]byte, []int) { - return file_plugin_certificate_issuer_v1_certificate_issuer_proto_rawDescGZIP(), []int{2} + return file_plugin_certificate_issuer_v1_certificate_issuer_proto_rawDescGZIP(), []int{3} } func (x *PrivateKey) GetData() []byte { @@ -238,28 +398,188 @@ func (x *PrivateKey) GetData() []byte { return nil } -type GetCertificateResponse struct { +func (x *PrivateKey) GetFormat() PrivateKey_KeyFormat { + if x != nil { + return x.Format + } + return PrivateKey_KEY_FORMAT_UNSPECIFIED +} + +type CertificateLifetime struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to Lifetime: + // + // *CertificateLifetime_Duration + // *CertificateLifetime_NotAfter + // *CertificateLifetime_Relative + Lifetime isCertificateLifetime_Lifetime `protobuf_oneof:"lifetime"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CertificateLifetime) Reset() { + *x = CertificateLifetime{} + mi := &file_plugin_certificate_issuer_v1_certificate_issuer_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CertificateLifetime) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CertificateLifetime) ProtoMessage() {} + +func (x *CertificateLifetime) ProtoReflect() protoreflect.Message { + mi := &file_plugin_certificate_issuer_v1_certificate_issuer_proto_msgTypes[4] + 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 CertificateLifetime.ProtoReflect.Descriptor instead. +func (*CertificateLifetime) Descriptor() ([]byte, []int) { + return file_plugin_certificate_issuer_v1_certificate_issuer_proto_rawDescGZIP(), []int{4} +} + +func (x *CertificateLifetime) GetLifetime() isCertificateLifetime_Lifetime { + if x != nil { + return x.Lifetime + } + return nil +} + +func (x *CertificateLifetime) GetDuration() *durationpb.Duration { + if x != nil { + if x, ok := x.Lifetime.(*CertificateLifetime_Duration); ok { + return x.Duration + } + } + return nil +} + +func (x *CertificateLifetime) GetNotAfter() *timestamppb.Timestamp { + if x != nil { + if x, ok := x.Lifetime.(*CertificateLifetime_NotAfter); ok { + return x.NotAfter + } + } + return nil +} + +func (x *CertificateLifetime) GetRelative() *RelativeValidity { + if x != nil { + if x, ok := x.Lifetime.(*CertificateLifetime_Relative); ok { + return x.Relative + } + } + return nil +} + +type isCertificateLifetime_Lifetime interface { + isCertificateLifetime_Lifetime() +} + +type CertificateLifetime_Duration struct { + Duration *durationpb.Duration `protobuf:"bytes,1,opt,name=duration,proto3,oneof"` +} + +type CertificateLifetime_NotAfter struct { + NotAfter *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=not_after,json=notAfter,proto3,oneof"` +} + +type CertificateLifetime_Relative struct { + Relative *RelativeValidity `protobuf:"bytes,3,opt,name=relative,proto3,oneof"` +} + +func (*CertificateLifetime_Duration) isCertificateLifetime_Lifetime() {} + +func (*CertificateLifetime_NotAfter) isCertificateLifetime_Lifetime() {} + +func (*CertificateLifetime_Relative) isCertificateLifetime_Lifetime() {} + +type RelativeValidity struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Ensure the value is a strictly positive number + Value int32 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` + Unit RelativeValidity_ValidityUnit `protobuf:"varint,2,opt,name=unit,proto3,enum=plugin.certificate_issuer.v1.RelativeValidity_ValidityUnit" json:"unit,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RelativeValidity) Reset() { + *x = RelativeValidity{} + mi := &file_plugin_certificate_issuer_v1_certificate_issuer_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RelativeValidity) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RelativeValidity) ProtoMessage() {} + +func (x *RelativeValidity) ProtoReflect() protoreflect.Message { + mi := &file_plugin_certificate_issuer_v1_certificate_issuer_proto_msgTypes[5] + 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 RelativeValidity.ProtoReflect.Descriptor instead. +func (*RelativeValidity) Descriptor() ([]byte, []int) { + return file_plugin_certificate_issuer_v1_certificate_issuer_proto_rawDescGZIP(), []int{5} +} + +func (x *RelativeValidity) GetValue() int32 { + if x != nil { + return x.Value + } + return 0 +} + +func (x *RelativeValidity) GetUnit() RelativeValidity_ValidityUnit { + if x != nil { + return x.Unit + } + return RelativeValidity_VALIDITY_UNIT_UNSPECIFIED +} + +type SupportedKeyFormatsError struct { state protoimpl.MessageState `protogen:"open.v1"` - CertificateChain string `protobuf:"bytes,1,opt,name=certificate_chain,json=certificateChain,proto3" json:"certificate_chain,omitempty"` + RejectedFormat string `protobuf:"bytes,1,opt,name=rejected_format,json=rejectedFormat,proto3" json:"rejected_format,omitempty"` + SupportedFormats []PrivateKey_KeyFormat `protobuf:"varint,2,rep,packed,name=supported_formats,json=supportedFormats,proto3,enum=plugin.certificate_issuer.v1.PrivateKey_KeyFormat" json:"supported_formats,omitempty"` + Reason string `protobuf:"bytes,3,opt,name=reason,proto3" json:"reason,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *GetCertificateResponse) Reset() { - *x = GetCertificateResponse{} - mi := &file_plugin_certificate_issuer_v1_certificate_issuer_proto_msgTypes[3] +func (x *SupportedKeyFormatsError) Reset() { + *x = SupportedKeyFormatsError{} + mi := &file_plugin_certificate_issuer_v1_certificate_issuer_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *GetCertificateResponse) String() string { +func (x *SupportedKeyFormatsError) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetCertificateResponse) ProtoMessage() {} +func (*SupportedKeyFormatsError) ProtoMessage() {} -func (x *GetCertificateResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_certificate_issuer_v1_certificate_issuer_proto_msgTypes[3] +func (x *SupportedKeyFormatsError) ProtoReflect() protoreflect.Message { + mi := &file_plugin_certificate_issuer_v1_certificate_issuer_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -270,14 +590,28 @@ func (x *GetCertificateResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetCertificateResponse.ProtoReflect.Descriptor instead. -func (*GetCertificateResponse) Descriptor() ([]byte, []int) { - return file_plugin_certificate_issuer_v1_certificate_issuer_proto_rawDescGZIP(), []int{3} +// Deprecated: Use SupportedKeyFormatsError.ProtoReflect.Descriptor instead. +func (*SupportedKeyFormatsError) Descriptor() ([]byte, []int) { + return file_plugin_certificate_issuer_v1_certificate_issuer_proto_rawDescGZIP(), []int{6} } -func (x *GetCertificateResponse) GetCertificateChain() string { +func (x *SupportedKeyFormatsError) GetRejectedFormat() string { if x != nil { - return x.CertificateChain + return x.RejectedFormat + } + return "" +} + +func (x *SupportedKeyFormatsError) GetSupportedFormats() []PrivateKey_KeyFormat { + if x != nil { + return x.SupportedFormats + } + return nil +} + +func (x *SupportedKeyFormatsError) GetReason() string { + if x != nil { + return x.Reason } return "" } @@ -286,29 +620,57 @@ var File_plugin_certificate_issuer_v1_certificate_issuer_proto protoreflect.File const file_plugin_certificate_issuer_v1_certificate_issuer_proto_rawDesc = "" + "\n" + - "5plugin/certificate_issuer/v1/certificate_issuer.proto\x12\x1cplugin.certificate_issuer.v1\"\xf1\x01\n" + - "\x15GetCertificateRequest\x12\x1f\n" + + "5plugin/certificate_issuer/v1/certificate_issuer.proto\x12\x1cplugin.certificate_issuer.v1\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1bbuf/validate/validate.proto\"\x8d\x04\n" + + "\x17IssueCertificateRequest\x12M\n" + + "\blifetime\x18\x01 \x01(\v21.plugin.certificate_issuer.v1.CertificateLifetimeR\blifetime\x12?\n" + + "\asubject\x18\x02 \x01(\v2%.plugin.certificate_issuer.v1.SubjectR\asubject\x12N\n" + + "\vprivate_key\x18\x03 \x01(\v2(.plugin.certificate_issuer.v1.PrivateKeyH\x00R\n" + + "privateKey\x88\x01\x01\x12r\n" + + "\x10preferred_format\x18\x04 \x01(\x0e2G.plugin.certificate_issuer.v1.IssueCertificateRequest.CertificateFormatR\x0fpreferredFormat\"\x8d\x01\n" + + "\x11CertificateFormat\x12\"\n" + + "\x1eCERTIFICATE_FORMAT_UNSPECIFIED\x10\x00\x12\x1a\n" + + "\x16CERTIFICATE_FORMAT_PEM\x10\x01\x12\x1a\n" + + "\x16CERTIFICATE_FORMAT_DER\x10\x02\x12\x1c\n" + + "\x18CERTIFICATE_FORMAT_PKCS7\x10\x03B\x0e\n" + + "\f_private_key\"\xc1\x01\n" + + "\x18IssueCertificateResponse\x12)\n" + + "\x10certificate_data\x18\x01 \x01(\fR\x0fcertificateData\x12_\n" + + "\x06format\x18\x02 \x01(\x0e2G.plugin.certificate_issuer.v1.IssueCertificateRequest.CertificateFormatR\x06format\x12\x19\n" + + "\bca_chain\x18\x03 \x03(\fR\acaChain\"*\n" + + "\aSubject\x12\x1f\n" + "\vcommon_name\x18\x01 \x01(\tR\n" + - "commonName\x12\x1a\n" + - "\blocality\x18\x02 \x03(\tR\blocality\x12P\n" + - "\bvalidity\x18\x03 \x01(\v24.plugin.certificate_issuer.v1.GetCertificateValidityR\bvalidity\x12I\n" + - "\vprivate_key\x18\x04 \x01(\v2(.plugin.certificate_issuer.v1.PrivateKeyR\n" + - "privateKey\"n\n" + - "\x16GetCertificateValidity\x12\x14\n" + - "\x05value\x18\x01 \x01(\x03R\x05value\x12>\n" + - "\x04type\x18\x02 \x01(\x0e2*.plugin.certificate_issuer.v1.ValidityTypeR\x04type\" \n" + + "commonName\"\xd6\x01\n" + "\n" + "PrivateKey\x12\x12\n" + - "\x04data\x18\x01 \x01(\fR\x04data\"E\n" + - "\x16GetCertificateResponse\x12+\n" + - "\x11certificate_chain\x18\x01 \x01(\tR\x10certificateChain*x\n" + - "\fValidityType\x12\x1d\n" + - "\x19VALIDITY_TYPE_UNSPECIFIED\x10\x00\x12\x16\n" + - "\x12VALIDITY_TYPE_DAYS\x10\x01\x12\x18\n" + - "\x14VALIDITY_TYPE_MONTHS\x10\x02\x12\x17\n" + - "\x13VALIDITY_TYPE_YEARS\x10\x032\x97\x01\n" + - "\x18CertificateIssuerService\x12{\n" + - "\x0eGetCertificate\x123.plugin.certificate_issuer.v1.GetCertificateRequest\x1a4.plugin.certificate_issuer.v1.GetCertificateResponseB\x9f\x02\n" + + "\x04data\x18\x01 \x01(\fR\x04data\x12J\n" + + "\x06format\x18\x02 \x01(\x0e22.plugin.certificate_issuer.v1.PrivateKey.KeyFormatR\x06format\"h\n" + + "\tKeyFormat\x12\x1a\n" + + "\x16KEY_FORMAT_UNSPECIFIED\x10\x00\x12\x14\n" + + "\x10KEY_FORMAT_PKCS1\x10\x01\x12\x14\n" + + "\x10KEY_FORMAT_PKCS8\x10\x02\x12\x13\n" + + "\x0fKEY_FORMAT_SEC1\x10\x03\"\xe3\x01\n" + + "\x13CertificateLifetime\x127\n" + + "\bduration\x18\x01 \x01(\v2\x19.google.protobuf.DurationH\x00R\bduration\x129\n" + + "\tnot_after\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampH\x00R\bnotAfter\x12L\n" + + "\brelative\x18\x03 \x01(\v2..plugin.certificate_issuer.v1.RelativeValidityH\x00R\brelativeB\n" + + "\n" + + "\blifetime\"\xe8\x03\n" + + "\x10RelativeValidity\x12\x1d\n" + + "\x05value\x18\x01 \x01(\x05B\a\xbaH\x04\x1a\x02 \x00R\x05value\x12[\n" + + "\x04unit\x18\x02 \x01(\x0e2;.plugin.certificate_issuer.v1.RelativeValidity.ValidityUnitB\n" + + "\xbaH\a\x82\x01\x04\x10\x01 \x00R\x04unit\"x\n" + + "\fValidityUnit\x12\x1d\n" + + "\x19VALIDITY_UNIT_UNSPECIFIED\x10\x00\x12\x16\n" + + "\x12VALIDITY_UNIT_DAYS\x10\x01\x12\x18\n" + + "\x14VALIDITY_UNIT_MONTHS\x10\x02\x12\x17\n" + + "\x13VALIDITY_UNIT_YEARS\x10\x03:\xdd\x01\xbaH\xd9\x01\x1a\xd6\x01\n" + + "\x15max_duration_one_year\x12GValidity duration cannot exceed 1 year (365 days, 12 months, or 1 year)\x1at(this.unit == 1 && this.value <= 365) || (this.unit == 2 && this.value <= 12) || (this.unit == 3 && this.value <= 1)\"\xbc\x01\n" + + "\x18SupportedKeyFormatsError\x12'\n" + + "\x0frejected_format\x18\x01 \x01(\tR\x0erejectedFormat\x12_\n" + + "\x11supported_formats\x18\x02 \x03(\x0e22.plugin.certificate_issuer.v1.PrivateKey.KeyFormatR\x10supportedFormats\x12\x16\n" + + "\x06reason\x18\x03 \x01(\tR\x06reason2\x97\x01\n" + + "\x11CertificateIssuer\x12\x81\x01\n" + + "\x10IssueCertificate\x125.plugin.certificate_issuer.v1.IssueCertificateRequest\x1a6.plugin.certificate_issuer.v1.IssueCertificateResponseB\x9f\x02\n" + " com.plugin.certificate_issuer.v1B\x16CertificateIssuerProtoP\x01ZUgithub.com/openkcm/plugin-sdk/proto/plugin/certificate_issuer/v1;certificate_issuerv1\xa2\x02\x03PCX\xaa\x02\x1bPlugin.CertificateIssuer.V1\xca\x02\x1bPlugin\\CertificateIssuer\\V1\xe2\x02'Plugin\\CertificateIssuer\\V1\\GPBMetadata\xea\x02\x1dPlugin::CertificateIssuer::V1b\x06proto3" var ( @@ -323,26 +685,41 @@ func file_plugin_certificate_issuer_v1_certificate_issuer_proto_rawDescGZIP() [] return file_plugin_certificate_issuer_v1_certificate_issuer_proto_rawDescData } -var file_plugin_certificate_issuer_v1_certificate_issuer_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_plugin_certificate_issuer_v1_certificate_issuer_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_plugin_certificate_issuer_v1_certificate_issuer_proto_enumTypes = make([]protoimpl.EnumInfo, 3) +var file_plugin_certificate_issuer_v1_certificate_issuer_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_plugin_certificate_issuer_v1_certificate_issuer_proto_goTypes = []any{ - (ValidityType)(0), // 0: plugin.certificate_issuer.v1.ValidityType - (*GetCertificateRequest)(nil), // 1: plugin.certificate_issuer.v1.GetCertificateRequest - (*GetCertificateValidity)(nil), // 2: plugin.certificate_issuer.v1.GetCertificateValidity - (*PrivateKey)(nil), // 3: plugin.certificate_issuer.v1.PrivateKey - (*GetCertificateResponse)(nil), // 4: plugin.certificate_issuer.v1.GetCertificateResponse + (IssueCertificateRequest_CertificateFormat)(0), // 0: plugin.certificate_issuer.v1.IssueCertificateRequest.CertificateFormat + (PrivateKey_KeyFormat)(0), // 1: plugin.certificate_issuer.v1.PrivateKey.KeyFormat + (RelativeValidity_ValidityUnit)(0), // 2: plugin.certificate_issuer.v1.RelativeValidity.ValidityUnit + (*IssueCertificateRequest)(nil), // 3: plugin.certificate_issuer.v1.IssueCertificateRequest + (*IssueCertificateResponse)(nil), // 4: plugin.certificate_issuer.v1.IssueCertificateResponse + (*Subject)(nil), // 5: plugin.certificate_issuer.v1.Subject + (*PrivateKey)(nil), // 6: plugin.certificate_issuer.v1.PrivateKey + (*CertificateLifetime)(nil), // 7: plugin.certificate_issuer.v1.CertificateLifetime + (*RelativeValidity)(nil), // 8: plugin.certificate_issuer.v1.RelativeValidity + (*SupportedKeyFormatsError)(nil), // 9: plugin.certificate_issuer.v1.SupportedKeyFormatsError + (*durationpb.Duration)(nil), // 10: google.protobuf.Duration + (*timestamppb.Timestamp)(nil), // 11: google.protobuf.Timestamp } var file_plugin_certificate_issuer_v1_certificate_issuer_proto_depIdxs = []int32{ - 2, // 0: plugin.certificate_issuer.v1.GetCertificateRequest.validity:type_name -> plugin.certificate_issuer.v1.GetCertificateValidity - 3, // 1: plugin.certificate_issuer.v1.GetCertificateRequest.private_key:type_name -> plugin.certificate_issuer.v1.PrivateKey - 0, // 2: plugin.certificate_issuer.v1.GetCertificateValidity.type:type_name -> plugin.certificate_issuer.v1.ValidityType - 1, // 3: plugin.certificate_issuer.v1.CertificateIssuerService.GetCertificate:input_type -> plugin.certificate_issuer.v1.GetCertificateRequest - 4, // 4: plugin.certificate_issuer.v1.CertificateIssuerService.GetCertificate:output_type -> plugin.certificate_issuer.v1.GetCertificateResponse - 4, // [4:5] is the sub-list for method output_type - 3, // [3:4] 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 + 7, // 0: plugin.certificate_issuer.v1.IssueCertificateRequest.lifetime:type_name -> plugin.certificate_issuer.v1.CertificateLifetime + 5, // 1: plugin.certificate_issuer.v1.IssueCertificateRequest.subject:type_name -> plugin.certificate_issuer.v1.Subject + 6, // 2: plugin.certificate_issuer.v1.IssueCertificateRequest.private_key:type_name -> plugin.certificate_issuer.v1.PrivateKey + 0, // 3: plugin.certificate_issuer.v1.IssueCertificateRequest.preferred_format:type_name -> plugin.certificate_issuer.v1.IssueCertificateRequest.CertificateFormat + 0, // 4: plugin.certificate_issuer.v1.IssueCertificateResponse.format:type_name -> plugin.certificate_issuer.v1.IssueCertificateRequest.CertificateFormat + 1, // 5: plugin.certificate_issuer.v1.PrivateKey.format:type_name -> plugin.certificate_issuer.v1.PrivateKey.KeyFormat + 10, // 6: plugin.certificate_issuer.v1.CertificateLifetime.duration:type_name -> google.protobuf.Duration + 11, // 7: plugin.certificate_issuer.v1.CertificateLifetime.not_after:type_name -> google.protobuf.Timestamp + 8, // 8: plugin.certificate_issuer.v1.CertificateLifetime.relative:type_name -> plugin.certificate_issuer.v1.RelativeValidity + 2, // 9: plugin.certificate_issuer.v1.RelativeValidity.unit:type_name -> plugin.certificate_issuer.v1.RelativeValidity.ValidityUnit + 1, // 10: plugin.certificate_issuer.v1.SupportedKeyFormatsError.supported_formats:type_name -> plugin.certificate_issuer.v1.PrivateKey.KeyFormat + 3, // 11: plugin.certificate_issuer.v1.CertificateIssuer.IssueCertificate:input_type -> plugin.certificate_issuer.v1.IssueCertificateRequest + 4, // 12: plugin.certificate_issuer.v1.CertificateIssuer.IssueCertificate:output_type -> plugin.certificate_issuer.v1.IssueCertificateResponse + 12, // [12:13] is the sub-list for method output_type + 11, // [11:12] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name } func init() { file_plugin_certificate_issuer_v1_certificate_issuer_proto_init() } @@ -350,13 +727,19 @@ func file_plugin_certificate_issuer_v1_certificate_issuer_proto_init() { if File_plugin_certificate_issuer_v1_certificate_issuer_proto != nil { return } + file_plugin_certificate_issuer_v1_certificate_issuer_proto_msgTypes[0].OneofWrappers = []any{} + file_plugin_certificate_issuer_v1_certificate_issuer_proto_msgTypes[4].OneofWrappers = []any{ + (*CertificateLifetime_Duration)(nil), + (*CertificateLifetime_NotAfter)(nil), + (*CertificateLifetime_Relative)(nil), + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_plugin_certificate_issuer_v1_certificate_issuer_proto_rawDesc), len(file_plugin_certificate_issuer_v1_certificate_issuer_proto_rawDesc)), - NumEnums: 1, - NumMessages: 4, + NumEnums: 3, + NumMessages: 7, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/plugin/certificate_issuer/v1/certificate_issuer.pb.validate.go b/proto/plugin/certificate_issuer/v1/certificate_issuer.pb.validate.go index 12c10a0..172216c 100644 --- a/proto/plugin/certificate_issuer/v1/certificate_issuer.pb.validate.go +++ b/proto/plugin/certificate_issuer/v1/certificate_issuer.pb.validate.go @@ -35,53 +35,51 @@ var ( _ = sort.Sort ) -// Validate checks the field values on GetCertificateRequest with the rules +// Validate checks the field values on IssueCertificateRequest 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 *GetCertificateRequest) Validate() error { +func (m *IssueCertificateRequest) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on GetCertificateRequest with the rules -// defined in the proto definition for this message. If any rules are +// ValidateAll checks the field values on IssueCertificateRequest 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 -// GetCertificateRequestMultiError, or nil if none found. -func (m *GetCertificateRequest) ValidateAll() error { +// IssueCertificateRequestMultiError, or nil if none found. +func (m *IssueCertificateRequest) ValidateAll() error { return m.validate(true) } -func (m *GetCertificateRequest) validate(all bool) error { +func (m *IssueCertificateRequest) validate(all bool) error { if m == nil { return nil } var errors []error - // no validation rules for CommonName - if all { - switch v := interface{}(m.GetValidity()).(type) { + switch v := interface{}(m.GetLifetime()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, GetCertificateRequestValidationError{ - field: "Validity", + errors = append(errors, IssueCertificateRequestValidationError{ + field: "Lifetime", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, GetCertificateRequestValidationError{ - field: "Validity", + errors = append(errors, IssueCertificateRequestValidationError{ + field: "Lifetime", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetValidity()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetLifetime()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return GetCertificateRequestValidationError{ - field: "Validity", + return IssueCertificateRequestValidationError{ + field: "Lifetime", reason: "embedded message failed validation", cause: err, } @@ -89,48 +87,83 @@ func (m *GetCertificateRequest) validate(all bool) error { } if all { - switch v := interface{}(m.GetPrivateKey()).(type) { + switch v := interface{}(m.GetSubject()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, GetCertificateRequestValidationError{ - field: "PrivateKey", + errors = append(errors, IssueCertificateRequestValidationError{ + field: "Subject", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, GetCertificateRequestValidationError{ - field: "PrivateKey", + errors = append(errors, IssueCertificateRequestValidationError{ + field: "Subject", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetPrivateKey()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetSubject()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return GetCertificateRequestValidationError{ - field: "PrivateKey", + return IssueCertificateRequestValidationError{ + field: "Subject", reason: "embedded message failed validation", cause: err, } } } + // no validation rules for PreferredFormat + + if m.PrivateKey != nil { + + if all { + switch v := interface{}(m.GetPrivateKey()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, IssueCertificateRequestValidationError{ + field: "PrivateKey", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, IssueCertificateRequestValidationError{ + field: "PrivateKey", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPrivateKey()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return IssueCertificateRequestValidationError{ + field: "PrivateKey", + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + if len(errors) > 0 { - return GetCertificateRequestMultiError(errors) + return IssueCertificateRequestMultiError(errors) } return nil } -// GetCertificateRequestMultiError is an error wrapping multiple validation -// errors returned by GetCertificateRequest.ValidateAll() if the designated +// IssueCertificateRequestMultiError is an error wrapping multiple validation +// errors returned by IssueCertificateRequest.ValidateAll() if the designated // constraints aren't met. -type GetCertificateRequestMultiError []error +type IssueCertificateRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m GetCertificateRequestMultiError) Error() string { +func (m IssueCertificateRequestMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -139,11 +172,11 @@ func (m GetCertificateRequestMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m GetCertificateRequestMultiError) AllErrors() []error { return m } +func (m IssueCertificateRequestMultiError) AllErrors() []error { return m } -// GetCertificateRequestValidationError is the validation error returned by -// GetCertificateRequest.Validate if the designated constraints aren't met. -type GetCertificateRequestValidationError struct { +// IssueCertificateRequestValidationError is the validation error returned by +// IssueCertificateRequest.Validate if the designated constraints aren't met. +type IssueCertificateRequestValidationError struct { field string reason string cause error @@ -151,24 +184,24 @@ type GetCertificateRequestValidationError struct { } // Field function returns field value. -func (e GetCertificateRequestValidationError) Field() string { return e.field } +func (e IssueCertificateRequestValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e GetCertificateRequestValidationError) Reason() string { return e.reason } +func (e IssueCertificateRequestValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e GetCertificateRequestValidationError) Cause() error { return e.cause } +func (e IssueCertificateRequestValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e GetCertificateRequestValidationError) Key() bool { return e.key } +func (e IssueCertificateRequestValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e GetCertificateRequestValidationError) ErrorName() string { - return "GetCertificateRequestValidationError" +func (e IssueCertificateRequestValidationError) ErrorName() string { + return "IssueCertificateRequestValidationError" } // Error satisfies the builtin error interface -func (e GetCertificateRequestValidationError) Error() string { +func (e IssueCertificateRequestValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -180,14 +213,14 @@ func (e GetCertificateRequestValidationError) Error() string { } return fmt.Sprintf( - "invalid %sGetCertificateRequest.%s: %s%s", + "invalid %sIssueCertificateRequest.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = GetCertificateRequestValidationError{} +var _ error = IssueCertificateRequestValidationError{} var _ interface { Field() string @@ -195,48 +228,48 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = GetCertificateRequestValidationError{} +} = IssueCertificateRequestValidationError{} -// Validate checks the field values on GetCertificateValidity with the rules +// Validate checks the field values on IssueCertificateResponse 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 *GetCertificateValidity) Validate() error { +func (m *IssueCertificateResponse) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on GetCertificateValidity with the rules -// defined in the proto definition for this message. If any rules are +// ValidateAll checks the field values on IssueCertificateResponse 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 -// GetCertificateValidityMultiError, or nil if none found. -func (m *GetCertificateValidity) ValidateAll() error { +// IssueCertificateResponseMultiError, or nil if none found. +func (m *IssueCertificateResponse) ValidateAll() error { return m.validate(true) } -func (m *GetCertificateValidity) validate(all bool) error { +func (m *IssueCertificateResponse) validate(all bool) error { if m == nil { return nil } var errors []error - // no validation rules for Value + // no validation rules for CertificateData - // no validation rules for Type + // no validation rules for Format if len(errors) > 0 { - return GetCertificateValidityMultiError(errors) + return IssueCertificateResponseMultiError(errors) } return nil } -// GetCertificateValidityMultiError is an error wrapping multiple validation -// errors returned by GetCertificateValidity.ValidateAll() if the designated +// IssueCertificateResponseMultiError is an error wrapping multiple validation +// errors returned by IssueCertificateResponse.ValidateAll() if the designated // constraints aren't met. -type GetCertificateValidityMultiError []error +type IssueCertificateResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m GetCertificateValidityMultiError) Error() string { +func (m IssueCertificateResponseMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -245,11 +278,11 @@ func (m GetCertificateValidityMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m GetCertificateValidityMultiError) AllErrors() []error { return m } +func (m IssueCertificateResponseMultiError) AllErrors() []error { return m } -// GetCertificateValidityValidationError is the validation error returned by -// GetCertificateValidity.Validate if the designated constraints aren't met. -type GetCertificateValidityValidationError struct { +// IssueCertificateResponseValidationError is the validation error returned by +// IssueCertificateResponse.Validate if the designated constraints aren't met. +type IssueCertificateResponseValidationError struct { field string reason string cause error @@ -257,24 +290,24 @@ type GetCertificateValidityValidationError struct { } // Field function returns field value. -func (e GetCertificateValidityValidationError) Field() string { return e.field } +func (e IssueCertificateResponseValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e GetCertificateValidityValidationError) Reason() string { return e.reason } +func (e IssueCertificateResponseValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e GetCertificateValidityValidationError) Cause() error { return e.cause } +func (e IssueCertificateResponseValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e GetCertificateValidityValidationError) Key() bool { return e.key } +func (e IssueCertificateResponseValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e GetCertificateValidityValidationError) ErrorName() string { - return "GetCertificateValidityValidationError" +func (e IssueCertificateResponseValidationError) ErrorName() string { + return "IssueCertificateResponseValidationError" } // Error satisfies the builtin error interface -func (e GetCertificateValidityValidationError) Error() string { +func (e IssueCertificateResponseValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -286,14 +319,14 @@ func (e GetCertificateValidityValidationError) Error() string { } return fmt.Sprintf( - "invalid %sGetCertificateValidity.%s: %s%s", + "invalid %sIssueCertificateResponse.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = GetCertificateValidityValidationError{} +var _ error = IssueCertificateResponseValidationError{} var _ interface { Field() string @@ -301,7 +334,107 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = GetCertificateValidityValidationError{} +} = IssueCertificateResponseValidationError{} + +// Validate checks the field values on Subject 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 *Subject) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Subject 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 SubjectMultiError, or nil if none found. +func (m *Subject) ValidateAll() error { + return m.validate(true) +} + +func (m *Subject) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for CommonName + + if len(errors) > 0 { + return SubjectMultiError(errors) + } + + return nil +} + +// SubjectMultiError is an error wrapping multiple validation errors returned +// by Subject.ValidateAll() if the designated constraints aren't met. +type SubjectMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m SubjectMultiError) 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 SubjectMultiError) AllErrors() []error { return m } + +// SubjectValidationError is the validation error returned by Subject.Validate +// if the designated constraints aren't met. +type SubjectValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e SubjectValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e SubjectValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e SubjectValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e SubjectValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e SubjectValidationError) ErrorName() string { return "SubjectValidationError" } + +// Error satisfies the builtin error interface +func (e SubjectValidationError) 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 %sSubject.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = SubjectValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = SubjectValidationError{} // Validate checks the field values on PrivateKey with the rules defined in the // proto definition for this message. If any rules are violated, the first @@ -327,6 +460,8 @@ func (m *PrivateKey) validate(all bool) error { // no validation rules for Data + // no validation rules for Format + if len(errors) > 0 { return PrivateKeyMultiError(errors) } @@ -404,44 +539,380 @@ var _ interface { ErrorName() string } = PrivateKeyValidationError{} -// Validate checks the field values on GetCertificateResponse with the rules +// Validate checks the field values on CertificateLifetime 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 *GetCertificateResponse) Validate() error { +func (m *CertificateLifetime) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on GetCertificateResponse with the rules +// ValidateAll checks the field values on CertificateLifetime 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 -// GetCertificateResponseMultiError, or nil if none found. -func (m *GetCertificateResponse) ValidateAll() error { +// CertificateLifetimeMultiError, or nil if none found. +func (m *CertificateLifetime) ValidateAll() error { return m.validate(true) } -func (m *GetCertificateResponse) validate(all bool) error { +func (m *CertificateLifetime) validate(all bool) error { if m == nil { return nil } var errors []error - // no validation rules for CertificateChain + switch v := m.Lifetime.(type) { + case *CertificateLifetime_Duration: + if v == nil { + err := CertificateLifetimeValidationError{ + field: "Lifetime", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetDuration()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CertificateLifetimeValidationError{ + field: "Duration", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CertificateLifetimeValidationError{ + field: "Duration", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDuration()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CertificateLifetimeValidationError{ + field: "Duration", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *CertificateLifetime_NotAfter: + if v == nil { + err := CertificateLifetimeValidationError{ + field: "Lifetime", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetNotAfter()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CertificateLifetimeValidationError{ + field: "NotAfter", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CertificateLifetimeValidationError{ + field: "NotAfter", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetNotAfter()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CertificateLifetimeValidationError{ + field: "NotAfter", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *CertificateLifetime_Relative: + if v == nil { + err := CertificateLifetimeValidationError{ + field: "Lifetime", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetRelative()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CertificateLifetimeValidationError{ + field: "Relative", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CertificateLifetimeValidationError{ + field: "Relative", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRelative()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CertificateLifetimeValidationError{ + field: "Relative", + reason: "embedded message failed validation", + cause: err, + } + } + } + + default: + _ = v // ensures v is used + } + + if len(errors) > 0 { + return CertificateLifetimeMultiError(errors) + } + + return nil +} + +// CertificateLifetimeMultiError is an error wrapping multiple validation +// errors returned by CertificateLifetime.ValidateAll() if the designated +// constraints aren't met. +type CertificateLifetimeMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CertificateLifetimeMultiError) 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 CertificateLifetimeMultiError) AllErrors() []error { return m } + +// CertificateLifetimeValidationError is the validation error returned by +// CertificateLifetime.Validate if the designated constraints aren't met. +type CertificateLifetimeValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CertificateLifetimeValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CertificateLifetimeValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CertificateLifetimeValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CertificateLifetimeValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CertificateLifetimeValidationError) ErrorName() string { + return "CertificateLifetimeValidationError" +} + +// Error satisfies the builtin error interface +func (e CertificateLifetimeValidationError) 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 %sCertificateLifetime.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CertificateLifetimeValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CertificateLifetimeValidationError{} + +// Validate checks the field values on RelativeValidity 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 *RelativeValidity) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RelativeValidity 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 +// RelativeValidityMultiError, or nil if none found. +func (m *RelativeValidity) ValidateAll() error { + return m.validate(true) +} + +func (m *RelativeValidity) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Value + + // no validation rules for Unit + + if len(errors) > 0 { + return RelativeValidityMultiError(errors) + } + + return nil +} + +// RelativeValidityMultiError is an error wrapping multiple validation errors +// returned by RelativeValidity.ValidateAll() if the designated constraints +// aren't met. +type RelativeValidityMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RelativeValidityMultiError) 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 RelativeValidityMultiError) AllErrors() []error { return m } + +// RelativeValidityValidationError is the validation error returned by +// RelativeValidity.Validate if the designated constraints aren't met. +type RelativeValidityValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RelativeValidityValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RelativeValidityValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RelativeValidityValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RelativeValidityValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RelativeValidityValidationError) ErrorName() string { return "RelativeValidityValidationError" } + +// Error satisfies the builtin error interface +func (e RelativeValidityValidationError) 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 %sRelativeValidity.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RelativeValidityValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RelativeValidityValidationError{} + +// Validate checks the field values on SupportedKeyFormatsError 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 *SupportedKeyFormatsError) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on SupportedKeyFormatsError 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 +// SupportedKeyFormatsErrorMultiError, or nil if none found. +func (m *SupportedKeyFormatsError) ValidateAll() error { + return m.validate(true) +} + +func (m *SupportedKeyFormatsError) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for RejectedFormat + + // no validation rules for Reason if len(errors) > 0 { - return GetCertificateResponseMultiError(errors) + return SupportedKeyFormatsErrorMultiError(errors) } return nil } -// GetCertificateResponseMultiError is an error wrapping multiple validation -// errors returned by GetCertificateResponse.ValidateAll() if the designated +// SupportedKeyFormatsErrorMultiError is an error wrapping multiple validation +// errors returned by SupportedKeyFormatsError.ValidateAll() if the designated // constraints aren't met. -type GetCertificateResponseMultiError []error +type SupportedKeyFormatsErrorMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m GetCertificateResponseMultiError) Error() string { +func (m SupportedKeyFormatsErrorMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -450,11 +921,11 @@ func (m GetCertificateResponseMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m GetCertificateResponseMultiError) AllErrors() []error { return m } +func (m SupportedKeyFormatsErrorMultiError) AllErrors() []error { return m } -// GetCertificateResponseValidationError is the validation error returned by -// GetCertificateResponse.Validate if the designated constraints aren't met. -type GetCertificateResponseValidationError struct { +// SupportedKeyFormatsErrorValidationError is the validation error returned by +// SupportedKeyFormatsError.Validate if the designated constraints aren't met. +type SupportedKeyFormatsErrorValidationError struct { field string reason string cause error @@ -462,24 +933,24 @@ type GetCertificateResponseValidationError struct { } // Field function returns field value. -func (e GetCertificateResponseValidationError) Field() string { return e.field } +func (e SupportedKeyFormatsErrorValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e GetCertificateResponseValidationError) Reason() string { return e.reason } +func (e SupportedKeyFormatsErrorValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e GetCertificateResponseValidationError) Cause() error { return e.cause } +func (e SupportedKeyFormatsErrorValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e GetCertificateResponseValidationError) Key() bool { return e.key } +func (e SupportedKeyFormatsErrorValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e GetCertificateResponseValidationError) ErrorName() string { - return "GetCertificateResponseValidationError" +func (e SupportedKeyFormatsErrorValidationError) ErrorName() string { + return "SupportedKeyFormatsErrorValidationError" } // Error satisfies the builtin error interface -func (e GetCertificateResponseValidationError) Error() string { +func (e SupportedKeyFormatsErrorValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -491,14 +962,14 @@ func (e GetCertificateResponseValidationError) Error() string { } return fmt.Sprintf( - "invalid %sGetCertificateResponse.%s: %s%s", + "invalid %sSupportedKeyFormatsError.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = GetCertificateResponseValidationError{} +var _ error = SupportedKeyFormatsErrorValidationError{} var _ interface { Field() string @@ -506,4 +977,4 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = GetCertificateResponseValidationError{} +} = SupportedKeyFormatsErrorValidationError{} diff --git a/proto/plugin/certificate_issuer/v1/certificate_issuer.proto b/proto/plugin/certificate_issuer/v1/certificate_issuer.proto index 00448ee..e66aacf 100644 --- a/proto/plugin/certificate_issuer/v1/certificate_issuer.proto +++ b/proto/plugin/certificate_issuer/v1/certificate_issuer.proto @@ -1,33 +1,107 @@ syntax = "proto3"; package plugin.certificate_issuer.v1; -service CertificateIssuerService { - rpc GetCertificate(GetCertificateRequest) returns (GetCertificateResponse); +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +import "buf/validate/validate.proto"; + +service CertificateIssuer { + rpc IssueCertificate(IssueCertificateRequest) returns (IssueCertificateResponse); } -message GetCertificateRequest { - string common_name = 1; - repeated string locality = 2; - GetCertificateValidity validity = 3; - PrivateKey private_key = 4; +message IssueCertificateRequest { + CertificateLifetime lifetime = 1; + Subject subject = 2; + optional PrivateKey private_key = 3; + CertificateFormat preferred_format = 4; + + enum CertificateFormat { + CERTIFICATE_FORMAT_UNSPECIFIED = 0; + CERTIFICATE_FORMAT_PEM = 1; + CERTIFICATE_FORMAT_DER = 2; + CERTIFICATE_FORMAT_PKCS7 = 3; + } } -message GetCertificateValidity { - int64 value = 1; - ValidityType type = 2; +message IssueCertificateResponse { + bytes certificate_data = 1; + IssueCertificateRequest.CertificateFormat format = 2; + repeated bytes ca_chain = 3; } -enum ValidityType { - VALIDITY_TYPE_UNSPECIFIED = 0; - VALIDITY_TYPE_DAYS = 1; - VALIDITY_TYPE_MONTHS = 2; - VALIDITY_TYPE_YEARS = 3; +message Subject { + string common_name = 1; // CN +// repeated string organizational_unit = 2; // OU +// repeated string organization = 3; // O +// repeated string locality = 4; // L +// repeated string province = 5; // ST +// repeated string country = 6; // C + + // Nest the advanced attributes cleanly inside the main Subject +// optional AdvancedSubjectAttributes advanced_attributes = 7; } +//message AdvancedSubjectAttributes { +// optional string serial_number = 1; // SERIALNUMBER +// repeated string postal_code = 2; // PC +// repeated string street_address = 3; // STREET +//} + message PrivateKey { bytes data = 1; + KeyFormat format = 2; + + enum KeyFormat { + KEY_FORMAT_UNSPECIFIED = 0; + KEY_FORMAT_PKCS1 = 1; + KEY_FORMAT_PKCS8 = 2; + KEY_FORMAT_SEC1 = 3; + } +} + +message CertificateLifetime { + oneof lifetime { + google.protobuf.Duration duration = 1; + google.protobuf.Timestamp not_after = 2; + RelativeValidity relative = 3; + } } -message GetCertificateResponse { - string certificate_chain = 1; + + +message RelativeValidity { + // Message-level validation using CEL (Common Expression Language) + // handles the cross-field logic for the 1-year maximum constraint. + option (buf.validate.message).cel = { + id: "max_duration_one_year", + message: "Validity duration cannot exceed 1 year (365 days, 12 months, or 1 year)", + // 1 = DAYS, 2 = MONTHS, 3 = YEARS + expression: "(this.unit == 1 && this.value <= 365) || (this.unit == 2 && this.value <= 12) || (this.unit == 3 && this.value <= 1)" + }; + + // Ensure the value is a strictly positive number + int32 value = 1 [ + (buf.validate.field).int32 = { gt: 0 } + ]; + + ValidityUnit unit = 2 [ + (buf.validate.field).enum = { + defined_only: true, + not_in: [0] // Ensures VALIDITY_UNIT_UNSPECIFIED is rejected + } + ]; + + enum ValidityUnit { + VALIDITY_UNIT_UNSPECIFIED = 0; + VALIDITY_UNIT_DAYS = 1; + VALIDITY_UNIT_MONTHS = 2; + VALIDITY_UNIT_YEARS = 3; + } } + +message SupportedKeyFormatsError { + string rejected_format = 1; + repeated PrivateKey.KeyFormat supported_formats = 2; + string reason = 3; +} \ No newline at end of file diff --git a/proto/plugin/certificate_issuer/v1/certificate_issuer_ext_plugin.pb.go b/proto/plugin/certificate_issuer/v1/certificate_issuer_ext_plugin.pb.go index dfe9e3a..6832af9 100644 --- a/proto/plugin/certificate_issuer/v1/certificate_issuer_ext_plugin.pb.go +++ b/proto/plugin/certificate_issuer/v1/certificate_issuer_ext_plugin.pb.go @@ -9,48 +9,48 @@ import ( ) const ( - Type = "CertificateIssuerService" - GRPCServiceFullName = "plugin.certificate_issuer.v1.CertificateIssuerService" + Type = "CertificateIssuer" + GRPCServiceFullName = "plugin.certificate_issuer.v1.CertificateIssuer" ) -func CertificateIssuerServicePluginServer(server CertificateIssuerServiceServer) api.PluginServer { - return certificateIssuerServicePluginServer{CertificateIssuerServiceServer: server} +func CertificateIssuerPluginServer(server CertificateIssuerServer) api.PluginServer { + return certificateIssuerPluginServer{CertificateIssuerServer: server} } -type certificateIssuerServicePluginServer struct { - CertificateIssuerServiceServer +type certificateIssuerPluginServer struct { + CertificateIssuerServer } -func (s certificateIssuerServicePluginServer) Type() string { +func (s certificateIssuerPluginServer) Type() string { return Type } -func (s certificateIssuerServicePluginServer) GRPCServiceName() string { +func (s certificateIssuerPluginServer) GRPCServiceName() string { return GRPCServiceFullName } -func (s certificateIssuerServicePluginServer) RegisterServer(server *grpc.Server) any { - RegisterCertificateIssuerServiceServer(server, s.CertificateIssuerServiceServer) - return s.CertificateIssuerServiceServer +func (s certificateIssuerPluginServer) RegisterServer(server *grpc.Server) any { + RegisterCertificateIssuerServer(server, s.CertificateIssuerServer) + return s.CertificateIssuerServer } -type CertificateIssuerServicePluginClient struct { - CertificateIssuerServiceClient +type CertificateIssuerPluginClient struct { + CertificateIssuerClient } -func (s CertificateIssuerServicePluginClient) Type() string { +func (s CertificateIssuerPluginClient) Type() string { return Type } -func (c *CertificateIssuerServicePluginClient) IsInitialized() bool { - return c.CertificateIssuerServiceClient != nil +func (c *CertificateIssuerPluginClient) IsInitialized() bool { + return c.CertificateIssuerClient != nil } -func (c *CertificateIssuerServicePluginClient) GRPCServiceName() string { +func (c *CertificateIssuerPluginClient) GRPCServiceName() string { return GRPCServiceFullName } -func (c *CertificateIssuerServicePluginClient) InitClient(conn grpc.ClientConnInterface) any { - c.CertificateIssuerServiceClient = NewCertificateIssuerServiceClient(conn) - return c.CertificateIssuerServiceClient +func (c *CertificateIssuerPluginClient) InitClient(conn grpc.ClientConnInterface) any { + c.CertificateIssuerClient = NewCertificateIssuerClient(conn) + return c.CertificateIssuerClient } diff --git a/proto/plugin/certificate_issuer/v1/certificate_issuer_grpc.pb.go b/proto/plugin/certificate_issuer/v1/certificate_issuer_grpc.pb.go index 21e8e15..74cc665 100644 --- a/proto/plugin/certificate_issuer/v1/certificate_issuer_grpc.pb.go +++ b/proto/plugin/certificate_issuer/v1/certificate_issuer_grpc.pb.go @@ -20,102 +20,101 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - CertificateIssuerService_GetCertificate_FullMethodName = "/plugin.certificate_issuer.v1.CertificateIssuerService/GetCertificate" + CertificateIssuer_IssueCertificate_FullMethodName = "/plugin.certificate_issuer.v1.CertificateIssuer/IssueCertificate" ) -// CertificateIssuerServiceClient is the client API for CertificateIssuerService service. +// CertificateIssuerClient is the client API for CertificateIssuer service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type CertificateIssuerServiceClient interface { - GetCertificate(ctx context.Context, in *GetCertificateRequest, opts ...grpc.CallOption) (*GetCertificateResponse, error) +type CertificateIssuerClient interface { + IssueCertificate(ctx context.Context, in *IssueCertificateRequest, opts ...grpc.CallOption) (*IssueCertificateResponse, error) } -type certificateIssuerServiceClient struct { +type certificateIssuerClient struct { cc grpc.ClientConnInterface } -func NewCertificateIssuerServiceClient(cc grpc.ClientConnInterface) CertificateIssuerServiceClient { - return &certificateIssuerServiceClient{cc} +func NewCertificateIssuerClient(cc grpc.ClientConnInterface) CertificateIssuerClient { + return &certificateIssuerClient{cc} } -func (c *certificateIssuerServiceClient) GetCertificate(ctx context.Context, in *GetCertificateRequest, opts ...grpc.CallOption) (*GetCertificateResponse, error) { +func (c *certificateIssuerClient) IssueCertificate(ctx context.Context, in *IssueCertificateRequest, opts ...grpc.CallOption) (*IssueCertificateResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetCertificateResponse) - err := c.cc.Invoke(ctx, CertificateIssuerService_GetCertificate_FullMethodName, in, out, cOpts...) + out := new(IssueCertificateResponse) + err := c.cc.Invoke(ctx, CertificateIssuer_IssueCertificate_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -// CertificateIssuerServiceServer is the server API for CertificateIssuerService service. -// All implementations must embed UnimplementedCertificateIssuerServiceServer +// CertificateIssuerServer is the server API for CertificateIssuer service. +// All implementations must embed UnimplementedCertificateIssuerServer // for forward compatibility. -type CertificateIssuerServiceServer interface { - GetCertificate(context.Context, *GetCertificateRequest) (*GetCertificateResponse, error) - mustEmbedUnimplementedCertificateIssuerServiceServer() +type CertificateIssuerServer interface { + IssueCertificate(context.Context, *IssueCertificateRequest) (*IssueCertificateResponse, error) + mustEmbedUnimplementedCertificateIssuerServer() } -// UnimplementedCertificateIssuerServiceServer must be embedded to have +// UnimplementedCertificateIssuerServer must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedCertificateIssuerServiceServer struct{} +type UnimplementedCertificateIssuerServer struct{} -func (UnimplementedCertificateIssuerServiceServer) GetCertificate(context.Context, *GetCertificateRequest) (*GetCertificateResponse, error) { - return nil, status.Error(codes.Unimplemented, "method GetCertificate not implemented") +func (UnimplementedCertificateIssuerServer) IssueCertificate(context.Context, *IssueCertificateRequest) (*IssueCertificateResponse, error) { + return nil, status.Error(codes.Unimplemented, "method IssueCertificate not implemented") } -func (UnimplementedCertificateIssuerServiceServer) mustEmbedUnimplementedCertificateIssuerServiceServer() { -} -func (UnimplementedCertificateIssuerServiceServer) testEmbeddedByValue() {} +func (UnimplementedCertificateIssuerServer) mustEmbedUnimplementedCertificateIssuerServer() {} +func (UnimplementedCertificateIssuerServer) testEmbeddedByValue() {} -// UnsafeCertificateIssuerServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to CertificateIssuerServiceServer will +// UnsafeCertificateIssuerServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to CertificateIssuerServer will // result in compilation errors. -type UnsafeCertificateIssuerServiceServer interface { - mustEmbedUnimplementedCertificateIssuerServiceServer() +type UnsafeCertificateIssuerServer interface { + mustEmbedUnimplementedCertificateIssuerServer() } -func RegisterCertificateIssuerServiceServer(s grpc.ServiceRegistrar, srv CertificateIssuerServiceServer) { - // If the following call panics, it indicates UnimplementedCertificateIssuerServiceServer was +func RegisterCertificateIssuerServer(s grpc.ServiceRegistrar, srv CertificateIssuerServer) { + // If the following call panics, it indicates UnimplementedCertificateIssuerServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } - s.RegisterService(&CertificateIssuerService_ServiceDesc, srv) + s.RegisterService(&CertificateIssuer_ServiceDesc, srv) } -func _CertificateIssuerService_GetCertificate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetCertificateRequest) +func _CertificateIssuer_IssueCertificate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(IssueCertificateRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(CertificateIssuerServiceServer).GetCertificate(ctx, in) + return srv.(CertificateIssuerServer).IssueCertificate(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: CertificateIssuerService_GetCertificate_FullMethodName, + FullMethod: CertificateIssuer_IssueCertificate_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CertificateIssuerServiceServer).GetCertificate(ctx, req.(*GetCertificateRequest)) + return srv.(CertificateIssuerServer).IssueCertificate(ctx, req.(*IssueCertificateRequest)) } return interceptor(ctx, in, info, handler) } -// CertificateIssuerService_ServiceDesc is the grpc.ServiceDesc for CertificateIssuerService service. +// CertificateIssuer_ServiceDesc is the grpc.ServiceDesc for CertificateIssuer service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) -var CertificateIssuerService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "plugin.certificate_issuer.v1.CertificateIssuerService", - HandlerType: (*CertificateIssuerServiceServer)(nil), +var CertificateIssuer_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "plugin.certificate_issuer.v1.CertificateIssuer", + HandlerType: (*CertificateIssuerServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "GetCertificate", - Handler: _CertificateIssuerService_GetCertificate_Handler, + MethodName: "IssueCertificate", + Handler: _CertificateIssuer_IssueCertificate_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/proto/plugin/common/v1/common.pb.go b/proto/plugin/common/v1/common.pb.go new file mode 100644 index 0000000..ee97e04 --- /dev/null +++ b/proto/plugin/common/v1/common.pb.go @@ -0,0 +1,129 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc (unknown) +// source: plugin/common/v1/common.proto + +package commonv1 + +import ( + reflect "reflect" + sync "sync" + unsafe "unsafe" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + structpb "google.golang.org/protobuf/types/known/structpb" +) + +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) +) + +// KeystoreConfig represents the configuration for a key store instance +// This is shared between management and operations plugins +type KeystoreConfig struct { + state protoimpl.MessageState `protogen:"open.v1"` + ConfigurationParameters *structpb.Struct `protobuf:"bytes,1,opt,name=configuration_parameters,json=configurationParameters,proto3" json:"configuration_parameters,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *KeystoreConfig) Reset() { + *x = KeystoreConfig{} + mi := &file_plugin_common_v1_common_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *KeystoreConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*KeystoreConfig) ProtoMessage() {} + +func (x *KeystoreConfig) ProtoReflect() protoreflect.Message { + mi := &file_plugin_common_v1_common_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 KeystoreConfig.ProtoReflect.Descriptor instead. +func (*KeystoreConfig) Descriptor() ([]byte, []int) { + return file_plugin_common_v1_common_proto_rawDescGZIP(), []int{0} +} + +func (x *KeystoreConfig) GetConfigurationParameters() *structpb.Struct { + if x != nil { + return x.ConfigurationParameters + } + return nil +} + +var File_plugin_common_v1_common_proto protoreflect.FileDescriptor + +const file_plugin_common_v1_common_proto_rawDesc = "" + + "\n" + + "\x1dplugin/common/v1/common.proto\x12\x10plugin.common.v1\x1a\x1cgoogle/protobuf/struct.proto\"d\n" + + "\x0eKeystoreConfig\x12R\n" + + "\x18configuration_parameters\x18\x01 \x01(\v2\x17.google.protobuf.StructR\x17configurationParametersB\xc4\x01\n" + + "\x14com.plugin.common.v1B\vCommonProtoP\x01Z=github.com/openkcm/plugin-sdk/proto/plugin/common/v1;commonv1\xa2\x02\x03PCX\xaa\x02\x10Plugin.Common.V1\xca\x02\x10Plugin\\Common\\V1\xe2\x02\x1cPlugin\\Common\\V1\\GPBMetadata\xea\x02\x12Plugin::Common::V1b\x06proto3" + +var ( + file_plugin_common_v1_common_proto_rawDescOnce sync.Once + file_plugin_common_v1_common_proto_rawDescData []byte +) + +func file_plugin_common_v1_common_proto_rawDescGZIP() []byte { + file_plugin_common_v1_common_proto_rawDescOnce.Do(func() { + file_plugin_common_v1_common_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_plugin_common_v1_common_proto_rawDesc), len(file_plugin_common_v1_common_proto_rawDesc))) + }) + return file_plugin_common_v1_common_proto_rawDescData +} + +var file_plugin_common_v1_common_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_plugin_common_v1_common_proto_goTypes = []any{ + (*KeystoreConfig)(nil), // 0: plugin.common.v1.KeystoreConfig + (*structpb.Struct)(nil), // 1: google.protobuf.Struct +} +var file_plugin_common_v1_common_proto_depIdxs = []int32{ + 1, // 0: plugin.common.v1.KeystoreConfig.configuration_parameters:type_name -> google.protobuf.Struct + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_plugin_common_v1_common_proto_init() } +func file_plugin_common_v1_common_proto_init() { + if File_plugin_common_v1_common_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_plugin_common_v1_common_proto_rawDesc), len(file_plugin_common_v1_common_proto_rawDesc)), + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_plugin_common_v1_common_proto_goTypes, + DependencyIndexes: file_plugin_common_v1_common_proto_depIdxs, + MessageInfos: file_plugin_common_v1_common_proto_msgTypes, + }.Build() + File_plugin_common_v1_common_proto = out.File + file_plugin_common_v1_common_proto_goTypes = nil + file_plugin_common_v1_common_proto_depIdxs = nil +} diff --git a/proto/plugin/common/v1/common.pb.validate.go b/proto/plugin/common/v1/common.pb.validate.go new file mode 100644 index 0000000..4f88e19 --- /dev/null +++ b/proto/plugin/common/v1/common.pb.validate.go @@ -0,0 +1,165 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: plugin/common/v1/common.proto + +package commonv1 + +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 KeystoreConfig 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 *KeystoreConfig) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on KeystoreConfig 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 KeystoreConfigMultiError, +// or nil if none found. +func (m *KeystoreConfig) ValidateAll() error { + return m.validate(true) +} + +func (m *KeystoreConfig) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetConfigurationParameters()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, KeystoreConfigValidationError{ + field: "ConfigurationParameters", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, KeystoreConfigValidationError{ + field: "ConfigurationParameters", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetConfigurationParameters()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return KeystoreConfigValidationError{ + field: "ConfigurationParameters", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return KeystoreConfigMultiError(errors) + } + + return nil +} + +// KeystoreConfigMultiError is an error wrapping multiple validation errors +// returned by KeystoreConfig.ValidateAll() if the designated constraints +// aren't met. +type KeystoreConfigMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m KeystoreConfigMultiError) 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 KeystoreConfigMultiError) AllErrors() []error { return m } + +// KeystoreConfigValidationError is the validation error returned by +// KeystoreConfig.Validate if the designated constraints aren't met. +type KeystoreConfigValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e KeystoreConfigValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e KeystoreConfigValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e KeystoreConfigValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e KeystoreConfigValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e KeystoreConfigValidationError) ErrorName() string { return "KeystoreConfigValidationError" } + +// Error satisfies the builtin error interface +func (e KeystoreConfigValidationError) 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 %sKeystoreConfig.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = KeystoreConfigValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = KeystoreConfigValidationError{} diff --git a/proto/plugin/common/v1/common.proto b/proto/plugin/common/v1/common.proto new file mode 100644 index 0000000..362a727 --- /dev/null +++ b/proto/plugin/common/v1/common.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; +package plugin.common.v1; + +import "google/protobuf/struct.proto"; + +// KeystoreConfig represents the configuration for a key store instance +// This is shared between management and operations plugins +message KeystoreConfig { + google.protobuf.Struct configuration_parameters = 1; +} diff --git a/proto/plugin/identity_management/v1/identity_management.pb.go b/proto/plugin/identity_management/v1/identity_management.pb.go index caf3355..5d34979 100644 --- a/proto/plugin/identity_management/v1/identity_management.pb.go +++ b/proto/plugin/identity_management/v1/identity_management.pb.go @@ -162,27 +162,27 @@ func (x *GetGroupResponse) GetGroup() *Group { return nil } -type GetAllGroupsRequest struct { +type ListGroupsRequest struct { state protoimpl.MessageState `protogen:"open.v1"` AuthContext *AuthContext `protobuf:"bytes,99,opt,name=auth_context,json=authContext,proto3" json:"auth_context,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *GetAllGroupsRequest) Reset() { - *x = GetAllGroupsRequest{} +func (x *ListGroupsRequest) Reset() { + *x = ListGroupsRequest{} mi := &file_plugin_identity_management_v1_identity_management_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *GetAllGroupsRequest) String() string { +func (x *ListGroupsRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetAllGroupsRequest) ProtoMessage() {} +func (*ListGroupsRequest) ProtoMessage() {} -func (x *GetAllGroupsRequest) ProtoReflect() protoreflect.Message { +func (x *ListGroupsRequest) ProtoReflect() protoreflect.Message { mi := &file_plugin_identity_management_v1_identity_management_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -194,39 +194,39 @@ func (x *GetAllGroupsRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetAllGroupsRequest.ProtoReflect.Descriptor instead. -func (*GetAllGroupsRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use ListGroupsRequest.ProtoReflect.Descriptor instead. +func (*ListGroupsRequest) Descriptor() ([]byte, []int) { return file_plugin_identity_management_v1_identity_management_proto_rawDescGZIP(), []int{3} } -func (x *GetAllGroupsRequest) GetAuthContext() *AuthContext { +func (x *ListGroupsRequest) GetAuthContext() *AuthContext { if x != nil { return x.AuthContext } return nil } -type GetAllGroupsResponse struct { +type ListGroupsResponse struct { state protoimpl.MessageState `protogen:"open.v1"` Groups []*Group `protobuf:"bytes,1,rep,name=groups,proto3" json:"groups,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *GetAllGroupsResponse) Reset() { - *x = GetAllGroupsResponse{} +func (x *ListGroupsResponse) Reset() { + *x = ListGroupsResponse{} mi := &file_plugin_identity_management_v1_identity_management_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *GetAllGroupsResponse) String() string { +func (x *ListGroupsResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetAllGroupsResponse) ProtoMessage() {} +func (*ListGroupsResponse) ProtoMessage() {} -func (x *GetAllGroupsResponse) ProtoReflect() protoreflect.Message { +func (x *ListGroupsResponse) ProtoReflect() protoreflect.Message { mi := &file_plugin_identity_management_v1_identity_management_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -238,19 +238,19 @@ func (x *GetAllGroupsResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetAllGroupsResponse.ProtoReflect.Descriptor instead. -func (*GetAllGroupsResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use ListGroupsResponse.ProtoReflect.Descriptor instead. +func (*ListGroupsResponse) Descriptor() ([]byte, []int) { return file_plugin_identity_management_v1_identity_management_proto_rawDescGZIP(), []int{4} } -func (x *GetAllGroupsResponse) GetGroups() []*Group { +func (x *ListGroupsResponse) GetGroups() []*Group { if x != nil { return x.Groups } return nil } -type GetUsersForGroupRequest struct { +type ListGroupUsersRequest struct { state protoimpl.MessageState `protogen:"open.v1"` GroupId string `protobuf:"bytes,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` AuthContext *AuthContext `protobuf:"bytes,99,opt,name=auth_context,json=authContext,proto3" json:"auth_context,omitempty"` @@ -258,20 +258,20 @@ type GetUsersForGroupRequest struct { sizeCache protoimpl.SizeCache } -func (x *GetUsersForGroupRequest) Reset() { - *x = GetUsersForGroupRequest{} +func (x *ListGroupUsersRequest) Reset() { + *x = ListGroupUsersRequest{} mi := &file_plugin_identity_management_v1_identity_management_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *GetUsersForGroupRequest) String() string { +func (x *ListGroupUsersRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetUsersForGroupRequest) ProtoMessage() {} +func (*ListGroupUsersRequest) ProtoMessage() {} -func (x *GetUsersForGroupRequest) ProtoReflect() protoreflect.Message { +func (x *ListGroupUsersRequest) ProtoReflect() protoreflect.Message { mi := &file_plugin_identity_management_v1_identity_management_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -283,46 +283,46 @@ func (x *GetUsersForGroupRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetUsersForGroupRequest.ProtoReflect.Descriptor instead. -func (*GetUsersForGroupRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use ListGroupUsersRequest.ProtoReflect.Descriptor instead. +func (*ListGroupUsersRequest) Descriptor() ([]byte, []int) { return file_plugin_identity_management_v1_identity_management_proto_rawDescGZIP(), []int{5} } -func (x *GetUsersForGroupRequest) GetGroupId() string { +func (x *ListGroupUsersRequest) GetGroupId() string { if x != nil { return x.GroupId } return "" } -func (x *GetUsersForGroupRequest) GetAuthContext() *AuthContext { +func (x *ListGroupUsersRequest) GetAuthContext() *AuthContext { if x != nil { return x.AuthContext } return nil } -type GetUsersForGroupResponse struct { +type ListGroupUsersResponse struct { state protoimpl.MessageState `protogen:"open.v1"` Users []*User `protobuf:"bytes,1,rep,name=users,proto3" json:"users,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *GetUsersForGroupResponse) Reset() { - *x = GetUsersForGroupResponse{} +func (x *ListGroupUsersResponse) Reset() { + *x = ListGroupUsersResponse{} mi := &file_plugin_identity_management_v1_identity_management_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *GetUsersForGroupResponse) String() string { +func (x *ListGroupUsersResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetUsersForGroupResponse) ProtoMessage() {} +func (*ListGroupUsersResponse) ProtoMessage() {} -func (x *GetUsersForGroupResponse) ProtoReflect() protoreflect.Message { +func (x *ListGroupUsersResponse) ProtoReflect() protoreflect.Message { mi := &file_plugin_identity_management_v1_identity_management_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -334,12 +334,12 @@ func (x *GetUsersForGroupResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetUsersForGroupResponse.ProtoReflect.Descriptor instead. -func (*GetUsersForGroupResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use ListGroupUsersResponse.ProtoReflect.Descriptor instead. +func (*ListGroupUsersResponse) Descriptor() ([]byte, []int) { return file_plugin_identity_management_v1_identity_management_proto_rawDescGZIP(), []int{6} } -func (x *GetUsersForGroupResponse) GetUsers() []*User { +func (x *ListGroupUsersResponse) GetUsers() []*User { if x != nil { return x.Users } @@ -406,7 +406,7 @@ func (x *User) GetEmail() string { return "" } -type GetGroupsForUserRequest struct { +type ListUserGroupsRequest struct { state protoimpl.MessageState `protogen:"open.v1"` UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` AuthContext *AuthContext `protobuf:"bytes,99,opt,name=auth_context,json=authContext,proto3" json:"auth_context,omitempty"` @@ -414,20 +414,20 @@ type GetGroupsForUserRequest struct { sizeCache protoimpl.SizeCache } -func (x *GetGroupsForUserRequest) Reset() { - *x = GetGroupsForUserRequest{} +func (x *ListUserGroupsRequest) Reset() { + *x = ListUserGroupsRequest{} mi := &file_plugin_identity_management_v1_identity_management_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *GetGroupsForUserRequest) String() string { +func (x *ListUserGroupsRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetGroupsForUserRequest) ProtoMessage() {} +func (*ListUserGroupsRequest) ProtoMessage() {} -func (x *GetGroupsForUserRequest) ProtoReflect() protoreflect.Message { +func (x *ListUserGroupsRequest) ProtoReflect() protoreflect.Message { mi := &file_plugin_identity_management_v1_identity_management_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -439,46 +439,46 @@ func (x *GetGroupsForUserRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetGroupsForUserRequest.ProtoReflect.Descriptor instead. -func (*GetGroupsForUserRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use ListUserGroupsRequest.ProtoReflect.Descriptor instead. +func (*ListUserGroupsRequest) Descriptor() ([]byte, []int) { return file_plugin_identity_management_v1_identity_management_proto_rawDescGZIP(), []int{8} } -func (x *GetGroupsForUserRequest) GetUserId() string { +func (x *ListUserGroupsRequest) GetUserId() string { if x != nil { return x.UserId } return "" } -func (x *GetGroupsForUserRequest) GetAuthContext() *AuthContext { +func (x *ListUserGroupsRequest) GetAuthContext() *AuthContext { if x != nil { return x.AuthContext } return nil } -type GetGroupsForUserResponse struct { +type ListUserGroupsResponse struct { state protoimpl.MessageState `protogen:"open.v1"` Groups []*Group `protobuf:"bytes,1,rep,name=groups,proto3" json:"groups,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *GetGroupsForUserResponse) Reset() { - *x = GetGroupsForUserResponse{} +func (x *ListUserGroupsResponse) Reset() { + *x = ListUserGroupsResponse{} mi := &file_plugin_identity_management_v1_identity_management_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *GetGroupsForUserResponse) String() string { +func (x *ListUserGroupsResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetGroupsForUserResponse) ProtoMessage() {} +func (*ListUserGroupsResponse) ProtoMessage() {} -func (x *GetGroupsForUserResponse) ProtoReflect() protoreflect.Message { +func (x *ListUserGroupsResponse) ProtoReflect() protoreflect.Message { mi := &file_plugin_identity_management_v1_identity_management_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -490,12 +490,12 @@ func (x *GetGroupsForUserResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetGroupsForUserResponse.ProtoReflect.Descriptor instead. -func (*GetGroupsForUserResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use ListUserGroupsResponse.ProtoReflect.Descriptor instead. +func (*ListUserGroupsResponse) Descriptor() ([]byte, []int) { return file_plugin_identity_management_v1_identity_management_proto_rawDescGZIP(), []int{9} } -func (x *GetGroupsForUserResponse) GetGroups() []*Group { +func (x *ListUserGroupsResponse) GetGroups() []*Group { if x != nil { return x.Groups } @@ -569,33 +569,34 @@ const file_plugin_identity_management_v1_identity_management_proto_rawDesc = "" "group_name\x18\x01 \x01(\tR\tgroupName\x12M\n" + "\fauth_context\x18c \x01(\v2*.plugin.identity_management.v1.AuthContextR\vauthContext\"N\n" + "\x10GetGroupResponse\x12:\n" + - "\x05group\x18\x01 \x01(\v2$.plugin.identity_management.v1.GroupR\x05group\"d\n" + - "\x13GetAllGroupsRequest\x12M\n" + - "\fauth_context\x18c \x01(\v2*.plugin.identity_management.v1.AuthContextR\vauthContext\"T\n" + - "\x14GetAllGroupsResponse\x12<\n" + - "\x06groups\x18\x01 \x03(\v2$.plugin.identity_management.v1.GroupR\x06groups\"\x83\x01\n" + - "\x17GetUsersForGroupRequest\x12\x19\n" + + "\x05group\x18\x01 \x01(\v2$.plugin.identity_management.v1.GroupR\x05group\"b\n" + + "\x11ListGroupsRequest\x12M\n" + + "\fauth_context\x18c \x01(\v2*.plugin.identity_management.v1.AuthContextR\vauthContext\"R\n" + + "\x12ListGroupsResponse\x12<\n" + + "\x06groups\x18\x01 \x03(\v2$.plugin.identity_management.v1.GroupR\x06groups\"\x81\x01\n" + + "\x15ListGroupUsersRequest\x12\x19\n" + "\bgroup_id\x18\x01 \x01(\tR\agroupId\x12M\n" + - "\fauth_context\x18c \x01(\v2*.plugin.identity_management.v1.AuthContextR\vauthContext\"U\n" + - "\x18GetUsersForGroupResponse\x129\n" + + "\fauth_context\x18c \x01(\v2*.plugin.identity_management.v1.AuthContextR\vauthContext\"S\n" + + "\x16ListGroupUsersResponse\x129\n" + "\x05users\x18\x01 \x03(\v2#.plugin.identity_management.v1.UserR\x05users\"@\n" + "\x04User\x12\x0e\n" + "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + "\x04name\x18\x02 \x01(\tR\x04name\x12\x14\n" + - "\x05email\x18\x03 \x01(\tR\x05email\"\x81\x01\n" + - "\x17GetGroupsForUserRequest\x12\x17\n" + + "\x05email\x18\x03 \x01(\tR\x05email\"\x7f\n" + + "\x15ListUserGroupsRequest\x12\x17\n" + "\auser_id\x18\x01 \x01(\tR\x06userId\x12M\n" + - "\fauth_context\x18c \x01(\v2*.plugin.identity_management.v1.AuthContextR\vauthContext\"X\n" + - "\x18GetGroupsForUserResponse\x12<\n" + + "\fauth_context\x18c \x01(\v2*.plugin.identity_management.v1.AuthContextR\vauthContext\"V\n" + + "\x16ListUserGroupsResponse\x12<\n" + "\x06groups\x18\x01 \x03(\v2$.plugin.identity_management.v1.GroupR\x06groups\"+\n" + "\x05Group\x12\x0e\n" + "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + - "\x04name\x18\x02 \x01(\tR\x04name2\x8d\x04\n" + - "\x19IdentityManagementService\x12k\n" + - "\bGetGroup\x12..plugin.identity_management.v1.GetGroupRequest\x1a/.plugin.identity_management.v1.GetGroupResponse\x12w\n" + - "\fGetAllGroups\x122.plugin.identity_management.v1.GetAllGroupsRequest\x1a3.plugin.identity_management.v1.GetAllGroupsResponse\x12\x83\x01\n" + - "\x10GetUsersForGroup\x126.plugin.identity_management.v1.GetUsersForGroupRequest\x1a7.plugin.identity_management.v1.GetUsersForGroupResponse\x12\x83\x01\n" + - "\x10GetGroupsForUser\x126.plugin.identity_management.v1.GetGroupsForUserRequest\x1a7.plugin.identity_management.v1.GetGroupsForUserResponseB\xa7\x02\n" + + "\x04name\x18\x02 \x01(\tR\x04name2\xf2\x03\n" + + "\x12IdentityManagement\x12k\n" + + "\bGetGroup\x12..plugin.identity_management.v1.GetGroupRequest\x1a/.plugin.identity_management.v1.GetGroupResponse\x12q\n" + + "\n" + + "ListGroups\x120.plugin.identity_management.v1.ListGroupsRequest\x1a1.plugin.identity_management.v1.ListGroupsResponse\x12}\n" + + "\x0eListGroupUsers\x124.plugin.identity_management.v1.ListGroupUsersRequest\x1a5.plugin.identity_management.v1.ListGroupUsersResponse\x12}\n" + + "\x0eListUserGroups\x124.plugin.identity_management.v1.ListUserGroupsRequest\x1a5.plugin.identity_management.v1.ListUserGroupsResponseB\xa7\x02\n" + "!com.plugin.identity_management.v1B\x17IdentityManagementProtoP\x01ZWgithub.com/openkcm/plugin-sdk/proto/plugin/identity_management/v1;identity_managementv1\xa2\x02\x03PIX\xaa\x02\x1cPlugin.IdentityManagement.V1\xca\x02\x1cPlugin\\IdentityManagement\\V1\xe2\x02(Plugin\\IdentityManagement\\V1\\GPBMetadata\xea\x02\x1ePlugin::IdentityManagement::V1b\x06proto3" var ( @@ -612,37 +613,37 @@ func file_plugin_identity_management_v1_identity_management_proto_rawDescGZIP() var file_plugin_identity_management_v1_identity_management_proto_msgTypes = make([]protoimpl.MessageInfo, 12) var file_plugin_identity_management_v1_identity_management_proto_goTypes = []any{ - (*AuthContext)(nil), // 0: plugin.identity_management.v1.AuthContext - (*GetGroupRequest)(nil), // 1: plugin.identity_management.v1.GetGroupRequest - (*GetGroupResponse)(nil), // 2: plugin.identity_management.v1.GetGroupResponse - (*GetAllGroupsRequest)(nil), // 3: plugin.identity_management.v1.GetAllGroupsRequest - (*GetAllGroupsResponse)(nil), // 4: plugin.identity_management.v1.GetAllGroupsResponse - (*GetUsersForGroupRequest)(nil), // 5: plugin.identity_management.v1.GetUsersForGroupRequest - (*GetUsersForGroupResponse)(nil), // 6: plugin.identity_management.v1.GetUsersForGroupResponse - (*User)(nil), // 7: plugin.identity_management.v1.User - (*GetGroupsForUserRequest)(nil), // 8: plugin.identity_management.v1.GetGroupsForUserRequest - (*GetGroupsForUserResponse)(nil), // 9: plugin.identity_management.v1.GetGroupsForUserResponse - (*Group)(nil), // 10: plugin.identity_management.v1.Group - nil, // 11: plugin.identity_management.v1.AuthContext.DataEntry + (*AuthContext)(nil), // 0: plugin.identity_management.v1.AuthContext + (*GetGroupRequest)(nil), // 1: plugin.identity_management.v1.GetGroupRequest + (*GetGroupResponse)(nil), // 2: plugin.identity_management.v1.GetGroupResponse + (*ListGroupsRequest)(nil), // 3: plugin.identity_management.v1.ListGroupsRequest + (*ListGroupsResponse)(nil), // 4: plugin.identity_management.v1.ListGroupsResponse + (*ListGroupUsersRequest)(nil), // 5: plugin.identity_management.v1.ListGroupUsersRequest + (*ListGroupUsersResponse)(nil), // 6: plugin.identity_management.v1.ListGroupUsersResponse + (*User)(nil), // 7: plugin.identity_management.v1.User + (*ListUserGroupsRequest)(nil), // 8: plugin.identity_management.v1.ListUserGroupsRequest + (*ListUserGroupsResponse)(nil), // 9: plugin.identity_management.v1.ListUserGroupsResponse + (*Group)(nil), // 10: plugin.identity_management.v1.Group + nil, // 11: plugin.identity_management.v1.AuthContext.DataEntry } var file_plugin_identity_management_v1_identity_management_proto_depIdxs = []int32{ 11, // 0: plugin.identity_management.v1.AuthContext.data:type_name -> plugin.identity_management.v1.AuthContext.DataEntry 0, // 1: plugin.identity_management.v1.GetGroupRequest.auth_context:type_name -> plugin.identity_management.v1.AuthContext 10, // 2: plugin.identity_management.v1.GetGroupResponse.group:type_name -> plugin.identity_management.v1.Group - 0, // 3: plugin.identity_management.v1.GetAllGroupsRequest.auth_context:type_name -> plugin.identity_management.v1.AuthContext - 10, // 4: plugin.identity_management.v1.GetAllGroupsResponse.groups:type_name -> plugin.identity_management.v1.Group - 0, // 5: plugin.identity_management.v1.GetUsersForGroupRequest.auth_context:type_name -> plugin.identity_management.v1.AuthContext - 7, // 6: plugin.identity_management.v1.GetUsersForGroupResponse.users:type_name -> plugin.identity_management.v1.User - 0, // 7: plugin.identity_management.v1.GetGroupsForUserRequest.auth_context:type_name -> plugin.identity_management.v1.AuthContext - 10, // 8: plugin.identity_management.v1.GetGroupsForUserResponse.groups:type_name -> plugin.identity_management.v1.Group - 1, // 9: plugin.identity_management.v1.IdentityManagementService.GetGroup:input_type -> plugin.identity_management.v1.GetGroupRequest - 3, // 10: plugin.identity_management.v1.IdentityManagementService.GetAllGroups:input_type -> plugin.identity_management.v1.GetAllGroupsRequest - 5, // 11: plugin.identity_management.v1.IdentityManagementService.GetUsersForGroup:input_type -> plugin.identity_management.v1.GetUsersForGroupRequest - 8, // 12: plugin.identity_management.v1.IdentityManagementService.GetGroupsForUser:input_type -> plugin.identity_management.v1.GetGroupsForUserRequest - 2, // 13: plugin.identity_management.v1.IdentityManagementService.GetGroup:output_type -> plugin.identity_management.v1.GetGroupResponse - 4, // 14: plugin.identity_management.v1.IdentityManagementService.GetAllGroups:output_type -> plugin.identity_management.v1.GetAllGroupsResponse - 6, // 15: plugin.identity_management.v1.IdentityManagementService.GetUsersForGroup:output_type -> plugin.identity_management.v1.GetUsersForGroupResponse - 9, // 16: plugin.identity_management.v1.IdentityManagementService.GetGroupsForUser:output_type -> plugin.identity_management.v1.GetGroupsForUserResponse + 0, // 3: plugin.identity_management.v1.ListGroupsRequest.auth_context:type_name -> plugin.identity_management.v1.AuthContext + 10, // 4: plugin.identity_management.v1.ListGroupsResponse.groups:type_name -> plugin.identity_management.v1.Group + 0, // 5: plugin.identity_management.v1.ListGroupUsersRequest.auth_context:type_name -> plugin.identity_management.v1.AuthContext + 7, // 6: plugin.identity_management.v1.ListGroupUsersResponse.users:type_name -> plugin.identity_management.v1.User + 0, // 7: plugin.identity_management.v1.ListUserGroupsRequest.auth_context:type_name -> plugin.identity_management.v1.AuthContext + 10, // 8: plugin.identity_management.v1.ListUserGroupsResponse.groups:type_name -> plugin.identity_management.v1.Group + 1, // 9: plugin.identity_management.v1.IdentityManagement.GetGroup:input_type -> plugin.identity_management.v1.GetGroupRequest + 3, // 10: plugin.identity_management.v1.IdentityManagement.ListGroups:input_type -> plugin.identity_management.v1.ListGroupsRequest + 5, // 11: plugin.identity_management.v1.IdentityManagement.ListGroupUsers:input_type -> plugin.identity_management.v1.ListGroupUsersRequest + 8, // 12: plugin.identity_management.v1.IdentityManagement.ListUserGroups:input_type -> plugin.identity_management.v1.ListUserGroupsRequest + 2, // 13: plugin.identity_management.v1.IdentityManagement.GetGroup:output_type -> plugin.identity_management.v1.GetGroupResponse + 4, // 14: plugin.identity_management.v1.IdentityManagement.ListGroups:output_type -> plugin.identity_management.v1.ListGroupsResponse + 6, // 15: plugin.identity_management.v1.IdentityManagement.ListGroupUsers:output_type -> plugin.identity_management.v1.ListGroupUsersResponse + 9, // 16: plugin.identity_management.v1.IdentityManagement.ListUserGroups:output_type -> plugin.identity_management.v1.ListUserGroupsResponse 13, // [13:17] is the sub-list for method output_type 9, // [9:13] is the sub-list for method input_type 9, // [9:9] is the sub-list for extension type_name diff --git a/proto/plugin/identity_management/v1/identity_management.pb.validate.go b/proto/plugin/identity_management/v1/identity_management.pb.validate.go index c72e3ef..a11a68a 100644 --- a/proto/plugin/identity_management/v1/identity_management.pb.validate.go +++ b/proto/plugin/identity_management/v1/identity_management.pb.validate.go @@ -396,22 +396,22 @@ var _ interface { ErrorName() string } = GetGroupResponseValidationError{} -// Validate checks the field values on GetAllGroupsRequest 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 *GetAllGroupsRequest) Validate() error { +// Validate checks the field values on ListGroupsRequest 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 *ListGroupsRequest) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on GetAllGroupsRequest with the rules +// ValidateAll checks the field values on ListGroupsRequest 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 -// GetAllGroupsRequestMultiError, or nil if none found. -func (m *GetAllGroupsRequest) ValidateAll() error { +// ListGroupsRequestMultiError, or nil if none found. +func (m *ListGroupsRequest) ValidateAll() error { return m.validate(true) } -func (m *GetAllGroupsRequest) validate(all bool) error { +func (m *ListGroupsRequest) validate(all bool) error { if m == nil { return nil } @@ -422,7 +422,7 @@ func (m *GetAllGroupsRequest) validate(all bool) error { switch v := interface{}(m.GetAuthContext()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, GetAllGroupsRequestValidationError{ + errors = append(errors, ListGroupsRequestValidationError{ field: "AuthContext", reason: "embedded message failed validation", cause: err, @@ -430,7 +430,7 @@ func (m *GetAllGroupsRequest) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, GetAllGroupsRequestValidationError{ + errors = append(errors, ListGroupsRequestValidationError{ field: "AuthContext", reason: "embedded message failed validation", cause: err, @@ -439,7 +439,7 @@ func (m *GetAllGroupsRequest) validate(all bool) error { } } else if v, ok := interface{}(m.GetAuthContext()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return GetAllGroupsRequestValidationError{ + return ListGroupsRequestValidationError{ field: "AuthContext", reason: "embedded message failed validation", cause: err, @@ -448,19 +448,19 @@ func (m *GetAllGroupsRequest) validate(all bool) error { } if len(errors) > 0 { - return GetAllGroupsRequestMultiError(errors) + return ListGroupsRequestMultiError(errors) } return nil } -// GetAllGroupsRequestMultiError is an error wrapping multiple validation -// errors returned by GetAllGroupsRequest.ValidateAll() if the designated -// constraints aren't met. -type GetAllGroupsRequestMultiError []error +// ListGroupsRequestMultiError is an error wrapping multiple validation errors +// returned by ListGroupsRequest.ValidateAll() if the designated constraints +// aren't met. +type ListGroupsRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m GetAllGroupsRequestMultiError) Error() string { +func (m ListGroupsRequestMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -469,11 +469,11 @@ func (m GetAllGroupsRequestMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m GetAllGroupsRequestMultiError) AllErrors() []error { return m } +func (m ListGroupsRequestMultiError) AllErrors() []error { return m } -// GetAllGroupsRequestValidationError is the validation error returned by -// GetAllGroupsRequest.Validate if the designated constraints aren't met. -type GetAllGroupsRequestValidationError struct { +// ListGroupsRequestValidationError is the validation error returned by +// ListGroupsRequest.Validate if the designated constraints aren't met. +type ListGroupsRequestValidationError struct { field string reason string cause error @@ -481,24 +481,24 @@ type GetAllGroupsRequestValidationError struct { } // Field function returns field value. -func (e GetAllGroupsRequestValidationError) Field() string { return e.field } +func (e ListGroupsRequestValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e GetAllGroupsRequestValidationError) Reason() string { return e.reason } +func (e ListGroupsRequestValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e GetAllGroupsRequestValidationError) Cause() error { return e.cause } +func (e ListGroupsRequestValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e GetAllGroupsRequestValidationError) Key() bool { return e.key } +func (e ListGroupsRequestValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e GetAllGroupsRequestValidationError) ErrorName() string { - return "GetAllGroupsRequestValidationError" +func (e ListGroupsRequestValidationError) ErrorName() string { + return "ListGroupsRequestValidationError" } // Error satisfies the builtin error interface -func (e GetAllGroupsRequestValidationError) Error() string { +func (e ListGroupsRequestValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -510,14 +510,14 @@ func (e GetAllGroupsRequestValidationError) Error() string { } return fmt.Sprintf( - "invalid %sGetAllGroupsRequest.%s: %s%s", + "invalid %sListGroupsRequest.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = GetAllGroupsRequestValidationError{} +var _ error = ListGroupsRequestValidationError{} var _ interface { Field() string @@ -525,24 +525,24 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = GetAllGroupsRequestValidationError{} +} = ListGroupsRequestValidationError{} -// Validate checks the field values on GetAllGroupsResponse with the rules +// Validate checks the field values on ListGroupsResponse 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 *GetAllGroupsResponse) Validate() error { +func (m *ListGroupsResponse) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on GetAllGroupsResponse with the rules +// ValidateAll checks the field values on ListGroupsResponse 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 -// GetAllGroupsResponseMultiError, or nil if none found. -func (m *GetAllGroupsResponse) ValidateAll() error { +// ListGroupsResponseMultiError, or nil if none found. +func (m *ListGroupsResponse) ValidateAll() error { return m.validate(true) } -func (m *GetAllGroupsResponse) validate(all bool) error { +func (m *ListGroupsResponse) validate(all bool) error { if m == nil { return nil } @@ -556,7 +556,7 @@ func (m *GetAllGroupsResponse) validate(all bool) error { switch v := interface{}(item).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, GetAllGroupsResponseValidationError{ + errors = append(errors, ListGroupsResponseValidationError{ field: fmt.Sprintf("Groups[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -564,7 +564,7 @@ func (m *GetAllGroupsResponse) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, GetAllGroupsResponseValidationError{ + errors = append(errors, ListGroupsResponseValidationError{ field: fmt.Sprintf("Groups[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -573,7 +573,7 @@ func (m *GetAllGroupsResponse) validate(all bool) error { } } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return GetAllGroupsResponseValidationError{ + return ListGroupsResponseValidationError{ field: fmt.Sprintf("Groups[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -584,19 +584,19 @@ func (m *GetAllGroupsResponse) validate(all bool) error { } if len(errors) > 0 { - return GetAllGroupsResponseMultiError(errors) + return ListGroupsResponseMultiError(errors) } return nil } -// GetAllGroupsResponseMultiError is an error wrapping multiple validation -// errors returned by GetAllGroupsResponse.ValidateAll() if the designated -// constraints aren't met. -type GetAllGroupsResponseMultiError []error +// ListGroupsResponseMultiError is an error wrapping multiple validation errors +// returned by ListGroupsResponse.ValidateAll() if the designated constraints +// aren't met. +type ListGroupsResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m GetAllGroupsResponseMultiError) Error() string { +func (m ListGroupsResponseMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -605,11 +605,11 @@ func (m GetAllGroupsResponseMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m GetAllGroupsResponseMultiError) AllErrors() []error { return m } +func (m ListGroupsResponseMultiError) AllErrors() []error { return m } -// GetAllGroupsResponseValidationError is the validation error returned by -// GetAllGroupsResponse.Validate if the designated constraints aren't met. -type GetAllGroupsResponseValidationError struct { +// ListGroupsResponseValidationError is the validation error returned by +// ListGroupsResponse.Validate if the designated constraints aren't met. +type ListGroupsResponseValidationError struct { field string reason string cause error @@ -617,24 +617,24 @@ type GetAllGroupsResponseValidationError struct { } // Field function returns field value. -func (e GetAllGroupsResponseValidationError) Field() string { return e.field } +func (e ListGroupsResponseValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e GetAllGroupsResponseValidationError) Reason() string { return e.reason } +func (e ListGroupsResponseValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e GetAllGroupsResponseValidationError) Cause() error { return e.cause } +func (e ListGroupsResponseValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e GetAllGroupsResponseValidationError) Key() bool { return e.key } +func (e ListGroupsResponseValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e GetAllGroupsResponseValidationError) ErrorName() string { - return "GetAllGroupsResponseValidationError" +func (e ListGroupsResponseValidationError) ErrorName() string { + return "ListGroupsResponseValidationError" } // Error satisfies the builtin error interface -func (e GetAllGroupsResponseValidationError) Error() string { +func (e ListGroupsResponseValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -646,14 +646,14 @@ func (e GetAllGroupsResponseValidationError) Error() string { } return fmt.Sprintf( - "invalid %sGetAllGroupsResponse.%s: %s%s", + "invalid %sListGroupsResponse.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = GetAllGroupsResponseValidationError{} +var _ error = ListGroupsResponseValidationError{} var _ interface { Field() string @@ -661,24 +661,24 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = GetAllGroupsResponseValidationError{} +} = ListGroupsResponseValidationError{} -// Validate checks the field values on GetUsersForGroupRequest with the rules +// Validate checks the field values on ListGroupUsersRequest 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 *GetUsersForGroupRequest) Validate() error { +func (m *ListGroupUsersRequest) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on GetUsersForGroupRequest with the -// rules defined in the proto definition for this message. If any rules are +// ValidateAll checks the field values on ListGroupUsersRequest 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 -// GetUsersForGroupRequestMultiError, or nil if none found. -func (m *GetUsersForGroupRequest) ValidateAll() error { +// ListGroupUsersRequestMultiError, or nil if none found. +func (m *ListGroupUsersRequest) ValidateAll() error { return m.validate(true) } -func (m *GetUsersForGroupRequest) validate(all bool) error { +func (m *ListGroupUsersRequest) validate(all bool) error { if m == nil { return nil } @@ -691,7 +691,7 @@ func (m *GetUsersForGroupRequest) validate(all bool) error { switch v := interface{}(m.GetAuthContext()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, GetUsersForGroupRequestValidationError{ + errors = append(errors, ListGroupUsersRequestValidationError{ field: "AuthContext", reason: "embedded message failed validation", cause: err, @@ -699,7 +699,7 @@ func (m *GetUsersForGroupRequest) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, GetUsersForGroupRequestValidationError{ + errors = append(errors, ListGroupUsersRequestValidationError{ field: "AuthContext", reason: "embedded message failed validation", cause: err, @@ -708,7 +708,7 @@ func (m *GetUsersForGroupRequest) validate(all bool) error { } } else if v, ok := interface{}(m.GetAuthContext()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return GetUsersForGroupRequestValidationError{ + return ListGroupUsersRequestValidationError{ field: "AuthContext", reason: "embedded message failed validation", cause: err, @@ -717,19 +717,19 @@ func (m *GetUsersForGroupRequest) validate(all bool) error { } if len(errors) > 0 { - return GetUsersForGroupRequestMultiError(errors) + return ListGroupUsersRequestMultiError(errors) } return nil } -// GetUsersForGroupRequestMultiError is an error wrapping multiple validation -// errors returned by GetUsersForGroupRequest.ValidateAll() if the designated +// ListGroupUsersRequestMultiError is an error wrapping multiple validation +// errors returned by ListGroupUsersRequest.ValidateAll() if the designated // constraints aren't met. -type GetUsersForGroupRequestMultiError []error +type ListGroupUsersRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m GetUsersForGroupRequestMultiError) Error() string { +func (m ListGroupUsersRequestMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -738,11 +738,11 @@ func (m GetUsersForGroupRequestMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m GetUsersForGroupRequestMultiError) AllErrors() []error { return m } +func (m ListGroupUsersRequestMultiError) AllErrors() []error { return m } -// GetUsersForGroupRequestValidationError is the validation error returned by -// GetUsersForGroupRequest.Validate if the designated constraints aren't met. -type GetUsersForGroupRequestValidationError struct { +// ListGroupUsersRequestValidationError is the validation error returned by +// ListGroupUsersRequest.Validate if the designated constraints aren't met. +type ListGroupUsersRequestValidationError struct { field string reason string cause error @@ -750,24 +750,24 @@ type GetUsersForGroupRequestValidationError struct { } // Field function returns field value. -func (e GetUsersForGroupRequestValidationError) Field() string { return e.field } +func (e ListGroupUsersRequestValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e GetUsersForGroupRequestValidationError) Reason() string { return e.reason } +func (e ListGroupUsersRequestValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e GetUsersForGroupRequestValidationError) Cause() error { return e.cause } +func (e ListGroupUsersRequestValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e GetUsersForGroupRequestValidationError) Key() bool { return e.key } +func (e ListGroupUsersRequestValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e GetUsersForGroupRequestValidationError) ErrorName() string { - return "GetUsersForGroupRequestValidationError" +func (e ListGroupUsersRequestValidationError) ErrorName() string { + return "ListGroupUsersRequestValidationError" } // Error satisfies the builtin error interface -func (e GetUsersForGroupRequestValidationError) Error() string { +func (e ListGroupUsersRequestValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -779,14 +779,14 @@ func (e GetUsersForGroupRequestValidationError) Error() string { } return fmt.Sprintf( - "invalid %sGetUsersForGroupRequest.%s: %s%s", + "invalid %sListGroupUsersRequest.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = GetUsersForGroupRequestValidationError{} +var _ error = ListGroupUsersRequestValidationError{} var _ interface { Field() string @@ -794,24 +794,24 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = GetUsersForGroupRequestValidationError{} +} = ListGroupUsersRequestValidationError{} -// Validate checks the field values on GetUsersForGroupResponse with the rules +// Validate checks the field values on ListGroupUsersResponse 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 *GetUsersForGroupResponse) Validate() error { +func (m *ListGroupUsersResponse) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on GetUsersForGroupResponse with the -// rules defined in the proto definition for this message. If any rules are +// ValidateAll checks the field values on ListGroupUsersResponse 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 -// GetUsersForGroupResponseMultiError, or nil if none found. -func (m *GetUsersForGroupResponse) ValidateAll() error { +// ListGroupUsersResponseMultiError, or nil if none found. +func (m *ListGroupUsersResponse) ValidateAll() error { return m.validate(true) } -func (m *GetUsersForGroupResponse) validate(all bool) error { +func (m *ListGroupUsersResponse) validate(all bool) error { if m == nil { return nil } @@ -825,7 +825,7 @@ func (m *GetUsersForGroupResponse) validate(all bool) error { switch v := interface{}(item).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, GetUsersForGroupResponseValidationError{ + errors = append(errors, ListGroupUsersResponseValidationError{ field: fmt.Sprintf("Users[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -833,7 +833,7 @@ func (m *GetUsersForGroupResponse) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, GetUsersForGroupResponseValidationError{ + errors = append(errors, ListGroupUsersResponseValidationError{ field: fmt.Sprintf("Users[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -842,7 +842,7 @@ func (m *GetUsersForGroupResponse) validate(all bool) error { } } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return GetUsersForGroupResponseValidationError{ + return ListGroupUsersResponseValidationError{ field: fmt.Sprintf("Users[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -853,19 +853,19 @@ func (m *GetUsersForGroupResponse) validate(all bool) error { } if len(errors) > 0 { - return GetUsersForGroupResponseMultiError(errors) + return ListGroupUsersResponseMultiError(errors) } return nil } -// GetUsersForGroupResponseMultiError is an error wrapping multiple validation -// errors returned by GetUsersForGroupResponse.ValidateAll() if the designated +// ListGroupUsersResponseMultiError is an error wrapping multiple validation +// errors returned by ListGroupUsersResponse.ValidateAll() if the designated // constraints aren't met. -type GetUsersForGroupResponseMultiError []error +type ListGroupUsersResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m GetUsersForGroupResponseMultiError) Error() string { +func (m ListGroupUsersResponseMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -874,11 +874,11 @@ func (m GetUsersForGroupResponseMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m GetUsersForGroupResponseMultiError) AllErrors() []error { return m } +func (m ListGroupUsersResponseMultiError) AllErrors() []error { return m } -// GetUsersForGroupResponseValidationError is the validation error returned by -// GetUsersForGroupResponse.Validate if the designated constraints aren't met. -type GetUsersForGroupResponseValidationError struct { +// ListGroupUsersResponseValidationError is the validation error returned by +// ListGroupUsersResponse.Validate if the designated constraints aren't met. +type ListGroupUsersResponseValidationError struct { field string reason string cause error @@ -886,24 +886,24 @@ type GetUsersForGroupResponseValidationError struct { } // Field function returns field value. -func (e GetUsersForGroupResponseValidationError) Field() string { return e.field } +func (e ListGroupUsersResponseValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e GetUsersForGroupResponseValidationError) Reason() string { return e.reason } +func (e ListGroupUsersResponseValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e GetUsersForGroupResponseValidationError) Cause() error { return e.cause } +func (e ListGroupUsersResponseValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e GetUsersForGroupResponseValidationError) Key() bool { return e.key } +func (e ListGroupUsersResponseValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e GetUsersForGroupResponseValidationError) ErrorName() string { - return "GetUsersForGroupResponseValidationError" +func (e ListGroupUsersResponseValidationError) ErrorName() string { + return "ListGroupUsersResponseValidationError" } // Error satisfies the builtin error interface -func (e GetUsersForGroupResponseValidationError) Error() string { +func (e ListGroupUsersResponseValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -915,14 +915,14 @@ func (e GetUsersForGroupResponseValidationError) Error() string { } return fmt.Sprintf( - "invalid %sGetUsersForGroupResponse.%s: %s%s", + "invalid %sListGroupUsersResponse.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = GetUsersForGroupResponseValidationError{} +var _ error = ListGroupUsersResponseValidationError{} var _ interface { Field() string @@ -930,7 +930,7 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = GetUsersForGroupResponseValidationError{} +} = ListGroupUsersResponseValidationError{} // Validate checks the field values on User with the rules defined in the proto // definition for this message. If any rules are violated, the first error @@ -1036,22 +1036,22 @@ var _ interface { ErrorName() string } = UserValidationError{} -// Validate checks the field values on GetGroupsForUserRequest with the rules +// Validate checks the field values on ListUserGroupsRequest 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 *GetGroupsForUserRequest) Validate() error { +func (m *ListUserGroupsRequest) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on GetGroupsForUserRequest with the -// rules defined in the proto definition for this message. If any rules are +// ValidateAll checks the field values on ListUserGroupsRequest 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 -// GetGroupsForUserRequestMultiError, or nil if none found. -func (m *GetGroupsForUserRequest) ValidateAll() error { +// ListUserGroupsRequestMultiError, or nil if none found. +func (m *ListUserGroupsRequest) ValidateAll() error { return m.validate(true) } -func (m *GetGroupsForUserRequest) validate(all bool) error { +func (m *ListUserGroupsRequest) validate(all bool) error { if m == nil { return nil } @@ -1064,7 +1064,7 @@ func (m *GetGroupsForUserRequest) validate(all bool) error { switch v := interface{}(m.GetAuthContext()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, GetGroupsForUserRequestValidationError{ + errors = append(errors, ListUserGroupsRequestValidationError{ field: "AuthContext", reason: "embedded message failed validation", cause: err, @@ -1072,7 +1072,7 @@ func (m *GetGroupsForUserRequest) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, GetGroupsForUserRequestValidationError{ + errors = append(errors, ListUserGroupsRequestValidationError{ field: "AuthContext", reason: "embedded message failed validation", cause: err, @@ -1081,7 +1081,7 @@ func (m *GetGroupsForUserRequest) validate(all bool) error { } } else if v, ok := interface{}(m.GetAuthContext()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return GetGroupsForUserRequestValidationError{ + return ListUserGroupsRequestValidationError{ field: "AuthContext", reason: "embedded message failed validation", cause: err, @@ -1090,19 +1090,19 @@ func (m *GetGroupsForUserRequest) validate(all bool) error { } if len(errors) > 0 { - return GetGroupsForUserRequestMultiError(errors) + return ListUserGroupsRequestMultiError(errors) } return nil } -// GetGroupsForUserRequestMultiError is an error wrapping multiple validation -// errors returned by GetGroupsForUserRequest.ValidateAll() if the designated +// ListUserGroupsRequestMultiError is an error wrapping multiple validation +// errors returned by ListUserGroupsRequest.ValidateAll() if the designated // constraints aren't met. -type GetGroupsForUserRequestMultiError []error +type ListUserGroupsRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m GetGroupsForUserRequestMultiError) Error() string { +func (m ListUserGroupsRequestMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -1111,11 +1111,11 @@ func (m GetGroupsForUserRequestMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m GetGroupsForUserRequestMultiError) AllErrors() []error { return m } +func (m ListUserGroupsRequestMultiError) AllErrors() []error { return m } -// GetGroupsForUserRequestValidationError is the validation error returned by -// GetGroupsForUserRequest.Validate if the designated constraints aren't met. -type GetGroupsForUserRequestValidationError struct { +// ListUserGroupsRequestValidationError is the validation error returned by +// ListUserGroupsRequest.Validate if the designated constraints aren't met. +type ListUserGroupsRequestValidationError struct { field string reason string cause error @@ -1123,24 +1123,24 @@ type GetGroupsForUserRequestValidationError struct { } // Field function returns field value. -func (e GetGroupsForUserRequestValidationError) Field() string { return e.field } +func (e ListUserGroupsRequestValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e GetGroupsForUserRequestValidationError) Reason() string { return e.reason } +func (e ListUserGroupsRequestValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e GetGroupsForUserRequestValidationError) Cause() error { return e.cause } +func (e ListUserGroupsRequestValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e GetGroupsForUserRequestValidationError) Key() bool { return e.key } +func (e ListUserGroupsRequestValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e GetGroupsForUserRequestValidationError) ErrorName() string { - return "GetGroupsForUserRequestValidationError" +func (e ListUserGroupsRequestValidationError) ErrorName() string { + return "ListUserGroupsRequestValidationError" } // Error satisfies the builtin error interface -func (e GetGroupsForUserRequestValidationError) Error() string { +func (e ListUserGroupsRequestValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -1152,14 +1152,14 @@ func (e GetGroupsForUserRequestValidationError) Error() string { } return fmt.Sprintf( - "invalid %sGetGroupsForUserRequest.%s: %s%s", + "invalid %sListUserGroupsRequest.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = GetGroupsForUserRequestValidationError{} +var _ error = ListUserGroupsRequestValidationError{} var _ interface { Field() string @@ -1167,24 +1167,24 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = GetGroupsForUserRequestValidationError{} +} = ListUserGroupsRequestValidationError{} -// Validate checks the field values on GetGroupsForUserResponse with the rules +// Validate checks the field values on ListUserGroupsResponse 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 *GetGroupsForUserResponse) Validate() error { +func (m *ListUserGroupsResponse) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on GetGroupsForUserResponse with the -// rules defined in the proto definition for this message. If any rules are +// ValidateAll checks the field values on ListUserGroupsResponse 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 -// GetGroupsForUserResponseMultiError, or nil if none found. -func (m *GetGroupsForUserResponse) ValidateAll() error { +// ListUserGroupsResponseMultiError, or nil if none found. +func (m *ListUserGroupsResponse) ValidateAll() error { return m.validate(true) } -func (m *GetGroupsForUserResponse) validate(all bool) error { +func (m *ListUserGroupsResponse) validate(all bool) error { if m == nil { return nil } @@ -1198,7 +1198,7 @@ func (m *GetGroupsForUserResponse) validate(all bool) error { switch v := interface{}(item).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, GetGroupsForUserResponseValidationError{ + errors = append(errors, ListUserGroupsResponseValidationError{ field: fmt.Sprintf("Groups[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -1206,7 +1206,7 @@ func (m *GetGroupsForUserResponse) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, GetGroupsForUserResponseValidationError{ + errors = append(errors, ListUserGroupsResponseValidationError{ field: fmt.Sprintf("Groups[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -1215,7 +1215,7 @@ func (m *GetGroupsForUserResponse) validate(all bool) error { } } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return GetGroupsForUserResponseValidationError{ + return ListUserGroupsResponseValidationError{ field: fmt.Sprintf("Groups[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -1226,19 +1226,19 @@ func (m *GetGroupsForUserResponse) validate(all bool) error { } if len(errors) > 0 { - return GetGroupsForUserResponseMultiError(errors) + return ListUserGroupsResponseMultiError(errors) } return nil } -// GetGroupsForUserResponseMultiError is an error wrapping multiple validation -// errors returned by GetGroupsForUserResponse.ValidateAll() if the designated +// ListUserGroupsResponseMultiError is an error wrapping multiple validation +// errors returned by ListUserGroupsResponse.ValidateAll() if the designated // constraints aren't met. -type GetGroupsForUserResponseMultiError []error +type ListUserGroupsResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m GetGroupsForUserResponseMultiError) Error() string { +func (m ListUserGroupsResponseMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -1247,11 +1247,11 @@ func (m GetGroupsForUserResponseMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m GetGroupsForUserResponseMultiError) AllErrors() []error { return m } +func (m ListUserGroupsResponseMultiError) AllErrors() []error { return m } -// GetGroupsForUserResponseValidationError is the validation error returned by -// GetGroupsForUserResponse.Validate if the designated constraints aren't met. -type GetGroupsForUserResponseValidationError struct { +// ListUserGroupsResponseValidationError is the validation error returned by +// ListUserGroupsResponse.Validate if the designated constraints aren't met. +type ListUserGroupsResponseValidationError struct { field string reason string cause error @@ -1259,24 +1259,24 @@ type GetGroupsForUserResponseValidationError struct { } // Field function returns field value. -func (e GetGroupsForUserResponseValidationError) Field() string { return e.field } +func (e ListUserGroupsResponseValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e GetGroupsForUserResponseValidationError) Reason() string { return e.reason } +func (e ListUserGroupsResponseValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e GetGroupsForUserResponseValidationError) Cause() error { return e.cause } +func (e ListUserGroupsResponseValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e GetGroupsForUserResponseValidationError) Key() bool { return e.key } +func (e ListUserGroupsResponseValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e GetGroupsForUserResponseValidationError) ErrorName() string { - return "GetGroupsForUserResponseValidationError" +func (e ListUserGroupsResponseValidationError) ErrorName() string { + return "ListUserGroupsResponseValidationError" } // Error satisfies the builtin error interface -func (e GetGroupsForUserResponseValidationError) Error() string { +func (e ListUserGroupsResponseValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -1288,14 +1288,14 @@ func (e GetGroupsForUserResponseValidationError) Error() string { } return fmt.Sprintf( - "invalid %sGetGroupsForUserResponse.%s: %s%s", + "invalid %sListUserGroupsResponse.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = GetGroupsForUserResponseValidationError{} +var _ error = ListUserGroupsResponseValidationError{} var _ interface { Field() string @@ -1303,7 +1303,7 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = GetGroupsForUserResponseValidationError{} +} = ListUserGroupsResponseValidationError{} // Validate checks the field values on Group with the rules defined in the // proto definition for this message. If any rules are violated, the first diff --git a/proto/plugin/identity_management/v1/identity_management.proto b/proto/plugin/identity_management/v1/identity_management.proto index 1140035..7e463ec 100644 --- a/proto/plugin/identity_management/v1/identity_management.proto +++ b/proto/plugin/identity_management/v1/identity_management.proto @@ -1,11 +1,11 @@ syntax = "proto3"; package plugin.identity_management.v1; -service IdentityManagementService { +service IdentityManagement { rpc GetGroup(GetGroupRequest) returns (GetGroupResponse); - rpc GetAllGroups(GetAllGroupsRequest) returns (GetAllGroupsResponse); - rpc GetUsersForGroup(GetUsersForGroupRequest) returns (GetUsersForGroupResponse); - rpc GetGroupsForUser(GetGroupsForUserRequest) returns (GetGroupsForUserResponse); + rpc ListGroups(ListGroupsRequest) returns (ListGroupsResponse); + rpc ListGroupUsers(ListGroupUsersRequest) returns (ListGroupUsersResponse); + rpc ListUserGroups(ListUserGroupsRequest) returns (ListUserGroupsResponse); } message AuthContext { @@ -21,20 +21,20 @@ message GetGroupResponse { Group group = 1; } -message GetAllGroupsRequest { +message ListGroupsRequest { AuthContext auth_context = 99; } -message GetAllGroupsResponse { +message ListGroupsResponse { repeated Group groups = 1; } -message GetUsersForGroupRequest { +message ListGroupUsersRequest { string group_id = 1; AuthContext auth_context = 99; } -message GetUsersForGroupResponse { +message ListGroupUsersResponse { repeated User users = 1; } @@ -44,12 +44,12 @@ message User { string email = 3; } -message GetGroupsForUserRequest { +message ListUserGroupsRequest { string user_id = 1; AuthContext auth_context = 99; } -message GetGroupsForUserResponse { +message ListUserGroupsResponse { repeated Group groups = 1; } diff --git a/proto/plugin/identity_management/v1/identity_management_ext_plugin.pb.go b/proto/plugin/identity_management/v1/identity_management_ext_plugin.pb.go index a047d65..086f4ac 100644 --- a/proto/plugin/identity_management/v1/identity_management_ext_plugin.pb.go +++ b/proto/plugin/identity_management/v1/identity_management_ext_plugin.pb.go @@ -9,48 +9,48 @@ import ( ) const ( - Type = "IdentityManagementService" - GRPCServiceFullName = "plugin.identity_management.v1.IdentityManagementService" + Type = "IdentityManagement" + GRPCServiceFullName = "plugin.identity_management.v1.IdentityManagement" ) -func IdentityManagementServicePluginServer(server IdentityManagementServiceServer) api.PluginServer { - return identityManagementServicePluginServer{IdentityManagementServiceServer: server} +func IdentityManagementPluginServer(server IdentityManagementServer) api.PluginServer { + return identityManagementPluginServer{IdentityManagementServer: server} } -type identityManagementServicePluginServer struct { - IdentityManagementServiceServer +type identityManagementPluginServer struct { + IdentityManagementServer } -func (s identityManagementServicePluginServer) Type() string { +func (s identityManagementPluginServer) Type() string { return Type } -func (s identityManagementServicePluginServer) GRPCServiceName() string { +func (s identityManagementPluginServer) GRPCServiceName() string { return GRPCServiceFullName } -func (s identityManagementServicePluginServer) RegisterServer(server *grpc.Server) any { - RegisterIdentityManagementServiceServer(server, s.IdentityManagementServiceServer) - return s.IdentityManagementServiceServer +func (s identityManagementPluginServer) RegisterServer(server *grpc.Server) any { + RegisterIdentityManagementServer(server, s.IdentityManagementServer) + return s.IdentityManagementServer } -type IdentityManagementServicePluginClient struct { - IdentityManagementServiceClient +type IdentityManagementPluginClient struct { + IdentityManagementClient } -func (s IdentityManagementServicePluginClient) Type() string { +func (s IdentityManagementPluginClient) Type() string { return Type } -func (c *IdentityManagementServicePluginClient) IsInitialized() bool { - return c.IdentityManagementServiceClient != nil +func (c *IdentityManagementPluginClient) IsInitialized() bool { + return c.IdentityManagementClient != nil } -func (c *IdentityManagementServicePluginClient) GRPCServiceName() string { +func (c *IdentityManagementPluginClient) GRPCServiceName() string { return GRPCServiceFullName } -func (c *IdentityManagementServicePluginClient) InitClient(conn grpc.ClientConnInterface) any { - c.IdentityManagementServiceClient = NewIdentityManagementServiceClient(conn) - return c.IdentityManagementServiceClient +func (c *IdentityManagementPluginClient) InitClient(conn grpc.ClientConnInterface) any { + c.IdentityManagementClient = NewIdentityManagementClient(conn) + return c.IdentityManagementClient } diff --git a/proto/plugin/identity_management/v1/identity_management_grpc.pb.go b/proto/plugin/identity_management/v1/identity_management_grpc.pb.go index 9adc1f9..9a5c990 100644 --- a/proto/plugin/identity_management/v1/identity_management_grpc.pb.go +++ b/proto/plugin/identity_management/v1/identity_management_grpc.pb.go @@ -20,216 +20,215 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - IdentityManagementService_GetGroup_FullMethodName = "/plugin.identity_management.v1.IdentityManagementService/GetGroup" - IdentityManagementService_GetAllGroups_FullMethodName = "/plugin.identity_management.v1.IdentityManagementService/GetAllGroups" - IdentityManagementService_GetUsersForGroup_FullMethodName = "/plugin.identity_management.v1.IdentityManagementService/GetUsersForGroup" - IdentityManagementService_GetGroupsForUser_FullMethodName = "/plugin.identity_management.v1.IdentityManagementService/GetGroupsForUser" + IdentityManagement_GetGroup_FullMethodName = "/plugin.identity_management.v1.IdentityManagement/GetGroup" + IdentityManagement_ListGroups_FullMethodName = "/plugin.identity_management.v1.IdentityManagement/ListGroups" + IdentityManagement_ListGroupUsers_FullMethodName = "/plugin.identity_management.v1.IdentityManagement/ListGroupUsers" + IdentityManagement_ListUserGroups_FullMethodName = "/plugin.identity_management.v1.IdentityManagement/ListUserGroups" ) -// IdentityManagementServiceClient is the client API for IdentityManagementService service. +// IdentityManagementClient is the client API for IdentityManagement service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type IdentityManagementServiceClient interface { +type IdentityManagementClient interface { GetGroup(ctx context.Context, in *GetGroupRequest, opts ...grpc.CallOption) (*GetGroupResponse, error) - GetAllGroups(ctx context.Context, in *GetAllGroupsRequest, opts ...grpc.CallOption) (*GetAllGroupsResponse, error) - GetUsersForGroup(ctx context.Context, in *GetUsersForGroupRequest, opts ...grpc.CallOption) (*GetUsersForGroupResponse, error) - GetGroupsForUser(ctx context.Context, in *GetGroupsForUserRequest, opts ...grpc.CallOption) (*GetGroupsForUserResponse, error) + ListGroups(ctx context.Context, in *ListGroupsRequest, opts ...grpc.CallOption) (*ListGroupsResponse, error) + ListGroupUsers(ctx context.Context, in *ListGroupUsersRequest, opts ...grpc.CallOption) (*ListGroupUsersResponse, error) + ListUserGroups(ctx context.Context, in *ListUserGroupsRequest, opts ...grpc.CallOption) (*ListUserGroupsResponse, error) } -type identityManagementServiceClient struct { +type identityManagementClient struct { cc grpc.ClientConnInterface } -func NewIdentityManagementServiceClient(cc grpc.ClientConnInterface) IdentityManagementServiceClient { - return &identityManagementServiceClient{cc} +func NewIdentityManagementClient(cc grpc.ClientConnInterface) IdentityManagementClient { + return &identityManagementClient{cc} } -func (c *identityManagementServiceClient) GetGroup(ctx context.Context, in *GetGroupRequest, opts ...grpc.CallOption) (*GetGroupResponse, error) { +func (c *identityManagementClient) GetGroup(ctx context.Context, in *GetGroupRequest, opts ...grpc.CallOption) (*GetGroupResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(GetGroupResponse) - err := c.cc.Invoke(ctx, IdentityManagementService_GetGroup_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, IdentityManagement_GetGroup_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *identityManagementServiceClient) GetAllGroups(ctx context.Context, in *GetAllGroupsRequest, opts ...grpc.CallOption) (*GetAllGroupsResponse, error) { +func (c *identityManagementClient) ListGroups(ctx context.Context, in *ListGroupsRequest, opts ...grpc.CallOption) (*ListGroupsResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetAllGroupsResponse) - err := c.cc.Invoke(ctx, IdentityManagementService_GetAllGroups_FullMethodName, in, out, cOpts...) + out := new(ListGroupsResponse) + err := c.cc.Invoke(ctx, IdentityManagement_ListGroups_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *identityManagementServiceClient) GetUsersForGroup(ctx context.Context, in *GetUsersForGroupRequest, opts ...grpc.CallOption) (*GetUsersForGroupResponse, error) { +func (c *identityManagementClient) ListGroupUsers(ctx context.Context, in *ListGroupUsersRequest, opts ...grpc.CallOption) (*ListGroupUsersResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetUsersForGroupResponse) - err := c.cc.Invoke(ctx, IdentityManagementService_GetUsersForGroup_FullMethodName, in, out, cOpts...) + out := new(ListGroupUsersResponse) + err := c.cc.Invoke(ctx, IdentityManagement_ListGroupUsers_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *identityManagementServiceClient) GetGroupsForUser(ctx context.Context, in *GetGroupsForUserRequest, opts ...grpc.CallOption) (*GetGroupsForUserResponse, error) { +func (c *identityManagementClient) ListUserGroups(ctx context.Context, in *ListUserGroupsRequest, opts ...grpc.CallOption) (*ListUserGroupsResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetGroupsForUserResponse) - err := c.cc.Invoke(ctx, IdentityManagementService_GetGroupsForUser_FullMethodName, in, out, cOpts...) + out := new(ListUserGroupsResponse) + err := c.cc.Invoke(ctx, IdentityManagement_ListUserGroups_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -// IdentityManagementServiceServer is the server API for IdentityManagementService service. -// All implementations must embed UnimplementedIdentityManagementServiceServer +// IdentityManagementServer is the server API for IdentityManagement service. +// All implementations must embed UnimplementedIdentityManagementServer // for forward compatibility. -type IdentityManagementServiceServer interface { +type IdentityManagementServer interface { GetGroup(context.Context, *GetGroupRequest) (*GetGroupResponse, error) - GetAllGroups(context.Context, *GetAllGroupsRequest) (*GetAllGroupsResponse, error) - GetUsersForGroup(context.Context, *GetUsersForGroupRequest) (*GetUsersForGroupResponse, error) - GetGroupsForUser(context.Context, *GetGroupsForUserRequest) (*GetGroupsForUserResponse, error) - mustEmbedUnimplementedIdentityManagementServiceServer() + ListGroups(context.Context, *ListGroupsRequest) (*ListGroupsResponse, error) + ListGroupUsers(context.Context, *ListGroupUsersRequest) (*ListGroupUsersResponse, error) + ListUserGroups(context.Context, *ListUserGroupsRequest) (*ListUserGroupsResponse, error) + mustEmbedUnimplementedIdentityManagementServer() } -// UnimplementedIdentityManagementServiceServer must be embedded to have +// UnimplementedIdentityManagementServer must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedIdentityManagementServiceServer struct{} +type UnimplementedIdentityManagementServer struct{} -func (UnimplementedIdentityManagementServiceServer) GetGroup(context.Context, *GetGroupRequest) (*GetGroupResponse, error) { +func (UnimplementedIdentityManagementServer) GetGroup(context.Context, *GetGroupRequest) (*GetGroupResponse, error) { return nil, status.Error(codes.Unimplemented, "method GetGroup not implemented") } -func (UnimplementedIdentityManagementServiceServer) GetAllGroups(context.Context, *GetAllGroupsRequest) (*GetAllGroupsResponse, error) { - return nil, status.Error(codes.Unimplemented, "method GetAllGroups not implemented") +func (UnimplementedIdentityManagementServer) ListGroups(context.Context, *ListGroupsRequest) (*ListGroupsResponse, error) { + return nil, status.Error(codes.Unimplemented, "method ListGroups not implemented") } -func (UnimplementedIdentityManagementServiceServer) GetUsersForGroup(context.Context, *GetUsersForGroupRequest) (*GetUsersForGroupResponse, error) { - return nil, status.Error(codes.Unimplemented, "method GetUsersForGroup not implemented") +func (UnimplementedIdentityManagementServer) ListGroupUsers(context.Context, *ListGroupUsersRequest) (*ListGroupUsersResponse, error) { + return nil, status.Error(codes.Unimplemented, "method ListGroupUsers not implemented") } -func (UnimplementedIdentityManagementServiceServer) GetGroupsForUser(context.Context, *GetGroupsForUserRequest) (*GetGroupsForUserResponse, error) { - return nil, status.Error(codes.Unimplemented, "method GetGroupsForUser not implemented") +func (UnimplementedIdentityManagementServer) ListUserGroups(context.Context, *ListUserGroupsRequest) (*ListUserGroupsResponse, error) { + return nil, status.Error(codes.Unimplemented, "method ListUserGroups not implemented") } -func (UnimplementedIdentityManagementServiceServer) mustEmbedUnimplementedIdentityManagementServiceServer() { -} -func (UnimplementedIdentityManagementServiceServer) testEmbeddedByValue() {} +func (UnimplementedIdentityManagementServer) mustEmbedUnimplementedIdentityManagementServer() {} +func (UnimplementedIdentityManagementServer) testEmbeddedByValue() {} -// UnsafeIdentityManagementServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to IdentityManagementServiceServer will +// UnsafeIdentityManagementServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to IdentityManagementServer will // result in compilation errors. -type UnsafeIdentityManagementServiceServer interface { - mustEmbedUnimplementedIdentityManagementServiceServer() +type UnsafeIdentityManagementServer interface { + mustEmbedUnimplementedIdentityManagementServer() } -func RegisterIdentityManagementServiceServer(s grpc.ServiceRegistrar, srv IdentityManagementServiceServer) { - // If the following call panics, it indicates UnimplementedIdentityManagementServiceServer was +func RegisterIdentityManagementServer(s grpc.ServiceRegistrar, srv IdentityManagementServer) { + // If the following call panics, it indicates UnimplementedIdentityManagementServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } - s.RegisterService(&IdentityManagementService_ServiceDesc, srv) + s.RegisterService(&IdentityManagement_ServiceDesc, srv) } -func _IdentityManagementService_GetGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _IdentityManagement_GetGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GetGroupRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(IdentityManagementServiceServer).GetGroup(ctx, in) + return srv.(IdentityManagementServer).GetGroup(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: IdentityManagementService_GetGroup_FullMethodName, + FullMethod: IdentityManagement_GetGroup_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(IdentityManagementServiceServer).GetGroup(ctx, req.(*GetGroupRequest)) + return srv.(IdentityManagementServer).GetGroup(ctx, req.(*GetGroupRequest)) } return interceptor(ctx, in, info, handler) } -func _IdentityManagementService_GetAllGroups_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetAllGroupsRequest) +func _IdentityManagement_ListGroups_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListGroupsRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(IdentityManagementServiceServer).GetAllGroups(ctx, in) + return srv.(IdentityManagementServer).ListGroups(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: IdentityManagementService_GetAllGroups_FullMethodName, + FullMethod: IdentityManagement_ListGroups_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(IdentityManagementServiceServer).GetAllGroups(ctx, req.(*GetAllGroupsRequest)) + return srv.(IdentityManagementServer).ListGroups(ctx, req.(*ListGroupsRequest)) } return interceptor(ctx, in, info, handler) } -func _IdentityManagementService_GetUsersForGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetUsersForGroupRequest) +func _IdentityManagement_ListGroupUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListGroupUsersRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(IdentityManagementServiceServer).GetUsersForGroup(ctx, in) + return srv.(IdentityManagementServer).ListGroupUsers(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: IdentityManagementService_GetUsersForGroup_FullMethodName, + FullMethod: IdentityManagement_ListGroupUsers_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(IdentityManagementServiceServer).GetUsersForGroup(ctx, req.(*GetUsersForGroupRequest)) + return srv.(IdentityManagementServer).ListGroupUsers(ctx, req.(*ListGroupUsersRequest)) } return interceptor(ctx, in, info, handler) } -func _IdentityManagementService_GetGroupsForUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetGroupsForUserRequest) +func _IdentityManagement_ListUserGroups_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListUserGroupsRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(IdentityManagementServiceServer).GetGroupsForUser(ctx, in) + return srv.(IdentityManagementServer).ListUserGroups(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: IdentityManagementService_GetGroupsForUser_FullMethodName, + FullMethod: IdentityManagement_ListUserGroups_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(IdentityManagementServiceServer).GetGroupsForUser(ctx, req.(*GetGroupsForUserRequest)) + return srv.(IdentityManagementServer).ListUserGroups(ctx, req.(*ListUserGroupsRequest)) } return interceptor(ctx, in, info, handler) } -// IdentityManagementService_ServiceDesc is the grpc.ServiceDesc for IdentityManagementService service. +// IdentityManagement_ServiceDesc is the grpc.ServiceDesc for IdentityManagement service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) -var IdentityManagementService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "plugin.identity_management.v1.IdentityManagementService", - HandlerType: (*IdentityManagementServiceServer)(nil), +var IdentityManagement_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "plugin.identity_management.v1.IdentityManagement", + HandlerType: (*IdentityManagementServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "GetGroup", - Handler: _IdentityManagementService_GetGroup_Handler, + Handler: _IdentityManagement_GetGroup_Handler, }, { - MethodName: "GetAllGroups", - Handler: _IdentityManagementService_GetAllGroups_Handler, + MethodName: "ListGroups", + Handler: _IdentityManagement_ListGroups_Handler, }, { - MethodName: "GetUsersForGroup", - Handler: _IdentityManagementService_GetUsersForGroup_Handler, + MethodName: "ListGroupUsers", + Handler: _IdentityManagement_ListGroupUsers_Handler, }, { - MethodName: "GetGroupsForUser", - Handler: _IdentityManagementService_GetGroupsForUser_Handler, + MethodName: "ListUserGroups", + Handler: _IdentityManagement_ListUserGroups_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/proto/plugin/keystore/operations/v1/operations.pb.go b/proto/plugin/key_management/v1/key_management.pb.go similarity index 59% rename from proto/plugin/keystore/operations/v1/operations.pb.go rename to proto/plugin/key_management/v1/key_management.pb.go index 2d5f546..7977d66 100644 --- a/proto/plugin/keystore/operations/v1/operations.pb.go +++ b/proto/plugin/key_management/v1/key_management.pb.go @@ -2,9 +2,9 @@ // versions: // protoc-gen-go v1.36.11 // protoc (unknown) -// source: plugin/keystore/operations/v1/operations.proto +// source: plugin/key_management/v1/key_management.proto -package operationsv1 +package key_managementv1 import ( reflect "reflect" @@ -15,7 +15,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" structpb "google.golang.org/protobuf/types/known/structpb" - v1 "github.com/openkcm/plugin-sdk/proto/plugin/keystore/common/v1" + v1 "github.com/openkcm/plugin-sdk/proto/plugin/common/v1" ) const ( @@ -25,29 +25,29 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// KeyAlgorithm defines the supported key algorithms across all operations +// Algorithm defines the supported key algorithms across all operations type KeyAlgorithm int32 const ( - KeyAlgorithm_KEY_ALGORITHM_UNSPECIFIED KeyAlgorithm = 0 - KeyAlgorithm_KEY_ALGORITHM_AES256 KeyAlgorithm = 1 - KeyAlgorithm_KEY_ALGORITHM_RSA3072 KeyAlgorithm = 2 - KeyAlgorithm_KEY_ALGORITHM_RSA4096 KeyAlgorithm = 3 + KeyAlgorithm_KEY_ALGORITHM_UNKNOWN KeyAlgorithm = 0 + KeyAlgorithm_KEY_ALGORITHM_AES256 KeyAlgorithm = 1 + KeyAlgorithm_KEY_ALGORITHM_RSA3072 KeyAlgorithm = 2 + KeyAlgorithm_KEY_ALGORITHM_RSA4096 KeyAlgorithm = 3 ) // Enum value maps for KeyAlgorithm. var ( KeyAlgorithm_name = map[int32]string{ - 0: "KEY_ALGORITHM_UNSPECIFIED", + 0: "KEY_ALGORITHM_UNKNOWN", 1: "KEY_ALGORITHM_AES256", 2: "KEY_ALGORITHM_RSA3072", 3: "KEY_ALGORITHM_RSA4096", } KeyAlgorithm_value = map[string]int32{ - "KEY_ALGORITHM_UNSPECIFIED": 0, - "KEY_ALGORITHM_AES256": 1, - "KEY_ALGORITHM_RSA3072": 2, - "KEY_ALGORITHM_RSA4096": 3, + "KEY_ALGORITHM_UNKNOWN": 0, + "KEY_ALGORITHM_AES256": 1, + "KEY_ALGORITHM_RSA3072": 2, + "KEY_ALGORITHM_RSA4096": 3, } ) @@ -62,11 +62,11 @@ func (x KeyAlgorithm) String() string { } func (KeyAlgorithm) Descriptor() protoreflect.EnumDescriptor { - return file_plugin_keystore_operations_v1_operations_proto_enumTypes[0].Descriptor() + return file_plugin_key_management_v1_key_management_proto_enumTypes[0].Descriptor() } func (KeyAlgorithm) Type() protoreflect.EnumType { - return &file_plugin_keystore_operations_v1_operations_proto_enumTypes[0] + return &file_plugin_key_management_v1_key_management_proto_enumTypes[0] } func (x KeyAlgorithm) Number() protoreflect.EnumNumber { @@ -75,7 +75,7 @@ func (x KeyAlgorithm) Number() protoreflect.EnumNumber { // Deprecated: Use KeyAlgorithm.Descriptor instead. func (KeyAlgorithm) EnumDescriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{0} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{0} } type KeyType int32 @@ -114,11 +114,11 @@ func (x KeyType) String() string { } func (KeyType) Descriptor() protoreflect.EnumDescriptor { - return file_plugin_keystore_operations_v1_operations_proto_enumTypes[1].Descriptor() + return file_plugin_key_management_v1_key_management_proto_enumTypes[1].Descriptor() } func (KeyType) Type() protoreflect.EnumType { - return &file_plugin_keystore_operations_v1_operations_proto_enumTypes[1] + return &file_plugin_key_management_v1_key_management_proto_enumTypes[1] } func (x KeyType) Number() protoreflect.EnumNumber { @@ -127,21 +127,21 @@ func (x KeyType) Number() protoreflect.EnumNumber { // Deprecated: Use KeyType.Descriptor instead. func (KeyType) EnumDescriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{1} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{1} } // RequestParameters contains the common fields needed for most key operations type RequestParameters struct { - state protoimpl.MessageState `protogen:"open.v1"` - Config *v1.KeystoreInstanceConfig `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"` - KeyId string `protobuf:"bytes,2,opt,name=key_id,json=keyId,proto3" json:"key_id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + KeystoreConfig *v1.KeystoreConfig `protobuf:"bytes,1,opt,name=keystore_config,json=keystoreConfig,proto3" json:"keystore_config,omitempty"` + KeyId string `protobuf:"bytes,2,opt,name=key_id,json=keyId,proto3" json:"key_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *RequestParameters) Reset() { *x = RequestParameters{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[0] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -153,7 +153,7 @@ func (x *RequestParameters) String() string { func (*RequestParameters) ProtoMessage() {} func (x *RequestParameters) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[0] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -166,12 +166,12 @@ func (x *RequestParameters) ProtoReflect() protoreflect.Message { // Deprecated: Use RequestParameters.ProtoReflect.Descriptor instead. func (*RequestParameters) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{0} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{0} } -func (x *RequestParameters) GetConfig() *v1.KeystoreInstanceConfig { +func (x *RequestParameters) GetKeystoreConfig() *v1.KeystoreConfig { if x != nil { - return x.Config + return x.KeystoreConfig } return nil } @@ -193,7 +193,7 @@ type GetKeyRequest struct { func (x *GetKeyRequest) Reset() { *x = GetKeyRequest{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[1] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -205,7 +205,7 @@ func (x *GetKeyRequest) String() string { func (*GetKeyRequest) ProtoMessage() {} func (x *GetKeyRequest) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[1] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -218,7 +218,7 @@ func (x *GetKeyRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetKeyRequest.ProtoReflect.Descriptor instead. func (*GetKeyRequest) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{1} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{1} } func (x *GetKeyRequest) GetParameters() *RequestParameters { @@ -230,17 +230,17 @@ func (x *GetKeyRequest) GetParameters() *RequestParameters { type GetKeyResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - KeyId string `protobuf:"bytes,1,opt,name=key_id,json=keyId,proto3" json:"key_id,omitempty"` // The ID of the retrieved key - Algorithm KeyAlgorithm `protobuf:"varint,2,opt,name=algorithm,proto3,enum=plugin.keystore.operations.v1.KeyAlgorithm" json:"algorithm,omitempty"` // The algorithm used for the key - Status string `protobuf:"bytes,3,opt,name=status,proto3" json:"status,omitempty"` // The current status of the key (e.g., enabled, disabled) - Usage string `protobuf:"bytes,4,opt,name=usage,proto3" json:"usage,omitempty"` // The intended usage of the key (e.g., encryption, signing) + KeyId string `protobuf:"bytes,1,opt,name=key_id,json=keyId,proto3" json:"key_id,omitempty"` // The ID of the retrieved key + Algorithm KeyAlgorithm `protobuf:"varint,2,opt,name=algorithm,proto3,enum=plugin.key_management.v1.KeyAlgorithm" json:"algorithm,omitempty"` // The algorithm used for the key + Status string `protobuf:"bytes,3,opt,name=status,proto3" json:"status,omitempty"` // The current status of the key (e.g., enabled, disabled) + Usage string `protobuf:"bytes,4,opt,name=usage,proto3" json:"usage,omitempty"` // The intended usage of the key (e.g., encryption, signing) unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *GetKeyResponse) Reset() { *x = GetKeyResponse{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[2] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -252,7 +252,7 @@ func (x *GetKeyResponse) String() string { func (*GetKeyResponse) ProtoMessage() {} func (x *GetKeyResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[2] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -265,7 +265,7 @@ func (x *GetKeyResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetKeyResponse.ProtoReflect.Descriptor instead. func (*GetKeyResponse) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{2} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{2} } func (x *GetKeyResponse) GetKeyId() string { @@ -279,7 +279,7 @@ func (x *GetKeyResponse) GetAlgorithm() KeyAlgorithm { if x != nil { return x.Algorithm } - return KeyAlgorithm_KEY_ALGORITHM_UNSPECIFIED + return KeyAlgorithm_KEY_ALGORITHM_UNKNOWN } func (x *GetKeyResponse) GetStatus() string { @@ -298,19 +298,19 @@ func (x *GetKeyResponse) GetUsage() string { // CreateKeyRequest contains parameters for key creation type CreateKeyRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Config *v1.KeystoreInstanceConfig `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"` - Algorithm KeyAlgorithm `protobuf:"varint,2,opt,name=algorithm,proto3,enum=plugin.keystore.operations.v1.KeyAlgorithm" json:"algorithm,omitempty"` - Id *string `protobuf:"bytes,3,opt,name=id,proto3,oneof" json:"id,omitempty"` // Optional predefined key ID - Region string `protobuf:"bytes,4,opt,name=region,proto3" json:"region,omitempty"` // The region in which to create the key - KeyType KeyType `protobuf:"varint,5,opt,name=key_type,json=keyType,proto3,enum=plugin.keystore.operations.v1.KeyType" json:"key_type,omitempty"` // Key type (system-managed or BYOK) - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + KeystoreConfig *v1.KeystoreConfig `protobuf:"bytes,1,opt,name=keystore_config,json=keystoreConfig,proto3" json:"keystore_config,omitempty"` + Algorithm KeyAlgorithm `protobuf:"varint,2,opt,name=algorithm,proto3,enum=plugin.key_management.v1.KeyAlgorithm" json:"algorithm,omitempty"` + Id *string `protobuf:"bytes,3,opt,name=id,proto3,oneof" json:"id,omitempty"` // Optional predefined key ID + Region string `protobuf:"bytes,4,opt,name=region,proto3" json:"region,omitempty"` // The region in which to create the key + KeyType KeyType `protobuf:"varint,5,opt,name=key_type,json=keyType,proto3,enum=plugin.key_management.v1.KeyType" json:"key_type,omitempty"` // Key type (system-managed or BYOK) + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *CreateKeyRequest) Reset() { *x = CreateKeyRequest{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[3] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -322,7 +322,7 @@ func (x *CreateKeyRequest) String() string { func (*CreateKeyRequest) ProtoMessage() {} func (x *CreateKeyRequest) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[3] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -335,12 +335,12 @@ func (x *CreateKeyRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateKeyRequest.ProtoReflect.Descriptor instead. func (*CreateKeyRequest) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{3} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{3} } -func (x *CreateKeyRequest) GetConfig() *v1.KeystoreInstanceConfig { +func (x *CreateKeyRequest) GetKeystoreConfig() *v1.KeystoreConfig { if x != nil { - return x.Config + return x.KeystoreConfig } return nil } @@ -349,7 +349,7 @@ func (x *CreateKeyRequest) GetAlgorithm() KeyAlgorithm { if x != nil { return x.Algorithm } - return KeyAlgorithm_KEY_ALGORITHM_UNSPECIFIED + return KeyAlgorithm_KEY_ALGORITHM_UNKNOWN } func (x *CreateKeyRequest) GetId() string { @@ -383,7 +383,7 @@ type CreateKeyResponse struct { func (x *CreateKeyResponse) Reset() { *x = CreateKeyResponse{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[4] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -395,7 +395,7 @@ func (x *CreateKeyResponse) String() string { func (*CreateKeyResponse) ProtoMessage() {} func (x *CreateKeyResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[4] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -408,7 +408,7 @@ func (x *CreateKeyResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateKeyResponse.ProtoReflect.Descriptor instead. func (*CreateKeyResponse) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{4} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{4} } func (x *CreateKeyResponse) GetKeyId() string { @@ -436,7 +436,7 @@ type DeleteKeyRequest struct { func (x *DeleteKeyRequest) Reset() { *x = DeleteKeyRequest{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[5] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -448,7 +448,7 @@ func (x *DeleteKeyRequest) String() string { func (*DeleteKeyRequest) ProtoMessage() {} func (x *DeleteKeyRequest) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[5] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -461,7 +461,7 @@ func (x *DeleteKeyRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteKeyRequest.ProtoReflect.Descriptor instead. func (*DeleteKeyRequest) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{5} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{5} } func (x *DeleteKeyRequest) GetParameters() *RequestParameters { @@ -486,7 +486,7 @@ type DeleteKeyResponse struct { func (x *DeleteKeyResponse) Reset() { *x = DeleteKeyResponse{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[6] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -498,7 +498,7 @@ func (x *DeleteKeyResponse) String() string { func (*DeleteKeyResponse) ProtoMessage() {} func (x *DeleteKeyResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[6] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -511,7 +511,7 @@ func (x *DeleteKeyResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteKeyResponse.ProtoReflect.Descriptor instead. func (*DeleteKeyResponse) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{6} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{6} } // EnableKeyRequest contains parameters for key enablement @@ -524,7 +524,7 @@ type EnableKeyRequest struct { func (x *EnableKeyRequest) Reset() { *x = EnableKeyRequest{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[7] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -536,7 +536,7 @@ func (x *EnableKeyRequest) String() string { func (*EnableKeyRequest) ProtoMessage() {} func (x *EnableKeyRequest) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[7] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -549,7 +549,7 @@ func (x *EnableKeyRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use EnableKeyRequest.ProtoReflect.Descriptor instead. func (*EnableKeyRequest) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{7} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{7} } func (x *EnableKeyRequest) GetParameters() *RequestParameters { @@ -567,7 +567,7 @@ type EnableKeyResponse struct { func (x *EnableKeyResponse) Reset() { *x = EnableKeyResponse{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[8] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -579,7 +579,7 @@ func (x *EnableKeyResponse) String() string { func (*EnableKeyResponse) ProtoMessage() {} func (x *EnableKeyResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[8] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -592,7 +592,7 @@ func (x *EnableKeyResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use EnableKeyResponse.ProtoReflect.Descriptor instead. func (*EnableKeyResponse) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{8} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{8} } // DisableKeyRequest contains parameters for key disablement @@ -605,7 +605,7 @@ type DisableKeyRequest struct { func (x *DisableKeyRequest) Reset() { *x = DisableKeyRequest{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[9] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -617,7 +617,7 @@ func (x *DisableKeyRequest) String() string { func (*DisableKeyRequest) ProtoMessage() {} func (x *DisableKeyRequest) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[9] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -630,7 +630,7 @@ func (x *DisableKeyRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DisableKeyRequest.ProtoReflect.Descriptor instead. func (*DisableKeyRequest) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{9} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{9} } func (x *DisableKeyRequest) GetParameters() *RequestParameters { @@ -648,7 +648,7 @@ type DisableKeyResponse struct { func (x *DisableKeyResponse) Reset() { *x = DisableKeyResponse{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[10] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -660,7 +660,7 @@ func (x *DisableKeyResponse) String() string { func (*DisableKeyResponse) ProtoMessage() {} func (x *DisableKeyResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[10] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -673,21 +673,21 @@ func (x *DisableKeyResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use DisableKeyResponse.ProtoReflect.Descriptor instead. func (*DisableKeyResponse) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{10} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{10} } // GetImportParametersRequest contains parameters for retrieving import parameters type GetImportParametersRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Parameters *RequestParameters `protobuf:"bytes,1,opt,name=parameters,proto3" json:"parameters,omitempty"` - Algorithm KeyAlgorithm `protobuf:"varint,2,opt,name=algorithm,proto3,enum=plugin.keystore.operations.v1.KeyAlgorithm" json:"algorithm,omitempty"` + Algorithm KeyAlgorithm `protobuf:"varint,2,opt,name=algorithm,proto3,enum=plugin.key_management.v1.KeyAlgorithm" json:"algorithm,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *GetImportParametersRequest) Reset() { *x = GetImportParametersRequest{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[11] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -699,7 +699,7 @@ func (x *GetImportParametersRequest) String() string { func (*GetImportParametersRequest) ProtoMessage() {} func (x *GetImportParametersRequest) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[11] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -712,7 +712,7 @@ func (x *GetImportParametersRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetImportParametersRequest.ProtoReflect.Descriptor instead. func (*GetImportParametersRequest) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{11} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{11} } func (x *GetImportParametersRequest) GetParameters() *RequestParameters { @@ -726,7 +726,7 @@ func (x *GetImportParametersRequest) GetAlgorithm() KeyAlgorithm { if x != nil { return x.Algorithm } - return KeyAlgorithm_KEY_ALGORITHM_UNSPECIFIED + return KeyAlgorithm_KEY_ALGORITHM_UNKNOWN } // ImportKeyMaterialRequest contains parameters for importing key material @@ -740,7 +740,7 @@ type GetImportParametersResponse struct { func (x *GetImportParametersResponse) Reset() { *x = GetImportParametersResponse{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[12] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -752,7 +752,7 @@ func (x *GetImportParametersResponse) String() string { func (*GetImportParametersResponse) ProtoMessage() {} func (x *GetImportParametersResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[12] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -765,7 +765,7 @@ func (x *GetImportParametersResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetImportParametersResponse.ProtoReflect.Descriptor instead. func (*GetImportParametersResponse) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{12} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{12} } func (x *GetImportParametersResponse) GetKeyId() string { @@ -794,7 +794,7 @@ type ImportKeyMaterialRequest struct { func (x *ImportKeyMaterialRequest) Reset() { *x = ImportKeyMaterialRequest{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[13] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -806,7 +806,7 @@ func (x *ImportKeyMaterialRequest) String() string { func (*ImportKeyMaterialRequest) ProtoMessage() {} func (x *ImportKeyMaterialRequest) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[13] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -819,7 +819,7 @@ func (x *ImportKeyMaterialRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ImportKeyMaterialRequest.ProtoReflect.Descriptor instead. func (*ImportKeyMaterialRequest) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{13} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{13} } func (x *ImportKeyMaterialRequest) GetParameters() *RequestParameters { @@ -852,7 +852,7 @@ type ImportKeyMaterialResponse struct { func (x *ImportKeyMaterialResponse) Reset() { *x = ImportKeyMaterialResponse{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[14] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -864,7 +864,7 @@ func (x *ImportKeyMaterialResponse) String() string { func (*ImportKeyMaterialResponse) ProtoMessage() {} func (x *ImportKeyMaterialResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[14] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -877,14 +877,14 @@ func (x *ImportKeyMaterialResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ImportKeyMaterialResponse.ProtoReflect.Descriptor instead. func (*ImportKeyMaterialResponse) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{14} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{14} } // ValidateKeyRequest contains parameters for validating key attributes type ValidateKeyRequest struct { state protoimpl.MessageState `protogen:"open.v1"` - KeyType KeyType `protobuf:"varint,1,opt,name=key_type,json=keyType,proto3,enum=plugin.keystore.operations.v1.KeyType" json:"key_type,omitempty"` - Algorithm KeyAlgorithm `protobuf:"varint,2,opt,name=algorithm,proto3,enum=plugin.keystore.operations.v1.KeyAlgorithm" json:"algorithm,omitempty"` + KeyType KeyType `protobuf:"varint,1,opt,name=key_type,json=keyType,proto3,enum=plugin.key_management.v1.KeyType" json:"key_type,omitempty"` + Algorithm KeyAlgorithm `protobuf:"varint,2,opt,name=algorithm,proto3,enum=plugin.key_management.v1.KeyAlgorithm" json:"algorithm,omitempty"` Region string `protobuf:"bytes,3,opt,name=region,proto3" json:"region,omitempty"` // The region in which the key is to be validated NativeKeyId string `protobuf:"bytes,4,opt,name=native_key_id,json=nativeKeyId,proto3" json:"native_key_id,omitempty"` // The native key ID if applicable unknownFields protoimpl.UnknownFields @@ -893,7 +893,7 @@ type ValidateKeyRequest struct { func (x *ValidateKeyRequest) Reset() { *x = ValidateKeyRequest{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[15] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -905,7 +905,7 @@ func (x *ValidateKeyRequest) String() string { func (*ValidateKeyRequest) ProtoMessage() {} func (x *ValidateKeyRequest) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[15] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -918,7 +918,7 @@ func (x *ValidateKeyRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ValidateKeyRequest.ProtoReflect.Descriptor instead. func (*ValidateKeyRequest) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{15} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{15} } func (x *ValidateKeyRequest) GetKeyType() KeyType { @@ -932,7 +932,7 @@ func (x *ValidateKeyRequest) GetAlgorithm() KeyAlgorithm { if x != nil { return x.Algorithm } - return KeyAlgorithm_KEY_ALGORITHM_UNSPECIFIED + return KeyAlgorithm_KEY_ALGORITHM_UNKNOWN } func (x *ValidateKeyRequest) GetRegion() string { @@ -960,7 +960,7 @@ type ValidateKeyResponse struct { func (x *ValidateKeyResponse) Reset() { *x = ValidateKeyResponse{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[16] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -972,7 +972,7 @@ func (x *ValidateKeyResponse) String() string { func (*ValidateKeyResponse) ProtoMessage() {} func (x *ValidateKeyResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[16] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -985,7 +985,7 @@ func (x *ValidateKeyResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ValidateKeyResponse.ProtoReflect.Descriptor instead. func (*ValidateKeyResponse) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{16} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{16} } func (x *ValidateKeyResponse) GetIsValid() bool { @@ -1013,7 +1013,7 @@ type ValidateKeyAccessDataRequest struct { func (x *ValidateKeyAccessDataRequest) Reset() { *x = ValidateKeyAccessDataRequest{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[17] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1025,7 +1025,7 @@ func (x *ValidateKeyAccessDataRequest) String() string { func (*ValidateKeyAccessDataRequest) ProtoMessage() {} func (x *ValidateKeyAccessDataRequest) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[17] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1038,7 +1038,7 @@ func (x *ValidateKeyAccessDataRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ValidateKeyAccessDataRequest.ProtoReflect.Descriptor instead. func (*ValidateKeyAccessDataRequest) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{17} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{17} } func (x *ValidateKeyAccessDataRequest) GetManagement() *structpb.Struct { @@ -1066,7 +1066,7 @@ type ValidateKeyAccessDataResponse struct { func (x *ValidateKeyAccessDataResponse) Reset() { *x = ValidateKeyAccessDataResponse{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[18] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1078,7 +1078,7 @@ func (x *ValidateKeyAccessDataResponse) String() string { func (*ValidateKeyAccessDataResponse) ProtoMessage() {} func (x *ValidateKeyAccessDataResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[18] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1091,7 +1091,7 @@ func (x *ValidateKeyAccessDataResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ValidateKeyAccessDataResponse.ProtoReflect.Descriptor instead. func (*ValidateKeyAccessDataResponse) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{18} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{18} } func (x *ValidateKeyAccessDataResponse) GetIsValid() bool { @@ -1119,7 +1119,7 @@ type TransformCryptoAccessDataRequest struct { func (x *TransformCryptoAccessDataRequest) Reset() { *x = TransformCryptoAccessDataRequest{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[19] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1131,7 +1131,7 @@ func (x *TransformCryptoAccessDataRequest) String() string { func (*TransformCryptoAccessDataRequest) ProtoMessage() {} func (x *TransformCryptoAccessDataRequest) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[19] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1144,7 +1144,7 @@ func (x *TransformCryptoAccessDataRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use TransformCryptoAccessDataRequest.ProtoReflect.Descriptor instead. func (*TransformCryptoAccessDataRequest) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{19} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{19} } func (x *TransformCryptoAccessDataRequest) GetNativeKeyId() string { @@ -1171,7 +1171,7 @@ type TransformCryptoAccessDataResponse struct { func (x *TransformCryptoAccessDataResponse) Reset() { *x = TransformCryptoAccessDataResponse{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[20] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1183,7 +1183,7 @@ func (x *TransformCryptoAccessDataResponse) String() string { func (*TransformCryptoAccessDataResponse) ProtoMessage() {} func (x *TransformCryptoAccessDataResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[20] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[20] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1196,7 +1196,7 @@ func (x *TransformCryptoAccessDataResponse) ProtoReflect() protoreflect.Message // Deprecated: Use TransformCryptoAccessDataResponse.ProtoReflect.Descriptor instead. func (*TransformCryptoAccessDataResponse) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{20} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{20} } func (x *TransformCryptoAccessDataResponse) GetTransformedAccessData() map[string][]byte { @@ -1217,7 +1217,7 @@ type ExtractKeyRegionRequest struct { func (x *ExtractKeyRegionRequest) Reset() { *x = ExtractKeyRegionRequest{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[21] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1229,7 +1229,7 @@ func (x *ExtractKeyRegionRequest) String() string { func (*ExtractKeyRegionRequest) ProtoMessage() {} func (x *ExtractKeyRegionRequest) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[21] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[21] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1242,7 +1242,7 @@ func (x *ExtractKeyRegionRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ExtractKeyRegionRequest.ProtoReflect.Descriptor instead. func (*ExtractKeyRegionRequest) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{21} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{21} } func (x *ExtractKeyRegionRequest) GetNativeKeyId() string { @@ -1269,7 +1269,7 @@ type ExtractKeyRegionResponse struct { func (x *ExtractKeyRegionResponse) Reset() { *x = ExtractKeyRegionResponse{} - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[22] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1281,7 +1281,7 @@ func (x *ExtractKeyRegionResponse) String() string { func (*ExtractKeyRegionResponse) ProtoMessage() {} func (x *ExtractKeyRegionResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_operations_v1_operations_proto_msgTypes[22] + mi := &file_plugin_key_management_v1_key_management_proto_msgTypes[22] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1294,7 +1294,7 @@ func (x *ExtractKeyRegionResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ExtractKeyRegionResponse.ProtoReflect.Descriptor instead. func (*ExtractKeyRegionResponse) Descriptor() ([]byte, []int) { - return file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP(), []int{22} + return file_plugin_key_management_v1_key_management_proto_rawDescGZIP(), []int{22} } func (x *ExtractKeyRegionResponse) GetRegion() string { @@ -1304,68 +1304,68 @@ func (x *ExtractKeyRegionResponse) GetRegion() string { return "" } -var File_plugin_keystore_operations_v1_operations_proto protoreflect.FileDescriptor +var File_plugin_key_management_v1_key_management_proto protoreflect.FileDescriptor -const file_plugin_keystore_operations_v1_operations_proto_rawDesc = "" + +const file_plugin_key_management_v1_key_management_proto_rawDesc = "" + "\n" + - ".plugin/keystore/operations/v1/operations.proto\x12\x1dplugin.keystore.operations.v1\x1a\x1cgoogle/protobuf/struct.proto\x1a&plugin/keystore/common/v1/common.proto\"u\n" + + "-plugin/key_management/v1/key_management.proto\x12\x18plugin.key_management.v1\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1dplugin/common/v1/common.proto\"u\n" + "\x11RequestParameters\x12I\n" + - "\x06config\x18\x01 \x01(\v21.plugin.keystore.common.v1.KeystoreInstanceConfigR\x06config\x12\x15\n" + - "\x06key_id\x18\x02 \x01(\tR\x05keyId\"a\n" + - "\rGetKeyRequest\x12P\n" + + "\x0fkeystore_config\x18\x01 \x01(\v2 .plugin.common.v1.KeystoreConfigR\x0ekeystoreConfig\x12\x15\n" + + "\x06key_id\x18\x02 \x01(\tR\x05keyId\"\\\n" + + "\rGetKeyRequest\x12K\n" + "\n" + - "parameters\x18\x01 \x01(\v20.plugin.keystore.operations.v1.RequestParametersR\n" + - "parameters\"\xa0\x01\n" + + "parameters\x18\x01 \x01(\v2+.plugin.key_management.v1.RequestParametersR\n" + + "parameters\"\x9b\x01\n" + "\x0eGetKeyResponse\x12\x15\n" + - "\x06key_id\x18\x01 \x01(\tR\x05keyId\x12I\n" + - "\talgorithm\x18\x02 \x01(\x0e2+.plugin.keystore.operations.v1.KeyAlgorithmR\talgorithm\x12\x16\n" + + "\x06key_id\x18\x01 \x01(\tR\x05keyId\x12D\n" + + "\talgorithm\x18\x02 \x01(\x0e2&.plugin.key_management.v1.KeyAlgorithmR\talgorithm\x12\x16\n" + "\x06status\x18\x03 \x01(\tR\x06status\x12\x14\n" + - "\x05usage\x18\x04 \x01(\tR\x05usage\"\x9f\x02\n" + + "\x05usage\x18\x04 \x01(\tR\x05usage\"\x95\x02\n" + "\x10CreateKeyRequest\x12I\n" + - "\x06config\x18\x01 \x01(\v21.plugin.keystore.common.v1.KeystoreInstanceConfigR\x06config\x12I\n" + - "\talgorithm\x18\x02 \x01(\x0e2+.plugin.keystore.operations.v1.KeyAlgorithmR\talgorithm\x12\x13\n" + + "\x0fkeystore_config\x18\x01 \x01(\v2 .plugin.common.v1.KeystoreConfigR\x0ekeystoreConfig\x12D\n" + + "\talgorithm\x18\x02 \x01(\x0e2&.plugin.key_management.v1.KeyAlgorithmR\talgorithm\x12\x13\n" + "\x02id\x18\x03 \x01(\tH\x00R\x02id\x88\x01\x01\x12\x16\n" + - "\x06region\x18\x04 \x01(\tR\x06region\x12A\n" + - "\bkey_type\x18\x05 \x01(\x0e2&.plugin.keystore.operations.v1.KeyTypeR\akeyTypeB\x05\n" + + "\x06region\x18\x04 \x01(\tR\x06region\x12<\n" + + "\bkey_type\x18\x05 \x01(\x0e2!.plugin.key_management.v1.KeyTypeR\akeyTypeB\x05\n" + "\x03_id\"B\n" + "\x11CreateKeyResponse\x12\x15\n" + "\x06key_id\x18\x01 \x01(\tR\x05keyId\x12\x16\n" + - "\x06status\x18\x02 \x01(\tR\x06status\"\x8c\x01\n" + - "\x10DeleteKeyRequest\x12P\n" + + "\x06status\x18\x02 \x01(\tR\x06status\"\x87\x01\n" + + "\x10DeleteKeyRequest\x12K\n" + "\n" + - "parameters\x18\x01 \x01(\v20.plugin.keystore.operations.v1.RequestParametersR\n" + + "parameters\x18\x01 \x01(\v2+.plugin.key_management.v1.RequestParametersR\n" + "parameters\x12\x1b\n" + "\x06window\x18\x02 \x01(\x05H\x00R\x06window\x88\x01\x01B\t\n" + "\a_window\"\x13\n" + - "\x11DeleteKeyResponse\"d\n" + - "\x10EnableKeyRequest\x12P\n" + + "\x11DeleteKeyResponse\"_\n" + + "\x10EnableKeyRequest\x12K\n" + "\n" + - "parameters\x18\x01 \x01(\v20.plugin.keystore.operations.v1.RequestParametersR\n" + + "parameters\x18\x01 \x01(\v2+.plugin.key_management.v1.RequestParametersR\n" + "parameters\"\x13\n" + - "\x11EnableKeyResponse\"e\n" + - "\x11DisableKeyRequest\x12P\n" + + "\x11EnableKeyResponse\"`\n" + + "\x11DisableKeyRequest\x12K\n" + "\n" + - "parameters\x18\x01 \x01(\v20.plugin.keystore.operations.v1.RequestParametersR\n" + + "parameters\x18\x01 \x01(\v2+.plugin.key_management.v1.RequestParametersR\n" + "parameters\"\x14\n" + - "\x12DisableKeyResponse\"\xb9\x01\n" + - "\x1aGetImportParametersRequest\x12P\n" + + "\x12DisableKeyResponse\"\xaf\x01\n" + + "\x1aGetImportParametersRequest\x12K\n" + "\n" + - "parameters\x18\x01 \x01(\v20.plugin.keystore.operations.v1.RequestParametersR\n" + - "parameters\x12I\n" + - "\talgorithm\x18\x02 \x01(\x0e2+.plugin.keystore.operations.v1.KeyAlgorithmR\talgorithm\"z\n" + + "parameters\x18\x01 \x01(\v2+.plugin.key_management.v1.RequestParametersR\n" + + "parameters\x12D\n" + + "\talgorithm\x18\x02 \x01(\x0e2&.plugin.key_management.v1.KeyAlgorithmR\talgorithm\"z\n" + "\x1bGetImportParametersResponse\x12\x15\n" + "\x06key_id\x18\x01 \x01(\tR\x05keyId\x12D\n" + - "\x11import_parameters\x18\x02 \x01(\v2\x17.google.protobuf.StructR\x10importParameters\"\xe8\x01\n" + - "\x18ImportKeyMaterialRequest\x12P\n" + + "\x11import_parameters\x18\x02 \x01(\v2\x17.google.protobuf.StructR\x10importParameters\"\xe3\x01\n" + + "\x18ImportKeyMaterialRequest\x12K\n" + "\n" + - "parameters\x18\x01 \x01(\v20.plugin.keystore.operations.v1.RequestParametersR\n" + + "parameters\x18\x01 \x01(\v2+.plugin.key_management.v1.RequestParametersR\n" + "parameters\x12D\n" + "\x11import_parameters\x18\x02 \x01(\v2\x17.google.protobuf.StructR\x10importParameters\x124\n" + "\x16encrypted_key_material\x18\x03 \x01(\tR\x14encryptedKeyMaterial\"\x1b\n" + - "\x19ImportKeyMaterialResponse\"\xde\x01\n" + - "\x12ValidateKeyRequest\x12A\n" + - "\bkey_type\x18\x01 \x01(\x0e2&.plugin.keystore.operations.v1.KeyTypeR\akeyType\x12I\n" + - "\talgorithm\x18\x02 \x01(\x0e2+.plugin.keystore.operations.v1.KeyAlgorithmR\talgorithm\x12\x16\n" + + "\x19ImportKeyMaterialResponse\"\xd4\x01\n" + + "\x12ValidateKeyRequest\x12<\n" + + "\bkey_type\x18\x01 \x01(\x0e2!.plugin.key_management.v1.KeyTypeR\akeyType\x12D\n" + + "\talgorithm\x18\x02 \x01(\x0e2&.plugin.key_management.v1.KeyAlgorithmR\talgorithm\x12\x16\n" + "\x06region\x18\x03 \x01(\tR\x06region\x12\"\n" + "\rnative_key_id\x18\x04 \x01(\tR\vnativeKeyId\"J\n" + "\x13ValidateKeyResponse\x12\x19\n" + @@ -1382,9 +1382,9 @@ const file_plugin_keystore_operations_v1_operations_proto_rawDesc = "" + " TransformCryptoAccessDataRequest\x12\"\n" + "\rnative_key_id\x18\x01 \x01(\tR\vnativeKeyId\x12\x1f\n" + "\vaccess_data\x18\x02 \x01(\fR\n" + - "accessData\"\x83\x02\n" + - "!TransformCryptoAccessDataResponse\x12\x93\x01\n" + - "\x17transformed_access_data\x18\x01 \x03(\v2[.plugin.keystore.operations.v1.TransformCryptoAccessDataResponse.TransformedAccessDataEntryR\x15transformedAccessData\x1aH\n" + + "accessData\"\xfe\x01\n" + + "!TransformCryptoAccessDataResponse\x12\x8e\x01\n" + + "\x17transformed_access_data\x18\x01 \x03(\v2V.plugin.key_management.v1.TransformCryptoAccessDataResponse.TransformedAccessDataEntryR\x15transformedAccessData\x1aH\n" + "\x1aTransformedAccessDataEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\fR\x05value:\x028\x01\"\x8c\x01\n" + @@ -1392,9 +1392,9 @@ const file_plugin_keystore_operations_v1_operations_proto_rawDesc = "" + "\rnative_key_id\x18\x01 \x01(\tR\vnativeKeyId\x12M\n" + "\x16management_access_data\x18\x02 \x01(\v2\x17.google.protobuf.StructR\x14managementAccessData\"2\n" + "\x18ExtractKeyRegionResponse\x12\x16\n" + - "\x06region\x18\x01 \x01(\tR\x06region*}\n" + - "\fKeyAlgorithm\x12\x1d\n" + - "\x19KEY_ALGORITHM_UNSPECIFIED\x10\x00\x12\x18\n" + + "\x06region\x18\x01 \x01(\tR\x06region*y\n" + + "\fKeyAlgorithm\x12\x19\n" + + "\x15KEY_ALGORITHM_UNKNOWN\x10\x00\x12\x18\n" + "\x14KEY_ALGORITHM_AES256\x10\x01\x12\x19\n" + "\x15KEY_ALGORITHM_RSA3072\x10\x02\x12\x19\n" + "\x15KEY_ALGORITHM_RSA4096\x10\x03*f\n" + @@ -1402,109 +1402,110 @@ const file_plugin_keystore_operations_v1_operations_proto_rawDesc = "" + "\x14KEY_TYPE_UNSPECIFIED\x10\x00\x12\x1b\n" + "\x17KEY_TYPE_SYSTEM_MANAGED\x10\x01\x12\x11\n" + "\rKEY_TYPE_BYOK\x10\x02\x12\x11\n" + - "\rKEY_TYPE_HYOK\x10\x032\x92\v\n" + - "\x1cKeystoreInstanceKeyOperation\x12e\n" + - "\x06GetKey\x12,.plugin.keystore.operations.v1.GetKeyRequest\x1a-.plugin.keystore.operations.v1.GetKeyResponse\x12n\n" + - "\tCreateKey\x12/.plugin.keystore.operations.v1.CreateKeyRequest\x1a0.plugin.keystore.operations.v1.CreateKeyResponse\x12n\n" + - "\tDeleteKey\x12/.plugin.keystore.operations.v1.DeleteKeyRequest\x1a0.plugin.keystore.operations.v1.DeleteKeyResponse\x12n\n" + - "\tEnableKey\x12/.plugin.keystore.operations.v1.EnableKeyRequest\x1a0.plugin.keystore.operations.v1.EnableKeyResponse\x12q\n" + + "\rKEY_TYPE_HYOK\x10\x032\x93\n" + + "\n" + + "\rKeyManagement\x12[\n" + + "\x06GetKey\x12'.plugin.key_management.v1.GetKeyRequest\x1a(.plugin.key_management.v1.GetKeyResponse\x12d\n" + + "\tCreateKey\x12*.plugin.key_management.v1.CreateKeyRequest\x1a+.plugin.key_management.v1.CreateKeyResponse\x12d\n" + + "\tDeleteKey\x12*.plugin.key_management.v1.DeleteKeyRequest\x1a+.plugin.key_management.v1.DeleteKeyResponse\x12d\n" + + "\tEnableKey\x12*.plugin.key_management.v1.EnableKeyRequest\x1a+.plugin.key_management.v1.EnableKeyResponse\x12g\n" + "\n" + - "DisableKey\x120.plugin.keystore.operations.v1.DisableKeyRequest\x1a1.plugin.keystore.operations.v1.DisableKeyResponse\x12\x8c\x01\n" + - "\x13GetImportParameters\x129.plugin.keystore.operations.v1.GetImportParametersRequest\x1a:.plugin.keystore.operations.v1.GetImportParametersResponse\x12\x86\x01\n" + - "\x11ImportKeyMaterial\x127.plugin.keystore.operations.v1.ImportKeyMaterialRequest\x1a8.plugin.keystore.operations.v1.ImportKeyMaterialResponse\x12t\n" + - "\vValidateKey\x121.plugin.keystore.operations.v1.ValidateKeyRequest\x1a2.plugin.keystore.operations.v1.ValidateKeyResponse\x12\x92\x01\n" + - "\x15ValidateKeyAccessData\x12;.plugin.keystore.operations.v1.ValidateKeyAccessDataRequest\x1a<.plugin.keystore.operations.v1.ValidateKeyAccessDataResponse\x12\x9e\x01\n" + - "\x19TransformCryptoAccessData\x12?.plugin.keystore.operations.v1.TransformCryptoAccessDataRequest\x1a@.plugin.keystore.operations.v1.TransformCryptoAccessDataResponse\x12\x83\x01\n" + - "\x10ExtractKeyRegion\x126.plugin.keystore.operations.v1.ExtractKeyRegionRequest\x1a7.plugin.keystore.operations.v1.ExtractKeyRegionResponseB\x9b\x02\n" + - "!com.plugin.keystore.operations.v1B\x0fOperationsProtoP\x01ZNgithub.com/openkcm/plugin-sdk/proto/plugin/keystore/operations/v1;operationsv1\xa2\x02\x03PKO\xaa\x02\x1dPlugin.Keystore.Operations.V1\xca\x02\x1dPlugin\\Keystore\\Operations\\V1\xe2\x02)Plugin\\Keystore\\Operations\\V1\\GPBMetadata\xea\x02 Plugin::Keystore::Operations::V1b\x06proto3" + "DisableKey\x12+.plugin.key_management.v1.DisableKeyRequest\x1a,.plugin.key_management.v1.DisableKeyResponse\x12\x82\x01\n" + + "\x13GetImportParameters\x124.plugin.key_management.v1.GetImportParametersRequest\x1a5.plugin.key_management.v1.GetImportParametersResponse\x12|\n" + + "\x11ImportKeyMaterial\x122.plugin.key_management.v1.ImportKeyMaterialRequest\x1a3.plugin.key_management.v1.ImportKeyMaterialResponse\x12j\n" + + "\vValidateKey\x12,.plugin.key_management.v1.ValidateKeyRequest\x1a-.plugin.key_management.v1.ValidateKeyResponse\x12\x88\x01\n" + + "\x15ValidateKeyAccessData\x126.plugin.key_management.v1.ValidateKeyAccessDataRequest\x1a7.plugin.key_management.v1.ValidateKeyAccessDataResponse\x12\x94\x01\n" + + "\x19TransformCryptoAccessData\x12:.plugin.key_management.v1.TransformCryptoAccessDataRequest\x1a;.plugin.key_management.v1.TransformCryptoAccessDataResponse\x12y\n" + + "\x10ExtractKeyRegion\x121.plugin.key_management.v1.ExtractKeyRegionRequest\x1a2.plugin.key_management.v1.ExtractKeyRegionResponseB\xff\x01\n" + + "\x1ccom.plugin.key_management.v1B\x12KeyManagementProtoP\x01ZMgithub.com/openkcm/plugin-sdk/proto/plugin/key_management/v1;key_managementv1\xa2\x02\x03PKX\xaa\x02\x17Plugin.KeyManagement.V1\xca\x02\x17Plugin\\KeyManagement\\V1\xe2\x02#Plugin\\KeyManagement\\V1\\GPBMetadata\xea\x02\x19Plugin::KeyManagement::V1b\x06proto3" var ( - file_plugin_keystore_operations_v1_operations_proto_rawDescOnce sync.Once - file_plugin_keystore_operations_v1_operations_proto_rawDescData []byte + file_plugin_key_management_v1_key_management_proto_rawDescOnce sync.Once + file_plugin_key_management_v1_key_management_proto_rawDescData []byte ) -func file_plugin_keystore_operations_v1_operations_proto_rawDescGZIP() []byte { - file_plugin_keystore_operations_v1_operations_proto_rawDescOnce.Do(func() { - file_plugin_keystore_operations_v1_operations_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_plugin_keystore_operations_v1_operations_proto_rawDesc), len(file_plugin_keystore_operations_v1_operations_proto_rawDesc))) +func file_plugin_key_management_v1_key_management_proto_rawDescGZIP() []byte { + file_plugin_key_management_v1_key_management_proto_rawDescOnce.Do(func() { + file_plugin_key_management_v1_key_management_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_plugin_key_management_v1_key_management_proto_rawDesc), len(file_plugin_key_management_v1_key_management_proto_rawDesc))) }) - return file_plugin_keystore_operations_v1_operations_proto_rawDescData -} - -var file_plugin_keystore_operations_v1_operations_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_plugin_keystore_operations_v1_operations_proto_msgTypes = make([]protoimpl.MessageInfo, 24) -var file_plugin_keystore_operations_v1_operations_proto_goTypes = []any{ - (KeyAlgorithm)(0), // 0: plugin.keystore.operations.v1.KeyAlgorithm - (KeyType)(0), // 1: plugin.keystore.operations.v1.KeyType - (*RequestParameters)(nil), // 2: plugin.keystore.operations.v1.RequestParameters - (*GetKeyRequest)(nil), // 3: plugin.keystore.operations.v1.GetKeyRequest - (*GetKeyResponse)(nil), // 4: plugin.keystore.operations.v1.GetKeyResponse - (*CreateKeyRequest)(nil), // 5: plugin.keystore.operations.v1.CreateKeyRequest - (*CreateKeyResponse)(nil), // 6: plugin.keystore.operations.v1.CreateKeyResponse - (*DeleteKeyRequest)(nil), // 7: plugin.keystore.operations.v1.DeleteKeyRequest - (*DeleteKeyResponse)(nil), // 8: plugin.keystore.operations.v1.DeleteKeyResponse - (*EnableKeyRequest)(nil), // 9: plugin.keystore.operations.v1.EnableKeyRequest - (*EnableKeyResponse)(nil), // 10: plugin.keystore.operations.v1.EnableKeyResponse - (*DisableKeyRequest)(nil), // 11: plugin.keystore.operations.v1.DisableKeyRequest - (*DisableKeyResponse)(nil), // 12: plugin.keystore.operations.v1.DisableKeyResponse - (*GetImportParametersRequest)(nil), // 13: plugin.keystore.operations.v1.GetImportParametersRequest - (*GetImportParametersResponse)(nil), // 14: plugin.keystore.operations.v1.GetImportParametersResponse - (*ImportKeyMaterialRequest)(nil), // 15: plugin.keystore.operations.v1.ImportKeyMaterialRequest - (*ImportKeyMaterialResponse)(nil), // 16: plugin.keystore.operations.v1.ImportKeyMaterialResponse - (*ValidateKeyRequest)(nil), // 17: plugin.keystore.operations.v1.ValidateKeyRequest - (*ValidateKeyResponse)(nil), // 18: plugin.keystore.operations.v1.ValidateKeyResponse - (*ValidateKeyAccessDataRequest)(nil), // 19: plugin.keystore.operations.v1.ValidateKeyAccessDataRequest - (*ValidateKeyAccessDataResponse)(nil), // 20: plugin.keystore.operations.v1.ValidateKeyAccessDataResponse - (*TransformCryptoAccessDataRequest)(nil), // 21: plugin.keystore.operations.v1.TransformCryptoAccessDataRequest - (*TransformCryptoAccessDataResponse)(nil), // 22: plugin.keystore.operations.v1.TransformCryptoAccessDataResponse - (*ExtractKeyRegionRequest)(nil), // 23: plugin.keystore.operations.v1.ExtractKeyRegionRequest - (*ExtractKeyRegionResponse)(nil), // 24: plugin.keystore.operations.v1.ExtractKeyRegionResponse - nil, // 25: plugin.keystore.operations.v1.TransformCryptoAccessDataResponse.TransformedAccessDataEntry - (*v1.KeystoreInstanceConfig)(nil), // 26: plugin.keystore.common.v1.KeystoreInstanceConfig + return file_plugin_key_management_v1_key_management_proto_rawDescData +} + +var file_plugin_key_management_v1_key_management_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_plugin_key_management_v1_key_management_proto_msgTypes = make([]protoimpl.MessageInfo, 24) +var file_plugin_key_management_v1_key_management_proto_goTypes = []any{ + (KeyAlgorithm)(0), // 0: plugin.key_management.v1.KeyAlgorithm + (KeyType)(0), // 1: plugin.key_management.v1.KeyType + (*RequestParameters)(nil), // 2: plugin.key_management.v1.RequestParameters + (*GetKeyRequest)(nil), // 3: plugin.key_management.v1.GetKeyRequest + (*GetKeyResponse)(nil), // 4: plugin.key_management.v1.GetKeyResponse + (*CreateKeyRequest)(nil), // 5: plugin.key_management.v1.CreateKeyRequest + (*CreateKeyResponse)(nil), // 6: plugin.key_management.v1.CreateKeyResponse + (*DeleteKeyRequest)(nil), // 7: plugin.key_management.v1.DeleteKeyRequest + (*DeleteKeyResponse)(nil), // 8: plugin.key_management.v1.DeleteKeyResponse + (*EnableKeyRequest)(nil), // 9: plugin.key_management.v1.EnableKeyRequest + (*EnableKeyResponse)(nil), // 10: plugin.key_management.v1.EnableKeyResponse + (*DisableKeyRequest)(nil), // 11: plugin.key_management.v1.DisableKeyRequest + (*DisableKeyResponse)(nil), // 12: plugin.key_management.v1.DisableKeyResponse + (*GetImportParametersRequest)(nil), // 13: plugin.key_management.v1.GetImportParametersRequest + (*GetImportParametersResponse)(nil), // 14: plugin.key_management.v1.GetImportParametersResponse + (*ImportKeyMaterialRequest)(nil), // 15: plugin.key_management.v1.ImportKeyMaterialRequest + (*ImportKeyMaterialResponse)(nil), // 16: plugin.key_management.v1.ImportKeyMaterialResponse + (*ValidateKeyRequest)(nil), // 17: plugin.key_management.v1.ValidateKeyRequest + (*ValidateKeyResponse)(nil), // 18: plugin.key_management.v1.ValidateKeyResponse + (*ValidateKeyAccessDataRequest)(nil), // 19: plugin.key_management.v1.ValidateKeyAccessDataRequest + (*ValidateKeyAccessDataResponse)(nil), // 20: plugin.key_management.v1.ValidateKeyAccessDataResponse + (*TransformCryptoAccessDataRequest)(nil), // 21: plugin.key_management.v1.TransformCryptoAccessDataRequest + (*TransformCryptoAccessDataResponse)(nil), // 22: plugin.key_management.v1.TransformCryptoAccessDataResponse + (*ExtractKeyRegionRequest)(nil), // 23: plugin.key_management.v1.ExtractKeyRegionRequest + (*ExtractKeyRegionResponse)(nil), // 24: plugin.key_management.v1.ExtractKeyRegionResponse + nil, // 25: plugin.key_management.v1.TransformCryptoAccessDataResponse.TransformedAccessDataEntry + (*v1.KeystoreConfig)(nil), // 26: plugin.common.v1.KeystoreConfig (*structpb.Struct)(nil), // 27: google.protobuf.Struct } -var file_plugin_keystore_operations_v1_operations_proto_depIdxs = []int32{ - 26, // 0: plugin.keystore.operations.v1.RequestParameters.config:type_name -> plugin.keystore.common.v1.KeystoreInstanceConfig - 2, // 1: plugin.keystore.operations.v1.GetKeyRequest.parameters:type_name -> plugin.keystore.operations.v1.RequestParameters - 0, // 2: plugin.keystore.operations.v1.GetKeyResponse.algorithm:type_name -> plugin.keystore.operations.v1.KeyAlgorithm - 26, // 3: plugin.keystore.operations.v1.CreateKeyRequest.config:type_name -> plugin.keystore.common.v1.KeystoreInstanceConfig - 0, // 4: plugin.keystore.operations.v1.CreateKeyRequest.algorithm:type_name -> plugin.keystore.operations.v1.KeyAlgorithm - 1, // 5: plugin.keystore.operations.v1.CreateKeyRequest.key_type:type_name -> plugin.keystore.operations.v1.KeyType - 2, // 6: plugin.keystore.operations.v1.DeleteKeyRequest.parameters:type_name -> plugin.keystore.operations.v1.RequestParameters - 2, // 7: plugin.keystore.operations.v1.EnableKeyRequest.parameters:type_name -> plugin.keystore.operations.v1.RequestParameters - 2, // 8: plugin.keystore.operations.v1.DisableKeyRequest.parameters:type_name -> plugin.keystore.operations.v1.RequestParameters - 2, // 9: plugin.keystore.operations.v1.GetImportParametersRequest.parameters:type_name -> plugin.keystore.operations.v1.RequestParameters - 0, // 10: plugin.keystore.operations.v1.GetImportParametersRequest.algorithm:type_name -> plugin.keystore.operations.v1.KeyAlgorithm - 27, // 11: plugin.keystore.operations.v1.GetImportParametersResponse.import_parameters:type_name -> google.protobuf.Struct - 2, // 12: plugin.keystore.operations.v1.ImportKeyMaterialRequest.parameters:type_name -> plugin.keystore.operations.v1.RequestParameters - 27, // 13: plugin.keystore.operations.v1.ImportKeyMaterialRequest.import_parameters:type_name -> google.protobuf.Struct - 1, // 14: plugin.keystore.operations.v1.ValidateKeyRequest.key_type:type_name -> plugin.keystore.operations.v1.KeyType - 0, // 15: plugin.keystore.operations.v1.ValidateKeyRequest.algorithm:type_name -> plugin.keystore.operations.v1.KeyAlgorithm - 27, // 16: plugin.keystore.operations.v1.ValidateKeyAccessDataRequest.management:type_name -> google.protobuf.Struct - 27, // 17: plugin.keystore.operations.v1.ValidateKeyAccessDataRequest.crypto:type_name -> google.protobuf.Struct - 25, // 18: plugin.keystore.operations.v1.TransformCryptoAccessDataResponse.transformed_access_data:type_name -> plugin.keystore.operations.v1.TransformCryptoAccessDataResponse.TransformedAccessDataEntry - 27, // 19: plugin.keystore.operations.v1.ExtractKeyRegionRequest.management_access_data:type_name -> google.protobuf.Struct - 3, // 20: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.GetKey:input_type -> plugin.keystore.operations.v1.GetKeyRequest - 5, // 21: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.CreateKey:input_type -> plugin.keystore.operations.v1.CreateKeyRequest - 7, // 22: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.DeleteKey:input_type -> plugin.keystore.operations.v1.DeleteKeyRequest - 9, // 23: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.EnableKey:input_type -> plugin.keystore.operations.v1.EnableKeyRequest - 11, // 24: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.DisableKey:input_type -> plugin.keystore.operations.v1.DisableKeyRequest - 13, // 25: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.GetImportParameters:input_type -> plugin.keystore.operations.v1.GetImportParametersRequest - 15, // 26: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.ImportKeyMaterial:input_type -> plugin.keystore.operations.v1.ImportKeyMaterialRequest - 17, // 27: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.ValidateKey:input_type -> plugin.keystore.operations.v1.ValidateKeyRequest - 19, // 28: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.ValidateKeyAccessData:input_type -> plugin.keystore.operations.v1.ValidateKeyAccessDataRequest - 21, // 29: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.TransformCryptoAccessData:input_type -> plugin.keystore.operations.v1.TransformCryptoAccessDataRequest - 23, // 30: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.ExtractKeyRegion:input_type -> plugin.keystore.operations.v1.ExtractKeyRegionRequest - 4, // 31: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.GetKey:output_type -> plugin.keystore.operations.v1.GetKeyResponse - 6, // 32: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.CreateKey:output_type -> plugin.keystore.operations.v1.CreateKeyResponse - 8, // 33: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.DeleteKey:output_type -> plugin.keystore.operations.v1.DeleteKeyResponse - 10, // 34: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.EnableKey:output_type -> plugin.keystore.operations.v1.EnableKeyResponse - 12, // 35: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.DisableKey:output_type -> plugin.keystore.operations.v1.DisableKeyResponse - 14, // 36: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.GetImportParameters:output_type -> plugin.keystore.operations.v1.GetImportParametersResponse - 16, // 37: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.ImportKeyMaterial:output_type -> plugin.keystore.operations.v1.ImportKeyMaterialResponse - 18, // 38: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.ValidateKey:output_type -> plugin.keystore.operations.v1.ValidateKeyResponse - 20, // 39: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.ValidateKeyAccessData:output_type -> plugin.keystore.operations.v1.ValidateKeyAccessDataResponse - 22, // 40: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.TransformCryptoAccessData:output_type -> plugin.keystore.operations.v1.TransformCryptoAccessDataResponse - 24, // 41: plugin.keystore.operations.v1.KeystoreInstanceKeyOperation.ExtractKeyRegion:output_type -> plugin.keystore.operations.v1.ExtractKeyRegionResponse +var file_plugin_key_management_v1_key_management_proto_depIdxs = []int32{ + 26, // 0: plugin.key_management.v1.RequestParameters.keystore_config:type_name -> plugin.common.v1.KeystoreConfig + 2, // 1: plugin.key_management.v1.GetKeyRequest.parameters:type_name -> plugin.key_management.v1.RequestParameters + 0, // 2: plugin.key_management.v1.GetKeyResponse.algorithm:type_name -> plugin.key_management.v1.KeyAlgorithm + 26, // 3: plugin.key_management.v1.CreateKeyRequest.keystore_config:type_name -> plugin.common.v1.KeystoreConfig + 0, // 4: plugin.key_management.v1.CreateKeyRequest.algorithm:type_name -> plugin.key_management.v1.KeyAlgorithm + 1, // 5: plugin.key_management.v1.CreateKeyRequest.key_type:type_name -> plugin.key_management.v1.KeyType + 2, // 6: plugin.key_management.v1.DeleteKeyRequest.parameters:type_name -> plugin.key_management.v1.RequestParameters + 2, // 7: plugin.key_management.v1.EnableKeyRequest.parameters:type_name -> plugin.key_management.v1.RequestParameters + 2, // 8: plugin.key_management.v1.DisableKeyRequest.parameters:type_name -> plugin.key_management.v1.RequestParameters + 2, // 9: plugin.key_management.v1.GetImportParametersRequest.parameters:type_name -> plugin.key_management.v1.RequestParameters + 0, // 10: plugin.key_management.v1.GetImportParametersRequest.algorithm:type_name -> plugin.key_management.v1.KeyAlgorithm + 27, // 11: plugin.key_management.v1.GetImportParametersResponse.import_parameters:type_name -> google.protobuf.Struct + 2, // 12: plugin.key_management.v1.ImportKeyMaterialRequest.parameters:type_name -> plugin.key_management.v1.RequestParameters + 27, // 13: plugin.key_management.v1.ImportKeyMaterialRequest.import_parameters:type_name -> google.protobuf.Struct + 1, // 14: plugin.key_management.v1.ValidateKeyRequest.key_type:type_name -> plugin.key_management.v1.KeyType + 0, // 15: plugin.key_management.v1.ValidateKeyRequest.algorithm:type_name -> plugin.key_management.v1.KeyAlgorithm + 27, // 16: plugin.key_management.v1.ValidateKeyAccessDataRequest.management:type_name -> google.protobuf.Struct + 27, // 17: plugin.key_management.v1.ValidateKeyAccessDataRequest.crypto:type_name -> google.protobuf.Struct + 25, // 18: plugin.key_management.v1.TransformCryptoAccessDataResponse.transformed_access_data:type_name -> plugin.key_management.v1.TransformCryptoAccessDataResponse.TransformedAccessDataEntry + 27, // 19: plugin.key_management.v1.ExtractKeyRegionRequest.management_access_data:type_name -> google.protobuf.Struct + 3, // 20: plugin.key_management.v1.KeyManagement.GetKey:input_type -> plugin.key_management.v1.GetKeyRequest + 5, // 21: plugin.key_management.v1.KeyManagement.CreateKey:input_type -> plugin.key_management.v1.CreateKeyRequest + 7, // 22: plugin.key_management.v1.KeyManagement.DeleteKey:input_type -> plugin.key_management.v1.DeleteKeyRequest + 9, // 23: plugin.key_management.v1.KeyManagement.EnableKey:input_type -> plugin.key_management.v1.EnableKeyRequest + 11, // 24: plugin.key_management.v1.KeyManagement.DisableKey:input_type -> plugin.key_management.v1.DisableKeyRequest + 13, // 25: plugin.key_management.v1.KeyManagement.GetImportParameters:input_type -> plugin.key_management.v1.GetImportParametersRequest + 15, // 26: plugin.key_management.v1.KeyManagement.ImportKeyMaterial:input_type -> plugin.key_management.v1.ImportKeyMaterialRequest + 17, // 27: plugin.key_management.v1.KeyManagement.ValidateKey:input_type -> plugin.key_management.v1.ValidateKeyRequest + 19, // 28: plugin.key_management.v1.KeyManagement.ValidateKeyAccessData:input_type -> plugin.key_management.v1.ValidateKeyAccessDataRequest + 21, // 29: plugin.key_management.v1.KeyManagement.TransformCryptoAccessData:input_type -> plugin.key_management.v1.TransformCryptoAccessDataRequest + 23, // 30: plugin.key_management.v1.KeyManagement.ExtractKeyRegion:input_type -> plugin.key_management.v1.ExtractKeyRegionRequest + 4, // 31: plugin.key_management.v1.KeyManagement.GetKey:output_type -> plugin.key_management.v1.GetKeyResponse + 6, // 32: plugin.key_management.v1.KeyManagement.CreateKey:output_type -> plugin.key_management.v1.CreateKeyResponse + 8, // 33: plugin.key_management.v1.KeyManagement.DeleteKey:output_type -> plugin.key_management.v1.DeleteKeyResponse + 10, // 34: plugin.key_management.v1.KeyManagement.EnableKey:output_type -> plugin.key_management.v1.EnableKeyResponse + 12, // 35: plugin.key_management.v1.KeyManagement.DisableKey:output_type -> plugin.key_management.v1.DisableKeyResponse + 14, // 36: plugin.key_management.v1.KeyManagement.GetImportParameters:output_type -> plugin.key_management.v1.GetImportParametersResponse + 16, // 37: plugin.key_management.v1.KeyManagement.ImportKeyMaterial:output_type -> plugin.key_management.v1.ImportKeyMaterialResponse + 18, // 38: plugin.key_management.v1.KeyManagement.ValidateKey:output_type -> plugin.key_management.v1.ValidateKeyResponse + 20, // 39: plugin.key_management.v1.KeyManagement.ValidateKeyAccessData:output_type -> plugin.key_management.v1.ValidateKeyAccessDataResponse + 22, // 40: plugin.key_management.v1.KeyManagement.TransformCryptoAccessData:output_type -> plugin.key_management.v1.TransformCryptoAccessDataResponse + 24, // 41: plugin.key_management.v1.KeyManagement.ExtractKeyRegion:output_type -> plugin.key_management.v1.ExtractKeyRegionResponse 31, // [31:42] is the sub-list for method output_type 20, // [20:31] is the sub-list for method input_type 20, // [20:20] is the sub-list for extension type_name @@ -1512,29 +1513,29 @@ var file_plugin_keystore_operations_v1_operations_proto_depIdxs = []int32{ 0, // [0:20] is the sub-list for field type_name } -func init() { file_plugin_keystore_operations_v1_operations_proto_init() } -func file_plugin_keystore_operations_v1_operations_proto_init() { - if File_plugin_keystore_operations_v1_operations_proto != nil { +func init() { file_plugin_key_management_v1_key_management_proto_init() } +func file_plugin_key_management_v1_key_management_proto_init() { + if File_plugin_key_management_v1_key_management_proto != nil { return } - file_plugin_keystore_operations_v1_operations_proto_msgTypes[3].OneofWrappers = []any{} - file_plugin_keystore_operations_v1_operations_proto_msgTypes[5].OneofWrappers = []any{} + file_plugin_key_management_v1_key_management_proto_msgTypes[3].OneofWrappers = []any{} + file_plugin_key_management_v1_key_management_proto_msgTypes[5].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_plugin_keystore_operations_v1_operations_proto_rawDesc), len(file_plugin_keystore_operations_v1_operations_proto_rawDesc)), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_plugin_key_management_v1_key_management_proto_rawDesc), len(file_plugin_key_management_v1_key_management_proto_rawDesc)), NumEnums: 2, NumMessages: 24, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_plugin_keystore_operations_v1_operations_proto_goTypes, - DependencyIndexes: file_plugin_keystore_operations_v1_operations_proto_depIdxs, - EnumInfos: file_plugin_keystore_operations_v1_operations_proto_enumTypes, - MessageInfos: file_plugin_keystore_operations_v1_operations_proto_msgTypes, + GoTypes: file_plugin_key_management_v1_key_management_proto_goTypes, + DependencyIndexes: file_plugin_key_management_v1_key_management_proto_depIdxs, + EnumInfos: file_plugin_key_management_v1_key_management_proto_enumTypes, + MessageInfos: file_plugin_key_management_v1_key_management_proto_msgTypes, }.Build() - File_plugin_keystore_operations_v1_operations_proto = out.File - file_plugin_keystore_operations_v1_operations_proto_goTypes = nil - file_plugin_keystore_operations_v1_operations_proto_depIdxs = nil + File_plugin_key_management_v1_key_management_proto = out.File + file_plugin_key_management_v1_key_management_proto_goTypes = nil + file_plugin_key_management_v1_key_management_proto_depIdxs = nil } diff --git a/proto/plugin/keystore/operations/v1/operations.pb.validate.go b/proto/plugin/key_management/v1/key_management.pb.validate.go similarity index 99% rename from proto/plugin/keystore/operations/v1/operations.pb.validate.go rename to proto/plugin/key_management/v1/key_management.pb.validate.go index 8eff541..56c9db3 100644 --- a/proto/plugin/keystore/operations/v1/operations.pb.validate.go +++ b/proto/plugin/key_management/v1/key_management.pb.validate.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-validate. DO NOT EDIT. -// source: plugin/keystore/operations/v1/operations.proto +// source: plugin/key_management/v1/key_management.proto -package operationsv1 +package key_managementv1 import ( "bytes" @@ -58,11 +58,11 @@ func (m *RequestParameters) validate(all bool) error { var errors []error if all { - switch v := interface{}(m.GetConfig()).(type) { + switch v := interface{}(m.GetKeystoreConfig()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, RequestParametersValidationError{ - field: "Config", + field: "KeystoreConfig", reason: "embedded message failed validation", cause: err, }) @@ -70,16 +70,16 @@ func (m *RequestParameters) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, RequestParametersValidationError{ - field: "Config", + field: "KeystoreConfig", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetConfig()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetKeystoreConfig()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RequestParametersValidationError{ - field: "Config", + field: "KeystoreConfig", reason: "embedded message failed validation", cause: err, } @@ -428,11 +428,11 @@ func (m *CreateKeyRequest) validate(all bool) error { var errors []error if all { - switch v := interface{}(m.GetConfig()).(type) { + switch v := interface{}(m.GetKeystoreConfig()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, CreateKeyRequestValidationError{ - field: "Config", + field: "KeystoreConfig", reason: "embedded message failed validation", cause: err, }) @@ -440,16 +440,16 @@ func (m *CreateKeyRequest) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, CreateKeyRequestValidationError{ - field: "Config", + field: "KeystoreConfig", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetConfig()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetKeystoreConfig()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CreateKeyRequestValidationError{ - field: "Config", + field: "KeystoreConfig", reason: "embedded message failed validation", cause: err, } diff --git a/proto/plugin/keystore/operations/v1/operations.proto b/proto/plugin/key_management/v1/key_management.proto similarity index 93% rename from proto/plugin/keystore/operations/v1/operations.proto rename to proto/plugin/key_management/v1/key_management.proto index 58d178b..c14fdc7 100644 --- a/proto/plugin/keystore/operations/v1/operations.proto +++ b/proto/plugin/key_management/v1/key_management.proto @@ -1,11 +1,11 @@ syntax = "proto3"; -package plugin.keystore.operations.v1; +package plugin.key_management.v1; import "google/protobuf/struct.proto"; -import "plugin/keystore/common/v1/common.proto"; +import "plugin/common/v1/common.proto"; -// KeystoreInstanceKeyOperation service defines the operations available for key management -service KeystoreInstanceKeyOperation { +// KeyManagement service defines the operations available for key management +service KeyManagement { // GetKey retrieves the details of a key by its ID // * Returns error "code = InvalidArgument desc = failed to authenticate with the keystore provider" // if the provided access data is invalid @@ -44,9 +44,9 @@ service KeystoreInstanceKeyOperation { rpc ExtractKeyRegion(ExtractKeyRegionRequest) returns (ExtractKeyRegionResponse); } -// KeyAlgorithm defines the supported key algorithms across all operations +// Algorithm defines the supported key algorithms across all operations enum KeyAlgorithm { - KEY_ALGORITHM_UNSPECIFIED = 0; + KEY_ALGORITHM_UNKNOWN = 0; KEY_ALGORITHM_AES256 = 1; KEY_ALGORITHM_RSA3072 = 2; KEY_ALGORITHM_RSA4096 = 3; @@ -61,7 +61,7 @@ enum KeyType { // RequestParameters contains the common fields needed for most key operations message RequestParameters { - plugin.keystore.common.v1.KeystoreInstanceConfig config = 1; + plugin.common.v1.KeystoreConfig keystore_config = 1; string key_id = 2; } @@ -79,7 +79,7 @@ message GetKeyResponse { // CreateKeyRequest contains parameters for key creation message CreateKeyRequest { - plugin.keystore.common.v1.KeystoreInstanceConfig config = 1; + plugin.common.v1.KeystoreConfig keystore_config = 1; KeyAlgorithm algorithm = 2; optional string id = 3; // Optional predefined key ID string region = 4; // The region in which to create the key diff --git a/proto/plugin/key_management/v1/key_management_ext_plugin.pb.go b/proto/plugin/key_management/v1/key_management_ext_plugin.pb.go new file mode 100644 index 0000000..a7a5d90 --- /dev/null +++ b/proto/plugin/key_management/v1/key_management_ext_plugin.pb.go @@ -0,0 +1,56 @@ +// Code generated by protoc-gen-go-extension. DO NOT EDIT. + +package key_managementv1 + +import ( + grpc "google.golang.org/grpc" + + api "github.com/openkcm/plugin-sdk/api" +) + +const ( + Type = "KeyManagement" + GRPCServiceFullName = "plugin.key_management.v1.KeyManagement" +) + +func KeyManagementPluginServer(server KeyManagementServer) api.PluginServer { + return keyManagementPluginServer{KeyManagementServer: server} +} + +type keyManagementPluginServer struct { + KeyManagementServer +} + +func (s keyManagementPluginServer) Type() string { + return Type +} + +func (s keyManagementPluginServer) GRPCServiceName() string { + return GRPCServiceFullName +} + +func (s keyManagementPluginServer) RegisterServer(server *grpc.Server) any { + RegisterKeyManagementServer(server, s.KeyManagementServer) + return s.KeyManagementServer +} + +type KeyManagementPluginClient struct { + KeyManagementClient +} + +func (s KeyManagementPluginClient) Type() string { + return Type +} + +func (c *KeyManagementPluginClient) IsInitialized() bool { + return c.KeyManagementClient != nil +} + +func (c *KeyManagementPluginClient) GRPCServiceName() string { + return GRPCServiceFullName +} + +func (c *KeyManagementPluginClient) InitClient(conn grpc.ClientConnInterface) any { + c.KeyManagementClient = NewKeyManagementClient(conn) + return c.KeyManagementClient +} diff --git a/proto/plugin/key_management/v1/key_management_grpc.pb.go b/proto/plugin/key_management/v1/key_management_grpc.pb.go new file mode 100644 index 0000000..34f26e7 --- /dev/null +++ b/proto/plugin/key_management/v1/key_management_grpc.pb.go @@ -0,0 +1,536 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.6.1 +// - protoc (unknown) +// source: plugin/key_management/v1/key_management.proto + +package key_managementv1 + +import ( + context "context" + + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + KeyManagement_GetKey_FullMethodName = "/plugin.key_management.v1.KeyManagement/GetKey" + KeyManagement_CreateKey_FullMethodName = "/plugin.key_management.v1.KeyManagement/CreateKey" + KeyManagement_DeleteKey_FullMethodName = "/plugin.key_management.v1.KeyManagement/DeleteKey" + KeyManagement_EnableKey_FullMethodName = "/plugin.key_management.v1.KeyManagement/EnableKey" + KeyManagement_DisableKey_FullMethodName = "/plugin.key_management.v1.KeyManagement/DisableKey" + KeyManagement_GetImportParameters_FullMethodName = "/plugin.key_management.v1.KeyManagement/GetImportParameters" + KeyManagement_ImportKeyMaterial_FullMethodName = "/plugin.key_management.v1.KeyManagement/ImportKeyMaterial" + KeyManagement_ValidateKey_FullMethodName = "/plugin.key_management.v1.KeyManagement/ValidateKey" + KeyManagement_ValidateKeyAccessData_FullMethodName = "/plugin.key_management.v1.KeyManagement/ValidateKeyAccessData" + KeyManagement_TransformCryptoAccessData_FullMethodName = "/plugin.key_management.v1.KeyManagement/TransformCryptoAccessData" + KeyManagement_ExtractKeyRegion_FullMethodName = "/plugin.key_management.v1.KeyManagement/ExtractKeyRegion" +) + +// KeyManagementClient is the client API for KeyManagement service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// KeyManagement service defines the operations available for key management +type KeyManagementClient interface { + // GetKey retrieves the details of a key by its ID + // * Returns error "code = InvalidArgument desc = failed to authenticate with the keystore provider" + // if the provided access data is invalid + // * Returns error "code = NotFound desc = key not found in the keystore provider" + // if the key does not exist + GetKey(ctx context.Context, in *GetKeyRequest, opts ...grpc.CallOption) (*GetKeyResponse, error) + // CreateKey generates a new key with the specified algorithm + CreateKey(ctx context.Context, in *CreateKeyRequest, opts ...grpc.CallOption) (*CreateKeyResponse, error) + // DeleteKey removes a key, optionally with a deletion window + DeleteKey(ctx context.Context, in *DeleteKeyRequest, opts ...grpc.CallOption) (*DeleteKeyResponse, error) + // EnableKey activates a previously disabled key + EnableKey(ctx context.Context, in *EnableKeyRequest, opts ...grpc.CallOption) (*EnableKeyResponse, error) + // DisableKey deactivates a key while maintaining its existence + DisableKey(ctx context.Context, in *DisableKeyRequest, opts ...grpc.CallOption) (*DisableKeyResponse, error) + // Gets the parameters needed for importing key material + GetImportParameters(ctx context.Context, in *GetImportParametersRequest, opts ...grpc.CallOption) (*GetImportParametersResponse, error) + // Imports key material into a KMS key + ImportKeyMaterial(ctx context.Context, in *ImportKeyMaterialRequest, opts ...grpc.CallOption) (*ImportKeyMaterialResponse, error) + // Validate the key attributes against the plugin's requirements + ValidateKey(ctx context.Context, in *ValidateKeyRequest, opts ...grpc.CallOption) (*ValidateKeyResponse, error) + // ValidateKeyAccessData checks the access data for key management and crypto operations + ValidateKeyAccessData(ctx context.Context, in *ValidateKeyAccessDataRequest, opts ...grpc.CallOption) (*ValidateKeyAccessDataResponse, error) + // TransformCryptoAccessData transforms the JSON-stored crypto access data into protobuf wire format for a given key + TransformCryptoAccessData(ctx context.Context, in *TransformCryptoAccessDataRequest, opts ...grpc.CallOption) (*TransformCryptoAccessDataResponse, error) + // ExtractKeyRegion extracts the region from key attributes + ExtractKeyRegion(ctx context.Context, in *ExtractKeyRegionRequest, opts ...grpc.CallOption) (*ExtractKeyRegionResponse, error) +} + +type keyManagementClient struct { + cc grpc.ClientConnInterface +} + +func NewKeyManagementClient(cc grpc.ClientConnInterface) KeyManagementClient { + return &keyManagementClient{cc} +} + +func (c *keyManagementClient) GetKey(ctx context.Context, in *GetKeyRequest, opts ...grpc.CallOption) (*GetKeyResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetKeyResponse) + err := c.cc.Invoke(ctx, KeyManagement_GetKey_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *keyManagementClient) CreateKey(ctx context.Context, in *CreateKeyRequest, opts ...grpc.CallOption) (*CreateKeyResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CreateKeyResponse) + err := c.cc.Invoke(ctx, KeyManagement_CreateKey_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *keyManagementClient) DeleteKey(ctx context.Context, in *DeleteKeyRequest, opts ...grpc.CallOption) (*DeleteKeyResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DeleteKeyResponse) + err := c.cc.Invoke(ctx, KeyManagement_DeleteKey_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *keyManagementClient) EnableKey(ctx context.Context, in *EnableKeyRequest, opts ...grpc.CallOption) (*EnableKeyResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(EnableKeyResponse) + err := c.cc.Invoke(ctx, KeyManagement_EnableKey_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *keyManagementClient) DisableKey(ctx context.Context, in *DisableKeyRequest, opts ...grpc.CallOption) (*DisableKeyResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DisableKeyResponse) + err := c.cc.Invoke(ctx, KeyManagement_DisableKey_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *keyManagementClient) GetImportParameters(ctx context.Context, in *GetImportParametersRequest, opts ...grpc.CallOption) (*GetImportParametersResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetImportParametersResponse) + err := c.cc.Invoke(ctx, KeyManagement_GetImportParameters_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *keyManagementClient) ImportKeyMaterial(ctx context.Context, in *ImportKeyMaterialRequest, opts ...grpc.CallOption) (*ImportKeyMaterialResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ImportKeyMaterialResponse) + err := c.cc.Invoke(ctx, KeyManagement_ImportKeyMaterial_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *keyManagementClient) ValidateKey(ctx context.Context, in *ValidateKeyRequest, opts ...grpc.CallOption) (*ValidateKeyResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ValidateKeyResponse) + err := c.cc.Invoke(ctx, KeyManagement_ValidateKey_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *keyManagementClient) ValidateKeyAccessData(ctx context.Context, in *ValidateKeyAccessDataRequest, opts ...grpc.CallOption) (*ValidateKeyAccessDataResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ValidateKeyAccessDataResponse) + err := c.cc.Invoke(ctx, KeyManagement_ValidateKeyAccessData_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *keyManagementClient) TransformCryptoAccessData(ctx context.Context, in *TransformCryptoAccessDataRequest, opts ...grpc.CallOption) (*TransformCryptoAccessDataResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(TransformCryptoAccessDataResponse) + err := c.cc.Invoke(ctx, KeyManagement_TransformCryptoAccessData_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *keyManagementClient) ExtractKeyRegion(ctx context.Context, in *ExtractKeyRegionRequest, opts ...grpc.CallOption) (*ExtractKeyRegionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ExtractKeyRegionResponse) + err := c.cc.Invoke(ctx, KeyManagement_ExtractKeyRegion_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// KeyManagementServer is the server API for KeyManagement service. +// All implementations must embed UnimplementedKeyManagementServer +// for forward compatibility. +// +// KeyManagement service defines the operations available for key management +type KeyManagementServer interface { + // GetKey retrieves the details of a key by its ID + // * Returns error "code = InvalidArgument desc = failed to authenticate with the keystore provider" + // if the provided access data is invalid + // * Returns error "code = NotFound desc = key not found in the keystore provider" + // if the key does not exist + GetKey(context.Context, *GetKeyRequest) (*GetKeyResponse, error) + // CreateKey generates a new key with the specified algorithm + CreateKey(context.Context, *CreateKeyRequest) (*CreateKeyResponse, error) + // DeleteKey removes a key, optionally with a deletion window + DeleteKey(context.Context, *DeleteKeyRequest) (*DeleteKeyResponse, error) + // EnableKey activates a previously disabled key + EnableKey(context.Context, *EnableKeyRequest) (*EnableKeyResponse, error) + // DisableKey deactivates a key while maintaining its existence + DisableKey(context.Context, *DisableKeyRequest) (*DisableKeyResponse, error) + // Gets the parameters needed for importing key material + GetImportParameters(context.Context, *GetImportParametersRequest) (*GetImportParametersResponse, error) + // Imports key material into a KMS key + ImportKeyMaterial(context.Context, *ImportKeyMaterialRequest) (*ImportKeyMaterialResponse, error) + // Validate the key attributes against the plugin's requirements + ValidateKey(context.Context, *ValidateKeyRequest) (*ValidateKeyResponse, error) + // ValidateKeyAccessData checks the access data for key management and crypto operations + ValidateKeyAccessData(context.Context, *ValidateKeyAccessDataRequest) (*ValidateKeyAccessDataResponse, error) + // TransformCryptoAccessData transforms the JSON-stored crypto access data into protobuf wire format for a given key + TransformCryptoAccessData(context.Context, *TransformCryptoAccessDataRequest) (*TransformCryptoAccessDataResponse, error) + // ExtractKeyRegion extracts the region from key attributes + ExtractKeyRegion(context.Context, *ExtractKeyRegionRequest) (*ExtractKeyRegionResponse, error) + mustEmbedUnimplementedKeyManagementServer() +} + +// UnimplementedKeyManagementServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedKeyManagementServer struct{} + +func (UnimplementedKeyManagementServer) GetKey(context.Context, *GetKeyRequest) (*GetKeyResponse, error) { + return nil, status.Error(codes.Unimplemented, "method GetKey not implemented") +} +func (UnimplementedKeyManagementServer) CreateKey(context.Context, *CreateKeyRequest) (*CreateKeyResponse, error) { + return nil, status.Error(codes.Unimplemented, "method CreateKey not implemented") +} +func (UnimplementedKeyManagementServer) DeleteKey(context.Context, *DeleteKeyRequest) (*DeleteKeyResponse, error) { + return nil, status.Error(codes.Unimplemented, "method DeleteKey not implemented") +} +func (UnimplementedKeyManagementServer) EnableKey(context.Context, *EnableKeyRequest) (*EnableKeyResponse, error) { + return nil, status.Error(codes.Unimplemented, "method EnableKey not implemented") +} +func (UnimplementedKeyManagementServer) DisableKey(context.Context, *DisableKeyRequest) (*DisableKeyResponse, error) { + return nil, status.Error(codes.Unimplemented, "method DisableKey not implemented") +} +func (UnimplementedKeyManagementServer) GetImportParameters(context.Context, *GetImportParametersRequest) (*GetImportParametersResponse, error) { + return nil, status.Error(codes.Unimplemented, "method GetImportParameters not implemented") +} +func (UnimplementedKeyManagementServer) ImportKeyMaterial(context.Context, *ImportKeyMaterialRequest) (*ImportKeyMaterialResponse, error) { + return nil, status.Error(codes.Unimplemented, "method ImportKeyMaterial not implemented") +} +func (UnimplementedKeyManagementServer) ValidateKey(context.Context, *ValidateKeyRequest) (*ValidateKeyResponse, error) { + return nil, status.Error(codes.Unimplemented, "method ValidateKey not implemented") +} +func (UnimplementedKeyManagementServer) ValidateKeyAccessData(context.Context, *ValidateKeyAccessDataRequest) (*ValidateKeyAccessDataResponse, error) { + return nil, status.Error(codes.Unimplemented, "method ValidateKeyAccessData not implemented") +} +func (UnimplementedKeyManagementServer) TransformCryptoAccessData(context.Context, *TransformCryptoAccessDataRequest) (*TransformCryptoAccessDataResponse, error) { + return nil, status.Error(codes.Unimplemented, "method TransformCryptoAccessData not implemented") +} +func (UnimplementedKeyManagementServer) ExtractKeyRegion(context.Context, *ExtractKeyRegionRequest) (*ExtractKeyRegionResponse, error) { + return nil, status.Error(codes.Unimplemented, "method ExtractKeyRegion not implemented") +} +func (UnimplementedKeyManagementServer) mustEmbedUnimplementedKeyManagementServer() {} +func (UnimplementedKeyManagementServer) testEmbeddedByValue() {} + +// UnsafeKeyManagementServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to KeyManagementServer will +// result in compilation errors. +type UnsafeKeyManagementServer interface { + mustEmbedUnimplementedKeyManagementServer() +} + +func RegisterKeyManagementServer(s grpc.ServiceRegistrar, srv KeyManagementServer) { + // If the following call panics, it indicates UnimplementedKeyManagementServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&KeyManagement_ServiceDesc, srv) +} + +func _KeyManagement_GetKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetKeyRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KeyManagementServer).GetKey(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: KeyManagement_GetKey_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KeyManagementServer).GetKey(ctx, req.(*GetKeyRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _KeyManagement_CreateKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateKeyRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KeyManagementServer).CreateKey(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: KeyManagement_CreateKey_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KeyManagementServer).CreateKey(ctx, req.(*CreateKeyRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _KeyManagement_DeleteKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteKeyRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KeyManagementServer).DeleteKey(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: KeyManagement_DeleteKey_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KeyManagementServer).DeleteKey(ctx, req.(*DeleteKeyRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _KeyManagement_EnableKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(EnableKeyRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KeyManagementServer).EnableKey(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: KeyManagement_EnableKey_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KeyManagementServer).EnableKey(ctx, req.(*EnableKeyRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _KeyManagement_DisableKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DisableKeyRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KeyManagementServer).DisableKey(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: KeyManagement_DisableKey_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KeyManagementServer).DisableKey(ctx, req.(*DisableKeyRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _KeyManagement_GetImportParameters_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetImportParametersRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KeyManagementServer).GetImportParameters(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: KeyManagement_GetImportParameters_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KeyManagementServer).GetImportParameters(ctx, req.(*GetImportParametersRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _KeyManagement_ImportKeyMaterial_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ImportKeyMaterialRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KeyManagementServer).ImportKeyMaterial(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: KeyManagement_ImportKeyMaterial_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KeyManagementServer).ImportKeyMaterial(ctx, req.(*ImportKeyMaterialRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _KeyManagement_ValidateKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ValidateKeyRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KeyManagementServer).ValidateKey(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: KeyManagement_ValidateKey_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KeyManagementServer).ValidateKey(ctx, req.(*ValidateKeyRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _KeyManagement_ValidateKeyAccessData_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ValidateKeyAccessDataRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KeyManagementServer).ValidateKeyAccessData(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: KeyManagement_ValidateKeyAccessData_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KeyManagementServer).ValidateKeyAccessData(ctx, req.(*ValidateKeyAccessDataRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _KeyManagement_TransformCryptoAccessData_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(TransformCryptoAccessDataRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KeyManagementServer).TransformCryptoAccessData(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: KeyManagement_TransformCryptoAccessData_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KeyManagementServer).TransformCryptoAccessData(ctx, req.(*TransformCryptoAccessDataRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _KeyManagement_ExtractKeyRegion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ExtractKeyRegionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KeyManagementServer).ExtractKeyRegion(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: KeyManagement_ExtractKeyRegion_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KeyManagementServer).ExtractKeyRegion(ctx, req.(*ExtractKeyRegionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// KeyManagement_ServiceDesc is the grpc.ServiceDesc for KeyManagement service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var KeyManagement_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "plugin.key_management.v1.KeyManagement", + HandlerType: (*KeyManagementServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetKey", + Handler: _KeyManagement_GetKey_Handler, + }, + { + MethodName: "CreateKey", + Handler: _KeyManagement_CreateKey_Handler, + }, + { + MethodName: "DeleteKey", + Handler: _KeyManagement_DeleteKey_Handler, + }, + { + MethodName: "EnableKey", + Handler: _KeyManagement_EnableKey_Handler, + }, + { + MethodName: "DisableKey", + Handler: _KeyManagement_DisableKey_Handler, + }, + { + MethodName: "GetImportParameters", + Handler: _KeyManagement_GetImportParameters_Handler, + }, + { + MethodName: "ImportKeyMaterial", + Handler: _KeyManagement_ImportKeyMaterial_Handler, + }, + { + MethodName: "ValidateKey", + Handler: _KeyManagement_ValidateKey_Handler, + }, + { + MethodName: "ValidateKeyAccessData", + Handler: _KeyManagement_ValidateKeyAccessData_Handler, + }, + { + MethodName: "TransformCryptoAccessData", + Handler: _KeyManagement_TransformCryptoAccessData_Handler, + }, + { + MethodName: "ExtractKeyRegion", + Handler: _KeyManagement_ExtractKeyRegion_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "plugin/key_management/v1/key_management.proto", +} diff --git a/proto/plugin/keystore/common/v1/common.pb.go b/proto/plugin/keystore/common/v1/common.pb.go deleted file mode 100644 index 5012e42..0000000 --- a/proto/plugin/keystore/common/v1/common.pb.go +++ /dev/null @@ -1,129 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.11 -// protoc (unknown) -// source: plugin/keystore/common/v1/common.proto - -package commonv1 - -import ( - reflect "reflect" - sync "sync" - unsafe "unsafe" - - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - structpb "google.golang.org/protobuf/types/known/structpb" -) - -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) -) - -// KeystoreInstanceConfig represents the configuration for a key store instance -// This is shared between management and operations plugins -type KeystoreInstanceConfig struct { - state protoimpl.MessageState `protogen:"open.v1"` - Values *structpb.Struct `protobuf:"bytes,1,opt,name=values,proto3" json:"values,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *KeystoreInstanceConfig) Reset() { - *x = KeystoreInstanceConfig{} - mi := &file_plugin_keystore_common_v1_common_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *KeystoreInstanceConfig) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*KeystoreInstanceConfig) ProtoMessage() {} - -func (x *KeystoreInstanceConfig) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_common_v1_common_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 KeystoreInstanceConfig.ProtoReflect.Descriptor instead. -func (*KeystoreInstanceConfig) Descriptor() ([]byte, []int) { - return file_plugin_keystore_common_v1_common_proto_rawDescGZIP(), []int{0} -} - -func (x *KeystoreInstanceConfig) GetValues() *structpb.Struct { - if x != nil { - return x.Values - } - return nil -} - -var File_plugin_keystore_common_v1_common_proto protoreflect.FileDescriptor - -const file_plugin_keystore_common_v1_common_proto_rawDesc = "" + - "\n" + - "&plugin/keystore/common/v1/common.proto\x12\x19plugin.keystore.common.v1\x1a\x1cgoogle/protobuf/struct.proto\"I\n" + - "\x16KeystoreInstanceConfig\x12/\n" + - "\x06values\x18\x01 \x01(\v2\x17.google.protobuf.StructR\x06valuesB\xfb\x01\n" + - "\x1dcom.plugin.keystore.common.v1B\vCommonProtoP\x01ZFgithub.com/openkcm/plugin-sdk/proto/plugin/keystore/common/v1;commonv1\xa2\x02\x03PKC\xaa\x02\x19Plugin.Keystore.Common.V1\xca\x02\x19Plugin\\Keystore\\Common\\V1\xe2\x02%Plugin\\Keystore\\Common\\V1\\GPBMetadata\xea\x02\x1cPlugin::Keystore::Common::V1b\x06proto3" - -var ( - file_plugin_keystore_common_v1_common_proto_rawDescOnce sync.Once - file_plugin_keystore_common_v1_common_proto_rawDescData []byte -) - -func file_plugin_keystore_common_v1_common_proto_rawDescGZIP() []byte { - file_plugin_keystore_common_v1_common_proto_rawDescOnce.Do(func() { - file_plugin_keystore_common_v1_common_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_plugin_keystore_common_v1_common_proto_rawDesc), len(file_plugin_keystore_common_v1_common_proto_rawDesc))) - }) - return file_plugin_keystore_common_v1_common_proto_rawDescData -} - -var file_plugin_keystore_common_v1_common_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_plugin_keystore_common_v1_common_proto_goTypes = []any{ - (*KeystoreInstanceConfig)(nil), // 0: plugin.keystore.common.v1.KeystoreInstanceConfig - (*structpb.Struct)(nil), // 1: google.protobuf.Struct -} -var file_plugin_keystore_common_v1_common_proto_depIdxs = []int32{ - 1, // 0: plugin.keystore.common.v1.KeystoreInstanceConfig.values:type_name -> google.protobuf.Struct - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name -} - -func init() { file_plugin_keystore_common_v1_common_proto_init() } -func file_plugin_keystore_common_v1_common_proto_init() { - if File_plugin_keystore_common_v1_common_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_plugin_keystore_common_v1_common_proto_rawDesc), len(file_plugin_keystore_common_v1_common_proto_rawDesc)), - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_plugin_keystore_common_v1_common_proto_goTypes, - DependencyIndexes: file_plugin_keystore_common_v1_common_proto_depIdxs, - MessageInfos: file_plugin_keystore_common_v1_common_proto_msgTypes, - }.Build() - File_plugin_keystore_common_v1_common_proto = out.File - file_plugin_keystore_common_v1_common_proto_goTypes = nil - file_plugin_keystore_common_v1_common_proto_depIdxs = nil -} diff --git a/proto/plugin/keystore/common/v1/common.pb.validate.go b/proto/plugin/keystore/common/v1/common.pb.validate.go deleted file mode 100644 index 738dab4..0000000 --- a/proto/plugin/keystore/common/v1/common.pb.validate.go +++ /dev/null @@ -1,167 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: plugin/keystore/common/v1/common.proto - -package commonv1 - -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 KeystoreInstanceConfig 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 *KeystoreInstanceConfig) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on KeystoreInstanceConfig 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 -// KeystoreInstanceConfigMultiError, or nil if none found. -func (m *KeystoreInstanceConfig) ValidateAll() error { - return m.validate(true) -} - -func (m *KeystoreInstanceConfig) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetValues()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, KeystoreInstanceConfigValidationError{ - field: "Values", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, KeystoreInstanceConfigValidationError{ - field: "Values", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetValues()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return KeystoreInstanceConfigValidationError{ - field: "Values", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return KeystoreInstanceConfigMultiError(errors) - } - - return nil -} - -// KeystoreInstanceConfigMultiError is an error wrapping multiple validation -// errors returned by KeystoreInstanceConfig.ValidateAll() if the designated -// constraints aren't met. -type KeystoreInstanceConfigMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m KeystoreInstanceConfigMultiError) 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 KeystoreInstanceConfigMultiError) AllErrors() []error { return m } - -// KeystoreInstanceConfigValidationError is the validation error returned by -// KeystoreInstanceConfig.Validate if the designated constraints aren't met. -type KeystoreInstanceConfigValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e KeystoreInstanceConfigValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e KeystoreInstanceConfigValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e KeystoreInstanceConfigValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e KeystoreInstanceConfigValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e KeystoreInstanceConfigValidationError) ErrorName() string { - return "KeystoreInstanceConfigValidationError" -} - -// Error satisfies the builtin error interface -func (e KeystoreInstanceConfigValidationError) 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 %sKeystoreInstanceConfig.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = KeystoreInstanceConfigValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = KeystoreInstanceConfigValidationError{} diff --git a/proto/plugin/keystore/common/v1/common.proto b/proto/plugin/keystore/common/v1/common.proto deleted file mode 100644 index d0171f1..0000000 --- a/proto/plugin/keystore/common/v1/common.proto +++ /dev/null @@ -1,10 +0,0 @@ -syntax = "proto3"; -package plugin.keystore.common.v1; - -import "google/protobuf/struct.proto"; - -// KeystoreInstanceConfig represents the configuration for a key store instance -// This is shared between management and operations plugins -message KeystoreInstanceConfig { - google.protobuf.Struct values = 1; -} diff --git a/proto/plugin/keystore/management/v1/management.pb.go b/proto/plugin/keystore/management/v1/management.pb.go deleted file mode 100644 index 4c2ff7d..0000000 --- a/proto/plugin/keystore/management/v1/management.pb.go +++ /dev/null @@ -1,271 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.11 -// protoc (unknown) -// source: plugin/keystore/management/v1/management.proto - -package managementv1 - -import ( - reflect "reflect" - sync "sync" - unsafe "unsafe" - - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - structpb "google.golang.org/protobuf/types/known/structpb" - - v1 "github.com/openkcm/plugin-sdk/proto/plugin/keystore/common/v1" -) - -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 CreateKeystoreRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Values *structpb.Struct `protobuf:"bytes,1,opt,name=values,proto3" json:"values,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateKeystoreRequest) Reset() { - *x = CreateKeystoreRequest{} - mi := &file_plugin_keystore_management_v1_management_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateKeystoreRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateKeystoreRequest) ProtoMessage() {} - -func (x *CreateKeystoreRequest) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_management_v1_management_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 CreateKeystoreRequest.ProtoReflect.Descriptor instead. -func (*CreateKeystoreRequest) Descriptor() ([]byte, []int) { - return file_plugin_keystore_management_v1_management_proto_rawDescGZIP(), []int{0} -} - -func (x *CreateKeystoreRequest) GetValues() *structpb.Struct { - if x != nil { - return x.Values - } - return nil -} - -type CreateKeystoreResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Config *v1.KeystoreInstanceConfig `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateKeystoreResponse) Reset() { - *x = CreateKeystoreResponse{} - mi := &file_plugin_keystore_management_v1_management_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateKeystoreResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateKeystoreResponse) ProtoMessage() {} - -func (x *CreateKeystoreResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_management_v1_management_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 CreateKeystoreResponse.ProtoReflect.Descriptor instead. -func (*CreateKeystoreResponse) Descriptor() ([]byte, []int) { - return file_plugin_keystore_management_v1_management_proto_rawDescGZIP(), []int{1} -} - -func (x *CreateKeystoreResponse) GetConfig() *v1.KeystoreInstanceConfig { - if x != nil { - return x.Config - } - return nil -} - -type DeleteKeystoreRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Config *v1.KeystoreInstanceConfig `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeleteKeystoreRequest) Reset() { - *x = DeleteKeystoreRequest{} - mi := &file_plugin_keystore_management_v1_management_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeleteKeystoreRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteKeystoreRequest) ProtoMessage() {} - -func (x *DeleteKeystoreRequest) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_management_v1_management_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 DeleteKeystoreRequest.ProtoReflect.Descriptor instead. -func (*DeleteKeystoreRequest) Descriptor() ([]byte, []int) { - return file_plugin_keystore_management_v1_management_proto_rawDescGZIP(), []int{2} -} - -func (x *DeleteKeystoreRequest) GetConfig() *v1.KeystoreInstanceConfig { - if x != nil { - return x.Config - } - return nil -} - -type DeleteKeystoreResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeleteKeystoreResponse) Reset() { - *x = DeleteKeystoreResponse{} - mi := &file_plugin_keystore_management_v1_management_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeleteKeystoreResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteKeystoreResponse) ProtoMessage() {} - -func (x *DeleteKeystoreResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_keystore_management_v1_management_proto_msgTypes[3] - 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 DeleteKeystoreResponse.ProtoReflect.Descriptor instead. -func (*DeleteKeystoreResponse) Descriptor() ([]byte, []int) { - return file_plugin_keystore_management_v1_management_proto_rawDescGZIP(), []int{3} -} - -var File_plugin_keystore_management_v1_management_proto protoreflect.FileDescriptor - -const file_plugin_keystore_management_v1_management_proto_rawDesc = "" + - "\n" + - ".plugin/keystore/management/v1/management.proto\x12\x1dplugin.keystore.management.v1\x1a\x1cgoogle/protobuf/struct.proto\x1a&plugin/keystore/common/v1/common.proto\"H\n" + - "\x15CreateKeystoreRequest\x12/\n" + - "\x06values\x18\x01 \x01(\v2\x17.google.protobuf.StructR\x06values\"c\n" + - "\x16CreateKeystoreResponse\x12I\n" + - "\x06config\x18\x01 \x01(\v21.plugin.keystore.common.v1.KeystoreInstanceConfigR\x06config\"b\n" + - "\x15DeleteKeystoreRequest\x12I\n" + - "\x06config\x18\x01 \x01(\v21.plugin.keystore.common.v1.KeystoreInstanceConfigR\x06config\"\x18\n" + - "\x16DeleteKeystoreResponse2\x90\x02\n" + - "\x10KeystoreProvider\x12}\n" + - "\x0eCreateKeystore\x124.plugin.keystore.management.v1.CreateKeystoreRequest\x1a5.plugin.keystore.management.v1.CreateKeystoreResponse\x12}\n" + - "\x0eDeleteKeystore\x124.plugin.keystore.management.v1.DeleteKeystoreRequest\x1a5.plugin.keystore.management.v1.DeleteKeystoreResponseB\x9b\x02\n" + - "!com.plugin.keystore.management.v1B\x0fManagementProtoP\x01ZNgithub.com/openkcm/plugin-sdk/proto/plugin/keystore/management/v1;managementv1\xa2\x02\x03PKM\xaa\x02\x1dPlugin.Keystore.Management.V1\xca\x02\x1dPlugin\\Keystore\\Management\\V1\xe2\x02)Plugin\\Keystore\\Management\\V1\\GPBMetadata\xea\x02 Plugin::Keystore::Management::V1b\x06proto3" - -var ( - file_plugin_keystore_management_v1_management_proto_rawDescOnce sync.Once - file_plugin_keystore_management_v1_management_proto_rawDescData []byte -) - -func file_plugin_keystore_management_v1_management_proto_rawDescGZIP() []byte { - file_plugin_keystore_management_v1_management_proto_rawDescOnce.Do(func() { - file_plugin_keystore_management_v1_management_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_plugin_keystore_management_v1_management_proto_rawDesc), len(file_plugin_keystore_management_v1_management_proto_rawDesc))) - }) - return file_plugin_keystore_management_v1_management_proto_rawDescData -} - -var file_plugin_keystore_management_v1_management_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_plugin_keystore_management_v1_management_proto_goTypes = []any{ - (*CreateKeystoreRequest)(nil), // 0: plugin.keystore.management.v1.CreateKeystoreRequest - (*CreateKeystoreResponse)(nil), // 1: plugin.keystore.management.v1.CreateKeystoreResponse - (*DeleteKeystoreRequest)(nil), // 2: plugin.keystore.management.v1.DeleteKeystoreRequest - (*DeleteKeystoreResponse)(nil), // 3: plugin.keystore.management.v1.DeleteKeystoreResponse - (*structpb.Struct)(nil), // 4: google.protobuf.Struct - (*v1.KeystoreInstanceConfig)(nil), // 5: plugin.keystore.common.v1.KeystoreInstanceConfig -} -var file_plugin_keystore_management_v1_management_proto_depIdxs = []int32{ - 4, // 0: plugin.keystore.management.v1.CreateKeystoreRequest.values:type_name -> google.protobuf.Struct - 5, // 1: plugin.keystore.management.v1.CreateKeystoreResponse.config:type_name -> plugin.keystore.common.v1.KeystoreInstanceConfig - 5, // 2: plugin.keystore.management.v1.DeleteKeystoreRequest.config:type_name -> plugin.keystore.common.v1.KeystoreInstanceConfig - 0, // 3: plugin.keystore.management.v1.KeystoreProvider.CreateKeystore:input_type -> plugin.keystore.management.v1.CreateKeystoreRequest - 2, // 4: plugin.keystore.management.v1.KeystoreProvider.DeleteKeystore:input_type -> plugin.keystore.management.v1.DeleteKeystoreRequest - 1, // 5: plugin.keystore.management.v1.KeystoreProvider.CreateKeystore:output_type -> plugin.keystore.management.v1.CreateKeystoreResponse - 3, // 6: plugin.keystore.management.v1.KeystoreProvider.DeleteKeystore:output_type -> plugin.keystore.management.v1.DeleteKeystoreResponse - 5, // [5:7] is the sub-list for method output_type - 3, // [3:5] 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_plugin_keystore_management_v1_management_proto_init() } -func file_plugin_keystore_management_v1_management_proto_init() { - if File_plugin_keystore_management_v1_management_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_plugin_keystore_management_v1_management_proto_rawDesc), len(file_plugin_keystore_management_v1_management_proto_rawDesc)), - NumEnums: 0, - NumMessages: 4, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_plugin_keystore_management_v1_management_proto_goTypes, - DependencyIndexes: file_plugin_keystore_management_v1_management_proto_depIdxs, - MessageInfos: file_plugin_keystore_management_v1_management_proto_msgTypes, - }.Build() - File_plugin_keystore_management_v1_management_proto = out.File - file_plugin_keystore_management_v1_management_proto_goTypes = nil - file_plugin_keystore_management_v1_management_proto_depIdxs = nil -} diff --git a/proto/plugin/keystore/management/v1/management_ext_plugin.pb.go b/proto/plugin/keystore/management/v1/management_ext_plugin.pb.go deleted file mode 100644 index 8241336..0000000 --- a/proto/plugin/keystore/management/v1/management_ext_plugin.pb.go +++ /dev/null @@ -1,56 +0,0 @@ -// Code generated by protoc-gen-go-extension. DO NOT EDIT. - -package managementv1 - -import ( - grpc "google.golang.org/grpc" - - api "github.com/openkcm/plugin-sdk/api" -) - -const ( - Type = "KeystoreProvider" - GRPCServiceFullName = "plugin.keystore.management.v1.KeystoreProvider" -) - -func KeystoreProviderPluginServer(server KeystoreProviderServer) api.PluginServer { - return keystoreProviderPluginServer{KeystoreProviderServer: server} -} - -type keystoreProviderPluginServer struct { - KeystoreProviderServer -} - -func (s keystoreProviderPluginServer) Type() string { - return Type -} - -func (s keystoreProviderPluginServer) GRPCServiceName() string { - return GRPCServiceFullName -} - -func (s keystoreProviderPluginServer) RegisterServer(server *grpc.Server) any { - RegisterKeystoreProviderServer(server, s.KeystoreProviderServer) - return s.KeystoreProviderServer -} - -type KeystoreProviderPluginClient struct { - KeystoreProviderClient -} - -func (s KeystoreProviderPluginClient) Type() string { - return Type -} - -func (c *KeystoreProviderPluginClient) IsInitialized() bool { - return c.KeystoreProviderClient != nil -} - -func (c *KeystoreProviderPluginClient) GRPCServiceName() string { - return GRPCServiceFullName -} - -func (c *KeystoreProviderPluginClient) InitClient(conn grpc.ClientConnInterface) any { - c.KeystoreProviderClient = NewKeystoreProviderClient(conn) - return c.KeystoreProviderClient -} diff --git a/proto/plugin/keystore/management/v1/management_grpc.pb.go b/proto/plugin/keystore/management/v1/management_grpc.pb.go deleted file mode 100644 index 0f12e10..0000000 --- a/proto/plugin/keystore/management/v1/management_grpc.pb.go +++ /dev/null @@ -1,160 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.6.1 -// - protoc (unknown) -// source: plugin/keystore/management/v1/management.proto - -package managementv1 - -import ( - context "context" - - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - KeystoreProvider_CreateKeystore_FullMethodName = "/plugin.keystore.management.v1.KeystoreProvider/CreateKeystore" - KeystoreProvider_DeleteKeystore_FullMethodName = "/plugin.keystore.management.v1.KeystoreProvider/DeleteKeystore" -) - -// KeystoreProviderClient is the client API for KeystoreProvider service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type KeystoreProviderClient interface { - CreateKeystore(ctx context.Context, in *CreateKeystoreRequest, opts ...grpc.CallOption) (*CreateKeystoreResponse, error) - DeleteKeystore(ctx context.Context, in *DeleteKeystoreRequest, opts ...grpc.CallOption) (*DeleteKeystoreResponse, error) -} - -type keystoreProviderClient struct { - cc grpc.ClientConnInterface -} - -func NewKeystoreProviderClient(cc grpc.ClientConnInterface) KeystoreProviderClient { - return &keystoreProviderClient{cc} -} - -func (c *keystoreProviderClient) CreateKeystore(ctx context.Context, in *CreateKeystoreRequest, opts ...grpc.CallOption) (*CreateKeystoreResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CreateKeystoreResponse) - err := c.cc.Invoke(ctx, KeystoreProvider_CreateKeystore_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *keystoreProviderClient) DeleteKeystore(ctx context.Context, in *DeleteKeystoreRequest, opts ...grpc.CallOption) (*DeleteKeystoreResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(DeleteKeystoreResponse) - err := c.cc.Invoke(ctx, KeystoreProvider_DeleteKeystore_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// KeystoreProviderServer is the server API for KeystoreProvider service. -// All implementations must embed UnimplementedKeystoreProviderServer -// for forward compatibility. -type KeystoreProviderServer interface { - CreateKeystore(context.Context, *CreateKeystoreRequest) (*CreateKeystoreResponse, error) - DeleteKeystore(context.Context, *DeleteKeystoreRequest) (*DeleteKeystoreResponse, error) - mustEmbedUnimplementedKeystoreProviderServer() -} - -// UnimplementedKeystoreProviderServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedKeystoreProviderServer struct{} - -func (UnimplementedKeystoreProviderServer) CreateKeystore(context.Context, *CreateKeystoreRequest) (*CreateKeystoreResponse, error) { - return nil, status.Error(codes.Unimplemented, "method CreateKeystore not implemented") -} -func (UnimplementedKeystoreProviderServer) DeleteKeystore(context.Context, *DeleteKeystoreRequest) (*DeleteKeystoreResponse, error) { - return nil, status.Error(codes.Unimplemented, "method DeleteKeystore not implemented") -} -func (UnimplementedKeystoreProviderServer) mustEmbedUnimplementedKeystoreProviderServer() {} -func (UnimplementedKeystoreProviderServer) testEmbeddedByValue() {} - -// UnsafeKeystoreProviderServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to KeystoreProviderServer will -// result in compilation errors. -type UnsafeKeystoreProviderServer interface { - mustEmbedUnimplementedKeystoreProviderServer() -} - -func RegisterKeystoreProviderServer(s grpc.ServiceRegistrar, srv KeystoreProviderServer) { - // If the following call panics, it indicates UnimplementedKeystoreProviderServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&KeystoreProvider_ServiceDesc, srv) -} - -func _KeystoreProvider_CreateKeystore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateKeystoreRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(KeystoreProviderServer).CreateKeystore(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: KeystoreProvider_CreateKeystore_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(KeystoreProviderServer).CreateKeystore(ctx, req.(*CreateKeystoreRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _KeystoreProvider_DeleteKeystore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteKeystoreRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(KeystoreProviderServer).DeleteKeystore(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: KeystoreProvider_DeleteKeystore_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(KeystoreProviderServer).DeleteKeystore(ctx, req.(*DeleteKeystoreRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// KeystoreProvider_ServiceDesc is the grpc.ServiceDesc for KeystoreProvider service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var KeystoreProvider_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "plugin.keystore.management.v1.KeystoreProvider", - HandlerType: (*KeystoreProviderServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "CreateKeystore", - Handler: _KeystoreProvider_CreateKeystore_Handler, - }, - { - MethodName: "DeleteKeystore", - Handler: _KeystoreProvider_DeleteKeystore_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "plugin/keystore/management/v1/management.proto", -} diff --git a/proto/plugin/keystore/operations/v1/operations_ext_plugin.pb.go b/proto/plugin/keystore/operations/v1/operations_ext_plugin.pb.go deleted file mode 100644 index f7629b0..0000000 --- a/proto/plugin/keystore/operations/v1/operations_ext_plugin.pb.go +++ /dev/null @@ -1,56 +0,0 @@ -// Code generated by protoc-gen-go-extension. DO NOT EDIT. - -package operationsv1 - -import ( - grpc "google.golang.org/grpc" - - api "github.com/openkcm/plugin-sdk/api" -) - -const ( - Type = "KeystoreInstanceKeyOperation" - GRPCServiceFullName = "plugin.keystore.operations.v1.KeystoreInstanceKeyOperation" -) - -func KeystoreInstanceKeyOperationPluginServer(server KeystoreInstanceKeyOperationServer) api.PluginServer { - return keystoreInstanceKeyOperationPluginServer{KeystoreInstanceKeyOperationServer: server} -} - -type keystoreInstanceKeyOperationPluginServer struct { - KeystoreInstanceKeyOperationServer -} - -func (s keystoreInstanceKeyOperationPluginServer) Type() string { - return Type -} - -func (s keystoreInstanceKeyOperationPluginServer) GRPCServiceName() string { - return GRPCServiceFullName -} - -func (s keystoreInstanceKeyOperationPluginServer) RegisterServer(server *grpc.Server) any { - RegisterKeystoreInstanceKeyOperationServer(server, s.KeystoreInstanceKeyOperationServer) - return s.KeystoreInstanceKeyOperationServer -} - -type KeystoreInstanceKeyOperationPluginClient struct { - KeystoreInstanceKeyOperationClient -} - -func (s KeystoreInstanceKeyOperationPluginClient) Type() string { - return Type -} - -func (c *KeystoreInstanceKeyOperationPluginClient) IsInitialized() bool { - return c.KeystoreInstanceKeyOperationClient != nil -} - -func (c *KeystoreInstanceKeyOperationPluginClient) GRPCServiceName() string { - return GRPCServiceFullName -} - -func (c *KeystoreInstanceKeyOperationPluginClient) InitClient(conn grpc.ClientConnInterface) any { - c.KeystoreInstanceKeyOperationClient = NewKeystoreInstanceKeyOperationClient(conn) - return c.KeystoreInstanceKeyOperationClient -} diff --git a/proto/plugin/keystore/operations/v1/operations_grpc.pb.go b/proto/plugin/keystore/operations/v1/operations_grpc.pb.go deleted file mode 100644 index eef81c3..0000000 --- a/proto/plugin/keystore/operations/v1/operations_grpc.pb.go +++ /dev/null @@ -1,537 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.6.1 -// - protoc (unknown) -// source: plugin/keystore/operations/v1/operations.proto - -package operationsv1 - -import ( - context "context" - - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - KeystoreInstanceKeyOperation_GetKey_FullMethodName = "/plugin.keystore.operations.v1.KeystoreInstanceKeyOperation/GetKey" - KeystoreInstanceKeyOperation_CreateKey_FullMethodName = "/plugin.keystore.operations.v1.KeystoreInstanceKeyOperation/CreateKey" - KeystoreInstanceKeyOperation_DeleteKey_FullMethodName = "/plugin.keystore.operations.v1.KeystoreInstanceKeyOperation/DeleteKey" - KeystoreInstanceKeyOperation_EnableKey_FullMethodName = "/plugin.keystore.operations.v1.KeystoreInstanceKeyOperation/EnableKey" - KeystoreInstanceKeyOperation_DisableKey_FullMethodName = "/plugin.keystore.operations.v1.KeystoreInstanceKeyOperation/DisableKey" - KeystoreInstanceKeyOperation_GetImportParameters_FullMethodName = "/plugin.keystore.operations.v1.KeystoreInstanceKeyOperation/GetImportParameters" - KeystoreInstanceKeyOperation_ImportKeyMaterial_FullMethodName = "/plugin.keystore.operations.v1.KeystoreInstanceKeyOperation/ImportKeyMaterial" - KeystoreInstanceKeyOperation_ValidateKey_FullMethodName = "/plugin.keystore.operations.v1.KeystoreInstanceKeyOperation/ValidateKey" - KeystoreInstanceKeyOperation_ValidateKeyAccessData_FullMethodName = "/plugin.keystore.operations.v1.KeystoreInstanceKeyOperation/ValidateKeyAccessData" - KeystoreInstanceKeyOperation_TransformCryptoAccessData_FullMethodName = "/plugin.keystore.operations.v1.KeystoreInstanceKeyOperation/TransformCryptoAccessData" - KeystoreInstanceKeyOperation_ExtractKeyRegion_FullMethodName = "/plugin.keystore.operations.v1.KeystoreInstanceKeyOperation/ExtractKeyRegion" -) - -// KeystoreInstanceKeyOperationClient is the client API for KeystoreInstanceKeyOperation service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// KeystoreInstanceKeyOperation service defines the operations available for key management -type KeystoreInstanceKeyOperationClient interface { - // GetKey retrieves the details of a key by its ID - // * Returns error "code = InvalidArgument desc = failed to authenticate with the keystore provider" - // if the provided access data is invalid - // * Returns error "code = NotFound desc = key not found in the keystore provider" - // if the key does not exist - GetKey(ctx context.Context, in *GetKeyRequest, opts ...grpc.CallOption) (*GetKeyResponse, error) - // CreateKey generates a new key with the specified algorithm - CreateKey(ctx context.Context, in *CreateKeyRequest, opts ...grpc.CallOption) (*CreateKeyResponse, error) - // DeleteKey removes a key, optionally with a deletion window - DeleteKey(ctx context.Context, in *DeleteKeyRequest, opts ...grpc.CallOption) (*DeleteKeyResponse, error) - // EnableKey activates a previously disabled key - EnableKey(ctx context.Context, in *EnableKeyRequest, opts ...grpc.CallOption) (*EnableKeyResponse, error) - // DisableKey deactivates a key while maintaining its existence - DisableKey(ctx context.Context, in *DisableKeyRequest, opts ...grpc.CallOption) (*DisableKeyResponse, error) - // Gets the parameters needed for importing key material - GetImportParameters(ctx context.Context, in *GetImportParametersRequest, opts ...grpc.CallOption) (*GetImportParametersResponse, error) - // Imports key material into a KMS key - ImportKeyMaterial(ctx context.Context, in *ImportKeyMaterialRequest, opts ...grpc.CallOption) (*ImportKeyMaterialResponse, error) - // Validate the key attributes against the plugin's requirements - ValidateKey(ctx context.Context, in *ValidateKeyRequest, opts ...grpc.CallOption) (*ValidateKeyResponse, error) - // ValidateKeyAccessData checks the access data for key management and crypto operations - ValidateKeyAccessData(ctx context.Context, in *ValidateKeyAccessDataRequest, opts ...grpc.CallOption) (*ValidateKeyAccessDataResponse, error) - // TransformCryptoAccessData transforms the JSON-stored crypto access data into protobuf wire format for a given key - TransformCryptoAccessData(ctx context.Context, in *TransformCryptoAccessDataRequest, opts ...grpc.CallOption) (*TransformCryptoAccessDataResponse, error) - // ExtractKeyRegion extracts the region from key attributes - ExtractKeyRegion(ctx context.Context, in *ExtractKeyRegionRequest, opts ...grpc.CallOption) (*ExtractKeyRegionResponse, error) -} - -type keystoreInstanceKeyOperationClient struct { - cc grpc.ClientConnInterface -} - -func NewKeystoreInstanceKeyOperationClient(cc grpc.ClientConnInterface) KeystoreInstanceKeyOperationClient { - return &keystoreInstanceKeyOperationClient{cc} -} - -func (c *keystoreInstanceKeyOperationClient) GetKey(ctx context.Context, in *GetKeyRequest, opts ...grpc.CallOption) (*GetKeyResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetKeyResponse) - err := c.cc.Invoke(ctx, KeystoreInstanceKeyOperation_GetKey_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *keystoreInstanceKeyOperationClient) CreateKey(ctx context.Context, in *CreateKeyRequest, opts ...grpc.CallOption) (*CreateKeyResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CreateKeyResponse) - err := c.cc.Invoke(ctx, KeystoreInstanceKeyOperation_CreateKey_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *keystoreInstanceKeyOperationClient) DeleteKey(ctx context.Context, in *DeleteKeyRequest, opts ...grpc.CallOption) (*DeleteKeyResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(DeleteKeyResponse) - err := c.cc.Invoke(ctx, KeystoreInstanceKeyOperation_DeleteKey_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *keystoreInstanceKeyOperationClient) EnableKey(ctx context.Context, in *EnableKeyRequest, opts ...grpc.CallOption) (*EnableKeyResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(EnableKeyResponse) - err := c.cc.Invoke(ctx, KeystoreInstanceKeyOperation_EnableKey_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *keystoreInstanceKeyOperationClient) DisableKey(ctx context.Context, in *DisableKeyRequest, opts ...grpc.CallOption) (*DisableKeyResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(DisableKeyResponse) - err := c.cc.Invoke(ctx, KeystoreInstanceKeyOperation_DisableKey_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *keystoreInstanceKeyOperationClient) GetImportParameters(ctx context.Context, in *GetImportParametersRequest, opts ...grpc.CallOption) (*GetImportParametersResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetImportParametersResponse) - err := c.cc.Invoke(ctx, KeystoreInstanceKeyOperation_GetImportParameters_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *keystoreInstanceKeyOperationClient) ImportKeyMaterial(ctx context.Context, in *ImportKeyMaterialRequest, opts ...grpc.CallOption) (*ImportKeyMaterialResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ImportKeyMaterialResponse) - err := c.cc.Invoke(ctx, KeystoreInstanceKeyOperation_ImportKeyMaterial_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *keystoreInstanceKeyOperationClient) ValidateKey(ctx context.Context, in *ValidateKeyRequest, opts ...grpc.CallOption) (*ValidateKeyResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ValidateKeyResponse) - err := c.cc.Invoke(ctx, KeystoreInstanceKeyOperation_ValidateKey_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *keystoreInstanceKeyOperationClient) ValidateKeyAccessData(ctx context.Context, in *ValidateKeyAccessDataRequest, opts ...grpc.CallOption) (*ValidateKeyAccessDataResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ValidateKeyAccessDataResponse) - err := c.cc.Invoke(ctx, KeystoreInstanceKeyOperation_ValidateKeyAccessData_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *keystoreInstanceKeyOperationClient) TransformCryptoAccessData(ctx context.Context, in *TransformCryptoAccessDataRequest, opts ...grpc.CallOption) (*TransformCryptoAccessDataResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(TransformCryptoAccessDataResponse) - err := c.cc.Invoke(ctx, KeystoreInstanceKeyOperation_TransformCryptoAccessData_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *keystoreInstanceKeyOperationClient) ExtractKeyRegion(ctx context.Context, in *ExtractKeyRegionRequest, opts ...grpc.CallOption) (*ExtractKeyRegionResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ExtractKeyRegionResponse) - err := c.cc.Invoke(ctx, KeystoreInstanceKeyOperation_ExtractKeyRegion_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// KeystoreInstanceKeyOperationServer is the server API for KeystoreInstanceKeyOperation service. -// All implementations must embed UnimplementedKeystoreInstanceKeyOperationServer -// for forward compatibility. -// -// KeystoreInstanceKeyOperation service defines the operations available for key management -type KeystoreInstanceKeyOperationServer interface { - // GetKey retrieves the details of a key by its ID - // * Returns error "code = InvalidArgument desc = failed to authenticate with the keystore provider" - // if the provided access data is invalid - // * Returns error "code = NotFound desc = key not found in the keystore provider" - // if the key does not exist - GetKey(context.Context, *GetKeyRequest) (*GetKeyResponse, error) - // CreateKey generates a new key with the specified algorithm - CreateKey(context.Context, *CreateKeyRequest) (*CreateKeyResponse, error) - // DeleteKey removes a key, optionally with a deletion window - DeleteKey(context.Context, *DeleteKeyRequest) (*DeleteKeyResponse, error) - // EnableKey activates a previously disabled key - EnableKey(context.Context, *EnableKeyRequest) (*EnableKeyResponse, error) - // DisableKey deactivates a key while maintaining its existence - DisableKey(context.Context, *DisableKeyRequest) (*DisableKeyResponse, error) - // Gets the parameters needed for importing key material - GetImportParameters(context.Context, *GetImportParametersRequest) (*GetImportParametersResponse, error) - // Imports key material into a KMS key - ImportKeyMaterial(context.Context, *ImportKeyMaterialRequest) (*ImportKeyMaterialResponse, error) - // Validate the key attributes against the plugin's requirements - ValidateKey(context.Context, *ValidateKeyRequest) (*ValidateKeyResponse, error) - // ValidateKeyAccessData checks the access data for key management and crypto operations - ValidateKeyAccessData(context.Context, *ValidateKeyAccessDataRequest) (*ValidateKeyAccessDataResponse, error) - // TransformCryptoAccessData transforms the JSON-stored crypto access data into protobuf wire format for a given key - TransformCryptoAccessData(context.Context, *TransformCryptoAccessDataRequest) (*TransformCryptoAccessDataResponse, error) - // ExtractKeyRegion extracts the region from key attributes - ExtractKeyRegion(context.Context, *ExtractKeyRegionRequest) (*ExtractKeyRegionResponse, error) - mustEmbedUnimplementedKeystoreInstanceKeyOperationServer() -} - -// UnimplementedKeystoreInstanceKeyOperationServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedKeystoreInstanceKeyOperationServer struct{} - -func (UnimplementedKeystoreInstanceKeyOperationServer) GetKey(context.Context, *GetKeyRequest) (*GetKeyResponse, error) { - return nil, status.Error(codes.Unimplemented, "method GetKey not implemented") -} -func (UnimplementedKeystoreInstanceKeyOperationServer) CreateKey(context.Context, *CreateKeyRequest) (*CreateKeyResponse, error) { - return nil, status.Error(codes.Unimplemented, "method CreateKey not implemented") -} -func (UnimplementedKeystoreInstanceKeyOperationServer) DeleteKey(context.Context, *DeleteKeyRequest) (*DeleteKeyResponse, error) { - return nil, status.Error(codes.Unimplemented, "method DeleteKey not implemented") -} -func (UnimplementedKeystoreInstanceKeyOperationServer) EnableKey(context.Context, *EnableKeyRequest) (*EnableKeyResponse, error) { - return nil, status.Error(codes.Unimplemented, "method EnableKey not implemented") -} -func (UnimplementedKeystoreInstanceKeyOperationServer) DisableKey(context.Context, *DisableKeyRequest) (*DisableKeyResponse, error) { - return nil, status.Error(codes.Unimplemented, "method DisableKey not implemented") -} -func (UnimplementedKeystoreInstanceKeyOperationServer) GetImportParameters(context.Context, *GetImportParametersRequest) (*GetImportParametersResponse, error) { - return nil, status.Error(codes.Unimplemented, "method GetImportParameters not implemented") -} -func (UnimplementedKeystoreInstanceKeyOperationServer) ImportKeyMaterial(context.Context, *ImportKeyMaterialRequest) (*ImportKeyMaterialResponse, error) { - return nil, status.Error(codes.Unimplemented, "method ImportKeyMaterial not implemented") -} -func (UnimplementedKeystoreInstanceKeyOperationServer) ValidateKey(context.Context, *ValidateKeyRequest) (*ValidateKeyResponse, error) { - return nil, status.Error(codes.Unimplemented, "method ValidateKey not implemented") -} -func (UnimplementedKeystoreInstanceKeyOperationServer) ValidateKeyAccessData(context.Context, *ValidateKeyAccessDataRequest) (*ValidateKeyAccessDataResponse, error) { - return nil, status.Error(codes.Unimplemented, "method ValidateKeyAccessData not implemented") -} -func (UnimplementedKeystoreInstanceKeyOperationServer) TransformCryptoAccessData(context.Context, *TransformCryptoAccessDataRequest) (*TransformCryptoAccessDataResponse, error) { - return nil, status.Error(codes.Unimplemented, "method TransformCryptoAccessData not implemented") -} -func (UnimplementedKeystoreInstanceKeyOperationServer) ExtractKeyRegion(context.Context, *ExtractKeyRegionRequest) (*ExtractKeyRegionResponse, error) { - return nil, status.Error(codes.Unimplemented, "method ExtractKeyRegion not implemented") -} -func (UnimplementedKeystoreInstanceKeyOperationServer) mustEmbedUnimplementedKeystoreInstanceKeyOperationServer() { -} -func (UnimplementedKeystoreInstanceKeyOperationServer) testEmbeddedByValue() {} - -// UnsafeKeystoreInstanceKeyOperationServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to KeystoreInstanceKeyOperationServer will -// result in compilation errors. -type UnsafeKeystoreInstanceKeyOperationServer interface { - mustEmbedUnimplementedKeystoreInstanceKeyOperationServer() -} - -func RegisterKeystoreInstanceKeyOperationServer(s grpc.ServiceRegistrar, srv KeystoreInstanceKeyOperationServer) { - // If the following call panics, it indicates UnimplementedKeystoreInstanceKeyOperationServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&KeystoreInstanceKeyOperation_ServiceDesc, srv) -} - -func _KeystoreInstanceKeyOperation_GetKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetKeyRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(KeystoreInstanceKeyOperationServer).GetKey(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: KeystoreInstanceKeyOperation_GetKey_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(KeystoreInstanceKeyOperationServer).GetKey(ctx, req.(*GetKeyRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _KeystoreInstanceKeyOperation_CreateKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateKeyRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(KeystoreInstanceKeyOperationServer).CreateKey(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: KeystoreInstanceKeyOperation_CreateKey_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(KeystoreInstanceKeyOperationServer).CreateKey(ctx, req.(*CreateKeyRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _KeystoreInstanceKeyOperation_DeleteKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteKeyRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(KeystoreInstanceKeyOperationServer).DeleteKey(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: KeystoreInstanceKeyOperation_DeleteKey_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(KeystoreInstanceKeyOperationServer).DeleteKey(ctx, req.(*DeleteKeyRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _KeystoreInstanceKeyOperation_EnableKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(EnableKeyRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(KeystoreInstanceKeyOperationServer).EnableKey(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: KeystoreInstanceKeyOperation_EnableKey_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(KeystoreInstanceKeyOperationServer).EnableKey(ctx, req.(*EnableKeyRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _KeystoreInstanceKeyOperation_DisableKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DisableKeyRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(KeystoreInstanceKeyOperationServer).DisableKey(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: KeystoreInstanceKeyOperation_DisableKey_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(KeystoreInstanceKeyOperationServer).DisableKey(ctx, req.(*DisableKeyRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _KeystoreInstanceKeyOperation_GetImportParameters_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetImportParametersRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(KeystoreInstanceKeyOperationServer).GetImportParameters(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: KeystoreInstanceKeyOperation_GetImportParameters_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(KeystoreInstanceKeyOperationServer).GetImportParameters(ctx, req.(*GetImportParametersRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _KeystoreInstanceKeyOperation_ImportKeyMaterial_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ImportKeyMaterialRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(KeystoreInstanceKeyOperationServer).ImportKeyMaterial(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: KeystoreInstanceKeyOperation_ImportKeyMaterial_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(KeystoreInstanceKeyOperationServer).ImportKeyMaterial(ctx, req.(*ImportKeyMaterialRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _KeystoreInstanceKeyOperation_ValidateKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ValidateKeyRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(KeystoreInstanceKeyOperationServer).ValidateKey(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: KeystoreInstanceKeyOperation_ValidateKey_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(KeystoreInstanceKeyOperationServer).ValidateKey(ctx, req.(*ValidateKeyRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _KeystoreInstanceKeyOperation_ValidateKeyAccessData_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ValidateKeyAccessDataRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(KeystoreInstanceKeyOperationServer).ValidateKeyAccessData(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: KeystoreInstanceKeyOperation_ValidateKeyAccessData_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(KeystoreInstanceKeyOperationServer).ValidateKeyAccessData(ctx, req.(*ValidateKeyAccessDataRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _KeystoreInstanceKeyOperation_TransformCryptoAccessData_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(TransformCryptoAccessDataRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(KeystoreInstanceKeyOperationServer).TransformCryptoAccessData(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: KeystoreInstanceKeyOperation_TransformCryptoAccessData_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(KeystoreInstanceKeyOperationServer).TransformCryptoAccessData(ctx, req.(*TransformCryptoAccessDataRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _KeystoreInstanceKeyOperation_ExtractKeyRegion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ExtractKeyRegionRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(KeystoreInstanceKeyOperationServer).ExtractKeyRegion(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: KeystoreInstanceKeyOperation_ExtractKeyRegion_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(KeystoreInstanceKeyOperationServer).ExtractKeyRegion(ctx, req.(*ExtractKeyRegionRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// KeystoreInstanceKeyOperation_ServiceDesc is the grpc.ServiceDesc for KeystoreInstanceKeyOperation service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var KeystoreInstanceKeyOperation_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "plugin.keystore.operations.v1.KeystoreInstanceKeyOperation", - HandlerType: (*KeystoreInstanceKeyOperationServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "GetKey", - Handler: _KeystoreInstanceKeyOperation_GetKey_Handler, - }, - { - MethodName: "CreateKey", - Handler: _KeystoreInstanceKeyOperation_CreateKey_Handler, - }, - { - MethodName: "DeleteKey", - Handler: _KeystoreInstanceKeyOperation_DeleteKey_Handler, - }, - { - MethodName: "EnableKey", - Handler: _KeystoreInstanceKeyOperation_EnableKey_Handler, - }, - { - MethodName: "DisableKey", - Handler: _KeystoreInstanceKeyOperation_DisableKey_Handler, - }, - { - MethodName: "GetImportParameters", - Handler: _KeystoreInstanceKeyOperation_GetImportParameters_Handler, - }, - { - MethodName: "ImportKeyMaterial", - Handler: _KeystoreInstanceKeyOperation_ImportKeyMaterial_Handler, - }, - { - MethodName: "ValidateKey", - Handler: _KeystoreInstanceKeyOperation_ValidateKey_Handler, - }, - { - MethodName: "ValidateKeyAccessData", - Handler: _KeystoreInstanceKeyOperation_ValidateKeyAccessData_Handler, - }, - { - MethodName: "TransformCryptoAccessData", - Handler: _KeystoreInstanceKeyOperation_TransformCryptoAccessData_Handler, - }, - { - MethodName: "ExtractKeyRegion", - Handler: _KeystoreInstanceKeyOperation_ExtractKeyRegion_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "plugin/keystore/operations/v1/operations.proto", -} diff --git a/proto/plugin/keystore_management/v1/keystore_management.pb.go b/proto/plugin/keystore_management/v1/keystore_management.pb.go new file mode 100644 index 0000000..59cf08d --- /dev/null +++ b/proto/plugin/keystore_management/v1/keystore_management.pb.go @@ -0,0 +1,271 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc (unknown) +// source: plugin/keystore_management/v1/keystore_management.proto + +package keystore_managementv1 + +import ( + reflect "reflect" + sync "sync" + unsafe "unsafe" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + structpb "google.golang.org/protobuf/types/known/structpb" + + v1 "github.com/openkcm/plugin-sdk/proto/plugin/common/v1" +) + +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 CreateKeystoreRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + ConfigurationParameters *structpb.Struct `protobuf:"bytes,1,opt,name=configuration_parameters,json=configurationParameters,proto3" json:"configuration_parameters,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateKeystoreRequest) Reset() { + *x = CreateKeystoreRequest{} + mi := &file_plugin_keystore_management_v1_keystore_management_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateKeystoreRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateKeystoreRequest) ProtoMessage() {} + +func (x *CreateKeystoreRequest) ProtoReflect() protoreflect.Message { + mi := &file_plugin_keystore_management_v1_keystore_management_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 CreateKeystoreRequest.ProtoReflect.Descriptor instead. +func (*CreateKeystoreRequest) Descriptor() ([]byte, []int) { + return file_plugin_keystore_management_v1_keystore_management_proto_rawDescGZIP(), []int{0} +} + +func (x *CreateKeystoreRequest) GetConfigurationParameters() *structpb.Struct { + if x != nil { + return x.ConfigurationParameters + } + return nil +} + +type CreateKeystoreResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Config *v1.KeystoreConfig `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateKeystoreResponse) Reset() { + *x = CreateKeystoreResponse{} + mi := &file_plugin_keystore_management_v1_keystore_management_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateKeystoreResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateKeystoreResponse) ProtoMessage() {} + +func (x *CreateKeystoreResponse) ProtoReflect() protoreflect.Message { + mi := &file_plugin_keystore_management_v1_keystore_management_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 CreateKeystoreResponse.ProtoReflect.Descriptor instead. +func (*CreateKeystoreResponse) Descriptor() ([]byte, []int) { + return file_plugin_keystore_management_v1_keystore_management_proto_rawDescGZIP(), []int{1} +} + +func (x *CreateKeystoreResponse) GetConfig() *v1.KeystoreConfig { + if x != nil { + return x.Config + } + return nil +} + +type DeleteKeystoreRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Config *v1.KeystoreConfig `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteKeystoreRequest) Reset() { + *x = DeleteKeystoreRequest{} + mi := &file_plugin_keystore_management_v1_keystore_management_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteKeystoreRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteKeystoreRequest) ProtoMessage() {} + +func (x *DeleteKeystoreRequest) ProtoReflect() protoreflect.Message { + mi := &file_plugin_keystore_management_v1_keystore_management_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 DeleteKeystoreRequest.ProtoReflect.Descriptor instead. +func (*DeleteKeystoreRequest) Descriptor() ([]byte, []int) { + return file_plugin_keystore_management_v1_keystore_management_proto_rawDescGZIP(), []int{2} +} + +func (x *DeleteKeystoreRequest) GetConfig() *v1.KeystoreConfig { + if x != nil { + return x.Config + } + return nil +} + +type DeleteKeystoreResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteKeystoreResponse) Reset() { + *x = DeleteKeystoreResponse{} + mi := &file_plugin_keystore_management_v1_keystore_management_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteKeystoreResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteKeystoreResponse) ProtoMessage() {} + +func (x *DeleteKeystoreResponse) ProtoReflect() protoreflect.Message { + mi := &file_plugin_keystore_management_v1_keystore_management_proto_msgTypes[3] + 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 DeleteKeystoreResponse.ProtoReflect.Descriptor instead. +func (*DeleteKeystoreResponse) Descriptor() ([]byte, []int) { + return file_plugin_keystore_management_v1_keystore_management_proto_rawDescGZIP(), []int{3} +} + +var File_plugin_keystore_management_v1_keystore_management_proto protoreflect.FileDescriptor + +const file_plugin_keystore_management_v1_keystore_management_proto_rawDesc = "" + + "\n" + + "7plugin/keystore_management/v1/keystore_management.proto\x12\x1dplugin.keystore_management.v1\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1dplugin/common/v1/common.proto\"k\n" + + "\x15CreateKeystoreRequest\x12R\n" + + "\x18configuration_parameters\x18\x01 \x01(\v2\x17.google.protobuf.StructR\x17configurationParameters\"R\n" + + "\x16CreateKeystoreResponse\x128\n" + + "\x06config\x18\x01 \x01(\v2 .plugin.common.v1.KeystoreConfigR\x06config\"Q\n" + + "\x15DeleteKeystoreRequest\x128\n" + + "\x06config\x18\x01 \x01(\v2 .plugin.common.v1.KeystoreConfigR\x06config\"\x18\n" + + "\x16DeleteKeystoreResponse2\x92\x02\n" + + "\x12KeystoreManagement\x12}\n" + + "\x0eCreateKeystore\x124.plugin.keystore_management.v1.CreateKeystoreRequest\x1a5.plugin.keystore_management.v1.CreateKeystoreResponse\x12}\n" + + "\x0eDeleteKeystore\x124.plugin.keystore_management.v1.DeleteKeystoreRequest\x1a5.plugin.keystore_management.v1.DeleteKeystoreResponseB\xa7\x02\n" + + "!com.plugin.keystore_management.v1B\x17KeystoreManagementProtoP\x01ZWgithub.com/openkcm/plugin-sdk/proto/plugin/keystore_management/v1;keystore_managementv1\xa2\x02\x03PKX\xaa\x02\x1cPlugin.KeystoreManagement.V1\xca\x02\x1cPlugin\\KeystoreManagement\\V1\xe2\x02(Plugin\\KeystoreManagement\\V1\\GPBMetadata\xea\x02\x1ePlugin::KeystoreManagement::V1b\x06proto3" + +var ( + file_plugin_keystore_management_v1_keystore_management_proto_rawDescOnce sync.Once + file_plugin_keystore_management_v1_keystore_management_proto_rawDescData []byte +) + +func file_plugin_keystore_management_v1_keystore_management_proto_rawDescGZIP() []byte { + file_plugin_keystore_management_v1_keystore_management_proto_rawDescOnce.Do(func() { + file_plugin_keystore_management_v1_keystore_management_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_plugin_keystore_management_v1_keystore_management_proto_rawDesc), len(file_plugin_keystore_management_v1_keystore_management_proto_rawDesc))) + }) + return file_plugin_keystore_management_v1_keystore_management_proto_rawDescData +} + +var file_plugin_keystore_management_v1_keystore_management_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_plugin_keystore_management_v1_keystore_management_proto_goTypes = []any{ + (*CreateKeystoreRequest)(nil), // 0: plugin.keystore_management.v1.CreateKeystoreRequest + (*CreateKeystoreResponse)(nil), // 1: plugin.keystore_management.v1.CreateKeystoreResponse + (*DeleteKeystoreRequest)(nil), // 2: plugin.keystore_management.v1.DeleteKeystoreRequest + (*DeleteKeystoreResponse)(nil), // 3: plugin.keystore_management.v1.DeleteKeystoreResponse + (*structpb.Struct)(nil), // 4: google.protobuf.Struct + (*v1.KeystoreConfig)(nil), // 5: plugin.common.v1.KeystoreConfig +} +var file_plugin_keystore_management_v1_keystore_management_proto_depIdxs = []int32{ + 4, // 0: plugin.keystore_management.v1.CreateKeystoreRequest.configuration_parameters:type_name -> google.protobuf.Struct + 5, // 1: plugin.keystore_management.v1.CreateKeystoreResponse.config:type_name -> plugin.common.v1.KeystoreConfig + 5, // 2: plugin.keystore_management.v1.DeleteKeystoreRequest.config:type_name -> plugin.common.v1.KeystoreConfig + 0, // 3: plugin.keystore_management.v1.KeystoreManagement.CreateKeystore:input_type -> plugin.keystore_management.v1.CreateKeystoreRequest + 2, // 4: plugin.keystore_management.v1.KeystoreManagement.DeleteKeystore:input_type -> plugin.keystore_management.v1.DeleteKeystoreRequest + 1, // 5: plugin.keystore_management.v1.KeystoreManagement.CreateKeystore:output_type -> plugin.keystore_management.v1.CreateKeystoreResponse + 3, // 6: plugin.keystore_management.v1.KeystoreManagement.DeleteKeystore:output_type -> plugin.keystore_management.v1.DeleteKeystoreResponse + 5, // [5:7] is the sub-list for method output_type + 3, // [3:5] 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_plugin_keystore_management_v1_keystore_management_proto_init() } +func file_plugin_keystore_management_v1_keystore_management_proto_init() { + if File_plugin_keystore_management_v1_keystore_management_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_plugin_keystore_management_v1_keystore_management_proto_rawDesc), len(file_plugin_keystore_management_v1_keystore_management_proto_rawDesc)), + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_plugin_keystore_management_v1_keystore_management_proto_goTypes, + DependencyIndexes: file_plugin_keystore_management_v1_keystore_management_proto_depIdxs, + MessageInfos: file_plugin_keystore_management_v1_keystore_management_proto_msgTypes, + }.Build() + File_plugin_keystore_management_v1_keystore_management_proto = out.File + file_plugin_keystore_management_v1_keystore_management_proto_goTypes = nil + file_plugin_keystore_management_v1_keystore_management_proto_depIdxs = nil +} diff --git a/proto/plugin/keystore/management/v1/management.pb.validate.go b/proto/plugin/keystore_management/v1/keystore_management.pb.validate.go similarity index 97% rename from proto/plugin/keystore/management/v1/management.pb.validate.go rename to proto/plugin/keystore_management/v1/keystore_management.pb.validate.go index 1610df6..d8cd11d 100644 --- a/proto/plugin/keystore/management/v1/management.pb.validate.go +++ b/proto/plugin/keystore_management/v1/keystore_management.pb.validate.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-validate. DO NOT EDIT. -// source: plugin/keystore/management/v1/management.proto +// source: plugin/keystore_management/v1/keystore_management.proto -package managementv1 +package keystore_managementv1 import ( "bytes" @@ -58,11 +58,11 @@ func (m *CreateKeystoreRequest) validate(all bool) error { var errors []error if all { - switch v := interface{}(m.GetValues()).(type) { + switch v := interface{}(m.GetConfigurationParameters()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, CreateKeystoreRequestValidationError{ - field: "Values", + field: "ConfigurationParameters", reason: "embedded message failed validation", cause: err, }) @@ -70,16 +70,16 @@ func (m *CreateKeystoreRequest) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, CreateKeystoreRequestValidationError{ - field: "Values", + field: "ConfigurationParameters", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetValues()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetConfigurationParameters()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CreateKeystoreRequestValidationError{ - field: "Values", + field: "ConfigurationParameters", reason: "embedded message failed validation", cause: err, } diff --git a/proto/plugin/keystore/management/v1/management.proto b/proto/plugin/keystore_management/v1/keystore_management.proto similarity index 56% rename from proto/plugin/keystore/management/v1/management.proto rename to proto/plugin/keystore_management/v1/keystore_management.proto index 22d90e0..90e1c4d 100644 --- a/proto/plugin/keystore/management/v1/management.proto +++ b/proto/plugin/keystore_management/v1/keystore_management.proto @@ -1,24 +1,24 @@ syntax = "proto3"; -package plugin.keystore.management.v1; +package plugin.keystore_management.v1; import "google/protobuf/struct.proto"; -import "plugin/keystore/common/v1/common.proto"; +import "plugin/common/v1/common.proto"; -service KeystoreProvider { +service KeystoreManagement { rpc CreateKeystore(CreateKeystoreRequest) returns (CreateKeystoreResponse); rpc DeleteKeystore(DeleteKeystoreRequest) returns (DeleteKeystoreResponse); } message CreateKeystoreRequest { - google.protobuf.Struct values = 1; + google.protobuf.Struct configuration_parameters = 1; } message CreateKeystoreResponse { - plugin.keystore.common.v1.KeystoreInstanceConfig config = 1; + plugin.common.v1.KeystoreConfig config = 1; } message DeleteKeystoreRequest { - plugin.keystore.common.v1.KeystoreInstanceConfig config = 1; + plugin.common.v1.KeystoreConfig config = 1; } message DeleteKeystoreResponse {} diff --git a/proto/plugin/keystore_management/v1/keystore_management_ext_plugin.pb.go b/proto/plugin/keystore_management/v1/keystore_management_ext_plugin.pb.go new file mode 100644 index 0000000..cd501bb --- /dev/null +++ b/proto/plugin/keystore_management/v1/keystore_management_ext_plugin.pb.go @@ -0,0 +1,56 @@ +// Code generated by protoc-gen-go-extension. DO NOT EDIT. + +package keystore_managementv1 + +import ( + grpc "google.golang.org/grpc" + + api "github.com/openkcm/plugin-sdk/api" +) + +const ( + Type = "KeystoreManagement" + GRPCServiceFullName = "plugin.keystore_management.v1.KeystoreManagement" +) + +func KeystoreManagementPluginServer(server KeystoreManagementServer) api.PluginServer { + return keystoreManagementPluginServer{KeystoreManagementServer: server} +} + +type keystoreManagementPluginServer struct { + KeystoreManagementServer +} + +func (s keystoreManagementPluginServer) Type() string { + return Type +} + +func (s keystoreManagementPluginServer) GRPCServiceName() string { + return GRPCServiceFullName +} + +func (s keystoreManagementPluginServer) RegisterServer(server *grpc.Server) any { + RegisterKeystoreManagementServer(server, s.KeystoreManagementServer) + return s.KeystoreManagementServer +} + +type KeystoreManagementPluginClient struct { + KeystoreManagementClient +} + +func (s KeystoreManagementPluginClient) Type() string { + return Type +} + +func (c *KeystoreManagementPluginClient) IsInitialized() bool { + return c.KeystoreManagementClient != nil +} + +func (c *KeystoreManagementPluginClient) GRPCServiceName() string { + return GRPCServiceFullName +} + +func (c *KeystoreManagementPluginClient) InitClient(conn grpc.ClientConnInterface) any { + c.KeystoreManagementClient = NewKeystoreManagementClient(conn) + return c.KeystoreManagementClient +} diff --git a/proto/plugin/keystore_management/v1/keystore_management_grpc.pb.go b/proto/plugin/keystore_management/v1/keystore_management_grpc.pb.go new file mode 100644 index 0000000..61b4712 --- /dev/null +++ b/proto/plugin/keystore_management/v1/keystore_management_grpc.pb.go @@ -0,0 +1,160 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.6.1 +// - protoc (unknown) +// source: plugin/keystore_management/v1/keystore_management.proto + +package keystore_managementv1 + +import ( + context "context" + + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + KeystoreManagement_CreateKeystore_FullMethodName = "/plugin.keystore_management.v1.KeystoreManagement/CreateKeystore" + KeystoreManagement_DeleteKeystore_FullMethodName = "/plugin.keystore_management.v1.KeystoreManagement/DeleteKeystore" +) + +// KeystoreManagementClient is the client API for KeystoreManagement service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type KeystoreManagementClient interface { + CreateKeystore(ctx context.Context, in *CreateKeystoreRequest, opts ...grpc.CallOption) (*CreateKeystoreResponse, error) + DeleteKeystore(ctx context.Context, in *DeleteKeystoreRequest, opts ...grpc.CallOption) (*DeleteKeystoreResponse, error) +} + +type keystoreManagementClient struct { + cc grpc.ClientConnInterface +} + +func NewKeystoreManagementClient(cc grpc.ClientConnInterface) KeystoreManagementClient { + return &keystoreManagementClient{cc} +} + +func (c *keystoreManagementClient) CreateKeystore(ctx context.Context, in *CreateKeystoreRequest, opts ...grpc.CallOption) (*CreateKeystoreResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CreateKeystoreResponse) + err := c.cc.Invoke(ctx, KeystoreManagement_CreateKeystore_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *keystoreManagementClient) DeleteKeystore(ctx context.Context, in *DeleteKeystoreRequest, opts ...grpc.CallOption) (*DeleteKeystoreResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DeleteKeystoreResponse) + err := c.cc.Invoke(ctx, KeystoreManagement_DeleteKeystore_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// KeystoreManagementServer is the server API for KeystoreManagement service. +// All implementations must embed UnimplementedKeystoreManagementServer +// for forward compatibility. +type KeystoreManagementServer interface { + CreateKeystore(context.Context, *CreateKeystoreRequest) (*CreateKeystoreResponse, error) + DeleteKeystore(context.Context, *DeleteKeystoreRequest) (*DeleteKeystoreResponse, error) + mustEmbedUnimplementedKeystoreManagementServer() +} + +// UnimplementedKeystoreManagementServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedKeystoreManagementServer struct{} + +func (UnimplementedKeystoreManagementServer) CreateKeystore(context.Context, *CreateKeystoreRequest) (*CreateKeystoreResponse, error) { + return nil, status.Error(codes.Unimplemented, "method CreateKeystore not implemented") +} +func (UnimplementedKeystoreManagementServer) DeleteKeystore(context.Context, *DeleteKeystoreRequest) (*DeleteKeystoreResponse, error) { + return nil, status.Error(codes.Unimplemented, "method DeleteKeystore not implemented") +} +func (UnimplementedKeystoreManagementServer) mustEmbedUnimplementedKeystoreManagementServer() {} +func (UnimplementedKeystoreManagementServer) testEmbeddedByValue() {} + +// UnsafeKeystoreManagementServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to KeystoreManagementServer will +// result in compilation errors. +type UnsafeKeystoreManagementServer interface { + mustEmbedUnimplementedKeystoreManagementServer() +} + +func RegisterKeystoreManagementServer(s grpc.ServiceRegistrar, srv KeystoreManagementServer) { + // If the following call panics, it indicates UnimplementedKeystoreManagementServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&KeystoreManagement_ServiceDesc, srv) +} + +func _KeystoreManagement_CreateKeystore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateKeystoreRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KeystoreManagementServer).CreateKeystore(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: KeystoreManagement_CreateKeystore_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KeystoreManagementServer).CreateKeystore(ctx, req.(*CreateKeystoreRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _KeystoreManagement_DeleteKeystore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteKeystoreRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KeystoreManagementServer).DeleteKeystore(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: KeystoreManagement_DeleteKeystore_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KeystoreManagementServer).DeleteKeystore(ctx, req.(*DeleteKeystoreRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// KeystoreManagement_ServiceDesc is the grpc.ServiceDesc for KeystoreManagement service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var KeystoreManagement_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "plugin.keystore_management.v1.KeystoreManagement", + HandlerType: (*KeystoreManagementServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateKeystore", + Handler: _KeystoreManagement_CreateKeystore_Handler, + }, + { + MethodName: "DeleteKeystore", + Handler: _KeystoreManagement_DeleteKeystore_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "plugin/keystore_management/v1/keystore_management.proto", +} diff --git a/proto/plugin/notification/v1/notification.pb.go b/proto/plugin/notification/v1/notification.pb.go index 91e7f74..5536a51 100644 --- a/proto/plugin/notification/v1/notification.pb.go +++ b/proto/plugin/notification/v1/notification.pb.go @@ -22,64 +22,72 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type NotificationType int32 +// Standardized channels, using the '0' prefix best practice. +type DeliveryChannel int32 const ( - NotificationType_NOTIFICATION_TYPE_UNSPECIFIED NotificationType = 0 // Unspecified notification type - NotificationType_NOTIFICATION_TYPE_EMAIL NotificationType = 1 // Email notification - NotificationType_NOTIFICATION_TYPE_TEXT NotificationType = 2 // Text message notification - NotificationType_NOTIFICATION_TYPE_WEB NotificationType = 3 // Web notification + DeliveryChannel_DELIVERY_CHANNEL_UNSPECIFIED DeliveryChannel = 0 + DeliveryChannel_DELIVERY_CHANNEL_EMAIL DeliveryChannel = 1 + DeliveryChannel_DELIVERY_CHANNEL_SMS DeliveryChannel = 2 + DeliveryChannel_DELIVERY_CHANNEL_PUSH DeliveryChannel = 3 + DeliveryChannel_DELIVERY_CHANNEL_IN_APP DeliveryChannel = 4 ) -// Enum value maps for NotificationType. +// Enum value maps for DeliveryChannel. var ( - NotificationType_name = map[int32]string{ - 0: "NOTIFICATION_TYPE_UNSPECIFIED", - 1: "NOTIFICATION_TYPE_EMAIL", - 2: "NOTIFICATION_TYPE_TEXT", - 3: "NOTIFICATION_TYPE_WEB", - } - NotificationType_value = map[string]int32{ - "NOTIFICATION_TYPE_UNSPECIFIED": 0, - "NOTIFICATION_TYPE_EMAIL": 1, - "NOTIFICATION_TYPE_TEXT": 2, - "NOTIFICATION_TYPE_WEB": 3, + DeliveryChannel_name = map[int32]string{ + 0: "DELIVERY_CHANNEL_UNSPECIFIED", + 1: "DELIVERY_CHANNEL_EMAIL", + 2: "DELIVERY_CHANNEL_SMS", + 3: "DELIVERY_CHANNEL_PUSH", + 4: "DELIVERY_CHANNEL_IN_APP", + } + DeliveryChannel_value = map[string]int32{ + "DELIVERY_CHANNEL_UNSPECIFIED": 0, + "DELIVERY_CHANNEL_EMAIL": 1, + "DELIVERY_CHANNEL_SMS": 2, + "DELIVERY_CHANNEL_PUSH": 3, + "DELIVERY_CHANNEL_IN_APP": 4, } ) -func (x NotificationType) Enum() *NotificationType { - p := new(NotificationType) +func (x DeliveryChannel) Enum() *DeliveryChannel { + p := new(DeliveryChannel) *p = x return p } -func (x NotificationType) String() string { +func (x DeliveryChannel) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -func (NotificationType) Descriptor() protoreflect.EnumDescriptor { +func (DeliveryChannel) Descriptor() protoreflect.EnumDescriptor { return file_plugin_notification_v1_notification_proto_enumTypes[0].Descriptor() } -func (NotificationType) Type() protoreflect.EnumType { +func (DeliveryChannel) Type() protoreflect.EnumType { return &file_plugin_notification_v1_notification_proto_enumTypes[0] } -func (x NotificationType) Number() protoreflect.EnumNumber { +func (x DeliveryChannel) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } -// Deprecated: Use NotificationType.Descriptor instead. -func (NotificationType) EnumDescriptor() ([]byte, []int) { +// Deprecated: Use DeliveryChannel.Descriptor instead. +func (DeliveryChannel) EnumDescriptor() ([]byte, []int) { return file_plugin_notification_v1_notification_proto_rawDescGZIP(), []int{0} } +// Represents the request to send a notification. type SendNotificationRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - NotificationType NotificationType `protobuf:"varint,1,opt,name=notification_type,json=notificationType,proto3,enum=plugin.notification.v1.NotificationType" json:"notification_type,omitempty"` // Type of notification (e.g., Email, Text, Web) - Recipients []string `protobuf:"bytes,2,rep,name=recipients,proto3" json:"recipients,omitempty"` // List of recipient addresses - Subject string `protobuf:"bytes,3,opt,name=subject,proto3" json:"subject,omitempty"` // Subject of the notification - Body string `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"` // Body of the notification (HTML or Raw) + state protoimpl.MessageState `protogen:"open.v1"` + // A list of targets. Can be mixed types (emails, phones, user IDs). + Recipients []*Recipient `protobuf:"bytes,1,rep,name=recipients,proto3" json:"recipients,omitempty"` + // The actual message payload (either raw or template-based). + Content *Content `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` + // Optional: Force a specific delivery method. + // If unspecified, the server can infer it from the Recipient data. + PreferredChannel DeliveryChannel `protobuf:"varint,3,opt,name=preferred_channel,json=preferredChannel,proto3,enum=plugin.notification.v1.DeliveryChannel" json:"preferred_channel,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -114,45 +122,351 @@ func (*SendNotificationRequest) Descriptor() ([]byte, []int) { return file_plugin_notification_v1_notification_proto_rawDescGZIP(), []int{0} } -func (x *SendNotificationRequest) GetNotificationType() NotificationType { +func (x *SendNotificationRequest) GetRecipients() []*Recipient { if x != nil { - return x.NotificationType + return x.Recipients } - return NotificationType_NOTIFICATION_TYPE_UNSPECIFIED + return nil } -func (x *SendNotificationRequest) GetRecipients() []string { +func (x *SendNotificationRequest) GetContent() *Content { if x != nil { - return x.Recipients + return x.Content + } + return nil +} + +func (x *SendNotificationRequest) GetPreferredChannel() DeliveryChannel { + if x != nil { + return x.PreferredChannel + } + return DeliveryChannel_DELIVERY_CHANNEL_UNSPECIFIED +} + +// A flexible recipient that can be targeted by explicit address or internal system ID. +type Recipient struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to Target: + // + // *Recipient_EmailAddress + // *Recipient_PhoneNumber + // *Recipient_DeviceToken + // *Recipient_UserId + Target isRecipient_Target `protobuf_oneof:"target"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Recipient) Reset() { + *x = Recipient{} + mi := &file_plugin_notification_v1_notification_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Recipient) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Recipient) ProtoMessage() {} + +func (x *Recipient) ProtoReflect() protoreflect.Message { + mi := &file_plugin_notification_v1_notification_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 Recipient.ProtoReflect.Descriptor instead. +func (*Recipient) Descriptor() ([]byte, []int) { + return file_plugin_notification_v1_notification_proto_rawDescGZIP(), []int{1} +} + +func (x *Recipient) GetTarget() isRecipient_Target { + if x != nil { + return x.Target + } + return nil +} + +func (x *Recipient) GetEmailAddress() string { + if x != nil { + if x, ok := x.Target.(*Recipient_EmailAddress); ok { + return x.EmailAddress + } + } + return "" +} + +func (x *Recipient) GetPhoneNumber() string { + if x != nil { + if x, ok := x.Target.(*Recipient_PhoneNumber); ok { + return x.PhoneNumber + } + } + return "" +} + +func (x *Recipient) GetDeviceToken() string { + if x != nil { + if x, ok := x.Target.(*Recipient_DeviceToken); ok { + return x.DeviceToken + } + } + return "" +} + +func (x *Recipient) GetUserId() string { + if x != nil { + if x, ok := x.Target.(*Recipient_UserId); ok { + return x.UserId + } + } + return "" +} + +type isRecipient_Target interface { + isRecipient_Target() +} + +type Recipient_EmailAddress struct { + EmailAddress string `protobuf:"bytes,1,opt,name=email_address,json=emailAddress,proto3,oneof"` +} + +type Recipient_PhoneNumber struct { + PhoneNumber string `protobuf:"bytes,2,opt,name=phone_number,json=phoneNumber,proto3,oneof"` +} + +type Recipient_DeviceToken struct { + DeviceToken string `protobuf:"bytes,3,opt,name=device_token,json=deviceToken,proto3,oneof"` // For mobile/web push notifications +} + +type Recipient_UserId struct { + UserId string `protobuf:"bytes,4,opt,name=user_id,json=userId,proto3,oneof"` // Server resolves this to addresses based on user preferences +} + +func (*Recipient_EmailAddress) isRecipient_Target() {} + +func (*Recipient_PhoneNumber) isRecipient_Target() {} + +func (*Recipient_DeviceToken) isRecipient_Target() {} + +func (*Recipient_UserId) isRecipient_Target() {} + +// The content of the notification, supporting both raw text and pre-defined templates. +type Content struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to Payload: + // + // *Content_Raw + // *Content_Template + Payload isContent_Payload `protobuf_oneof:"payload"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Content) Reset() { + *x = Content{} + mi := &file_plugin_notification_v1_notification_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Content) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Content) ProtoMessage() {} + +func (x *Content) ProtoReflect() protoreflect.Message { + mi := &file_plugin_notification_v1_notification_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 Content.ProtoReflect.Descriptor instead. +func (*Content) Descriptor() ([]byte, []int) { + return file_plugin_notification_v1_notification_proto_rawDescGZIP(), []int{2} +} + +func (x *Content) GetPayload() isContent_Payload { + if x != nil { + return x.Payload + } + return nil +} + +func (x *Content) GetRaw() *RawMessage { + if x != nil { + if x, ok := x.Payload.(*Content_Raw); ok { + return x.Raw + } + } + return nil +} + +func (x *Content) GetTemplate() *TemplateMessage { + if x != nil { + if x, ok := x.Payload.(*Content_Template); ok { + return x.Template + } } return nil } -func (x *SendNotificationRequest) GetSubject() string { +type isContent_Payload interface { + isContent_Payload() +} + +type Content_Raw struct { + Raw *RawMessage `protobuf:"bytes,1,opt,name=raw,proto3,oneof"` +} + +type Content_Template struct { + Template *TemplateMessage `protobuf:"bytes,2,opt,name=template,proto3,oneof"` +} + +func (*Content_Raw) isContent_Payload() {} + +func (*Content_Template) isContent_Payload() {} + +// A generic message structure that automatically adapts to the delivery channel. +type RawMessage struct { + state protoimpl.MessageState `protogen:"open.v1"` + Subject string `protobuf:"bytes,1,opt,name=subject,proto3" json:"subject,omitempty"` // Maps to Email Subject or Push Notification Title + Body string `protobuf:"bytes,2,opt,name=body,proto3" json:"body,omitempty"` // The main text/html content + Metadata map[string]string `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // Extra data for apps (e.g., deep links, JSON payloads) + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RawMessage) Reset() { + *x = RawMessage{} + mi := &file_plugin_notification_v1_notification_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RawMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RawMessage) ProtoMessage() {} + +func (x *RawMessage) ProtoReflect() protoreflect.Message { + mi := &file_plugin_notification_v1_notification_proto_msgTypes[3] + 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 RawMessage.ProtoReflect.Descriptor instead. +func (*RawMessage) Descriptor() ([]byte, []int) { + return file_plugin_notification_v1_notification_proto_rawDescGZIP(), []int{3} +} + +func (x *RawMessage) GetSubject() string { if x != nil { return x.Subject } return "" } -func (x *SendNotificationRequest) GetBody() string { +func (x *RawMessage) GetBody() string { if x != nil { return x.Body } return "" } -type SendNotificationResponse struct { +func (x *RawMessage) GetMetadata() map[string]string { + if x != nil { + return x.Metadata + } + return nil +} + +// Used for dynamic templating systems (like SendGrid, Twilio, or Firebase). +type TemplateMessage struct { state protoimpl.MessageState `protogen:"open.v1"` - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` // Indicates if the notification was sent successfully - Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` // Additional message or error details + TemplateId string `protobuf:"bytes,1,opt,name=template_id,json=templateId,proto3" json:"template_id,omitempty"` + Parameters map[string]string `protobuf:"bytes,2,rep,name=parameters,proto3" json:"parameters,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // Dynamic variables to inject into the template unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } +func (x *TemplateMessage) Reset() { + *x = TemplateMessage{} + mi := &file_plugin_notification_v1_notification_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TemplateMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TemplateMessage) ProtoMessage() {} + +func (x *TemplateMessage) ProtoReflect() protoreflect.Message { + mi := &file_plugin_notification_v1_notification_proto_msgTypes[4] + 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 TemplateMessage.ProtoReflect.Descriptor instead. +func (*TemplateMessage) Descriptor() ([]byte, []int) { + return file_plugin_notification_v1_notification_proto_rawDescGZIP(), []int{4} +} + +func (x *TemplateMessage) GetTemplateId() string { + if x != nil { + return x.TemplateId + } + return "" +} + +func (x *TemplateMessage) GetParameters() map[string]string { + if x != nil { + return x.Parameters + } + return nil +} + +// The response handles partial successes cleanly without breaking gRPC conventions. +type SendNotificationResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + TrackingId string `protobuf:"bytes,1,opt,name=tracking_id,json=trackingId,proto3" json:"tracking_id,omitempty"` // A global ID to track delivery status asynchronously + PartialFailures []*DeliveryFailure `protobuf:"bytes,2,rep,name=partial_failures,json=partialFailures,proto3" json:"partial_failures,omitempty"` // Empty array means 100% success + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + func (x *SendNotificationResponse) Reset() { *x = SendNotificationResponse{} - mi := &file_plugin_notification_v1_notification_proto_msgTypes[1] + mi := &file_plugin_notification_v1_notification_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -164,7 +478,7 @@ func (x *SendNotificationResponse) String() string { func (*SendNotificationResponse) ProtoMessage() {} func (x *SendNotificationResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_notification_v1_notification_proto_msgTypes[1] + mi := &file_plugin_notification_v1_notification_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -177,19 +491,72 @@ func (x *SendNotificationResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use SendNotificationResponse.ProtoReflect.Descriptor instead. func (*SendNotificationResponse) Descriptor() ([]byte, []int) { - return file_plugin_notification_v1_notification_proto_rawDescGZIP(), []int{1} + return file_plugin_notification_v1_notification_proto_rawDescGZIP(), []int{5} +} + +func (x *SendNotificationResponse) GetTrackingId() string { + if x != nil { + return x.TrackingId + } + return "" +} + +func (x *SendNotificationResponse) GetPartialFailures() []*DeliveryFailure { + if x != nil { + return x.PartialFailures + } + return nil +} + +// Details about why a specific recipient failed, allowing the client to handle retries. +type DeliveryFailure struct { + state protoimpl.MessageState `protogen:"open.v1"` + Recipient *Recipient `protobuf:"bytes,1,opt,name=recipient,proto3" json:"recipient,omitempty"` + ErrorReason string `protobuf:"bytes,2,opt,name=error_reason,json=errorReason,proto3" json:"error_reason,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeliveryFailure) Reset() { + *x = DeliveryFailure{} + mi := &file_plugin_notification_v1_notification_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } -func (x *SendNotificationResponse) GetSuccess() bool { +func (x *DeliveryFailure) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeliveryFailure) ProtoMessage() {} + +func (x *DeliveryFailure) ProtoReflect() protoreflect.Message { + mi := &file_plugin_notification_v1_notification_proto_msgTypes[6] if x != nil { - return x.Success + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeliveryFailure.ProtoReflect.Descriptor instead. +func (*DeliveryFailure) Descriptor() ([]byte, []int) { + return file_plugin_notification_v1_notification_proto_rawDescGZIP(), []int{6} +} + +func (x *DeliveryFailure) GetRecipient() *Recipient { + if x != nil { + return x.Recipient } - return false + return nil } -func (x *SendNotificationResponse) GetMessage() string { +func (x *DeliveryFailure) GetErrorReason() string { if x != nil { - return x.Message + return x.ErrorReason } return "" } @@ -198,24 +565,55 @@ var File_plugin_notification_v1_notification_proto protoreflect.FileDescriptor const file_plugin_notification_v1_notification_proto_rawDesc = "" + "\n" + - ")plugin/notification/v1/notification.proto\x12\x16plugin.notification.v1\"\xbe\x01\n" + - "\x17SendNotificationRequest\x12U\n" + - "\x11notification_type\x18\x01 \x01(\x0e2(.plugin.notification.v1.NotificationTypeR\x10notificationType\x12\x1e\n" + + ")plugin/notification/v1/notification.proto\x12\x16plugin.notification.v1\"\xed\x01\n" + + "\x17SendNotificationRequest\x12A\n" + + "\n" + + "recipients\x18\x01 \x03(\v2!.plugin.notification.v1.RecipientR\n" + + "recipients\x129\n" + + "\acontent\x18\x02 \x01(\v2\x1f.plugin.notification.v1.ContentR\acontent\x12T\n" + + "\x11preferred_channel\x18\x03 \x01(\x0e2'.plugin.notification.v1.DeliveryChannelR\x10preferredChannel\"\xa1\x01\n" + + "\tRecipient\x12%\n" + + "\remail_address\x18\x01 \x01(\tH\x00R\femailAddress\x12#\n" + + "\fphone_number\x18\x02 \x01(\tH\x00R\vphoneNumber\x12#\n" + + "\fdevice_token\x18\x03 \x01(\tH\x00R\vdeviceToken\x12\x19\n" + + "\auser_id\x18\x04 \x01(\tH\x00R\x06userIdB\b\n" + + "\x06target\"\x93\x01\n" + + "\aContent\x126\n" + + "\x03raw\x18\x01 \x01(\v2\".plugin.notification.v1.RawMessageH\x00R\x03raw\x12E\n" + + "\btemplate\x18\x02 \x01(\v2'.plugin.notification.v1.TemplateMessageH\x00R\btemplateB\t\n" + + "\apayload\"\xc5\x01\n" + "\n" + - "recipients\x18\x02 \x03(\tR\n" + - "recipients\x12\x18\n" + - "\asubject\x18\x03 \x01(\tR\asubject\x12\x12\n" + - "\x04body\x18\x04 \x01(\tR\x04body\"N\n" + - "\x18SendNotificationResponse\x12\x18\n" + - "\asuccess\x18\x01 \x01(\bR\asuccess\x12\x18\n" + - "\amessage\x18\x02 \x01(\tR\amessage*\x89\x01\n" + - "\x10NotificationType\x12!\n" + - "\x1dNOTIFICATION_TYPE_UNSPECIFIED\x10\x00\x12\x1b\n" + - "\x17NOTIFICATION_TYPE_EMAIL\x10\x01\x12\x1a\n" + - "\x16NOTIFICATION_TYPE_TEXT\x10\x02\x12\x19\n" + - "\x15NOTIFICATION_TYPE_WEB\x10\x032\x8c\x01\n" + - "\x13NotificationService\x12u\n" + - "\x10SendNotification\x12/.plugin.notification.v1.SendNotificationRequest\x1a0.plugin.notification.v1.SendNotificationResponseB\xf4\x01\n" + + "RawMessage\x12\x18\n" + + "\asubject\x18\x01 \x01(\tR\asubject\x12\x12\n" + + "\x04body\x18\x02 \x01(\tR\x04body\x12L\n" + + "\bmetadata\x18\x03 \x03(\v20.plugin.notification.v1.RawMessage.MetadataEntryR\bmetadata\x1a;\n" + + "\rMetadataEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xca\x01\n" + + "\x0fTemplateMessage\x12\x1f\n" + + "\vtemplate_id\x18\x01 \x01(\tR\n" + + "templateId\x12W\n" + + "\n" + + "parameters\x18\x02 \x03(\v27.plugin.notification.v1.TemplateMessage.ParametersEntryR\n" + + "parameters\x1a=\n" + + "\x0fParametersEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\x8f\x01\n" + + "\x18SendNotificationResponse\x12\x1f\n" + + "\vtracking_id\x18\x01 \x01(\tR\n" + + "trackingId\x12R\n" + + "\x10partial_failures\x18\x02 \x03(\v2'.plugin.notification.v1.DeliveryFailureR\x0fpartialFailures\"u\n" + + "\x0fDeliveryFailure\x12?\n" + + "\trecipient\x18\x01 \x01(\v2!.plugin.notification.v1.RecipientR\trecipient\x12!\n" + + "\ferror_reason\x18\x02 \x01(\tR\verrorReason*\xa1\x01\n" + + "\x0fDeliveryChannel\x12 \n" + + "\x1cDELIVERY_CHANNEL_UNSPECIFIED\x10\x00\x12\x1a\n" + + "\x16DELIVERY_CHANNEL_EMAIL\x10\x01\x12\x18\n" + + "\x14DELIVERY_CHANNEL_SMS\x10\x02\x12\x19\n" + + "\x15DELIVERY_CHANNEL_PUSH\x10\x03\x12\x1b\n" + + "\x17DELIVERY_CHANNEL_IN_APP\x10\x042y\n" + + "\fNotification\x12i\n" + + "\x04Send\x12/.plugin.notification.v1.SendNotificationRequest\x1a0.plugin.notification.v1.SendNotificationResponseB\xf4\x01\n" + "\x1acom.plugin.notification.v1B\x11NotificationProtoP\x01ZIgithub.com/openkcm/plugin-sdk/proto/plugin/notification/v1;notificationv1\xa2\x02\x03PNX\xaa\x02\x16Plugin.Notification.V1\xca\x02\x16Plugin\\Notification\\V1\xe2\x02\"Plugin\\Notification\\V1\\GPBMetadata\xea\x02\x18Plugin::Notification::V1b\x06proto3" var ( @@ -231,21 +629,36 @@ func file_plugin_notification_v1_notification_proto_rawDescGZIP() []byte { } var file_plugin_notification_v1_notification_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_plugin_notification_v1_notification_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_plugin_notification_v1_notification_proto_msgTypes = make([]protoimpl.MessageInfo, 9) var file_plugin_notification_v1_notification_proto_goTypes = []any{ - (NotificationType)(0), // 0: plugin.notification.v1.NotificationType + (DeliveryChannel)(0), // 0: plugin.notification.v1.DeliveryChannel (*SendNotificationRequest)(nil), // 1: plugin.notification.v1.SendNotificationRequest - (*SendNotificationResponse)(nil), // 2: plugin.notification.v1.SendNotificationResponse + (*Recipient)(nil), // 2: plugin.notification.v1.Recipient + (*Content)(nil), // 3: plugin.notification.v1.Content + (*RawMessage)(nil), // 4: plugin.notification.v1.RawMessage + (*TemplateMessage)(nil), // 5: plugin.notification.v1.TemplateMessage + (*SendNotificationResponse)(nil), // 6: plugin.notification.v1.SendNotificationResponse + (*DeliveryFailure)(nil), // 7: plugin.notification.v1.DeliveryFailure + nil, // 8: plugin.notification.v1.RawMessage.MetadataEntry + nil, // 9: plugin.notification.v1.TemplateMessage.ParametersEntry } var file_plugin_notification_v1_notification_proto_depIdxs = []int32{ - 0, // 0: plugin.notification.v1.SendNotificationRequest.notification_type:type_name -> plugin.notification.v1.NotificationType - 1, // 1: plugin.notification.v1.NotificationService.SendNotification:input_type -> plugin.notification.v1.SendNotificationRequest - 2, // 2: plugin.notification.v1.NotificationService.SendNotification:output_type -> plugin.notification.v1.SendNotificationResponse - 2, // [2:3] is the sub-list for method output_type - 1, // [1:2] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 2, // 0: plugin.notification.v1.SendNotificationRequest.recipients:type_name -> plugin.notification.v1.Recipient + 3, // 1: plugin.notification.v1.SendNotificationRequest.content:type_name -> plugin.notification.v1.Content + 0, // 2: plugin.notification.v1.SendNotificationRequest.preferred_channel:type_name -> plugin.notification.v1.DeliveryChannel + 4, // 3: plugin.notification.v1.Content.raw:type_name -> plugin.notification.v1.RawMessage + 5, // 4: plugin.notification.v1.Content.template:type_name -> plugin.notification.v1.TemplateMessage + 8, // 5: plugin.notification.v1.RawMessage.metadata:type_name -> plugin.notification.v1.RawMessage.MetadataEntry + 9, // 6: plugin.notification.v1.TemplateMessage.parameters:type_name -> plugin.notification.v1.TemplateMessage.ParametersEntry + 7, // 7: plugin.notification.v1.SendNotificationResponse.partial_failures:type_name -> plugin.notification.v1.DeliveryFailure + 2, // 8: plugin.notification.v1.DeliveryFailure.recipient:type_name -> plugin.notification.v1.Recipient + 1, // 9: plugin.notification.v1.Notification.Send:input_type -> plugin.notification.v1.SendNotificationRequest + 6, // 10: plugin.notification.v1.Notification.Send:output_type -> plugin.notification.v1.SendNotificationResponse + 10, // [10:11] is the sub-list for method output_type + 9, // [9:10] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name } func init() { file_plugin_notification_v1_notification_proto_init() } @@ -253,13 +666,23 @@ func file_plugin_notification_v1_notification_proto_init() { if File_plugin_notification_v1_notification_proto != nil { return } + file_plugin_notification_v1_notification_proto_msgTypes[1].OneofWrappers = []any{ + (*Recipient_EmailAddress)(nil), + (*Recipient_PhoneNumber)(nil), + (*Recipient_DeviceToken)(nil), + (*Recipient_UserId)(nil), + } + file_plugin_notification_v1_notification_proto_msgTypes[2].OneofWrappers = []any{ + (*Content_Raw)(nil), + (*Content_Template)(nil), + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_plugin_notification_v1_notification_proto_rawDesc), len(file_plugin_notification_v1_notification_proto_rawDesc)), NumEnums: 1, - NumMessages: 2, + NumMessages: 9, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/plugin/notification/v1/notification.pb.validate.go b/proto/plugin/notification/v1/notification.pb.validate.go index 4143db3..fac2599 100644 --- a/proto/plugin/notification/v1/notification.pb.validate.go +++ b/proto/plugin/notification/v1/notification.pb.validate.go @@ -57,11 +57,70 @@ func (m *SendNotificationRequest) validate(all bool) error { var errors []error - // no validation rules for NotificationType + for idx, item := range m.GetRecipients() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, SendNotificationRequestValidationError{ + field: fmt.Sprintf("Recipients[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, SendNotificationRequestValidationError{ + field: fmt.Sprintf("Recipients[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return SendNotificationRequestValidationError{ + field: fmt.Sprintf("Recipients[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } - // no validation rules for Subject + } - // no validation rules for Body + if all { + switch v := interface{}(m.GetContent()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, SendNotificationRequestValidationError{ + field: "Content", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, SendNotificationRequestValidationError{ + field: "Content", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetContent()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return SendNotificationRequestValidationError{ + field: "Content", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for PreferredChannel if len(errors) > 0 { return SendNotificationRequestMultiError(errors) @@ -143,6 +202,552 @@ var _ interface { ErrorName() string } = SendNotificationRequestValidationError{} +// Validate checks the field values on Recipient 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 *Recipient) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Recipient 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 RecipientMultiError, or nil +// if none found. +func (m *Recipient) ValidateAll() error { + return m.validate(true) +} + +func (m *Recipient) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + switch v := m.Target.(type) { + case *Recipient_EmailAddress: + if v == nil { + err := RecipientValidationError{ + field: "Target", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + // no validation rules for EmailAddress + case *Recipient_PhoneNumber: + if v == nil { + err := RecipientValidationError{ + field: "Target", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + // no validation rules for PhoneNumber + case *Recipient_DeviceToken: + if v == nil { + err := RecipientValidationError{ + field: "Target", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + // no validation rules for DeviceToken + case *Recipient_UserId: + if v == nil { + err := RecipientValidationError{ + field: "Target", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + // no validation rules for UserId + default: + _ = v // ensures v is used + } + + if len(errors) > 0 { + return RecipientMultiError(errors) + } + + return nil +} + +// RecipientMultiError is an error wrapping multiple validation errors returned +// by Recipient.ValidateAll() if the designated constraints aren't met. +type RecipientMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RecipientMultiError) 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 RecipientMultiError) AllErrors() []error { return m } + +// RecipientValidationError is the validation error returned by +// Recipient.Validate if the designated constraints aren't met. +type RecipientValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RecipientValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RecipientValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RecipientValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RecipientValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RecipientValidationError) ErrorName() string { return "RecipientValidationError" } + +// Error satisfies the builtin error interface +func (e RecipientValidationError) 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 %sRecipient.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RecipientValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RecipientValidationError{} + +// Validate checks the field values on Content 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 *Content) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Content 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 ContentMultiError, or nil if none found. +func (m *Content) ValidateAll() error { + return m.validate(true) +} + +func (m *Content) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + switch v := m.Payload.(type) { + case *Content_Raw: + if v == nil { + err := ContentValidationError{ + field: "Payload", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetRaw()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ContentValidationError{ + field: "Raw", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ContentValidationError{ + field: "Raw", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRaw()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ContentValidationError{ + field: "Raw", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *Content_Template: + if v == nil { + err := ContentValidationError{ + field: "Payload", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetTemplate()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ContentValidationError{ + field: "Template", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ContentValidationError{ + field: "Template", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetTemplate()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ContentValidationError{ + field: "Template", + reason: "embedded message failed validation", + cause: err, + } + } + } + + default: + _ = v // ensures v is used + } + + if len(errors) > 0 { + return ContentMultiError(errors) + } + + return nil +} + +// ContentMultiError is an error wrapping multiple validation errors returned +// by Content.ValidateAll() if the designated constraints aren't met. +type ContentMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ContentMultiError) 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 ContentMultiError) AllErrors() []error { return m } + +// ContentValidationError is the validation error returned by Content.Validate +// if the designated constraints aren't met. +type ContentValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ContentValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ContentValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ContentValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ContentValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ContentValidationError) ErrorName() string { return "ContentValidationError" } + +// Error satisfies the builtin error interface +func (e ContentValidationError) 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 %sContent.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ContentValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ContentValidationError{} + +// Validate checks the field values on RawMessage 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 *RawMessage) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RawMessage 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 RawMessageMultiError, or +// nil if none found. +func (m *RawMessage) ValidateAll() error { + return m.validate(true) +} + +func (m *RawMessage) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Subject + + // no validation rules for Body + + // no validation rules for Metadata + + if len(errors) > 0 { + return RawMessageMultiError(errors) + } + + return nil +} + +// RawMessageMultiError is an error wrapping multiple validation errors +// returned by RawMessage.ValidateAll() if the designated constraints aren't met. +type RawMessageMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RawMessageMultiError) 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 RawMessageMultiError) AllErrors() []error { return m } + +// RawMessageValidationError is the validation error returned by +// RawMessage.Validate if the designated constraints aren't met. +type RawMessageValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RawMessageValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RawMessageValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RawMessageValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RawMessageValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RawMessageValidationError) ErrorName() string { return "RawMessageValidationError" } + +// Error satisfies the builtin error interface +func (e RawMessageValidationError) 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 %sRawMessage.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RawMessageValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RawMessageValidationError{} + +// Validate checks the field values on TemplateMessage 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 *TemplateMessage) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on TemplateMessage 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 +// TemplateMessageMultiError, or nil if none found. +func (m *TemplateMessage) ValidateAll() error { + return m.validate(true) +} + +func (m *TemplateMessage) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for TemplateId + + // no validation rules for Parameters + + if len(errors) > 0 { + return TemplateMessageMultiError(errors) + } + + return nil +} + +// TemplateMessageMultiError is an error wrapping multiple validation errors +// returned by TemplateMessage.ValidateAll() if the designated constraints +// aren't met. +type TemplateMessageMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m TemplateMessageMultiError) 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 TemplateMessageMultiError) AllErrors() []error { return m } + +// TemplateMessageValidationError is the validation error returned by +// TemplateMessage.Validate if the designated constraints aren't met. +type TemplateMessageValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e TemplateMessageValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e TemplateMessageValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e TemplateMessageValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e TemplateMessageValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e TemplateMessageValidationError) ErrorName() string { return "TemplateMessageValidationError" } + +// Error satisfies the builtin error interface +func (e TemplateMessageValidationError) 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 %sTemplateMessage.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = TemplateMessageValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = TemplateMessageValidationError{} + // Validate checks the field values on SendNotificationResponse 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. @@ -165,9 +770,41 @@ func (m *SendNotificationResponse) validate(all bool) error { var errors []error - // no validation rules for Success + // no validation rules for TrackingId + + for idx, item := range m.GetPartialFailures() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, SendNotificationResponseValidationError{ + field: fmt.Sprintf("PartialFailures[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, SendNotificationResponseValidationError{ + field: fmt.Sprintf("PartialFailures[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return SendNotificationResponseValidationError{ + field: fmt.Sprintf("PartialFailures[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } - // no validation rules for Message + } if len(errors) > 0 { return SendNotificationResponseMultiError(errors) @@ -248,3 +885,134 @@ var _ interface { Cause() error ErrorName() string } = SendNotificationResponseValidationError{} + +// Validate checks the field values on DeliveryFailure 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 *DeliveryFailure) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeliveryFailure 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 +// DeliveryFailureMultiError, or nil if none found. +func (m *DeliveryFailure) ValidateAll() error { + return m.validate(true) +} + +func (m *DeliveryFailure) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetRecipient()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeliveryFailureValidationError{ + field: "Recipient", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeliveryFailureValidationError{ + field: "Recipient", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRecipient()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DeliveryFailureValidationError{ + field: "Recipient", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for ErrorReason + + if len(errors) > 0 { + return DeliveryFailureMultiError(errors) + } + + return nil +} + +// DeliveryFailureMultiError is an error wrapping multiple validation errors +// returned by DeliveryFailure.ValidateAll() if the designated constraints +// aren't met. +type DeliveryFailureMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeliveryFailureMultiError) 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 DeliveryFailureMultiError) AllErrors() []error { return m } + +// DeliveryFailureValidationError is the validation error returned by +// DeliveryFailure.Validate if the designated constraints aren't met. +type DeliveryFailureValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeliveryFailureValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeliveryFailureValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeliveryFailureValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeliveryFailureValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeliveryFailureValidationError) ErrorName() string { return "DeliveryFailureValidationError" } + +// Error satisfies the builtin error interface +func (e DeliveryFailureValidationError) 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 %sDeliveryFailure.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeliveryFailureValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeliveryFailureValidationError{} diff --git a/proto/plugin/notification/v1/notification.proto b/proto/plugin/notification/v1/notification.proto index 169284a..6d3fc02 100644 --- a/proto/plugin/notification/v1/notification.proto +++ b/proto/plugin/notification/v1/notification.proto @@ -1,26 +1,72 @@ syntax = "proto3"; package plugin.notification.v1; -service NotificationService { - // SendNotification sends a notification to the specified recipients - rpc SendNotification(SendNotificationRequest) returns (SendNotificationResponse); +// The Notification standardizes message delivery across multiple channels. +service Notification { + rpc Send(SendNotificationRequest) returns (SendNotificationResponse); } +// Represents the request to send a notification. message SendNotificationRequest { - NotificationType notification_type = 1; // Type of notification (e.g., Email, Text, Web) - repeated string recipients = 2; // List of recipient addresses - string subject = 3; // Subject of the notification - string body = 4; // Body of the notification (HTML or Raw) + // A list of targets. Can be mixed types (emails, phones, user IDs). + repeated Recipient recipients = 1; + + // The actual message payload (either raw or template-based). + Content content = 2; + + // Optional: Force a specific delivery method. + // If unspecified, the server can infer it from the Recipient data. + DeliveryChannel preferred_channel = 3; +} + +// A flexible recipient that can be targeted by explicit address or internal system ID. +message Recipient { + oneof target { + string email_address = 1; + string phone_number = 2; + string device_token = 3; // For mobile/web push notifications + string user_id = 4; // Server resolves this to addresses based on user preferences + } +} + +// The content of the notification, supporting both raw text and pre-defined templates. +message Content { + oneof payload { + RawMessage raw = 1; + TemplateMessage template = 2; + } } -enum NotificationType { - NOTIFICATION_TYPE_UNSPECIFIED = 0; // Unspecified notification type - NOTIFICATION_TYPE_EMAIL = 1; // Email notification - NOTIFICATION_TYPE_TEXT = 2; // Text message notification - NOTIFICATION_TYPE_WEB = 3; // Web notification +// A generic message structure that automatically adapts to the delivery channel. +message RawMessage { + string subject = 1; // Maps to Email Subject or Push Notification Title + string body = 2; // The main text/html content + map metadata = 3; // Extra data for apps (e.g., deep links, JSON payloads) } +// Used for dynamic templating systems (like SendGrid, Twilio, or Firebase). +message TemplateMessage { + string template_id = 1; + map parameters = 2; // Dynamic variables to inject into the template +} + +// Standardized channels, using the '0' prefix best practice. +enum DeliveryChannel { + DELIVERY_CHANNEL_UNSPECIFIED = 0; + DELIVERY_CHANNEL_EMAIL = 1; + DELIVERY_CHANNEL_SMS = 2; + DELIVERY_CHANNEL_PUSH = 3; + DELIVERY_CHANNEL_IN_APP = 4; +} + +// The response handles partial successes cleanly without breaking gRPC conventions. message SendNotificationResponse { - bool success = 1; // Indicates if the notification was sent successfully - string message = 2; // Additional message or error details + string tracking_id = 1; // A global ID to track delivery status asynchronously + repeated DeliveryFailure partial_failures = 2; // Empty array means 100% success } + +// Details about why a specific recipient failed, allowing the client to handle retries. +message DeliveryFailure { + Recipient recipient = 1; + string error_reason = 2; +} \ No newline at end of file diff --git a/proto/plugin/notification/v1/notification_ext_plugin.pb.go b/proto/plugin/notification/v1/notification_ext_plugin.pb.go index dd6783a..003fad0 100644 --- a/proto/plugin/notification/v1/notification_ext_plugin.pb.go +++ b/proto/plugin/notification/v1/notification_ext_plugin.pb.go @@ -9,48 +9,48 @@ import ( ) const ( - Type = "NotificationService" - GRPCServiceFullName = "plugin.notification.v1.NotificationService" + Type = "Notification" + GRPCServiceFullName = "plugin.notification.v1.Notification" ) -func NotificationServicePluginServer(server NotificationServiceServer) api.PluginServer { - return notificationServicePluginServer{NotificationServiceServer: server} +func NotificationPluginServer(server NotificationServer) api.PluginServer { + return notificationPluginServer{NotificationServer: server} } -type notificationServicePluginServer struct { - NotificationServiceServer +type notificationPluginServer struct { + NotificationServer } -func (s notificationServicePluginServer) Type() string { +func (s notificationPluginServer) Type() string { return Type } -func (s notificationServicePluginServer) GRPCServiceName() string { +func (s notificationPluginServer) GRPCServiceName() string { return GRPCServiceFullName } -func (s notificationServicePluginServer) RegisterServer(server *grpc.Server) any { - RegisterNotificationServiceServer(server, s.NotificationServiceServer) - return s.NotificationServiceServer +func (s notificationPluginServer) RegisterServer(server *grpc.Server) any { + RegisterNotificationServer(server, s.NotificationServer) + return s.NotificationServer } -type NotificationServicePluginClient struct { - NotificationServiceClient +type NotificationPluginClient struct { + NotificationClient } -func (s NotificationServicePluginClient) Type() string { +func (s NotificationPluginClient) Type() string { return Type } -func (c *NotificationServicePluginClient) IsInitialized() bool { - return c.NotificationServiceClient != nil +func (c *NotificationPluginClient) IsInitialized() bool { + return c.NotificationClient != nil } -func (c *NotificationServicePluginClient) GRPCServiceName() string { +func (c *NotificationPluginClient) GRPCServiceName() string { return GRPCServiceFullName } -func (c *NotificationServicePluginClient) InitClient(conn grpc.ClientConnInterface) any { - c.NotificationServiceClient = NewNotificationServiceClient(conn) - return c.NotificationServiceClient +func (c *NotificationPluginClient) InitClient(conn grpc.ClientConnInterface) any { + c.NotificationClient = NewNotificationClient(conn) + return c.NotificationClient } diff --git a/proto/plugin/notification/v1/notification_grpc.pb.go b/proto/plugin/notification/v1/notification_grpc.pb.go index 52d6536..be062e2 100644 --- a/proto/plugin/notification/v1/notification_grpc.pb.go +++ b/proto/plugin/notification/v1/notification_grpc.pb.go @@ -20,103 +20,105 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - NotificationService_SendNotification_FullMethodName = "/plugin.notification.v1.NotificationService/SendNotification" + Notification_Send_FullMethodName = "/plugin.notification.v1.Notification/Send" ) -// NotificationServiceClient is the client API for NotificationService service. +// NotificationClient is the client API for Notification service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type NotificationServiceClient interface { - // SendNotification sends a notification to the specified recipients - SendNotification(ctx context.Context, in *SendNotificationRequest, opts ...grpc.CallOption) (*SendNotificationResponse, error) +// +// The Notification standardizes message delivery across multiple channels. +type NotificationClient interface { + Send(ctx context.Context, in *SendNotificationRequest, opts ...grpc.CallOption) (*SendNotificationResponse, error) } -type notificationServiceClient struct { +type notificationClient struct { cc grpc.ClientConnInterface } -func NewNotificationServiceClient(cc grpc.ClientConnInterface) NotificationServiceClient { - return ¬ificationServiceClient{cc} +func NewNotificationClient(cc grpc.ClientConnInterface) NotificationClient { + return ¬ificationClient{cc} } -func (c *notificationServiceClient) SendNotification(ctx context.Context, in *SendNotificationRequest, opts ...grpc.CallOption) (*SendNotificationResponse, error) { +func (c *notificationClient) Send(ctx context.Context, in *SendNotificationRequest, opts ...grpc.CallOption) (*SendNotificationResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(SendNotificationResponse) - err := c.cc.Invoke(ctx, NotificationService_SendNotification_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, Notification_Send_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -// NotificationServiceServer is the server API for NotificationService service. -// All implementations must embed UnimplementedNotificationServiceServer +// NotificationServer is the server API for Notification service. +// All implementations must embed UnimplementedNotificationServer // for forward compatibility. -type NotificationServiceServer interface { - // SendNotification sends a notification to the specified recipients - SendNotification(context.Context, *SendNotificationRequest) (*SendNotificationResponse, error) - mustEmbedUnimplementedNotificationServiceServer() +// +// The Notification standardizes message delivery across multiple channels. +type NotificationServer interface { + Send(context.Context, *SendNotificationRequest) (*SendNotificationResponse, error) + mustEmbedUnimplementedNotificationServer() } -// UnimplementedNotificationServiceServer must be embedded to have +// UnimplementedNotificationServer must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedNotificationServiceServer struct{} +type UnimplementedNotificationServer struct{} -func (UnimplementedNotificationServiceServer) SendNotification(context.Context, *SendNotificationRequest) (*SendNotificationResponse, error) { - return nil, status.Error(codes.Unimplemented, "method SendNotification not implemented") +func (UnimplementedNotificationServer) Send(context.Context, *SendNotificationRequest) (*SendNotificationResponse, error) { + return nil, status.Error(codes.Unimplemented, "method Send not implemented") } -func (UnimplementedNotificationServiceServer) mustEmbedUnimplementedNotificationServiceServer() {} -func (UnimplementedNotificationServiceServer) testEmbeddedByValue() {} +func (UnimplementedNotificationServer) mustEmbedUnimplementedNotificationServer() {} +func (UnimplementedNotificationServer) testEmbeddedByValue() {} -// UnsafeNotificationServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to NotificationServiceServer will +// UnsafeNotificationServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to NotificationServer will // result in compilation errors. -type UnsafeNotificationServiceServer interface { - mustEmbedUnimplementedNotificationServiceServer() +type UnsafeNotificationServer interface { + mustEmbedUnimplementedNotificationServer() } -func RegisterNotificationServiceServer(s grpc.ServiceRegistrar, srv NotificationServiceServer) { - // If the following call panics, it indicates UnimplementedNotificationServiceServer was +func RegisterNotificationServer(s grpc.ServiceRegistrar, srv NotificationServer) { + // If the following call panics, it indicates UnimplementedNotificationServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } - s.RegisterService(&NotificationService_ServiceDesc, srv) + s.RegisterService(&Notification_ServiceDesc, srv) } -func _NotificationService_SendNotification_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Notification_Send_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SendNotificationRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(NotificationServiceServer).SendNotification(ctx, in) + return srv.(NotificationServer).Send(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: NotificationService_SendNotification_FullMethodName, + FullMethod: Notification_Send_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(NotificationServiceServer).SendNotification(ctx, req.(*SendNotificationRequest)) + return srv.(NotificationServer).Send(ctx, req.(*SendNotificationRequest)) } return interceptor(ctx, in, info, handler) } -// NotificationService_ServiceDesc is the grpc.ServiceDesc for NotificationService service. +// Notification_ServiceDesc is the grpc.ServiceDesc for Notification service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) -var NotificationService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "plugin.notification.v1.NotificationService", - HandlerType: (*NotificationServiceServer)(nil), +var Notification_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "plugin.notification.v1.Notification", + HandlerType: (*NotificationServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "SendNotification", - Handler: _NotificationService_SendNotification_Handler, + MethodName: "Send", + Handler: _Notification_Send_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/proto/plugin/system_information/v1/system_information.pb.go b/proto/plugin/system_information/v1/system_information.pb.go new file mode 100644 index 0000000..8eb56bc --- /dev/null +++ b/proto/plugin/system_information/v1/system_information.pb.go @@ -0,0 +1,192 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc (unknown) +// source: plugin/system_information/v1/system_information.proto + +package system_informationv1 + +import ( + reflect "reflect" + sync "sync" + unsafe "unsafe" + + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +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 GetInfoRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetInfoRequest) Reset() { + *x = GetInfoRequest{} + mi := &file_plugin_system_information_v1_system_information_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetInfoRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetInfoRequest) ProtoMessage() {} + +func (x *GetInfoRequest) ProtoReflect() protoreflect.Message { + mi := &file_plugin_system_information_v1_system_information_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 GetInfoRequest.ProtoReflect.Descriptor instead. +func (*GetInfoRequest) Descriptor() ([]byte, []int) { + return file_plugin_system_information_v1_system_information_proto_rawDescGZIP(), []int{0} +} + +func (x *GetInfoRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *GetInfoRequest) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +type GetInfoResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Metadata map[string]string `protobuf:"bytes,1,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetInfoResponse) Reset() { + *x = GetInfoResponse{} + mi := &file_plugin_system_information_v1_system_information_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetInfoResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetInfoResponse) ProtoMessage() {} + +func (x *GetInfoResponse) ProtoReflect() protoreflect.Message { + mi := &file_plugin_system_information_v1_system_information_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 GetInfoResponse.ProtoReflect.Descriptor instead. +func (*GetInfoResponse) Descriptor() ([]byte, []int) { + return file_plugin_system_information_v1_system_information_proto_rawDescGZIP(), []int{1} +} + +func (x *GetInfoResponse) GetMetadata() map[string]string { + if x != nil { + return x.Metadata + } + return nil +} + +var File_plugin_system_information_v1_system_information_proto protoreflect.FileDescriptor + +const file_plugin_system_information_v1_system_information_proto_rawDesc = "" + + "\n" + + "5plugin/system_information/v1/system_information.proto\x12\x1cplugin.system_information.v1\x1a\x1bbuf/validate/validate.proto\"L\n" + + "\x0eGetInfoRequest\x12\x1a\n" + + "\x02id\x18\x01 \x01(\tB\n" + + "\xbaH\a\xc8\x01\x01r\x02\x10\x03R\x02id\x12\x1e\n" + + "\x04type\x18\x02 \x01(\tB\n" + + "\xbaH\a\xc8\x01\x01r\x02\x10\x03R\x04type\"\xa7\x01\n" + + "\x0fGetInfoResponse\x12W\n" + + "\bmetadata\x18\x01 \x03(\v2;.plugin.system_information.v1.GetInfoResponse.MetadataEntryR\bmetadata\x1a;\n" + + "\rMetadataEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x012{\n" + + "\x11SystemInformation\x12f\n" + + "\aGetInfo\x12,.plugin.system_information.v1.GetInfoRequest\x1a-.plugin.system_information.v1.GetInfoResponseB\x9f\x02\n" + + " com.plugin.system_information.v1B\x16SystemInformationProtoP\x01ZUgithub.com/openkcm/plugin-sdk/proto/plugin/system_information/v1;system_informationv1\xa2\x02\x03PSX\xaa\x02\x1bPlugin.SystemInformation.V1\xca\x02\x1bPlugin\\SystemInformation\\V1\xe2\x02'Plugin\\SystemInformation\\V1\\GPBMetadata\xea\x02\x1dPlugin::SystemInformation::V1b\x06proto3" + +var ( + file_plugin_system_information_v1_system_information_proto_rawDescOnce sync.Once + file_plugin_system_information_v1_system_information_proto_rawDescData []byte +) + +func file_plugin_system_information_v1_system_information_proto_rawDescGZIP() []byte { + file_plugin_system_information_v1_system_information_proto_rawDescOnce.Do(func() { + file_plugin_system_information_v1_system_information_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_plugin_system_information_v1_system_information_proto_rawDesc), len(file_plugin_system_information_v1_system_information_proto_rawDesc))) + }) + return file_plugin_system_information_v1_system_information_proto_rawDescData +} + +var file_plugin_system_information_v1_system_information_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_plugin_system_information_v1_system_information_proto_goTypes = []any{ + (*GetInfoRequest)(nil), // 0: plugin.system_information.v1.GetInfoRequest + (*GetInfoResponse)(nil), // 1: plugin.system_information.v1.GetInfoResponse + nil, // 2: plugin.system_information.v1.GetInfoResponse.MetadataEntry +} +var file_plugin_system_information_v1_system_information_proto_depIdxs = []int32{ + 2, // 0: plugin.system_information.v1.GetInfoResponse.metadata:type_name -> plugin.system_information.v1.GetInfoResponse.MetadataEntry + 0, // 1: plugin.system_information.v1.SystemInformation.GetInfo:input_type -> plugin.system_information.v1.GetInfoRequest + 1, // 2: plugin.system_information.v1.SystemInformation.GetInfo:output_type -> plugin.system_information.v1.GetInfoResponse + 2, // [2:3] is the sub-list for method output_type + 1, // [1:2] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_plugin_system_information_v1_system_information_proto_init() } +func file_plugin_system_information_v1_system_information_proto_init() { + if File_plugin_system_information_v1_system_information_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_plugin_system_information_v1_system_information_proto_rawDesc), len(file_plugin_system_information_v1_system_information_proto_rawDesc)), + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_plugin_system_information_v1_system_information_proto_goTypes, + DependencyIndexes: file_plugin_system_information_v1_system_information_proto_depIdxs, + MessageInfos: file_plugin_system_information_v1_system_information_proto_msgTypes, + }.Build() + File_plugin_system_information_v1_system_information_proto = out.File + file_plugin_system_information_v1_system_information_proto_goTypes = nil + file_plugin_system_information_v1_system_information_proto_depIdxs = nil +} diff --git a/proto/plugin/system_information/v1/system_information.pb.validate.go b/proto/plugin/system_information/v1/system_information.pb.validate.go new file mode 100644 index 0000000..3db92ec --- /dev/null +++ b/proto/plugin/system_information/v1/system_information.pb.validate.go @@ -0,0 +1,242 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: plugin/system_information/v1/system_information.proto + +package system_informationv1 + +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 GetInfoRequest 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 *GetInfoRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetInfoRequest 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 GetInfoRequestMultiError, +// or nil if none found. +func (m *GetInfoRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetInfoRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Type + + if len(errors) > 0 { + return GetInfoRequestMultiError(errors) + } + + return nil +} + +// GetInfoRequestMultiError is an error wrapping multiple validation errors +// returned by GetInfoRequest.ValidateAll() if the designated constraints +// aren't met. +type GetInfoRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetInfoRequestMultiError) 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 GetInfoRequestMultiError) AllErrors() []error { return m } + +// GetInfoRequestValidationError is the validation error returned by +// GetInfoRequest.Validate if the designated constraints aren't met. +type GetInfoRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetInfoRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetInfoRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetInfoRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetInfoRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetInfoRequestValidationError) ErrorName() string { return "GetInfoRequestValidationError" } + +// Error satisfies the builtin error interface +func (e GetInfoRequestValidationError) 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 %sGetInfoRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetInfoRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetInfoRequestValidationError{} + +// Validate checks the field values on GetInfoResponse 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 *GetInfoResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetInfoResponse 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 +// GetInfoResponseMultiError, or nil if none found. +func (m *GetInfoResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetInfoResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Metadata + + if len(errors) > 0 { + return GetInfoResponseMultiError(errors) + } + + return nil +} + +// GetInfoResponseMultiError is an error wrapping multiple validation errors +// returned by GetInfoResponse.ValidateAll() if the designated constraints +// aren't met. +type GetInfoResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetInfoResponseMultiError) 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 GetInfoResponseMultiError) AllErrors() []error { return m } + +// GetInfoResponseValidationError is the validation error returned by +// GetInfoResponse.Validate if the designated constraints aren't met. +type GetInfoResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetInfoResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetInfoResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetInfoResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetInfoResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetInfoResponseValidationError) ErrorName() string { return "GetInfoResponseValidationError" } + +// Error satisfies the builtin error interface +func (e GetInfoResponseValidationError) 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 %sGetInfoResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetInfoResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetInfoResponseValidationError{} diff --git a/proto/plugin/systeminformation/v1/systeminformation.proto b/proto/plugin/system_information/v1/system_information.proto similarity index 64% rename from proto/plugin/systeminformation/v1/systeminformation.proto rename to proto/plugin/system_information/v1/system_information.proto index d103627..54473ad 100644 --- a/proto/plugin/systeminformation/v1/systeminformation.proto +++ b/proto/plugin/system_information/v1/system_information.proto @@ -1,13 +1,13 @@ syntax = "proto3"; -package plugin.systeminformation.v1; +package plugin.system_information.v1; import "buf/validate/validate.proto"; -service SystemInformationService { - rpc Get(GetRequest) returns (GetResponse); +service SystemInformation { + rpc GetInfo(GetInfoRequest) returns (GetInfoResponse); } -message GetRequest { +message GetInfoRequest { string id = 1 [ (buf.validate.field).required = true, (buf.validate.field).string.min_len = 3 @@ -19,6 +19,7 @@ message GetRequest { ]; } -message GetResponse { +message GetInfoResponse { map metadata = 1; } + diff --git a/proto/plugin/system_information/v1/system_information_ext_plugin.pb.go b/proto/plugin/system_information/v1/system_information_ext_plugin.pb.go new file mode 100644 index 0000000..ad5038d --- /dev/null +++ b/proto/plugin/system_information/v1/system_information_ext_plugin.pb.go @@ -0,0 +1,56 @@ +// Code generated by protoc-gen-go-extension. DO NOT EDIT. + +package system_informationv1 + +import ( + grpc "google.golang.org/grpc" + + api "github.com/openkcm/plugin-sdk/api" +) + +const ( + Type = "SystemInformation" + GRPCServiceFullName = "plugin.system_information.v1.SystemInformation" +) + +func SystemInformationPluginServer(server SystemInformationServer) api.PluginServer { + return systemInformationPluginServer{SystemInformationServer: server} +} + +type systemInformationPluginServer struct { + SystemInformationServer +} + +func (s systemInformationPluginServer) Type() string { + return Type +} + +func (s systemInformationPluginServer) GRPCServiceName() string { + return GRPCServiceFullName +} + +func (s systemInformationPluginServer) RegisterServer(server *grpc.Server) any { + RegisterSystemInformationServer(server, s.SystemInformationServer) + return s.SystemInformationServer +} + +type SystemInformationPluginClient struct { + SystemInformationClient +} + +func (s SystemInformationPluginClient) Type() string { + return Type +} + +func (c *SystemInformationPluginClient) IsInitialized() bool { + return c.SystemInformationClient != nil +} + +func (c *SystemInformationPluginClient) GRPCServiceName() string { + return GRPCServiceFullName +} + +func (c *SystemInformationPluginClient) InitClient(conn grpc.ClientConnInterface) any { + c.SystemInformationClient = NewSystemInformationClient(conn) + return c.SystemInformationClient +} diff --git a/proto/plugin/system_information/v1/system_information_grpc.pb.go b/proto/plugin/system_information/v1/system_information_grpc.pb.go new file mode 100644 index 0000000..84f5d0a --- /dev/null +++ b/proto/plugin/system_information/v1/system_information_grpc.pb.go @@ -0,0 +1,122 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.6.1 +// - protoc (unknown) +// source: plugin/system_information/v1/system_information.proto + +package system_informationv1 + +import ( + context "context" + + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + SystemInformation_GetInfo_FullMethodName = "/plugin.system_information.v1.SystemInformation/GetInfo" +) + +// SystemInformationClient is the client API for SystemInformation service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type SystemInformationClient interface { + GetInfo(ctx context.Context, in *GetInfoRequest, opts ...grpc.CallOption) (*GetInfoResponse, error) +} + +type systemInformationClient struct { + cc grpc.ClientConnInterface +} + +func NewSystemInformationClient(cc grpc.ClientConnInterface) SystemInformationClient { + return &systemInformationClient{cc} +} + +func (c *systemInformationClient) GetInfo(ctx context.Context, in *GetInfoRequest, opts ...grpc.CallOption) (*GetInfoResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetInfoResponse) + err := c.cc.Invoke(ctx, SystemInformation_GetInfo_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// SystemInformationServer is the server API for SystemInformation service. +// All implementations must embed UnimplementedSystemInformationServer +// for forward compatibility. +type SystemInformationServer interface { + GetInfo(context.Context, *GetInfoRequest) (*GetInfoResponse, error) + mustEmbedUnimplementedSystemInformationServer() +} + +// UnimplementedSystemInformationServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedSystemInformationServer struct{} + +func (UnimplementedSystemInformationServer) GetInfo(context.Context, *GetInfoRequest) (*GetInfoResponse, error) { + return nil, status.Error(codes.Unimplemented, "method GetInfo not implemented") +} +func (UnimplementedSystemInformationServer) mustEmbedUnimplementedSystemInformationServer() {} +func (UnimplementedSystemInformationServer) testEmbeddedByValue() {} + +// UnsafeSystemInformationServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to SystemInformationServer will +// result in compilation errors. +type UnsafeSystemInformationServer interface { + mustEmbedUnimplementedSystemInformationServer() +} + +func RegisterSystemInformationServer(s grpc.ServiceRegistrar, srv SystemInformationServer) { + // If the following call panics, it indicates UnimplementedSystemInformationServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&SystemInformation_ServiceDesc, srv) +} + +func _SystemInformation_GetInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SystemInformationServer).GetInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SystemInformation_GetInfo_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SystemInformationServer).GetInfo(ctx, req.(*GetInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// SystemInformation_ServiceDesc is the grpc.ServiceDesc for SystemInformation service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var SystemInformation_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "plugin.system_information.v1.SystemInformation", + HandlerType: (*SystemInformationServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetInfo", + Handler: _SystemInformation_GetInfo_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "plugin/system_information/v1/system_information.proto", +} diff --git a/proto/plugin/systeminformation/v1/systeminformation.pb.go b/proto/plugin/systeminformation/v1/systeminformation.pb.go deleted file mode 100644 index 298f3e0..0000000 --- a/proto/plugin/systeminformation/v1/systeminformation.pb.go +++ /dev/null @@ -1,193 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.11 -// protoc (unknown) -// source: plugin/systeminformation/v1/systeminformation.proto - -package systeminformationv1 - -import ( - reflect "reflect" - sync "sync" - unsafe "unsafe" - - _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" -) - -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 GetRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetRequest) Reset() { - *x = GetRequest{} - mi := &file_plugin_systeminformation_v1_systeminformation_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetRequest) ProtoMessage() {} - -func (x *GetRequest) ProtoReflect() protoreflect.Message { - mi := &file_plugin_systeminformation_v1_systeminformation_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 GetRequest.ProtoReflect.Descriptor instead. -func (*GetRequest) Descriptor() ([]byte, []int) { - return file_plugin_systeminformation_v1_systeminformation_proto_rawDescGZIP(), []int{0} -} - -func (x *GetRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *GetRequest) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -type GetResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Metadata map[string]string `protobuf:"bytes,1,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetResponse) Reset() { - *x = GetResponse{} - mi := &file_plugin_systeminformation_v1_systeminformation_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetResponse) ProtoMessage() {} - -func (x *GetResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_systeminformation_v1_systeminformation_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 GetResponse.ProtoReflect.Descriptor instead. -func (*GetResponse) Descriptor() ([]byte, []int) { - return file_plugin_systeminformation_v1_systeminformation_proto_rawDescGZIP(), []int{1} -} - -func (x *GetResponse) GetMetadata() map[string]string { - if x != nil { - return x.Metadata - } - return nil -} - -var File_plugin_systeminformation_v1_systeminformation_proto protoreflect.FileDescriptor - -const file_plugin_systeminformation_v1_systeminformation_proto_rawDesc = "" + - "\n" + - "3plugin/systeminformation/v1/systeminformation.proto\x12\x1bplugin.systeminformation.v1\x1a\x1bbuf/validate/validate.proto\"H\n" + - "\n" + - "GetRequest\x12\x1a\n" + - "\x02id\x18\x01 \x01(\tB\n" + - "\xbaH\a\xc8\x01\x01r\x02\x10\x03R\x02id\x12\x1e\n" + - "\x04type\x18\x02 \x01(\tB\n" + - "\xbaH\a\xc8\x01\x01r\x02\x10\x03R\x04type\"\x9e\x01\n" + - "\vGetResponse\x12R\n" + - "\bmetadata\x18\x01 \x03(\v26.plugin.systeminformation.v1.GetResponse.MetadataEntryR\bmetadata\x1a;\n" + - "\rMetadataEntry\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x012t\n" + - "\x18SystemInformationService\x12X\n" + - "\x03Get\x12'.plugin.systeminformation.v1.GetRequest\x1a(.plugin.systeminformation.v1.GetResponseB\x9c\x02\n" + - "\x1fcom.plugin.systeminformation.v1B\x16SysteminformationProtoP\x01ZSgithub.com/openkcm/plugin-sdk/proto/plugin/systeminformation/v1;systeminformationv1\xa2\x02\x03PSX\xaa\x02\x1bPlugin.Systeminformation.V1\xca\x02\x1bPlugin\\Systeminformation\\V1\xe2\x02'Plugin\\Systeminformation\\V1\\GPBMetadata\xea\x02\x1dPlugin::Systeminformation::V1b\x06proto3" - -var ( - file_plugin_systeminformation_v1_systeminformation_proto_rawDescOnce sync.Once - file_plugin_systeminformation_v1_systeminformation_proto_rawDescData []byte -) - -func file_plugin_systeminformation_v1_systeminformation_proto_rawDescGZIP() []byte { - file_plugin_systeminformation_v1_systeminformation_proto_rawDescOnce.Do(func() { - file_plugin_systeminformation_v1_systeminformation_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_plugin_systeminformation_v1_systeminformation_proto_rawDesc), len(file_plugin_systeminformation_v1_systeminformation_proto_rawDesc))) - }) - return file_plugin_systeminformation_v1_systeminformation_proto_rawDescData -} - -var file_plugin_systeminformation_v1_systeminformation_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_plugin_systeminformation_v1_systeminformation_proto_goTypes = []any{ - (*GetRequest)(nil), // 0: plugin.systeminformation.v1.GetRequest - (*GetResponse)(nil), // 1: plugin.systeminformation.v1.GetResponse - nil, // 2: plugin.systeminformation.v1.GetResponse.MetadataEntry -} -var file_plugin_systeminformation_v1_systeminformation_proto_depIdxs = []int32{ - 2, // 0: plugin.systeminformation.v1.GetResponse.metadata:type_name -> plugin.systeminformation.v1.GetResponse.MetadataEntry - 0, // 1: plugin.systeminformation.v1.SystemInformationService.Get:input_type -> plugin.systeminformation.v1.GetRequest - 1, // 2: plugin.systeminformation.v1.SystemInformationService.Get:output_type -> plugin.systeminformation.v1.GetResponse - 2, // [2:3] is the sub-list for method output_type - 1, // [1:2] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name -} - -func init() { file_plugin_systeminformation_v1_systeminformation_proto_init() } -func file_plugin_systeminformation_v1_systeminformation_proto_init() { - if File_plugin_systeminformation_v1_systeminformation_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_plugin_systeminformation_v1_systeminformation_proto_rawDesc), len(file_plugin_systeminformation_v1_systeminformation_proto_rawDesc)), - NumEnums: 0, - NumMessages: 3, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_plugin_systeminformation_v1_systeminformation_proto_goTypes, - DependencyIndexes: file_plugin_systeminformation_v1_systeminformation_proto_depIdxs, - MessageInfos: file_plugin_systeminformation_v1_systeminformation_proto_msgTypes, - }.Build() - File_plugin_systeminformation_v1_systeminformation_proto = out.File - file_plugin_systeminformation_v1_systeminformation_proto_goTypes = nil - file_plugin_systeminformation_v1_systeminformation_proto_depIdxs = nil -} diff --git a/proto/plugin/systeminformation/v1/systeminformation.pb.validate.go b/proto/plugin/systeminformation/v1/systeminformation.pb.validate.go deleted file mode 100644 index 699461c..0000000 --- a/proto/plugin/systeminformation/v1/systeminformation.pb.validate.go +++ /dev/null @@ -1,240 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: plugin/systeminformation/v1/systeminformation.proto - -package systeminformationv1 - -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 GetRequest 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 *GetRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetRequest 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 GetRequestMultiError, or -// nil if none found. -func (m *GetRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *GetRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Type - - if len(errors) > 0 { - return GetRequestMultiError(errors) - } - - return nil -} - -// GetRequestMultiError is an error wrapping multiple validation errors -// returned by GetRequest.ValidateAll() if the designated constraints aren't met. -type GetRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetRequestMultiError) 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 GetRequestMultiError) AllErrors() []error { return m } - -// GetRequestValidationError is the validation error returned by -// GetRequest.Validate if the designated constraints aren't met. -type GetRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetRequestValidationError) ErrorName() string { return "GetRequestValidationError" } - -// Error satisfies the builtin error interface -func (e GetRequestValidationError) 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 %sGetRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetRequestValidationError{} - -// Validate checks the field values on GetResponse 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 *GetResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetResponse 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 GetResponseMultiError, or -// nil if none found. -func (m *GetResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *GetResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Metadata - - if len(errors) > 0 { - return GetResponseMultiError(errors) - } - - return nil -} - -// GetResponseMultiError is an error wrapping multiple validation errors -// returned by GetResponse.ValidateAll() if the designated constraints aren't met. -type GetResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetResponseMultiError) 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 GetResponseMultiError) AllErrors() []error { return m } - -// GetResponseValidationError is the validation error returned by -// GetResponse.Validate if the designated constraints aren't met. -type GetResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetResponseValidationError) ErrorName() string { return "GetResponseValidationError" } - -// Error satisfies the builtin error interface -func (e GetResponseValidationError) 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 %sGetResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetResponseValidationError{} diff --git a/proto/plugin/systeminformation/v1/systeminformation_ext_plugin.pb.go b/proto/plugin/systeminformation/v1/systeminformation_ext_plugin.pb.go deleted file mode 100644 index b2cb7a4..0000000 --- a/proto/plugin/systeminformation/v1/systeminformation_ext_plugin.pb.go +++ /dev/null @@ -1,56 +0,0 @@ -// Code generated by protoc-gen-go-extension. DO NOT EDIT. - -package systeminformationv1 - -import ( - grpc "google.golang.org/grpc" - - api "github.com/openkcm/plugin-sdk/api" -) - -const ( - Type = "SystemInformationService" - GRPCServiceFullName = "plugin.systeminformation.v1.SystemInformationService" -) - -func SystemInformationServicePluginServer(server SystemInformationServiceServer) api.PluginServer { - return systemInformationServicePluginServer{SystemInformationServiceServer: server} -} - -type systemInformationServicePluginServer struct { - SystemInformationServiceServer -} - -func (s systemInformationServicePluginServer) Type() string { - return Type -} - -func (s systemInformationServicePluginServer) GRPCServiceName() string { - return GRPCServiceFullName -} - -func (s systemInformationServicePluginServer) RegisterServer(server *grpc.Server) any { - RegisterSystemInformationServiceServer(server, s.SystemInformationServiceServer) - return s.SystemInformationServiceServer -} - -type SystemInformationServicePluginClient struct { - SystemInformationServiceClient -} - -func (s SystemInformationServicePluginClient) Type() string { - return Type -} - -func (c *SystemInformationServicePluginClient) IsInitialized() bool { - return c.SystemInformationServiceClient != nil -} - -func (c *SystemInformationServicePluginClient) GRPCServiceName() string { - return GRPCServiceFullName -} - -func (c *SystemInformationServicePluginClient) InitClient(conn grpc.ClientConnInterface) any { - c.SystemInformationServiceClient = NewSystemInformationServiceClient(conn) - return c.SystemInformationServiceClient -} diff --git a/proto/plugin/systeminformation/v1/systeminformation_grpc.pb.go b/proto/plugin/systeminformation/v1/systeminformation_grpc.pb.go deleted file mode 100644 index bf05e12..0000000 --- a/proto/plugin/systeminformation/v1/systeminformation_grpc.pb.go +++ /dev/null @@ -1,123 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.6.1 -// - protoc (unknown) -// source: plugin/systeminformation/v1/systeminformation.proto - -package systeminformationv1 - -import ( - context "context" - - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - SystemInformationService_Get_FullMethodName = "/plugin.systeminformation.v1.SystemInformationService/Get" -) - -// SystemInformationServiceClient is the client API for SystemInformationService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type SystemInformationServiceClient interface { - Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) -} - -type systemInformationServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewSystemInformationServiceClient(cc grpc.ClientConnInterface) SystemInformationServiceClient { - return &systemInformationServiceClient{cc} -} - -func (c *systemInformationServiceClient) Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetResponse) - err := c.cc.Invoke(ctx, SystemInformationService_Get_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// SystemInformationServiceServer is the server API for SystemInformationService service. -// All implementations must embed UnimplementedSystemInformationServiceServer -// for forward compatibility. -type SystemInformationServiceServer interface { - Get(context.Context, *GetRequest) (*GetResponse, error) - mustEmbedUnimplementedSystemInformationServiceServer() -} - -// UnimplementedSystemInformationServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedSystemInformationServiceServer struct{} - -func (UnimplementedSystemInformationServiceServer) Get(context.Context, *GetRequest) (*GetResponse, error) { - return nil, status.Error(codes.Unimplemented, "method Get not implemented") -} -func (UnimplementedSystemInformationServiceServer) mustEmbedUnimplementedSystemInformationServiceServer() { -} -func (UnimplementedSystemInformationServiceServer) testEmbeddedByValue() {} - -// UnsafeSystemInformationServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to SystemInformationServiceServer will -// result in compilation errors. -type UnsafeSystemInformationServiceServer interface { - mustEmbedUnimplementedSystemInformationServiceServer() -} - -func RegisterSystemInformationServiceServer(s grpc.ServiceRegistrar, srv SystemInformationServiceServer) { - // If the following call panics, it indicates UnimplementedSystemInformationServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&SystemInformationService_ServiceDesc, srv) -} - -func _SystemInformationService_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(SystemInformationServiceServer).Get(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: SystemInformationService_Get_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(SystemInformationServiceServer).Get(ctx, req.(*GetRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// SystemInformationService_ServiceDesc is the grpc.ServiceDesc for SystemInformationService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var SystemInformationService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "plugin.systeminformation.v1.SystemInformationService", - HandlerType: (*SystemInformationServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Get", - Handler: _SystemInformationService_Get_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "plugin/systeminformation/v1/systeminformation.proto", -} diff --git a/proto/plugin/systeminformation/v1/systeminformation_test.go b/proto/plugin/systeminformation/v1/systeminformation_test.go deleted file mode 100644 index db6a7cf..0000000 --- a/proto/plugin/systeminformation/v1/systeminformation_test.go +++ /dev/null @@ -1,14 +0,0 @@ -package systeminformationv1 - -import "testing" - -func TestGetRequestTypeString(t *testing.T) { - req := &GetRequest{ - Id: "id-1", - Type: "SYSTEM", - } - - if got := req.GetType(); got != "SYSTEM" { - t.Fatalf("expected type SYSTEM, got %q", got) - } -} diff --git a/proto/plugin/test/v1/test_ext_plugin.pb.go b/proto/plugin/test/v1/test_ext_plugin.pb.go index c51e1b9..bac0b2f 100644 --- a/proto/plugin/test/v1/test_ext_plugin.pb.go +++ b/proto/plugin/test/v1/test_ext_plugin.pb.go @@ -9,7 +9,7 @@ import ( ) const ( - Type = "TestService" + Type = "Test" GRPCServiceFullName = "plugin.test.v1.TestService" ) diff --git a/service/api/certificateissuer/certificate_issuer.go b/service/api/certificateissuer/certificate_issuer.go index 1dbebe2..380d29e 100644 --- a/service/api/certificateissuer/certificate_issuer.go +++ b/service/api/certificateissuer/certificate_issuer.go @@ -2,6 +2,9 @@ package certificateissuer import ( "context" + "fmt" + "strings" + "time" "github.com/openkcm/plugin-sdk/api" ) @@ -11,36 +14,111 @@ type CertificateIssuer interface { IssueCertificate(ctx context.Context, req *IssueCertificateRequest) (*IssueCertificateResponse, error) } +type CertificateFormat int -type ValidityType int32 +const ( + CertificateFormatUnspecified CertificateFormat = iota + CertificateFormatPEM + CertificateFormatDER + CertificateFormatPKCS7 +) + +type KeyFormat int const ( - Unspecified ValidityType = iota - Days - Months - Years + KeyFormatUnspecified KeyFormat = iota + KeyFormatPKCS1 + KeyFormatPKCS8 + KeyFormatSEC1 ) -type IssueCertificateRequest struct { - // V1 Fields +func (k KeyFormat) String() string { + switch k { + case KeyFormatPKCS1: + return "PKCS1" + case KeyFormatPKCS8: + return "PKCS8" + case KeyFormatSEC1: + return "SEC1" + default: + return "UNSPECIFIED" + } +} + +type ValidityUnit int + +const ( + ValidityUnitUnspecified ValidityUnit = iota + ValidityUnitDays + ValidityUnitMonths + ValidityUnitYears +) + +// Domain Models + +type RelativeValidity struct { + Value int32 + Unit ValidityUnit +} + +// CertificateLifetime represents the oneof field. +// In pure Go, using pointers allows us to check which field is active (not nil). +type CertificateLifetime struct { + Duration *time.Duration + NotAfter *time.Time + Relative *RelativeValidity +} + +type Subject struct { CommonName string - Localities []string - Validity *CertificateValidity - PrivateKey *CertificatePrivateKey + //OrganizationalUnit []string + //Organization []string + //Locality []string + //Province []string + //Country []string + + //AdvancedAttributes *AdvancedSubjectAttributes +} + +//type AdvancedSubjectAttributes struct { +// SerialNumber *string +// StreetAddress []string +// PostalCode []string +//} + +type PrivateKey struct { + Data []byte + Format KeyFormat +} + +type IssueCertificateRequest struct { + Lifetime CertificateLifetime + Subject Subject + PrivateKey *PrivateKey + PreferredFormat CertificateFormat } type IssueCertificateResponse struct { - // V1 Fields - ChainPem string + CertificateData []byte + Format CertificateFormat + CAChain [][]byte } -type CertificateValidity struct { - // V1 Fields - Value int64 - Type ValidityType +type SupportedKeyFormatsError struct { + RejectedFormat string + SupportedFormats []KeyFormat + Reason string } -type CertificatePrivateKey struct { - // V1 Fields - Data []byte +func (e *SupportedKeyFormatsError) Error() string { + var formats []string + for _, f := range e.SupportedFormats { + formats = append(formats, f.String()) + } + + return fmt.Sprintf("unsupported private key format '%s': %s (supported formats: %s)", + e.RejectedFormat, + e.Reason, + strings.Join(formats, ", "), + ) } diff --git a/service/api/certificateissuer/parse_certificate_chain.go b/service/api/certificateissuer/parse_certificate_chain.go new file mode 100644 index 0000000..aff8024 --- /dev/null +++ b/service/api/certificateissuer/parse_certificate_chain.go @@ -0,0 +1,142 @@ +package certificateissuer + +import ( + "crypto/x509" + "encoding/pem" + "errors" + "fmt" + + "github.com/cloudflare/cfssl/crypto/pkcs7" +) + +// ParseCertificateChain extracts the leaf certificate and its accompanying CA chain. +// Cognitive Complexity: drastically reduced by delegating parsing to parseBytes. +func (resp *IssueCertificateResponse) ParseCertificateChain() ([]*x509.Certificate, error) { + if len(resp.CertificateData) == 0 { + return nil, errors.New("certificate data is empty") + } + + var rawCerts []*x509.Certificate + + // Parse main payload + certs, err := parseBytes(resp.CertificateData, resp.Format) + if err != nil { + return nil, fmt.Errorf("failed to parse certificate data: %w", err) + } + rawCerts = append(rawCerts, certs...) + + // Parse CA chain elements + for i, caBytes := range resp.CAChain { + certs, err := parseBytes(caBytes, resp.Format) + if err != nil { + return nil, fmt.Errorf("failed to parse CA chain at index %d: %w", i, err) + } + rawCerts = append(rawCerts, certs...) + } + + return orderCertificateChain(rawCerts), nil +} + +// parseBytes is a dedicated helper that handles the format switching. +// This isolates the branching logic from the iteration logic. +func parseBytes(data []byte, format CertificateFormat) ([]*x509.Certificate, error) { + switch format { + case CertificateFormatDER: + cert, err := x509.ParseCertificate(data) + if err != nil { + return nil, err + } + return []*x509.Certificate{cert}, nil + + case CertificateFormatPEM, CertificateFormatUnspecified: + block, _ := pem.Decode(data) + if block == nil || block.Type != "CERTIFICATE" { + return nil, errors.New("failed to decode valid PEM CERTIFICATE block") + } + cert, err := x509.ParseCertificate(block.Bytes) + if err != nil { + return nil, err + } + return []*x509.Certificate{cert}, nil + + case CertificateFormatPKCS7: + p7, err := pkcs7.ParsePKCS7(data) + if err != nil { + return nil, err + } + if len(p7.Content.SignedData.Certificates) == 0 { + return nil, errors.New("no certificates found in the PKCS7 container") + } + return p7.Content.SignedData.Certificates, nil + + default: + return nil, errors.New("unsupported certificate format") + } +} + +// orderCertificateChain logically orders an unsorted slice of certificates. +// Cognitive Complexity: drastically reduced by using maps instead of nested loops. +func orderCertificateChain(certs []*x509.Certificate) []*x509.Certificate { + if len(certs) <= 1 { + return certs + } + + subjects := make(map[string]*x509.Certificate) + issuers := make(map[string]bool) + + // Build O(1) lookup maps + for _, cert := range certs { + subjects[string(cert.RawSubject)] = cert + issuers[string(cert.RawIssuer)] = true + } + + leaf := findLeaf(certs, issuers) + if leaf == nil { + return certs // Fallback if no clean leaf is found + } + + return buildChainFromLeaf(leaf, subjects, len(certs)) +} + +// findLeaf identifies the certificate that hasn't issued any other certificate in the pool. +func findLeaf(certs []*x509.Certificate, issuers map[string]bool) *x509.Certificate { + for _, cert := range certs { + if !issuers[string(cert.RawSubject)] { + return cert + } + } + return nil +} + +// buildChainFromLeaf walks up the cryptographic chain using the subjects map. +func buildChainFromLeaf(leaf *x509.Certificate, subjects map[string]*x509.Certificate, total int) []*x509.Certificate { + ordered := make([]*x509.Certificate, 0, total) + ordered = append(ordered, leaf) + + // Track added certs to prevent infinite loops (e.g., self-signed roots) + added := make(map[string]bool) + added[string(leaf.RawSubject)] = true + + current := leaf + for len(ordered) < total { + parent, exists := subjects[string(current.RawIssuer)] + + // Break if the chain breaks or we hit a circular loop/self-signed root + if !exists || added[string(parent.RawSubject)] { + break + } + + ordered = append(ordered, parent) + added[string(parent.RawSubject)] = true + current = parent + } + + // Append any remaining disconnected certificates + for _, cert := range subjects { + if !added[string(cert.RawSubject)] { + ordered = append(ordered, cert) + } + } + + return ordered +} diff --git a/service/api/notification/notification.go b/service/api/notification/notification.go index e4b81c3..219ff4f 100644 --- a/service/api/notification/notification.go +++ b/service/api/notification/notification.go @@ -12,22 +12,73 @@ type Notification interface { Send(ctx context.Context, req *SendNotificationRequest) (*SendNotificationResponse, error) } -type Type int32 +// Enums translated to pure Go types + +type DeliveryChannel int const ( - Unspecified Type = iota - Email - Text - Web + DeliveryChannelUnspecified DeliveryChannel = iota + DeliveryChannelEmail + DeliveryChannelSMS + DeliveryChannelPush + DeliveryChannelInApp ) +func (d DeliveryChannel) String() string { + switch d { + case DeliveryChannelEmail: + return "EMAIL" + case DeliveryChannelSMS: + return "SMS" + case DeliveryChannelPush: + return "PUSH" + case DeliveryChannelInApp: + return "IN_APP" + default: + return "UNSPECIFIED" + } +} + +// Domain Models + +// Recipient uses pointers to represent the oneof field. +// Only one of these should be non-nil. +type Recipient struct { + EmailAddress *string + PhoneNumber *string + DeviceToken *string + UserID *string +} + +type RawMessage struct { + Subject string + Body string + Metadata map[string]string +} + +type TemplateMessage struct { + TemplateID string + Parameters map[string]string +} + +// Content uses pointers for the oneof field. +type Content struct { + Raw *RawMessage + Template *TemplateMessage +} + type SendNotificationRequest struct { - // V1 Fields - Type Type - Recipients []string - Subject string - Body string + Recipients []Recipient + Content Content + PreferredChannel DeliveryChannel +} + +type DeliveryFailure struct { + Recipient Recipient + ErrorReason string } type SendNotificationResponse struct { + TrackingID string + PartialFailures []DeliveryFailure } diff --git a/service/wrapper/certificate_issuer/v1.go b/service/wrapper/certificate_issuer/v1.go index c37417e..a109ab0 100644 --- a/service/wrapper/certificate_issuer/v1.go +++ b/service/wrapper/certificate_issuer/v1.go @@ -5,6 +5,9 @@ import ( "fmt" "buf.build/go/protovalidate" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/durationpb" + "google.golang.org/protobuf/types/known/timestamppb" "github.com/openkcm/plugin-sdk/api" "github.com/openkcm/plugin-sdk/pkg/plugin" @@ -14,7 +17,7 @@ import ( type V1 struct { plugin.Facade - grpccertificateissuerv1.CertificateIssuerServicePluginClient + grpccertificateissuerv1.CertificateIssuerPluginClient } func (v1 *V1) Version() uint { @@ -26,40 +29,105 @@ func (v1 *V1) ServiceInfo() api.Info { } func (v1 *V1) IssueCertificate(ctx context.Context, req *certificateissuer.IssueCertificateRequest) (*certificateissuer.IssueCertificateResponse, error) { - in := &grpccertificateissuerv1.GetCertificateRequest{ - CommonName: req.CommonName, - Locality: req.Localities, - Validity: CertificateValidityToGRPC(req.Validity), - PrivateKey: CertificatePrivateKeyToGRPC(req.PrivateKey), - } - if err := protovalidate.Validate(in); err != nil { + pbReq := mapRequestToProto(req) + + if err := protovalidate.Validate(pbReq); err != nil { return nil, fmt.Errorf("failed validation: %v", err) } - grpcResp, err := v1.GetCertificate(ctx, in) + pbResp, err := v1.CertificateIssuerPluginClient.IssueCertificate(ctx, pbReq) if err != nil { - return nil, err + return nil, handleGRPCError(err) } - return &certificateissuer.IssueCertificateResponse{ - ChainPem: grpcResp.CertificateChain, - }, nil + + return mapResponseToDomain(pbResp), nil } -func CertificateValidityToGRPC(v *certificateissuer.CertificateValidity) *grpccertificateissuerv1.GetCertificateValidity { - if v == nil { - return nil +func mapRequestToProto(req *certificateissuer.IssueCertificateRequest) *grpccertificateissuerv1.IssueCertificateRequest { + pbReq := &grpccertificateissuerv1.IssueCertificateRequest{ + PreferredFormat: grpccertificateissuerv1.IssueCertificateRequest_CertificateFormat(req.PreferredFormat), + Subject: &grpccertificateissuerv1.Subject{ + CommonName: req.Subject.CommonName, + + //Country: req.Subject.Country, + //Organization: req.Subject.Organization, + //OrganizationalUnit: req.Subject.OrganizationalUnit, + //Locality: req.Subject.Locality, + //Province: req.Subject.Province, + }, + } + + //if req.Subject.AdvancedAttributes != nil { + // pbReq.Subject.AdvancedAttributes = &grpccertificateissuerv1.AdvancedSubjectAttributes{ + // SerialNumber: req.Subject.AdvancedAttributes.SerialNumber, + // StreetAddress: req.Subject.AdvancedAttributes.StreetAddress, + // PostalCode: req.Subject.AdvancedAttributes.PostalCode, + // } + //} + + if req.PrivateKey != nil { + pbReq.PrivateKey = &grpccertificateissuerv1.PrivateKey{ + Data: req.PrivateKey.Data, + Format: grpccertificateissuerv1.PrivateKey_KeyFormat(req.PrivateKey.Format), + } } - return &grpccertificateissuerv1.GetCertificateValidity{ - Value: v.Value, - Type: grpccertificateissuerv1.ValidityType(v.Type), + + switch { + case req.Lifetime.Duration != nil: + pbReq.Lifetime = &grpccertificateissuerv1.CertificateLifetime{ + Lifetime: &grpccertificateissuerv1.CertificateLifetime_Duration{ + Duration: durationpb.New(*req.Lifetime.Duration), + }, + } + case req.Lifetime.NotAfter != nil: + pbReq.Lifetime = &grpccertificateissuerv1.CertificateLifetime{ + Lifetime: &grpccertificateissuerv1.CertificateLifetime_NotAfter{ + NotAfter: timestamppb.New(*req.Lifetime.NotAfter), + }, + } + case req.Lifetime.Relative != nil: + pbReq.Lifetime = &grpccertificateissuerv1.CertificateLifetime{ + Lifetime: &grpccertificateissuerv1.CertificateLifetime_Relative{ + Relative: &grpccertificateissuerv1.RelativeValidity{ + Value: req.Lifetime.Relative.Value, + Unit: grpccertificateissuerv1.RelativeValidity_ValidityUnit(req.Lifetime.Relative.Unit), + }, + }, + } + } + + return pbReq +} + +func mapResponseToDomain(pbResp *grpccertificateissuerv1.IssueCertificateResponse) *certificateissuer.IssueCertificateResponse { + return &certificateissuer.IssueCertificateResponse{ + CertificateData: pbResp.CertificateData, + Format: certificateissuer.CertificateFormat(pbResp.Format), + CAChain: pbResp.CaChain, } } -func CertificatePrivateKeyToGRPC(pk *certificateissuer.CertificatePrivateKey) *grpccertificateissuerv1.PrivateKey { - if pk == nil { - return nil +func handleGRPCError(err error) error { + st, ok := status.FromError(err) + if !ok { + return err } - return &grpccertificateissuerv1.PrivateKey{ - Data: pk.Data, + + // Iterate over the "Any" details packed into the gRPC status + for _, detail := range st.Details() { + switch t := detail.(type) { + case *grpccertificateissuerv1.SupportedKeyFormatsError: + domainErr := &certificateissuer.SupportedKeyFormatsError{ + RejectedFormat: t.RejectedFormat, + Reason: t.Reason, + SupportedFormats: make([]certificateissuer.KeyFormat, len(t.SupportedFormats)), + } + for i, format := range t.SupportedFormats { + domainErr.SupportedFormats[i] = certificateissuer.KeyFormat(format) + } + return domainErr + } } + + return err } diff --git a/service/wrapper/identity_management/v1.go b/service/wrapper/identity_management/v1.go index 5ed02c3..fa4c07d 100644 --- a/service/wrapper/identity_management/v1.go +++ b/service/wrapper/identity_management/v1.go @@ -14,7 +14,7 @@ import ( type V1 struct { plugin.Facade - grpcidentitymanagementv1.IdentityManagementServicePluginClient + grpcidentitymanagementv1.IdentityManagementPluginClient } func (v1 *V1) Version() uint { @@ -33,8 +33,7 @@ func (v1 *V1) GetGroup(ctx context.Context, req *identitymanagement.GetGroupRequ if err := protovalidate.Validate(in); err != nil { return nil, fmt.Errorf("failed validation: %v", err) } - - grpcResp, err := v1.IdentityManagementServicePluginClient.GetGroup(ctx, in) + grpcResp, err := v1.IdentityManagementPluginClient.GetGroup(ctx, in) if err != nil { return nil, err } @@ -44,14 +43,13 @@ func (v1 *V1) GetGroup(ctx context.Context, req *identitymanagement.GetGroupRequ } func (v1 *V1) ListGroups(ctx context.Context, req *identitymanagement.ListGroupsRequest) (*identitymanagement.ListGroupsResponse, error) { - in := &grpcidentitymanagementv1.GetAllGroupsRequest{ + in := &grpcidentitymanagementv1.ListGroupsRequest{ AuthContext: AuthContextToGRPC(&req.AuthContext), } if err := protovalidate.Validate(in); err != nil { return nil, fmt.Errorf("failed validation: %v", err) } - - grpcResp, err := v1.GetAllGroups(ctx, in) + grpcResp, err := v1.IdentityManagementPluginClient.ListGroups(ctx, in) if err != nil { return nil, err } @@ -61,15 +59,14 @@ func (v1 *V1) ListGroups(ctx context.Context, req *identitymanagement.ListGroups } func (v1 *V1) ListGroupUsers(ctx context.Context, req *identitymanagement.ListGroupUsersRequest) (*identitymanagement.ListGroupUsersResponse, error) { - in := &grpcidentitymanagementv1.GetUsersForGroupRequest{ + in := &grpcidentitymanagementv1.ListGroupUsersRequest{ GroupId: req.GroupID, AuthContext: AuthContextToGRPC(&req.AuthContext), } if err := protovalidate.Validate(in); err != nil { return nil, fmt.Errorf("failed validation: %v", err) } - - grpcResp, err := v1.GetUsersForGroup(ctx, in) + grpcResp, err := v1.IdentityManagementPluginClient.ListGroupUsers(ctx, in) if err != nil { return nil, err } @@ -79,15 +76,14 @@ func (v1 *V1) ListGroupUsers(ctx context.Context, req *identitymanagement.ListGr } func (v1 *V1) ListUserGroups(ctx context.Context, req *identitymanagement.ListUserGroupsRequest) (*identitymanagement.ListUserGroupsResponse, error) { - in := &grpcidentitymanagementv1.GetGroupsForUserRequest{ + in := &grpcidentitymanagementv1.ListUserGroupsRequest{ UserId: req.UserID, AuthContext: AuthContextToGRPC(&req.AuthContext), } if err := protovalidate.Validate(in); err != nil { return nil, fmt.Errorf("failed validation: %v", err) } - - grpcResp, err := v1.GetGroupsForUser(ctx, in) + grpcResp, err := v1.IdentityManagementPluginClient.ListUserGroups(ctx, in) if err != nil { return nil, err } diff --git a/service/wrapper/key_management/v1.go b/service/wrapper/key_management/v1.go index edf7d01..f21c329 100644 --- a/service/wrapper/key_management/v1.go +++ b/service/wrapper/key_management/v1.go @@ -9,14 +9,19 @@ import ( "github.com/openkcm/plugin-sdk/api" "github.com/openkcm/plugin-sdk/pkg/plugin" - grpccommonv1 "github.com/openkcm/plugin-sdk/proto/plugin/keystore/common/v1" - grpckeymanagerv1 "github.com/openkcm/plugin-sdk/proto/plugin/keystore/operations/v1" + grpccommonv1 "github.com/openkcm/plugin-sdk/proto/plugin/common/v1" + grpckeymanagementv1 "github.com/openkcm/plugin-sdk/proto/plugin/key_management/v1" "github.com/openkcm/plugin-sdk/service/api/keymanagement" ) +const ( + msgFailedValidation = "failed to validate request object" + msgFailedParseValue = "failed to parse values" +) + type V1 struct { plugin.Facade - grpckeymanagerv1.KeystoreInstanceKeyOperationPluginClient + grpckeymanagementv1.KeyManagementPluginClient } func (v1 *V1) Version() uint { @@ -30,18 +35,21 @@ func (v1 *V1) ServiceInfo() api.Info { func (v1 *V1) GetKey(ctx context.Context, req *keymanagement.GetKeyRequest) (*keymanagement.GetKeyResponse, error) { value, err := structpb.NewStruct(req.Parameters.Config.Values) if err != nil { - return nil, fmt.Errorf("failed to parse values: %v", err) + return nil, failureError(msgFailedParseValue, err) } - in := &grpckeymanagerv1.GetKeyRequest{ - Parameters: &grpckeymanagerv1.RequestParameters{ - Config: &grpccommonv1.KeystoreInstanceConfig{ - Values: value, + in := &grpckeymanagementv1.GetKeyRequest{ + Parameters: &grpckeymanagementv1.RequestParameters{ + KeystoreConfig: &grpccommonv1.KeystoreConfig{ + ConfigurationParameters: value, }, KeyId: req.Parameters.KeyID, }, } - grpcResp, err := v1.KeystoreInstanceKeyOperationPluginClient.GetKey(ctx, in) + if err := protovalidate.Validate(in); err != nil { + return nil, failureError(msgFailedValidation, err) + } + grpcResp, err := v1.KeyManagementPluginClient.GetKey(ctx, in) if err != nil { return nil, err } @@ -57,23 +65,22 @@ func (v1 *V1) GetKey(ctx context.Context, req *keymanagement.GetKeyRequest) (*ke func (v1 *V1) CreateKey(ctx context.Context, req *keymanagement.CreateKeyRequest) (*keymanagement.CreateKeyResponse, error) { value, err := structpb.NewStruct(req.Config.Values) if err != nil { - return nil, fmt.Errorf("failed to parse values: %v", err) + return nil, failureError(msgFailedParseValue, err) } - in := &grpckeymanagerv1.CreateKeyRequest{ - Config: &grpccommonv1.KeystoreInstanceConfig{ - Values: value, + in := &grpckeymanagementv1.CreateKeyRequest{ + KeystoreConfig: &grpccommonv1.KeystoreConfig{ + ConfigurationParameters: value, }, - Algorithm: grpckeymanagerv1.KeyAlgorithm(req.KeyAlgorithm), + Algorithm: grpckeymanagementv1.KeyAlgorithm(req.KeyAlgorithm), Id: req.ID, Region: req.Region, - KeyType: grpckeymanagerv1.KeyType(req.KeyType), + KeyType: grpckeymanagementv1.KeyType(req.KeyType), } if err := protovalidate.Validate(in); err != nil { - return nil, fmt.Errorf("failed validation: %v", err) + return nil, failureError(msgFailedValidation, err) } - - grpcResp, err := v1.KeystoreInstanceKeyOperationPluginClient.CreateKey(ctx, in) + grpcResp, err := v1.KeyManagementPluginClient.CreateKey(ctx, in) if err != nil { return nil, err } @@ -87,23 +94,22 @@ func (v1 *V1) CreateKey(ctx context.Context, req *keymanagement.CreateKeyRequest func (v1 *V1) DeleteKey(ctx context.Context, req *keymanagement.DeleteKeyRequest) (*keymanagement.DeleteKeyResponse, error) { value, err := structpb.NewStruct(req.Parameters.Config.Values) if err != nil { - return nil, fmt.Errorf("failed to parse values: %v", err) + return nil, failureError(msgFailedParseValue, err) } - in := &grpckeymanagerv1.DeleteKeyRequest{ - Parameters: &grpckeymanagerv1.RequestParameters{ - Config: &grpccommonv1.KeystoreInstanceConfig{ - Values: value, + in := &grpckeymanagementv1.DeleteKeyRequest{ + Parameters: &grpckeymanagementv1.RequestParameters{ + KeystoreConfig: &grpccommonv1.KeystoreConfig{ + ConfigurationParameters: value, }, KeyId: req.Parameters.KeyID, }, Window: req.Window, } if err := protovalidate.Validate(in); err != nil { - return nil, fmt.Errorf("failed validation: %v", err) + return nil, failureError(msgFailedValidation, err) } - - _, err = v1.KeystoreInstanceKeyOperationPluginClient.DeleteKey(ctx, in) + _, err = v1.KeyManagementPluginClient.DeleteKey(ctx, in) if err != nil { return nil, err } @@ -114,22 +120,21 @@ func (v1 *V1) DeleteKey(ctx context.Context, req *keymanagement.DeleteKeyRequest func (v1 *V1) EnableKey(ctx context.Context, req *keymanagement.EnableKeyRequest) (*keymanagement.EnableKeyResponse, error) { value, err := structpb.NewStruct(req.Parameters.Config.Values) if err != nil { - return nil, fmt.Errorf("failed to parse values: %v", err) + return nil, failureError(msgFailedParseValue, err) } - in := &grpckeymanagerv1.EnableKeyRequest{ - Parameters: &grpckeymanagerv1.RequestParameters{ - Config: &grpccommonv1.KeystoreInstanceConfig{ - Values: value, + in := &grpckeymanagementv1.EnableKeyRequest{ + Parameters: &grpckeymanagementv1.RequestParameters{ + KeystoreConfig: &grpccommonv1.KeystoreConfig{ + ConfigurationParameters: value, }, KeyId: req.Parameters.KeyID, }, } if err := protovalidate.Validate(in); err != nil { - return nil, fmt.Errorf("failed validation: %v", err) + return nil, failureError(msgFailedValidation, err) } - - _, err = v1.KeystoreInstanceKeyOperationPluginClient.EnableKey(ctx, in) + _, err = v1.KeyManagementPluginClient.EnableKey(ctx, in) if err != nil { return nil, err } @@ -140,23 +145,23 @@ func (v1 *V1) EnableKey(ctx context.Context, req *keymanagement.EnableKeyRequest func (v1 *V1) GetImportParameters(ctx context.Context, req *keymanagement.GetImportParametersRequest) (*keymanagement.GetImportParametersResponse, error) { value, err := structpb.NewStruct(req.Parameters.Config.Values) if err != nil { - return nil, fmt.Errorf("failed to parse values: %v", err) + return nil, failureError(msgFailedParseValue, err) } - in := &grpckeymanagerv1.GetImportParametersRequest{ - Parameters: &grpckeymanagerv1.RequestParameters{ - Config: &grpccommonv1.KeystoreInstanceConfig{ - Values: value, + in := &grpckeymanagementv1.GetImportParametersRequest{ + Parameters: &grpckeymanagementv1.RequestParameters{ + KeystoreConfig: &grpccommonv1.KeystoreConfig{ + ConfigurationParameters: value, }, KeyId: req.Parameters.KeyID, }, - Algorithm: grpckeymanagerv1.KeyAlgorithm(req.KeyAlgorithm), + Algorithm: grpckeymanagementv1.KeyAlgorithm(req.KeyAlgorithm), } if err := protovalidate.Validate(in); err != nil { - return nil, fmt.Errorf("failed validation: %v", err) + return nil, failureError(msgFailedValidation, err) } - grpcResp, err := v1.KeystoreInstanceKeyOperationPluginClient.GetImportParameters(ctx, in) + grpcResp, err := v1.KeyManagementPluginClient.GetImportParameters(ctx, in) if err != nil { return nil, err } @@ -170,28 +175,28 @@ func (v1 *V1) GetImportParameters(ctx context.Context, req *keymanagement.GetImp func (v1 *V1) ImportKeyMaterial(ctx context.Context, req *keymanagement.ImportKeyMaterialRequest) (*keymanagement.ImportKeyMaterialResponse, error) { value, err := structpb.NewStruct(req.Parameters.Config.Values) if err != nil { - return nil, fmt.Errorf("failed to parse values: %v", err) + return nil, failureError(msgFailedParseValue, err) } importParams, err := structpb.NewStruct(req.ImportParameters) if err != nil { - return nil, fmt.Errorf("failed to parse values: %v", err) + return nil, failureError(msgFailedParseValue, err) } - in := &grpckeymanagerv1.ImportKeyMaterialRequest{ - Parameters: &grpckeymanagerv1.RequestParameters{ - Config: &grpccommonv1.KeystoreInstanceConfig{ - Values: value, + in := &grpckeymanagementv1.ImportKeyMaterialRequest{ + Parameters: &grpckeymanagementv1.RequestParameters{ + KeystoreConfig: &grpccommonv1.KeystoreConfig{ + ConfigurationParameters: value, }, KeyId: req.Parameters.KeyID, }, ImportParameters: importParams, } if err := protovalidate.Validate(in); err != nil { - return nil, fmt.Errorf("failed validation: %v", err) + return nil, failureError(msgFailedValidation, err) } - _, err = v1.KeystoreInstanceKeyOperationPluginClient.ImportKeyMaterial(ctx, in) + _, err = v1.KeyManagementPluginClient.ImportKeyMaterial(ctx, in) if err != nil { return nil, err } @@ -200,17 +205,17 @@ func (v1 *V1) ImportKeyMaterial(ctx context.Context, req *keymanagement.ImportKe } func (v1 *V1) ValidateKey(ctx context.Context, req *keymanagement.ValidateKeyRequest) (*keymanagement.ValidateKeyResponse, error) { - in := &grpckeymanagerv1.ValidateKeyRequest{ - KeyType: grpckeymanagerv1.KeyType(req.KeyType), - Algorithm: grpckeymanagerv1.KeyAlgorithm(req.KeyAlgorithm), + in := &grpckeymanagementv1.ValidateKeyRequest{ + KeyType: grpckeymanagementv1.KeyType(req.KeyType), + Algorithm: grpckeymanagementv1.KeyAlgorithm(req.KeyAlgorithm), Region: req.Region, NativeKeyId: req.NativeKeyID, } if err := protovalidate.Validate(in); err != nil { - return nil, fmt.Errorf("failed validation: %v", err) + return nil, failureError(msgFailedValidation, err) } - grpcResp, err := v1.KeystoreInstanceKeyOperationPluginClient.ValidateKey(ctx, in) + grpcResp, err := v1.KeyManagementPluginClient.ValidateKey(ctx, in) if err != nil { return nil, err } @@ -224,22 +229,22 @@ func (v1 *V1) ValidateKey(ctx context.Context, req *keymanagement.ValidateKeyReq func (v1 *V1) ValidateKeyAccessData(ctx context.Context, req *keymanagement.ValidateKeyAccessDataRequest) (*keymanagement.ValidateKeyAccessDataResponse, error) { management, err := structpb.NewStruct(req.Management) if err != nil { - return nil, fmt.Errorf("failed to parse values: %v", err) + return nil, failureError(msgFailedParseValue, err) } crypto, err := structpb.NewStruct(req.Crypto) if err != nil { - return nil, fmt.Errorf("failed to parse values: %v", err) + return nil, failureError(msgFailedParseValue, err) } - in := &grpckeymanagerv1.ValidateKeyAccessDataRequest{ + in := &grpckeymanagementv1.ValidateKeyAccessDataRequest{ Management: management, Crypto: crypto, } if err := protovalidate.Validate(in); err != nil { - return nil, fmt.Errorf("failed validation: %v", err) + return nil, failureError(msgFailedValidation, err) } - grpcResp, err := v1.KeystoreInstanceKeyOperationPluginClient.ValidateKeyAccessData(ctx, in) + grpcResp, err := v1.KeyManagementPluginClient.ValidateKeyAccessData(ctx, in) if err != nil { return nil, err } @@ -251,15 +256,15 @@ func (v1 *V1) ValidateKeyAccessData(ctx context.Context, req *keymanagement.Vali } func (v1 *V1) TransformCryptoAccessData(ctx context.Context, req *keymanagement.TransformCryptoAccessDataRequest) (*keymanagement.TransformCryptoAccessDataResponse, error) { - in := &grpckeymanagerv1.TransformCryptoAccessDataRequest{ + in := &grpckeymanagementv1.TransformCryptoAccessDataRequest{ NativeKeyId: req.NativeKeyID, AccessData: req.AccessData, } if err := protovalidate.Validate(in); err != nil { - return nil, fmt.Errorf("failed validation: %v", err) + return nil, failureError(msgFailedValidation, err) } - grpcResp, err := v1.KeystoreInstanceKeyOperationPluginClient.TransformCryptoAccessData(ctx, in) + grpcResp, err := v1.KeyManagementPluginClient.TransformCryptoAccessData(ctx, in) if err != nil { return nil, err } @@ -272,18 +277,18 @@ func (v1 *V1) TransformCryptoAccessData(ctx context.Context, req *keymanagement. func (v1 *V1) ExtractKeyRegion(ctx context.Context, req *keymanagement.ExtractKeyRegionRequest) (*keymanagement.ExtractKeyRegionResponse, error) { management, err := structpb.NewStruct(req.ManagementAccessData) if err != nil { - return nil, fmt.Errorf("failed to parse values: %v", err) + return nil, failureError(msgFailedParseValue, err) } - in := &grpckeymanagerv1.ExtractKeyRegionRequest{ + in := &grpckeymanagementv1.ExtractKeyRegionRequest{ NativeKeyId: req.NativeKeyID, ManagementAccessData: management, } if err := protovalidate.Validate(in); err != nil { - return nil, fmt.Errorf("failed validation: %v", err) + return nil, failureError(msgFailedValidation, err) } - grpcResp, err := v1.KeystoreInstanceKeyOperationPluginClient.ExtractKeyRegion(ctx, in) + grpcResp, err := v1.KeyManagementPluginClient.ExtractKeyRegion(ctx, in) if err != nil { return nil, err } @@ -292,3 +297,7 @@ func (v1 *V1) ExtractKeyRegion(ctx context.Context, req *keymanagement.ExtractKe Region: grpcResp.GetRegion(), }, nil } + +func failureError(msg string, err error) error { + return fmt.Errorf(msg+": %v", err) +} diff --git a/service/wrapper/keystore_management/v1.go b/service/wrapper/keystore_management/v1.go index 04dc8bd..1f00137 100644 --- a/service/wrapper/keystore_management/v1.go +++ b/service/wrapper/keystore_management/v1.go @@ -9,15 +9,15 @@ import ( "github.com/openkcm/plugin-sdk/api" "github.com/openkcm/plugin-sdk/pkg/plugin" - grpccommonv1 "github.com/openkcm/plugin-sdk/proto/plugin/keystore/common/v1" - grpckeystoremanagementv1 "github.com/openkcm/plugin-sdk/proto/plugin/keystore/management/v1" + grpccommonv1 "github.com/openkcm/plugin-sdk/proto/plugin/common/v1" + grpckeystoremanagementv1 "github.com/openkcm/plugin-sdk/proto/plugin/keystore_management/v1" "github.com/openkcm/plugin-sdk/service/api/common" "github.com/openkcm/plugin-sdk/service/api/keystoremanagement" ) type V1 struct { plugin.Facade - grpckeystoremanagementv1.KeystoreProviderPluginClient + grpckeystoremanagementv1.KeystoreManagementPluginClient } func (v1 *V1) Version() uint { @@ -35,13 +35,12 @@ func (v1 *V1) CreateKeystore(ctx context.Context, req *keystoremanagement.Create } in := &grpckeystoremanagementv1.CreateKeystoreRequest{ - Values: value, + ConfigurationParameters: value, } if err := protovalidate.Validate(in); err != nil { return nil, fmt.Errorf("failed validation: %v", err) } - - grpcResp, err := v1.KeystoreProviderPluginClient.CreateKeystore(ctx, in) + grpcResp, err := v1.KeystoreManagementPluginClient.CreateKeystore(ctx, in) if err != nil { return nil, err } @@ -50,8 +49,8 @@ func (v1 *V1) CreateKeystore(ctx context.Context, req *keystoremanagement.Create Values: nil, }, } - if grpcResp.GetConfig() != nil || grpcResp.GetConfig().GetValues() != nil { - resp.Config.Values = grpcResp.GetConfig().GetValues().AsMap() + if grpcResp.GetConfig() != nil || grpcResp.GetConfig().GetConfigurationParameters() != nil { + resp.Config.Values = grpcResp.GetConfig().GetConfigurationParameters().AsMap() } return resp, nil } @@ -62,15 +61,15 @@ func (v1 *V1) DeleteKeystore(ctx context.Context, req *keystoremanagement.Delete return nil, fmt.Errorf("failed to parse values: %v", err) } in := &grpckeystoremanagementv1.DeleteKeystoreRequest{ - Config: &grpccommonv1.KeystoreInstanceConfig{ - Values: value, + Config: &grpccommonv1.KeystoreConfig{ + ConfigurationParameters: value, }, } if err := protovalidate.Validate(in); err != nil { return nil, fmt.Errorf("failed validation: %v", err) } - _, err = v1.KeystoreProviderPluginClient.DeleteKeystore(ctx, in) + _, err = v1.KeystoreManagementPluginClient.DeleteKeystore(ctx, in) if err != nil { return nil, err } diff --git a/service/wrapper/notification/v1.go b/service/wrapper/notification/v1.go index 724b244..04099da 100644 --- a/service/wrapper/notification/v1.go +++ b/service/wrapper/notification/v1.go @@ -2,7 +2,6 @@ package notification import ( "context" - "errors" "fmt" "buf.build/go/protovalidate" @@ -15,7 +14,7 @@ import ( type V1 struct { plugin.Facade - grpcnotification1.NotificationServicePluginClient + grpcnotification1.NotificationPluginClient } func (v1 *V1) Version() uint { @@ -27,24 +26,96 @@ func (v1 *V1) ServiceInfo() api.Info { } func (v1 *V1) Send(ctx context.Context, req *notification.SendNotificationRequest) (*notification.SendNotificationResponse, error) { - in := &grpcnotification1.SendNotificationRequest{ - NotificationType: grpcnotification1.NotificationType(req.Type), - Recipients: req.Recipients, - Subject: req.Subject, - Body: req.Body, - } - if err := protovalidate.Validate(in); err != nil { + pbReq := mapNotificationRequestToProto(req) + + if err := protovalidate.Validate(pbReq); err != nil { return nil, fmt.Errorf("failed validation: %v", err) } - grpcResp, err := v1.SendNotification(ctx, in) + pbResp, err := v1.NotificationPluginClient.Send(ctx, pbReq) if err != nil { return nil, err } - if !grpcResp.GetSuccess() { - return nil, errors.New(grpcResp.GetMessage()) + return mapNotificationResponseToDomain(pbResp), nil +} + +// Mapping Functions + +func mapNotificationRequestToProto(req *notification.SendNotificationRequest) *grpcnotification1.SendNotificationRequest { + pbReq := &grpcnotification1.SendNotificationRequest{ + PreferredChannel: grpcnotification1.DeliveryChannel(req.PreferredChannel), + Recipients: make([]*grpcnotification1.Recipient, 0, len(req.Recipients)), + } + + // Map Recipients array using a clean switch for the oneof + for _, r := range req.Recipients { + pbRecipient := &grpcnotification1.Recipient{} + switch { + case r.EmailAddress != nil: + pbRecipient.Target = &grpcnotification1.Recipient_EmailAddress{EmailAddress: *r.EmailAddress} + case r.PhoneNumber != nil: + pbRecipient.Target = &grpcnotification1.Recipient_PhoneNumber{PhoneNumber: *r.PhoneNumber} + case r.DeviceToken != nil: + pbRecipient.Target = &grpcnotification1.Recipient_DeviceToken{DeviceToken: *r.DeviceToken} + case r.UserID != nil: + pbRecipient.Target = &grpcnotification1.Recipient_UserId{UserId: *r.UserID} + } + pbReq.Recipients = append(pbReq.Recipients, pbRecipient) + } + + // Map Content oneof using a clean switch + pbReq.Content = &grpcnotification1.Content{} + switch { + case req.Content.Raw != nil: + pbReq.Content.Payload = &grpcnotification1.Content_Raw{ + Raw: &grpcnotification1.RawMessage{ + Subject: req.Content.Raw.Subject, + Body: req.Content.Raw.Body, + Metadata: req.Content.Raw.Metadata, + }, + } + case req.Content.Template != nil: + pbReq.Content.Payload = &grpcnotification1.Content_Template{ + Template: &grpcnotification1.TemplateMessage{ + TemplateId: req.Content.Template.TemplateID, + Parameters: req.Content.Template.Parameters, + }, + } + } + + return pbReq +} + +func mapNotificationResponseToDomain(pbResp *grpcnotification1.SendNotificationResponse) *notification.SendNotificationResponse { + domainResp := ¬ification.SendNotificationResponse{ + TrackingID: pbResp.TrackingId, + PartialFailures: make([]notification.DeliveryFailure, 0, len(pbResp.PartialFailures)), + } + + // Map partial failures back to domain objects + for _, pf := range pbResp.PartialFailures { + domainFailure := notification.DeliveryFailure{ + ErrorReason: pf.ErrorReason, + Recipient: notification.Recipient{}, + } + + if pf.Recipient != nil { + // Type switch to unpack the gRPC oneof into domain pointers + switch target := pf.Recipient.Target.(type) { + case *grpcnotification1.Recipient_EmailAddress: + domainFailure.Recipient.EmailAddress = &target.EmailAddress + case *grpcnotification1.Recipient_PhoneNumber: + domainFailure.Recipient.PhoneNumber = &target.PhoneNumber + case *grpcnotification1.Recipient_DeviceToken: + domainFailure.Recipient.DeviceToken = &target.DeviceToken + case *grpcnotification1.Recipient_UserId: + domainFailure.Recipient.UserID = &target.UserId + } + } + + domainResp.PartialFailures = append(domainResp.PartialFailures, domainFailure) } - return ¬ification.SendNotificationResponse{}, nil + return domainResp } diff --git a/service/wrapper/repository.go b/service/wrapper/repository.go index 23104ca..beb0bb5 100644 --- a/service/wrapper/repository.go +++ b/service/wrapper/repository.go @@ -8,26 +8,12 @@ import ( ) const ( - certificateIssuerType = "CertificateIssuer" - // TODO: value should go away after plugin proto refactoring - certificateIssuerServiceType = "CertificateIssuerService" - - notificationType = "Notification" - // TODO: value should go away after plugin proto refactoring - notificationServiceType = "NotificationService" - - systemInformationType = "SystemInformation" - // TODO: value should go away after plugin proto refactoring - systemInformationServiceType = "SystemInformationService" - + certificateIssuerType = "CertificateIssuer" + notificationType = "Notification" + systemInformationType = "SystemInformation" identityManagementType = "IdentityManagement" - // TODO: value should go away after plugin proto refactoring - identityManagementServiceType = "IdentityManagementService" - - // TODO: value should become `KeystoreManagement` after plugin proto refactoring - keystoreManagementType = "KeystoreProvider" - // TODO: value should become `KeyManagement` after plugin proto refactoring - keyManagementType = "KeystoreInstanceKeyOperation" + keystoreManagementType = "KeystoreManagement" + keyManagementType = "KeyManagement" ) type Repository struct { @@ -43,16 +29,12 @@ type Repository struct { func (repo *Repository) Plugins() map[string]api.PluginRepo { return map[string]api.PluginRepo{ - identityManagementType: &repo.identityManagementRepository, - identityManagementServiceType: &repo.identityManagementRepository, - certificateIssuerType: &repo.certificateIssuerRepository, - certificateIssuerServiceType: &repo.certificateIssuerRepository, - notificationType: &repo.notificationRepository, - notificationServiceType: &repo.notificationRepository, - systemInformationType: &repo.systemInformationRepository, - systemInformationServiceType: &repo.systemInformationRepository, - keystoreManagementType: &repo.keystoreManagementRepository, - keyManagementType: &repo.keyManagementRepository, + identityManagementType: &repo.identityManagementRepository, + certificateIssuerType: &repo.certificateIssuerRepository, + notificationType: &repo.notificationRepository, + systemInformationType: &repo.systemInformationRepository, + keystoreManagementType: &repo.keystoreManagementRepository, + keyManagementType: &repo.keyManagementRepository, } } diff --git a/service/wrapper/system_information/v1.go b/service/wrapper/system_information/v1.go index 64ffd80..b50bc22 100644 --- a/service/wrapper/system_information/v1.go +++ b/service/wrapper/system_information/v1.go @@ -8,13 +8,13 @@ import ( "github.com/openkcm/plugin-sdk/api" "github.com/openkcm/plugin-sdk/pkg/plugin" - systeminformationv1 "github.com/openkcm/plugin-sdk/proto/plugin/systeminformation/v1" + grpcsysteminformationv1 "github.com/openkcm/plugin-sdk/proto/plugin/system_information/v1" "github.com/openkcm/plugin-sdk/service/api/systeminformation" ) type V1 struct { plugin.Facade - systeminformationv1.SystemInformationServicePluginClient + grpcsysteminformationv1.SystemInformationPluginClient } func (v1 *V1) Version() uint { @@ -26,7 +26,7 @@ func (v1 *V1) ServiceInfo() api.Info { } func (v1 *V1) GetSystemInfo(ctx context.Context, req *systeminformation.GetSystemInfoRequest) (*systeminformation.GetSystemInfoResponse, error) { - in := &systeminformationv1.GetRequest{ + in := &grpcsysteminformationv1.GetInfoRequest{ Id: req.ID, Type: req.Type, } @@ -34,7 +34,7 @@ func (v1 *V1) GetSystemInfo(ctx context.Context, req *systeminformation.GetSyste return nil, fmt.Errorf("failed validation: %v", err) } - grpcResp, err := v1.Get(ctx, in) + grpcResp, err := v1.GetInfo(ctx, in) if err != nil { return nil, err }