UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

122 lines • 4.43 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../../core/resource.mjs"; import { V4PagePaginationArray, } from "../../../../core/pagination.mjs"; import { path } from "../../../../internal/utils/path.mjs"; export var BaseJobs = /* @__PURE__ */ (() => { class BaseJobs extends 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(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(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(path `/accounts/${account_id}/ai-search/namespaces/${name}/instances/${id}/jobs`, (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(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(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; })(); export class Jobs extends BaseJobs { } //# sourceMappingURL=jobs.mjs.map