Skip to content

Commit

Permalink
Merge branch 'master' into get-r2-bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyb3r-Jak3 committed May 23, 2023
2 parents c1db717 + 870f6bd commit 305ee56
Show file tree
Hide file tree
Showing 30 changed files with 549 additions and 35 deletions.
3 changes: 3 additions & 0 deletions .changelog/1246.txt
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`.
```
3 changes: 3 additions & 0 deletions .changelog/1268.txt
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
```
3 changes: 3 additions & 0 deletions .changelog/1274.txt
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
```
3 changes: 3 additions & 0 deletions .changelog/1275.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
rulesets: allow `PreserveQueryString` to be nullable
```
3 changes: 3 additions & 0 deletions .changelog/1276.txt
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
```
3 changes: 3 additions & 0 deletions .changelog/1278.txt
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.
```
7 changes: 7 additions & 0 deletions .changelog/1279.txt
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`.
```
3 changes: 3 additions & 0 deletions .changelog/1280.txt
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
```
3 changes: 3 additions & 0 deletions .changelog/1284.txt
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
```
3 changes: 3 additions & 0 deletions .changelog/1285.txt
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
```
3 changes: 3 additions & 0 deletions .changelog/1286.txt
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
```
3 changes: 2 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ What sort of change does your code introduce/modify?
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
- [ ] This change is using publicly documented (api.cloudflare.com or developers.cloudflare.com) and stable APIs.
- [ ] This change is using publicly documented in [cloudflare/api-schemas](https://github.com/cloudflare/api-schemas)
and relies on stable APIs.

[1]: https://help.github.com/articles/closing-issues-using-keywords/
4 changes: 4 additions & 0 deletions .github/workflows/milestone-closed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,21 @@ permissions:
jobs:
comment-on-closed-milestone:
runs-on: ubuntu-latest
outputs:
ids: ${{ steps.milestone-comment.outputs.ids }}
steps:
- uses: bflad/action-milestone-comment@v1
with:
body: |
This functionality has been released in [${{ github.event.milestone.title }}](https://github.com/${{ github.repository }}/releases/tag/${{ github.event.milestone.title }}).
For further feature requests or bug reports with this functionality, please create a [new GitHub issue](https://github.com/${{ github.repository }}/issues/new/choose) following the template. Thank you!
lock-closed-issues:
runs-on: ubuntu-latest
needs: comment-on-closed-milestone
steps:
- uses: actions/checkout@v3
- run: |
IFS=',' read -r -a issues <<< "$ISSUES"
for element in "${issues[@]}"
Expand Down
37 changes: 36 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
## 0.67.0 (Unreleased)
## 0.68.0 (Unreleased)

ENHANCEMENTS:

* pages: add support for Smart Placement. Added `Placement` in `PagesProjectDeploymentConfigEnvironment`. ([#1279](https://github.com/cloudflare/cloudflare-go/issues/1279))
* workers: add support for Smart Placement. Added `Placement` in `CreateWorkerParams`. ([#1279](https://github.com/cloudflare/cloudflare-go/issues/1279))
* zone: Added `GetCacheReserve` and `UpdateacheReserve` to allow setting Cache Reserve for a zone. ([#1278](https://github.com/cloudflare/cloudflare-go/issues/1278))

BUG FIXES:

* turnstile: remove `SiteKey` being sent in rotate secret's request body ([#1285](https://github.com/cloudflare/cloudflare-go/issues/1285))
* turnstile: remove `SiteKey`/`Secret` being sent in update request body ([#1284](https://github.com/cloudflare/cloudflare-go/issues/1284))

DEPENDENCIES:

* deps: bumps github.com/stretchr/testify from 1.8.2 to 1.8.3 ([#1286](https://github.com/cloudflare/cloudflare-go/issues/1286))

## 0.67.0 (May 10th, 2023)

NOTES:

* dns_firewall: The `OriginIPs` field has been renamed to `UpstreamIPs`. ([#1246](https://github.com/cloudflare/cloudflare-go/issues/1246))

ENHANCEMENTS:

* device_posture_rule: add input fields tanium, intune and kolide ([#1268](https://github.com/cloudflare/cloudflare-go/issues/1268))
* waiting_room: add support for zone-level settings ([#1276](https://github.com/cloudflare/cloudflare-go/issues/1276))

BUG FIXES:

* rulesets: allow `PreserveQueryString` to be nullable ([#1275](https://github.com/cloudflare/cloudflare-go/issues/1275))

DEPENDENCIES:

* deps: bumps github.com/urfave/cli/v2 from 2.25.1 to 2.25.3 ([#1274](https://github.com/cloudflare/cloudflare-go/issues/1274))
* deps: bumps golang.org/x/net from 0.9.0 to 0.10.0 ([#1280](https://github.com/cloudflare/cloudflare-go/issues/1280))

## 0.66.0 (26th April, 2023)

Expand Down
82 changes: 82 additions & 0 deletions cache_reserve.go
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
}
82 changes: 82 additions & 0 deletions cache_reserve_test.go
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)
}
}
4 changes: 4 additions & 0 deletions device_posture_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ type DevicePostureRuleInput struct {
Domain string `json:"domain,omitempty"`
ComplianceStatus string `json:"compliance_status,omitempty"`
ConnectionID string `json:"connection_id,omitempty"`
IssueCount string `json:"issue_count,omitempty"`
CountOperator string `json:"countOperator,omitempty"`
TotalScore string `json:"total_score,omitempty"`
ScoreOperator string `json:"scoreOperator,omitempty"`
}

// DevicePostureRuleListResponse represents the response from the list
Expand Down
2 changes: 1 addition & 1 deletion dns_firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
type DNSFirewallCluster struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
OriginIPs []string `json:"origin_ips"`
UpstreamIPs []string `json:"upstream_ips"`
DNSFirewallIPs []string `json:"dns_firewall_ips,omitempty"`
MinimumCacheTTL uint `json:"minimum_cache_ttl,omitempty"`
MaximumCacheTTL uint `json:"maximum_cache_ttl,omitempty"`
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ require (
github.com/google/go-querystring v1.1.0
github.com/hashicorp/go-retryablehttp v0.7.2
github.com/olekukonko/tablewriter v0.0.5
github.com/stretchr/testify v1.8.2
github.com/urfave/cli/v2 v2.25.1
golang.org/x/net v0.9.0
github.com/stretchr/testify v1.8.3
github.com/urfave/cli/v2 v2.25.3
golang.org/x/net v0.10.0
golang.org/x/time v0.3.0
)

Expand Down
21 changes: 7 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
Expand Down Expand Up @@ -51,27 +50,22 @@ github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XF
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/urfave/cli/v2 v2.25.1 h1:zw8dSP7ghX0Gmm8vugrs6q9Ku0wzweqPyshy+syu9Gw=
github.com/urfave/cli/v2 v2.25.1/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/urfave/cli/v2 v2.25.3 h1:VJkt6wvEBOoSjPFQvOkv6iWIrsJyCrKGtCtxXWwmGeY=
github.com/urfave/cli/v2 v2.25.3/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
Expand All @@ -82,6 +76,5 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 2 additions & 0 deletions pages_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ type PagesProjectDeploymentConfigEnvironment struct {
FailOpen bool `json:"fail_open"`
AlwaysUseLatestCompatibilityDate bool `json:"always_use_latest_compatibility_date"`
UsageModel UsageModel `json:"usage_model,omitempty"`
Placement *Placement `json:"placement,omitempty"`
}

// PagesProjectDeployment represents a deployment to a Pages project.
Expand All @@ -98,6 +99,7 @@ type PagesProjectDeployment struct {
D1Databases D1BindingMap `json:"d1_databases,omitempty"`
R2Bindings R2BindingMap `json:"r2_buckets,omitempty"`
ServiceBindings ServiceBindingMap `json:"services,omitempty"`
Placement *Placement `json:"placement,omitempty"`
DeploymentTrigger PagesProjectDeploymentTrigger `json:"deployment_trigger"`
Stages []PagesProjectDeploymentStage `json:"stages"`
BuildConfig PagesProjectBuildConfig `json:"build_config"`
Expand Down

0 comments on commit 305ee56

Please sign in to comment.