/* tslint:disable */
/* eslint-disable */
/**
 * Jellyfin API
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 10.8.9
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


import * as runtime from '../runtime';
import type {
  PluginInfo,
  ProblemDetails,
} from '../models';
import {
    PluginInfoFromJSON,
    PluginInfoToJSON,
    ProblemDetailsFromJSON,
    ProblemDetailsToJSON,
} from '../models';

export interface DisablePluginRequest {
    pluginId: string;
    version: string;
}

export interface EnablePluginRequest {
    pluginId: string;
    version: string;
}

export interface GetPluginConfigurationRequest {
    pluginId: string;
}

export interface GetPluginImageRequest {
    pluginId: string;
    version: string;
}

export interface GetPluginManifestRequest {
    pluginId: string;
}

export interface UninstallPluginRequest {
    pluginId: string;
}

export interface UninstallPluginByVersionRequest {
    pluginId: string;
    version: string;
}

export interface UpdatePluginConfigurationRequest {
    pluginId: string;
}

/**
 * 
 */
export class PluginsApi extends runtime.BaseAPI {

    /**
     * Disable a plugin.
     */
    async disablePluginRaw(requestParameters: DisablePluginRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.pluginId === null || requestParameters.pluginId === undefined) {
            throw new runtime.RequiredError('pluginId','Required parameter requestParameters.pluginId was null or undefined when calling disablePlugin.');
        }

