Skip to content

Commit

Permalink
feat: update via SDK Studio (#1531)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Mar 10, 2024
1 parent 73bb1b6 commit ebedc4f
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 236 deletions.
8 changes: 4 additions & 4 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2666,7 +2666,7 @@ Response Types:

Methods:

- <code title="get /accounts/{account_id}/storage/kv/namespaces/{namespace_id}/keys">client.KV.Namespaces.Keys.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/kv#NamespaceKeyService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, namespaceID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/kv">kv</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/kv#NamespaceKeyListParams">NamespaceKeyListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared#CursorPagination">CursorPagination</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/kv">kv</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/kv#WorkersKVKey">WorkersKVKey</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_id}/storage/kv/namespaces/{namespace_id}/keys">client.KV.Namespaces.Keys.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/kv#NamespaceKeyService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, namespaceID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/kv">kv</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/kv#NamespaceKeyListParams">NamespaceKeyListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared#CursorLimitPagination">CursorLimitPagination</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/kv">kv</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/kv#WorkersKVKey">WorkersKVKey</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

### Metadata

Expand Down Expand Up @@ -2711,7 +2711,7 @@ Response Types:

Methods:

- <code title="get /accounts/{account_id}/workers/durable_objects/namespaces/{id}/objects">client.DurableObjects.Namespaces.Objects.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/durable_objects#NamespaceObjectService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/durable_objects">durable_objects</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/durable_objects#NamespaceObjectListParams">NamespaceObjectListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared#CursorPagination">CursorPagination</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/durable_objects">durable_objects</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/durable_objects#WorkersObject">WorkersObject</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_id}/workers/durable_objects/namespaces/{id}/objects">client.DurableObjects.Namespaces.Objects.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/durable_objects#NamespaceObjectService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/durable_objects">durable_objects</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/durable_objects#NamespaceObjectListParams">NamespaceObjectListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared#CursorLimitPagination">CursorLimitPagination</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/durable_objects">durable_objects</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/durable_objects#WorkersObject">WorkersObject</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

# Queues

Expand Down Expand Up @@ -3681,7 +3681,7 @@ Methods:

- <code title="post /accounts/{account_id}/rules/lists/{list_id}/items">client.Rules.Lists.Items.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, listID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemNewParams">ListItemNewParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemNewResponse">ListItemNewResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="put /accounts/{account_id}/rules/lists/{list_id}/items">client.Rules.Lists.Items.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemService.Update">Update</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, listID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemUpdateParams">ListItemUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemUpdateResponse">ListItemUpdateResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_id}/rules/lists/{list_id}/items">client.Rules.Lists.Items.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, listID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemListParams">ListItemListParams</a>) ([]<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemListResponse">ListItemListResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_id}/rules/lists/{list_id}/items">client.Rules.Lists.Items.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, listID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemListParams">ListItemListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared#CursorPagination">CursorPagination</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemListResponse">ListItemListResponse</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="delete /accounts/{account_id}/rules/lists/{list_id}/items">client.Rules.Lists.Items.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, listID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemDeleteParams">ListItemDeleteParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemDeleteResponse">ListItemDeleteResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_identifier}/rules/lists/{list_id}/items/{item_id}">client.Rules.Lists.Items.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, accountIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>, listID <a href="https://pkg.go.dev/builtin#string">string</a>, itemID <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemGetResponse">ListItemGetResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

Expand Down Expand Up @@ -3997,7 +3997,7 @@ Response Types:
Methods:

- <code title="post /accounts/{account_id}/r2/buckets">client.R2.Buckets.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2#BucketService.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/v2/r2">r2</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2#BucketNewParams">BucketNewParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2">r2</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2#R2Bucket">R2Bucket</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_id}/r2/buckets">client.R2.Buckets.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2#BucketService.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/v2/r2">r2</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2#BucketListParams">BucketListParams</a>) ([]<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2">r2</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2#R2Bucket">R2Bucket</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_id}/r2/buckets">client.R2.Buckets.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2#BucketService.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/v2/r2">r2</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2#BucketListParams">BucketListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/shared#CursorPagination">CursorPagination</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2">r2</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2#R2Bucket">R2Bucket</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="delete /accounts/{account_id}/r2/buckets/{bucket_name}">client.R2.Buckets.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2#BucketService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, bucketName <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2">r2</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2#BucketDeleteParams">BucketDeleteParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2">r2</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2#BucketDeleteResponse">BucketDeleteResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_id}/r2/buckets/{bucket_name}">client.R2.Buckets.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2#BucketService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, bucketName <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2">r2</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2#BucketGetParams">BucketGetParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2">r2</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/r2#R2Bucket">R2Bucket</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

Expand Down
6 changes: 3 additions & 3 deletions durable_objects/namespaceobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewNamespaceObjectService(opts ...option.RequestOption) (r *NamespaceObject
}

