cloudflare/cloudflare-typescript

Public

mirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v3.0.0-beta.13

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/resources/cache/cache.ts

175lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import * as Core from 'cloudflare/core';
4import { APIResource } from 'cloudflare/resource';
5import * as CacheAPI from 'cloudflare/resources/cache/cache';
6import * as CacheReserveAPI from 'cloudflare/resources/cache/cache-reserve';
7import * as RegionalTieredCacheAPI from 'cloudflare/resources/cache/regional-tiered-cache';
8import * as SmartTieredCacheAPI from 'cloudflare/resources/cache/smart-tiered-cache';
9import * as VariantsAPI from 'cloudflare/resources/cache/variants';
10
11export class Cache extends APIResource {
12 cacheReserve: CacheReserveAPI.CacheReserve = new CacheReserveAPI.CacheReserve(this._client);
13 smartTieredCache: SmartTieredCacheAPI.SmartTieredCache = new SmartTieredCacheAPI.SmartTieredCache(
14 this._client,
15 );
16 variants: VariantsAPI.Variants = new VariantsAPI.Variants(this._client);
17 regionalTieredCache: RegionalTieredCacheAPI.RegionalTieredCache =
18 new RegionalTieredCacheAPI.RegionalTieredCache(this._client);
19
20 /**
21 * ### Purge All Cached Content
22 *
23 * Removes ALL files from Cloudflare's cache. All tiers can purge everything.
24 *
25 * ### Purge Cached Content by URL
26 *
27 * Granularly removes one or more files from Cloudflare's cache by specifying URLs.
28 * All tiers can purge by URL.
29 *
30 * To purge files with custom cache keys, include the headers used to compute the
31 * cache key as in the example. If you have a device type or geo in your cache key,
32 * you will need to include the CF-Device-Type or CF-IPCountry headers. If you have
33 * lang in your cache key, you will need to include the Accept-Language header.
34 *
35 * **NB:** When including the Origin header, be sure to include the **scheme** and
36 * **hostname**. The port number can be omitted if it is the default port (80 for
37 * http, 443 for https), but must be included otherwise.
38 *
39 * ### Purge Cached Content by Tag, Host or Prefix
40 *
41 * Granularly removes one or more files from Cloudflare's cache either by
42 * specifying the host, the associated Cache-Tag, or a Prefix. Only Enterprise
43 * customers are permitted to purge by Tag, Host or Prefix.
44 *
45 * **NB:** Cache-Tag, host, and prefix purging each have a rate limit of 30,000
46 * purge API calls in every 24 hour period. You may purge up to 30 tags, hosts, or
47 * prefixes in one API call. This rate limit can be raised for customers who need
48 * to purge at higher volume.
49 */
50 purge(params: CachePurgeParams, options?: Core.RequestOptions): Core.APIPromise<CachePurgeResponse | null> {
51 const { zone_id, ...body } = params;
52 return (
53 this._client.post(`/zones/${zone_id}/purge_cache`, { body, ...options }) as Core.APIPromise<{
54 result: CachePurgeResponse | null;
55 }>
56 )._thenUnwrap((obj) => obj.result);
57 }
58}
59
60export interface CachePurgeResponse {
61 /**
62 * Identifier
63 */
64 id: string;
65}
66
67export type CachePurgeParams =
68 | CachePurgeParams.CachePurgeTags
69 | CachePurgeParams.CachePurgeHosts
70 | CachePurgeParams.CachePurgePrefixes
71 | CachePurgeParams.CachePurgeEverything
72 | CachePurgeParams.CachePurgeFiles;
73
74export namespace CachePurgeParams {
75 export interface CachePurgeTags {
76 /**
77 * Path param:
78 */
79 zone_id: string;
80
81 /**
82 * Body param:
83 */
84 tags?: Array<string>;
85 }
86
87 export interface CachePurgeHosts {
88 /**
89 * Path param:
90 */
91 zone_id: string;
92
93 /**
94 * Body param:
95 */
96 hosts?: Array<string>;
97 }
98
99 export interface CachePurgePrefixes {
100 /**
101 * Path param:
102 */
103 zone_id: string;
104
105 /**
106 * Body param:
107 */
108 prefixes?: Array<string>;
109 }
110
111 export interface CachePurgeEverything {
112 /**
113 * Path param:
114 */
115 zone_id: string;
116
117 /**
118 * Body param:
119 */
120 purge_everything?: boolean;
121 }
122
123 export interface CachePurgeFiles {
124 /**
125 * Path param:
126 */
127 zone_id: string;
128
129 /**
130 * Body param:
131 */
132 files?: Array<string | CachePurgeParams.CachePurgeFiles.CachePurgeURLAndHeaders>;
133 }
134
135 export namespace CachePurgeFiles {
136 export interface CachePurgeURLAndHeaders {
137 headers?: unknown;
138
139 url?: string;
140 }
141 }
142}
143
144export namespace Cache {
145 export import CachePurgeResponse = CacheAPI.CachePurgeResponse;
146 export import CachePurgeParams = CacheAPI.CachePurgeParams;
147 export import CacheReserve = CacheReserveAPI.CacheReserve;
148 export import CacheReserveClearResponse = CacheReserveAPI.CacheReserveClearResponse;
149 export import CacheReserveEditResponse = CacheReserveAPI.CacheReserveEditResponse;
150 export import CacheReserveGetResponse = CacheReserveAPI.CacheReserveGetResponse;
151 export import CacheReserveStatusResponse = CacheReserveAPI.CacheReserveStatusResponse;
152 export import CacheReserveClearParams = CacheReserveAPI.CacheReserveClearParams;
153 export import CacheReserveEditParams = CacheReserveAPI.CacheReserveEditParams;
154 export import CacheReserveGetParams = CacheReserveAPI.CacheReserveGetParams;
155 export import CacheReserveStatusParams = CacheReserveAPI.CacheReserveStatusParams;
156 export import SmartTieredCache = SmartTieredCacheAPI.SmartTieredCache;
157 export import SmartTieredCacheDeleteResponse = SmartTieredCacheAPI.SmartTieredCacheDeleteResponse;
158 export import SmartTieredCacheEditResponse = SmartTieredCacheAPI.SmartTieredCacheEditResponse;
159 export import SmartTieredCacheGetResponse = SmartTieredCacheAPI.SmartTieredCacheGetResponse;
160 export import SmartTieredCacheDeleteParams = SmartTieredCacheAPI.SmartTieredCacheDeleteParams;
161 export import SmartTieredCacheEditParams = SmartTieredCacheAPI.SmartTieredCacheEditParams;
162 export import SmartTieredCacheGetParams = SmartTieredCacheAPI.SmartTieredCacheGetParams;
163 export import Variants = VariantsAPI.Variants;
164 export import CacheVariants = VariantsAPI.CacheVariants;
165 export import VariantEditResponse = VariantsAPI.VariantEditResponse;
166 export import VariantGetResponse = VariantsAPI.VariantGetResponse;
167 export import VariantDeleteParams = VariantsAPI.VariantDeleteParams;
168 export import VariantEditParams = VariantsAPI.VariantEditParams;
169 export import VariantGetParams = VariantsAPI.VariantGetParams;
170 export import RegionalTieredCache = RegionalTieredCacheAPI.RegionalTieredCache;
171 export import RegionalTieredCacheEditResponse = RegionalTieredCacheAPI.RegionalTieredCacheEditResponse;
172 export import RegionalTieredCacheGetResponse = RegionalTieredCacheAPI.RegionalTieredCacheGetResponse;
173 export import RegionalTieredCacheEditParams = RegionalTieredCacheAPI.RegionalTieredCacheEditParams;
174 export import RegionalTieredCacheGetParams = RegionalTieredCacheAPI.RegionalTieredCacheGetParams;
175}
176