-
Notifications
You must be signed in to change notification settings - Fork 616
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into get-r2-bucket
- Loading branch information
Showing
30 changed files
with
549 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:note | ||
dns_firewall: The `OriginIPs` field has been renamed to `UpstreamIPs`. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:enhancement | ||
device_posture_rule: add input fields tanium, intune and kolide | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:dependency | ||
deps: bumps github.com/urfave/cli/v2 from 2.25.1 to 2.25.3 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
rulesets: allow `PreserveQueryString` to be nullable | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:enhancement | ||
waiting_room: add support for zone-level settings | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:enhancement | ||
zone: Added `GetCacheReserve` and `UpdateacheReserve` to allow setting Cache Reserve for a zone. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```release-note:enhancement | ||
pages: add support for Smart Placement. Added `Placement` in `PagesProjectDeploymentConfigEnvironment`. | ||
``` | ||
|
||
```release-note:enhancement | ||
workers: add support for Smart Placement. Added `Placement` in `CreateWorkerParams`. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:dependency | ||
deps: bumps golang.org/x/net from 0.9.0 to 0.10.0 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
turnstile: remove `SiteKey`/`Secret` being sent in update request body | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
turnstile: remove `SiteKey` being sent in rotate secret's request body | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:dependency | ||
deps: bumps github.com/stretchr/testify from 1.8.2 to 1.8.3 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package cloudflare | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
"time" | ||
) | ||
|
||
// CacheReserve is the structure of the API object for the cache reserve | ||
// setting. | ||
type CacheReserve struct { | ||
ID string `json:"id,omitempty"` | ||
ModifiedOn time.Time `json:"modified_on,omitempty"` | ||
Value string `json:"value"` | ||
} | ||
|
||
// CacheReserveDetailsResponse is the API response for the cache reserve | ||
// setting. | ||
type CacheReserveDetailsResponse struct { | ||
Result CacheReserve `json:"result"` | ||
Response | ||
} | ||
|
||
type zoneCacheReserveSingleResponse struct { | ||
Response | ||
Result CacheReserve `json:"result"` | ||
} | ||
|
||
type GetCacheReserveParams struct{} | ||
|
||
type UpdateCacheReserveParams struct { | ||
Value string `json:"value"` | ||
} | ||
|
||
// GetCacheReserve returns information about the current cache reserve settings. | ||
// | ||
// API reference: https://developers.cloudflare.com/api/operations/zone-cache-settings-get-cache-reserve-setting | ||
func (api *API) GetCacheReserve(ctx context.Context, rc *ResourceContainer, params GetCacheReserveParams) (CacheReserve, error) { | ||
if rc.Level != ZoneRouteLevel { | ||
return CacheReserve{}, ErrRequiredZoneLevelResourceContainer | ||
} | ||
|
||
uri := fmt.Sprintf("/%s/%s/cache/cache_reserve", rc.Level, rc.Identifier) | ||
|
||
res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil) | ||
if err != nil { | ||
return CacheReserve{}, err | ||
} | ||
|
||
var cacheReserveDetailsResponse CacheReserveDetailsResponse | ||
err = json.Unmarshal(res, &cacheReserveDetailsResponse) | ||
if err != nil { | ||
return CacheReserve{}, fmt.Errorf("%s: %w", errUnmarshalError, err) | ||
} | ||
return cacheReserveDetailsResponse.Result, nil | ||
} | ||
|
||
// UpdateCacheReserve updates the cache reserve setting for a zone | ||
// | ||
// API reference: https://developers.cloudflare.com/api/operations/zone-cache-settings-change-cache-reserve-setting | ||
func (api *API) UpdateCacheReserve(ctx context.Context, rc *ResourceContainer, params UpdateCacheReserveParams) (CacheReserve, error) { | ||
if rc.Level != ZoneRouteLevel { | ||
return CacheReserve{}, ErrRequiredZoneLevelResourceContainer | ||
} | ||
|
||
uri := fmt.Sprintf("/%s/%s/cache/cache_reserve", rc.Level, rc.Identifier) | ||
|
||
res, err := api.makeRequestContext(ctx, http.MethodPatch, uri, params) | ||
if err != nil { | ||
return CacheReserve{}, err | ||
} | ||
|
||
response := &zoneCacheReserveSingleResponse{} | ||
err = json.Unmarshal(res, &response) | ||
if err != nil { | ||
return CacheReserve{}, fmt.Errorf("%s: %w", errUnmarshalError, err) | ||
} | ||
|
||
return response.Result, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package cloudflare | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/http" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
var cacheReserveTimestampString = "2019-02-20T22:37:07.107449Z" | ||
var cacheReserveTimestamp, _ = time.Parse(time.RFC3339Nano, cacheReserveTimestampString) | ||
|
||
func TestCacheReserve(t *testing.T) { | ||
setup() | ||
defer teardown() | ||
|
||
handler := func(w http.ResponseWriter, r *http.Request) { | ||
assert.Equal(t, http.MethodGet, r.Method, "Expected method 'GET', got %s", r.Method) | ||
w.Header().Set("content-type", "application/json") | ||
fmt.Fprintf(w, `{ | ||
"success": true, | ||
"errors": [], | ||
"messages": [], | ||
"result": { | ||
"id": "cache_reserve", | ||
"value": "on", | ||
"modified_on": "%s" | ||
} | ||
} | ||
`, cacheReserveTimestampString) | ||
} | ||
|
||
mux.HandleFunc("/zones/01a7362d577a6c3019a474fd6f485823/cache/cache_reserve", handler) | ||
want := CacheReserve{ | ||
ID: "cache_reserve", | ||
Value: "on", | ||
ModifiedOn: cacheReserveTimestamp, | ||
} | ||
|
||
actual, err := client.GetCacheReserve(context.Background(), ZoneIdentifier("01a7362d577a6c3019a474fd6f485823"), GetCacheReserveParams{}) | ||
|
||
if assert.NoError(t, err) { | ||
assert.Equal(t, want, actual) | ||
} | ||
} | ||
|
||
func TestUpdateCacheReserve(t *testing.T) { | ||
setup() | ||
defer teardown() | ||
|
||
handler := func(w http.ResponseWriter, r *http.Request) { | ||
assert.Equal(t, http.MethodPatch, r.Method, "Expected method 'PATCH', got %s", r.Method) | ||
w.Header().Set("content-type", "application/json") | ||
fmt.Fprintf(w, `{ | ||
"success": true, | ||
"errors": [], | ||
"messages": [], | ||
"result": { | ||
"id": "cache_reserve", | ||
"value": "off", | ||
"modified_on": "%s" | ||
} | ||
} | ||
`, cacheReserveTimestampString) | ||
} | ||
|
||
mux.HandleFunc("/zones/01a7362d577a6c3019a474fd6f485823/cache/cache_reserve", handler) | ||
want := CacheReserve{ | ||
ID: "cache_reserve", | ||
Value: "off", | ||
ModifiedOn: cacheReserveTimestamp, | ||
} | ||
|
||
actual, err := client.UpdateCacheReserve(context.Background(), ZoneIdentifier("01a7362d577a6c3019a474fd6f485823"), UpdateCacheReserveParams{Value: "off"}) | ||
|
||
if assert.NoError(t, err) { | ||
assert.Equal(t, want, actual) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.