cloudflare/cloudflare-typescript
Publicmirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable
src/resources/cache/variants.ts
376lines · modecode
| 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | |
| 3 | import * as Core from 'cloudflare/core'; |
| 4 | import { APIResource } from 'cloudflare/resource'; |
| 5 | import * as VariantsAPI from 'cloudflare/resources/cache/variants'; |
| 6 | |
| 7 | export class Variants extends APIResource { |
| 8 | /** |
| 9 | * Variant support enables caching variants of images with certain file extensions |
| 10 | * in addition to the original. This only applies when the origin server sends the |
| 11 | * 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but |
| 12 | * does not serve the variant requested, the response will not be cached. This will |
| 13 | * be indicated with BYPASS cache status in the response headers. |
| 14 | */ |
| 15 | delete(params: VariantDeleteParams, options?: Core.RequestOptions): Core.APIPromise<CacheVariants> { |
| 16 | const { zone_id } = params; |
| 17 | return ( |
| 18 | this._client.delete(`/zones/${zone_id}/cache/variants`, options) as Core.APIPromise<{ |
| 19 | result: CacheVariants; |
| 20 | }> |
| 21 | )._thenUnwrap((obj) => obj.result); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Variant support enables caching variants of images with certain file extensions |
| 26 | * in addition to the original. This only applies when the origin server sends the |
| 27 | * 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but |
| 28 | * does not serve the variant requested, the response will not be cached. This will |
| 29 | * be indicated with BYPASS cache status in the response headers. |
| 30 | */ |
| 31 | edit(params: VariantEditParams, options?: Core.RequestOptions): Core.APIPromise<VariantEditResponse> { |
| 32 | const { zone_id, ...body } = params; |
| 33 | return ( |
| 34 | this._client.patch(`/zones/${zone_id}/cache/variants`, { body, ...options }) as Core.APIPromise<{ |
| 35 | result: VariantEditResponse; |
| 36 | }> |
| 37 | )._thenUnwrap((obj) => obj.result); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Variant support enables caching variants of images with certain file extensions |
| 42 | * in addition to the original. This only applies when the origin server sends the |
| 43 | * 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but |
| 44 | * does not serve the variant requested, the response will not be cached. This will |
| 45 | * be indicated with BYPASS cache status in the response headers. |
| 46 | */ |
| 47 | get(params: VariantGetParams, options?: Core.RequestOptions): Core.APIPromise<VariantGetResponse> { |
| 48 | const { zone_id } = params; |
| 49 | return ( |
| 50 | this._client.get(`/zones/${zone_id}/cache/variants`, options) as Core.APIPromise<{ |
| 51 | result: VariantGetResponse; |
| 52 | }> |
| 53 | )._thenUnwrap((obj) => obj.result); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Variant support enables caching variants of images with certain file extensions |
| 59 | * in addition to the original. This only applies when the origin server sends the |
| 60 | * 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but |
| 61 | * does not serve the variant requested, the response will not be cached. This will |
| 62 | * be indicated with BYPASS cache status in the response headers. |
| 63 | */ |
| 64 | export interface CacheVariants { |
| 65 | /** |
| 66 | * ID of the zone setting. |
| 67 | */ |
| 68 | id: 'variants'; |
| 69 | |
| 70 | /** |
| 71 | * last time this setting was modified. |
| 72 | */ |
| 73 | modified_on: string | null; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Variant support enables caching variants of images with certain file extensions |
| 78 | * in addition to the original. This only applies when the origin server sends the |
| 79 | * 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but |
| 80 | * does not serve the variant requested, the response will not be cached. This will |
| 81 | * be indicated with BYPASS cache status in the response headers. |
| 82 | */ |
| 83 | export interface VariantEditResponse { |
| 84 | /** |
| 85 | * ID of the zone setting. |
| 86 | */ |
| 87 | id: 'variants'; |
| 88 | |
| 89 | /** |
| 90 | * last time this setting was modified. |
| 91 | */ |
| 92 | modified_on: string | null; |
| 93 | |
| 94 | /** |
| 95 | * Value of the zone setting. |
| 96 | */ |
| 97 | value: VariantEditResponse.Value; |
| 98 | } |
| 99 | |
| 100 | export namespace VariantEditResponse { |
| 101 | /** |
| 102 | * Value of the zone setting. |
| 103 | */ |
| 104 | export interface Value { |
| 105 | /** |
| 106 | * List of strings with the MIME types of all the variants that should be served |
| 107 | * for avif. |
| 108 | */ |
| 109 | avif?: Array<unknown>; |
| 110 | |
| 111 | /** |
| 112 | * List of strings with the MIME types of all the variants that should be served |
| 113 | * for bmp. |
| 114 | */ |
| 115 | bmp?: Array<unknown>; |
| 116 | |
| 117 | /** |
| 118 | * List of strings with the MIME types of all the variants that should be served |
| 119 | * for gif. |
| 120 | */ |
| 121 | gif?: Array<unknown>; |
| 122 | |
| 123 | /** |
| 124 | * List of strings with the MIME types of all the variants that should be served |
| 125 | * for jp2. |
| 126 | */ |
| 127 | jp2?: Array<unknown>; |
| 128 | |
| 129 | /** |
| 130 | * List of strings with the MIME types of all the variants that should be served |
| 131 | * for jpeg. |
| 132 | */ |
| 133 | jpeg?: Array<unknown>; |
| 134 | |
| 135 | /** |
| 136 | * List of strings with the MIME types of all the variants that should be served |
| 137 | * for jpg. |
| 138 | */ |
| 139 | jpg?: Array<unknown>; |
| 140 | |
| 141 | /** |
| 142 | * List of strings with the MIME types of all the variants that should be served |
| 143 | * for jpg2. |
| 144 | */ |
| 145 | jpg2?: Array<unknown>; |
| 146 | |
| 147 | /** |
| 148 | * List of strings with the MIME types of all the variants that should be served |
| 149 | * for png. |
| 150 | */ |
| 151 | png?: Array<unknown>; |
| 152 | |
| 153 | /** |
| 154 | * List of strings with the MIME types of all the variants that should be served |
| 155 | * for tif. |
| 156 | */ |
| 157 | tif?: Array<unknown>; |
| 158 | |
| 159 | /** |
| 160 | * List of strings with the MIME types of all the variants that should be served |
| 161 | * for tiff. |
| 162 | */ |
| 163 | tiff?: Array<unknown>; |
| 164 | |
| 165 | /** |
| 166 | * List of strings with the MIME types of all the variants that should be served |
| 167 | * for webp. |
| 168 | */ |
| 169 | webp?: Array<unknown>; |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * Variant support enables caching variants of images with certain file extensions |
| 175 | * in addition to the original. This only applies when the origin server sends the |
| 176 | * 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but |
| 177 | * does not serve the variant requested, the response will not be cached. This will |
| 178 | * be indicated with BYPASS cache status in the response headers. |
| 179 | */ |
| 180 | export interface VariantGetResponse { |
| 181 | /** |
| 182 | * ID of the zone setting. |
| 183 | */ |
| 184 | id: 'variants'; |
| 185 | |
| 186 | /** |
| 187 | * last time this setting was modified. |
| 188 | */ |
| 189 | modified_on: string | null; |
| 190 | |
| 191 | /** |
| 192 | * Value of the zone setting. |
| 193 | */ |
| 194 | value: VariantGetResponse.Value; |
| 195 | } |
| 196 | |
| 197 | export namespace VariantGetResponse { |
| 198 | /** |
| 199 | * Value of the zone setting. |
| 200 | */ |
| 201 | export interface Value { |
| 202 | /** |
| 203 | * List of strings with the MIME types of all the variants that should be served |
| 204 | * for avif. |
| 205 | */ |
| 206 | avif?: Array<unknown>; |
| 207 | |
| 208 | /** |
| 209 | * List of strings with the MIME types of all the variants that should be served |
| 210 | * for bmp. |
| 211 | */ |
| 212 | bmp?: Array<unknown>; |
| 213 | |
| 214 | /** |
| 215 | * List of strings with the MIME types of all the variants that should be served |
| 216 | * for gif. |
| 217 | */ |
| 218 | gif?: Array<unknown>; |
| 219 | |
| 220 | /** |
| 221 | * List of strings with the MIME types of all the variants that should be served |
| 222 | * for jp2. |
| 223 | */ |
| 224 | jp2?: Array<unknown>; |
| 225 | |
| 226 | /** |
| 227 | * List of strings with the MIME types of all the variants that should be served |
| 228 | * for jpeg. |
| 229 | */ |
| 230 | jpeg?: Array<unknown>; |
| 231 | |
| 232 | /** |
| 233 | * List of strings with the MIME types of all the variants that should be served |
| 234 | * for jpg. |
| 235 | */ |
| 236 | jpg?: Array<unknown>; |
| 237 | |
| 238 | /** |
| 239 | * List of strings with the MIME types of all the variants that should be served |
| 240 | * for jpg2. |
| 241 | */ |
| 242 | jpg2?: Array<unknown>; |
| 243 | |
| 244 | /** |
| 245 | * List of strings with the MIME types of all the variants that should be served |
| 246 | * for png. |
| 247 | */ |
| 248 | png?: Array<unknown>; |
| 249 | |
| 250 | /** |
| 251 | * List of strings with the MIME types of all the variants that should be served |
| 252 | * for tif. |
| 253 | */ |
| 254 | tif?: Array<unknown>; |
| 255 | |
| 256 | /** |
| 257 | * List of strings with the MIME types of all the variants that should be served |
| 258 | * for tiff. |
| 259 | */ |
| 260 | tiff?: Array<unknown>; |
| 261 | |
| 262 | /** |
| 263 | * List of strings with the MIME types of all the variants that should be served |
| 264 | * for webp. |
| 265 | */ |
| 266 | webp?: Array<unknown>; |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | export interface VariantDeleteParams { |
| 271 | /** |
| 272 | * Identifier |
| 273 | */ |
| 274 | zone_id: string; |
| 275 | } |
| 276 | |
| 277 | export interface VariantEditParams { |
| 278 | /** |
| 279 | * Path param: Identifier |
| 280 | */ |
| 281 | zone_id: string; |
| 282 | |
| 283 | /** |
| 284 | * Body param: Value of the zone setting. |
| 285 | */ |
| 286 | value: VariantEditParams.Value; |
| 287 | } |
| 288 | |
| 289 | export namespace VariantEditParams { |
| 290 | /** |
| 291 | * Value of the zone setting. |
| 292 | */ |
| 293 | export interface Value { |
| 294 | /** |
| 295 | * List of strings with the MIME types of all the variants that should be served |
| 296 | * for avif. |
| 297 | */ |
| 298 | avif?: Array<unknown>; |
| 299 | |
| 300 | /** |
| 301 | * List of strings with the MIME types of all the variants that should be served |
| 302 | * for bmp. |
| 303 | */ |
| 304 | bmp?: Array<unknown>; |
| 305 | |
| 306 | /** |
| 307 | * List of strings with the MIME types of all the variants that should be served |
| 308 | * for gif. |
| 309 | */ |
| 310 | gif?: Array<unknown>; |
| 311 | |
| 312 | /** |
| 313 | * List of strings with the MIME types of all the variants that should be served |
| 314 | * for jp2. |
| 315 | */ |
| 316 | jp2?: Array<unknown>; |
| 317 | |
| 318 | /** |
| 319 | * List of strings with the MIME types of all the variants that should be served |
| 320 | * for jpeg. |
| 321 | */ |
| 322 | jpeg?: Array<unknown>; |
| 323 | |
| 324 | /** |
| 325 | * List of strings with the MIME types of all the variants that should be served |
| 326 | * for jpg. |
| 327 | */ |
| 328 | jpg?: Array<unknown>; |
| 329 | |
| 330 | /** |
| 331 | * List of strings with the MIME types of all the variants that should be served |
| 332 | * for jpg2. |
| 333 | */ |
| 334 | jpg2?: Array<unknown>; |
| 335 | |
| 336 | /** |
| 337 | * List of strings with the MIME types of all the variants that should be served |
| 338 | * for png. |
| 339 | */ |
| 340 | png?: Array<unknown>; |
| 341 | |
| 342 | /** |
| 343 | * List of strings with the MIME types of all the variants that should be served |
| 344 | * for tif. |
| 345 | */ |
| 346 | tif?: Array<unknown>; |
| 347 | |
| 348 | /** |
| 349 | * List of strings with the MIME types of all the variants that should be served |
| 350 | * for tiff. |
| 351 | */ |
| 352 | tiff?: Array<unknown>; |
| 353 | |
| 354 | /** |
| 355 | * List of strings with the MIME types of all the variants that should be served |
| 356 | * for webp. |
| 357 | */ |
| 358 | webp?: Array<unknown>; |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | export interface VariantGetParams { |
| 363 | /** |
| 364 | * Identifier |
| 365 | */ |
| 366 | zone_id: string; |
| 367 | } |
| 368 | |
| 369 | export namespace Variants { |
| 370 | export import CacheVariants = VariantsAPI.CacheVariants; |
| 371 | export import VariantEditResponse = VariantsAPI.VariantEditResponse; |
| 372 | export import VariantGetResponse = VariantsAPI.VariantGetResponse; |
| 373 | export import VariantDeleteParams = VariantsAPI.VariantDeleteParams; |
| 374 | export import VariantEditParams = VariantsAPI.VariantEditParams; |
| 375 | export import VariantGetParams = VariantsAPI.VariantGetParams; |
| 376 | } |
| 377 | |