UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

59 lines • 2.05 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import { buildHeaders } from "../../internal/headers.mjs"; import { path } from "../../internal/utils/path.mjs"; export var BaseDatasets = /* @__PURE__ */ (() => { class BaseDatasets extends APIResource { /** * Retrieves a list of datasets. * * @example * ```ts * const datasets = await client.radar.datasets.list(); * ``` */ list(query = {}, options) { return this._client.get('/radar/datasets', { query, ...options })._thenUnwrap((obj) => obj.result); } /** * Retrieves an URL to download a single dataset. * * @example * ```ts * const response = await client.radar.datasets.download({ * datasetId: 3, * }); * ``` */ download(params, options) { const { format, ...body } = params; return this._client.post('/radar/datasets/download', { query: { format }, body, ...options })._thenUnwrap((obj) => obj.result); } /** * Retrieves the CSV content of a given dataset by alias or ID. When getting the * content by alias the latest dataset is returned, optionally filtered by the * latest available at a given date. * * @example * ```ts * const dataset = await client.radar.datasets.get( * 'ranking_top_1000', * ); * ``` */ get(alias, options) { return this._client.get(path `/radar/datasets/${alias}`, { ...options, headers: buildHeaders([{ Accept: 'text/csv' }, options?.headers]), }); } } BaseDatasets._key = Object.freeze([ 'radar', 'datasets', ]); return BaseDatasets; })(); export class Datasets extends BaseDatasets { } //# sourceMappingURL=datasets.mjs.map