        if (requestParameters.version === null || requestParameters.version === undefined) {
            throw new runtime.RequiredError('version','Required parameter requestParameters.version was null or undefined when calling disablePlugin.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // CustomAuthentication authentication
        }

        const response = await this.request({
            path: `/Plugins/{pluginId}/{version}/Disable`.replace(`{${"pluginId"}}`, encodeURIComponent(String(requestParameters.pluginId))).replace(`{${"version"}}`, encodeURIComponent(String(requestParameters.version))),
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Disable a plugin.
     */
    async disablePlugin(requestParameters: DisablePluginRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.disablePluginRaw(requestParameters, initOverrides);
    }

    /**
     * Enables a disabled plugin.
     */
    async enablePluginRaw(requestParameters: EnablePluginRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.pluginId === null || requestParameters.pluginId === undefined) {
            throw new runtime.RequiredError('pluginId','Required parameter requestParameters.pluginId was null or undefined when calling enablePlugin.');
        }

        if (requestParameters.version === null || requestParameters.version === undefined) {
            throw new runtime.RequiredError('version','Required parameter requestParameters.version was null or undefined when calling enablePlugin.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // CustomAuthentication authentication
        }

        const response = await this.request({
            path: `/Plugins/{pluginId}/{version}/Enable`.replace(`{${"pluginId"}}`, encodeURIComponent(String(requestParameters.pluginId))).replace(`{${"version"}}`, encodeURIComponent(String(requestParameters.version))),
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Enables a disabled plugin.
     */
    async enablePlugin(requestParameters: EnablePluginRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.enablePluginRaw(requestParameters, initOverrides);
    }

    /**
     * Gets plugin configuration.
     */
    async getPluginConfigurationRaw(requestParameters: GetPluginConfigurationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<object>> {
        if (requestParameters.pluginId === null || requestParameters.pluginId === undefined) {
            throw new runtime.RequiredError('pluginId','Required parameter requestParameters.pluginId was null or undefined when calling getPluginConfiguration.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // CustomAuthentication authentication
        }

        const response = await this.request({
            path: `/Plugins/{pluginId}/Configuration`.replace(`{${"pluginId"}}`, encodeURIComponent(String(requestParameters.pluginId))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse<any>(response);
    }

    /**
     * Gets plugin configuration.
     */
    async getPluginConfiguration(requestParameters: GetPluginConfigurationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<object> {
        const response = await this.getPluginConfigurationRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Gets a plugin\'s image.
     */
    async getPluginImageRaw(requestParameters: GetPluginImageRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Blob>> {
        if (requestParameters.pluginId === null || requestParameters.pluginId === undefined) {
            throw new runtime.RequiredError('pluginId','Required parameter requestParameters.pluginId was null or undefined when calling getPluginImage.');
        }

        if (requestParameters.version === null || requestParameters.version === undefined) {
            throw new runtime.RequiredError('version','Required parameter requestParameters.version was null or undefined when calling getPluginImage.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // CustomAuthentication authentication
        }

        const response = await this.request({
            path: `/Plugins/{pluginId}/{version}/Image`.replace(`{${"pluginId"}}`, encodeURIComponent(String(requestParameters.pluginId))).replace(`{${"version"}}`, encodeURIComponent(String(requestParameters.version))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.BlobApiResponse(response);
    }

    /**
     * Gets a plugin\'s image.
     */
    async getPluginImage(requestParameters: GetPluginImageRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Blob> {
        const response = await this.getPluginImageRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Gets a plugin\'s manifest.
     */
    async getPluginManifestRaw(requestParameters: GetPluginManifestRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.pluginId === null || requestParameters.pluginId === undefined) {
            throw new runtime.RequiredError('pluginId','Required parameter requestParameters.pluginId was null or undefined when calling getPluginManifest.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // CustomAuthentication authentication
        }

        const response = await this.request({
            path: `/Plugins/{pluginId}/Manifest`.replace(`{${"pluginId"}}`, encodeURIComponent(String(requestParameters.pluginId))),
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Gets a plugin\'s manifest.
     */
    async getPluginManifest(requestParameters: GetPluginManifestRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.getPluginManifestRaw(requestParameters, initOverrides);
    }

    /**
     * Gets a list of currently installed plugins.
     */
    async getPluginsRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<PluginInfo>>> {
        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // CustomAuthentication authentication
        }

        const response = await this.request({
            path: `/Plugins`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PluginInfoFromJSON));
    }

    /**
     * Gets a list of currently installed plugins.
     */
    async getPlugins(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<PluginInfo>> {
        const response = await this.getPluginsRaw(initOverrides);
        return await response.value();
    }

    /**
     * Uninstalls a plugin.
     */
    async uninstallPluginRaw(requestParameters: UninstallPluginRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.pluginId === null || requestParameters.pluginId === undefined) {
            throw new runtime.RequiredError('pluginId','Required parameter requestParameters.pluginId was null or undefined when calling uninstallPlugin.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // CustomAuthentication authentication
        }

        const response = await this.request({
            path: `/Plugins/{pluginId}`.replace(`{${"pluginId"}}`, encodeURIComponent(String(requestParameters.pluginId))),
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Uninstalls a plugin.
     */
    async uninstallPlugin(requestParameters: UninstallPluginRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.uninstallPluginRaw(requestParameters, initOverrides);
    }

    /**
     * Uninstalls a plugin by version.
     */
    async uninstallPluginByVersionRaw(requestParameters: UninstallPluginByVersionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.pluginId === null || requestParameters.pluginId === undefined) {
            throw new runtime.RequiredError('pluginId','Required parameter requestParameters.pluginId was null or undefined when calling uninstallPluginByVersion.');
        }

        if (requestParameters.version === null || requestParameters.version === undefined) {
            throw new runtime.RequiredError('version','Required parameter requestParameters.version was null or undefined when calling uninstallPluginByVersion.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // CustomAuthentication authentication
        }

        const response = await this.request({
            path: `/Plugins/{pluginId}/{version}`.replace(`{${"pluginId"}}`, encodeURIComponent(String(requestParameters.pluginId))).replace(`{${"version"}}`, encodeURIComponent(String(requestParameters.version))),
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Uninstalls a plugin by version.
     */
    async uninstallPluginByVersion(requestParameters: UninstallPluginByVersionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.uninstallPluginByVersionRaw(requestParameters, initOverrides);
    }

    /**
     * Accepts plugin configuration as JSON body.
     * Updates plugin configuration.
     */
    async updatePluginConfigurationRaw(requestParameters: UpdatePluginConfigurationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.pluginId === null || requestParameters.pluginId === undefined) {
            throw new runtime.RequiredError('pluginId','Required parameter requestParameters.pluginId was null or undefined when calling updatePluginConfiguration.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // CustomAuthentication authentication
        }

        const response = await this.request({
            path: `/Plugins/{pluginId}/Configuration`.replace(`{${"pluginId"}}`, encodeURIComponent(String(requestParameters.pluginId))),
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Accepts plugin configuration as JSON body.
     * Updates plugin configuration.
     */
    async updatePluginConfiguration(requestParameters: UpdatePluginConfigurationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.updatePluginConfigurationRaw(requestParameters, initOverrides);
    }

}
