UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

134 lines • 4.72 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import * as PreviewsAPI from "./previews.mjs"; import { BasePreviews, Previews, } from "./previews.mjs"; import { V4PagePaginationArray } from "../../core/pagination.mjs"; import { path } from "../../internal/utils/path.mjs"; export var BaseHealthchecks = /* @__PURE__ */ (() => { class BaseHealthchecks extends APIResource { /** * Create a new health check. * * @example * ```ts * const healthcheck = await client.healthchecks.create({ * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * address: 'www.example.com', * name: 'server-1', * }); * ``` */ create(params, options) { const { zone_id, ...body } = params; return this._client.post(path `/zones/${zone_id}/healthchecks`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Update a configured health check. * * @example * ```ts * const healthcheck = await client.healthchecks.update( * '023e105f4ecef8ad9ca31a8372d0c353', * { * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * address: 'www.example.com', * name: 'server-1', * }, * ); * ``` */ update(healthcheckID, params, options) { const { zone_id, ...body } = params; return this._client.put(path `/zones/${zone_id}/healthchecks/${healthcheckID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * List configured health checks. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const healthcheck of client.healthchecks.list({ * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * })) { * // ... * } * ``` */ list(params, options) { const { zone_id, ...query } = params; return this._client.getAPIList(path `/zones/${zone_id}/healthchecks`, (V4PagePaginationArray), { query, ...options, }); } /** * Delete a health check. * * @example * ```ts * const healthcheck = await client.healthchecks.delete( * '023e105f4ecef8ad9ca31a8372d0c353', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(healthcheckID, params, options) { const { zone_id } = params; return this._client.delete(path `/zones/${zone_id}/healthchecks/${healthcheckID}`, options)._thenUnwrap((obj) => obj.result); } /** * Patch a configured health check. * * @example * ```ts * const healthcheck = await client.healthchecks.edit( * '023e105f4ecef8ad9ca31a8372d0c353', * { * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * address: 'www.example.com', * name: 'server-1', * }, * ); * ``` */ edit(healthcheckID, params, options) { const { zone_id, ...body } = params; return this._client.patch(path `/zones/${zone_id}/healthchecks/${healthcheckID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Fetch a single configured health check. * * @example * ```ts * const healthcheck = await client.healthchecks.get( * '023e105f4ecef8ad9ca31a8372d0c353', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(healthcheckID, params, options) { const { zone_id } = params; return this._client.get(path `/zones/${zone_id}/healthchecks/${healthcheckID}`, options)._thenUnwrap((obj) => obj.result); } } BaseHealthchecks._key = Object.freeze(['healthchecks']); return BaseHealthchecks; })(); export var Healthchecks = /* @__PURE__ */ (() => { class Healthchecks extends BaseHealthchecks { constructor() { super(...arguments); this.previews = new PreviewsAPI.Previews(this._client); } } Healthchecks.Previews = Previews; Healthchecks.BasePreviews = BasePreviews; return Healthchecks; })(); //# sourceMappingURL=healthchecks.mjs.map