Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#1681)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Apr 5, 2024
1 parent 2e3b6c0 commit 8368a09
Show file tree
Hide file tree
Showing 9 changed files with 1,453 additions and 1,078 deletions.
25 changes: 5 additions & 20 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2398,25 +2398,6 @@ Methods:

# Workers

Params Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers#DispatchNamespaceBindingParam">DispatchNamespaceBindingParam</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers#MigrationStepParam">MigrationStepParam</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers#MTLSCERTBindingParam">MTLSCERTBindingParam</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers#PlacementConfigurationParam">PlacementConfigurationParam</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers#SingleStepMigrationParam">SingleStepMigrationParam</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers#SteppedMigrationParam">SteppedMigrationParam</a>

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers#Binding">Binding</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers#DispatchNamespaceBinding">DispatchNamespaceBinding</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers#MigrationStep">MigrationStep</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers#MTLSCERTBinding">MTLSCERTBinding</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers#PlacementConfiguration">PlacementConfiguration</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers#SingleStepMigration">SingleStepMigration</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers#SteppedMigration">SteppedMigration</a>

## AI

Response Types:
Expand Down Expand Up @@ -4329,9 +4310,13 @@ Methods:

##### Bindings

Response Types:

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

Methods:

- <code title="get /accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/bindings">client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Bindings.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers_for_platforms#DispatchNamespaceScriptBindingService.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/v2/workers_for_platforms">workers_for_platforms</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers_for_platforms#DispatchNamespaceScriptBindingGetParams">DispatchNamespaceScriptBindingGetParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers#Binding">Binding</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}/bindings">client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Bindings.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers_for_platforms#DispatchNamespaceScriptBindingService.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/v2/workers_for_platforms">workers_for_platforms</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers_for_platforms#DispatchNamespaceScriptBindingGetParams">DispatchNamespaceScriptBindingGetParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers_for_platforms">workers_for_platforms</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/workers_for_platforms#DispatchNamespaceScriptBindingGetResponse">DispatchNamespaceScriptBindingGetResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

# ZeroTrust

