// AUTO-GENERATED by scripts/generate.ts from .generated-specs. Do not edit. import * as S from "@distilled.cloud/core/schema"; import * as API from "@distilled.cloud/core/api"; import * as T from "../traits.ts"; import { CloudflareProtocol, CloudflarePaginatedProtocol, type CloudflareOpError, type CloudflareOpContext, } from "../protocol.ts"; import { cloudflarePaginate, ResultInfo } from "../pagination.ts"; import { CloudflareError, CloudflareRateLimited } from "../errors.ts"; import * as Retry from "../retry.ts"; export type { CloudflareOpError, CloudflareOpContext }; /** Fallback camelCase→wire mapping for opaque content (mined from the distilled SDK). */ const KEY_DICTIONARY: Record> = { checkType: "check_type", documentationUrl: "documentation_url", maxRttMs: "max_rtt_ms", maxTtl: "max_ttl", meanRttMs: "mean_rtt_ms", minRttMs: "min_rtt_ms", packetCount: "packet_count", packetType: "packet_type", packetsLost: "packets_lost", packetsPerTtl: "packets_per_ttl", packetsSent: "packets_sent", packetsTtl: "packets_ttl", stdDevRttMs: "std_dev_rtt_ms", targetSummary: "target_summary", tracerouteTimeMs: "traceroute_time_ms", waitTime: "wait_time", }; export class EndpointHealthcheckNotFound extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()( "EndpointHealthcheckNotFound", { code: S.Number, message: S.String, }, ), [{ code: 1022 }], ) {} export class Forbidden extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()("Forbidden", { code: S.Number, message: S.String, }), [{ status: 403 }], ) {} export class InvalidHealthcheckEndpoint extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()( "InvalidHealthcheckEndpoint", { code: S.Number, message: S.String, }, ), [{ code: 1002 }], ) {} export type EndpointHealthchecksCreateRequestCheckType = "icmp"; export const EndpointHealthchecksCreateRequestCheckType = /*@__PURE__*/ S.String; export interface CreateEndpointHealthcheckRequest { /** Identifier */ accountId: string; /** type of check to perform */ checkType: EndpointHealthchecksCreateRequestCheckType | (string & {}); /** the IP address of the host to perform checks against */ endpoint: string; /** Optional name associated with this check */ name?: string; } export const CreateEndpointHealthcheckRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), checkType: EndpointHealthchecksCreateRequestCheckType.pipe( T.Body("check_type"), ), endpoint: S.String, name: S.optional(S.String), }) .pipe( T.Http({ method: "POST", uri: "/accounts/{account_id}/diagnostics/endpoint-healthchecks", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "CreateEndpointHealthcheckRequest", }) as any as S.Schema; export type EndpointHealthchecksCreateResponseCheckType = "icmp"; export const EndpointHealthchecksCreateResponseCheckType = /*@__PURE__*/ S.String; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface CreateEndpointHealthcheckResponse { /** type of check to perform */ checkType: EndpointHealthchecksCreateResponseCheckType; /** the IP address of the host to perform checks against */ endpoint: string; /** UUID. */ id?: string | null; /** Optional name associated with this check */ name?: string | null; } export const CreateEndpointHealthcheckResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ checkType: EndpointHealthchecksCreateResponseCheckType.pipe( T.Body("check_type"), ), endpoint: S.String, id: S.optional(S.NullOr(S.String)), name: S.optional(S.NullOr(S.String)), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "CreateEndpointHealthcheckResponse", }) as any as S.Schema; export type TraceroutesCreateRequestTargetsList = Array; export const TraceroutesCreateRequestTargetsList = /*@__PURE__*/ S.Array( S.String, ) as any as S.Schema; export type TraceroutesCreateRequestColosList = Array; export const TraceroutesCreateRequestColosList = /*@__PURE__*/ S.Array( S.String, ) as any as S.Schema; export type TraceroutesCreateRequestOptionsPacketType = | "icmp" | "tcp" | "udp" | "gre" | "gre+icmp"; export const TraceroutesCreateRequestOptionsPacketType = /*@__PURE__*/ S.String; export interface TraceroutesCreateRequestOptions { /** Max TTL. */ maxTtl?: number; /** Type of packet sent. */ packetType?: TraceroutesCreateRequestOptionsPacketType | (string & {}); /** Number of packets sent at each TTL. */ packetsPerTtl?: number; /** For UDP and TCP, specifies the destination port. For ICMP, specifies the initial ICMP sequence value. Default value 0 will choose the best value to use for each protocol. */ port?: number; /** Set the time (in seconds) to wait for a response to a probe. */ waitTime?: number; } export const TraceroutesCreateRequestOptions = /*@__PURE__*/ S.suspend(() => S.Struct({ maxTtl: S.optional(S.Number.pipe(T.Body("max_ttl"))), packetType: S.optional( TraceroutesCreateRequestOptionsPacketType.pipe(T.Body("packet_type")), ), packetsPerTtl: S.optional(S.Number.pipe(T.Body("packets_per_ttl"))), port: S.optional(S.Number), waitTime: S.optional(S.Number.pipe(T.Body("wait_time"))), }), ).annotate({ identifier: "TraceroutesCreateRequestOptions", }) as any as S.Schema; export interface CreateTracerouteRequest { /** Identifier */ accountId: string; targets: TraceroutesCreateRequestTargetsList; /** If no source colo names specified, all colos will be used. China colos are unavailable for traceroutes. */ colos?: TraceroutesCreateRequestColosList; options?: TraceroutesCreateRequestOptions; } export const CreateTracerouteRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), targets: TraceroutesCreateRequestTargetsList, colos: S.optional(TraceroutesCreateRequestColosList), options: S.optional(TraceroutesCreateRequestOptions), }) .pipe( T.Http({ method: "POST", uri: "/accounts/{account_id}/diagnostics/traceroute", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "CreateTracerouteRequest", }) as any as S.Schema; export interface TraceroutesCreateResultItemColosItemColo { /** Source colo city. */ city?: string | null; /** Source colo name. */ name?: string | null; } export const TraceroutesCreateResultItemColosItemColo = /*@__PURE__*/ S.suspend( () => S.Struct({ city: S.optional(S.NullOr(S.String)), name: S.optional(S.NullOr(S.String)), }), ).annotate({ identifier: "TraceroutesCreateResultItemColosItemColo", }) as any as S.Schema; export type TraceroutesCreateResultItemColosItemError = | "" | "Could not gather traceroute data: Code 1" | "Could not gather traceroute data: Code 2" | "Could not gather traceroute data: Code 3" | "Could not gather traceroute data: Code 4"; export const TraceroutesCreateResultItemColosItemError = /*@__PURE__*/ S.String; export type TraceroutesCreateResultItemColosItemHopsItemNodesItemLabelsList = Array; export const TraceroutesCreateResultItemColosItemHopsItemNodesItemLabelsList = /*@__PURE__*/ S.Array( S.String, ) as any as S.Schema; export interface TraceroutesCreateResultItemColosItemHopsItemNodesItem { /** AS number associated with the node object. */ asn?: string | null; /** IP address of the node. */ ip?: string | null; /** Field appears if there is an additional annotation printed when the probe returns. Field also appears when running a GRE+ICMP traceroute to denote which traceroute a node comes from. */ labels?: TraceroutesCreateResultItemColosItemHopsItemNodesItemLabelsList | null; /** Maximum RTT in ms. */ maxRttMs?: number | null; /** Mean RTT in ms. */ meanRttMs?: number | null; /** Minimum RTT in ms. */ minRttMs?: number | null; /** Host name of the address, this may be the same as the IP address. */ name?: string | null; /** Number of packets with a response from this node. */ packetCount?: number | null; /** Standard deviation of the RTTs in ms. */ stdDevRttMs?: number | null; } export const TraceroutesCreateResultItemColosItemHopsItemNodesItem = /*@__PURE__*/ S.suspend(() => S.Struct({ asn: S.optional(S.NullOr(S.String)), ip: S.optional(S.NullOr(S.String)), labels: S.optional( S.NullOr( TraceroutesCreateResultItemColosItemHopsItemNodesItemLabelsList, ), ), maxRttMs: S.optional(S.NullOr(S.Number).pipe(T.Body("max_rtt_ms"))), meanRttMs: S.optional(S.NullOr(S.Number).pipe(T.Body("mean_rtt_ms"))), minRttMs: S.optional(S.NullOr(S.Number).pipe(T.Body("min_rtt_ms"))), name: S.optional(S.NullOr(S.String)), packetCount: S.optional(S.NullOr(S.Number).pipe(T.Body("packet_count"))), stdDevRttMs: S.optional( S.NullOr(S.Number).pipe(T.Body("std_dev_rtt_ms")), ), }), ).annotate({ identifier: "TraceroutesCreateResultItemColosItemHopsItemNodesItem", }) as any as S.Schema; export type TraceroutesCreateResultItemColosItemHopsItemNodesList = Array; export const TraceroutesCreateResultItemColosItemHopsItemNodesList = /*@__PURE__*/ S.Array( TraceroutesCreateResultItemColosItemHopsItemNodesItem, ) as any as S.Schema; export interface TraceroutesCreateResultItemColosItemHopsItem { /** An array of node objects. */ nodes?: TraceroutesCreateResultItemColosItemHopsItemNodesList | null; /** Number of packets where no response was received. */ packetsLost?: number | null; /** Number of packets sent with specified TTL. */ packetsSent?: number | null; /** The time to live (TTL). */ packetsTtl?: number | null; } export const TraceroutesCreateResultItemColosItemHopsItem = /*@__PURE__*/ S.suspend(() => S.Struct({ nodes: S.optional( S.NullOr(TraceroutesCreateResultItemColosItemHopsItemNodesList), ), packetsLost: S.optional(S.NullOr(S.Number).pipe(T.Body("packets_lost"))), packetsSent: S.optional(S.NullOr(S.Number).pipe(T.Body("packets_sent"))), packetsTtl: S.optional(S.NullOr(S.Number).pipe(T.Body("packets_ttl"))), }), ).annotate({ identifier: "TraceroutesCreateResultItemColosItemHopsItem", }) as any as S.Schema; export type TraceroutesCreateResultItemColosItemHopsList = Array; export const TraceroutesCreateResultItemColosItemHopsList = /*@__PURE__*/ S.Array( TraceroutesCreateResultItemColosItemHopsItem, ) as any as S.Schema; export interface TraceroutesCreateResultItemColosItem { colo?: TraceroutesCreateResultItemColosItemColo | null; /** Errors resulting from collecting traceroute from colo to target. */ error?: TraceroutesCreateResultItemColosItemError | null; hops?: TraceroutesCreateResultItemColosItemHopsList | null; /** Aggregated statistics from all hops about the target. */ targetSummary?: unknown | null; /** Total time of traceroute in ms. */ tracerouteTimeMs?: number | null; } export const TraceroutesCreateResultItemColosItem = /*@__PURE__*/ S.suspend( () => S.Struct({ colo: S.optional(S.NullOr(TraceroutesCreateResultItemColosItemColo)), error: S.optional(S.NullOr(TraceroutesCreateResultItemColosItemError)), hops: S.optional(S.NullOr(TraceroutesCreateResultItemColosItemHopsList)), targetSummary: S.optional( S.NullOr(S.Unknown).pipe(T.Body("target_summary")), ), tracerouteTimeMs: S.optional( S.NullOr(S.Number).pipe(T.Body("traceroute_time_ms")), ), }), ).annotate({ identifier: "TraceroutesCreateResultItemColosItem", }) as any as S.Schema; export type TraceroutesCreateResultItemColosList = Array; export const TraceroutesCreateResultItemColosList = /*@__PURE__*/ S.Array( TraceroutesCreateResultItemColosItem, ) as any as S.Schema; export interface TraceroutesCreateResultItem { colos?: TraceroutesCreateResultItemColosList | null; /** The target hostname, IPv6, or IPv6 address. */ target?: string | null; } export const TraceroutesCreateResultItem = /*@__PURE__*/ S.suspend(() => S.Struct({ colos: S.optional(S.NullOr(TraceroutesCreateResultItemColosList)), target: S.optional(S.NullOr(S.String)), }), ).annotate({ identifier: "TraceroutesCreateResultItem", }) as any as S.Schema; export type TraceroutesCreateResultList = Array; export const TraceroutesCreateResultList = /*@__PURE__*/ S.Array( TraceroutesCreateResultItem, ) as any as S.Schema; export interface CreateTracerouteResponse { /** The unwrapped `result` payload of the v4 response envelope. */ result: TraceroutesCreateResultList; /** Pagination info from the envelope's `result_info`. */ resultInfo?: ResultInfo | null; } export const CreateTracerouteResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ result: TraceroutesCreateResultList.pipe(T.EnvelopePayload()), resultInfo: S.optional(S.NullOr(ResultInfo).pipe(T.ResultInfo())), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "CreateTracerouteResponse", }) as any as S.Schema; export interface DeleteEndpointHealthcheckRequest { /** Identifier */ accountId: string; /** UUID. */ id: string; } export const DeleteEndpointHealthcheckRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), id: S.String.pipe(T.Label()), }) .pipe( T.Http({ method: "DELETE", uri: "/accounts/{account_id}/diagnostics/endpoint-healthchecks/{id}", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "DeleteEndpointHealthcheckRequest", }) as any as S.Schema; export interface DeleteEndpointHealthcheckResponse {} export const DeleteEndpointHealthcheckResponse = /*@__PURE__*/ S.suspend(() => S.Struct({}).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "DeleteEndpointHealthcheckResponse", }) as any as S.Schema; export interface GetEndpointHealthcheckRequest { /** Identifier */ accountId: string; /** UUID. */ id: string; } export const GetEndpointHealthcheckRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), id: S.String.pipe(T.Label()), }) .pipe( T.Http({ method: "GET", uri: "/accounts/{account_id}/diagnostics/endpoint-healthchecks/{id}", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "GetEndpointHealthcheckRequest", }) as any as S.Schema; export type EndpointHealthchecksGetResponseCheckType = "icmp"; export const EndpointHealthchecksGetResponseCheckType = /*@__PURE__*/ S.String; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface GetEndpointHealthcheckResponse { /** type of check to perform */ checkType: EndpointHealthchecksGetResponseCheckType; /** the IP address of the host to perform checks against */ endpoint: string; /** UUID. */ id?: string | null; /** Optional name associated with this check */ name?: string | null; } export const GetEndpointHealthcheckResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ checkType: EndpointHealthchecksGetResponseCheckType.pipe( T.Body("check_type"), ), endpoint: S.String, id: S.optional(S.NullOr(S.String)), name: S.optional(S.NullOr(S.String)), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "GetEndpointHealthcheckResponse", }) as any as S.Schema; export interface ListEndpointHealthchecksRequest { /** Identifier */ accountId: string; } export const ListEndpointHealthchecksRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), }) .pipe( T.Http({ method: "GET", uri: "/accounts/{account_id}/diagnostics/endpoint-healthchecks", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "ListEndpointHealthchecksRequest", }) as any as S.Schema; export type EndpointHealthchecksListResponseCheckType = "icmp"; export const EndpointHealthchecksListResponseCheckType = /*@__PURE__*/ S.String; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface ListEndpointHealthchecksItem { /** type of check to perform */ checkType: EndpointHealthchecksListResponseCheckType; /** the IP address of the host to perform checks against */ endpoint: string; /** UUID. */ id?: string | null; /** Optional name associated with this check */ name?: string | null; } export const ListEndpointHealthchecksItem = /*@__PURE__*/ S.suspend(() => S.Struct({ checkType: EndpointHealthchecksListResponseCheckType.pipe( T.Body("check_type"), ), endpoint: S.String, id: S.optional(S.NullOr(S.String)), name: S.optional(S.NullOr(S.String)), }), ).annotate({ identifier: "ListEndpointHealthchecksItem", }) as any as S.Schema; export type ListEndpointHealthchecksItemsList = Array; export const ListEndpointHealthchecksItemsList = /*@__PURE__*/ S.Array( ListEndpointHealthchecksItem, ) as any as S.Schema; export type ListEndpointHealthchecksResponse = ListEndpointHealthchecksItemsList; export const ListEndpointHealthchecksResponse = /*@__PURE__*/ S.suspend(() => ListEndpointHealthchecksItemsList.pipe( T.EnvelopePayloadRoot(), T.KeyDictionary(KEY_DICTIONARY), ), ).annotate({ identifier: "ListEndpointHealthchecksResponse", }) as any as S.Schema; export type EndpointHealthchecksUpdateRequestCheckType = "icmp"; export const EndpointHealthchecksUpdateRequestCheckType = /*@__PURE__*/ S.String; export interface UpdateEndpointHealthcheckRequest { /** Identifier */ accountId: string; /** UUID. */ id: string; /** type of check to perform */ checkType: EndpointHealthchecksUpdateRequestCheckType | (string & {}); /** the IP address of the host to perform checks against */ endpoint: string; /** Optional name associated with this check */ name?: string; } export const UpdateEndpointHealthcheckRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), id: S.String.pipe(T.Label()), checkType: EndpointHealthchecksUpdateRequestCheckType.pipe( T.Body("check_type"), ), endpoint: S.String, name: S.optional(S.String), }) .pipe( T.Http({ method: "PUT", uri: "/accounts/{account_id}/diagnostics/endpoint-healthchecks/{id}", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "UpdateEndpointHealthcheckRequest", }) as any as S.Schema; export type EndpointHealthchecksUpdateResponseCheckType = "icmp"; export const EndpointHealthchecksUpdateResponseCheckType = /*@__PURE__*/ S.String; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface UpdateEndpointHealthcheckResponse { /** type of check to perform */ checkType: EndpointHealthchecksUpdateResponseCheckType; /** the IP address of the host to perform checks against */ endpoint: string; /** UUID. */ id?: string | null; /** Optional name associated with this check */ name?: string | null; } export const UpdateEndpointHealthcheckResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ checkType: EndpointHealthchecksUpdateResponseCheckType.pipe( T.Body("check_type"), ), endpoint: S.String, id: S.optional(S.NullOr(S.String)), name: S.optional(S.NullOr(S.String)), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "UpdateEndpointHealthcheckResponse", }) as any as S.Schema; export type CreateEndpointHealthcheckError = | InvalidHealthcheckEndpoint | Forbidden | CloudflareOpError; /** Create Endpoint Health Check. */ export const createEndpointHealthcheck: API.OperationMethod< CreateEndpointHealthcheckRequest, CreateEndpointHealthcheckResponse, CreateEndpointHealthcheckError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: CreateEndpointHealthcheckRequest, output: CreateEndpointHealthcheckResponse, errors: [ InvalidHealthcheckEndpoint, Forbidden, CloudflareRateLimited, CloudflareError, ], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type CreateTracerouteError = CloudflareOpError; /** Run traceroutes from Cloudflare colos. */ export const createTraceroute: API.PaginatedOperationMethod< CreateTracerouteRequest, CreateTracerouteResponse, CreateTracerouteError, CloudflareOpContext, TraceroutesCreateResultItem > = /*@__PURE__*/ API.makePaginated( () => ({ input: CreateTracerouteRequest, output: CreateTracerouteResponse, errors: [CloudflareRateLimited, CloudflareError], protocol: CloudflarePaginatedProtocol, retry: Retry.Retry, pagination: { mode: "single", items: "result" } as const, }), cloudflarePaginate, ) as any; export type DeleteEndpointHealthcheckError = | EndpointHealthcheckNotFound | Forbidden | CloudflareOpError; /** Delete Endpoint Health Check. */ export const deleteEndpointHealthcheck: API.OperationMethod< DeleteEndpointHealthcheckRequest, DeleteEndpointHealthcheckResponse, DeleteEndpointHealthcheckError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: DeleteEndpointHealthcheckRequest, output: DeleteEndpointHealthcheckResponse, errors: [ EndpointHealthcheckNotFound, Forbidden, CloudflareRateLimited, CloudflareError, ], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type GetEndpointHealthcheckError = | EndpointHealthcheckNotFound | Forbidden | CloudflareOpError; /** Get a single Endpoint Health Check. */ export const getEndpointHealthcheck: API.OperationMethod< GetEndpointHealthcheckRequest, GetEndpointHealthcheckResponse, GetEndpointHealthcheckError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: GetEndpointHealthcheckRequest, output: GetEndpointHealthcheckResponse, errors: [ EndpointHealthcheckNotFound, Forbidden, CloudflareRateLimited, CloudflareError, ], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type ListEndpointHealthchecksError = Forbidden | CloudflareOpError; /** List Endpoint Health Checks. */ export const listEndpointHealthchecks: API.OperationMethod< ListEndpointHealthchecksRequest, ListEndpointHealthchecksResponse, ListEndpointHealthchecksError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: ListEndpointHealthchecksRequest, output: ListEndpointHealthchecksResponse, errors: [Forbidden, CloudflareRateLimited, CloudflareError], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type UpdateEndpointHealthcheckError = | EndpointHealthcheckNotFound | InvalidHealthcheckEndpoint | Forbidden | CloudflareOpError; /** Update a Endpoint Health Check. */ export const updateEndpointHealthcheck: API.OperationMethod< UpdateEndpointHealthcheckRequest, UpdateEndpointHealthcheckResponse, UpdateEndpointHealthcheckError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: UpdateEndpointHealthcheckRequest, output: UpdateEndpointHealthcheckResponse, errors: [ EndpointHealthcheckNotFound, InvalidHealthcheckEndpoint, Forbidden, CloudflareRateLimited, CloudflareError, ], protocol: CloudflareProtocol, retry: Retry.Retry, }));