UNPKG

tsonik

Version:

A TypeScript client library for the Iconik API based on Swagger documentation

172 lines 5.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.JobResource = void 0; const base_1 = require("./base"); const utils_1 = require("../utils"); /** * Job resource for interacting with Iconik Jobs API * Handles job management, state control, and monitoring */ class JobResource extends base_1.BaseResource { constructor(client) { super(client, '/API/jobs/v1/jobs'); } /** * Get a specific job by ID * @param jobId The job ID * @returns Promise resolving to the job data */ async getJob(jobId) { return this.client.get(`${this.basePath}/${jobId}`); } /** * Search and list jobs with optional filtering * @param query Query parameters for filtering and pagination * @returns Promise resolving to paginated job results */ async listJobs(query = {}) { return super.list(query); } /** * Create a new job * @param jobData Job creation data * @returns Promise resolving to the created job */ async createJob(jobData) { return this.client.post(`${this.basePath}/`, jobData); } /** * Update an existing job * @param jobId The job ID to update * @param jobData Partial job data to update * @returns Promise resolving to the updated job */ async updateJob(jobId, jobData) { return this.client.patch(`${this.basePath}/${jobId}`, jobData); } /** * Replace an existing job (full update) * @param jobId The job ID to replace * @param jobData Complete job data to replace with * @param options Optional request options * @returns Promise resolving to the replaced job */ async replaceJob(jobId, jobData, options) { return this.client.put(`${this.basePath}/${jobId}`, jobData, { params: (0, utils_1.cleanParams)(options) }); } /** * Delete a job * @param jobId The job ID to delete * @returns Promise resolving to deletion confirmation */ async deleteJob(jobId) { return this.client.delete(`${this.basePath}/${jobId}`); } /** * Update job priority * @param jobId The job ID * @param priority New priority value (1-10) * @returns Promise resolving to updated job data */ async updatePriority(jobId, priority) { return this.client.patch(`${this.basePath}/${jobId}/`, { priority }); } /** * Update job steps * @param jobId The job ID * @param stepsData The steps update data * @returns Promise resolving to the updated job */ async updateSteps(jobId, stepsData) { return this.client.patch(`${this.basePath}/${jobId}/steps/`, stepsData); } /** * Bulk edit jobs based on query filters * @param query Query parameters to filter which jobs to edit * @param editData Data to update on matching jobs * @returns Promise resolving to bulk edit result */ async bulkEditJobs(query, editData) { return this.client.patch(`${this.basePath}/`, editData, { params: (0, utils_1.cleanParams)(query) }); } /** * Bulk update job priorities * @param priorityData Bulk priority update data * @returns Promise resolving to bulk operation results */ async bulkUpdatePriority(priorityData) { return this.client.put(`${this.basePath}/priority/`, priorityData); } /** * Bulk update job states * @param stateData Bulk state update data * @returns Promise resolving to bulk operation results */ async bulkUpdateState(stateData) { return this.client.put(`${this.basePath}/state/`, stateData); } /** * Bulk delete multiple jobs * @param jobIds Array of job IDs to delete * @returns Promise resolving to deletion confirmation (204 No Content) */ async bulkDelete(jobIds) { const requestBody = { job_ids: jobIds }; return this.client.delete(`${this.basePath}/`, { data: requestBody }); } /** * Reindex a job * @param jobId The job ID to reindex * @param options Options for reindexing * @returns Promise resolving to success confirmation */ async reindexJob(jobId, options) { return this.client.post(`${this.basePath}/${jobId}/reindex`, options ?? {}); } /** * Update multiple steps for a job * @param jobId The job ID to update steps for * @param stepsData Job steps update data * @returns Promise resolving to the updated job */ async updateJobSteps(jobId, stepsData) { return this.client.patch(`${this.basePath}/${jobId}/steps/`, stepsData); } /** * Replace multiple steps for a job * @param jobId The job ID to replace steps for * @param stepsData Job steps update data * @returns Promise resolving to the updated job */ async replaceJobSteps(jobId, stepsData) { return this.client.put(`${this.basePath}/${jobId}/steps/`, stepsData); } /** * Update a single job step * @param jobId The job ID the step belongs to * @param stepId The ID of the step to update * @param stepData Step update data (status, message, etc.) * @returns Promise resolving to the updated job */ async updateJobStep(jobId, stepId, stepData) { return this.client.patch(`${this.basePath}/${jobId}/steps/${stepId}/`, stepData); } /** * Replace a single job step (complete replacement) * @param jobId The job ID the step belongs to * @param stepId The ID of the step to replace * @param stepData Full step data to replace with * @returns Promise resolving to the updated job */ async replaceJobStep(jobId, stepId, stepData) { return this.client.put(`${this.basePath}/${jobId}/steps/${stepId}/`, stepData); } } exports.JobResource = JobResource; //# sourceMappingURL=jobs.js.map