Browse Source

Add Keys method to kvstore

main
Sam 4 years ago
parent
commit
14c7ec6cec
  1. 19
      kvstore.go
  2. 11
      types.go

19
kvstore.go

@ -43,3 +43,22 @@ func (kv KV) Namespaces() (KVAPI, error) { @@ -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
}

11
types.go

@ -667,9 +667,15 @@ type kvParams struct { @@ -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 { @@ -882,6 +888,7 @@ type KV struct {
type kvInterface interface {
Namespaces() (KVAPI, error)
Keys(namespace string) (KVAPI, error)
}
type keybase interface {

Loading…
Cancel
Save