cloudflare/cloudflare-typescript
Publicmirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable
src/resources/cache/smart-tiered-cache.ts
262lines · modecode
| 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | |
| 3 | import { APIResource } from '../../core/resource'; |
| 4 | import { APIPromise } from '../../core/api-promise'; |
| 5 | import { RequestOptions } from '../../internal/request-options'; |
| 6 | import { path } from '../../internal/utils/path'; |
| 7 | |
| 8 | export class BaseSmartTieredCache extends APIResource { |
| 9 | static override readonly _key: readonly ['cache', 'smartTieredCache'] = Object.freeze([ |
| 10 | 'cache', |
| 11 | 'smartTieredCache', |
| 12 | ] as const); |
| 13 | |
| 14 | /** |
| 15 | * Smart Tiered Cache dynamically selects the single closest upper tier for each of |
| 16 | * your website's origins with no configuration required, using our in-house |
| 17 | * performance and routing data. Cloudflare collects latency data for each request |
| 18 | * to an origin, and uses the latency data to determine how well any upper-tier |
| 19 | * data center is connected with an origin. As a result, Cloudflare can select the |
| 20 | * data center with the lowest latency to be the upper-tier for an origin. |
| 21 | * |
| 22 | * @example |
| 23 | * ```ts |
| 24 | * const smartTieredCache = |
| 25 | * await client.cache.smartTieredCache.create({ |
| 26 | * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 27 | * value: 'on', |
| 28 | * }); |
| 29 | * ``` |
| 30 | */ |
| 31 | create( |
| 32 | params: SmartTieredCacheCreateParams, |
| 33 | options?: RequestOptions, |
| 34 | ): APIPromise<SmartTieredCacheCreateResponse> { |
| 35 | const { zone_id, ...body } = params; |
| 36 | return ( |
| 37 | this._client.post(path`/zones/${zone_id}/cache/tiered_cache_smart_topology_enable`, { |
| 38 | body, |
| 39 | ...options, |
| 40 | }) as APIPromise<{ result: SmartTieredCacheCreateResponse }> |
| 41 | )._thenUnwrap((obj) => obj.result); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Smart Tiered Cache dynamically selects the single closest upper tier for each of |
| 46 | * your website’s origins with no configuration required, using our in-house |
| 47 | * performance and routing data. Cloudflare collects latency data for each request |
| 48 | * to an origin, and uses the latency data to determine how well any upper-tier |
| 49 | * data center is connected with an origin. As a result, Cloudflare can select the |
| 50 | * data center with the lowest latency to be the upper-tier for an origin. |
| 51 | * |
| 52 | * @example |
| 53 | * ```ts |
| 54 | * const smartTieredCache = |
| 55 | * await client.cache.smartTieredCache.delete({ |
| 56 | * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 57 | * }); |
| 58 | * ``` |
| 59 | */ |
| 60 | delete( |
| 61 | params: SmartTieredCacheDeleteParams, |
| 62 | options?: RequestOptions, |
| 63 | ): APIPromise<SmartTieredCacheDeleteResponse> { |
| 64 | const { zone_id } = params; |
| 65 | return ( |
| 66 | this._client.delete( |
| 67 | path`/zones/${zone_id}/cache/tiered_cache_smart_topology_enable`, |
| 68 | options, |
| 69 | ) as APIPromise<{ result: SmartTieredCacheDeleteResponse }> |
| 70 | )._thenUnwrap((obj) => obj.result); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Smart Tiered Cache dynamically selects the single closest upper tier for each of |
| 75 | * your website’s origins with no configuration required, using our in-house |
| 76 | * performance and routing data. Cloudflare collects latency data for each request |
| 77 | * to an origin, and uses the latency data to determine how well any upper-tier |
| 78 | * data center is connected with an origin. As a result, Cloudflare can select the |
| 79 | * data center with the lowest latency to be the upper-tier for an origin. |
| 80 | * |
| 81 | * @example |
| 82 | * ```ts |
| 83 | * const response = await client.cache.smartTieredCache.edit({ |
| 84 | * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 85 | * value: 'on', |
| 86 | * }); |
| 87 | * ``` |
| 88 | */ |
| 89 | edit( |
| 90 | params: SmartTieredCacheEditParams, |
| 91 | options?: RequestOptions, |
| 92 | ): APIPromise<SmartTieredCacheEditResponse> { |
| 93 | const { zone_id, ...body } = params; |
| 94 | return ( |
| 95 | this._client.patch(path`/zones/${zone_id}/cache/tiered_cache_smart_topology_enable`, { |
| 96 | body, |
| 97 | ...options, |
| 98 | }) as APIPromise<{ result: SmartTieredCacheEditResponse }> |
| 99 | )._thenUnwrap((obj) => obj.result); |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Smart Tiered Cache dynamically selects the single closest upper tier for each of |
| 104 | * your website’s origins with no configuration required, using our in-house |
| 105 | * performance and routing data. Cloudflare collects latency data for each request |
| 106 | * to an origin, and uses the latency data to determine how well any upper-tier |
| 107 | * data center is connected with an origin. As a result, Cloudflare can select the |
| 108 | * data center with the lowest latency to be the upper-tier for an origin. |
| 109 | * |
| 110 | * @example |
| 111 | * ```ts |
| 112 | * const smartTieredCache = |
| 113 | * await client.cache.smartTieredCache.get({ |
| 114 | * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 115 | * }); |
| 116 | * ``` |
| 117 | */ |
| 118 | get(params: SmartTieredCacheGetParams, options?: RequestOptions): APIPromise<SmartTieredCacheGetResponse> { |
| 119 | const { zone_id } = params; |
| 120 | return ( |
| 121 | this._client.get( |
| 122 | path`/zones/${zone_id}/cache/tiered_cache_smart_topology_enable`, |
| 123 | options, |
| 124 | ) as APIPromise<{ result: SmartTieredCacheGetResponse }> |
| 125 | )._thenUnwrap((obj) => obj.result); |
| 126 | } |
| 127 | } |
| 128 | export class SmartTieredCache extends BaseSmartTieredCache {} |
| 129 | |
| 130 | export interface SmartTieredCacheCreateResponse { |
| 131 | /** |
| 132 | * The identifier of the caching setting. |
| 133 | */ |
| 134 | id: 'tiered_cache_smart_topology_enable'; |
| 135 | |
| 136 | /** |
| 137 | * Whether the setting is editable. |
| 138 | */ |
| 139 | editable: boolean; |
| 140 | |
| 141 | /** |
| 142 | * Value of the Smart Tiered Cache zone setting. |
| 143 | */ |
| 144 | value: 'on' | 'off'; |
| 145 | |
| 146 | /** |
| 147 | * Last time this setting was modified. |
| 148 | */ |
| 149 | modified_on?: string | null; |
| 150 | } |
| 151 | |
| 152 | export interface SmartTieredCacheDeleteResponse { |
| 153 | /** |
| 154 | * The identifier of the caching setting. |
| 155 | */ |
| 156 | id: 'tiered_cache_smart_topology_enable'; |
| 157 | |
| 158 | /** |
| 159 | * Whether the setting is editable. |
| 160 | */ |
| 161 | editable: boolean; |
| 162 | |
| 163 | /** |
| 164 | * Last time this setting was modified. |
| 165 | */ |
| 166 | modified_on?: string | null; |
| 167 | } |
| 168 | |
| 169 | export interface SmartTieredCacheEditResponse { |
| 170 | /** |
| 171 | * The identifier of the caching setting. |
| 172 | */ |
| 173 | id: 'tiered_cache_smart_topology_enable'; |
| 174 | |
| 175 | /** |
| 176 | * Whether the setting is editable. |
| 177 | */ |
| 178 | editable: boolean; |
| 179 | |
| 180 | /** |
| 181 | * Value of the Smart Tiered Cache zone setting. |
| 182 | */ |
| 183 | value: 'on' | 'off'; |
| 184 | |
| 185 | /** |
| 186 | * Last time this setting was modified. |
| 187 | */ |
| 188 | modified_on?: string | null; |
| 189 | } |
| 190 | |
| 191 | export interface SmartTieredCacheGetResponse { |
| 192 | /** |
| 193 | * The identifier of the caching setting. |
| 194 | */ |
| 195 | id: 'tiered_cache_smart_topology_enable'; |
| 196 | |
| 197 | /** |
| 198 | * Whether the setting is editable. |
| 199 | */ |
| 200 | editable: boolean; |
| 201 | |
| 202 | /** |
| 203 | * Value of the Smart Tiered Cache zone setting. |
| 204 | */ |
| 205 | value: 'on' | 'off'; |
| 206 | |
| 207 | /** |
| 208 | * Last time this setting was modified. |
| 209 | */ |
| 210 | modified_on?: string | null; |
| 211 | } |
| 212 | |
| 213 | export interface SmartTieredCacheCreateParams { |
| 214 | /** |
| 215 | * Path param: Identifier. |
| 216 | */ |
| 217 | zone_id: string; |
| 218 | |
| 219 | /** |
| 220 | * Body param: Enable or disable the Smart Tiered Cache. |
| 221 | */ |
| 222 | value: 'on' | 'off'; |
| 223 | } |
| 224 | |
| 225 | export interface SmartTieredCacheDeleteParams { |
| 226 | /** |
| 227 | * Identifier. |
| 228 | */ |
| 229 | zone_id: string; |
| 230 | } |
| 231 | |
| 232 | export interface SmartTieredCacheEditParams { |
| 233 | /** |
| 234 | * Path param: Identifier. |
| 235 | */ |
| 236 | zone_id: string; |
| 237 | |
| 238 | /** |
| 239 | * Body param: Enable or disable the Smart Tiered Cache. |
| 240 | */ |
| 241 | value: 'on' | 'off'; |
| 242 | } |
| 243 | |
| 244 | export interface SmartTieredCacheGetParams { |
| 245 | /** |
| 246 | * Identifier. |
| 247 | */ |
| 248 | zone_id: string; |
| 249 | } |
| 250 | |
| 251 | export declare namespace SmartTieredCache { |
| 252 | export { |
| 253 | type SmartTieredCacheCreateResponse as SmartTieredCacheCreateResponse, |
| 254 | type SmartTieredCacheDeleteResponse as SmartTieredCacheDeleteResponse, |
| 255 | type SmartTieredCacheEditResponse as SmartTieredCacheEditResponse, |
| 256 | type SmartTieredCacheGetResponse as SmartTieredCacheGetResponse, |
| 257 | type SmartTieredCacheCreateParams as SmartTieredCacheCreateParams, |
| 258 | type SmartTieredCacheDeleteParams as SmartTieredCacheDeleteParams, |
| 259 | type SmartTieredCacheEditParams as SmartTieredCacheEditParams, |
| 260 | type SmartTieredCacheGetParams as SmartTieredCacheGetParams, |
| 261 | }; |
| 262 | } |
| 263 | |