UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

148 lines 4.8 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../resource.mjs"; import { SinglePage } from "../../pagination.mjs"; export class MonitorGroups extends 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); } } export class MonitorGroupsSinglePage extends SinglePage { } MonitorGroups.MonitorGroupsSinglePage = MonitorGroupsSinglePage; //# sourceMappingURL=monitor-groups.mjs.map