cloudflare
Version:
The official TypeScript library for the Cloudflare API
158 lines • 5.72 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../../core/resource.mjs";
import * as LogsAPI from "./logs.mjs";
import { BaseLogs, Logs } from "./logs.mjs";
import { SinglePage } from "../../../../core/pagination.mjs";
import { path } from "../../../../internal/utils/path.mjs";
export var BaseJobs = /* @__PURE__ */ (() => {
class BaseJobs extends 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(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(path `/accounts/${account_id}/slurper/jobs`, (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(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(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(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(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(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(path `/accounts/${account_id}/slurper/jobs/${jobID}/resume`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseJobs._key = Object.freeze([
'r2',
'superSlurper',
'jobs',
]);
return BaseJobs;
})();
export var Jobs = /* @__PURE__ */ (() => {
class Jobs extends BaseJobs {
constructor() {
super(...arguments);
this.logs = new LogsAPI.Logs(this._client);
}
}
Jobs.Logs = Logs;
Jobs.BaseLogs = BaseLogs;
return Jobs;
})();
//# sourceMappingURL=jobs.mjs.map