Add Keys method to kvstore
This commit is contained in:
19
kvstore.go
19
kvstore.go
@ -43,3 +43,22 @@ func (kv KV) Namespaces() (KVAPI, error) {
|
|||||||
}
|
}
|
||||||
return r, nil
|
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
11
types.go
@ -667,9 +667,15 @@ type kvParams struct {
|
|||||||
Options kvOptions `json:"options,omitempty"`
|
Options kvOptions `json:"options,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type entryKey struct {
|
||||||
|
EntryKey string `json:"entryKey"`
|
||||||
|
Revision int `json:"revision"`
|
||||||
|
}
|
||||||
|
|
||||||
type kvResult struct {
|
type kvResult struct {
|
||||||
TeamName string `json:"teamName"`
|
TeamName string `json:"teamName"`
|
||||||
Namespaces []string `json:"namespaces"`
|
Namespaces []string `json:"namespaces"`
|
||||||
|
EntryKeys []entryKey `json:"entryKeys"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserAPI holds information received from the user/lookup api
|
// UserAPI holds information received from the user/lookup api
|
||||||
@ -882,6 +888,7 @@ type KV struct {
|
|||||||
|
|
||||||
type kvInterface interface {
|
type kvInterface interface {
|
||||||
Namespaces() (KVAPI, error)
|
Namespaces() (KVAPI, error)
|
||||||
|
Keys(namespace string) (KVAPI, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type keybase interface {
|
type keybase interface {
|
||||||
|
|||||||
Reference in New Issue
Block a user