cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v4.2.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/resources/cache/variants.ts

245lines · 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 delete(params: VariantDeleteParams, options?: Core.RequestOptions): Core.APIPromise<VariantDeleteResponse> {
15 const { zone_id } = params;
16 return (
17 this._client.delete(`/zones/${zone_id}/cache/variants`, options) as Core.APIPromise<{
18 result: VariantDeleteResponse;
19 }>
20 )._thenUnwrap((obj) => obj.result);
21 }
22
23 /**
24 * Variant support enables caching variants of images with certain file extensions
25 * in addition to the original. This only applies when the origin server sends the
26 * 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but
27 * does not serve the variant requested, the response will not be cached. This will
28 * be indicated with BYPASS cache status in the response headers.
29 */
30 edit(params: VariantEditParams, options?: Core.RequestOptions): Core.APIPromise<VariantEditResponse> {
31 const { zone_id, ...body } = params;
32 return (
33 this._client.patch(`/zones/${zone_id}/cache/variants`, { body, ...options }) as Core.APIPromise<{
34 result: VariantEditResponse;
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 get(params: VariantGetParams, options?: Core.RequestOptions): Core.APIPromise<VariantGetResponse> {
47 const { zone_id } = params;
48 return (
49 this._client.get(`/zones/${zone_id}/cache/variants`, options) as Core.APIPromise<{
50 result: VariantGetResponse;
51 }>
52 )._thenUnwrap((obj) => obj.result);
53 }
54}
55
56/**
57 * Variant support enables caching variants of images with certain file extensions
58 * in addition to the original. This only applies when the origin server sends the
59 * 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but
60 * does not serve the variant requested, the response will not be cached. This will
61 * be indicated with BYPASS cache status in the response headers.
62 */
63export interface CacheVariant {
64 /**
65 * ID of the zone setting.
66 */
67 id: 'variants';
68
69 /**
70 * Last time this setting was modified.
71 */
72 modified_on?: string | null;
73}
74
75export interface VariantDeleteResponse {
76 /**
77 * ID of the zone setting.
78 */
79 id: 'variants';
80
81 /**
82 * Whether the setting is editable
83 */
84 editable: boolean;
85
86 /**
87 * Last time this setting was modified.
88 */
89 modified_on?: string | null;
90}
91
92export interface VariantEditResponse {
93 /**
94 * ID of the zone setting.
95 */
96 id: 'variants';
97
98 /**
99 * Whether the setting is editable
100 */
101 editable: boolean;
102
103 /**
104 * The value of the feature
105 */
106 value: string;
107
108 /**
109 * Last time this setting was modified.
110 */
111 modified_on?: string | null;
112}
113
114export interface VariantGetResponse {
115 /**
116 * ID of the zone setting.
117 */
118 id: 'variants';
119
120 /**
121 * Whether the setting is editable
122 */
123 editable: boolean;
124
125 /**
126 * The value of the feature
127 */
128 value: string;
129
130 /**
131 * Last time this setting was modified.
132 */
133 modified_on?: string | null;
134}
135
136export interface VariantDeleteParams {
137 /**
138 * Identifier
139 */
140 zone_id: string;
141}
142
143export interface VariantEditParams {
144 /**
145 * Path param: Identifier
146 */
147 zone_id: string;
148
149 /**
150 * Body param: Value of the zone setting.
151 */
152 value: VariantEditParams.Value;
153}
154
155export namespace VariantEditParams {
156 /**
157 * Value of the zone setting.
158 */
159 export interface Value {
160 /**
161 * List of strings with the MIME types of all the variants that should be served
162 * for avif.
163 */
164 avif?: Array<string>;
165
166 /**
167 * List of strings with the MIME types of all the variants that should be served
168 * for bmp.
169 */
170 bmp?: Array<string>;
171
172 /**
173 * List of strings with the MIME types of all the variants that should be served
174 * for gif.
175 */
176 gif?: Array<string>;
177
178 /**
179 * List of strings with the MIME types of all the variants that should be served
180 * for jp2.
181 */
182 jp2?: Array<string>;
183
184 /**
185 * List of strings with the MIME types of all the variants that should be served
186 * for jpeg.
187 */
188 jpeg?: Array<string>;
189
190 /**
191 * List of strings with the MIME types of all the variants that should be served
192 * for jpg.
193 */
194 jpg?: Array<string>;
195
196 /**
197 * List of strings with the MIME types of all the variants that should be served
198 * for jpg2.
199 */
200 jpg2?: Array<string>;
201
202 /**
203 * List of strings with the MIME types of all the variants that should be served
204 * for png.
205 */
206 png?: Array<string>;
207
208 /**
209 * List of strings with the MIME types of all the variants that should be served
210 * for tif.
211 */
212 tif?: Array<string>;
213
214 /**
215 * List of strings with the MIME types of all the variants that should be served
216 * for tiff.
217 */
218 tiff?: Array<string>;
219
220 /**
221 * List of strings with the MIME types of all the variants that should be served
222 * for webp.
223 */
224 webp?: Array<string>;
225 }
226}
227
228export interface VariantGetParams {
229 /**
230 * Identifier
231 */
232 zone_id: string;
233}
234
235export declare namespace Variants {
236 export {
237 type CacheVariant as CacheVariant,
238 type VariantDeleteResponse as VariantDeleteResponse,
239 type VariantEditResponse as VariantEditResponse,
240 type VariantGetResponse as VariantGetResponse,
241 type VariantDeleteParams as VariantDeleteParams,
242 type VariantEditParams as VariantEditParams,
243 type VariantGetParams as VariantGetParams,
244 };
245}
246