Skip to content

Commit

Permalink
feat(api): remap models to newer bundle names (#3556)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Nov 4, 2024
1 parent 2c620f8 commit 55ea581
Show file tree
Hide file tree
Showing 11 changed files with 339 additions and 793 deletions.
63 changes: 33 additions & 30 deletions api.md

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions argo/tieredcaching.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 9,7 @@ import (
"net/http"
"time"

"github.com/cloudflare/cloudflare-go/v3/cache"
"github.com/cloudflare/cloudflare-go/v3/internal/apijson"
"github.com/cloudflare/cloudflare-go/v3/internal/param"
"github.com/cloudflare/cloudflare-go/v3/internal/requestconfig"
Expand Down Expand Up @@ -165,7 166,7 @@ func (r TieredCachingGetResponseValue) IsKnown() bool {

type TieredCachingEditParams struct {
// Identifier
ZoneID param.Field[string] `path:"zone_id,required"`
ZoneID param.Field[cache.CacheVariantIdentifierParam] `path:"zone_id,required"`
// Enables Tiered Caching.
Value param.Field[TieredCachingEditParamsValue] `json:"value,required"`
}
Expand Down Expand Up @@ -235,7 236,7 @@ func (r TieredCachingEditResponseEnvelopeSuccess) IsKnown() bool {

type TieredCachingGetParams struct {
// Identifier
ZoneID param.Field[string] `path:"zone_id,required"`
ZoneID param.Field[cache.CacheVariantIdentifierParam] `path:"zone_id,required"`
}

type TieredCachingGetResponseEnvelope struct {
Expand Down
10 changes: 5 additions & 5 deletions cache/cachereserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 343,8 @@ func (r cacheReserveStatusResponseJSON) RawJSON() string {

type CacheReserveClearParams struct {
// Identifier
ZoneID param.Field[string] `path:"zone_id,required"`
Body interface{} `json:"body,required"`
ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"`
Body interface{} `json:"body,required"`
}

func (r CacheReserveClearParams) MarshalJSON() (data []byte, err error) {
Expand Down Expand Up @@ -400,7 400,7 @@ func (r CacheReserveClearResponseEnvelopeSuccess) IsKnown() bool {

type CacheReserveEditParams struct {
// Identifier
ZoneID param.Field[string] `path:"zone_id,required"`
ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"`
// Value of the Cache Reserve zone setting.
Value param.Field[CacheReserveEditParamsValue] `json:"value,required"`
}
Expand Down Expand Up @@ -476,7 476,7 @@ func (r CacheReserveEditResponseEnvelopeSuccess) IsKnown() bool {

type CacheReserveGetParams struct {
// Identifier
ZoneID param.Field[string] `path:"zone_id,required"`
ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"`
}

type CacheReserveGetResponseEnvelope struct {
Expand Down Expand Up @@ -530,7 530,7 @@ func (r CacheReserveGetResponseEnvelopeSuccess) IsKnown() bool {

type CacheReserveStatusParams struct {
// Identifier
ZoneID param.Field[string] `path:"zone_id,required"`
ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"`
}

type CacheReserveStatusResponseEnvelope struct {
Expand Down
4 changes: 2 additions & 2 deletions cache/regionaltieredcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 212,7 @@ func (r regionalTieredCacheGetResponseValueJSON) RawJSON() string {

type RegionalTieredCacheEditParams struct {
// Identifier
ZoneID param.Field[string] `path:"zone_id,required"`
ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"`
// Value of the Regional Tiered Cache zone setting.
Value param.Field[RegionalTieredCacheEditParamsValue] `json:"value,required"`
}
Expand Down Expand Up @@ -285,7 285,7 @@ func (r RegionalTieredCacheEditResponseEnvelopeSuccess) IsKnown() bool {

type RegionalTieredCacheGetParams struct {
// Identifier
ZoneID param.Field[string] `path:"zone_id,required"`
ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"`
}

type RegionalTieredCacheGetResponseEnvelope struct {
Expand Down
6 changes: 3 additions & 3 deletions cache/smarttieredcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 229,7 @@ func (r SmartTieredCacheGetResponseValue) IsKnown() bool {

type SmartTieredCacheDeleteParams struct {
// Identifier
ZoneID param.Field[string] `path:"zone_id,required"`
ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"`
}

type SmartTieredCacheDeleteResponseEnvelope struct {
Expand Down Expand Up @@ -277,7 277,7 @@ func (r SmartTieredCacheDeleteResponseEnvelopeSuccess) IsKnown() bool {

type SmartTieredCacheEditParams struct {
// Identifier
ZoneID param.Field[string] `path:"zone_id,required"`
ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"`
// Enable or disable the Smart Tiered Cache
Value param.Field[SmartTieredCacheEditParamsValue] `json:"value,required"`
}
Expand Down Expand Up @@ -347,7 347,7 @@ func (r SmartTieredCacheEditResponseEnvelopeSuccess) IsKnown() bool {

type SmartTieredCacheGetParams struct {
// Identifier
ZoneID param.Field[string] `path:"zone_id,required"`
ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"`
}

type SmartTieredCacheGetResponseEnvelope struct {
Expand Down
93 changes: 62 additions & 31 deletions cache/variant.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 40,7 @@ func NewVariantService(opts ...option.RequestOption) (r *VariantService) {
// 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but
// does not serve the variant requested, the response will not be cached. This will
// be indicated with BYPASS cache status in the response headers.
func (r *VariantService) Delete(ctx context.Context, body VariantDeleteParams, opts ...option.RequestOption) (res *VariantDeleteResponse, err error) {
func (r *VariantService) Delete(ctx context.Context, body VariantDeleteParams, opts ...option.RequestOption) (res *CacheVariant, err error) {
var env VariantDeleteResponseEnvelope
opts = append(r.Options[:], opts...)
if body.ZoneID.Value == "" {
Expand Down Expand Up @@ -98,59 98,60 @@ func (r *VariantService) Get(ctx context.Context, query VariantGetParams, opts .
return
}

// ID of the zone setting.
type CacheVariantIdentifier string

const (
CacheVariantIdentifierVariants CacheVariantIdentifier = "variants"
)

func (r CacheVariantIdentifier) IsKnown() bool {
switch r {
case CacheVariantIdentifierVariants:
return true
}
return false
}

// Variant support enables caching variants of images with certain file extensions
// in addition to the original. This only applies when the origin server sends the
// 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but
// does not serve the variant requested, the response will not be cached. This will
// be indicated with BYPASS cache status in the response headers.
type VariantDeleteResponse struct {
type CacheVariant struct {
// ID of the zone setting.
ID CacheVariantIdentifier `json:"id,required"`
ID CacheVariantID `json:"id,required"`
// last time this setting was modified.
ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"`
JSON variantDeleteResponseJSON `json:"-"`
ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"`
JSON cacheVariantJSON `json:"-"`
}

// variantDeleteResponseJSON contains the JSON metadata for the struct
// [VariantDeleteResponse]
type variantDeleteResponseJSON struct {
// cacheVariantJSON contains the JSON metadata for the struct [CacheVariant]
type cacheVariantJSON struct {
ID apijson.Field
ModifiedOn apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

func (r variantDeleteResponseJSON) RawJSON() string {
func (r cacheVariantJSON) RawJSON() string {
return r.raw
}

// ID of the zone setting.
type CacheVariantID string

const (
CacheVariantIDVariants CacheVariantID = "variants"
)

func (r CacheVariantID) IsKnown() bool {
switch r {
case CacheVariantIDVariants:
return true
}
return false
}

type CacheVariantIdentifierParam = string

// Variant support enables caching variants of images with certain file extensions
// in addition to the original. This only applies when the origin server sends the
// 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but
// does not serve the variant requested, the response will not be cached. This will
// be indicated with BYPASS cache status in the response headers.
type VariantEditResponse struct {
// ID of the zone setting.
ID CacheVariantIdentifier `json:"id,required"`
ID VariantEditResponseID `json:"id,required"`
// last time this setting was modified.
ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"`
// Value of the zone setting.
Expand All @@ -176,6 177,21 @@ func (r variantEditResponseJSON) RawJSON() string {
return r.raw
}

// ID of the zone setting.
type VariantEditResponseID string

const (
VariantEditResponseIDVariants VariantEditResponseID = "variants"
)

func (r VariantEditResponseID) IsKnown() bool {
switch r {
case VariantEditResponseIDVariants:
return true
}
return false
}

// Value of the zone setting.
type VariantEditResponseValue struct {
// List of strings with the MIME types of all the variants that should be served
Expand Down Expand Up @@ -247,7 263,7 @@ func (r variantEditResponseValueJSON) RawJSON() string {
// be indicated with BYPASS cache status in the response headers.
type VariantGetResponse struct {
// ID of the zone setting.
ID CacheVariantIdentifier `json:"id,required"`
ID VariantGetResponseID `json:"id,required"`
// last time this setting was modified.
ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"`
// Value of the zone setting.
Expand All @@ -273,6 289,21 @@ func (r variantGetResponseJSON) RawJSON() string {
return r.raw
}

// ID of the zone setting.
type VariantGetResponseID string

const (
VariantGetResponseIDVariants VariantGetResponseID = "variants"
)

func (r VariantGetResponseID) IsKnown() bool {
switch r {
case VariantGetResponseIDVariants:
return true
}
return false
}

// Value of the zone setting.
type VariantGetResponseValue struct {
// List of strings with the MIME types of all the variants that should be served
Expand Down Expand Up @@ -339,7 370,7 @@ func (r variantGetResponseValueJSON) RawJSON() string {

type VariantDeleteParams struct {
// Identifier
ZoneID param.Field[string] `path:"zone_id,required"`
ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"`
}

type VariantDeleteResponseEnvelope struct {
Expand All @@ -350,7 381,7 @@ type VariantDeleteResponseEnvelope struct {
// 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but
// does not serve the variant requested, the response will not be cached. This will
// be indicated with BYPASS cache status in the response headers.
Result VariantDeleteResponse `json:"result,required"`
Result CacheVariant `json:"result,required"`
// Whether the API call was successful
Success VariantDeleteResponseEnvelopeSuccess `json:"success,required"`
JSON variantDeleteResponseEnvelopeJSON `json:"-"`
Expand Down Expand Up @@ -392,7 423,7 @@ func (r VariantDeleteResponseEnvelopeSuccess) IsKnown() bool {

type VariantEditParams struct {
// Identifier
ZoneID param.Field[string] `path:"zone_id,required"`
ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"`
// Value of the zone setting.
Value param.Field[VariantEditParamsValue] `json:"value,required"`
}
Expand Down Expand Up @@ -492,7 523,7 @@ func (r VariantEditResponseEnvelopeSuccess) IsKnown() bool {

type VariantGetParams struct {
// Identifier
ZoneID param.Field[string] `path:"zone_id,required"`
ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"`
}

type VariantGetResponseEnvelope struct {
Expand Down
Loading

0 comments on commit 55ea581

Please sign in to comment.