-
Notifications
You must be signed in to change notification settings - Fork 32
/
teams.go
42 lines (34 loc) · 925 Bytes
/
teams.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package registry
import (
"context"
"errors"
"log"
"net/url"
"github.com/manifoldco/torus-cli/envelope"
"github.com/manifoldco/torus-cli/identity"
)
// TeamsClient represents the `/teams` registry endpoint, used for
// accessing teams stored in Torus.
type TeamsClient struct {
client *Client
}
// List returns all teams for an organization
func (t *TeamsClient) List(ctx context.Context, orgID *identity.ID) ([]envelope.Unsigned, error) {
if orgID == nil {
return nil, errors.New("must provide org id")
}
v := &url.Values{}
v.Set("org_id", orgID.String())
req, err := t.client.NewRequest("GET", "/teams", v, nil)
if err != nil {
log.Printf("Error building GET /teams request: %s", err)
return nil, err
}
teams := []envelope.Unsigned{}
_, err = t.client.Do(ctx, req, &teams)
if err != nil {
log.Printf("Error performing GET /teams request: %s", err)
return nil, err
}
return teams, nil
}