UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

62 lines 2.37 kB
"use strict"; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. Object.defineProperty(exports, "__esModule", { value: true }); exports.Ownership = void 0; const resource_1 = require("cloudflare/resource"); const error_1 = require("cloudflare/error"); class Ownership extends resource_1.APIResource { /** * Gets a new ownership challenge sent to your destination. */ create(params, options) { const { account_id, zone_id, ...body } = params; if (!account_id && !zone_id) { throw new error_1.CloudflareError('You must provide either account_id or zone_id.'); } if (account_id && zone_id) { throw new error_1.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.post(`/${accountOrZone}/${accountOrZoneId}/logpush/ownership`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Validates ownership challenge of the destination. */ validate(params, options) { const { account_id, zone_id, ...body } = params; if (!account_id && !zone_id) { throw new error_1.CloudflareError('You must provide either account_id or zone_id.'); } if (account_id && zone_id) { throw new error_1.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.post(`/${accountOrZone}/${accountOrZoneId}/logpush/ownership/validate`, { body, ...options, })._thenUnwrap((obj) => obj.result); } } exports.Ownership = Ownership; (function (Ownership) { })(Ownership = exports.Ownership || (exports.Ownership = {})); //# sourceMappingURL=ownership.js.map