@jellyfin/sdk
Version:
A TypeScript SDK for Jellyfin.
394 lines (391 loc) • 20.2 kB
JavaScript
import globalAxios from 'axios';
import { assertParamExists, DUMMY_BASE_URL, setApiKeyToObject, setSearchParams, toPathString, serializeDataIfNeeded, createRequestFunction } from '../common.js';
import { operationServerMap, BaseAPI, BASE_PATH } from '../base.js';
/* tslint:disable */
/* eslint-disable */
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* Do not edit the class manually.
*
* Jellyfin API
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/**
* ScheduledTasksApi - axios parameter creator
* @export
*/
const ScheduledTasksApiAxiosParamCreator = function (configuration) {
return {
/**
*
* @summary Get task by id.
* @param {string} taskId Task Id.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getTask: async (taskId, options = {}) => {
// verify required parameter 'taskId' is not null or undefined
assertParamExists('getTask', 'taskId', taskId);
const localVarPath = `/ScheduledTasks/{taskId}`
.replace(`{${"taskId"}}`, encodeURIComponent(String(taskId)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options };
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication CustomAuthentication required
await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration);
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @summary Get tasks.
* @param {boolean} [isHidden] Optional filter tasks that are hidden, or not.
* @param {boolean} [isEnabled] Optional filter tasks that are enabled, or not.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getTasks: async (isHidden, isEnabled, options = {}) => {
const localVarPath = `/ScheduledTasks`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options };
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication CustomAuthentication required
await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration);
if (isHidden !== undefined) {
localVarQueryParameter['isHidden'] = isHidden;
}
if (isEnabled !== undefined) {
localVarQueryParameter['isEnabled'] = isEnabled;
}
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @summary Start specified task.
* @param {string} taskId Task Id.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
startTask: async (taskId, options = {}) => {
// verify required parameter 'taskId' is not null or undefined
assertParamExists('startTask', 'taskId', taskId);
const localVarPath = `/ScheduledTasks/Running/{taskId}`
.replace(`{${"taskId"}}`, encodeURIComponent(String(taskId)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication CustomAuthentication required
await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration);
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @summary Stop specified task.
* @param {string} taskId Task Id.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
stopTask: async (taskId, options = {}) => {
// verify required parameter 'taskId' is not null or undefined
assertParamExists('stopTask', 'taskId', taskId);
const localVarPath = `/ScheduledTasks/Running/{taskId}`
.replace(`{${"taskId"}}`, encodeURIComponent(String(taskId)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options };
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication CustomAuthentication required
await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration);
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @summary Update specified task triggers.
* @param {string} taskId Task Id.
* @param {Array<TaskTriggerInfo>} taskTriggerInfo Triggers.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updateTask: async (taskId, taskTriggerInfo, options = {}) => {
// verify required parameter 'taskId' is not null or undefined
assertParamExists('updateTask', 'taskId', taskId);
// verify required parameter 'taskTriggerInfo' is not null or undefined
assertParamExists('updateTask', 'taskTriggerInfo', taskTriggerInfo);
const localVarPath = `/ScheduledTasks/{taskId}/Triggers`
.replace(`{${"taskId"}}`, encodeURIComponent(String(taskId)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication CustomAuthentication required
await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration);
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
localVarRequestOptions.data = serializeDataIfNeeded(taskTriggerInfo, localVarRequestOptions, configuration);
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
};
};
/**
* ScheduledTasksApi - functional programming interface
* @export
*/
const ScheduledTasksApiFp = function (configuration) {
const localVarAxiosParamCreator = ScheduledTasksApiAxiosParamCreator(configuration);
return {
/**
*
* @summary Get task by id.
* @param {string} taskId Task Id.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getTask(taskId, options) {
var _a, _b, _c;
const localVarAxiosArgs = await localVarAxiosParamCreator.getTask(taskId, options);
const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
const localVarOperationServerBasePath = (_c = (_b = operationServerMap['ScheduledTasksApi.getTask']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
*
* @summary Get tasks.
* @param {boolean} [isHidden] Optional filter tasks that are hidden, or not.
* @param {boolean} [isEnabled] Optional filter tasks that are enabled, or not.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getTasks(isHidden, isEnabled, options) {
var _a, _b, _c;
const localVarAxiosArgs = await localVarAxiosParamCreator.getTasks(isHidden, isEnabled, options);
const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
const localVarOperationServerBasePath = (_c = (_b = operationServerMap['ScheduledTasksApi.getTasks']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
*
* @summary Start specified task.
* @param {string} taskId Task Id.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async startTask(taskId, options) {
var _a, _b, _c;
const localVarAxiosArgs = await localVarAxiosParamCreator.startTask(taskId, options);
const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
const localVarOperationServerBasePath = (_c = (_b = operationServerMap['ScheduledTasksApi.startTask']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
*
* @summary Stop specified task.
* @param {string} taskId Task Id.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async stopTask(taskId, options) {
var _a, _b, _c;
const localVarAxiosArgs = await localVarAxiosParamCreator.stopTask(taskId, options);
const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
const localVarOperationServerBasePath = (_c = (_b = operationServerMap['ScheduledTasksApi.stopTask']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
*
* @summary Update specified task triggers.
* @param {string} taskId Task Id.
* @param {Array<TaskTriggerInfo>} taskTriggerInfo Triggers.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async updateTask(taskId, taskTriggerInfo, options) {
var _a, _b, _c;
const localVarAxiosArgs = await localVarAxiosParamCreator.updateTask(taskId, taskTriggerInfo, options);
const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
const localVarOperationServerBasePath = (_c = (_b = operationServerMap['ScheduledTasksApi.updateTask']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
};
};
/**
* ScheduledTasksApi - factory interface
* @export
*/
const ScheduledTasksApiFactory = function (configuration, basePath, axios) {
const localVarFp = ScheduledTasksApiFp(configuration);
return {
/**
*
* @summary Get task by id.
* @param {ScheduledTasksApiGetTaskRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getTask(requestParameters, options) {
return localVarFp.getTask(requestParameters.taskId, options).then((request) => request(axios, basePath));
},
/**
*
* @summary Get tasks.
* @param {ScheduledTasksApiGetTasksRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getTasks(requestParameters = {}, options) {
return localVarFp.getTasks(requestParameters.isHidden, requestParameters.isEnabled, options).then((request) => request(axios, basePath));
},
/**
*
* @summary Start specified task.
* @param {ScheduledTasksApiStartTaskRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
startTask(requestParameters, options) {
return localVarFp.startTask(requestParameters.taskId, options).then((request) => request(axios, basePath));
},
/**
*
* @summary Stop specified task.
* @param {ScheduledTasksApiStopTaskRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
stopTask(requestParameters, options) {
return localVarFp.stopTask(requestParameters.taskId, options).then((request) => request(axios, basePath));
},
/**
*
* @summary Update specified task triggers.
* @param {ScheduledTasksApiUpdateTaskRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updateTask(requestParameters, options) {
return localVarFp.updateTask(requestParameters.taskId, requestParameters.taskTriggerInfo, options).then((request) => request(axios, basePath));
},
};
};
/**
* ScheduledTasksApi - object-oriented interface
* @export
* @class ScheduledTasksApi
* @extends {BaseAPI}
*/
class ScheduledTasksApi extends BaseAPI {
/**
*
* @summary Get task by id.
* @param {ScheduledTasksApiGetTaskRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ScheduledTasksApi
*/
getTask(requestParameters, options) {
return ScheduledTasksApiFp(this.configuration).getTask(requestParameters.taskId, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary Get tasks.
* @param {ScheduledTasksApiGetTasksRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ScheduledTasksApi
*/
getTasks(requestParameters = {}, options) {
return ScheduledTasksApiFp(this.configuration).getTasks(requestParameters.isHidden, requestParameters.isEnabled, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary Start specified task.
* @param {ScheduledTasksApiStartTaskRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ScheduledTasksApi
*/
startTask(requestParameters, options) {
return ScheduledTasksApiFp(this.configuration).startTask(requestParameters.taskId, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary Stop specified task.
* @param {ScheduledTasksApiStopTaskRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ScheduledTasksApi
*/
stopTask(requestParameters, options) {
return ScheduledTasksApiFp(this.configuration).stopTask(requestParameters.taskId, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary Update specified task triggers.
* @param {ScheduledTasksApiUpdateTaskRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ScheduledTasksApi
*/
updateTask(requestParameters, options) {
return ScheduledTasksApiFp(this.configuration).updateTask(requestParameters.taskId, requestParameters.taskTriggerInfo, options).then((request) => request(this.axios, this.basePath));
}
}
export { ScheduledTasksApi, ScheduledTasksApiAxiosParamCreator, ScheduledTasksApiFactory, ScheduledTasksApiFp };