cloudflare/cloudflare-typescript
Publicmirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable
src/resources/cache/cache-reserve.ts
292lines · 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 CacheReserveResource extends APIResource { |
| 7 | /** |
| 8 | * You can use Cache Reserve Clear to clear your Cache Reserve, but you must first |
| 9 | * disable Cache Reserve. In most cases, this will be accomplished within 24 hours. |
| 10 | * You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind |
| 11 | * that you cannot undo or cancel this operation. |
| 12 | * |
| 13 | * @example |
| 14 | * ```ts |
| 15 | * const response = await client.cache.cacheReserve.clear({ |
| 16 | * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 17 | * body: {}, |
| 18 | * }); |
| 19 | * ``` |
| 20 | */ |
| 21 | clear( |
| 22 | params: CacheReserveClearParams, |
| 23 | options?: Core.RequestOptions, |
| 24 | ): Core.APIPromise<CacheReserveClearResponse> { |
| 25 | const { zone_id, body } = params; |
| 26 | return ( |
| 27 | this._client.post(`/zones/${zone_id}/cache/cache_reserve_clear`, { |
| 28 | body: body, |
| 29 | ...options, |
| 30 | }) as Core.APIPromise<{ result: CacheReserveClearResponse }> |
| 31 | )._thenUnwrap((obj) => obj.result); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Increase cache lifetimes by automatically storing all cacheable files into |
| 36 | * Cloudflare's persistent object storage buckets. Requires Cache Reserve |
| 37 | * subscription. Note: using Tiered Cache with Cache Reserve is highly recommended |
| 38 | * to reduce Reserve operations costs. See the |
| 39 | * [developer docs](https://developers.cloudflare.com/cache/about/cache-reserve) |
| 40 | * for more information. |
| 41 | * |
| 42 | * @example |
| 43 | * ```ts |
| 44 | * const response = await client.cache.cacheReserve.edit({ |
| 45 | * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 46 | * value: 'on', |
| 47 | * }); |
| 48 | * ``` |
| 49 | */ |
| 50 | edit( |
| 51 | params: CacheReserveEditParams, |
| 52 | options?: Core.RequestOptions, |
| 53 | ): Core.APIPromise<CacheReserveEditResponse> { |
| 54 | const { zone_id, ...body } = params; |
| 55 | return ( |
| 56 | this._client.patch(`/zones/${zone_id}/cache/cache_reserve`, { body, ...options }) as Core.APIPromise<{ |
| 57 | result: CacheReserveEditResponse; |
| 58 | }> |
| 59 | )._thenUnwrap((obj) => obj.result); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Increase cache lifetimes by automatically storing all cacheable files into |
| 64 | * Cloudflare's persistent object storage buckets. Requires Cache Reserve |
| 65 | * subscription. Note: using Tiered Cache with Cache Reserve is highly recommended |
| 66 | * to reduce Reserve operations costs. See the |
| 67 | * [developer docs](https://developers.cloudflare.com/cache/about/cache-reserve) |
| 68 | * for more information. |
| 69 | * |
| 70 | * @example |
| 71 | * ```ts |
| 72 | * const cacheReserve = await client.cache.cacheReserve.get({ |
| 73 | * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 74 | * }); |
| 75 | * ``` |
| 76 | */ |
| 77 | get( |
| 78 | params: CacheReserveGetParams, |
| 79 | options?: Core.RequestOptions, |
| 80 | ): Core.APIPromise<CacheReserveGetResponse> { |
| 81 | const { zone_id } = params; |
| 82 | return ( |
| 83 | this._client.get(`/zones/${zone_id}/cache/cache_reserve`, options) as Core.APIPromise<{ |
| 84 | result: CacheReserveGetResponse; |
| 85 | }> |
| 86 | )._thenUnwrap((obj) => obj.result); |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * You can use Cache Reserve Clear to clear your Cache Reserve, but you must first |
| 91 | * disable Cache Reserve. In most cases, this will be accomplished within 24 hours. |
| 92 | * You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind |
| 93 | * that you cannot undo or cancel this operation. |
| 94 | * |
| 95 | * @example |
| 96 | * ```ts |
| 97 | * const response = await client.cache.cacheReserve.status({ |
| 98 | * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 99 | * }); |
| 100 | * ``` |
| 101 | */ |
| 102 | status( |
| 103 | params: CacheReserveStatusParams, |
| 104 | options?: Core.RequestOptions, |
| 105 | ): Core.APIPromise<CacheReserveStatusResponse> { |
| 106 | const { zone_id } = params; |
| 107 | return ( |
| 108 | this._client.get(`/zones/${zone_id}/cache/cache_reserve_clear`, options) as Core.APIPromise<{ |
| 109 | result: CacheReserveStatusResponse; |
| 110 | }> |
| 111 | )._thenUnwrap((obj) => obj.result); |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * The identifier of the caching setting. |
| 117 | */ |
| 118 | export type CacheReserve = 'cache_reserve'; |
| 119 | |
| 120 | /** |
| 121 | * ID of the zone setting. |
| 122 | */ |
| 123 | export type CacheReserveClear = 'cache_reserve_clear'; |
| 124 | |
| 125 | /** |
| 126 | * The current state of the Cache Reserve Clear operation. |
| 127 | */ |
| 128 | export type State = 'In-progress' | 'Completed'; |
| 129 | |
| 130 | /** |
| 131 | * You can use Cache Reserve Clear to clear your Cache Reserve, but you must first |
| 132 | * disable Cache Reserve. In most cases, this will be accomplished within 24 hours. |
| 133 | * You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind |
| 134 | * that you cannot undo or cancel this operation. |
| 135 | */ |
| 136 | export interface CacheReserveClearResponse { |
| 137 | /** |
| 138 | * ID of the zone setting. |
| 139 | */ |
| 140 | id: CacheReserveClear; |
| 141 | |
| 142 | /** |
| 143 | * The time that the latest Cache Reserve Clear operation started. |
| 144 | */ |
| 145 | start_ts: string; |
| 146 | |
| 147 | /** |
| 148 | * The current state of the Cache Reserve Clear operation. |
| 149 | */ |
| 150 | state: State; |
| 151 | |
| 152 | /** |
| 153 | * The time that the latest Cache Reserve Clear operation completed. |
| 154 | */ |
| 155 | end_ts?: string; |
| 156 | |
| 157 | /** |
| 158 | * Last time this setting was modified. |
| 159 | */ |
| 160 | modified_on?: string | null; |
| 161 | } |
| 162 | |
| 163 | export interface CacheReserveEditResponse { |
| 164 | /** |
| 165 | * The identifier of the caching setting. |
| 166 | */ |
| 167 | id: CacheReserve; |
| 168 | |
| 169 | /** |
| 170 | * Whether the setting is editable. |
| 171 | */ |
| 172 | editable: boolean; |
| 173 | |
| 174 | /** |
| 175 | * Value of the Cache Reserve zone setting. |
| 176 | */ |
| 177 | value: 'on' | 'off'; |
| 178 | |
| 179 | /** |
| 180 | * Last time this setting was modified. |
| 181 | */ |
| 182 | modified_on?: string | null; |
| 183 | } |
| 184 | |
| 185 | export interface CacheReserveGetResponse { |
| 186 | /** |
| 187 | * The identifier of the caching setting. |
| 188 | */ |
| 189 | id: CacheReserve; |
| 190 | |
| 191 | /** |
| 192 | * Whether the setting is editable. |
| 193 | */ |
| 194 | editable: boolean; |
| 195 | |
| 196 | /** |
| 197 | * Value of the Cache Reserve zone setting. |
| 198 | */ |
| 199 | value: 'on' | 'off'; |
| 200 | |
| 201 | /** |
| 202 | * Last time this setting was modified. |
| 203 | */ |
| 204 | modified_on?: string | null; |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * You can use Cache Reserve Clear to clear your Cache Reserve, but you must first |
| 209 | * disable Cache Reserve. In most cases, this will be accomplished within 24 hours. |
| 210 | * You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind |
| 211 | * that you cannot undo or cancel this operation. |
| 212 | */ |
| 213 | export interface CacheReserveStatusResponse { |
| 214 | /** |
| 215 | * ID of the zone setting. |
| 216 | */ |
| 217 | id: CacheReserveClear; |
| 218 | |
| 219 | /** |
| 220 | * The time that the latest Cache Reserve Clear operation started. |
| 221 | */ |
| 222 | start_ts: string; |
| 223 | |
| 224 | /** |
| 225 | * The current state of the Cache Reserve Clear operation. |
| 226 | */ |
| 227 | state: State; |
| 228 | |
| 229 | /** |
| 230 | * The time that the latest Cache Reserve Clear operation completed. |
| 231 | */ |
| 232 | end_ts?: string; |
| 233 | |
| 234 | /** |
| 235 | * Last time this setting was modified. |
| 236 | */ |
| 237 | modified_on?: string | null; |
| 238 | } |
| 239 | |
| 240 | export interface CacheReserveClearParams { |
| 241 | /** |
| 242 | * Path param: Identifier. |
| 243 | */ |
| 244 | zone_id: string; |
| 245 | |
| 246 | /** |
| 247 | * Body param: |
| 248 | */ |
| 249 | body: unknown; |
| 250 | } |
| 251 | |
| 252 | export interface CacheReserveEditParams { |
| 253 | /** |
| 254 | * Path param: Identifier. |
| 255 | */ |
| 256 | zone_id: string; |
| 257 | |
| 258 | /** |
| 259 | * Body param: Value of the Cache Reserve zone setting. |
| 260 | */ |
| 261 | value: 'on' | 'off'; |
| 262 | } |
| 263 | |
| 264 | export interface CacheReserveGetParams { |
| 265 | /** |
| 266 | * Identifier. |
| 267 | */ |
| 268 | zone_id: string; |
| 269 | } |
| 270 | |
| 271 | export interface CacheReserveStatusParams { |
| 272 | /** |
| 273 | * Identifier. |
| 274 | */ |
| 275 | zone_id: string; |
| 276 | } |
| 277 | |
| 278 | export declare namespace CacheReserveResource { |
| 279 | export { |
| 280 | type CacheReserve as CacheReserve, |
| 281 | type CacheReserveClear as CacheReserveClear, |
| 282 | type State as State, |
| 283 | type CacheReserveClearResponse as CacheReserveClearResponse, |
| 284 | type CacheReserveEditResponse as CacheReserveEditResponse, |
| 285 | type CacheReserveGetResponse as CacheReserveGetResponse, |
| 286 | type CacheReserveStatusResponse as CacheReserveStatusResponse, |
| 287 | type CacheReserveClearParams as CacheReserveClearParams, |
| 288 | type CacheReserveEditParams as CacheReserveEditParams, |
| 289 | type CacheReserveGetParams as CacheReserveGetParams, |
| 290 | type CacheReserveStatusParams as CacheReserveStatusParams, |
| 291 | }; |
| 292 | } |
| 293 | |