Skip to content

Commit f322091

Browse files
feat(api): api update
1 parent 227732b commit f322091

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 1781
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f552d9d66684cd309a04567e09c14c86cf824a1776da6b25b27de302bc0686dc.yml
3-
openapi_spec_hash: 97f316cb6055691278d565061afcd9cd
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-45f3d528a7290d80336539cc59fdf9074526ae8c5b5b012a9d8c597db4f151d7.yml
3+
openapi_spec_hash: 8cf560393053b3a83f0ad48b20515589
44
config_hash: 31525fc9404677e20330cc748dfaf55d

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2201,7 +2201,7 @@ Response Types:
22012201
Methods:
22022202

22032203
- <code title="put /accounts/{account_id}/workers/scripts/{script_name}">client.Workers.Scripts.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/workers#ScriptService.Update">Update</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, scriptName <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/workers#ScriptUpdateParams">ScriptUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/workers#ScriptUpdateResponse">ScriptUpdateResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
2204-
- <code title="get /accounts/{account_id}/workers/scripts">client.Workers.Scripts.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/workers#ScriptService.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/v5/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/workers#ScriptListParams">ScriptListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/packages/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/packages/pagination#SinglePage">SinglePage</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/workers#Script">Script</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
2204+
- <code title="get /accounts/{account_id}/workers/scripts">client.Workers.Scripts.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/workers#ScriptService.List">List</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/v5/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/workers#ScriptListParams">ScriptListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/packages/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/packages/pagination#SinglePage">SinglePage</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/workers#Script">Script</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
22052205
- <code title="delete /accounts/{account_id}/workers/scripts/{script_name}">client.Workers.Scripts.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/workers#ScriptService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, scriptName <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/workers#ScriptDeleteParams">ScriptDeleteParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/workers#ScriptDeleteResponse">ScriptDeleteResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
22062206
- <code title="get /accounts/{account_id}/workers/scripts/{script_name}">client.Workers.Scripts.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/workers#ScriptService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, scriptName <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/workers">workers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v5/workers#ScriptGetParams">ScriptGetParams</a>) (<a href="https://pkg.go.dev/builtin#string">string</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
22072207

workers/script.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,16 @@ func (r *ScriptService) Update(ctx context.Context, scriptName string, params Sc
8585
}
8686

8787
// Fetch a list of uploaded workers.
88-
func (r *ScriptService) List(ctx context.Context, query ScriptListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Script], err error) {
88+
func (r *ScriptService) List(ctx context.Context, params ScriptListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Script], err error) {
8989
var raw *http.Response
9090
opts = append(r.Options[:], opts...)
9191
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
92-
if query.AccountID.Value == "" {
92+
if params.AccountID.Value == "" {
9393
err = errors.New("missing required account_id parameter")
9494
return
9595
}
96-
path := fmt.Sprintf("accounts/%s/workers/scripts", query.AccountID)
97-
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, nil, &res, opts...)
96+
path := fmt.Sprintf("accounts/%s/workers/scripts", params.AccountID)
97+
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...)
9898
if err != nil {
9999
return nil, err
100100
}
@@ -107,8 +107,8 @@ func (r *ScriptService) List(ctx context.Context, query ScriptListParams, opts .
107107
}
108108

109109
// Fetch a list of uploaded workers.
110-
func (r *ScriptService) ListAutoPaging(ctx context.Context, query ScriptListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Script] {
111-
return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...))
110+
func (r *ScriptService) ListAutoPaging(ctx context.Context, params ScriptListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Script] {
111+
return pagination.NewSinglePageAutoPager(r.List(ctx, params, opts...))
112112
}
113113

114114
// Delete your worker. This call has no response body on a successful delete.
@@ -1968,6 +1968,17 @@ func (r ScriptUpdateResponseEnvelopeSuccess) IsKnown() bool {
19681968
type ScriptListParams struct {
19691969
// Identifier.
19701970
AccountID param.Field[string] `path:"account_id,required"`
1971+
// Filter scripts by tags. Format: comma-separated list of tag:allowed pairs where
1972+
// allowed is 'yes' or 'no'.
1973+
Tags param.Field[string] `query:"tags"`
1974+
}
1975+
1976+
// URLQuery serializes [ScriptListParams]'s query parameters as `url.Values`.
1977+
func (r ScriptListParams) URLQuery() (v url.Values) {
1978+
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
1979+
ArrayFormat: apiquery.ArrayQueryFormatRepeat,
1980+
NestedFormat: apiquery.NestedQueryFormatDots,
1981+
})
19711982
}
19721983

19731984
type ScriptDeleteParams struct {

workers/script_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func TestScriptUpdateWithOptionalParams(t *testing.T) {
107107
}
108108
}
109109

110-
func TestScriptList(t *testing.T) {
110+
func TestScriptListWithOptionalParams(t *testing.T) {
111111
baseURL := "http://localhost:4010"
112112
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
113113
baseURL = envURL
@@ -122,6 +122,7 @@ func TestScriptList(t *testing.T) {
122122
)
123123
_, err := client.Workers.Scripts.List(context.TODO(), workers.ScriptListParams{
124124
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
125+
Tags: cloudflare.F("production:yes,staging:no"),
125126
})
126127
if err != nil {
127128
var apierr *cloudflare.Error

0 commit comments

Comments
 (0)