forked from ThalesGroup/kmip-go
-
Notifications
You must be signed in to change notification settings - Fork 2
/
op_locate.go
47 lines (35 loc) · 1.01 KB
/
op_locate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package kmip
import (
"context"
)
// 4.9 Locate
// Table 190
type LocateRequestPayload struct {
// MaximumItems uint32 // Required: No
// OffsetItems uint32 // Required: No
// StorageStatusMask kmip14.StorageStatusMask // Required: No
// ObjectGroupMember kmip14.ObjectGroupMember // Required: No
Attribute []Attribute // Required: No
}
// Table 191
type LocateResponsePayload struct {
UniqueIdentifier string // Required: No
}
type LocateHandler struct {
Locate func(ctx context.Context, payload *LocateRequestPayload) (*LocateResponsePayload, error)
}
func (h *LocateHandler) HandleItem(ctx context.Context, req *Request) (*ResponseBatchItem, error) {
var payload LocateRequestPayload
err := req.DecodePayload(&payload)
if err != nil {
return nil, err
}
respPayload, err := h.Locate(ctx, &payload)
if err != nil {
return nil, err
}
req.IDPlaceholder = respPayload.UniqueIdentifier
return &ResponseBatchItem{
ResponsePayload: respPayload,
}, nil
}