Skip to content

Commit 159aba7

Browse files
feat: docs: WC-4152 Expose subdomain delete for workers
* docs: WC-4152 Expose subdomain delete for workers
1 parent e16d0c5 commit 159aba7

File tree

4 files changed

+46
-2
lines changed

4 files changed

+46
-2
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 1894
1+
configured_endpoints: 1895
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ffb103f5eee9b32861f01358666cd5ca83d8c5b17eb87398652b6b1512a4a830.yml
33
openapi_spec_hash: 748e21d73949bb766db229a1c3ecf8ce
4-
config_hash: feb968146b5a84697390fed70d260f68
4+
config_hash: da15c53ae7de30af9d9aa523b32f6559

api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2508,6 +2508,7 @@ Response Types:
25082508
Methods:
25092509

25102510
- <code title="put /accounts/{account_id}/workers/subdomain">client.Workers.Subdomains.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/workers#SubdomainService.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/v6/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/workers#SubdomainUpdateParams">SubdomainUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/workers#SubdomainUpdateResponse">SubdomainUpdateResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
2511+
- <code title="delete /accounts/{account_id}/workers/subdomain">client.Workers.Subdomains.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/workers#SubdomainService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/workers#SubdomainDeleteParams">SubdomainDeleteParams</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>
25112512
- <code title="get /accounts/{account_id}/workers/subdomain">client.Workers.Subdomains.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/workers#SubdomainService.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/v6/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/workers#SubdomainGetParams">SubdomainGetParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/workers#SubdomainGetResponse">SubdomainGetResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
25122513

25132514
## Observability

workers/subdomain.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ func (r *SubdomainService) Update(ctx context.Context, params SubdomainUpdatePar
5151
return
5252
}
5353

54+
// Deletes a Workers subdomain for an account.
55+
func (r *SubdomainService) Delete(ctx context.Context, body SubdomainDeleteParams, opts ...option.RequestOption) (err error) {
56+
opts = slices.Concat(r.Options, opts)
57+
opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...)
58+
if body.AccountID.Value == "" {
59+
err = errors.New("missing required account_id parameter")
60+
return
61+
}
62+
path := fmt.Sprintf("accounts/%s/workers/subdomain", body.AccountID)
63+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
64+
return
65+
}
66+
5467
// Returns a Workers subdomain for an account.
5568
func (r *SubdomainService) Get(ctx context.Context, query SubdomainGetParams, opts ...option.RequestOption) (res *SubdomainGetResponse, err error) {
5669
var env SubdomainGetResponseEnvelope
@@ -259,6 +272,11 @@ func (r SubdomainUpdateResponseEnvelopeSuccess) IsKnown() bool {
259272
return false
260273
}
261274

275+
type SubdomainDeleteParams struct {
276+
// Identifier.
277+
AccountID param.Field[string] `path:"account_id,required"`
278+
}
279+
262280
type SubdomainGetParams struct {
263281
// Identifier.
264282
AccountID param.Field[string] `path:"account_id,required"`

workers/subdomain_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,31 @@ func TestSubdomainUpdate(t *testing.T) {
4040
}
4141
}
4242

43+
func TestSubdomainDelete(t *testing.T) {
44+
baseURL := "http://localhost:4010"
45+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
46+
baseURL = envURL
47+
}
48+
if !testutil.CheckTestServer(t, baseURL) {
49+
return
50+
}
51+
client := cloudflare.NewClient(
52+
option.WithBaseURL(baseURL),
53+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
54+
option.WithAPIEmail("user@example.com"),
55+
)
56+
err := client.Workers.Subdomains.Delete(context.TODO(), workers.SubdomainDeleteParams{
57+
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
58+
})
59+
if err != nil {
60+
var apierr *cloudflare.Error
61+
if errors.As(err, &apierr) {
62+
t.Log(string(apierr.DumpRequest(true)))
63+
}
64+
t.Fatalf("err should be nil: %s", err.Error())
65+
}
66+
}
67+
4368
func TestSubdomainGet(t *testing.T) {
4469
baseURL := "http://localhost:4010"
4570
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {

0 commit comments

Comments
 (0)