UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

140 lines • 5.23 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import * as AdvertisementsAPI from "./advertisements.mjs"; import { Advertisements, BaseAdvertisements } from "./advertisements.mjs"; import { SinglePage } from "../../../core/pagination.mjs"; import { path } from "../../../internal/utils/path.mjs"; export var BaseRules = /* @__PURE__ */ (() => { class BaseRules extends APIResource { /** * Create network monitoring rules for account. Currently only supports creating a * single rule per API request. * * @example * ```ts * const magicNetworkMonitoringRule = * await client.magicNetworkMonitoring.rules.create({ * account_id: '6f91088a406011ed95aed352566e8d4c', * automatic_advertisement: true, * name: 'my_rule_1', * prefixes: ['203.0.113.1/32'], * type: 'zscore', * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/mnm/rules`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Update network monitoring rules for account. * * @example * ```ts * const magicNetworkMonitoringRule = * await client.magicNetworkMonitoring.rules.update({ * account_id: '6f91088a406011ed95aed352566e8d4c', * automatic_advertisement: true, * name: 'my_rule_1', * prefixes: ['203.0.113.1/32'], * type: 'zscore', * }); * ``` */ update(params, options) { const { account_id, ...body } = params; return this._client.put(path `/accounts/${account_id}/mnm/rules`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Lists network monitoring rules for account. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const magicNetworkMonitoringRule of client.magicNetworkMonitoring.rules.list( * { account_id: '6f91088a406011ed95aed352566e8d4c' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id } = params; return this._client.getAPIList(path `/accounts/${account_id}/mnm/rules`, (SinglePage), options); } /** * Delete a network monitoring rule for account. * * @example * ```ts * const magicNetworkMonitoringRule = * await client.magicNetworkMonitoring.rules.delete( * '2890e6fa406311ed9b5a23f70f6fb8cf', * { account_id: '6f91088a406011ed95aed352566e8d4c' }, * ); * ``` */ delete(ruleID, params, options) { const { account_id } = params; return this._client.delete(path `/accounts/${account_id}/mnm/rules/${ruleID}`, options)._thenUnwrap((obj) => obj.result); } /** * Update a network monitoring rule for account. * * @example * ```ts * const magicNetworkMonitoringRule = * await client.magicNetworkMonitoring.rules.edit( * '2890e6fa406311ed9b5a23f70f6fb8cf', * { * account_id: '6f91088a406011ed95aed352566e8d4c', * automatic_advertisement: true, * name: 'my_rule_1', * prefixes: ['203.0.113.1/32'], * type: 'zscore', * }, * ); * ``` */ edit(ruleID, params, options) { const { account_id, ...body } = params; return this._client.patch(path `/accounts/${account_id}/mnm/rules/${ruleID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * List a single network monitoring rule for account. * * @example * ```ts * const magicNetworkMonitoringRule = * await client.magicNetworkMonitoring.rules.get( * '2890e6fa406311ed9b5a23f70f6fb8cf', * { account_id: '6f91088a406011ed95aed352566e8d4c' }, * ); * ``` */ get(ruleID, params, options) { const { account_id } = params; return this._client.get(path `/accounts/${account_id}/mnm/rules/${ruleID}`, options)._thenUnwrap((obj) => obj.result); } } BaseRules._key = Object.freeze([ 'magicNetworkMonitoring', 'rules', ]); return BaseRules; })(); export var Rules = /* @__PURE__ */ (() => { class Rules extends BaseRules { constructor() { super(...arguments); this.advertisements = new AdvertisementsAPI.Advertisements(this._client); } } Rules.Advertisements = Advertisements; Rules.BaseAdvertisements = BaseAdvertisements; return Rules; })(); //# sourceMappingURL=rules.mjs.map