UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

164 lines • 6.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Jobs = exports.BaseJobs = void 0; const tslib_1 = require("../../../../internal/tslib.js"); // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../../../core/resource.js"); const LogsAPI = tslib_1.__importStar(require("./logs.js")); const logs_1 = require("./logs.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 R2 Super Slurper migration job to transfer objects from a source * bucket (e.g. S3, GCS, R2) to R2. * * @example * ```ts * const job = await client.r2.superSlurper.jobs.create({ * account_id: 'account_id', * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post((0, path_1.path) `/accounts/${account_id}/slurper/jobs`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Lists all R2 Super Slurper migration jobs for the account with their status. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const jobListResponse of client.r2.superSlurper.jobs.list( * { account_id: 'account_id' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/slurper/jobs`, (pagination_1.SinglePage), { query, ...options, }); } /** * Cancels a specific R2 Super Slurper migration job. Any objects in the middle of * a transfer will finish, but no new objects will start transferring. * * @example * ```ts * const response = await client.r2.superSlurper.jobs.abort( * 'job_id', * { account_id: 'account_id' }, * ); * ``` */ abort(jobID, params, options) { const { account_id } = params; return this._client.put((0, path_1.path) `/accounts/${account_id}/slurper/jobs/${jobID}/abort`, options)._thenUnwrap((obj) => obj.result); } /** * Cancels all running R2 Super Slurper migration jobs for the account. Any objects * in the middle of a transfer will finish, but no new objects will start * transferring. * * @example * ```ts * const response = await client.r2.superSlurper.jobs.abortAll( * { account_id: 'account_id' }, * ); * ``` */ abortAll(params, options) { const { account_id } = params; return this._client.put((0, path_1.path) `/accounts/${account_id}/slurper/jobs/abortAll`, options)._thenUnwrap((obj) => obj.result); } /** * Retrieves detailed status and configuration for a specific R2 Super Slurper * migration job. * * @example * ```ts * const job = await client.r2.superSlurper.jobs.get( * 'job_id', * { account_id: 'account_id' }, * ); * ``` */ get(jobID, params, options) { const { account_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/slurper/jobs/${jobID}`, options)._thenUnwrap((obj) => obj.result); } /** * Pauses a running R2 Super Slurper migration job. The job can be resumed later to * continue transferring. * * @example * ```ts * const response = await client.r2.superSlurper.jobs.pause( * 'job_id', * { account_id: 'account_id' }, * ); * ``` */ pause(jobID, params, options) { const { account_id } = params; return this._client.put((0, path_1.path) `/accounts/${account_id}/slurper/jobs/${jobID}/pause`, options)._thenUnwrap((obj) => obj.result); } /** * Retrieves current progress metrics for an R2 Super Slurper migration job * * @example * ```ts * const response = await client.r2.superSlurper.jobs.progress( * 'job_id', * { account_id: 'account_id' }, * ); * ``` */ progress(jobID, params, options) { const { account_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/slurper/jobs/${jobID}/progress`, options)._thenUnwrap((obj) => obj.result); } /** * Resumes a paused R2 Super Slurper migration job, continuing the transfer from * where it stopped. * * @example * ```ts * const response = await client.r2.superSlurper.jobs.resume( * 'job_id', * { account_id: 'account_id' }, * ); * ``` */ resume(jobID, params, options) { const { account_id } = params; return this._client.put((0, path_1.path) `/accounts/${account_id}/slurper/jobs/${jobID}/resume`, options)._thenUnwrap((obj) => obj.result); } } BaseJobs._key = Object.freeze([ 'r2', 'superSlurper', 'jobs', ]); return BaseJobs; })(); exports.BaseJobs = BaseJobs; var Jobs = /* @__PURE__ */ (() => { class Jobs extends BaseJobs { constructor() { super(...arguments); this.logs = new LogsAPI.Logs(this._client); } } Jobs.Logs = logs_1.Logs; Jobs.BaseLogs = logs_1.BaseLogs; return Jobs; })(); exports.Jobs = Jobs; //# sourceMappingURL=jobs.js.map