/** * Flamenco manager * Render Farm manager API * * The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. * */ import ApiClient from "../ApiClient"; import AssignedTask from '../model/AssignedTask'; import Error from '../model/Error'; import MayKeepRunning from '../model/MayKeepRunning'; import RegisteredWorker from '../model/RegisteredWorker'; import SecurityError from '../model/SecurityError'; import TaskUpdate from '../model/TaskUpdate'; import WorkerRegistration from '../model/WorkerRegistration'; import WorkerSignOn from '../model/WorkerSignOn'; import WorkerStateChange from '../model/WorkerStateChange'; import WorkerStateChanged from '../model/WorkerStateChanged'; /** * Worker service. * @module manager/WorkerApi * @version 0.0.0 */ export default class WorkerApi { /** * Constructs a new WorkerApi. * @alias module:manager/WorkerApi * @class * @param {module:ApiClient} [apiClient] Optional API client implementation to use, * default to {@link module:ApiClient#instance} if unspecified. */ constructor(apiClient) { this.apiClient = apiClient || ApiClient.instance; } /** * The response indicates whether the worker is allowed to run / keep running the task. Optionally contains a queued worker status change. * @param {String} taskId * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/MayKeepRunning} and HTTP response */ mayWorkerRunWithHttpInfo(taskId) { let postBody = null; // verify the required parameter 'taskId' is set if (taskId === undefined || taskId === null) { throw new Error("Missing the required parameter 'taskId' when calling mayWorkerRun"); } let pathParams = { 'task_id': taskId }; let queryParams = { }; let headerParams = { }; let formParams = { }; let authNames = ['worker_auth']; let contentTypes = []; let accepts = ['application/json']; let returnType = MayKeepRunning; return this.apiClient.callApi( '/api/worker/task/{task_id}/may-i-run', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null ); } /** * The response indicates whether the worker is allowed to run / keep running the task. Optionally contains a queued worker status change. * @param {String} taskId * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/MayKeepRunning} */ mayWorkerRun(taskId) { return this.mayWorkerRunWithHttpInfo(taskId) .then(function(response_and_data) { return response_and_data.data; }); } /** * Register a new worker * @param {module:model/WorkerRegistration} workerRegistration Worker to register * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/RegisteredWorker} and HTTP response */ registerWorkerWithHttpInfo(workerRegistration) { let postBody = workerRegistration; // verify the required parameter 'workerRegistration' is set if (workerRegistration === undefined || workerRegistration === null) { throw new Error("Missing the required parameter 'workerRegistration' when calling registerWorker"); } let pathParams = { }; let queryParams = { }; let headerParams = { }; let formParams = { }; let authNames = []; let contentTypes = ['application/json']; let accepts = ['application/json']; let returnType = RegisteredWorker; return this.apiClient.callApi( '/api/worker/register-worker', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null ); } /** * Register a new worker * @param {module:model/WorkerRegistration} workerRegistration Worker to register * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/RegisteredWorker} */ registerWorker(workerRegistration) { return this.registerWorkerWithHttpInfo(workerRegistration) .then(function(response_and_data) { return response_and_data.data; }); } /** * Obtain a new task to execute * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AssignedTask} and HTTP response */ scheduleTaskWithHttpInfo() { let postBody = null; let pathParams = { }; let queryParams = { }; let headerParams = { }; let formParams = { }; let authNames = ['worker_auth']; let contentTypes = []; let accepts = ['application/json']; let returnType = AssignedTask; return this.apiClient.callApi( '/api/worker/task', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null ); } /** * Obtain a new task to execute * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AssignedTask} */ scheduleTask() { return this.scheduleTaskWithHttpInfo() .then(function(response_and_data) { return response_and_data.data; }); } /** * Mark the worker as offline * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ signOffWithHttpInfo() { let postBody = null; let pathParams = { }; let queryParams = { }; let headerParams = { }; let formParams = { }; let authNames = ['worker_auth']; let contentTypes = []; let accepts = ['application/json']; let returnType = null; return this.apiClient.callApi( '/api/worker/sign-off', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null ); } /** * Mark the worker as offline * @return {Promise} a {@link https://www.promisejs.org/|Promise} */ signOff() { return this.signOffWithHttpInfo() .then(function(response_and_data) { return response_and_data.data; }); } /** * Authenticate & sign in the worker. * @param {module:model/WorkerSignOn} workerSignOn Worker metadata * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/WorkerStateChange} and HTTP response */ signOnWithHttpInfo(workerSignOn) { let postBody = workerSignOn; // verify the required parameter 'workerSignOn' is set if (workerSignOn === undefined || workerSignOn === null) { throw new Error("Missing the required parameter 'workerSignOn' when calling signOn"); } let pathParams = { }; let queryParams = { }; let headerParams = { }; let formParams = { }; let authNames = ['worker_auth']; let contentTypes = ['application/json']; let accepts = ['application/json']; let returnType = WorkerStateChange; return this.apiClient.callApi( '/api/worker/sign-on', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null ); } /** * Authenticate & sign in the worker. * @param {module:model/WorkerSignOn} workerSignOn Worker metadata * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/WorkerStateChange} */ signOn(workerSignOn) { return this.signOnWithHttpInfo(workerSignOn) .then(function(response_and_data) { return response_and_data.data; }); } /** * Update the task, typically to indicate progress, completion, or failure. * @param {String} taskId * @param {module:model/TaskUpdate} taskUpdate Task update information * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ taskUpdateWithHttpInfo(taskId, taskUpdate) { let postBody = taskUpdate; // verify the required parameter 'taskId' is set if (taskId === undefined || taskId === null) { throw new Error("Missing the required parameter 'taskId' when calling taskUpdate"); } // verify the required parameter 'taskUpdate' is set if (taskUpdate === undefined || taskUpdate === null) { throw new Error("Missing the required parameter 'taskUpdate' when calling taskUpdate"); } let pathParams = { 'task_id': taskId }; let queryParams = { }; let headerParams = { }; let formParams = { }; let authNames = ['worker_auth']; let contentTypes = ['application/json']; let accepts = ['application/json']; let returnType = null; return this.apiClient.callApi( '/api/worker/task/{task_id}', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null ); } /** * Update the task, typically to indicate progress, completion, or failure. * @param {String} taskId * @param {module:model/TaskUpdate} taskUpdate Task update information * @return {Promise} a {@link https://www.promisejs.org/|Promise} */ taskUpdate(taskId, taskUpdate) { return this.taskUpdateWithHttpInfo(taskId, taskUpdate) .then(function(response_and_data) { return response_and_data.data; }); } /** * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/WorkerStateChange} and HTTP response */ workerStateWithHttpInfo() { let postBody = null; let pathParams = { }; let queryParams = { }; let headerParams = { }; let formParams = { }; let authNames = ['worker_auth']; let contentTypes = []; let accepts = ['application/json']; let returnType = WorkerStateChange; return this.apiClient.callApi( '/api/worker/state', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null ); } /** * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/WorkerStateChange} */ workerState() { return this.workerStateWithHttpInfo() .then(function(response_and_data) { return response_and_data.data; }); } /** * Worker changed state. This could be as acknowledgement of a Manager-requested state change, or in response to worker-local signals. * @param {module:model/WorkerStateChanged} workerStateChanged New worker state * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ workerStateChangedWithHttpInfo(workerStateChanged) { let postBody = workerStateChanged; // verify the required parameter 'workerStateChanged' is set if (workerStateChanged === undefined || workerStateChanged === null) { throw new Error("Missing the required parameter 'workerStateChanged' when calling workerStateChanged"); } let pathParams = { }; let queryParams = { }; let headerParams = { }; let formParams = { }; let authNames = ['worker_auth']; let contentTypes = ['application/json']; let accepts = ['application/json']; let returnType = null; return this.apiClient.callApi( '/api/worker/state-changed', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null ); } /** * Worker changed state. This could be as acknowledgement of a Manager-requested state change, or in response to worker-local signals. * @param {module:model/WorkerStateChanged} workerStateChanged New worker state * @return {Promise} a {@link https://www.promisejs.org/|Promise} */ workerStateChanged(workerStateChanged) { return this.workerStateChangedWithHttpInfo(workerStateChanged) .then(function(response_and_data) { return response_and_data.data; }); } }