cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v3.2.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/resources/cache/cache.ts

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