UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

153 lines 5.05 kB
"use strict"; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. Object.defineProperty(exports, "__esModule", { value: true }); exports.MonitorGroupsSinglePage = exports.MonitorGroups = void 0; const resource_1 = require("../../resource.js"); const pagination_1 = require("../../pagination.js"); class MonitorGroups extends resource_1.APIResource { /** * Create a new monitor group. * * @example * ```ts * const monitorGroup = * await client.loadBalancers.monitorGroups.create({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * id: 'id', * 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(`/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', * id: 'id', * 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(`/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(`/accounts/${account_id}/load_balancers/monitor_groups`, MonitorGroupsSinglePage, 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(`/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', * id: 'id', * 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(`/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(`/accounts/${account_id}/load_balancers/monitor_groups/${monitorGroupId}`, options)._thenUnwrap((obj) => obj.result); } } exports.MonitorGroups = MonitorGroups; class MonitorGroupsSinglePage extends pagination_1.SinglePage { } exports.MonitorGroupsSinglePage = MonitorGroupsSinglePage; MonitorGroups.MonitorGroupsSinglePage = MonitorGroupsSinglePage; //# sourceMappingURL=monitor-groups.js.map