-
Notifications
You must be signed in to change notification settings - Fork 32
/
profiles.go
33 lines (27 loc) · 919 Bytes
/
profiles.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
package registry
import (
"context"
"net/url"
"github.com/manifoldco/torus-cli/apitypes"
"github.com/manifoldco/torus-cli/identity"
)
// ProfilesClient makes proxied requests to the registry's profiles endpoints
type ProfilesClient struct {
client RoundTripper
}
// ListByName returns profiles looked up by username
func (p *ProfilesClient) ListByName(ctx context.Context, name string) (*apitypes.Profile, error) {
result := &apitypes.Profile{}
err := p.client.RoundTrip(ctx, "GET", "/profiles/"+name, nil, nil, &result)
return result, err
}
// ListByID returns profiles looked up by User ID
func (p *ProfilesClient) ListByID(ctx context.Context, userIDs []identity.ID) ([]apitypes.Profile, error) {
v := &url.Values{}
for _, id := range userIDs {
v.Add("id", id.String())
}
var results []apitypes.Profile
err := p.client.RoundTrip(ctx, "GET", "/profiles", v, nil, &results)
return results, err
}