Skip to content

Commit

Permalink
Address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-alberto committed Feb 1, 2024
1 parent 2040236 commit 2a4f155
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
13 changes: 7 additions & 6 deletions hyperdrive.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ type HyperdriveConfigOrigin struct {
}

type HyperdriveConfigCaching struct {
Disabled bool `json:"disabled,omitempty"`
MaxAge int `json:"max_age,omitempty"`
StaleWhileRevalidate int `json:"stale_while_revalidate,omitempty"`
Disabled *bool `json:"disabled,omitempty"`
MaxAge int `json:"max_age,omitempty"`
StaleWhileRevalidate int `json:"stale_while_revalidate,omitempty"`
}

type HyperdriveConfigListResponse struct {
Expand Down Expand Up @@ -61,16 +61,17 @@ type UpdateHyperdriveConfigParams struct {
Caching HyperdriveConfigCaching `json:"caching,omitempty"`
}

type ListHyperdriveConfigParams struct{}

// ListHyperdriveConfigs returns the Hyperdrive configs owned by an account.
//
// API reference: https://developers.cloudflare.com/api/operations/list-hyperdrive
func (api *API) ListHyperdriveConfigs(ctx context.Context, rc *ResourceContainer) ([]HyperdriveConfig, error) {
func (api *API) ListHyperdriveConfigs(ctx context.Context, rc *ResourceContainer, params ListHyperdriveConfigParams) ([]HyperdriveConfig, error) {
if rc.Identifier == "" {
return []HyperdriveConfig{}, ErrMissingAccountID
}

var hResponse HyperdriveConfigListResponse
hResponse = HyperdriveConfigListResponse{}
hResponse := HyperdriveConfigListResponse{}
uri := fmt.Sprintf("/accounts/%s/hyperdrive/configs", rc.Identifier)

res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
Expand Down
10 changes: 5 additions & 5 deletions hyperdrive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func testHyperdriveConfig() HyperdriveConfig {
User: "postgres",
},
Caching: HyperdriveConfigCaching{
Disabled: false,
Disabled: BoolPtr(false),
MaxAge: 30,
StaleWhileRevalidate: 15,
},
Expand Down Expand Up @@ -64,12 +64,12 @@ func TestHyperdriveConfig_List(t *testing.T) {
}`)
})

_, err := client.ListHyperdriveConfigs(context.Background(), AccountIdentifier(""))
_, err := client.ListHyperdriveConfigs(context.Background(), AccountIdentifier(""), ListHyperdriveConfigParams{})
if assert.Error(t, err) {
assert.Equal(t, ErrMissingAccountID, err)
}

result, err := client.ListHyperdriveConfigs(context.Background(), AccountIdentifier(testAccountID))
result, err := client.ListHyperdriveConfigs(context.Background(), AccountIdentifier(testAccountID), ListHyperdriveConfigParams{})
if assert.NoError(t, err) {
assert.Equal(t, 1, len(result))
assert.Equal(t, testHyperdriveConfig(), result[0])
Expand Down Expand Up @@ -180,7 +180,7 @@ func TestHyperdriveConfig_Create(t *testing.T) {
User: "postgres",
},
Caching: HyperdriveConfigCaching{
Disabled: false,
Disabled: BoolPtr(false),
MaxAge: 30,
StaleWhileRevalidate: 15,
},
Expand Down Expand Up @@ -273,7 +273,7 @@ func TestHyperdriveConfig_Update(t *testing.T) {
User: "postgres",
},
Caching: HyperdriveConfigCaching{
Disabled: false,
Disabled: BoolPtr(false),
MaxAge: 30,
StaleWhileRevalidate: 15,
},
Expand Down

0 comments on commit 2a4f155

Please sign in to comment.