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