// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; import { APIPromise } from '../../core/api-promise'; import { RequestOptions } from '../../internal/request-options'; import { path } from '../../internal/utils/path'; export class BaseSmartTieredCache extends APIResource { static override readonly _key: readonly ['cache', 'smartTieredCache'] = Object.freeze([ 'cache', 'smartTieredCache', ] as const); /** * Smart Tiered Cache dynamically selects the single closest upper tier for each of * your website's origins with no configuration required, using our in-house * performance and routing data. Cloudflare collects latency data for each request * to an origin, and uses the latency data to determine how well any upper-tier * data center is connected with an origin. As a result, Cloudflare can select the * data center with the lowest latency to be the upper-tier for an origin. * * @example * ```ts * const smartTieredCache = * await client.cache.smartTieredCache.create({ * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * value: 'on', * }); * ``` */ create( params: SmartTieredCacheCreateParams, options?: RequestOptions, ): APIPromise { const { zone_id, ...body } = params; return ( this._client.post(path`/zones/${zone_id}/cache/tiered_cache_smart_topology_enable`, { body, ...options, }) as APIPromise<{ result: SmartTieredCacheCreateResponse }> )._thenUnwrap((obj) => obj.result); } /** * Smart Tiered Cache dynamically selects the single closest upper tier for each of * your website’s origins with no configuration required, using our in-house * performance and routing data. Cloudflare collects latency data for each request * to an origin, and uses the latency data to determine how well any upper-tier * data center is connected with an origin. As a result, Cloudflare can select the * data center with the lowest latency to be the upper-tier for an origin. * * @example * ```ts * const smartTieredCache = * await client.cache.smartTieredCache.delete({ * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * }); * ``` */ delete( params: SmartTieredCacheDeleteParams, options?: RequestOptions, ): APIPromise { const { zone_id } = params; return ( this._client.delete( path`/zones/${zone_id}/cache/tiered_cache_smart_topology_enable`, options, ) as APIPromise<{ result: SmartTieredCacheDeleteResponse }> )._thenUnwrap((obj) => obj.result); } /** * Smart Tiered Cache dynamically selects the single closest upper tier for each of * your website’s origins with no configuration required, using our in-house * performance and routing data. Cloudflare collects latency data for each request * to an origin, and uses the latency data to determine how well any upper-tier * data center is connected with an origin. As a result, Cloudflare can select the * data center with the lowest latency to be the upper-tier for an origin. * * @example * ```ts * const response = await client.cache.smartTieredCache.edit({ * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * value: 'on', * }); * ``` */ edit( params: SmartTieredCacheEditParams, options?: RequestOptions, ): APIPromise { const { zone_id, ...body } = params; return ( this._client.patch(path`/zones/${zone_id}/cache/tiered_cache_smart_topology_enable`, { body, ...options, }) as APIPromise<{ result: SmartTieredCacheEditResponse }> )._thenUnwrap((obj) => obj.result); } /** * Smart Tiered Cache dynamically selects the single closest upper tier for each of * your website’s origins with no configuration required, using our in-house * performance and routing data. Cloudflare collects latency data for each request * to an origin, and uses the latency data to determine how well any upper-tier * data center is connected with an origin. As a result, Cloudflare can select the * data center with the lowest latency to be the upper-tier for an origin. * * @example * ```ts * const smartTieredCache = * await client.cache.smartTieredCache.get({ * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * }); * ``` */ get(params: SmartTieredCacheGetParams, options?: RequestOptions): APIPromise { const { zone_id } = params; return ( this._client.get( path`/zones/${zone_id}/cache/tiered_cache_smart_topology_enable`, options, ) as APIPromise<{ result: SmartTieredCacheGetResponse }> )._thenUnwrap((obj) => obj.result); } } export class SmartTieredCache extends BaseSmartTieredCache {} export interface SmartTieredCacheCreateResponse { /** * The identifier of the caching setting. */ id: 'tiered_cache_smart_topology_enable'; /** * Whether the setting is editable. */ editable: boolean; /** * Value of the Smart Tiered Cache zone setting. */ value: 'on' | 'off'; /** * Last time this setting was modified. */ modified_on?: string | null; } export interface SmartTieredCacheDeleteResponse { /** * The identifier of the caching setting. */ id: 'tiered_cache_smart_topology_enable'; /** * Whether the setting is editable. */ editable: boolean; /** * Last time this setting was modified. */ modified_on?: string | null; } export interface SmartTieredCacheEditResponse { /** * The identifier of the caching setting. */ id: 'tiered_cache_smart_topology_enable'; /** * Whether the setting is editable. */ editable: boolean; /** * Value of the Smart Tiered Cache zone setting. */ value: 'on' | 'off'; /** * Last time this setting was modified. */ modified_on?: string | null; } export interface SmartTieredCacheGetResponse { /** * The identifier of the caching setting. */ id: 'tiered_cache_smart_topology_enable'; /** * Whether the setting is editable. */ editable: boolean; /** * Value of the Smart Tiered Cache zone setting. */ value: 'on' | 'off'; /** * Last time this setting was modified. */ modified_on?: string | null; } export interface SmartTieredCacheCreateParams { /** * Path param: Identifier. */ zone_id: string; /** * Body param: Enable or disable the Smart Tiered Cache. */ value: 'on' | 'off'; } export interface SmartTieredCacheDeleteParams { /** * Identifier. */ zone_id: string; } export interface SmartTieredCacheEditParams { /** * Path param: Identifier. */ zone_id: string; /** * Body param: Enable or disable the Smart Tiered Cache. */ value: 'on' | 'off'; } export interface SmartTieredCacheGetParams { /** * Identifier. */ zone_id: string; } export declare namespace SmartTieredCache { export { type SmartTieredCacheCreateResponse as SmartTieredCacheCreateResponse, type SmartTieredCacheDeleteResponse as SmartTieredCacheDeleteResponse, type SmartTieredCacheEditResponse as SmartTieredCacheEditResponse, type SmartTieredCacheGetResponse as SmartTieredCacheGetResponse, type SmartTieredCacheCreateParams as SmartTieredCacheCreateParams, type SmartTieredCacheDeleteParams as SmartTieredCacheDeleteParams, type SmartTieredCacheEditParams as SmartTieredCacheEditParams, type SmartTieredCacheGetParams as SmartTieredCacheGetParams, }; }