UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

51 lines • 1.91 kB
// 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 BaseJobs = /* @__PURE__ */ (() => { class BaseJobs extends APIResource { /** * Lists Logpush jobs for an account or zone for a dataset. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const logpushJob of client.logpush.datasets.jobs.get( * 'gateway_dns', * { account_id: 'account_id' }, * )) { * // ... * } * ``` */ get(datasetID, 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}/logpush/datasets/${datasetID}/jobs`, (SinglePage), options); } } BaseJobs._key = Object.freeze([ 'logpush', 'datasets', 'jobs', ]); return BaseJobs; })(); export class Jobs extends BaseJobs { } //# sourceMappingURL=jobs.mjs.map