UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

55 lines • 1.86 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import { SinglePage } from "../../../core/pagination.mjs"; import { path } from "../../../internal/utils/path.mjs"; export var BaseQueries = /* @__PURE__ */ (() => { class BaseQueries extends APIResource { /** * Persist query for later use. * * @example * ```ts * const query = * await client.workers.observability.queries.create({ * account_id: 'account_id', * description: 'Query description', * name: 'x', * parameters: {}, * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/workers/observability/queries`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * List saved queries. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const queryListResponse of client.workers.observability.queries.list( * { account_id: 'account_id' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList(path `/accounts/${account_id}/workers/observability/queries`, (SinglePage), { query, ...options }); } } BaseQueries._key = Object.freeze([ 'workers', 'observability', 'queries', ]); return BaseQueries; })(); export class Queries extends BaseQueries { } //# sourceMappingURL=queries.mjs.map