-
Notifications
You must be signed in to change notification settings - Fork 32
/
keyring_member.go
35 lines (29 loc) · 1.16 KB
/
keyring_member.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
package registry
import (
"context"
"github.com/manifoldco/torus-cli/envelope"
)
// KeyringMemberClientV1 represents the `/keyring-members` registry endpoint
// for creating memberships related to a set of Keyrings.
type KeyringMemberClientV1 struct {
client RoundTripper
}
// Post sends a creation requests for a set of KeyringMember objects to the
// registry.
func (k *KeyringMemberClientV1) Post(ctx context.Context, members []envelope.KeyringMemberV1) ([]envelope.KeyringMemberV1, error) {
resp := []envelope.KeyringMemberV1{}
err := k.client.RoundTrip(ctx, "POST", "/keyring-members", nil, members, &resp)
return resp, err
}
// KeyringMembersClient represents the `/keyring/:id/members` registry endpoint
// for creating memberships in a keyring.
type KeyringMembersClient struct {
client RoundTripper
}
// Post sends a creation requests for a set of KeyringMember objects to the
// registry.
func (k *KeyringMembersClient) Post(ctx context.Context, member KeyringMember) error {
keyringID := member.Member.Body.KeyringID
members := []KeyringMember{member}
return k.client.RoundTrip(ctx, "POST", "/keyrings/"+keyringID.String()+"/members", nil, members, nil)
}