UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

49 lines • 1.96 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import { CloudflareError } from "../../core/error.mjs"; import { V4PagePaginationArray } from "../../core/pagination.mjs"; import { path } from "../../internal/utils/path.mjs"; export var BaseAccountRules = /* @__PURE__ */ (() => { class BaseAccountRules extends APIResource { /** * Lists existing routing rules across all zones in the account or zone. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const accountRule of client.emailRouting.accountRules.list( * { account_id: 'account_id' }, * )) { * // ... * } * ``` */ list(params = {}, options) { const { account_id, zone_id, ...query } = params ?? {}; if (!account_id && !zone_id) { throw new CloudflareError('You must provide either account_id or zone_id.'); } if (account_id && zone_id) { throw new CloudflareError('You cannot provide both account_id and zone_id.'); } const { accountOrZone, accountOrZoneId } = account_id ? { accountOrZone: 'accounts', accountOrZoneId: account_id, } : { accountOrZone: 'zones', accountOrZoneId: zone_id, }; return this._client.getAPIList(path `/${accountOrZone}/${accountOrZoneId}/email/routing/rules`, (V4PagePaginationArray), { query, ...options }); } } BaseAccountRules._key = Object.freeze([ 'emailRouting', 'accountRules', ]); return BaseAccountRules; })(); export class AccountRules extends BaseAccountRules { } //# sourceMappingURL=account-rules.mjs.map