cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v6.0.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/index.ts

925lines · modecode

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