Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#1747)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Apr 10, 2024
1 parent c45c68e commit c22805e
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 75 deletions.
10 changes: 5 additions & 5 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3878,20 +3878,20 @@ Params Types:
Response Types:

- <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#Hostname">Hostname</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#List">List</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#Redirect">Redirect</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#RuleList">RuleList</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#ListNewResponse">ListNewResponse</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#ListUpdateResponse">ListUpdateResponse</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#ListDeleteResponse">ListDeleteResponse</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#ListGetResponse">ListGetResponse</a>

Methods:

- <code title="post /accounts/{account_id}/rules/lists">client.Rules.Lists.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListService.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/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListNewParams">ListNewParams</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#List">List</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="put /accounts/{account_id}/rules/lists/{list_id}">client.Rules.Lists.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListService.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#ListUpdateParams">ListUpdateParams</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#List">List</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_id}/rules/lists">client.Rules.Lists.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListService.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/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListListParams">ListListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/pagination#SinglePage">SinglePage</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#List">List</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="post /accounts/{account_id}/rules/lists">client.Rules.Lists.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListService.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/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListNewParams">ListNewParams</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#RuleList">RuleList</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="put /accounts/{account_id}/rules/lists/{list_id}">client.Rules.Lists.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListService.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#ListUpdateParams">ListUpdateParams</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#RuleList">RuleList</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_id}/rules/lists">client.Rules.Lists.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListService.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/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListListParams">ListListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/pagination#SinglePage">SinglePage</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#RuleList">RuleList</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="delete /accounts/{account_id}/rules/lists/{list_id}">client.Rules.Lists.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListService.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#ListDeleteParams">ListDeleteParams</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#ListDeleteResponse">ListDeleteResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_id}/rules/lists/{list_id}">client.Rules.Lists.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListService.Get">Get</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>, query <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#ListGetParams">ListGetParams</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#List">List</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_id}/rules/lists/{list_id}">client.Rules.Lists.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListService.Get">Get</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>, query <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#ListGetParams">ListGetParams</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#RuleList">RuleList</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

### BulkOperations

Expand Down
140 changes: 70 additions & 70 deletions rules/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func NewListService(opts ...option.RequestOption) (r *ListService) {
}

