Skip to content

Commit

Permalink
chore(internal): codegen related update (#3881)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Jan 31, 2025
1 parent 76a95e3 commit 0e1c191
Show file tree
Hide file tree
Showing 57 changed files with 1,476 additions and 5,690 deletions.
99 changes: 17 additions & 82 deletions accounts/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/cloudflare/cloudflare-go/v4/internal/param"
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
"github.com/cloudflare/cloudflare-go/v4/option"
"github.com/cloudflare/cloudflare-go/v4/packages/pagination"
"github.com/cloudflare/cloudflare-go/v4/shared"
)

Expand Down Expand Up @@ -94,20 +95,30 @@ func (r *SubscriptionService) Delete(ctx context.Context, subscriptionIdentifier
}

// Lists all of an account's subscriptions.
func (r *SubscriptionService) Get(ctx context.Context, query SubscriptionGetParams, opts ...option.RequestOption) (res *[]shared.Subscription, err error) {
var env SubscriptionGetResponseEnvelope
func (r *SubscriptionService) Get(ctx context.Context, query SubscriptionGetParams, opts ...option.RequestOption) (res *pagination.SinglePage[shared.Subscription], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
if query.AccountID.Value == "" {
err = errors.New("missing required account_id parameter")
return
}
path := fmt.Sprintf("accounts/%s/subscriptions", query.AccountID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, nil, &res, opts...)
if err != nil {
return
return nil, err
}
res = &env.Result
return
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}

// Lists all of an account's subscriptions.
func (r *SubscriptionService) GetAutoPaging(ctx context.Context, query SubscriptionGetParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[shared.Subscription] {
return pagination.NewSinglePageAutoPager(r.Get(ctx, query, opts...))
}

type SubscriptionDeleteResponse struct {
Expand Down Expand Up @@ -290,79 +301,3 @@ type SubscriptionGetParams struct {
// Identifier
AccountID param.Field[string] `path:"account_id,required"`
}

type SubscriptionGetResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result []shared.Subscription `json:"result,required,nullable"`
// Whether the API call was successful
Success SubscriptionGetResponseEnvelopeSuccess `json:"success,required"`
ResultInfo SubscriptionGetResponseEnvelopeResultInfo `json:"result_info"`
JSON subscriptionGetResponseEnvelopeJSON `json:"-"`
}

// subscriptionGetResponseEnvelopeJSON contains the JSON metadata for the struct
// [SubscriptionGetResponseEnvelope]
type subscriptionGetResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
ResultInfo apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

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

// Whether the API call was successful
type SubscriptionGetResponseEnvelopeSuccess bool

const (
SubscriptionGetResponseEnvelopeSuccessTrue SubscriptionGetResponseEnvelopeSuccess = true
)

func (r SubscriptionGetResponseEnvelopeSuccess) IsKnown() bool {
switch r {
case SubscriptionGetResponseEnvelopeSuccessTrue:
return true
}
return false
}

type SubscriptionGetResponseEnvelopeResultInfo struct {
// Total number of results for the requested service
Count float64 `json:"count"`
// Current page within paginated list of results
Page float64 `json:"page"`
// Number of results per page of results
PerPage float64 `json:"per_page"`
// Total results available without any search parameters
TotalCount float64 `json:"total_count"`
JSON subscriptionGetResponseEnvelopeResultInfoJSON `json:"-"`
}

// subscriptionGetResponseEnvelopeResultInfoJSON contains the JSON metadata for the
// struct [SubscriptionGetResponseEnvelopeResultInfo]
type subscriptionGetResponseEnvelopeResultInfoJSON struct {
Count apijson.Field
Page apijson.Field
PerPage apijson.Field
TotalCount apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

func (r subscriptionGetResponseEnvelopeResultInfoJSON) RawJSON() string {
return r.raw
}
99 changes: 17 additions & 82 deletions alerting/destinationpagerduty.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/cloudflare/cloudflare-go/v4/internal/param"
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
"github.com/cloudflare/cloudflare-go/v4/option"
"github.com/cloudflare/cloudflare-go/v4/packages/pagination"
"github.com/cloudflare/cloudflare-go/v4/shared"
)

Expand Down Expand Up @@ -64,20 +65,30 @@ func (r *DestinationPagerdutyService) Delete(ctx context.Context, body Destinati
}

// Get a list of all configured PagerDuty services.
func (r *DestinationPagerdutyService) Get(ctx context.Context, query DestinationPagerdutyGetParams, opts ...option.RequestOption) (res *[]Pagerduty, err error) {
var env DestinationPagerdutyGetResponseEnvelope
func (r *DestinationPagerdutyService) Get(ctx context.Context, query DestinationPagerdutyGetParams, opts ...option.RequestOption) (res *pagination.SinglePage[Pagerduty], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
if query.AccountID.Value == "" {
err = errors.New("missing required account_id parameter")
return
}
path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/pagerduty", query.AccountID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, nil, &res, opts...)
if err != nil {
return
return nil, err
}
res = &env.Result
return
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}

// Get a list of all configured PagerDuty services.
func (r *DestinationPagerdutyService) GetAutoPaging(ctx context.Context, query DestinationPagerdutyGetParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Pagerduty] {
return pagination.NewSinglePageAutoPager(r.Get(ctx, query, opts...))
}

// Links PagerDuty with the account using the integration token.
Expand Down Expand Up @@ -301,82 +312,6 @@ type DestinationPagerdutyGetParams struct {
AccountID param.Field[string] `path:"account_id,required"`
}

type DestinationPagerdutyGetResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
// Whether the API call was successful
Success DestinationPagerdutyGetResponseEnvelopeSuccess `json:"success,required"`
Result []Pagerduty `json:"result"`
ResultInfo DestinationPagerdutyGetResponseEnvelopeResultInfo `json:"result_info"`
JSON destinationPagerdutyGetResponseEnvelopeJSON `json:"-"`
}

// destinationPagerdutyGetResponseEnvelopeJSON contains the JSON metadata for the
// struct [DestinationPagerdutyGetResponseEnvelope]
type destinationPagerdutyGetResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Success apijson.Field
Result apijson.Field
ResultInfo apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

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

// Whether the API call was successful
type DestinationPagerdutyGetResponseEnvelopeSuccess bool

const (
DestinationPagerdutyGetResponseEnvelopeSuccessTrue DestinationPagerdutyGetResponseEnvelopeSuccess = true
)

func (r DestinationPagerdutyGetResponseEnvelopeSuccess) IsKnown() bool {
switch r {
case DestinationPagerdutyGetResponseEnvelopeSuccessTrue:
return true
}
return false
}

type DestinationPagerdutyGetResponseEnvelopeResultInfo struct {
// Total number of results for the requested service
Count float64 `json:"count"`
// Current page within paginated list of results
Page float64 `json:"page"`
// Number of results per page of results
PerPage float64 `json:"per_page"`
// Total results available without any search parameters
TotalCount float64 `json:"total_count"`
JSON destinationPagerdutyGetResponseEnvelopeResultInfoJSON `json:"-"`
}

// destinationPagerdutyGetResponseEnvelopeResultInfoJSON contains the JSON metadata
// for the struct [DestinationPagerdutyGetResponseEnvelopeResultInfo]
type destinationPagerdutyGetResponseEnvelopeResultInfoJSON struct {
Count apijson.Field
Page apijson.Field
PerPage apijson.Field
TotalCount apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

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

type DestinationPagerdutyLinkParams struct {
// The account id
AccountID param.Field[string] `path:"account_id,required"`
Expand Down
Loading

0 comments on commit 0e1c191

Please sign in to comment.