UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

127 lines • 4.66 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Jobs = exports.BaseJobs = void 0; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../../../core/resource.js"); const pagination_1 = require("../../../../core/pagination.js"); const path_1 = require("../../../../internal/utils/path.js"); var BaseJobs = /* @__PURE__ */ (() => { class BaseJobs extends resource_1.APIResource { /** * Creates a new indexing job for an AI Search instance. * * @example * ```ts * const job = * await client.aiSearch.namespaces.instances.jobs.create( * 'my-ai-search', * { * account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', * name: 'my-namespace', * }, * ); * ``` */ create(id, params, options) { const { account_id, name, ...body } = params; return this._client.post((0, path_1.path) `/accounts/${account_id}/ai-search/namespaces/${name}/instances/${id}/jobs`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Cancel an in-progress indexing job for an AI Search instance. * * @example * ```ts * const job = * await client.aiSearch.namespaces.instances.jobs.update( * 'job_id', * { * account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', * name: 'my-namespace', * id: 'my-ai-search', * action: 'cancel', * }, * ); * ``` */ update(jobID, params, options) { const { account_id, name, id, ...body } = params; return this._client.patch((0, path_1.path) `/accounts/${account_id}/ai-search/namespaces/${name}/instances/${id}/jobs/${jobID}`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Lists indexing jobs for an AI Search instance. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const jobListResponse of client.aiSearch.namespaces.instances.jobs.list( * 'my-ai-search', * { * account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', * name: 'my-namespace', * }, * )) { * // ... * } * ``` */ list(id, params, options) { const { account_id, name, ...query } = params; return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/ai-search/namespaces/${name}/instances/${id}/jobs`, (pagination_1.V4PagePaginationArray), { query, ...options }); } /** * Retrieves details for a specific AI Search indexing job. * * @example * ```ts * const job = * await client.aiSearch.namespaces.instances.jobs.get( * 'job_id', * { * account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', * name: 'my-namespace', * id: 'my-ai-search', * }, * ); * ``` */ get(jobID, params, options) { const { account_id, name, id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/ai-search/namespaces/${name}/instances/${id}/jobs/${jobID}`, options)._thenUnwrap((obj) => obj.result); } /** * Lists log entries for an AI Search indexing job. * * @example * ```ts * const response = * await client.aiSearch.namespaces.instances.jobs.logs( * 'job_id', * { * account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', * name: 'my-namespace', * id: 'my-ai-search', * }, * ); * ``` */ logs(jobID, params, options) { const { account_id, name, id, ...query } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/ai-search/namespaces/${name}/instances/${id}/jobs/${jobID}/logs`, { query, ...options })._thenUnwrap((obj) => obj.result); } } BaseJobs._key = Object.freeze([ 'aiSearch', 'namespaces', 'instances', 'jobs', ]); return BaseJobs; })(); exports.BaseJobs = BaseJobs; class Jobs extends BaseJobs { } exports.Jobs = Jobs; //# sourceMappingURL=jobs.js.map