cloudflare
Version:
The official TypeScript library for the Cloudflare API
319 lines • 14.9 kB
text/typescript
import * as Core from "./core.js";
import * as Errors from "./error.js";
import { type Agent } from "./_shims/index.js";
import * as Uploads from "./uploads.js";
import * as Pagination from 'cloudflare/pagination';
import * as API from 'cloudflare/resources/index';
export interface ClientOptions {
/**
* Defaults to process.env['CLOUDFLARE_API_TOKEN'].
*/
apiToken?: string | null | undefined;
/**
* Defaults to process.env['CLOUDFLARE_API_KEY'].
*/
apiKey?: string | null | undefined;
/**
* Defaults to process.env['CLOUDFLARE_EMAIL'].
*/
apiEmail?: string | null | undefined;
/**
* Defaults to process.env['CLOUDFLARE_API_USER_SERVICE_KEY'].
*/
userServiceKey?: string | null | undefined;
/**
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
*
* Defaults to process.env['CLOUDFLARE_BASE_URL'].
*/
baseURL?: string | null | undefined;
/**
* The maximum amount of time (in milliseconds) that the client should wait for a response
* from the server before timing out a single request.
*
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
* much longer than this timeout before the promise succeeds or fails.
*/
timeout?: number;
/**
* An HTTP agent used to manage HTTP(S) connections.
*
* If not provided, an agent will be constructed by default in the Node.js environment,
* otherwise no agent is used.
*/
httpAgent?: Agent;
/**
* Specify a custom `fetch` function implementation.
*
* If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
* defined globally.
*/
fetch?: Core.Fetch | undefined;
/**
* The maximum number of times that the client will retry a request in case of a
* temporary failure, like a network error or a 5XX error from the server.
*
* @default 2
*/
maxRetries?: number;
/**
* Default headers to include with every request to the API.
*
* These can be removed in individual requests by explicitly setting the
* header to `undefined` or `null` in request options.
*/
defaultHeaders?: Core.Headers;
/**
* Default query parameters to include with every request to the API.
*
* These can be removed in individual requests by explicitly setting the
* param to `undefined` in request options.
*/
defaultQuery?: Core.DefaultQuery;
}
/** API Client for interfacing with the Cloudflare API. */
export declare class Cloudflare extends Core.APIClient {
apiToken: string | null;
apiKey: string | null;
apiEmail: string | null;
userServiceKey: string | null;
private _options;
/**
* API Client for interfacing with the Cloudflare API.
*
* @param {string | null | undefined} [opts.apiToken=process.env['CLOUDFLARE_API_TOKEN'] ?? null]
* @param {string | null | undefined} [opts.apiKey=process.env['CLOUDFLARE_API_KEY'] ?? null]
* @param {string | null | undefined} [opts.apiEmail=process.env['CLOUDFLARE_EMAIL'] ?? null]
* @param {string | null | undefined} [opts.userServiceKey=process.env['CLOUDFLARE_API_USER_SERVICE_KEY'] ?? null]
* @param {string} [opts.baseURL=process.env['CLOUDFLARE_BASE_URL'] ?? https://api.cloudflare.com/client/v4] - Override the default base URL for the API.
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
*/
constructor({ baseURL, apiToken, apiKey, apiEmail, userServiceKey, ...opts }?: ClientOptions);
accounts: API.Accounts;
originCACertificates: API.OriginCACertificates;
ips: API.IPs;
memberships: API.Memberships;
user: API.User;
zones: API.Zones;
loadBalancers: API.LoadBalancers;
cache: API.Cache;
ssl: API.SSL;
subscriptions: API.Subscriptions;
acm: API.ACM;
argo: API.Argo;
plans: API.Plans;
ratePlans: API.RatePlans;
certificateAuthorities: API.CertificateAuthorities;
clientCertificates: API.ClientCertificates;
customCertificates: API.CustomCertificates;
customHostnames: API.CustomHostnames;
customNameservers: API.CustomNameservers;
dns: API.DNS;
dnssec: API.DNSSECResource;
emailRouting: API.EmailRouting;
filters: API.Filters;
firewall: API.Firewall;
healthchecks: API.Healthchecks;
keylessCertificates: API.KeylessCertificates;
logpush: API.Logpush;
logs: API.Logs;
originTLSClientAuth: API.OriginTLSClientAuth;
pagerules: API.Pagerules;
rateLimits: API.RateLimits;
secondaryDNS: API.SecondaryDNS;
waitingRooms: API.WaitingRooms;
web3: API.Web3;
workers: API.Workers;
kv: API.KV;
durableObjects: API.DurableObjects;
queues: API.Queues;
managedHeaders: API.ManagedHeaders;
pageShield: API.PageShield;
rulesets: API.Rulesets;
urlNormalization: API.URLNormalization;
spectrum: API.Spectrum;
addressing: API.Addressing;
auditLogs: API.AuditLogs;
billing: API.Billing;
brandProtection: API.BrandProtection;
diagnostics: API.Diagnostics;
images: API.Images;
intel: API.Intel;
magicTransit: API.MagicTransit;
magicNetworkMonitoring: API.MagicNetworkMonitoring;
mtlsCertificates: API.MTLSCertificates;
pages: API.Pages;
pcaps: API.PCAPs;
registrar: API.Registrar;
requestTracers: API.RequestTracers;
rules: API.Rules;
storage: API.Storage;
stream: API.Stream;
alerting: API.Alerting;
d1: API.D1Resource;
r2: API.R2;
warpConnector: API.WARPConnector;
workersForPlatforms: API.WorkersForPlatforms;
zeroTrust: API.ZeroTrust;
challenges: API.Challenges;
hyperdrive: API.HyperdriveResource;
rum: API.RUM;
vectorize: API.Vectorize;
urlScanner: API.URLScanner;
radar: API.Radar;
botManagement: API.BotManagement;
originPostQuantumEncryption: API.OriginPostQuantumEncryption;
speed: API.Speed;
dcvDelegation: API.DCVDelegation;
hostnames: API.Hostnames;
snippets: API.Snippets;
calls: API.Calls;
cloudforceOne: API.CloudforceOne;
eventNotifications: API.EventNotifications;
protected defaultQuery(): Core.DefaultQuery | undefined;
protected defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers;
protected validateHeaders(headers: Core.Headers, customHeaders: Core.Headers): void;
protected authHeaders(opts: Core.FinalRequestOptions): Core.Headers;
protected apiEmailAuth(opts: Core.FinalRequestOptions): Core.Headers;
protected apiKeyAuth(opts: Core.FinalRequestOptions): Core.Headers;
protected apiTokenAuth(opts: Core.FinalRequestOptions): Core.Headers;
protected userServiceKeyAuth(opts: Core.FinalRequestOptions): Core.Headers;
protected stringifyQuery(query: Record<string, unknown>): string;
static Cloudflare: typeof Cloudflare;
static CloudflareError: typeof Errors.CloudflareError;
static APIError: typeof Errors.APIError;
static APIConnectionError: typeof Errors.APIConnectionError;
static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
static APIUserAbortError: typeof Errors.APIUserAbortError;
static NotFoundError: typeof Errors.NotFoundError;
static ConflictError: typeof Errors.ConflictError;
static RateLimitError: typeof Errors.RateLimitError;
static BadRequestError: typeof Errors.BadRequestError;
static AuthenticationError: typeof Errors.AuthenticationError;
static InternalServerError: typeof Errors.InternalServerError;
static PermissionDeniedError: typeof Errors.PermissionDeniedError;
static UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
static toFile: typeof Uploads.toFile;
static fileFromPath: typeof Uploads.fileFromPath;
}
export declare const CloudflareError: typeof Errors.CloudflareError, APIError: typeof Errors.APIError, APIConnectionError: typeof Errors.APIConnectionError, APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError, APIUserAbortError: typeof Errors.APIUserAbortError, NotFoundError: typeof Errors.NotFoundError, ConflictError: typeof Errors.ConflictError, RateLimitError: typeof Errors.RateLimitError, BadRequestError: typeof Errors.BadRequestError, AuthenticationError: typeof Errors.AuthenticationError, InternalServerError: typeof Errors.InternalServerError, PermissionDeniedError: typeof Errors.PermissionDeniedError, UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
export import toFile = Uploads.toFile;
export import fileFromPath = Uploads.fileFromPath;
export declare namespace Cloudflare {
export import RequestOptions = Core.RequestOptions;
export import V4PagePagination = Pagination.V4PagePagination;
export import V4PagePaginationParams = Pagination.V4PagePaginationParams;
export import V4PagePaginationResponse = Pagination.V4PagePaginationResponse;
export import V4PagePaginationArray = Pagination.V4PagePaginationArray;
export import V4PagePaginationArrayParams = Pagination.V4PagePaginationArrayParams;
export import V4PagePaginationArrayResponse = Pagination.V4PagePaginationArrayResponse;
export import CursorPagination = Pagination.CursorPagination;
export import CursorPaginationParams = Pagination.CursorPaginationParams;
export import CursorPaginationResponse = Pagination.CursorPaginationResponse;
export import CursorLimitPagination = Pagination.CursorLimitPagination;
export import CursorLimitPaginationParams = Pagination.CursorLimitPaginationParams;
export import CursorLimitPaginationResponse = Pagination.CursorLimitPaginationResponse;
export import SinglePage = Pagination.SinglePage;
export import SinglePageResponse = Pagination.SinglePageResponse;
export import Accounts = API.Accounts;
export import OriginCACertificates = API.OriginCACertificates;
export import IPs = API.IPs;
export import Memberships = API.Memberships;
export import User = API.User;
export import Zones = API.Zones;
export import LoadBalancers = API.LoadBalancers;
export import Cache = API.Cache;
export import SSL = API.SSL;
export import Subscriptions = API.Subscriptions;
export import ACM = API.ACM;
export import Argo = API.Argo;
export import Plans = API.Plans;
export import RatePlans = API.RatePlans;
export import CertificateAuthorities = API.CertificateAuthorities;
export import ClientCertificates = API.ClientCertificates;
export import CustomCertificates = API.CustomCertificates;
export import CustomHostnames = API.CustomHostnames;
export import CustomNameservers = API.CustomNameservers;
export import DNS = API.DNS;
export import DNSSECResource = API.DNSSECResource;
export import EmailRouting = API.EmailRouting;
export import Filters = API.Filters;
export import Firewall = API.Firewall;
export import Healthchecks = API.Healthchecks;
export import KeylessCertificates = API.KeylessCertificates;
export import Logpush = API.Logpush;
export import Logs = API.Logs;
export import OriginTLSClientAuth = API.OriginTLSClientAuth;
export import Pagerules = API.Pagerules;
export import RateLimits = API.RateLimits;
export import SecondaryDNS = API.SecondaryDNS;
export import WaitingRooms = API.WaitingRooms;
export import Web3 = API.Web3;
export import Workers = API.Workers;
export import KV = API.KV;
export import DurableObjects = API.DurableObjects;
export import Queues = API.Queues;
export import ManagedHeaders = API.ManagedHeaders;
export import PageShield = API.PageShield;
export import Rulesets = API.Rulesets;
export import URLNormalization = API.URLNormalization;
export import Spectrum = API.Spectrum;
export import Addressing = API.Addressing;
export import AuditLogs = API.AuditLogs;
export import Billing = API.Billing;
export import BrandProtection = API.BrandProtection;
export import Diagnostics = API.Diagnostics;
export import Images = API.Images;
export import Intel = API.Intel;
export import MagicTransit = API.MagicTransit;
export import MagicNetworkMonitoring = API.MagicNetworkMonitoring;
export import MTLSCertificates = API.MTLSCertificates;
export import Pages = API.Pages;
export import PCAPs = API.PCAPs;
export import Registrar = API.Registrar;
export import RequestTracers = API.RequestTracers;
export import Rules = API.Rules;
export import Storage = API.Storage;
export import Stream = API.Stream;
export import Alerting = API.Alerting;
export import D1Resource = API.D1Resource;
export import R2 = API.R2;
export import WARPConnector = API.WARPConnector;
export import WorkersForPlatforms = API.WorkersForPlatforms;
export import ZeroTrust = API.ZeroTrust;
export import Challenges = API.Challenges;
export import HyperdriveResource = API.HyperdriveResource;
export import RUM = API.RUM;
export import Vectorize = API.Vectorize;
export import URLScanner = API.URLScanner;
export import Radar = API.Radar;
export import BotManagement = API.BotManagement;
export import OriginPostQuantumEncryption = API.OriginPostQuantumEncryption;
export import Speed = API.Speed;
export import DCVDelegation = API.DCVDelegation;
export import Hostnames = API.Hostnames;
export import Snippets = API.Snippets;
export import Calls = API.Calls;
export import CloudforceOne = API.CloudforceOne;
export import EventNotifications = API.EventNotifications;
export import ASN = API.ASN;
export import AuditLog = API.AuditLog;
export import CloudflareTunnel = API.CloudflareTunnel;
export import ErrorData = API.ErrorData;
export import Identifier = API.Identifier;
export import LoadBalancerPreview = API.LoadBalancerPreview;
export import Member = API.Member;
export import PaginationInfo = API.PaginationInfo;
export import Permission = API.Permission;
export import PermissionGrant = API.PermissionGrant;
export import ResponseInfo = API.ResponseInfo;
export import Result = API.Result;
export import Role = API.Role;
}
export default Cloudflare;
//# sourceMappingURL=index.d.ts.map