/* 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 {
  AddMediaPathRequest,
  AddVirtualFolderRequest,
  CollectionTypeOptions,
  ProblemDetails,
  UpdateLibraryOptionsRequest,
  UpdateMediaPathRequest,
  VirtualFolderInfo,
} from '../models';
import {
    AddMediaPathRequestFromJSON,
    AddMediaPathRequestToJSON,
    AddVirtualFolderRequestFromJSON,
    AddVirtualFolderRequestToJSON,
    CollectionTypeOptionsFromJSON,
    CollectionTypeOptionsToJSON,
    ProblemDetailsFromJSON,
    ProblemDetailsToJSON,
    UpdateLibraryOptionsRequestFromJSON,
    UpdateLibraryOptionsRequestToJSON,
    UpdateMediaPathRequestFromJSON,
    UpdateMediaPathRequestToJSON,
    VirtualFolderInfoFromJSON,
    VirtualFolderInfoToJSON,
} from '../models';

export interface AddMediaPathOperationRequest {
    addMediaPathRequest: AddMediaPathRequest;
    refreshLibrary?: boolean;
}

export interface AddVirtualFolderOperationRequest {
    name?: string;
    collectionType?: CollectionTypeOptions;
    paths?: Array<string>;
    refreshLibrary?: boolean;
    addVirtualFolderRequest?: AddVirtualFolderRequest;
}

export interface RemoveMediaPathRequest {
    name?: string;
    path?: string;
    refreshLibrary?: boolean;
}

export interface RemoveVirtualFolderRequest {
    name?: string;
    refreshLibrary?: boolean;
}

export interface RenameVirtualFolderRequest {
    name?: string;
    newName?: string;
    refreshLibrary?: boolean;
}

export interface UpdateLibraryOptionsOperationRequest {
    updateLibraryOptionsRequest?: UpdateLibraryOptionsRequest;
}

export interface UpdateMediaPathOperationRequest {
    updateMediaPathRequest: UpdateMediaPathRequest;
}

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

    /**
     * Add a media path to a library.
     */
    async addMediaPathRaw(requestParameters: AddMediaPathOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.addMediaPathRequest === null || requestParameters.addMediaPathRequest === undefined) {
            throw new runtime.RequiredError('addMediaPathRequest','Required parameter requestParameters.addMediaPathRequest was null or undefined when calling addMediaPath.');
        }

        const queryParameters: any = {};

        if (requestParameters.refreshLibrary !== undefined) {
            queryParameters['refreshLibrary'] = requestParameters.refreshLibrary;
        }

        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: `/Library/VirtualFolders/Paths`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: AddMediaPathRequestToJSON(requestParameters.addMediaPathRequest),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Add a media path to a library.
     */
    async addMediaPath(requestParameters: AddMediaPathOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.addMediaPathRaw(requestParameters, initOverrides);
    }

    /**
     * Adds a virtual folder.
     */
    async addVirtualFolderRaw(requestParameters: AddVirtualFolderOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        const queryParameters: any = {};

        if (requestParameters.name !== undefined) {
            queryParameters['name'] = requestParameters.name;
        }

        if (requestParameters.collectionType !== undefined) {
            queryParameters['collectionType'] = requestParameters.collectionType;
        }

        if (requestParameters.paths) {
            queryParameters['paths'] = requestParameters.paths;
        }

        if (requestParameters.refreshLibrary !== undefined) {
            queryParameters['refreshLibrary'] = requestParameters.refreshLibrary;
        }

        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: `/Library/VirtualFolders`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: AddVirtualFolderRequestToJSON(requestParameters.addVirtualFolderRequest),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Adds a virtual folder.
     */
    async addVirtualFolder(requestParameters: AddVirtualFolderOperationRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.addVirtualFolderRaw(requestParameters, initOverrides);
    }

    /**
     * Gets all virtual folders.
     */
    async getVirtualFoldersRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<VirtualFolderInfo>>> {
        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: `/Library/VirtualFolders`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * Gets all virtual folders.
     */
    async getVirtualFolders(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<VirtualFolderInfo>> {
        const response = await this.getVirtualFoldersRaw(initOverrides);
        return await response.value();
    }

    /**
     * Remove a media path.
     */
    async removeMediaPathRaw(requestParameters: RemoveMediaPathRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        const queryParameters: any = {};

        if (requestParameters.name !== undefined) {
            queryParameters['name'] = requestParameters.name;
        }

        if (requestParameters.path !== undefined) {
            queryParameters['path'] = requestParameters.path;
        }

        if (requestParameters.refreshLibrary !== undefined) {
            queryParameters['refreshLibrary'] = requestParameters.refreshLibrary;
        }

        const headerParameters: runtime.HTTPHeaders = {};

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

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

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Remove a media path.
     */
    async removeMediaPath(requestParameters: RemoveMediaPathRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.removeMediaPathRaw(requestParameters, initOverrides);
    }

    /**
     * Removes a virtual folder.
     */
    async removeVirtualFolderRaw(requestParameters: RemoveVirtualFolderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        const queryParameters: any = {};

        if (requestParameters.name !== undefined) {
            queryParameters['name'] = requestParameters.name;
        }

        if (requestParameters.refreshLibrary !== undefined) {
            queryParameters['refreshLibrary'] = requestParameters.refreshLibrary;
        }

        const headerParameters: runtime.HTTPHeaders = {};

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

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

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Removes a virtual folder.
     */
    async removeVirtualFolder(requestParameters: RemoveVirtualFolderRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.removeVirtualFolderRaw(requestParameters, initOverrides);
    }

    /**
     * Renames a virtual folder.
     */
    async renameVirtualFolderRaw(requestParameters: RenameVirtualFolderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        const queryParameters: any = {};

        if (requestParameters.name !== undefined) {
            queryParameters['name'] = requestParameters.name;
        }

        if (requestParameters.newName !== undefined) {
            queryParameters['newName'] = requestParameters.newName;
        }

        if (requestParameters.refreshLibrary !== undefined) {
            queryParameters['refreshLibrary'] = requestParameters.refreshLibrary;
        }

        const headerParameters: runtime.HTTPHeaders = {};

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

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

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Renames a virtual folder.
     */
    async renameVirtualFolder(requestParameters: RenameVirtualFolderRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.renameVirtualFolderRaw(requestParameters, initOverrides);
    }

    /**
     * Update library options.
     */
    async updateLibraryOptionsRaw(requestParameters: UpdateLibraryOptionsOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        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: `/Library/VirtualFolders/LibraryOptions`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: UpdateLibraryOptionsRequestToJSON(requestParameters.updateLibraryOptionsRequest),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Update library options.
     */
    async updateLibraryOptions(requestParameters: UpdateLibraryOptionsOperationRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.updateLibraryOptionsRaw(requestParameters, initOverrides);
    }

    /**
     * Updates a media path.
     */
    async updateMediaPathRaw(requestParameters: UpdateMediaPathOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.updateMediaPathRequest === null || requestParameters.updateMediaPathRequest === undefined) {
            throw new runtime.RequiredError('updateMediaPathRequest','Required parameter requestParameters.updateMediaPathRequest was null or undefined when calling updateMediaPath.');
        }

        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: `/Library/VirtualFolders/Paths/Update`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: UpdateMediaPathRequestToJSON(requestParameters.updateMediaPathRequest),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Updates a media path.
     */
    async updateMediaPath(requestParameters: UpdateMediaPathOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.updateMediaPathRaw(requestParameters, initOverrides);
    }

}
