cloudflare
Version:
The official TypeScript library for the Cloudflare API
57 lines • 2.39 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../../core/resource.mjs";
import { CloudflareError } from "../../../../core/error.mjs";
import { SinglePage } from "../../../../core/pagination.mjs";
import { path } from "../../../../internal/utils/path.mjs";
export var BaseAvailable = /* @__PURE__ */ (() => {
class BaseAvailable extends APIResource {
/**
* Returns all dataset types that this account or zone can create. Each entry
* includes the dataset schema and timestamp field.
*
* The schema shows all possible fields for a dataset. However, not all fields may
* be available for your account or zone. When creating or updating a dataset, only
* fields available to your account or zone can be enabled. If you request a field
* that is not available, you will receive an error.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const availableDataset of client.logs.logExplorer.datasets.available.list(
* { account_id: 'account_id' },
* )) {
* // ...
* }
* ```
*/
list(params = {}, options) {
const { account_id, zone_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.getAPIList(path `/${accountOrZone}/${accountOrZoneId}/logs/explorer/datasets/available`, (SinglePage), options);
}
}
BaseAvailable._key = Object.freeze([
'logs',
'logExplorer',
'datasets',
'available',
]);
return BaseAvailable;
})();
export class Available extends BaseAvailable {
}
//# sourceMappingURL=available.mjs.map