Skip to content

Commit

Permalink
Add AccountService.QueryAccounts
Browse files Browse the repository at this point in the history
  • Loading branch information
hanwen authored and andygrunwald committed Aug 20, 2023
1 parent 1d229fd commit 8a06083
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ type QueryAccountOptions struct {

// The `S` or `start` query parameter can be supplied to skip a number of accounts from the list.
Start int `url:"S,omitempty"`

AccountOptions
}

// AccountOptions specifies parameters for Query Accounts.
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#query-account
type AccountOptions struct {
// Additional fields can be obtained by adding o parameters.
// Currently supported are "DETAILS" and "ALL_EMAILS".
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#query-account
AdditionalFields []string `url:"o,omitempty"`
}

// SSHKeyInfo entity contains information about an SSH key of a user.
Expand Down Expand Up @@ -244,6 +257,33 @@ type CapabilityOptions struct {
Filter []string `url:"q,omitempty"`
}

// QueryAccounts lists accounts visible to the caller.
// The query string must be provided by the q parameter.
// The n parameter can be used to limit the returned results.
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#query-accounts
func (s *AccountsService) QueryAccounts(opt *QueryAccountOptions) (*[]AccountInfo, *Response, error) {
u := "accounts/"

u, err := addOptions(u, opt)
if err != nil {
return nil, nil, err
}

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

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

return v, resp, err
}

// GetAccount returns an account as an AccountInfo entity.
// If account is "self" the current authenticated account will be returned.
//
Expand Down

0 comments on commit 8a06083

Please sign in to comment.