Skip to content

Commit

Permalink
feat: Deprecate Client.ListKeys in favor of Client.ListAPIKeys (closes
Browse files Browse the repository at this point in the history
  • Loading branch information
aseure committed Apr 11, 2018
1 parent 0eae8c2 commit 39bd6c1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
12 changes: 12 additions & 0 deletions algoliasearch/algoliasearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,24 @@ type Client interface {

// ListKeys returns all the API keys available for this Algolia
// application.
//
// Deprecated: Use ListAPIKeys instead.
ListKeys() (keys []Key, err error)

// ListKeysWithRequestOptions is the same as ListKeys but it also accepts
// extra RequestOptions.
//
// Deprecated: Use ListAPIKeysWithRequestOptions instead.
ListKeysWithRequestOptions(opts *RequestOptions) (keys []Key, err error)

// ListAPIKeys returns all the API keys available for this Algolia
// application.
ListAPIKeys() (keys []Key, err error)

// ListAPIKeysWithRequestOptions is the same as ListKeys but it also
// accepts extra RequestOptions.
ListAPIKeysWithRequestOptions(opts *RequestOptions) (keys []Key, err error)

// MoveIndex renames the index named `source` as `destination`.
MoveIndex(source, destination string) (UpdateTaskRes, error)

Expand Down
12 changes: 10 additions & 2 deletions algoliasearch/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,19 @@ func (c *client) InitIndex(name string) Index {
}

func (c *client) ListKeys() (keys []Key, err error) {
return c.ListKeysWithRequestOptions(nil)
return c.ListAPIKeys()
}

func (c *client) ListKeysWithRequestOptions(opts *RequestOptions) (keys []Key, err error) {
var res listKeysRes
return c.ListAPIKeysWithRequestOptions(opts)
}

func (c *client) ListAPIKeys() (keys []Key, err error) {
return c.ListAPIKeysWithRequestOptions(nil)
}

func (c *client) ListAPIKeysWithRequestOptions(opts *RequestOptions) (keys []Key, err error) {
var res listAPIKeysRes
err = c.request(&res, "GET", "/1/keys", nil, read, opts)
keys = res.Keys
return
Expand Down
2 changes: 1 addition & 1 deletion algoliasearch/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (i *index) ListKeys() (keys []Key, err error) {
}

func (i *index) ListKeysWithRequestOptions(opts *RequestOptions) (keys []Key, err error) {
var res listKeysRes
var res listAPIKeysRes

path := i.route + "/keys"
err = i.client.request(&res, "GET", path, nil, read, opts)
Expand Down
2 changes: 1 addition & 1 deletion algoliasearch/types_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Key struct {
Value string `json:"value,omitempty"`
}

type listKeysRes struct {
type listAPIKeysRes struct {
Keys []Key `json:"keys"`
}

Expand Down

0 comments on commit 39bd6c1

Please sign in to comment.