-
Notifications
You must be signed in to change notification settings - Fork 28
/
account_team_invites.go
66 lines (55 loc) · 1.98 KB
/
account_team_invites.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package aiven
import (
"context"
"errors"
"time"
)
type (
// AccountTeamInvitesHandler Aiven go-client handler for Account Invites
AccountTeamInvitesHandler struct {
client *Client
}
// AccountTeamInvitesResponse represents account team list of invites API response
AccountTeamInvitesResponse struct {
APIResponse
Invites []AccountTeamInvite `json:"account_invites"`
}
// AccountTeamInvite represents account team invite
AccountTeamInvite struct {
AccountId string `json:"account_id"`
AccountName string `json:"account_name"`
InvitedByUserEmail string `json:"invited_by_user_email"`
TeamId string `json:"team_id"`
TeamName string `json:"team_name"`
UserEmail string `json:"user_email"`
CreateTime *time.Time `json:"create_time,omitempty"`
}
)
// List returns a list of all available account invitations
func (h AccountTeamInvitesHandler) List(ctx context.Context, accountId, teamId string) (*AccountTeamInvitesResponse, error) {
if accountId == "" || teamId == "" {
return nil, errors.New("cannot get a list of account team invites when account id or team id is empty")
}
path := buildPath("account", accountId, "team", teamId, "invites")
bts, err := h.client.doGetRequest(ctx, path, nil)
if err != nil {
return nil, err
}
var rsp AccountTeamInvitesResponse
if errR := checkAPIResponse(bts, &rsp); errR != nil {
return nil, errR
}
return &rsp, nil
}
// Delete deletes a list of all available account invitations
func (h AccountTeamInvitesHandler) Delete(ctx context.Context, accountId, teamId, userEmail string) error {
if accountId == "" || teamId == "" || userEmail == "" {
return errors.New("cannot delete an account team invite when account id or team id or user email is empty")
}
path := buildPath("account", accountId, "team", teamId, "invites", userEmail)
bts, err := h.client.doDeleteRequest(ctx, path, nil)
if err != nil {
return err
}
return checkAPIResponse(bts, nil)
}