UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

52 lines 2.14 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from 'cloudflare/resource'; import { CloudflareError } from 'cloudflare/error'; export class Zones extends APIResource { /** * Add a zone as a member of a particular address map. */ update(addressMapId, params, options) { const { zone_id, account_id } = 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.put(`/accounts/${accountOrZone}/addressing/address_maps/${addressMapId}/zones/${accountOrZoneId}`, options)._thenUnwrap((obj) => obj.result); } /** * Remove a zone as a member of a particular address map. */ delete(addressMapId, params, options) { const { zone_id, account_id } = 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.delete(`/accounts/${accountOrZone}/addressing/address_maps/${addressMapId}/zones/${accountOrZoneId}`, options)._thenUnwrap((obj) => obj.result); } } (function (Zones) { })(Zones || (Zones = {})); //# sourceMappingURL=zones.mjs.map