// Returns the Durable Objects in a given namespace.
func (r *NamespaceObjectService) List(ctx context.Context, id string, params NamespaceObjectListParams, opts ...option.RequestOption) (res *shared.CursorPagination[WorkersObject], err error) {
func (r *NamespaceObjectService) List(ctx context.Context, id string, params NamespaceObjectListParams, opts ...option.RequestOption) (res *shared.CursorLimitPagination[WorkersObject], err error) {
var raw *http.Response
opts = append(r.Options, opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
Expand All @@ -53,8 +53,8 @@ func (r *NamespaceObjectService) List(ctx context.Context, id string, params Nam
}

// Returns the Durable Objects in a given namespace.
func (r *NamespaceObjectService) ListAutoPaging(ctx context.Context, id string, params NamespaceObjectListParams, opts ...option.RequestOption) *shared.CursorPaginationAutoPager[WorkersObject] {
return shared.NewCursorPaginationAutoPager(r.List(ctx, id, params, opts...))
func (r *NamespaceObjectService) ListAutoPaging(ctx context.Context, id string, params NamespaceObjectListParams, opts ...option.RequestOption) *shared.CursorLimitPaginationAutoPager[WorkersObject] {
return shared.NewCursorLimitPaginationAutoPager(r.List(ctx, id, params, opts...))
}

type WorkersObject struct {
Expand Down
120 changes: 120 additions & 0 deletions internal/shared/pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,123 @@ func (r *CursorPaginationAutoPager[T]) Err() error {
func (r *CursorPaginationAutoPager[T]) Index() int {
return r.run
}

type CursorLimitPaginationResultInfo struct {
Count int64 `json:"count"`
Cursor string `json:"cursor"`
PerPage int64 `json:"per_page"`
JSON cursorLimitPaginationResultInfoJSON `json:"-"`
}

// cursorLimitPaginationResultInfoJSON contains the JSON metadata for the struct
// [CursorLimitPaginationResultInfo]
type cursorLimitPaginationResultInfoJSON struct {
Count apijson.Field
Cursor apijson.Field
PerPage apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *CursorLimitPaginationResultInfo) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r cursorLimitPaginationResultInfoJSON) RawJSON() string {
return r.raw
}

type CursorLimitPagination[T any] struct {
Result []T `json:"result"`
ResultInfo CursorLimitPaginationResultInfo `json:"result_info"`
JSON cursorLimitPaginationJSON `json:"-"`
cfg *requestconfig.RequestConfig
res *http.Response
}

// cursorLimitPaginationJSON contains the JSON metadata for the struct
// [CursorLimitPagination[T]]
type cursorLimitPaginationJSON struct {
Result apijson.Field
ResultInfo apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *CursorLimitPagination[T]) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r cursorLimitPaginationJSON) RawJSON() string {
return r.raw
}

// NextPage returns the next page as defined by this pagination style. When there
// is no next page, this function will return a 'nil' for the page value, but will
// not return an error
func (r *CursorLimitPagination[T]) GetNextPage() (res *CursorLimitPagination[T], err error) {
next := r.ResultInfo.Cursor
if len(next) == 0 {
return nil, nil
}
cfg := r.cfg.Clone(r.cfg.Context)
cfg.Apply(option.WithQuery("cursor", next))
var raw *http.Response
cfg.ResponseInto = &raw
cfg.ResponseBodyInto = &res
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}

func (r *CursorLimitPagination[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {
r.cfg = cfg
r.res = res
}

type CursorLimitPaginationAutoPager[T any] struct {
page *CursorLimitPagination[T]
cur T
idx int
run int
err error
}

func NewCursorLimitPaginationAutoPager[T any](page *CursorLimitPagination[T], err error) *CursorLimitPaginationAutoPager[T] {
return &CursorLimitPaginationAutoPager[T]{
page: page,
err: err,
}
}

func (r *CursorLimitPaginationAutoPager[T]) Next() bool {
if r.page == nil || len(r.page.Result) == 0 {
return false
}
if r.idx >= len(r.page.Result) {
r.idx = 0
r.page, r.err = r.page.GetNextPage()
if r.err != nil || r.page == nil || len(r.page.Result) == 0 {
return false
}
}
r.cur = r.page.Result[r.idx]
r.run += 1
r.idx += 1
return true
}

func (r *CursorLimitPaginationAutoPager[T]) Current() T {
return r.cur
}

func (r *CursorLimitPaginationAutoPager[T]) Err() error {
return r.err
}

func (r *CursorLimitPaginationAutoPager[T]) Index() int {
return r.run
}
6 changes: 3 additions & 3 deletions kv/namespacekey.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewNamespaceKeyService(opts ...option.RequestOption) (r *NamespaceKeyServic
}

// Lists a namespace's keys.
func (r *NamespaceKeyService) List(ctx context.Context, namespaceID string, params NamespaceKeyListParams, opts ...option.RequestOption) (res *shared.CursorPagination[WorkersKVKey], err error) {
func (r *NamespaceKeyService) List(ctx context.Context, namespaceID string, params NamespaceKeyListParams, opts ...option.RequestOption) (res *shared.CursorLimitPagination[WorkersKVKey], err error) {
var raw *http.Response
opts = append(r.Options, opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
Expand All @@ -53,8 +53,8 @@ func (r *NamespaceKeyService) List(ctx context.Context, namespaceID string, para
}

// Lists a namespace's keys.
func (r *NamespaceKeyService) ListAutoPaging(ctx context.Context, namespaceID string, params NamespaceKeyListParams, opts ...option.RequestOption) *shared.CursorPaginationAutoPager[WorkersKVKey] {
return shared.NewCursorPaginationAutoPager(r.List(ctx, namespaceID, params, opts...))
func (r *NamespaceKeyService) ListAutoPaging(ctx context.Context, namespaceID string, params NamespaceKeyListParams, opts ...option.RequestOption) *shared.CursorLimitPaginationAutoPager[WorkersKVKey] {
return shared.NewCursorLimitPaginationAutoPager(r.List(ctx, namespaceID, params, opts...))
}

// A name for a value. A value stored under a given key may be retrieved via the
Expand Down
Loading

0 comments on commit ebedc4f

Please sign in to comment.