feat(client): add pagination support

Closes #11
This commit is contained in:
Julien Dessaux 2025-05-20 21:45:08 +02:00
parent f04d7b341d
commit 412bbe0b37
Signed by: adyxax
GPG key ID: F92E51B86E07177E
5 changed files with 98 additions and 50 deletions

View file

@ -21,14 +21,8 @@ type Team struct {
func (c *Client) TeamsList(ctx context.Context, organizationName string) ([]Team, error) {
var response []Team
query := make(url.Values)
query.Set("limit", "50")
query.Set("page", "1")
uriRef := url.URL{
Path: path.Join("api/v1/orgs", organizationName, "teams"),
RawQuery: query.Encode(),
}
if err := c.Send(ctx, "GET", &uriRef, nil, &response); err != nil {
uriRef := url.URL{Path: path.Join("api/v1/orgs", organizationName, "teams")}
if err := c.sendPaginated(ctx, "GET", &uriRef, nil, &response); err != nil {
return nil, fmt.Errorf("failed to list teams of organization %s: %w", organizationName, err)
}
return response, nil