cloudflare/cloudflare-typescript

Public

mirrored fromhttps://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/index.ts

945lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import { type Agent } from './_shims/index';
4import * as qs from './internal/qs';
5import * as Core from './core';
6import * as Errors from './error';
7import * as Pagination from './pagination';
8import {
9 type CursorLimitPaginationParams,
10 CursorLimitPaginationResponse,
11 type CursorPaginationAfterParams,
12 CursorPaginationAfterResponse,
13 type CursorPaginationParams,
14 CursorPaginationResponse,
15 SinglePageResponse,
16 type V4PagePaginationArrayParams,
17 V4PagePaginationArrayResponse,
18 type V4PagePaginationParams,
19 V4PagePaginationResponse,
20} from './pagination';
21import * as Uploads from './uploads';
22import * as API from './resources/index';
23import { AuditLogs } from './resources/audit-logs';
24import { BotManagement } from './resources/bot-management';
25import { ClientCertificates } from './resources/client-certificates';
26import { CustomNameservers } from './resources/custom-nameservers';
27import { DCVDelegation } from './resources/dcv-delegation';
28import { Filters } from './resources/filters';
29import { Fraud } from './resources/fraud';
30import { IPs } from './resources/ips';
31import { KeylessCertificates } from './resources/keyless-certificates';
32import { ManagedTransforms } from './resources/managed-transforms';
33import { Memberships } from './resources/memberships';
34import { OriginCACertificates } from './resources/origin-ca-certificates';
35import { OriginPostQuantumEncryption } from './resources/origin-post-quantum-encryption';
36import { PageRules } from './resources/page-rules';
37import { RateLimits } from './resources/rate-limits';
38import { SecurityTXT } from './resources/security-txt';
39import { URLNormalization } from './resources/url-normalization';
40import { AbuseReports } from './resources/abuse-reports/abuse-reports';
41import { Accounts } from './resources/accounts/accounts';
42import { ACM } from './resources/acm/acm';
43import { Addressing } from './resources/addressing/addressing';
44import { AIGateway } from './resources/ai-gateway/ai-gateway';
45import { AI } from './resources/ai/ai';
46import { AISearch } from './resources/aisearch/aisearch';
47import { Alerting } from './resources/alerting/alerting';
48import { APIGateway } from './resources/api-gateway/api-gateway';
49import { Argo } from './resources/argo/argo';
50import { Billing } from './resources/billing/billing';
51import { BotnetFeed } from './resources/botnet-feed/botnet-feed';
52import { BrandProtection } from './resources/brand-protection/brand-protection';
53import { BrowserRendering } from './resources/browser-rendering/browser-rendering';
54import { Cache } from './resources/cache/cache';
55import { Calls } from './resources/calls/calls';
56import { CertificateAuthorities } from './resources/certificate-authorities/certificate-authorities';
57import { CloudConnector } from './resources/cloud-connector/cloud-connector';
58import { CloudforceOne } from './resources/cloudforce-one/cloudforce-one';
59import { Connectivity } from './resources/connectivity/connectivity';
60import { ContentScanning } from './resources/content-scanning/content-scanning';
61import { CustomCertificates } from './resources/custom-certificates/custom-certificates';
62import { CustomHostnames } from './resources/custom-hostnames/custom-hostnames';
63import { CustomPages } from './resources/custom-pages/custom-pages';
64import { D1Resource } from './resources/d1/d1';
65import { Diagnostics } from './resources/diagnostics/diagnostics';
66import { DNSFirewall } from './resources/dns-firewall/dns-firewall';
67import { DNS } from './resources/dns/dns';
68import { DurableObjects } from './resources/durable-objects/durable-objects';
69import { EmailRouting } from './resources/email-routing/email-routing';
70import { EmailSecurity } from './resources/email-security/email-security';
71import { EmailSending } from './resources/email-sending/email-sending';
72import { Firewall } from './resources/firewall/firewall';
73import { GoogleTagGateway } from './resources/google-tag-gateway/google-tag-gateway';
74import { Healthchecks } from './resources/healthchecks/healthchecks';
75import { Hostnames } from './resources/hostnames/hostnames';
76import { HyperdriveResource } from './resources/hyperdrive/hyperdrive';
77import { IAM } from './resources/iam/iam';
78import { Images } from './resources/images/images';
79import { Intel } from './resources/intel/intel';
80import { KV } from './resources/kv/kv';
81import { LeakedCredentialChecks } from './resources/leaked-credential-checks/leaked-credential-checks';
82import { LoadBalancers } from './resources/load-balancers/load-balancers';
83import { Logpush } from './resources/logpush/logpush';
84import { Logs } from './resources/logs/logs';
85import { MagicCloudNetworking } from './resources/magic-cloud-networking/magic-cloud-networking';
86import { MagicNetworkMonitoring } from './resources/magic-network-monitoring/magic-network-monitoring';
87import { MagicTransit } from './resources/magic-transit/magic-transit';
88import { MTLSCertificates } from './resources/mtls-certificates/mtls-certificates';
89import { NetworkInterconnects } from './resources/network-interconnects/network-interconnects';
90import { Organizations } from './resources/organizations/organizations';
91import { OriginTLSClientAuth } from './resources/origin-tls-client-auth/origin-tls-client-auth';
92import { PageShield } from './resources/page-shield/page-shield';
93import { Pages } from './resources/pages/pages';
94import { Pipelines } from './resources/pipelines/pipelines';
95import { Queues } from './resources/queues/queues';
96import { R2DataCatalog } from './resources/r2-data-catalog/r2-data-catalog';
97import { R2 } from './resources/r2/r2';
98import { Radar } from './resources/radar/radar';
99import { RealtimeKit } from './resources/realtime-kit/realtime-kit';
100import { Registrar } from './resources/registrar/registrar';
101import { RequestTracers } from './resources/request-tracers/request-tracers';
102import { ResourceSharing } from './resources/resource-sharing/resource-sharing';
103import { ResourceTagging } from './resources/resource-tagging/resource-tagging';
104import { Rules } from './resources/rules/rules';
105import { Rulesets } from './resources/rulesets/rulesets';
106import { RUM } from './resources/rum/rum';
107import { SchemaValidation } from './resources/schema-validation/schema-validation';
108import { SecretsStore } from './resources/secrets-store/secrets-store';
109import { SecurityCenter } from './resources/security-center/security-center';
110import { Snippets } from './resources/snippets/snippets';
111import { Spectrum } from './resources/spectrum/spectrum';
112import { Speed } from './resources/speed/speed';
113import { SSL } from './resources/ssl/ssl';
114import { Stream } from './resources/stream/stream';
115import { TokenValidation } from './resources/token-validation/token-validation';
116import { Turnstile } from './resources/turnstile/turnstile';
117import { URLScanner } from './resources/url-scanner/url-scanner';
118import { User } from './resources/user/user';
119import { Vectorize } from './resources/vectorize/vectorize';
120import { VulnerabilityScanner } from './resources/vulnerability-scanner/vulnerability-scanner';
121import { WaitingRooms } from './resources/waiting-rooms/waiting-rooms';
122import { Web3 } from './resources/web3/web3';
123import { WorkersForPlatforms } from './resources/workers-for-platforms/workers-for-platforms';
124import { Workers } from './resources/workers/workers';
125import { Workflows } from './resources/workflows/workflows';
126import { Zaraz } from './resources/zaraz/zaraz';
127import { ZeroTrust } from './resources/zero-trust/zero-trust';
128import { Zones } from './resources/zones/zones';
129
130export interface ClientOptions {
131 /**
132 * The preferred authorization scheme for interacting with the Cloudflare API. [Create a token](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/).
133 */
134 apiToken?: string | null | undefined;
135
136 /**
137 * The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
138 */
139 apiKey?: string | null | undefined;
140
141 /**
142 * The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
143 */
144 apiEmail?: string | null | undefined;
145
146 /**
147 * Used when interacting with the Origin CA certificates API. [View/change your key](https://developers.cloudflare.com/fundamentals/api/get-started/ca-keys/#viewchange-your-origin-ca-keys).
148 */
149 userServiceKey?: string | null | undefined;
150
151 /**
152 * Sets an account ID to be used with all account-scoped requests.
153 */
154 accountId?: string | null | undefined;
155
156 /**
157 * Sets a zone ID to be used with all zone-scoped requests.
158 */
159 zoneId?: string | null | undefined;
160
161 /**
162 * Override the default base URL for the API, e.g., "https://api.example.com/v2/"
163 *
164 * Defaults to process.env['CLOUDFLARE_BASE_URL'].
165 */
166 baseURL?: string | null | undefined;
167
168 /**
169 * Define the API version to target for the requests, e.g., "2025-01-01"
170 */
171 apiVersion?: string | null;
172
173 /**
174 * The maximum amount of time (in milliseconds) that the client should wait for a response
175 * from the server before timing out a single request.
176 *
177 * Note that request timeouts are retried by default, so in a worst-case scenario you may wait
178 * much longer than this timeout before the promise succeeds or fails.
179 *
180 * @unit milliseconds
181 */
182 timeout?: number | undefined;
183
184 /**
185 * An HTTP agent used to manage HTTP(S) connections.
186 *
187 * If not provided, an agent will be constructed by default in the Node.js environment,
188 * otherwise no agent is used.
189 */
190 httpAgent?: Agent | undefined;
191
192 /**
193 * Specify a custom `fetch` function implementation.
194 *
195 * If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
196 * defined globally.
197 */
198 fetch?: Core.Fetch | undefined;
199
200 /**
201 * The maximum number of times that the client will retry a request in case of a
202 * temporary failure, like a network error or a 5XX error from the server.
203 *
204 * @default 2
205 */
206 maxRetries?: number | undefined;
207
208 /**
209 * Default headers to include with every request to the API.
210 *
211 * These can be removed in individual requests by explicitly setting the
212 * header to `undefined` or `null` in request options.
213 */
214 defaultHeaders?: Core.Headers | undefined;
215
216 /**
217 * Default query parameters to include with every request to the API.
218 *
219 * These can be removed in individual requests by explicitly setting the
220 * param to `undefined` in request options.
221 */
222 defaultQuery?: Core.DefaultQuery | undefined;
223}
224
225/**
226 * API Client for interfacing with the Cloudflare API.
227 */
228export class Cloudflare extends Core.APIClient {
229 apiToken: string | null;
230 apiKey: string | null;
231 apiEmail: string | null;
232 userServiceKey: string | null;
233 accountId: string | null;
234 zoneId: string | null;
235
236 private _options: ClientOptions;
237
238 /**
239 * API Client for interfacing with the Cloudflare API.
240 *
241 * @param {string | null | undefined} [opts.apiToken=process.env['CLOUDFLARE_API_TOKEN'] ?? null]
242 * @param {string | null | undefined} [opts.apiKey=process.env['CLOUDFLARE_API_KEY'] ?? null]
243 * @param {string | null | undefined} [opts.apiEmail=process.env['CLOUDFLARE_EMAIL'] ?? null]
244 * @param {string | null | undefined} [opts.userServiceKey=process.env['CLOUDFLARE_API_USER_SERVICE_KEY'] ?? null]
245 * @param {string | null | undefined} [opts.accountId=process.env['CLOUDFLARE_ACCOUNT_ID'] ?? null]
246 * @param {string | null | undefined} [opts.zoneId=process.env['CLOUDFLARE_ZONE_ID'] ?? null]
247 * @param {string} [opts.baseURL=process.env['CLOUDFLARE_BASE_URL'] ?? https://api.cloudflare.com/client/v4] - Override the default base URL for the API.
248 * @param {string | null} [opts.apiVersion] - Define the version to target for the API.
249 * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
250 * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
251 * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
252 * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
253 * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
254 * @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
255 */
256 constructor({
257 baseURL = Core.readEnv('CLOUDFLARE_BASE_URL'),
258 apiVersion = null,
259 apiToken = Core.readEnv('CLOUDFLARE_API_TOKEN') ?? null,
260 apiKey = Core.readEnv('CLOUDFLARE_API_KEY') ?? null,
261 apiEmail = Core.readEnv('CLOUDFLARE_EMAIL') ?? null,
262 userServiceKey = Core.readEnv('CLOUDFLARE_API_USER_SERVICE_KEY') ?? null,
263 accountId = Core.readEnv('CLOUDFLARE_ACCOUNT_ID') ?? null,
264 zoneId = Core.readEnv('CLOUDFLARE_ZONE_ID') ?? null,
265 ...opts
266 }: ClientOptions = {}) {
267 const options: ClientOptions = {
268 apiToken,
269 apiKey,
270 apiEmail,
271 userServiceKey,
272 accountId,
273 zoneId,
274 ...opts,
275 baseURL: baseURL || `https://api.cloudflare.com/client/v4`,
276 apiVersion: apiVersion || new Date().toISOString().slice(0, 10),
277 };
278
279 super({
280 baseURL: options.baseURL!,
281 apiVersion: options.apiVersion!,
282 baseURLOverridden: baseURL ? baseURL !== 'https://api.cloudflare.com/client/v4' : false,
283 timeout: options.timeout ?? 60000 /* 1 minute */,
284 httpAgent: options.httpAgent,
285 maxRetries: options.maxRetries,
286 fetch: options.fetch,
287 });
288
289 this._options = options;
290
291 this.apiToken = apiToken;
292 this.apiKey = apiKey;
293 this.apiEmail = apiEmail;
294 this.userServiceKey = userServiceKey;
295 this.accountId = accountId;
296 this.zoneId = zoneId;
297 }
298
299 accounts: API.Accounts = new API.Accounts(this);
300 organizations: API.Organizations = new API.Organizations(this);
301 originCACertificates: API.OriginCACertificates = new API.OriginCACertificates(this);
302 ips: API.IPs = new API.IPs(this);
303 memberships: API.Memberships = new API.Memberships(this);
304 user: API.User = new API.User(this);
305 zones: API.Zones = new API.Zones(this);
306 loadBalancers: API.LoadBalancers = new API.LoadBalancers(this);
307 cache: API.Cache = new API.Cache(this);
308 ssl: API.SSL = new API.SSL(this);
309 acm: API.ACM = new API.ACM(this);
310 argo: API.Argo = new API.Argo(this);
311 certificateAuthorities: API.CertificateAuthorities = new API.CertificateAuthorities(this);
312 clientCertificates: API.ClientCertificates = new API.ClientCertificates(this);
313 customCertificates: API.CustomCertificates = new API.CustomCertificates(this);
314 customHostnames: API.CustomHostnames = new API.CustomHostnames(this);
315 customNameservers: API.CustomNameservers = new API.CustomNameservers(this);
316 dnsFirewall: API.DNSFirewall = new API.DNSFirewall(this);
317 dns: API.DNS = new API.DNS(this);
318 emailSecurity: API.EmailSecurity = new API.EmailSecurity(this);
319 emailRouting: API.EmailRouting = new API.EmailRouting(this);
320 emailSending: API.EmailSending = new API.EmailSending(this);
321 filters: API.Filters = new API.Filters(this);
322 firewall: API.Firewall = new API.Firewall(this);
323 healthchecks: API.Healthchecks = new API.Healthchecks(this);
324 keylessCertificates: API.KeylessCertificates = new API.KeylessCertificates(this);
325 logpush: API.Logpush = new API.Logpush(this);
326 logs: API.Logs = new API.Logs(this);
327 originTLSClientAuth: API.OriginTLSClientAuth = new API.OriginTLSClientAuth(this);
328 pageRules: API.PageRules = new API.PageRules(this);
329 rateLimits: API.RateLimits = new API.RateLimits(this);
330 waitingRooms: API.WaitingRooms = new API.WaitingRooms(this);
331 web3: API.Web3 = new API.Web3(this);
332 workers: API.Workers = new API.Workers(this);
333 kv: API.KV = new API.KV(this);
334 durableObjects: API.DurableObjects = new API.DurableObjects(this);
335 queues: API.Queues = new API.Queues(this);
336 apiGateway: API.APIGateway = new API.APIGateway(this);
337 managedTransforms: API.ManagedTransforms = new API.ManagedTransforms(this);
338 pageShield: API.PageShield = new API.PageShield(this);
339 rulesets: API.Rulesets = new API.Rulesets(this);
340 urlNormalization: API.URLNormalization = new API.URLNormalization(this);
341 spectrum: API.Spectrum = new API.Spectrum(this);
342 addressing: API.Addressing = new API.Addressing(this);
343 auditLogs: API.AuditLogs = new API.AuditLogs(this);
344 billing: API.Billing = new API.Billing(this);
345 brandProtection: API.BrandProtection = new API.BrandProtection(this);
346 diagnostics: API.Diagnostics = new API.Diagnostics(this);
347 images: API.Images = new API.Images(this);
348 intel: API.Intel = new API.Intel(this);
349 magicTransit: API.MagicTransit = new API.MagicTransit(this);
350 magicNetworkMonitoring: API.MagicNetworkMonitoring = new API.MagicNetworkMonitoring(this);
351 magicCloudNetworking: API.MagicCloudNetworking = new API.MagicCloudNetworking(this);
352 networkInterconnects: API.NetworkInterconnects = new API.NetworkInterconnects(this);
353 mtlsCertificates: API.MTLSCertificates = new API.MTLSCertificates(this);
354 pages: API.Pages = new API.Pages(this);
355 registrar: API.Registrar = new API.Registrar(this);
356 requestTracers: API.RequestTracers = new API.RequestTracers(this);
357 rules: API.Rules = new API.Rules(this);
358 stream: API.Stream = new API.Stream(this);
359 alerting: API.Alerting = new API.Alerting(this);
360 d1: API.D1Resource = new API.D1Resource(this);
361 r2: API.R2 = new API.R2(this);
362 r2DataCatalog: API.R2DataCatalog = new API.R2DataCatalog(this);
363 workersForPlatforms: API.WorkersForPlatforms = new API.WorkersForPlatforms(this);
364 zeroTrust: API.ZeroTrust = new API.ZeroTrust(this);
365 turnstile: API.Turnstile = new API.Turnstile(this);
366 connectivity: API.Connectivity = new API.Connectivity(this);
367 hyperdrive: API.HyperdriveResource = new API.HyperdriveResource(this);
368 rum: API.RUM = new API.RUM(this);
369 vectorize: API.Vectorize = new API.Vectorize(this);
370 urlScanner: API.URLScanner = new API.URLScanner(this);
371 vulnerabilityScanner: API.VulnerabilityScanner = new API.VulnerabilityScanner(this);
372 radar: API.Radar = new API.Radar(this);
373 botManagement: API.BotManagement = new API.BotManagement(this);
374 fraud: API.Fraud = new API.Fraud(this);
375 originPostQuantumEncryption: API.OriginPostQuantumEncryption = new API.OriginPostQuantumEncryption(this);
376 googleTagGateway: API.GoogleTagGateway = new API.GoogleTagGateway(this);
377 zaraz: API.Zaraz = new API.Zaraz(this);
378 speed: API.Speed = new API.Speed(this);
379 dcvDelegation: API.DCVDelegation = new API.DCVDelegation(this);
380 hostnames: API.Hostnames = new API.Hostnames(this);
381 snippets: API.Snippets = new API.Snippets(this);
382 realtimeKit: API.RealtimeKit = new API.RealtimeKit(this);
383 calls: API.Calls = new API.Calls(this);
384 cloudforceOne: API.CloudforceOne = new API.CloudforceOne(this);
385 aiGateway: API.AIGateway = new API.AIGateway(this);
386 iam: API.IAM = new API.IAM(this);
387 cloudConnector: API.CloudConnector = new API.CloudConnector(this);
388 botnetFeed: API.BotnetFeed = new API.BotnetFeed(this);
389 securityTXT: API.SecurityTXT = new API.SecurityTXT(this);
390 workflows: API.Workflows = new API.Workflows(this);
391 resourceSharing: API.ResourceSharing = new API.ResourceSharing(this);
392 resourceTagging: API.ResourceTagging = new API.ResourceTagging(this);
393 leakedCredentialChecks: API.LeakedCredentialChecks = new API.LeakedCredentialChecks(this);
394 contentScanning: API.ContentScanning = new API.ContentScanning(this);
395 abuseReports: API.AbuseReports = new API.AbuseReports(this);
396 ai: API.AI = new API.AI(this);
397 aiSearch: API.AISearch = new API.AISearch(this);
398 securityCenter: API.SecurityCenter = new API.SecurityCenter(this);
399 browserRendering: API.BrowserRendering = new API.BrowserRendering(this);
400 customPages: API.CustomPages = new API.CustomPages(this);
401 secretsStore: API.SecretsStore = new API.SecretsStore(this);
402 pipelines: API.Pipelines = new API.Pipelines(this);
403 schemaValidation: API.SchemaValidation = new API.SchemaValidation(this);
404 tokenValidation: API.TokenValidation = new API.TokenValidation(this);
405
406 /**
407 * Check whether the base URL is set to its default.
408 */
409 #baseURLOverridden(): boolean {
410 return this.baseURL !== 'https://api.cloudflare.com/client/v4';
411 }
412
413 protected override defaultQuery(): Core.DefaultQuery | undefined {
414 return this._options.defaultQuery;
415 }
416
417 protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers {
418 return {
419 ...super.defaultHeaders(opts),
420 'X-Auth-Key': this.apiKey,
421 'X-Auth-Email': this.apiEmail,
422 ...this._options.defaultHeaders,
423 };
424 }
425
426 protected override validateHeaders(
427 headers: Core.Headers,
428 customHeaders: Core.Headers,
429 usingCustomFetch: boolean,
430 ) {
431 if (this.apiEmail && headers['x-auth-email']) {
432 return;
433 }
434 if (customHeaders['x-auth-email'] === null) {
435 return;
436 }
437
438 if (this.apiKey && headers['x-auth-key']) {
439 return;
440 }
441 if (customHeaders['x-auth-key'] === null) {
442 return;
443 }
444
445 if (this.apiToken && headers['authorization']) {
446 return;
447 }
448 if (customHeaders['authorization'] === null) {
449 return;
450 }
451
452 if (this.userServiceKey && headers['x-auth-user-service-key']) {
453 return;
454 }
455 if (customHeaders['x-auth-user-service-key'] === null) {
456 return;
457 }
458
459 // we can't check for the presence of the headers with a custom fetch implementation, so we shouldn't throw an error
460 if (usingCustomFetch) {
461 return;
462 }
463
464 throw new Error(
465 'Could not resolve authentication method. Expected one of apiEmail, apiKey, apiToken or userServiceKey to be set. Or for one of the "X-Auth-Email", "X-Auth-Key", "Authorization" or "X-Auth-User-Service-Key" headers to be explicitly omitted',
466 );
467 }
468
469 protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
470 const apiEmailAuth = this.apiEmailAuth(opts);
471 const apiKeyAuth = this.apiKeyAuth(opts);
472 const apiTokenAuth = this.apiTokenAuth(opts);
473 const userServiceKeyAuth = this.userServiceKeyAuth(opts);
474
475 if (
476 apiEmailAuth != null &&
477 !Core.isEmptyObj(apiEmailAuth) &&
478 apiKeyAuth != null &&
479 !Core.isEmptyObj(apiKeyAuth)
480 ) {
481 return { ...apiEmailAuth, ...apiKeyAuth };
482 }
483
484 if (apiTokenAuth != null && !Core.isEmptyObj(apiTokenAuth)) {
485 return apiTokenAuth;
486 }
487
488 if (userServiceKeyAuth != null && !Core.isEmptyObj(userServiceKeyAuth)) {
489 return userServiceKeyAuth;
490 }
491 return {};
492 }
493
494 protected apiEmailAuth(opts: Core.FinalRequestOptions): Core.Headers {
495 if (this.apiEmail == null) {
496 return {};
497 }
498 return { 'X-Auth-Email': this.apiEmail };
499 }
500
501 protected apiKeyAuth(opts: Core.FinalRequestOptions): Core.Headers {
502 if (this.apiKey == null) {
503 return {};
504 }
505 return { 'X-Auth-Key': this.apiKey };
506 }
507
508 protected apiTokenAuth(opts: Core.FinalRequestOptions): Core.Headers {
509 if (this.apiToken == null) {
510 return {};
511 }
512 return { Authorization: `Bearer ${this.apiToken}` };
513 }
514
515 protected userServiceKeyAuth(opts: Core.FinalRequestOptions): Core.Headers {
516 if (this.userServiceKey == null) {
517 return {};
518 }
519 return { 'X-Auth-User-Service-Key': this.userServiceKey };
520 }
521
522 protected override stringifyQuery(query: Record<string, unknown>): string {
523 return qs.stringify(query, { allowDots: true, arrayFormat: 'repeat' });
524 }
525
526 static Cloudflare = this;
527 static DEFAULT_TIMEOUT = 60000; // 1 minute
528
529 static CloudflareError = Errors.CloudflareError;
530 static APIError = Errors.APIError;
531 static APIConnectionError = Errors.APIConnectionError;
532 static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
533 static APIUserAbortError = Errors.APIUserAbortError;
534 static NotFoundError = Errors.NotFoundError;
535 static ConflictError = Errors.ConflictError;
536 static RateLimitError = Errors.RateLimitError;
537 static BadRequestError = Errors.BadRequestError;
538 static AuthenticationError = Errors.AuthenticationError;
539 static InternalServerError = Errors.InternalServerError;
540 static PermissionDeniedError = Errors.PermissionDeniedError;
541 static UnprocessableEntityError = Errors.UnprocessableEntityError;
542
543 static toFile = Uploads.toFile;
544 static fileFromPath = Uploads.fileFromPath;
545}
546
547Cloudflare.Accounts = Accounts;
548Cloudflare.Organizations = Organizations;
549Cloudflare.OriginCACertificates = OriginCACertificates;
550Cloudflare.IPs = IPs;
551Cloudflare.Memberships = Memberships;
552Cloudflare.User = User;
553Cloudflare.Zones = Zones;
554Cloudflare.LoadBalancers = LoadBalancers;
555Cloudflare.Cache = Cache;
556Cloudflare.SSL = SSL;
557Cloudflare.ACM = ACM;
558Cloudflare.Argo = Argo;
559Cloudflare.CertificateAuthorities = CertificateAuthorities;
560Cloudflare.ClientCertificates = ClientCertificates;
561Cloudflare.CustomCertificates = CustomCertificates;
562Cloudflare.CustomHostnames = CustomHostnames;
563Cloudflare.CustomNameservers = CustomNameservers;
564Cloudflare.DNSFirewall = DNSFirewall;
565Cloudflare.DNS = DNS;
566Cloudflare.EmailSecurity = EmailSecurity;
567Cloudflare.EmailRouting = EmailRouting;
568Cloudflare.EmailSending = EmailSending;
569Cloudflare.Filters = Filters;
570Cloudflare.Firewall = Firewall;
571Cloudflare.Healthchecks = Healthchecks;
572Cloudflare.KeylessCertificates = KeylessCertificates;
573Cloudflare.Logpush = Logpush;
574Cloudflare.Logs = Logs;
575Cloudflare.OriginTLSClientAuth = OriginTLSClientAuth;
576Cloudflare.PageRules = PageRules;
577Cloudflare.RateLimits = RateLimits;
578Cloudflare.WaitingRooms = WaitingRooms;
579Cloudflare.Web3 = Web3;
580Cloudflare.Workers = Workers;
581Cloudflare.KV = KV;
582Cloudflare.DurableObjects = DurableObjects;
583Cloudflare.Queues = Queues;
584Cloudflare.APIGateway = APIGateway;
585Cloudflare.ManagedTransforms = ManagedTransforms;
586Cloudflare.PageShield = PageShield;
587Cloudflare.Rulesets = Rulesets;
588Cloudflare.URLNormalization = URLNormalization;
589Cloudflare.Spectrum = Spectrum;
590Cloudflare.Addressing = Addressing;
591Cloudflare.AuditLogs = AuditLogs;
592Cloudflare.Billing = Billing;
593Cloudflare.BrandProtection = BrandProtection;
594Cloudflare.Diagnostics = Diagnostics;
595Cloudflare.Images = Images;
596Cloudflare.Intel = Intel;
597Cloudflare.MagicTransit = MagicTransit;
598Cloudflare.MagicNetworkMonitoring = MagicNetworkMonitoring;
599Cloudflare.MagicCloudNetworking = MagicCloudNetworking;
600Cloudflare.NetworkInterconnects = NetworkInterconnects;
601Cloudflare.MTLSCertificates = MTLSCertificates;
602Cloudflare.Pages = Pages;
603Cloudflare.Registrar = Registrar;
604Cloudflare.RequestTracers = RequestTracers;
605Cloudflare.Rules = Rules;
606Cloudflare.Stream = Stream;
607Cloudflare.Alerting = Alerting;
608Cloudflare.D1Resource = D1Resource;
609Cloudflare.R2 = R2;
610Cloudflare.R2DataCatalog = R2DataCatalog;
611Cloudflare.WorkersForPlatforms = WorkersForPlatforms;
612Cloudflare.ZeroTrust = ZeroTrust;
613Cloudflare.Turnstile = Turnstile;
614Cloudflare.Connectivity = Connectivity;
615Cloudflare.HyperdriveResource = HyperdriveResource;
616Cloudflare.RUM = RUM;
617Cloudflare.Vectorize = Vectorize;
618Cloudflare.URLScanner = URLScanner;
619Cloudflare.VulnerabilityScanner = VulnerabilityScanner;
620Cloudflare.Radar = Radar;
621Cloudflare.BotManagement = BotManagement;
622Cloudflare.Fraud = Fraud;
623Cloudflare.OriginPostQuantumEncryption = OriginPostQuantumEncryption;
624Cloudflare.GoogleTagGateway = GoogleTagGateway;
625Cloudflare.Zaraz = Zaraz;
626Cloudflare.Speed = Speed;
627Cloudflare.DCVDelegation = DCVDelegation;
628Cloudflare.Hostnames = Hostnames;
629Cloudflare.Snippets = Snippets;
630Cloudflare.RealtimeKit = RealtimeKit;
631Cloudflare.Calls = Calls;
632Cloudflare.CloudforceOne = CloudforceOne;
633Cloudflare.AIGateway = AIGateway;
634Cloudflare.IAM = IAM;
635Cloudflare.CloudConnector = CloudConnector;
636Cloudflare.BotnetFeed = BotnetFeed;
637Cloudflare.SecurityTXT = SecurityTXT;
638Cloudflare.Workflows = Workflows;
639Cloudflare.ResourceSharing = ResourceSharing;
640Cloudflare.ResourceTagging = ResourceTagging;
641Cloudflare.LeakedCredentialChecks = LeakedCredentialChecks;
642Cloudflare.ContentScanning = ContentScanning;
643Cloudflare.AbuseReports = AbuseReports;
644Cloudflare.AI = AI;
645Cloudflare.AISearch = AISearch;
646Cloudflare.SecurityCenter = SecurityCenter;
647Cloudflare.BrowserRendering = BrowserRendering;
648Cloudflare.CustomPages = CustomPages;
649Cloudflare.SecretsStore = SecretsStore;
650Cloudflare.Pipelines = Pipelines;
651Cloudflare.SchemaValidation = SchemaValidation;
652Cloudflare.TokenValidation = TokenValidation;
653
654export declare namespace Cloudflare {
655 export type RequestOptions = Core.RequestOptions;
656
657 export import V4PagePagination = Pagination.V4PagePagination;
658 export {
659 type V4PagePaginationParams as V4PagePaginationParams,
660 type V4PagePaginationResponse as V4PagePaginationResponse,
661 };
662
663 export import V4PagePaginationArray = Pagination.V4PagePaginationArray;
664 export {
665 type V4PagePaginationArrayParams as V4PagePaginationArrayParams,
666 type V4PagePaginationArrayResponse as V4PagePaginationArrayResponse,
667 };
668
669 export import CursorPagination = Pagination.CursorPagination;
670 export {
671 type CursorPaginationParams as CursorPaginationParams,
672 type CursorPaginationResponse as CursorPaginationResponse,
673 };
674
675 export import CursorPaginationAfter = Pagination.CursorPaginationAfter;
676 export {
677 type CursorPaginationAfterParams as CursorPaginationAfterParams,
678 type CursorPaginationAfterResponse as CursorPaginationAfterResponse,
679 };
680
681 export import CursorLimitPagination = Pagination.CursorLimitPagination;
682 export {
683 type CursorLimitPaginationParams as CursorLimitPaginationParams,
684 type CursorLimitPaginationResponse as CursorLimitPaginationResponse,
685 };
686
687 export import SinglePage = Pagination.SinglePage;
688 export { type SinglePageResponse as SinglePageResponse };
689
690 export { Accounts as Accounts };
691
692 export { Organizations as Organizations };
693
694 export { OriginCACertificates as OriginCACertificates };
695
696 export { IPs as IPs };
697
698 export { Memberships as Memberships };
699
700 export { User as User };
701
702 export { Zones as Zones };
703
704 export { LoadBalancers as LoadBalancers };
705
706 export { Cache as Cache };
707
708 export { SSL as SSL };
709
710 export { ACM as ACM };
711
712 export { Argo as Argo };
713
714 export { CertificateAuthorities as CertificateAuthorities };
715
716 export { ClientCertificates as ClientCertificates };
717
718 export { CustomCertificates as CustomCertificates };
719
720 export { CustomHostnames as CustomHostnames };
721
722 export { CustomNameservers as CustomNameservers };
723
724 export { DNSFirewall as DNSFirewall };
725
726 export { DNS as DNS };
727
728 export { EmailSecurity as EmailSecurity };
729
730 export { EmailRouting as EmailRouting };
731
732 export { EmailSending as EmailSending };
733
734 export { Filters as Filters };
735
736 export { Firewall as Firewall };
737
738 export { Healthchecks as Healthchecks };
739
740 export { KeylessCertificates as KeylessCertificates };
741
742 export { Logpush as Logpush };
743
744 export { Logs as Logs };
745
746 export { OriginTLSClientAuth as OriginTLSClientAuth };
747
748 export { PageRules as PageRules };
749
750 export { RateLimits as RateLimits };
751
752 export { WaitingRooms as WaitingRooms };
753
754 export { Web3 as Web3 };
755
756 export { Workers as Workers };
757
758 export { KV as KV };
759
760 export { DurableObjects as DurableObjects };
761
762 export { Queues as Queues };
763
764 export { APIGateway as APIGateway };
765
766 export { ManagedTransforms as ManagedTransforms };
767
768 export { PageShield as PageShield };
769
770 export { Rulesets as Rulesets };
771
772 export { URLNormalization as URLNormalization };
773
774 export { Spectrum as Spectrum };
775
776 export { Addressing as Addressing };
777
778 export { AuditLogs as AuditLogs };
779
780 export { Billing as Billing };
781
782 export { BrandProtection as BrandProtection };
783
784 export { Diagnostics as Diagnostics };
785
786 export { Images as Images };
787
788 export { Intel as Intel };
789
790 export { MagicTransit as MagicTransit };
791
792 export { MagicNetworkMonitoring as MagicNetworkMonitoring };
793
794 export { MagicCloudNetworking as MagicCloudNetworking };
795
796 export { NetworkInterconnects as NetworkInterconnects };
797
798 export { MTLSCertificates as MTLSCertificates };
799
800 export { Pages as Pages };
801
802 export { Registrar as Registrar };
803
804 export { RequestTracers as RequestTracers };
805
806 export { Rules as Rules };
807
808 export { Stream as Stream };
809
810 export { Alerting as Alerting };
811
812 export { D1Resource as D1Resource };
813
814 export { R2 as R2 };
815
816 export { R2DataCatalog as R2DataCatalog };
817
818 export { WorkersForPlatforms as WorkersForPlatforms };
819
820 export { ZeroTrust as ZeroTrust };
821
822 export { Turnstile as Turnstile };
823
824 export { Connectivity as Connectivity };
825
826 export { HyperdriveResource as HyperdriveResource };
827
828 export { RUM as RUM };
829
830 export { Vectorize as Vectorize };
831
832 export { URLScanner as URLScanner };
833
834 export { VulnerabilityScanner as VulnerabilityScanner };
835
836 export { Radar as Radar };
837
838 export { BotManagement as BotManagement };
839
840 export { Fraud as Fraud };
841
842 export { OriginPostQuantumEncryption as OriginPostQuantumEncryption };
843
844 export { GoogleTagGateway as GoogleTagGateway };
845
846 export { Zaraz as Zaraz };
847
848 export { Speed as Speed };
849
850 export { DCVDelegation as DCVDelegation };
851
852 export { Hostnames as Hostnames };
853
854 export { Snippets as Snippets };
855
856 export { RealtimeKit as RealtimeKit };
857
858 export { Calls as Calls };
859
860 export { CloudforceOne as CloudforceOne };
861
862 export { AIGateway as AIGateway };
863
864 export { IAM as IAM };
865
866 export { CloudConnector as CloudConnector };
867
868 export { BotnetFeed as BotnetFeed };
869
870 export { SecurityTXT as SecurityTXT };
871
872 export { Workflows as Workflows };
873
874 export { ResourceSharing as ResourceSharing };
875
876 export { ResourceTagging as ResourceTagging };
877
878 export { LeakedCredentialChecks as LeakedCredentialChecks };
879
880 export { ContentScanning as ContentScanning };
881
882 export { AbuseReports as AbuseReports };
883
884 export { AI as AI };
885
886 export { AISearch as AISearch };
887
888 export { SecurityCenter as SecurityCenter };
889
890 export { BrowserRendering as BrowserRendering };
891
892 export { CustomPages as CustomPages };
893
894 export { SecretsStore as SecretsStore };
895
896 export { Pipelines as Pipelines };
897
898 export { SchemaValidation as SchemaValidation };
899
900 export { TokenValidation as TokenValidation };
901
902 export type ASN = API.ASN;
903 export type AuditLog = API.AuditLog;
904 export type CertificateCA = API.CertificateCA;
905 export type CertificateRequestType = API.CertificateRequestType;
906 export type CloudflareTunnel = API.CloudflareTunnel;
907 export type ErrorData = API.ErrorData;
908 export type Identifier = API.Identifier;
909 export type LoadBalancerPreview = API.LoadBalancerPreview;
910 export type Member = API.Member;
911 export type PaginationInfo = API.PaginationInfo;
912 export type Permission = API.Permission;
913 export type PermissionGrant = API.PermissionGrant;
914 export type RatePlan = API.RatePlan;
915 export type ResponseInfo = API.ResponseInfo;
916 export type Result = API.Result;
917 export type Role = API.Role;
918 export type SortDirection = API.SortDirection;
919 export type Subscription = API.Subscription;
920 export type SubscriptionComponent = API.SubscriptionComponent;
921 export type SubscriptionZone = API.SubscriptionZone;
922 export type Token = API.Token;
923 export type TokenConditionCIDRList = API.TokenConditionCIDRList;
924 export type TokenPolicy = API.TokenPolicy;
925 export type TokenValue = API.TokenValue;
926}
927
928export { toFile, fileFromPath } from './uploads';
929export {
930 CloudflareError,
931 APIError,
932 APIConnectionError,
933 APIConnectionTimeoutError,
934 APIUserAbortError,
935 NotFoundError,
936 ConflictError,
937 RateLimitError,
938 BadRequestError,
939 AuthenticationError,
940 InternalServerError,
941 PermissionDeniedError,
942 UnprocessableEntityError,
943} from './error';
944
945export default Cloudflare;
946