Skip to content

Commit

Permalink
Add AccountService.GetAccountExternalIDs
Browse files Browse the repository at this point in the history
Add the type AccountExternalIdInfo to serve as return value. The
naming (Id rather than ID) is picked to be consistent with the Gerrit
documentation.
  • Loading branch information
hanwen authored and andygrunwald committed Aug 20, 2023
1 parent 999473b commit 1d229fd
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ type AccountDetailInfo struct {
RegisteredOn Timestamp `json:"registered_on"`
}

// AccountExternalIdInfo contains informations to link to external ID providers
type AccountExternalIdInfo struct {
Identity string `json:"identity"`
EmailAddress string `json:"email_address,omitempty"`
Trusted bool `json:"trusted"`
CanDelete bool `json:"can_delete,omitempty"`
}

// AccountNameInput entity contains information for setting a name for an account.
type AccountNameInput struct {
Name string `json:"name,omitempty"`
Expand Down Expand Up @@ -277,6 +285,26 @@ func (s *AccountsService) GetAccountDetails(accountID string) (*AccountDetailInf
return v, resp, err
}

// GetAccountExternalIDs returns AccountExternalIdInfo for the account
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#get-account-external-ids
func (s *AccountsService) GetAccountExternalIDs(accountID string) (*[]AccountExternalIdInfo, *Response, error) {
u := fmt.Sprintf("accounts/%s/external.ids", accountID)

req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}

v := new([]AccountExternalIdInfo)
resp, err := s.client.Do(req, v)
if err != nil {
return nil, resp, err
}

return v, resp, err
}

// GetAccountName retrieves the full name of an account.
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#get-account-name
Expand Down

0 comments on commit 1d229fd

Please sign in to comment.