Repository: cloudflare/cloudflare-go (go)

Issue:
Accounts API does not have the `name` filter
### Confirmation

- [X] My issue isn't already found on the issue tracker.
- [X] I have replicated my issue using the latest version of the library and it is still present.

### cloudflare-go version

v0.31.0

### Go environment

❯ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/adyah/Library/Caches/go-build"
GOENV="/Users/adyah/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/adyah/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/adyah/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.17.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.17.5/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.17.5"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/adyah/Projects/cloudflare-operator/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/0q/sgy6jpw95rz3gk0nrh8g5ptc0000gn/T/go-build3211450902=/tmp/go-build -gno-record-gcc-switches -fno-common"


### Expected output

The Accounts endpoint supports a Query parameter for filtering by name as seen in [the API documentation](https://api.cloudflare.com/#accounts-list-accounts).

I expect the `cloudflare-go` [`API.Accounts`](https://pkg.go.dev/github.com/cloudflare/cloudflare-go#API.Accounts) to be feature compatible with the API.

### Actual output

Current implementation provides no such filter.

https://github.com/cloudflare/cloudflare-go/blob/7adbc2bba64175b7244eb3842cc655001fdf7c1d/accounts.go#L53

### Code demonstrating the issue

Run the default Accounts function.

### Steps to reproduce

Run the default Accounts function.

### References

_No response_

Pull request:
accounts: allow filtering by name for `Accounts`
closes #791

Patch:
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/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


Test patch:
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)