/* tslint:disable */
/* eslint-disable */
/**
 * authentik
 * Making authentication simple.
 *
 * The version of the OpenAPI document: 2026.5.0-rc1
 * Contact: hello@goauthentik.io
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

import type {
    InstallID,
    License,
    LicenseForecast,
    LicenseRequest,
    LicenseSummary,
    PaginatedLicenseList,
    PatchedLicenseRequest,
    UsedBy,
} from "../models/index";
import {
    InstallIDFromJSON,
    LicenseForecastFromJSON,
    LicenseFromJSON,
    LicenseRequestToJSON,
    LicenseSummaryFromJSON,
    PaginatedLicenseListFromJSON,
    PatchedLicenseRequestToJSON,
    UsedByFromJSON,
} from "../models/index";
import * as runtime from "../runtime";

export interface EnterpriseLicenseCreateRequest {
    licenseRequest: LicenseRequest;
}

export interface EnterpriseLicenseDestroyRequest {
    licenseUuid: string;
}

export interface EnterpriseLicenseListRequest {
    name?: string;
    ordering?: string;
    page?: number;
    pageSize?: number;
    search?: string;
}

export interface EnterpriseLicensePartialUpdateRequest {
    licenseUuid: string;
    patchedLicenseRequest?: PatchedLicenseRequest;
}

export interface EnterpriseLicenseRetrieveRequest {
    licenseUuid: string;
}

export interface EnterpriseLicenseSummaryRetrieveRequest {
    cached?: boolean;
}

export interface EnterpriseLicenseUpdateRequest {
    licenseUuid: string;
    licenseRequest: LicenseRequest;
}

export interface EnterpriseLicenseUsedByListRequest {
    licenseUuid: string;
}

/**
 *
 */
