From 3b4b5b66fd8dc7d157596908e24a45accc2dadf5 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 22 Jan 2020 07:58:32 -0500 Subject: [PATCH] Add put method for kvstore --- kvstore.go | 21 +++++++++++++++++++++ types.go | 1 + 2 files changed, 22 insertions(+) diff --git a/kvstore.go b/kvstore.go index 7f8eaf2..472f974 100644 --- a/kvstore.go +++ b/kvstore.go @@ -82,3 +82,24 @@ func (kv KV) Get(namespace string, key string) (KVAPI, error) { } return r, nil } + +// Put adds an entry +func (kv KV) Put(namespace string, key string, value string) (KVAPI, error) { + m := KVAPI{ + Params: &kvParams{}, + } + m.Params.Options = kvOptions{ + Team: kv.Team, + Namespace: namespace, + EntryKey: key, + EntryValue: value, + } + + m.Method = "put" + + r, err := kvAPIOut(kv.keybase, m) + if err != nil { + return r, err + } + return r, nil +} diff --git a/types.go b/types.go index c65aa99..7581df6 100644 --- a/types.go +++ b/types.go @@ -893,6 +893,7 @@ type kvInterface interface { Namespaces() (KVAPI, error) Keys(namespace string) (KVAPI, error) Get(namespace string, key string) (KVAPI, error) + Put(namespace string, key string, value string) (KVAPI, error) } type keybase interface {