UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

107 lines • 4.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PCAPs = exports.BasePCAPs = 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 DownloadAPI = tslib_1.__importStar(require("./download.js")); const download_1 = require("./download.js"); const OwnershipAPI = tslib_1.__importStar(require("./ownership.js")); const ownership_1 = require("./ownership.js"); const pagination_1 = require("../../../core/pagination.js"); const headers_1 = require("../../../internal/headers.js"); const path_1 = require("../../../internal/utils/path.js"); var BasePCAPs = /* @__PURE__ */ (() => { class BasePCAPs extends resource_1.APIResource { /** * Create new PCAP request for account. * * @example * ```ts * const pcap = await client.magicTransit.pcaps.create({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * packet_limit: 10000, * system: 'magic-transit', * time_limit: 300, * type: 'simple', * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post((0, path_1.path) `/accounts/${account_id}/pcaps`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Lists all packet capture requests for an account. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const pcapListResponse of client.magicTransit.pcaps.list( * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id } = params; return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/pcaps`, (pagination_1.SinglePage), options); } /** * Get information for a PCAP request by id. * * @example * ```ts * const pcap = await client.magicTransit.pcaps.get( * '023e105f4ecef8ad9ca31a8372d0c353', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(pcapID, params, options) { const { account_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/pcaps/${pcapID}`, options)._thenUnwrap((obj) => obj.result); } /** * Stop full PCAP. * * @example * ```ts * await client.magicTransit.pcaps.stop( * '023e105f4ecef8ad9ca31a8372d0c353', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ stop(pcapID, params, options) { const { account_id } = params; return this._client.put((0, path_1.path) `/accounts/${account_id}/pcaps/${pcapID}/stop`, { ...options, headers: (0, headers_1.buildHeaders)([{ Accept: '*/*' }, options?.headers]), }); } } BasePCAPs._key = Object.freeze([ 'magicTransit', 'pcaps', ]); return BasePCAPs; })(); exports.BasePCAPs = BasePCAPs; var PCAPs = /* @__PURE__ */ (() => { class PCAPs extends BasePCAPs { constructor() { super(...arguments); this.ownership = new OwnershipAPI.OwnershipResource(this._client); this.download = new DownloadAPI.Download(this._client); } } PCAPs.OwnershipResource = ownership_1.OwnershipResource; PCAPs.BaseOwnershipResource = ownership_1.BaseOwnershipResource; PCAPs.Download = download_1.Download; PCAPs.BaseDownload = download_1.BaseDownload; return PCAPs; })(); exports.PCAPs = PCAPs; //# sourceMappingURL=pcaps.js.map