cloudflare
Version:
The official TypeScript library for the Cloudflare API
101 lines • 3.67 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import * as DownloadAPI from "./download.mjs";
import { BaseDownload, Download } from "./download.mjs";
import * as OwnershipAPI from "./ownership.mjs";
import { BaseOwnershipResource, OwnershipResource, } from "./ownership.mjs";
import { SinglePage } from "../../../core/pagination.mjs";
import { buildHeaders } from "../../../internal/headers.mjs";
import { path } from "../../../internal/utils/path.mjs";
export var BasePCAPs = /* @__PURE__ */ (() => {
class BasePCAPs extends 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(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(path `/accounts/${account_id}/pcaps`, (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(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(path `/accounts/${account_id}/pcaps/${pcapID}/stop`, {
...options,
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
});
}
}
BasePCAPs._key = Object.freeze([
'magicTransit',
'pcaps',
]);
return BasePCAPs;
})();
export 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 = OwnershipResource;
PCAPs.BaseOwnershipResource = BaseOwnershipResource;
PCAPs.Download = Download;
PCAPs.BaseDownload = BaseDownload;
return PCAPs;
})();
//# sourceMappingURL=pcaps.mjs.map