Skip to content

Commit

Permalink
lowercase error messages and make docs include API references
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobbednarz committed Dec 22, 2022
1 parent 49a9103 commit 438ff78
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions tiered_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ const notFoundError = "Unable to retrieve tiered_cache_smart_topology_enable set
// This function does not support custom topologies, only Generic and Smart Tiered Caching.
//
// API Reference: https://api.cloudflare.com/#smart-tiered-cache-get-smart-tiered-cache-setting
//
// https://api.cloudflare.com/#tiered-cache-get-tiered-cache-setting
// API Reference: https://api.cloudflare.com/#tiered-cache-get-tiered-cache-setting
func (api *API) GetTieredCache(ctx context.Context, rc *ResourceContainer) (TieredCache, error) {
var lastModified time.Time

Expand Down Expand Up @@ -63,8 +62,7 @@ func (api *API) GetTieredCache(ctx context.Context, rc *ResourceContainer) (Tier
// Using the value of TieredCacheOff will disable Tiered Cache entirely.
//
// API Reference: https://api.cloudflare.com/#smart-tiered-cache-patch-smart-tiered-cache-setting
//
// https://api.cloudflare.com/#tiered-cache-patch-tiered-cache-setting
// API Reference: https://api.cloudflare.com/#tiered-cache-patch-tiered-cache-setting
func (api *API) SetTieredCache(ctx context.Context, rc *ResourceContainer, value TieredCacheType) (TieredCache, error) {
if value == TieredCacheOff {
return api.DeleteTieredCache(ctx, rc)
Expand Down Expand Up @@ -111,8 +109,7 @@ func (api *API) SetTieredCache(ctx context.Context, rc *ResourceContainer, value
// This is equivalent to using SetTieredCache with the value of TieredCacheOff.
//
// API Reference: https://api.cloudflare.com/#smart-tiered-cache-delete-smart-tiered-cache-setting
//
// https://api.cloudflare.com/#tiered-cache-patch-tiered-cache-setting
// API Reference: https://api.cloudflare.com/#tiered-cache-patch-tiered-cache-setting
func (api *API) DeleteTieredCache(ctx context.Context, rc *ResourceContainer) (TieredCache, error) {
var lastModified time.Time

Expand Down Expand Up @@ -162,7 +159,7 @@ func getGenericTieredCache(api *API, ctx context.Context, rc *ResourceContainer)
}

if !response.Success {
return TieredCache{Type: TieredCacheOff}, errors.New("Request to retrieve generic tiered cache failed")
return TieredCache{Type: TieredCacheOff}, errors.New("request to retrieve generic tiered cache failed")
}

if response.Result.Value == "off" {
Expand All @@ -189,7 +186,7 @@ func getSmartTieredCache(api *API, ctx context.Context, rc *ResourceContainer) (
}

if !response.Success {
return TieredCache{Type: TieredCacheOff}, errors.New("Request to retrieve smart tiered cache failed")
return TieredCache{Type: TieredCacheOff}, errors.New("request to retrieve smart tiered cache failed")
}

if response.Result.Value == "off" {
Expand Down Expand Up @@ -220,7 +217,7 @@ func enableGenericTieredCache(api *API, ctx context.Context, rc *ResourceContain
}

if !response.Success {
return TieredCache{Type: TieredCacheOff}, errors.New("Request to enable generic tiered cache failed")
return TieredCache{Type: TieredCacheOff}, errors.New("request to enable generic tiered cache failed")
}

return TieredCache{Type: TieredCacheGeneric, LastModified: response.Result.LastModified}, nil
Expand Down Expand Up @@ -248,7 +245,7 @@ func enableSmartTieredCache(api *API, ctx context.Context, rc *ResourceContainer
}

if !response.Success {
return TieredCache{Type: TieredCacheOff}, errors.New("Request to enable smart tiered cache failed")
return TieredCache{Type: TieredCacheOff}, errors.New("request to enable smart tiered cache failed")
}

return TieredCache{Type: TieredCacheSmart, LastModified: response.Result.LastModified}, nil
Expand Down Expand Up @@ -276,7 +273,7 @@ func disableGenericTieredCache(api *API, ctx context.Context, rc *ResourceContai
}

if !response.Success {
return TieredCache{Type: TieredCacheOff}, errors.New("Request to disable generic tiered cache failed")
return TieredCache{Type: TieredCacheOff}, errors.New("request to disable generic tiered cache failed")
}

return TieredCache{Type: TieredCacheOff, LastModified: response.Result.LastModified}, nil
Expand All @@ -299,7 +296,7 @@ func deleteSmartTieredCache(api *API, ctx context.Context, rc *ResourceContainer
}

if !response.Success {
return TieredCache{Type: TieredCacheOff}, errors.New("Request to disable smart tiered cache failed")
return TieredCache{Type: TieredCacheOff}, errors.New("request to disable smart tiered cache failed")
}

return TieredCache{Type: TieredCacheOff, LastModified: response.Result.LastModified}, nil
Expand Down

0 comments on commit 438ff78

Please sign in to comment.