UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

163 lines • 5.94 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import * as ReferencesAPI from "./references.mjs"; import { BaseReferences, References, } from "./references.mjs"; import { SinglePage } from "../../../core/pagination.mjs"; import { path } from "../../../internal/utils/path.mjs"; export var BaseMonitorGroups = /* @__PURE__ */ (() => { class BaseMonitorGroups extends 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(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(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(path `/accounts/${account_id}/load_balancers/monitor_groups`, (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(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(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(path `/accounts/${account_id}/load_balancers/monitor_groups/${monitorGroupID}`, options)._thenUnwrap((obj) => obj.result); } } BaseMonitorGroups._key = Object.freeze([ 'loadBalancers', 'monitorGroups', ]); return BaseMonitorGroups; })(); export var MonitorGroups = /* @__PURE__ */ (() => { class MonitorGroups extends BaseMonitorGroups { constructor() { super(...arguments); this.references = new ReferencesAPI.References(this._client); } } MonitorGroups.References = References; MonitorGroups.BaseReferences = BaseReferences; return MonitorGroups; })(); //# sourceMappingURL=monitor-groups.mjs.map