Skip to content

Commit

Permalink
feat(api): manual updates (#3754)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Dec 18, 2024
1 parent b2aa339 commit a2b3227
Show file tree
Hide file tree
Showing 9 changed files with 310 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1480
configured_endpoints: 1483
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-405af13ac696c25ab9d54a26786eab9bf02e2c2ff817a7ec01a454056dda053c.yml
12 changes: 12 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2654,6 +2654,7 @@ Response Types:
Methods:

- <code title="get /zones/{zone_id}/managed_headers">client.ManagedTransforms.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/managed_transforms#ManagedTransformService.List">List</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/v3/managed_transforms">managed_transforms</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/managed_transforms#ManagedTransformListParams">ManagedTransformListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/managed_transforms">managed_transforms</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/managed_transforms#ManagedTransformListResponse">ManagedTransformListResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="delete /zones/{zone_id}/managed_headers">client.ManagedTransforms.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/managed_transforms#ManagedTransformService.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/v3/managed_transforms">managed_transforms</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/managed_transforms#ManagedTransformDeleteParams">ManagedTransformDeleteParams</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>
- <code title="patch /zones/{zone_id}/managed_headers">client.ManagedTransforms.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/managed_transforms#ManagedTransformService.Edit">Edit</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/v3/managed_transforms">managed_transforms</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/managed_transforms#ManagedTransformEditParams">ManagedTransformEditParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/managed_transforms">managed_transforms</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/managed_transforms#ManagedTransformEditResponse">ManagedTransformEditResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

# PageShield
Expand Down Expand Up @@ -2848,6 +2849,7 @@ Response Types:
Methods:

- <code title="put /zones/{zone_id}/url_normalization">client.URLNormalization.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/url_normalization#URLNormalizationService.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/v3/url_normalization">url_normalization</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/url_normalization#URLNormalizationUpdateParams">URLNormalizationUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/url_normalization">url_normalization</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/url_normalization#URLNormalizationUpdateResponse">URLNormalizationUpdateResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="delete /zones/{zone_id}/url_normalization">client.URLNormalization.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/url_normalization#URLNormalizationService.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/v3/url_normalization">url_normalization</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/url_normalization#URLNormalizationDeleteParams">URLNormalizationDeleteParams</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>
- <code title="get /zones/{zone_id}/url_normalization">client.URLNormalization.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/url_normalization#URLNormalizationService.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/v3/url_normalization">url_normalization</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/url_normalization#URLNormalizationGetParams">URLNormalizationGetParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/url_normalization">url_normalization</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/url_normalization#URLNormalizationGetResponse">URLNormalizationGetResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

# Spectrum
Expand Down Expand Up @@ -4394,6 +4396,16 @@ Methods:
- <code title="delete /accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}">client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/workers_for_platforms#DispatchNamespaceScriptService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, dispatchNamespace <a href="https://pkg.go.dev/builtin#string">string</a>, scriptName <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/workers_for_platforms">workers_for_platforms</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/workers_for_platforms#DispatchNamespaceScriptDeleteParams">DispatchNamespaceScriptDeleteParams</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>
- <code title="get /accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}">client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/workers_for_platforms#DispatchNamespaceScriptService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, dispatchNamespace <a href="https://pkg.go.dev/builtin#string">string</a>, scriptName <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/workers_for_platforms">workers_for_platforms</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/workers_for_platforms#DispatchNamespaceScriptGetParams">DispatchNamespaceScriptGetParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/workers_for_platforms">workers_for_platforms</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/workers_for_platforms#Script">Script</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

##### AssetUpload

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/workers_for_platforms">workers_for_platforms</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/workers_for_platforms#DispatchNamespaceScriptAssetUploadNewResponse">DispatchNamespaceScriptAssetUploadNewResponse</a>

Methods:

- <code title="post /accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/assets-upload-session">client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.AssetUpload.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/workers_for_platforms#DispatchNamespaceScriptAssetUploadService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, dispatchNamespace <a href="https://pkg.go.dev/builtin#string">string</a>, scriptName <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/workers_for_platforms">workers_for_platforms</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/workers_for_platforms#DispatchNamespaceScriptAssetUploadNewParams">DispatchNamespaceScriptAssetUploadNewParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/workers_for_platforms">workers_for_platforms</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/workers_for_platforms#DispatchNamespaceScriptAssetUploadNewResponse">DispatchNamespaceScriptAssetUploadNewResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

##### Content

Methods:
Expand Down
18 changes: 18 additions & 0 deletions managed_transforms/managedtransform.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ func (r *ManagedTransformService) List(ctx context.Context, query ManagedTransfo
return
}

// Disables all Managed Transforms.
func (r *ManagedTransformService) Delete(ctx context.Context, body ManagedTransformDeleteParams, opts ...option.RequestOption) (err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...)
if body.ZoneID.Value == "" {
err = errors.New("missing required zone_id parameter")
return
}
path := fmt.Sprintf("zones/%s/managed_headers", body.ZoneID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
return
}

// Updates the status of one or more Managed Transforms.
func (r *ManagedTransformService) Edit(ctx context.Context, params ManagedTransformEditParams, opts ...option.RequestOption) (res *ManagedTransformEditResponse, err error) {
var env ManagedTransformEditResponseEnvelope
Expand Down Expand Up @@ -491,6 +504,11 @@ func (r ManagedTransformListResponseEnvelopeSuccess) IsKnown() bool {
return false
}

type ManagedTransformDeleteParams struct {
// The unique ID of the zone.
ZoneID param.Field[string] `path:"zone_id,required"`
}

type ManagedTransformEditParams struct {
// The unique ID of the zone.
ZoneID param.Field[string] `path:"zone_id,required"`
Expand Down
25 changes: 25 additions & 0 deletions managed_transforms/managedtransform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,31 @@ func TestManagedTransformList(t *testing.T) {
}
}

func TestManagedTransformDelete(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
client := cloudflare.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
option.WithAPIEmail("[email protected]"),
)
err := client.ManagedTransforms.Delete(context.TODO(), managed_transforms.ManagedTransformDeleteParams{
ZoneID: cloudflare.F("9f1839b6152d298aca64c4e906b6d074"),
})
if err != nil {
var apierr *cloudflare.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}

func TestManagedTransformEdit(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
Expand Down
18 changes: 18 additions & 0 deletions url_normalization/urlnormalization.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ func (r *URLNormalizationService) Update(ctx context.Context, params URLNormaliz
return
}

// Deletes the URL Normalization settings.
func (r *URLNormalizationService) Delete(ctx context.Context, body URLNormalizationDeleteParams, opts ...option.RequestOption) (err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...)
if body.ZoneID.Value == "" {
err = errors.New("missing required zone_id parameter")
return
}
path := fmt.Sprintf("zones/%s/url_normalization", body.ZoneID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
return
}

// Fetches the current URL Normalization settings.
func (r *URLNormalizationService) Get(ctx context.Context, query URLNormalizationGetParams, opts ...option.RequestOption) (res *URLNormalizationGetResponse, err error) {
var env URLNormalizationGetResponseEnvelope
Expand Down Expand Up @@ -379,6 +392,11 @@ func (r URLNormalizationUpdateResponseEnvelopeSuccess) IsKnown() bool {
return false
}

type URLNormalizationDeleteParams struct {
// The unique ID of the zone.
ZoneID param.Field[string] `path:"zone_id,required"`
}

type URLNormalizationGetParams struct {
// The unique ID of the zone.
ZoneID param.Field[string] `path:"zone_id,required"`
Expand Down
25 changes: 25 additions & 0 deletions url_normalization/urlnormalization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,31 @@ func TestURLNormalizationUpdate(t *testing.T) {
}
}

func TestURLNormalizationDelete(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
client := cloudflare.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
option.WithAPIEmail("[email protected]"),
)
err := client.URLNormalization.Delete(context.TODO(), url_normalization.URLNormalizationDeleteParams{
ZoneID: cloudflare.F("9f1839b6152d298aca64c4e906b6d074"),
})
if err != nil {
var apierr *cloudflare.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}

func TestURLNormalizationGet(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
Expand Down
14 changes: 8 additions & 6 deletions workers_for_platforms/dispatchnamespacescript.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ import (
// automatically. You should not instantiate this service directly, and instead use
// the [NewDispatchNamespaceScriptService] method instead.
type DispatchNamespaceScriptService struct {
Options []option.RequestOption
Content *DispatchNamespaceScriptContentService
Settings *DispatchNamespaceScriptSettingService
Bindings *DispatchNamespaceScriptBindingService
Secrets *DispatchNamespaceScriptSecretService
Tags *DispatchNamespaceScriptTagService
Options []option.RequestOption
AssetUpload *DispatchNamespaceScriptAssetUploadService
Content *DispatchNamespaceScriptContentService
Settings *DispatchNamespaceScriptSettingService
Bindings *DispatchNamespaceScriptBindingService
Secrets *DispatchNamespaceScriptSecretService
Tags *DispatchNamespaceScriptTagService
}

// NewDispatchNamespaceScriptService generates a new service that applies the given
Expand All @@ -44,6 +45,7 @@ type DispatchNamespaceScriptService struct {
func NewDispatchNamespaceScriptService(opts ...option.RequestOption) (r *DispatchNamespaceScriptService) {
r = &DispatchNamespaceScriptService{}
r.Options = opts
r.AssetUpload = NewDispatchNamespaceScriptAssetUploadService(opts...)
r.Content = NewDispatchNamespaceScriptContentService(opts...)
r.Settings = NewDispatchNamespaceScriptSettingService(opts...)
r.Bindings = NewDispatchNamespaceScriptBindingService(opts...)
Expand Down
Loading

0 comments on commit a2b3227

Please sign in to comment.