export class EnterpriseApi extends runtime.BaseAPI {
    /**
     * Creates request options for enterpriseLicenseCreate without sending the request
     */
    async enterpriseLicenseCreateRequestOpts(
        requestParameters: EnterpriseLicenseCreateRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["licenseRequest"] == null) {
            throw new runtime.RequiredError(
                "licenseRequest",
                'Required parameter "licenseRequest" was null or undefined when calling enterpriseLicenseCreate().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/enterprise/license/`;

        return {
            path: urlPath,
            method: "POST",
            headers: headerParameters,
            query: queryParameters,
            body: LicenseRequestToJSON(requestParameters["licenseRequest"]),
        };
    }

    /**
     * License Viewset
     */
    async enterpriseLicenseCreateRaw(
        requestParameters: EnterpriseLicenseCreateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<License>> {
        const requestOptions = await this.enterpriseLicenseCreateRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * License Viewset
     */
    async enterpriseLicenseCreate(
        requestParameters: EnterpriseLicenseCreateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<License> {
        const response = await this.enterpriseLicenseCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for enterpriseLicenseDestroy without sending the request
     */
    async enterpriseLicenseDestroyRequestOpts(
        requestParameters: EnterpriseLicenseDestroyRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["licenseUuid"] == null) {
            throw new runtime.RequiredError(
                "licenseUuid",
                'Required parameter "licenseUuid" was null or undefined when calling enterpriseLicenseDestroy().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/enterprise/license/{license_uuid}/`;
        urlPath = urlPath.replace(
            `{${"license_uuid"}}`,
            encodeURIComponent(String(requestParameters["licenseUuid"])),
        );

        return {
            path: urlPath,
            method: "DELETE",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * License Viewset
     */
    async enterpriseLicenseDestroyRaw(
        requestParameters: EnterpriseLicenseDestroyRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<void>> {
        const requestOptions = await this.enterpriseLicenseDestroyRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * License Viewset
     */
    async enterpriseLicenseDestroy(
        requestParameters: EnterpriseLicenseDestroyRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<void> {
        await this.enterpriseLicenseDestroyRaw(requestParameters, initOverrides);
    }

    /**
     * Creates request options for enterpriseLicenseForecastRetrieve without sending the request
     */
    async enterpriseLicenseForecastRetrieveRequestOpts(): Promise<runtime.RequestOpts> {
        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/enterprise/license/forecast/`;

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Forecast how many users will be required in a year
     */
    async enterpriseLicenseForecastRetrieveRaw(
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<LicenseForecast>> {
        const requestOptions = await this.enterpriseLicenseForecastRetrieveRequestOpts();
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * Forecast how many users will be required in a year
     */
    async enterpriseLicenseForecastRetrieve(
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<LicenseForecast> {
        const response = await this.enterpriseLicenseForecastRetrieveRaw(initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for enterpriseLicenseInstallIdRetrieve without sending the request
     */
    async enterpriseLicenseInstallIdRetrieveRequestOpts(): Promise<runtime.RequestOpts> {
        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/enterprise/license/install_id/`;

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Get install_id
     */
    async enterpriseLicenseInstallIdRetrieveRaw(
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<InstallID>> {
        const requestOptions = await this.enterpriseLicenseInstallIdRetrieveRequestOpts();
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * Get install_id
     */
    async enterpriseLicenseInstallIdRetrieve(
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<InstallID> {
        const response = await this.enterpriseLicenseInstallIdRetrieveRaw(initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for enterpriseLicenseList without sending the request
     */
    async enterpriseLicenseListRequestOpts(
        requestParameters: EnterpriseLicenseListRequest,
    ): Promise<runtime.RequestOpts> {
        const queryParameters: any = {};

        if (requestParameters["name"] != null) {
            queryParameters["name"] = requestParameters["name"];
        }

        if (requestParameters["ordering"] != null) {
            queryParameters["ordering"] = requestParameters["ordering"];
        }

        if (requestParameters["page"] != null) {
            queryParameters["page"] = requestParameters["page"];
        }

        if (requestParameters["pageSize"] != null) {
            queryParameters["page_size"] = requestParameters["pageSize"];
        }

        if (requestParameters["search"] != null) {
            queryParameters["search"] = requestParameters["search"];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/enterprise/license/`;

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * License Viewset
     */
    async enterpriseLicenseListRaw(
        requestParameters: EnterpriseLicenseListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<PaginatedLicenseList>> {
        const requestOptions = await this.enterpriseLicenseListRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * License Viewset
     */
    async enterpriseLicenseList(
        requestParameters: EnterpriseLicenseListRequest = {},
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<PaginatedLicenseList> {
        const response = await this.enterpriseLicenseListRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for enterpriseLicensePartialUpdate without sending the request
     */
    async enterpriseLicensePartialUpdateRequestOpts(
        requestParameters: EnterpriseLicensePartialUpdateRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["licenseUuid"] == null) {
            throw new runtime.RequiredError(
                "licenseUuid",
                'Required parameter "licenseUuid" was null or undefined when calling enterpriseLicensePartialUpdate().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/enterprise/license/{license_uuid}/`;
        urlPath = urlPath.replace(
            `{${"license_uuid"}}`,
            encodeURIComponent(String(requestParameters["licenseUuid"])),
        );

        return {
            path: urlPath,
            method: "PATCH",
            headers: headerParameters,
            query: queryParameters,
            body: PatchedLicenseRequestToJSON(requestParameters["patchedLicenseRequest"]),
        };
    }

    /**
     * License Viewset
     */
    async enterpriseLicensePartialUpdateRaw(
        requestParameters: EnterpriseLicensePartialUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<License>> {
        const requestOptions =
            await this.enterpriseLicensePartialUpdateRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * License Viewset
     */
    async enterpriseLicensePartialUpdate(
        requestParameters: EnterpriseLicensePartialUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<License> {
        const response = await this.enterpriseLicensePartialUpdateRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

    /**
     * Creates request options for enterpriseLicenseRetrieve without sending the request
     */
    async enterpriseLicenseRetrieveRequestOpts(
        requestParameters: EnterpriseLicenseRetrieveRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["licenseUuid"] == null) {
            throw new runtime.RequiredError(
                "licenseUuid",
                'Required parameter "licenseUuid" was null or undefined when calling enterpriseLicenseRetrieve().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/enterprise/license/{license_uuid}/`;
        urlPath = urlPath.replace(
            `{${"license_uuid"}}`,
            encodeURIComponent(String(requestParameters["licenseUuid"])),
        );

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * License Viewset
     */
    async enterpriseLicenseRetrieveRaw(
        requestParameters: EnterpriseLicenseRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<License>> {
        const requestOptions = await this.enterpriseLicenseRetrieveRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * License Viewset
     */
    async enterpriseLicenseRetrieve(
        requestParameters: EnterpriseLicenseRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<License> {
        const response = await this.enterpriseLicenseRetrieveRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for enterpriseLicenseSummaryRetrieve without sending the request
     */
    async enterpriseLicenseSummaryRetrieveRequestOpts(
        requestParameters: EnterpriseLicenseSummaryRetrieveRequest,
    ): Promise<runtime.RequestOpts> {
        const queryParameters: any = {};

        if (requestParameters["cached"] != null) {
            queryParameters["cached"] = requestParameters["cached"];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/enterprise/license/summary/`;

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Get the total license status
     */
    async enterpriseLicenseSummaryRetrieveRaw(
        requestParameters: EnterpriseLicenseSummaryRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<LicenseSummary>> {
        const requestOptions =
            await this.enterpriseLicenseSummaryRetrieveRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * Get the total license status
     */
    async enterpriseLicenseSummaryRetrieve(
        requestParameters: EnterpriseLicenseSummaryRetrieveRequest = {},
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<LicenseSummary> {
        const response = await this.enterpriseLicenseSummaryRetrieveRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

    /**
     * Creates request options for enterpriseLicenseUpdate without sending the request
     */
    async enterpriseLicenseUpdateRequestOpts(
        requestParameters: EnterpriseLicenseUpdateRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["licenseUuid"] == null) {
            throw new runtime.RequiredError(
                "licenseUuid",
                'Required parameter "licenseUuid" was null or undefined when calling enterpriseLicenseUpdate().',
            );
        }

        if (requestParameters["licenseRequest"] == null) {
            throw new runtime.RequiredError(
                "licenseRequest",
                'Required parameter "licenseRequest" was null or undefined when calling enterpriseLicenseUpdate().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/enterprise/license/{license_uuid}/`;
        urlPath = urlPath.replace(
            `{${"license_uuid"}}`,
            encodeURIComponent(String(requestParameters["licenseUuid"])),
        );

        return {
            path: urlPath,
            method: "PUT",
            headers: headerParameters,
            query: queryParameters,
            body: LicenseRequestToJSON(requestParameters["licenseRequest"]),
        };
    }

    /**
     * License Viewset
     */
    async enterpriseLicenseUpdateRaw(
        requestParameters: EnterpriseLicenseUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<License>> {
        const requestOptions = await this.enterpriseLicenseUpdateRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * License Viewset
     */
    async enterpriseLicenseUpdate(
        requestParameters: EnterpriseLicenseUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<License> {
        const response = await this.enterpriseLicenseUpdateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for enterpriseLicenseUsedByList without sending the request
     */
    async enterpriseLicenseUsedByListRequestOpts(
        requestParameters: EnterpriseLicenseUsedByListRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["licenseUuid"] == null) {
            throw new runtime.RequiredError(
                "licenseUuid",
                'Required parameter "licenseUuid" was null or undefined when calling enterpriseLicenseUsedByList().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/enterprise/license/{license_uuid}/used_by/`;
        urlPath = urlPath.replace(
            `{${"license_uuid"}}`,
            encodeURIComponent(String(requestParameters["licenseUuid"])),
        );

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Get a list of all objects that use this object
     */
    async enterpriseLicenseUsedByListRaw(
        requestParameters: EnterpriseLicenseUsedByListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Array<UsedBy>>> {
        const requestOptions = await this.enterpriseLicenseUsedByListRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * Get a list of all objects that use this object
     */
    async enterpriseLicenseUsedByList(
        requestParameters: EnterpriseLicenseUsedByListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Array<UsedBy>> {
        const response = await this.enterpriseLicenseUsedByListRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }
}
