diff --git a/kvstore.go b/kvstore.go index a1caf81..0d15522 100644 --- a/kvstore.go +++ b/kvstore.go @@ -43,3 +43,22 @@ func (kv KV) Namespaces() (KVAPI, error) { } return r, nil } + +// Keys returns all non-deleted keys for a namespace +func (kv KV) Keys(namespace string) (KVAPI, error) { + m := KVAPI{ + Params: &kvParams{}, + } + m.Params.Options = kvOptions{ + Team: kv.Team, + Namespace: namespace, + } + + m.Method = "list" + + r, err := kvAPIOut(kv.keybase, m) + if err != nil { + return r, err + } + return r, nil +} diff --git a/types.go b/types.go index b70d014..af01c2a 100644 --- a/types.go +++ b/types.go @@ -667,9 +667,15 @@ type kvParams struct { Options kvOptions `json:"options,omitempty"` } +type entryKey struct { + EntryKey string `json:"entryKey"` + Revision int `json:"revision"` +} + type kvResult struct { - TeamName string `json:"teamName"` - Namespaces []string `json:"namespaces"` + TeamName string `json:"teamName"` + Namespaces []string `json:"namespaces"` + EntryKeys []entryKey `json:"entryKeys"` } // UserAPI holds information received from the user/lookup api @@ -882,6 +888,7 @@ type KV struct { type kvInterface interface { Namespaces() (KVAPI, error) + Keys(namespace string) (KVAPI, error) } type keybase interface {