cloudflare/cloudflare-typescript
Publicmirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable
src/resources/cache/variants.ts
267lines · modecode
| 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | |
| 3 | import { APIResource } from '../../resource'; |
| 4 | import * as Core from '../../core'; |
| 5 | |
| 6 | export 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 | */ |
| 85 | export 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 | |
| 97 | export interface VariantDeleteResponse { |
| 98 | /** |
| 99 | * ID of the zone 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 | |
| 114 | export interface VariantEditResponse { |
| 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 | |
| 136 | export interface VariantGetResponse { |
| 137 | /** |
| 138 | * ID of the zone setting. |
| 139 | */ |
| 140 | id: 'variants'; |
| 141 | |
| 142 | /** |
| 143 | * Whether the setting is editable |
| 144 | */ |
| 145 | editable: boolean; |
| 146 | |
| 147 | /** |
| 148 | * The value of the feature |
| 149 | */ |
| 150 | value: string; |
| 151 | |
| 152 | /** |
| 153 | * Last time this setting was modified. |
| 154 | */ |
| 155 | modified_on?: string | null; |
| 156 | } |
| 157 | |
| 158 | export interface VariantDeleteParams { |
| 159 | /** |
| 160 | * Identifier |
| 161 | */ |
| 162 | zone_id: string; |
| 163 | } |
| 164 | |
| 165 | export interface VariantEditParams { |
| 166 | /** |
| 167 | * Path param: Identifier |
| 168 | */ |
| 169 | zone_id: string; |
| 170 | |
| 171 | /** |
| 172 | * Body param: Value of the zone setting. |
| 173 | */ |
| 174 | value: VariantEditParams.Value; |
| 175 | } |
| 176 | |
| 177 | export namespace VariantEditParams { |
| 178 | /** |
| 179 | * Value of the zone setting. |
| 180 | */ |
| 181 | export interface Value { |
| 182 | /** |
| 183 | * List of strings with the MIME types of all the variants that should be served |
| 184 | * for avif. |
| 185 | */ |
| 186 | avif?: Array<string>; |
| 187 | |
| 188 | /** |
| 189 | * List of strings with the MIME types of all the variants that should be served |
| 190 | * for bmp. |
| 191 | */ |
| 192 | bmp?: Array<string>; |
| 193 | |
| 194 | /** |
| 195 | * List of strings with the MIME types of all the variants that should be served |
| 196 | * for gif. |
| 197 | */ |
| 198 | gif?: Array<string>; |
| 199 | |
| 200 | /** |
| 201 | * List of strings with the MIME types of all the variants that should be served |
| 202 | * for jp2. |
| 203 | */ |
| 204 | jp2?: Array<string>; |
| 205 | |
| 206 | /** |
| 207 | * List of strings with the MIME types of all the variants that should be served |
| 208 | * for jpeg. |
| 209 | */ |
| 210 | jpeg?: Array<string>; |
| 211 | |
| 212 | /** |
| 213 | * List of strings with the MIME types of all the variants that should be served |
| 214 | * for jpg. |
| 215 | */ |
| 216 | jpg?: Array<string>; |
| 217 | |
| 218 | /** |
| 219 | * List of strings with the MIME types of all the variants that should be served |
| 220 | * for jpg2. |
| 221 | */ |
| 222 | jpg2?: Array<string>; |
| 223 | |
| 224 | /** |
| 225 | * List of strings with the MIME types of all the variants that should be served |
| 226 | * for png. |
| 227 | */ |
| 228 | png?: Array<string>; |
| 229 | |
| 230 | /** |
| 231 | * List of strings with the MIME types of all the variants that should be served |
| 232 | * for tif. |
| 233 | */ |
| 234 | tif?: Array<string>; |
| 235 | |
| 236 | /** |
| 237 | * List of strings with the MIME types of all the variants that should be served |
| 238 | * for tiff. |
| 239 | */ |
| 240 | tiff?: Array<string>; |
| 241 | |
| 242 | /** |
| 243 | * List of strings with the MIME types of all the variants that should be served |
| 244 | * for webp. |
| 245 | */ |
| 246 | webp?: Array<string>; |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | export interface VariantGetParams { |
| 251 | /** |
| 252 | * Identifier |
| 253 | */ |
| 254 | zone_id: string; |
| 255 | } |
| 256 | |
| 257 | export declare namespace Variants { |
| 258 | export { |
| 259 | type CacheVariant as CacheVariant, |
| 260 | type VariantDeleteResponse as VariantDeleteResponse, |
| 261 | type VariantEditResponse as VariantEditResponse, |
| 262 | type VariantGetResponse as VariantGetResponse, |
| 263 | type VariantDeleteParams as VariantDeleteParams, |
| 264 | type VariantEditParams as VariantEditParams, |
| 265 | type VariantGetParams as VariantGetParams, |
| 266 | }; |
| 267 | } |
| 268 | |