-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Get,Destroy) New commands added by BK Sim (#13)
Signed-off-by: Joe Skazinski <[email protected]>
- Loading branch information
1 parent
4dd2d91
commit aeff56b
Showing
4 changed files
with
83 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package kmip | ||
|
||
import ( | ||
"context" | ||
//"github.com/gemalto/kmip-go/kmip14" | ||
) | ||
|
||
// DestroyRequestPayload //////////////////////////////////////// | ||
// | ||
type DestroyRequestPayload struct { | ||
UniqueIdentifier string | ||
} | ||
|
||
// DestroyResponsePayload | ||
type DestroyResponsePayload struct { | ||
UniqueIdentifier string | ||
} | ||
|
||
type DestroyHandler struct { | ||
Destroy func(ctx context.Context, payload *DestroyRequestPayload) (*DestroyResponsePayload, error) | ||
} | ||
|
||
func (h *DestroyHandler) HandleItem(ctx context.Context, req *Request) (*ResponseBatchItem, error) { | ||
var payload DestroyRequestPayload | ||
err := req.DecodePayload(&payload) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
respPayload, err := h.Destroy(ctx, &payload) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
//req.Key = respPayload.Key | ||
|
||
return &ResponseBatchItem{ | ||
ResponsePayload: respPayload, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package kmip | ||
|
||
import ( | ||
"context" | ||
"github.com/gemalto/kmip-go/kmip14" | ||
) | ||
|
||
// GetRequestPayload //////////////////////////////////////// | ||
// | ||
type GetRequestPayload struct { | ||
UniqueIdentifier string | ||
} | ||
|
||
// GetResponsePayload | ||
type GetResponsePayload struct { | ||
ObjectType kmip14.ObjectType | ||
UniqueIdentifier string | ||
Key string | ||
} | ||
|
||
type GetHandler struct { | ||
Get func(ctx context.Context, payload *GetRequestPayload) (*GetResponsePayload, error) | ||
} | ||
|
||
func (h *GetHandler) HandleItem(ctx context.Context, req *Request) (*ResponseBatchItem, error) { | ||
var payload GetRequestPayload | ||
err := req.DecodePayload(&payload) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
respPayload, err := h.Get(ctx, &payload) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
//req.Key = respPayload.Key | ||
|
||
return &ResponseBatchItem{ | ||
ResponsePayload: respPayload, | ||
}, nil | ||
} |