github.com/aiven/aiven-go-client@v1.36.0/account_team_invites.go (about) 1 package aiven 2 3 import ( 4 "errors" 5 "time" 6 ) 7 8 type ( 9 // AccountTeamInvitesHandler Aiven go-client handler for Account Invites 10 AccountTeamInvitesHandler struct { 11 client *Client 12 } 13 14 // AccountTeamInvitesResponse represents account team list of invites API response 15 AccountTeamInvitesResponse struct { 16 APIResponse 17 Invites []AccountTeamInvite `json:"account_invites"` 18 } 19 20 // AccountTeamInvite represents account team invite 21 AccountTeamInvite struct { 22 AccountId string `json:"account_id"` 23 AccountName string `json:"account_name"` 24 InvitedByUserEmail string `json:"invited_by_user_email"` 25 TeamId string `json:"team_id"` 26 TeamName string `json:"team_name"` 27 UserEmail string `json:"user_email"` 28 CreateTime *time.Time `json:"create_time,omitempty"` 29 } 30 ) 31 32 // List returns a list of all available account invitations 33 func (h AccountTeamInvitesHandler) List(accountId, teamId string) (*AccountTeamInvitesResponse, error) { 34 if accountId == "" || teamId == "" { 35 return nil, errors.New("cannot get a list of account team invites when account id or team id is empty") 36 } 37 38 path := buildPath("account", accountId, "team", teamId, "invites") 39 bts, err := h.client.doGetRequest(path, nil) 40 if err != nil { 41 return nil, err 42 } 43 44 var rsp AccountTeamInvitesResponse 45 if errR := checkAPIResponse(bts, &rsp); errR != nil { 46 return nil, errR 47 } 48 49 return &rsp, nil 50 } 51 52 // Delete deletes a list of all available account invitations 53 func (h AccountTeamInvitesHandler) Delete(accountId, teamId, userEmail string) error { 54 if accountId == "" || teamId == "" || userEmail == "" { 55 return errors.New("cannot delete an account team invite when account id or team id or user email is empty") 56 } 57 58 path := buildPath("account", accountId, "team", teamId, "invites", userEmail) 59 bts, err := h.client.doDeleteRequest(path, nil) 60 if err != nil { 61 return err 62 } 63 64 return checkAPIResponse(bts, nil) 65 }