cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v6.3.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/resources/cache/variants.ts

413lines · modecode

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