cloudflare
Version:
The official TypeScript library for the Cloudflare API
138 lines • 5.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Monitors = exports.BaseMonitors = 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 ReferencesAPI = tslib_1.__importStar(require("./references.js"));
const references_1 = require("./references.js");
const pagination_1 = require("../../../core/pagination.js");
const path_1 = require("../../../internal/utils/path.js");
var BaseMonitors = /* @__PURE__ */ (() => {
class BaseMonitors extends resource_1.APIResource {
/**
* Create a configured monitor.
*
* @example
* ```ts
* const monitor = await client.loadBalancers.monitors.create({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/load_balancers/monitors`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Modify a configured monitor.
*
* @example
* ```ts
* const monitor = await client.loadBalancers.monitors.update(
* 'f1aba936b94213e5b8dca0c0dbf1f9cc',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
update(monitorID, params, options) {
const { account_id, ...body } = params;
return this._client.put((0, path_1.path) `/accounts/${account_id}/load_balancers/monitors/${monitorID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* List configured monitors for an account.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const monitor of client.loadBalancers.monitors.list(
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id } = params;
return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/load_balancers/monitors`, (pagination_1.SinglePage), options);
}
/**
* Delete a configured monitor.
*
* @example
* ```ts
* const monitor = await client.loadBalancers.monitors.delete(
* 'f1aba936b94213e5b8dca0c0dbf1f9cc',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(monitorID, params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/load_balancers/monitors/${monitorID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Apply changes to an existing monitor, overwriting the supplied properties.
*
* @example
* ```ts
* const monitor = await client.loadBalancers.monitors.edit(
* 'f1aba936b94213e5b8dca0c0dbf1f9cc',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
edit(monitorID, params, options) {
const { account_id, ...body } = params;
return this._client.patch((0, path_1.path) `/accounts/${account_id}/load_balancers/monitors/${monitorID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* List a single configured monitor for an account.
*
* @example
* ```ts
* const monitor = await client.loadBalancers.monitors.get(
* 'f1aba936b94213e5b8dca0c0dbf1f9cc',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(monitorID, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/load_balancers/monitors/${monitorID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseMonitors._key = Object.freeze([
'loadBalancers',
'monitors',
]);
return BaseMonitors;
})();
exports.BaseMonitors = BaseMonitors;
var Monitors = /* @__PURE__ */ (() => {
class Monitors extends BaseMonitors {
constructor() {
super(...arguments);
this.previews = new PreviewsAPI.Previews(this._client);
this.references = new ReferencesAPI.References(this._client);
}
}
Monitors.Previews = previews_1.Previews;
Monitors.BasePreviews = previews_1.BasePreviews;
Monitors.References = references_1.References;
Monitors.BaseReferences = references_1.BaseReferences;
return Monitors;
})();
exports.Monitors = Monitors;
//# sourceMappingURL=monitors.js.map