// Creates a new list of the specified type.
func (r *ListService) New(ctx context.Context, params ListNewParams, opts ...option.RequestOption) (res *List, err error) {
func (r *ListService) New(ctx context.Context, params ListNewParams, opts ...option.RequestOption) (res *RuleList, err error) {
opts = append(r.Options[:], opts...)
var env ListNewResponseEnvelope
path := fmt.Sprintf("accounts/%s/rules/lists", params.AccountID)
Expand All @@ -50,7 +50,7 @@ func (r *ListService) New(ctx context.Context, params ListNewParams, opts ...opt
}

// Updates the description of a list.
func (r *ListService) Update(ctx context.Context, listID string, params ListUpdateParams, opts ...option.RequestOption) (res *List, err error) {
func (r *ListService) Update(ctx context.Context, listID string, params ListUpdateParams, opts ...option.RequestOption) (res *RuleList, err error) {
opts = append(r.Options[:], opts...)
var env ListUpdateResponseEnvelope
path := fmt.Sprintf("accounts/%s/rules/lists/%s", params.AccountID, listID)
Expand All @@ -63,7 +63,7 @@ func (r *ListService) Update(ctx context.Context, listID string, params ListUpda
}

// Fetches all lists in the account.
func (r *ListService) List(ctx context.Context, query ListListParams, opts ...option.RequestOption) (res *pagination.SinglePage[List], err error) {
func (r *ListService) List(ctx context.Context, query ListListParams, opts ...option.RequestOption) (res *pagination.SinglePage[RuleList], err error) {
var raw *http.Response
opts = append(r.Options, opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
Expand All @@ -81,7 +81,7 @@ func (r *ListService) List(ctx context.Context, query ListListParams, opts ...op
}

// Fetches all lists in the account.
func (r *ListService) ListAutoPaging(ctx context.Context, query ListListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[List] {
func (r *ListService) ListAutoPaging(ctx context.Context, query ListListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[RuleList] {
return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...))
}

Expand All @@ -99,7 +99,7 @@ func (r *ListService) Delete(ctx context.Context, listID string, params ListDele
}

// Fetches the details of a list.
func (r *ListService) Get(ctx context.Context, listID string, query ListGetParams, opts ...option.RequestOption) (res *List, err error) {
func (r *ListService) Get(ctx context.Context, listID string, query ListGetParams, opts ...option.RequestOption) (res *RuleList, err error) {
opts = append(r.Options[:], opts...)
var env ListGetResponseEnvelope
path := fmt.Sprintf("accounts/%s/rules/lists/%s", query.AccountID, listID)
Expand Down Expand Up @@ -145,68 +145,6 @@ func (r HostnameParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

type List struct {
// The unique ID of the list.
ID string `json:"id"`
// The RFC 3339 timestamp of when the list was created.
CreatedOn string `json:"created_on"`
// An informative summary of the list.
Description string `json:"description"`
// The type of the list. Each type supports specific list items (IP addresses,
// ASNs, hostnames or redirects).
Kind ListKind `json:"kind"`
// The RFC 3339 timestamp of when the list was last modified.
ModifiedOn string `json:"modified_on"`
// An informative name for the list. Use this name in filter and rule expressions.
Name string `json:"name"`
// The number of items in the list.
NumItems float64 `json:"num_items"`
// The number of [filters](/operations/filters-list-filters) referencing the list.
NumReferencingFilters float64 `json:"num_referencing_filters"`
JSON listJSON `json:"-"`
}

// listJSON contains the JSON metadata for the struct [List]
type listJSON struct {
ID apijson.Field
CreatedOn apijson.Field
Description apijson.Field
Kind apijson.Field
ModifiedOn apijson.Field
Name apijson.Field
NumItems apijson.Field
NumReferencingFilters apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

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

// The type of the list. Each type supports specific list items (IP addresses,
// ASNs, hostnames or redirects).
type ListKind string

const (
ListKindIP ListKind = "ip"
ListKindRedirect ListKind = "redirect"
ListKindHostname ListKind = "hostname"
ListKindASN ListKind = "asn"
)

func (r ListKind) IsKnown() bool {
switch r {
case ListKindIP, ListKindRedirect, ListKindHostname, ListKindASN:
return true
}
return false
}

// The definition of the redirect.
type Redirect struct {
SourceURL string `json:"source_url,required"`
Expand Down Expand Up @@ -274,6 +212,68 @@ func (r RedirectParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

type RuleList struct {
// The unique ID of the list.
ID string `json:"id"`
// The RFC 3339 timestamp of when the list was created.
CreatedOn string `json:"created_on"`
// An informative summary of the list.
Description string `json:"description"`
// The type of the list. Each type supports specific list items (IP addresses,
// ASNs, hostnames or redirects).
Kind RuleListKind `json:"kind"`
// The RFC 3339 timestamp of when the list was last modified.
ModifiedOn string `json:"modified_on"`
// An informative name for the list. Use this name in filter and rule expressions.
Name string `json:"name"`
// The number of items in the list.
NumItems float64 `json:"num_items"`
// The number of [filters](/operations/filters-list-filters) referencing the list.
NumReferencingFilters float64 `json:"num_referencing_filters"`
JSON ruleListJSON `json:"-"`
}

// ruleListJSON contains the JSON metadata for the struct [RuleList]
type ruleListJSON struct {
ID apijson.Field
CreatedOn apijson.Field
Description apijson.Field
Kind apijson.Field
ModifiedOn apijson.Field
Name apijson.Field
NumItems apijson.Field
NumReferencingFilters apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

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

// The type of the list. Each type supports specific list items (IP addresses,
// ASNs, hostnames or redirects).
type RuleListKind string

const (
RuleListKindIP RuleListKind = "ip"
RuleListKindRedirect RuleListKind = "redirect"
RuleListKindHostname RuleListKind = "hostname"
RuleListKindASN RuleListKind = "asn"
)

func (r RuleListKind) IsKnown() bool {
switch r {
case RuleListKindIP, RuleListKindRedirect, RuleListKindHostname, RuleListKindASN:
return true
}
return false
}

type ListNewResponse = interface{}

type ListUpdateResponse = interface{}
Expand Down Expand Up @@ -340,7 +340,7 @@ func (r ListNewParamsKind) IsKnown() bool {
type ListNewResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result List `json:"result,required,nullable"`
Result RuleList `json:"result,required,nullable"`
// Whether the API call was successful
Success ListNewResponseEnvelopeSuccess `json:"success,required"`
JSON listNewResponseEnvelopeJSON `json:"-"`
Expand Down Expand Up @@ -394,7 +394,7 @@ func (r ListUpdateParams) MarshalJSON() (data []byte, err error) {
type ListUpdateResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result List `json:"result,required,nullable"`
Result RuleList `json:"result,required,nullable"`
// Whether the API call was successful
Success ListUpdateResponseEnvelopeSuccess `json:"success,required"`
JSON listUpdateResponseEnvelopeJSON `json:"-"`
Expand Down Expand Up @@ -500,7 +500,7 @@ type ListGetParams struct {
type ListGetResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result List `json:"result,required,nullable"`
Result RuleList `json:"result,required,nullable"`
// Whether the API call was successful
Success ListGetResponseEnvelopeSuccess `json:"success,required"`
JSON listGetResponseEnvelopeJSON `json:"-"`
Expand Down

0 comments on commit c22805e

Please sign in to comment.