Skip to content

Commit

Permalink
feat: update via SDK Studio
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Feb 21, 2024
1 parent e5d7c0e commit 7a06e6d
Show file tree
Hide file tree
Showing 56 changed files with 8,904 additions and 1,567 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 1168
configured_endpoints: 1209
231 changes: 201 additions & 30 deletions api.md

Large diffs are not rendered by default.

276 changes: 276 additions & 0 deletions cachecachereserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ func (r *CacheCacheReserveService) List(ctx context.Context, zoneID string, opts
return
}

// You can use Cache Reserve Clear to clear your Cache Reserve, but you must first
// disable Cache Reserve. In most cases, this will be accomplished within 24 hours.
// You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind
// that you cannot undo or cancel this operation.
func (r *CacheCacheReserveService) Clear(ctx context.Context, zoneID string, opts ...option.RequestOption) (res *CacheCacheReserveClearResponse, err error) {
opts = append(r.Options[:], opts...)
var env CacheCacheReserveClearResponseEnvelope
path := fmt.Sprintf("zones/%s/cache/cache_reserve_clear", zoneID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...)
if err != nil {
return
}
res = &env.Result
return
}

// Increase cache lifetimes by automatically storing all cacheable files into
// Cloudflare's persistent object storage buckets. Requires Cache Reserve
// subscription. Note: using Tiered Cache with Cache Reserve is highly recommended
Expand All @@ -68,6 +84,22 @@ func (r *CacheCacheReserveService) Edit(ctx context.Context, zoneID string, body
return
}

// You can use Cache Reserve Clear to clear your Cache Reserve, but you must first
// disable Cache Reserve. In most cases, this will be accomplished within 24 hours.
// You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind
// that you cannot undo or cancel this operation.
func (r *CacheCacheReserveService) Status(ctx context.Context, zoneID string, opts ...option.RequestOption) (res *CacheCacheReserveStatusResponse, err error) {
opts = append(r.Options[:], opts...)
var env CacheCacheReserveStatusResponseEnvelope
path := fmt.Sprintf("zones/%s/cache/cache_reserve_clear", zoneID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...)
if err != nil {
return
}
res = &env.Result
return
}

// Increase cache lifetimes by automatically storing all cacheable files into
// Cloudflare's persistent object storage buckets. Requires Cache Reserve
// subscription. Note: using Tiered Cache with Cache Reserve is highly recommended
Expand Down Expand Up @@ -113,6 +145,55 @@ const (
CacheCacheReserveListResponseValueOff CacheCacheReserveListResponseValue = "off"
)

// You can use Cache Reserve Clear to clear your Cache Reserve, but you must first
// disable Cache Reserve. In most cases, this will be accomplished within 24 hours.
// You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind
// that you cannot undo or cancel this operation.
type CacheCacheReserveClearResponse struct {
// ID of the zone setting.
ID CacheCacheReserveClearResponseID `json:"id,required"`
// last time this setting was modified.
ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"`
// The time that the latest Cache Reserve Clear operation started.
StartTs time.Time `json:"start_ts,required" format:"date-time"`
// The current state of the Cache Reserve Clear operation.
State CacheCacheReserveClearResponseState `json:"state,required"`
// The time that the latest Cache Reserve Clear operation completed.
EndTs time.Time `json:"end_ts" format:"date-time"`
JSON cacheCacheReserveClearResponseJSON `json:"-"`
}

