Skip to content

Commit

Permalink
Add users pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
ohkinozomu committed Sep 21, 2022
1 parent 6b12eff commit d085bca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ In your go files, simply use:
import "github.com/snowplow-devops/redash-client-go/redash"
```

Then next `go mod tidy` or `go test` invocation will automatically
populate your `go.mod` with the last redash-client-go release, now
[![Version](https://img.shields.io/github/tag/snowplow-devops/redash-client-go.svg)](https://github.com/snowplow-devops/redash-client-go/releases).
(Note you can use `go mod vendor` to vendor your dependencies.)
Then next `go mod tidy` or `go test` invocation will automatically populate your `go.mod` with the last redash-client-go release, now [![Version](https://img.shields.io/github/tag/snowplow-devops/redash-client-go.svg)](https://github.com/snowplow-devops/redash-client-go/releases).

_Note_: you can use `go mod vendor` to vendor your dependencies.

From there, you will need to setup a new client in order to access API methods:

```
config := redash.Config{
RedashURI: "https://acme.com/",
Expand Down
4 changes: 3 additions & 1 deletion redash/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ type UserUpdatePayload struct {
}

//GetUsers returns a paginated list of users
func (c *Client) GetUsers() (*UserList, error) {
func (c *Client) GetUsers(page, pageSize int) (*UserList, error) {
path := "/api/users"

query := url.Values{}
query.Add("page", strconv.Itoa(page))
query.Add("page_size", strconv.Itoa(pageSize))
response, err := c.get(path, query)

if err != nil {
Expand Down

0 comments on commit d085bca

Please sign in to comment.