diff --git a/accounts.go b/accounts.go index 0013be28c..2e5b0f878 100644 --- a/accounts.go +++ b/accounts.go @@ -48,13 +48,20 @@ type AccountDetailResponse struct { Result Account `json:"result"` } +// AccountsListParams holds the filterable options for Accounts. +type AccountsListParams struct { + Name string `url:"name"` + + PaginationOptions +} + // Accounts returns all accounts the logged in user has access to. // // API reference: https://api.cloudflare.com/#accounts-list-accounts -func (api *API) Accounts(ctx context.Context, pageOpts PaginationOptions) ([]Account, ResultInfo, error) { +func (api *API) Accounts(ctx context.Context, params AccountsListParams) ([]Account, ResultInfo, error) { uri := "/accounts" - v, _ := query.Values(pageOpts) + v, _ := query.Values(params) queryParams := v.Encode() if queryParams != "" { queryParams = "?" + queryParams diff --git a/accounts_test.go b/accounts_test.go index c630d284a..53455372a 100644 --- a/accounts_test.go +++ b/accounts_test.go @@ -57,7 +57,7 @@ func TestAccounts(t *testing.T) { mux.HandleFunc("/accounts", handler) want := []Account{expectedAccountStruct} - actual, _, err := client.Accounts(context.Background(), PaginationOptions{}) + actual, _, err := client.Accounts(context.Background(), AccountsListParams{}) if assert.NoError(t, err) { assert.Equal(t, want, actual) diff --git a/cmd/flarectl/firewall.go b/cmd/flarectl/firewall.go index 04b5b0e16..a8df00cfa 100644 --- a/cmd/flarectl/firewall.go +++ b/cmd/flarectl/firewall.go @@ -316,8 +316,8 @@ func getScope(c *cli.Context) (string, string, error) { var account, accountID string if c.String("account") != "" { account = c.String("account") - pageOpts := cloudflare.PaginationOptions{} - accounts, _, err := api.Accounts(context.Background(), pageOpts) + params := cloudflare.AccountsListParams{} + accounts, _, err := api.Accounts(context.Background(), params) if err != nil { fmt.Println(err) return "", "", err