cloudflare
Version:
The official TypeScript library for the Cloudflare API
140 lines • 5.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Healthchecks = exports.BaseHealthchecks = void 0;
const tslib_1 = require("../../internal/tslib.js");
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../core/resource.js");
const PreviewsAPI = tslib_1.__importStar(require("./previews.js"));
const previews_1 = require("./previews.js");
const pagination_1 = require("../../core/pagination.js");
const path_1 = require("../../internal/utils/path.js");
var BaseHealthchecks = /* @__PURE__ */ (() => {
class BaseHealthchecks extends resource_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/zones/${zone_id}/healthchecks`, (pagination_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/zones/${zone_id}/healthchecks/${healthcheckID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseHealthchecks._key = Object.freeze(['healthchecks']);
return BaseHealthchecks;
})();
exports.BaseHealthchecks = BaseHealthchecks;
var Healthchecks = /* @__PURE__ */ (() => {
class Healthchecks extends BaseHealthchecks {
constructor() {
super(...arguments);
this.previews = new PreviewsAPI.Previews(this._client);
}
}
Healthchecks.Previews = previews_1.Previews;
Healthchecks.BasePreviews = previews_1.BasePreviews;
return Healthchecks;
})();
exports.Healthchecks = Healthchecks;
//# sourceMappingURL=healthchecks.js.map