cloudflare/cloudflare-typescript

Public

mirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v7

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/resources/cache/variants.ts

421lines · modecode

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