ceph-csi/vendor/github.com/gemalto/kmip-go/op_discover_versions.go
Rakshith R e72ed593be rebase: vendor files required for kmip
Signed-off-by: Rakshith R <rar@redhat.com>
2022-08-18 07:41:42 +00:00

48 lines
962 B
Go

package kmip
import (
"context"
)
// 4.26
type DiscoverVersionsRequestPayload struct {
ProtocolVersion []ProtocolVersion
}
type DiscoverVersionsResponsePayload struct {
ProtocolVersion []ProtocolVersion
}
type DiscoverVersionsHandler struct {
SupportedVersions []ProtocolVersion
}
func (h *DiscoverVersionsHandler) HandleItem(ctx context.Context, req *Request) (item *ResponseBatchItem, err error) {
var payload DiscoverVersionsRequestPayload
err = req.DecodePayload(&payload)
if err != nil {
return nil, err
}
var respPayload DiscoverVersionsResponsePayload
if len(payload.ProtocolVersion) == 0 {
respPayload.ProtocolVersion = h.SupportedVersions
} else {
for _, v := range h.SupportedVersions {
for _, cv := range payload.ProtocolVersion {
if cv == v {
respPayload.ProtocolVersion = append(respPayload.ProtocolVersion, v)
break
}
}
}
}
return &ResponseBatchItem{
ResponsePayload: respPayload,
}, nil
}