cloudflare/cloudflare-typescript

Public

mirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v6.0.0-beta.2

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/resources/cache/smart-tiered-cache.ts

208lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import { APIResource } from '../../resource';
4import { isRequestOptions } from '../../core';
5import * as Core from '../../core';
6
7export class SmartTieredCache extends APIResource {
8 /**
9 * Smart Tiered Cache dynamically selects the single closest upper tier for each of
10 * your website’s origins with no configuration required, using our in-house
11 * performance and routing data. Cloudflare collects latency data for each request
12 * to an origin, and uses the latency data to determine how well any upper-tier
13 * data center is connected with an origin. As a result, Cloudflare can select the
14 * data center with the lowest latency to be the upper-tier for an origin.
15 *
16 * @example
17 * ```ts
18 * const smartTieredCache =
19 * await client.cache.smartTieredCache.delete({
20 * zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
21 * });
22 * ```
23 */
24 delete(
25 params?: SmartTieredCacheDeleteParams,
26 options?: Core.RequestOptions,
27 ): Core.APIPromise<SmartTieredCacheDeleteResponse>;
28 delete(options?: Core.RequestOptions): Core.APIPromise<SmartTieredCacheDeleteResponse>;
29 delete(
30 params: SmartTieredCacheDeleteParams | Core.RequestOptions = {},
31 options?: Core.RequestOptions,
32 ): Core.APIPromise<SmartTieredCacheDeleteResponse> {
33 if (isRequestOptions(params)) {
34 return this.delete({}, params);
35 }
36 const { zone_id = this._client.zoneId } = params;
37 return (
38 this._client.delete(
39 `/zones/${zone_id}/cache/tiered_cache_smart_topology_enable`,
40 options,
41 ) as Core.APIPromise<{ result: SmartTieredCacheDeleteResponse }>
42 )._thenUnwrap((obj) => obj.result);
43 }
44
45 /**
46 * Smart Tiered Cache dynamically selects the single closest upper tier for each of
47 * your website’s origins with no configuration required, using our in-house
48 * performance and routing data. Cloudflare collects latency data for each request
49 * to an origin, and uses the latency data to determine how well any upper-tier
50 * data center is connected with an origin. As a result, Cloudflare can select the
51 * data center with the lowest latency to be the upper-tier for an origin.
52 *
53 * @example
54 * ```ts
55 * const response = await client.cache.smartTieredCache.edit({
56 * zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
57 * value: 'on',
58 * });
59 * ```
60 */
61 edit(
62 params: SmartTieredCacheEditParams,
63 options?: Core.RequestOptions,
64 ): Core.APIPromise<SmartTieredCacheEditResponse> {
65 const { zone_id = this._client.zoneId, ...body } = params;
66 return (
67 this._client.patch(`/zones/${zone_id}/cache/tiered_cache_smart_topology_enable`, {
68 body,
69 ...options,
70 }) as Core.APIPromise<{ result: SmartTieredCacheEditResponse }>
71 )._thenUnwrap((obj) => obj.result);
72 }
73
74 /**
75 * Smart Tiered Cache dynamically selects the single closest upper tier for each of
76 * your website’s origins with no configuration required, using our in-house
77 * performance and routing data. Cloudflare collects latency data for each request
78 * to an origin, and uses the latency data to determine how well any upper-tier
79 * data center is connected with an origin. As a result, Cloudflare can select the
80 * data center with the lowest latency to be the upper-tier for an origin.
81 *
82 * @example
83 * ```ts
84 * const smartTieredCache =
85 * await client.cache.smartTieredCache.get({
86 * zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
87 * });
88 * ```
89 */
90 get(
91 params?: SmartTieredCacheGetParams,
92 options?: Core.RequestOptions,
93 ): Core.APIPromise<SmartTieredCacheGetResponse>;
94 get(options?: Core.RequestOptions): Core.APIPromise<SmartTieredCacheGetResponse>;
95 get(
96 params: SmartTieredCacheGetParams | Core.RequestOptions = {},
97 options?: Core.RequestOptions,
98 ): Core.APIPromise<SmartTieredCacheGetResponse> {
99 if (isRequestOptions(params)) {
100 return this.get({}, params);
101 }
102 const { zone_id = this._client.zoneId } = params;
103 return (
104 this._client.get(
105 `/zones/${zone_id}/cache/tiered_cache_smart_topology_enable`,
106 options,
107 ) as Core.APIPromise<{ result: SmartTieredCacheGetResponse }>
108 )._thenUnwrap((obj) => obj.result);
109 }
110}
111
112export interface SmartTieredCacheDeleteResponse {
113 /**
114 * The identifier of the caching setting.
115 */
116 id: 'tiered_cache_smart_topology_enable';
117
118 /**
119 * Whether the setting is editable.
120 */
121 editable: boolean;
122
123 /**
124 * Last time this setting was modified.
125 */
126 modified_on?: string | null;
127}
128
129export interface SmartTieredCacheEditResponse {
130 /**
131 * The identifier of the caching setting.
132 */
133 id: 'tiered_cache_smart_topology_enable';
134
135 /**
136 * Whether the setting is editable.
137 */
138 editable: boolean;
139
140 /**
141 * Value of the Smart Tiered Cache zone setting.
142 */
143 value: 'on' | 'off';
144
145 /**
146 * Last time this setting was modified.
147 */
148 modified_on?: string | null;
149}
150
151export interface SmartTieredCacheGetResponse {
152 /**
153 * The identifier of the caching setting.
154 */
155 id: 'tiered_cache_smart_topology_enable';
156
157 /**
158 * Whether the setting is editable.
159 */
160 editable: boolean;
161
162 /**
163 * Value of the Smart Tiered Cache zone setting.
164 */
165 value: 'on' | 'off';
166
167 /**
168 * Last time this setting was modified.
169 */
170 modified_on?: string | null;
171}
172
173export interface SmartTieredCacheDeleteParams {
174 /**
175 * Identifier.
176 */
177 zone_id?: string;
178}
179
180export interface SmartTieredCacheEditParams {
181 /**
182 * Path param: Identifier.
183 */
184 zone_id?: string;
185
186 /**
187 * Body param: Enable or disable the Smart Tiered Cache.
188 */
189 value: 'on' | 'off';
190}
191
192export interface SmartTieredCacheGetParams {
193 /**
194 * Identifier.
195 */
196 zone_id?: string;
197}
198
199export declare namespace SmartTieredCache {
200 export {
201 type SmartTieredCacheDeleteResponse as SmartTieredCacheDeleteResponse,
202 type SmartTieredCacheEditResponse as SmartTieredCacheEditResponse,
203 type SmartTieredCacheGetResponse as SmartTieredCacheGetResponse,
204 type SmartTieredCacheDeleteParams as SmartTieredCacheDeleteParams,
205 type SmartTieredCacheEditParams as SmartTieredCacheEditParams,
206 type SmartTieredCacheGetParams as SmartTieredCacheGetParams,
207 };
208}
209