Expand Down
132 changes: 129 additions & 3 deletions workers/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ type ScriptUpdateParamsVariant0Metadata struct {
MainModule param.Field[string] `json:"main_module"`
// Migrations to apply for Durable Objects associated with this Worker.
Migrations param.Field[ScriptUpdateParamsVariant0MetadataMigrationsUnion] `json:"migrations"`
Placement param.Field[PlacementConfigurationParam] `json:"placement"`
Placement param.Field[ScriptUpdateParamsVariant0MetadataPlacement] `json:"placement"`
// List of strings to use as tags for this Worker
Tags param.Field[[]string] `json:"tags"`
// List of Workers that will consume logs from the attached Worker.
Expand Down Expand Up @@ -351,12 +351,138 @@ func (r ScriptUpdateParamsVariant0MetadataMigrations) implementsWorkersScriptUpd

// Migrations to apply for Durable Objects associated with this Worker.
//
// Satisfied by [workers.SingleStepMigrationParam],
// [workers.SteppedMigrationParam], [ScriptUpdateParamsVariant0MetadataMigrations].
// Satisfied by
// [workers.ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrations],
// [workers.ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrations],
// [ScriptUpdateParamsVariant0MetadataMigrations].
type ScriptUpdateParamsVariant0MetadataMigrationsUnion interface {
implementsWorkersScriptUpdateParamsVariant0MetadataMigrationsUnion()
}

// A single set of migrations to apply.
type ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrations struct {
// A list of classes to delete Durable Object namespaces from.
DeletedClasses param.Field[[]string] `json:"deleted_classes"`
// A list of classes to create Durable Object namespaces from.
NewClasses param.Field[[]string] `json:"new_classes"`
// Tag to set as the latest migration tag.
NewTag param.Field[string] `json:"new_tag"`
// Tag used to verify against the latest migration tag for this Worker. If they
// don't match, the upload is rejected.
OldTag param.Field[string] `json:"old_tag"`
// A list of classes with Durable Object namespaces that were renamed.
RenamedClasses param.Field[[]ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsRenamedClass] `json:"renamed_classes"`
// A list of transfers for Durable Object namespaces from a different Worker and
// class to a class defined in this Worker.
TransferredClasses param.Field[[]ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsTransferredClass] `json:"transferred_classes"`
}

func (r ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrations) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

func (r ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrations) implementsWorkersScriptUpdateParamsVariant0MetadataMigrationsUnion() {
}

type ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsRenamedClass struct {
From param.Field[string] `json:"from"`
To param.Field[string] `json:"to"`
}

func (r ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsRenamedClass) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

type ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsTransferredClass struct {
From param.Field[string] `json:"from"`
FromScript param.Field[string] `json:"from_script"`
To param.Field[string] `json:"to"`
}

func (r ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsTransferredClass) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

type ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrations struct {
// Tag to set as the latest migration tag.
NewTag param.Field[string] `json:"new_tag"`
// Tag used to verify against the latest migration tag for this Worker. If they
// don't match, the upload is rejected.
OldTag param.Field[string] `json:"old_tag"`
// Migrations to apply in order.
Steps param.Field[[]ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStep] `json:"steps"`
}

func (r ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrations) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

func (r ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrations) implementsWorkersScriptUpdateParamsVariant0MetadataMigrationsUnion() {
}

type ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStep struct {
// A list of classes to delete Durable Object namespaces from.
DeletedClasses param.Field[[]string] `json:"deleted_classes"`
// A list of classes to create Durable Object namespaces from.
NewClasses param.Field[[]string] `json:"new_classes"`
// A list of classes with Durable Object namespaces that were renamed.
RenamedClasses param.Field[[]ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStepsRenamedClass] `json:"renamed_classes"`
// A list of transfers for Durable Object namespaces from a different Worker and
// class to a class defined in this Worker.
TransferredClasses param.Field[[]ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStepsTransferredClass] `json:"transferred_classes"`
}

func (r ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStep) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

type ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStepsRenamedClass struct {
From param.Field[string] `json:"from"`
To param.Field[string] `json:"to"`
}

func (r ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStepsRenamedClass) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

type ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStepsTransferredClass struct {
From param.Field[string] `json:"from"`
FromScript param.Field[string] `json:"from_script"`
To param.Field[string] `json:"to"`
}

func (r ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStepsTransferredClass) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

type ScriptUpdateParamsVariant0MetadataPlacement struct {
// Enables
// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
// Only `"smart"` is currently supported
Mode param.Field[ScriptUpdateParamsVariant0MetadataPlacementMode] `json:"mode"`
}

func (r ScriptUpdateParamsVariant0MetadataPlacement) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

// Enables
// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
// Only `"smart"` is currently supported
type ScriptUpdateParamsVariant0MetadataPlacementMode string

const (
ScriptUpdateParamsVariant0MetadataPlacementModeSmart ScriptUpdateParamsVariant0MetadataPlacementMode = "smart"
)

func (r ScriptUpdateParamsVariant0MetadataPlacementMode) IsKnown() bool {
switch r {
case ScriptUpdateParamsVariant0MetadataPlacementModeSmart:
return true
}
return false
}

// Usage model to apply to invocations.
type ScriptUpdateParamsVariant0MetadataUsageModel string

Expand Down
10 changes: 5 additions & 5 deletions workers/script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ func TestScriptUpdateWithOptionalParams(t *testing.T) {
KeepBindings: cloudflare.F([]string{"string", "string", "string"}),
Logpush: cloudflare.F(false),
MainModule: cloudflare.F("worker.js"),
Migrations: cloudflare.F[workers.ScriptUpdateParamsVariant0MetadataMigrationsUnion](workers.SingleStepMigrationParam{
Migrations: cloudflare.F[workers.ScriptUpdateParamsVariant0MetadataMigrationsUnion](workers.ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrations{
NewTag: cloudflare.F("v2"),
OldTag: cloudflare.F("v1"),
DeletedClasses: cloudflare.F([]string{"string", "string", "string"}),
NewClasses: cloudflare.F([]string{"string", "string", "string"}),
RenamedClasses: cloudflare.F([]workers.SingleStepMigrationRenamedClassParam{{
RenamedClasses: cloudflare.F([]workers.ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsRenamedClass{{
From: cloudflare.F("string"),
To: cloudflare.F("string"),
}, {
Expand All @@ -66,7 +66,7 @@ func TestScriptUpdateWithOptionalParams(t *testing.T) {
From: cloudflare.F("string"),
To: cloudflare.F("string"),
}}),
TransferredClasses: cloudflare.F([]workers.SingleStepMigrationTransferredClassParam{{
TransferredClasses: cloudflare.F([]workers.ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsTransferredClass{{
From: cloudflare.F("string"),
FromScript: cloudflare.F("string"),
To: cloudflare.F("string"),
Expand All @@ -80,8 +80,8 @@ func TestScriptUpdateWithOptionalParams(t *testing.T) {
To: cloudflare.F("string"),
}}),
}),
Placement: cloudflare.F(workers.PlacementConfigurationParam{
Mode: cloudflare.F(workers.PlacementConfigurationModeSmart),
Placement: cloudflare.F(workers.ScriptUpdateParamsVariant0MetadataPlacement{
Mode: cloudflare.F(workers.ScriptUpdateParamsVariant0MetadataPlacementModeSmart),
}),
Tags: cloudflare.F([]string{"string", "string", "string"}),
TailConsumers: cloudflare.F([]workers.ConsumerScriptParam{{
Expand Down
Loading

0 comments on commit 8368a09

Please sign in to comment.