cloudflare
Version:
The official TypeScript library for the Cloudflare API
146 lines • 5.58 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Rules = exports.BaseRules = 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 AdvertisementsAPI = tslib_1.__importStar(require("./advertisements.js"));
const advertisements_1 = require("./advertisements.js");
const pagination_1 = require("../../../core/pagination.js");
const path_1 = require("../../../internal/utils/path.js");
var BaseRules = /* @__PURE__ */ (() => {
class BaseRules extends resource_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/mnm/rules`, (pagination_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/mnm/rules/${ruleID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseRules._key = Object.freeze([
'magicNetworkMonitoring',
'rules',
]);
return BaseRules;
})();
exports.BaseRules = BaseRules;
var Rules = /* @__PURE__ */ (() => {
class Rules extends BaseRules {
constructor() {
super(...arguments);
this.advertisements = new AdvertisementsAPI.Advertisements(this._client);
}
}
Rules.Advertisements = advertisements_1.Advertisements;
Rules.BaseAdvertisements = advertisements_1.BaseAdvertisements;
return Rules;
})();
exports.Rules = Rules;
//# sourceMappingURL=rules.js.map