Skip to content

Commit 8a06083

Browse files
hanwenandygrunwald
authored andcommitted
Add AccountService.QueryAccounts
1 parent 1d229fd commit 8a06083

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

accounts.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ type QueryAccountOptions struct {
4040

4141
// The `S` or `start` query parameter can be supplied to skip a number of accounts from the list.
4242
Start int `url:"S,omitempty"`
43+
44+
AccountOptions
45+
}
46+
47+
// AccountOptions specifies parameters for Query Accounts.
48+
//
49+
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#query-account
50+
type AccountOptions struct {
51+
// Additional fields can be obtained by adding o parameters.
52+
// Currently supported are "DETAILS" and "ALL_EMAILS".
53+
//
54+
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#query-account
55+
AdditionalFields []string `url:"o,omitempty"`
4356
}
4457

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

260+
// QueryAccounts lists accounts visible to the caller.
261+
// The query string must be provided by the q parameter.
262+
// The n parameter can be used to limit the returned results.
263+
//
264+
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#query-accounts
265+
func (s *AccountsService) QueryAccounts(opt *QueryAccountOptions) (*[]AccountInfo, *Response, error) {
266+
u := "accounts/"
267+
268+
u, err := addOptions(u, opt)
269+
if err != nil {
270+
return nil, nil, err
271+
}
272+
273+
req, err := s.client.NewRequest("GET", u, nil)
274+
if err != nil {
275+
return nil, nil, err
276+
}
277+
278+
v := new([]AccountInfo)
279+
resp, err := s.client.Do(req, v)
280+
if err != nil {
281+
return nil, resp, err
282+
}
283+
284+
return v, resp, err
285+
}
286+
247287
// GetAccount returns an account as an AccountInfo entity.
248288
// If account is "self" the current authenticated account will be returned.
249289
//

0 commit comments

Comments
 (0)