/* 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 {
  MetadataOptions,
  ServerConfiguration,
  UpdateConfigurationRequest,
  UpdateMediaEncoderPathRequest,
} from '../models';
import {
    MetadataOptionsFromJSON,
    MetadataOptionsToJSON,
    ServerConfigurationFromJSON,
    ServerConfigurationToJSON,
    UpdateConfigurationRequestFromJSON,
    UpdateConfigurationRequestToJSON,
    UpdateMediaEncoderPathRequestFromJSON,
    UpdateMediaEncoderPathRequestToJSON,
} from '../models';

export interface GetNamedConfigurationRequest {
    key: string;
}

export interface UpdateConfigurationOperationRequest {
    updateConfigurationRequest: UpdateConfigurationRequest;
}

export interface UpdateMediaEncoderPathOperationRequest {
    updateMediaEncoderPathRequest: UpdateMediaEncoderPathRequest;
}

export interface UpdateNamedConfigurationRequest {
    key: string;
    body: any | null;
}

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

    /**
     * Gets application configuration.
     */
    async getConfigurationRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ServerConfiguration>> {
        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: `/System/Configuration`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * Gets application configuration.
     */
    async getConfiguration(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ServerConfiguration> {
        const response = await this.getConfigurationRaw(initOverrides);
        return await response.value();
    }

    /**
     * Gets a default MetadataOptions object.
     */
    async getDefaultMetadataOptionsRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<MetadataOptions>> {
        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: `/System/Configuration/MetadataOptions/Default`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * Gets a default MetadataOptions object.
     */
    async getDefaultMetadataOptions(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<MetadataOptions> {
        const response = await this.getDefaultMetadataOptionsRaw(initOverrides);
        return await response.value();
    }

    /**
     * Gets a named configuration.
     */
    async getNamedConfigurationRaw(requestParameters: GetNamedConfigurationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Blob>> {
        if (requestParameters.key === null || requestParameters.key === undefined) {
            throw new runtime.RequiredError('key','Required parameter requestParameters.key was null or undefined when calling getNamedConfiguration.');
        }

        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: `/System/Configuration/{key}`.replace(`{${"key"}}`, encodeURIComponent(String(requestParameters.key))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.BlobApiResponse(response);
    }

    /**
     * Gets a named configuration.
     */
    async getNamedConfiguration(requestParameters: GetNamedConfigurationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Blob> {
        const response = await this.getNamedConfigurationRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Updates application configuration.
     */
    async updateConfigurationRaw(requestParameters: UpdateConfigurationOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.updateConfigurationRequest === null || requestParameters.updateConfigurationRequest === undefined) {
            throw new runtime.RequiredError('updateConfigurationRequest','Required parameter requestParameters.updateConfigurationRequest was null or undefined when calling updateConfiguration.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

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

        const response = await this.request({
            path: `/System/Configuration`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: UpdateConfigurationRequestToJSON(requestParameters.updateConfigurationRequest),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Updates application configuration.
     */
    async updateConfiguration(requestParameters: UpdateConfigurationOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.updateConfigurationRaw(requestParameters, initOverrides);
    }

    /**
     * Updates the path to the media encoder.
     */
    async updateMediaEncoderPathRaw(requestParameters: UpdateMediaEncoderPathOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.updateMediaEncoderPathRequest === null || requestParameters.updateMediaEncoderPathRequest === undefined) {
            throw new runtime.RequiredError('updateMediaEncoderPathRequest','Required parameter requestParameters.updateMediaEncoderPathRequest was null or undefined when calling updateMediaEncoderPath.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

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

        const response = await this.request({
            path: `/System/MediaEncoder/Path`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: UpdateMediaEncoderPathRequestToJSON(requestParameters.updateMediaEncoderPathRequest),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Updates the path to the media encoder.
     */
    async updateMediaEncoderPath(requestParameters: UpdateMediaEncoderPathOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.updateMediaEncoderPathRaw(requestParameters, initOverrides);
    }

    /**
     * Updates named configuration.
     */
    async updateNamedConfigurationRaw(requestParameters: UpdateNamedConfigurationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.key === null || requestParameters.key === undefined) {
            throw new runtime.RequiredError('key','Required parameter requestParameters.key was null or undefined when calling updateNamedConfiguration.');
        }

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

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

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

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

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Updates named configuration.
     */
    async updateNamedConfiguration(requestParameters: UpdateNamedConfigurationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.updateNamedConfigurationRaw(requestParameters, initOverrides);
    }

}
