UNPKG

@jellyfin/sdk

Version:
246 lines (243 loc) • 11.3 kB
import globalAxios from 'axios'; import { assertParamExists, DUMMY_BASE_URL, setApiKeyToObject, setSearchParams, toPathString, 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/. */ /** * ApiKeyApi - axios parameter creator * @export */ const ApiKeyApiAxiosParamCreator = function (configuration) { return { /** * * @summary Create a new api key. * @param {string} app Name of the app using the authentication key. * @param {*} [options] Override http request option. * @throws {RequiredError} */ createKey: async (app, options = {}) => { // verify required parameter 'app' is not null or undefined assertParamExists('createKey', 'app', app); const localVarPath = `/Auth/Keys`; // 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); if (app !== undefined) { localVarQueryParameter['app'] = app; } setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers }; return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, /** * * @summary Get all keys. * @param {*} [options] Override http request option. * @throws {RequiredError} */ getKeys: async (options = {}) => { const localVarPath = `/Auth/Keys`; // 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 Remove an api key. * @param {string} key The access token to delete. * @param {*} [options] Override http request option. * @throws {RequiredError} */ revokeKey: async (key, options = {}) => { // verify required parameter 'key' is not null or undefined assertParamExists('revokeKey', 'key', key); const localVarPath = `/Auth/Keys/{key}` .replace(`{${"key"}}`, encodeURIComponent(String(key))); // 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, }; }, }; }; /** * ApiKeyApi - functional programming interface * @export */ const ApiKeyApiFp = function (configuration) { const localVarAxiosParamCreator = ApiKeyApiAxiosParamCreator(configuration); return { /** * * @summary Create a new api key. * @param {string} app Name of the app using the authentication key. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async createKey(app, options) { var _a, _b, _c; const localVarAxiosArgs = await localVarAxiosParamCreator.createKey(app, options); const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0; const localVarOperationServerBasePath = (_c = (_b = operationServerMap['ApiKeyApi.createKey']) === 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 all keys. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async getKeys(options) { var _a, _b, _c; const localVarAxiosArgs = await localVarAxiosParamCreator.getKeys(options); const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0; const localVarOperationServerBasePath = (_c = (_b = operationServerMap['ApiKeyApi.getKeys']) === 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 Remove an api key. * @param {string} key The access token to delete. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async revokeKey(key, options) { var _a, _b, _c; const localVarAxiosArgs = await localVarAxiosParamCreator.revokeKey(key, options); const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0; const localVarOperationServerBasePath = (_c = (_b = operationServerMap['ApiKeyApi.revokeKey']) === 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); }, }; }; /** * ApiKeyApi - factory interface * @export */ const ApiKeyApiFactory = function (configuration, basePath, axios) { const localVarFp = ApiKeyApiFp(configuration); return { /** * * @summary Create a new api key. * @param {ApiKeyApiCreateKeyRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ createKey(requestParameters, options) { return localVarFp.createKey(requestParameters.app, options).then((request) => request(axios, basePath)); }, /** * * @summary Get all keys. * @param {*} [options] Override http request option. * @throws {RequiredError} */ getKeys(options) { return localVarFp.getKeys(options).then((request) => request(axios, basePath)); }, /** * * @summary Remove an api key. * @param {ApiKeyApiRevokeKeyRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} */ revokeKey(requestParameters, options) { return localVarFp.revokeKey(requestParameters.key, options).then((request) => request(axios, basePath)); }, }; }; /** * ApiKeyApi - object-oriented interface * @export * @class ApiKeyApi * @extends {BaseAPI} */ class ApiKeyApi extends BaseAPI { /** * * @summary Create a new api key. * @param {ApiKeyApiCreateKeyRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof ApiKeyApi */ createKey(requestParameters, options) { return ApiKeyApiFp(this.configuration).createKey(requestParameters.app, options).then((request) => request(this.axios, this.basePath)); } /** * * @summary Get all keys. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof ApiKeyApi */ getKeys(options) { return ApiKeyApiFp(this.configuration).getKeys(options).then((request) => request(this.axios, this.basePath)); } /** * * @summary Remove an api key. * @param {ApiKeyApiRevokeKeyRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof ApiKeyApi */ revokeKey(requestParameters, options) { return ApiKeyApiFp(this.configuration).revokeKey(requestParameters.key, options).then((request) => request(this.axios, this.basePath)); } } export { ApiKeyApi, ApiKeyApiAxiosParamCreator, ApiKeyApiFactory, ApiKeyApiFp };