// cacheCacheReserveClearResponseJSON contains the JSON metadata for the struct
// [CacheCacheReserveClearResponse]
type cacheCacheReserveClearResponseJSON struct {
ID apijson.Field
ModifiedOn apijson.Field
StartTs apijson.Field
State apijson.Field
EndTs apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

// ID of the zone setting.
type CacheCacheReserveClearResponseID string

const (
CacheCacheReserveClearResponseIDCacheReserveClear CacheCacheReserveClearResponseID = "cache_reserve_clear"
)

// The current state of the Cache Reserve Clear operation.
type CacheCacheReserveClearResponseState string

const (
CacheCacheReserveClearResponseStateInProgress CacheCacheReserveClearResponseState = "In-progress"
CacheCacheReserveClearResponseStateCompleted CacheCacheReserveClearResponseState = "Completed"
)

// Increase cache lifetimes by automatically storing all cacheable files into
// Cloudflare's persistent object storage buckets. Requires Cache Reserve
// subscription. Note: using Tiered Cache with Cache Reserve is highly recommended
Expand Down Expand Up @@ -158,6 +239,55 @@ const (
CacheCacheReserveEditResponseValueOff CacheCacheReserveEditResponseValue = "off"
)

// You can use Cache Reserve Clear to clear your Cache Reserve, but you must first
// disable Cache Reserve. In most cases, this will be accomplished within 24 hours.
// You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind
// that you cannot undo or cancel this operation.
type CacheCacheReserveStatusResponse struct {
// ID of the zone setting.
ID CacheCacheReserveStatusResponseID `json:"id,required"`
// last time this setting was modified.
ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"`
// The time that the latest Cache Reserve Clear operation started.
StartTs time.Time `json:"start_ts,required" format:"date-time"`
// The current state of the Cache Reserve Clear operation.
State CacheCacheReserveStatusResponseState `json:"state,required"`
// The time that the latest Cache Reserve Clear operation completed.
EndTs time.Time `json:"end_ts" format:"date-time"`
JSON cacheCacheReserveStatusResponseJSON `json:"-"`
}

// cacheCacheReserveStatusResponseJSON contains the JSON metadata for the struct
// [CacheCacheReserveStatusResponse]
type cacheCacheReserveStatusResponseJSON struct {
ID apijson.Field
ModifiedOn apijson.Field
StartTs apijson.Field
State apijson.Field
EndTs apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

// ID of the zone setting.
type CacheCacheReserveStatusResponseID string

const (
CacheCacheReserveStatusResponseIDCacheReserveClear CacheCacheReserveStatusResponseID = "cache_reserve_clear"
)

// The current state of the Cache Reserve Clear operation.
type CacheCacheReserveStatusResponseState string

const (
CacheCacheReserveStatusResponseStateInProgress CacheCacheReserveStatusResponseState = "In-progress"
CacheCacheReserveStatusResponseStateCompleted CacheCacheReserveStatusResponseState = "Completed"
)

type CacheCacheReserveListResponseEnvelope struct {
Errors []CacheCacheReserveListResponseEnvelopeErrors `json:"errors,required"`
Messages []CacheCacheReserveListResponseEnvelopeMessages `json:"messages,required"`
Expand Down Expand Up @@ -233,6 +363,79 @@ const (
CacheCacheReserveListResponseEnvelopeSuccessTrue CacheCacheReserveListResponseEnvelopeSuccess = true
)

type CacheCacheReserveClearResponseEnvelope struct {
Errors []CacheCacheReserveClearResponseEnvelopeErrors `json:"errors,required"`
Messages []CacheCacheReserveClearResponseEnvelopeMessages `json:"messages,required"`
// You can use Cache Reserve Clear to clear your Cache Reserve, but you must first
// disable Cache Reserve. In most cases, this will be accomplished within 24 hours.
// You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind
// that you cannot undo or cancel this operation.
Result CacheCacheReserveClearResponse `json:"result,required"`
// Whether the API call was successful
Success CacheCacheReserveClearResponseEnvelopeSuccess `json:"success,required"`
JSON cacheCacheReserveClearResponseEnvelopeJSON `json:"-"`
}

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

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

type CacheCacheReserveClearResponseEnvelopeErrors struct {
Code int64 `json:"code,required"`
Message string `json:"message,required"`
JSON cacheCacheReserveClearResponseEnvelopeErrorsJSON `json:"-"`
}

// cacheCacheReserveClearResponseEnvelopeErrorsJSON contains the JSON metadata for
// the struct [CacheCacheReserveClearResponseEnvelopeErrors]
type cacheCacheReserveClearResponseEnvelopeErrorsJSON struct {
Code apijson.Field
Message apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

type CacheCacheReserveClearResponseEnvelopeMessages struct {
Code int64 `json:"code,required"`
Message string `json:"message,required"`
JSON cacheCacheReserveClearResponseEnvelopeMessagesJSON `json:"-"`
}

// cacheCacheReserveClearResponseEnvelopeMessagesJSON contains the JSON metadata
// for the struct [CacheCacheReserveClearResponseEnvelopeMessages]
type cacheCacheReserveClearResponseEnvelopeMessagesJSON struct {
Code apijson.Field
Message apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

// Whether the API call was successful
type CacheCacheReserveClearResponseEnvelopeSuccess bool

const (
CacheCacheReserveClearResponseEnvelopeSuccessTrue CacheCacheReserveClearResponseEnvelopeSuccess = true
)

type CacheCacheReserveEditParams struct {
// Value of the Cache Reserve zone setting.
Value param.Field[CacheCacheReserveEditParamsValue] `json:"value,required"`
Expand Down Expand Up @@ -324,3 +527,76 @@ type CacheCacheReserveEditResponseEnvelopeSuccess bool
const (
CacheCacheReserveEditResponseEnvelopeSuccessTrue CacheCacheReserveEditResponseEnvelopeSuccess = true
)

type CacheCacheReserveStatusResponseEnvelope struct {
Errors []CacheCacheReserveStatusResponseEnvelopeErrors `json:"errors,required"`
Messages []CacheCacheReserveStatusResponseEnvelopeMessages `json:"messages,required"`
// You can use Cache Reserve Clear to clear your Cache Reserve, but you must first
// disable Cache Reserve. In most cases, this will be accomplished within 24 hours.
// You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind
// that you cannot undo or cancel this operation.
Result CacheCacheReserveStatusResponse `json:"result,required"`
// Whether the API call was successful
Success CacheCacheReserveStatusResponseEnvelopeSuccess `json:"success,required"`
JSON cacheCacheReserveStatusResponseEnvelopeJSON `json:"-"`
}

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

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

type CacheCacheReserveStatusResponseEnvelopeErrors struct {
Code int64 `json:"code,required"`
Message string `json:"message,required"`
JSON cacheCacheReserveStatusResponseEnvelopeErrorsJSON `json:"-"`
}

// cacheCacheReserveStatusResponseEnvelopeErrorsJSON contains the JSON metadata for
// the struct [CacheCacheReserveStatusResponseEnvelopeErrors]
type cacheCacheReserveStatusResponseEnvelopeErrorsJSON struct {
Code apijson.Field
Message apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

type CacheCacheReserveStatusResponseEnvelopeMessages struct {
Code int64 `json:"code,required"`
Message string `json:"message,required"`
JSON cacheCacheReserveStatusResponseEnvelopeMessagesJSON `json:"-"`
}

// cacheCacheReserveStatusResponseEnvelopeMessagesJSON contains the JSON metadata
// for the struct [CacheCacheReserveStatusResponseEnvelopeMessages]
type cacheCacheReserveStatusResponseEnvelopeMessagesJSON struct {
Code apijson.Field
Message apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

// Whether the API call was successful
type CacheCacheReserveStatusResponseEnvelopeSuccess bool

const (
CacheCacheReserveStatusResponseEnvelopeSuccessTrue CacheCacheReserveStatusResponseEnvelopeSuccess = true
)
52 changes: 52 additions & 0 deletions cachecachereserve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,32 @@ func TestCacheCacheReserveList(t *testing.T) {
}
}

func TestCacheCacheReserveClear(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
client := cloudflare.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
option.WithAPIEmail("user@example.com"),
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
option.WithUserServiceKey("v1.0-144c9defac04969c7bfad8ef-631a41d003a32d25fe878081ef365c49503f7fada600da935e2851a1c7326084b85cbf6429c4b859de8475731dc92a9c329631e6d59e6c73da7b198497172b4cefe071d90d0f5d2719"),
)
_, err := client.Cache.CacheReserve.Clear(context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353")
if err != nil {
var apierr *cloudflare.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}

func TestCacheCacheReserveEdit(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010"
Expand Down Expand Up @@ -70,3 +96,29 @@ func TestCacheCacheReserveEdit(t *testing.T) {
t.Fatalf("err should be nil: %s", err.Error())
}
}

func TestCacheCacheReserveStatus(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
client := cloudflare.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
option.WithAPIEmail("user@example.com"),
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
option.WithUserServiceKey("v1.0-144c9defac04969c7bfad8ef-631a41d003a32d25fe878081ef365c49503f7fada600da935e2851a1c7326084b85cbf6429c4b859de8475731dc92a9c329631e6d59e6c73da7b198497172b4cefe071d90d0f5d2719"),
)
_, err := client.Cache.CacheReserve.Status(context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353")
if err != nil {
var apierr *cloudflare.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}
Loading

0 comments on commit 7a06e6d

Please sign in to comment.