cloudflare
Version:
The official TypeScript library for the Cloudflare API
169 lines • 6.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MonitorGroups = exports.BaseMonitorGroups = 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 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 BaseMonitorGroups = /* @__PURE__ */ (() => {
class BaseMonitorGroups extends resource_1.APIResource {
/**
* Create a new monitor group.
*
* @example
* ```ts
* const monitorGroup =
* await client.loadBalancers.monitorGroups.create({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* description: 'Primary datacenter monitors',
* members: [
* {
* enabled: true,
* monitor_id: 'monitor_id',
* monitoring_only: false,
* must_be_healthy: true,
* },
* ],
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/load_balancers/monitor_groups`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Modify a configured monitor group.
*
* @example
* ```ts
* const monitorGroup =
* await client.loadBalancers.monitorGroups.update(
* '17b5962d775c646f3f9725cbc7a53df4',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* description: 'Primary datacenter monitors',
* members: [
* {
* enabled: true,
* monitor_id: 'monitor_id',
* monitoring_only: false,
* must_be_healthy: true,
* },
* ],
* },
* );
* ```
*/
update(monitorGroupID, params, options) {
const { account_id, ...body } = params;
return this._client.put((0, path_1.path) `/accounts/${account_id}/load_balancers/monitor_groups/${monitorGroupID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* List configured monitor groups.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const monitorGroup of client.loadBalancers.monitorGroups.list(
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id } = params;
return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/load_balancers/monitor_groups`, (pagination_1.SinglePage), options);
}
/**
* Delete a configured monitor group.
*
* @example
* ```ts
* const monitorGroup =
* await client.loadBalancers.monitorGroups.delete(
* '17b5962d775c646f3f9725cbc7a53df4',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(monitorGroupID, params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/load_balancers/monitor_groups/${monitorGroupID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Apply changes to an existing monitor group, overwriting the supplied properties.
*
* @example
* ```ts
* const monitorGroup =
* await client.loadBalancers.monitorGroups.edit(
* '17b5962d775c646f3f9725cbc7a53df4',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* description: 'Primary datacenter monitors',
* members: [
* {
* enabled: true,
* monitor_id: 'monitor_id',
* monitoring_only: false,
* must_be_healthy: true,
* },
* ],
* },
* );
* ```
*/
edit(monitorGroupID, params, options) {
const { account_id, ...body } = params;
return this._client.patch((0, path_1.path) `/accounts/${account_id}/load_balancers/monitor_groups/${monitorGroupID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Fetch a single configured monitor group.
*
* @example
* ```ts
* const monitorGroup =
* await client.loadBalancers.monitorGroups.get(
* '17b5962d775c646f3f9725cbc7a53df4',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(monitorGroupID, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/load_balancers/monitor_groups/${monitorGroupID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseMonitorGroups._key = Object.freeze([
'loadBalancers',
'monitorGroups',
]);
return BaseMonitorGroups;
})();
exports.BaseMonitorGroups = BaseMonitorGroups;
var MonitorGroups = /* @__PURE__ */ (() => {
class MonitorGroups extends BaseMonitorGroups {
constructor() {
super(...arguments);
this.references = new ReferencesAPI.References(this._client);
}
}
MonitorGroups.References = references_1.References;
MonitorGroups.BaseReferences = references_1.BaseReferences;
return MonitorGroups;
})();
exports.MonitorGroups = MonitorGroups;
//# sourceMappingURL=monitor-groups.js.map