Skip to content

Commit 911970b

Browse files
authored
Merge pull request #4168 from cloudflare/release-please--branches--main--changes--next
release: 4.5.1
2 parents e543b27 + a042b81 commit 911970b

File tree

9 files changed

+391
-5
lines changed

9 files changed

+391
-5
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "4.5.0"
2+
".": "4.5.1"
33
}

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 1749
1+
configured_endpoints: 1752
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b15b44e0efd207de48e7e74e742b0b4b190c74f12a941a1a0ef59a51656a5224.yml
33
openapi_spec_hash: 83243c9ee06f88d0fa91e9b185d8a42e
4-
config_hash: d0ab46f06dbe6f6e33d86a3ede15ac44
4+
config_hash: 8601d43fd5ccaf9e3d08f26748a5a63a

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Changelog
22

3+
## 4.5.1 (2025-06-16)
4+
5+
Full Changelog: [v4.5.0...v4.5.1](https://github.com/cloudflare/cloudflare-go/compare/v4.5.0...v4.5.1)
6+
7+
### Features
8+
9+
* **client:** add debug log helper ([cd7dd39](https://github.com/cloudflare/cloudflare-go/commit/cd7dd39e4a76f4fd22d41bc2e51d7a9ce55ab0fc))
10+
11+
12+
### Bug Fixes
13+
14+
* **api:** Update zone subscription paths ([7b78606](https://github.com/cloudflare/cloudflare-go/commit/7b78606a368b157f30833d28198dff453aa1930e))
15+
316
## 4.5.0 (2025-06-16)
417

518
Full Changelog: [v4.4.0...v4.5.0](https://github.com/cloudflare/cloudflare-go/compare/v4.4.0...v4.5.0)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Or to pin the version:
2424
<!-- x-release-please-start-version -->
2525

2626
```sh
27-
go get -u 'github.com/cloudflare/cloudflare-go/[email protected].0'
27+
go get -u 'github.com/cloudflare/cloudflare-go/[email protected].1'
2828
```
2929

3030
<!-- x-release-please-end -->

api.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,12 @@ Methods:
422422

423423
## Subscriptions
424424

425+
Methods:
426+
427+
- <code title="post /zones/{zone_id}/subscription">client.Zones.Subscriptions.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zones#SubscriptionService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zones">zones</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zones#SubscriptionNewParams">SubscriptionNewParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/shared">shared</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/shared#Subscription">Subscription</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
428+
- <code title="put /zones/{zone_id}/subscription">client.Zones.Subscriptions.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zones#SubscriptionService.Update">Update</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zones">zones</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zones#SubscriptionUpdateParams">SubscriptionUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/shared">shared</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/shared#Subscription">Subscription</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
429+
- <code title="get /zones/{zone_id}/subscription">client.Zones.Subscriptions.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zones#SubscriptionService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zones">zones</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/zones#SubscriptionGetParams">SubscriptionGetParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/shared">shared</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/shared#Subscription">Subscription</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
430+
425431
## Plans
426432

427433
Response Types:

internal/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
package internal
44

5-
const PackageVersion = "4.5.0" // x-release-please-version
5+
const PackageVersion = "4.5.1" // x-release-please-version

option/middleware.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package option
4+
5+
import (
6+
"log"
7+
"net/http"
8+
"net/http/httputil"
9+
)
10+
11+
// WithDebugLog logs the HTTP request and response content.
12+
// If the logger parameter is nil, it uses the default logger.
13+
//
14+
// WithDebugLog is for debugging and development purposes only.
15+
// It should not be used in production code. The behavior and interface
16+
// of WithDebugLog is not guaranteed to be stable.
17+
func WithDebugLog(logger *log.Logger) RequestOption {
18+
return WithMiddleware(func(req *http.Request, nxt MiddlewareNext) (*http.Response, error) {
19+
if logger == nil {
20+
logger = log.Default()
21+
}
22+
23+
if reqBytes, err := httputil.DumpRequest(req, true); err == nil {
24+
logger.Printf("Request Content:\n%s\n", reqBytes)
25+
}
26+
27+
resp, err := nxt(req)
28+
if err != nil {
29+
return resp, err
30+
}
31+
32+
if respBytes, err := httputil.DumpResponse(resp, true); err == nil {
33+
logger.Printf("Response Content:\n%s\n", respBytes)
34+
}
35+
36+
return resp, err
37+
})
38+
}

zones/subscription.go

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@
33
package zones
44

55
import (
6+
"context"
7+
"errors"
8+
"fmt"
9+
"net/http"
10+
11+
"github.com/cloudflare/cloudflare-go/v4/internal/apijson"
12+
"github.com/cloudflare/cloudflare-go/v4/internal/param"
13+
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
614
"github.com/cloudflare/cloudflare-go/v4/option"
15+
"github.com/cloudflare/cloudflare-go/v4/shared"
716
)
817

918
// SubscriptionService contains methods and other services that help with
@@ -24,3 +33,208 @@ func NewSubscriptionService(opts ...option.RequestOption) (r *SubscriptionServic
2433
r.Options = opts
2534
return
2635
}
36+
37+
// Create a zone subscription, either plan or add-ons.
38+
func (r *SubscriptionService) New(ctx context.Context, params SubscriptionNewParams, opts ...option.RequestOption) (res *shared.Subscription, err error) {
39+
var env SubscriptionNewResponseEnvelope
40+
opts = append(r.Options[:], opts...)
41+
if params.ZoneID.Value == "" {
42+
err = errors.New("missing required zone_id parameter")
43+
return
44+
}
45+
path := fmt.Sprintf("zones/%s/subscription", params.ZoneID)
46+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...)
47+
if err != nil {
48+
return
49+
}
50+
res = &env.Result
51+
return
52+
}
53+
54+
// Updates zone subscriptions, either plan or add-ons.
55+
func (r *SubscriptionService) Update(ctx context.Context, params SubscriptionUpdateParams, opts ...option.RequestOption) (res *shared.Subscription, err error) {
56+
var env SubscriptionUpdateResponseEnvelope
57+
opts = append(r.Options[:], opts...)
58+
if params.ZoneID.Value == "" {
59+
err = errors.New("missing required zone_id parameter")
60+
return
61+
}
62+
path := fmt.Sprintf("zones/%s/subscription", params.ZoneID)
63+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...)
64+
if err != nil {
65+
return
66+
}
67+
res = &env.Result
68+
return
69+
}
70+
71+
// Lists zone subscription details.
72+
func (r *SubscriptionService) Get(ctx context.Context, query SubscriptionGetParams, opts ...option.RequestOption) (res *shared.Subscription, err error) {
73+
var env SubscriptionGetResponseEnvelope
74+
opts = append(r.Options[:], opts...)
75+
if query.ZoneID.Value == "" {
76+
err = errors.New("missing required zone_id parameter")
77+
return
78+
}
79+
path := fmt.Sprintf("zones/%s/subscription", query.ZoneID)
80+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...)
81+
if err != nil {
82+
return
83+
}
84+
res = &env.Result
85+
return
86+
}
87+
88+
type SubscriptionNewParams struct {
89+
// Subscription identifier tag.
90+
ZoneID param.Field[string] `path:"zone_id,required"`
91+
Subscription shared.SubscriptionParam `json:"subscription,required"`
92+
}
93+
94+
func (r SubscriptionNewParams) MarshalJSON() (data []byte, err error) {
95+
return apijson.MarshalRoot(r.Subscription)
96+
}
97+
98+
type SubscriptionNewResponseEnvelope struct {
99+
Errors []shared.ResponseInfo `json:"errors,required"`
100+
Messages []shared.ResponseInfo `json:"messages,required"`
101+
Result shared.Subscription `json:"result,required"`
102+
// Whether the API call was successful
103+
Success SubscriptionNewResponseEnvelopeSuccess `json:"success,required"`
104+
JSON subscriptionNewResponseEnvelopeJSON `json:"-"`
105+
}
106+
107+
// subscriptionNewResponseEnvelopeJSON contains the JSON metadata for the struct
108+
// [SubscriptionNewResponseEnvelope]
109+
type subscriptionNewResponseEnvelopeJSON struct {
110+
Errors apijson.Field
111+
Messages apijson.Field
112+
Result apijson.Field
113+
Success apijson.Field
114+
raw string
115+
ExtraFields map[string]apijson.Field
116+
}
117+
118+
func (r *SubscriptionNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
119+
return apijson.UnmarshalRoot(data, r)
120+
}
121+
122+
func (r subscriptionNewResponseEnvelopeJSON) RawJSON() string {
123+
return r.raw
124+
}
125+
126+
// Whether the API call was successful
127+
type SubscriptionNewResponseEnvelopeSuccess bool
128+
129+
const (
130+
SubscriptionNewResponseEnvelopeSuccessTrue SubscriptionNewResponseEnvelopeSuccess = true
131+
)
132+
133+
func (r SubscriptionNewResponseEnvelopeSuccess) IsKnown() bool {
134+
switch r {
135+
case SubscriptionNewResponseEnvelopeSuccessTrue:
136+
return true
137+
}
138+
return false
139+
}
140+
141+
type SubscriptionUpdateParams struct {
142+
// Subscription identifier tag.
143+
ZoneID param.Field[string] `path:"zone_id,required"`
144+
Subscription shared.SubscriptionParam `json:"subscription,required"`
145+
}
146+
147+
func (r SubscriptionUpdateParams) MarshalJSON() (data []byte, err error) {
148+
return apijson.MarshalRoot(r.Subscription)
149+
}
150+
151+
type SubscriptionUpdateResponseEnvelope struct {
152+
Errors []shared.ResponseInfo `json:"errors,required"`
153+
Messages []shared.ResponseInfo `json:"messages,required"`
154+
Result shared.Subscription `json:"result,required"`
155+
// Whether the API call was successful
156+
Success SubscriptionUpdateResponseEnvelopeSuccess `json:"success,required"`
157+
JSON subscriptionUpdateResponseEnvelopeJSON `json:"-"`
158+
}
159+
160+
// subscriptionUpdateResponseEnvelopeJSON contains the JSON metadata for the struct
161+
// [SubscriptionUpdateResponseEnvelope]
162+
type subscriptionUpdateResponseEnvelopeJSON struct {
163+
Errors apijson.Field
164+
Messages apijson.Field
165+
Result apijson.Field
166+
Success apijson.Field
167+
raw string
168+
ExtraFields map[string]apijson.Field
169+
}
170+
171+
func (r *SubscriptionUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
172+
return apijson.UnmarshalRoot(data, r)
173+
}
174+
175+
func (r subscriptionUpdateResponseEnvelopeJSON) RawJSON() string {
176+
return r.raw
177+
}
178+
179+
// Whether the API call was successful
180+
type SubscriptionUpdateResponseEnvelopeSuccess bool
181+
182+
const (
183+
SubscriptionUpdateResponseEnvelopeSuccessTrue SubscriptionUpdateResponseEnvelopeSuccess = true
184+
)
185+
186+
func (r SubscriptionUpdateResponseEnvelopeSuccess) IsKnown() bool {
187+
switch r {
188+
case SubscriptionUpdateResponseEnvelopeSuccessTrue:
189+
return true
190+
}
191+
return false
192+
}
193+
194+
type SubscriptionGetParams struct {
195+
// Subscription identifier tag.
196+
ZoneID param.Field[string] `path:"zone_id,required"`
197+
}
198+
199+
type SubscriptionGetResponseEnvelope struct {
200+
Errors []shared.ResponseInfo `json:"errors,required"`
201+
Messages []shared.ResponseInfo `json:"messages,required"`
202+
Result shared.Subscription `json:"result,required"`
203+
// Whether the API call was successful
204+
Success SubscriptionGetResponseEnvelopeSuccess `json:"success,required"`
205+
JSON subscriptionGetResponseEnvelopeJSON `json:"-"`
206+
}
207+
208+
// subscriptionGetResponseEnvelopeJSON contains the JSON metadata for the struct
209+
// [SubscriptionGetResponseEnvelope]
210+
type subscriptionGetResponseEnvelopeJSON struct {
211+
Errors apijson.Field
212+
Messages apijson.Field
213+
Result apijson.Field
214+
Success apijson.Field
215+
raw string
216+
ExtraFields map[string]apijson.Field
217+
}
218+
219+
func (r *SubscriptionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
220+
return apijson.UnmarshalRoot(data, r)
221+
}
222+
223+
func (r subscriptionGetResponseEnvelopeJSON) RawJSON() string {
224+
return r.raw
225+
}
226+
227+
// Whether the API call was successful
228+
type SubscriptionGetResponseEnvelopeSuccess bool
229+
230+
const (
231+
SubscriptionGetResponseEnvelopeSuccessTrue SubscriptionGetResponseEnvelopeSuccess = true
232+
)
233+
234+
func (r SubscriptionGetResponseEnvelopeSuccess) IsKnown() bool {
235+
switch r {
236+
case SubscriptionGetResponseEnvelopeSuccessTrue:
237+
return true
238+
}
239+
return false
240+
}

0 commit comments

Comments
 (0)