cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v6.0.0-beta.2

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/resources/cache/variants.ts

430lines · modecode

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